Merge lp:~widelands-dev/widelands/bug-1562071-rendering_issues into lp:widelands

Proposed by Miroslav Remák
Status: Merged
Merged at revision: 7912
Proposed branch: lp:~widelands-dev/widelands/bug-1562071-rendering_issues
Merge into: lp:widelands
Diff against target: 167 lines (+33/-12)
10 files modified
src/graphic/blend_mode.h (+6/-0)
src/graphic/gl/fill_rect_program.cc (+6/-0)
src/graphic/gl/utils.cc (+10/-0)
src/graphic/gl/utils.h (+2/-0)
src/graphic/rendertarget.cc (+2/-2)
src/graphic/rendertarget.h (+1/-1)
src/graphic/surface.cc (+2/-2)
src/graphic/surface.h (+2/-3)
src/graphic/texture.cc (+1/-2)
src/wui/chatoverlay.cc (+1/-2)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1562071-rendering_issues
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+290183@code.launchpad.net

Description of the change

Fixes bug #1562071 as well as chat overlay transparency.

To post a comment you must log in.
Revision history for this message
GunChleoc (gunchleoc) wrote :

LGTM :)

review: Approve
Revision history for this message
GunChleoc (gunchleoc) wrote :

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/graphic/blend_mode.h'
2--- src/graphic/blend_mode.h 2015-01-27 08:09:56 +0000
3+++ src/graphic/blend_mode.h 2016-03-27 21:17:15 +0000
4@@ -22,6 +22,12 @@
5
6 // Defines blending during blitting.
7 enum class BlendMode {
8+ // Normal blending, equivalent to:
9+ // glEnable(GL_BLEND);
10+ // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
11+ // glBlendEquation(GL_FUNC_ADD);
12+ Default,
13+
14 // Perform a normal blitting operation that respects the alpha channel if
15 // present.
16 UseAlpha,
17
18=== modified file 'src/graphic/gl/fill_rect_program.cc'
19--- src/graphic/gl/fill_rect_program.cc 2016-02-01 10:24:34 +0000
20+++ src/graphic/gl/fill_rect_program.cc 2016-03-27 21:17:15 +0000
21@@ -74,6 +74,9 @@
22 case BlendMode::Copy:
23 glDisable(GL_BLEND);
24 break;
25+
26+ default:
27+ break;
28 }
29
30 glUseProgram(gl_program_.object());
31@@ -164,6 +167,9 @@
32 case BlendMode::Copy:
33 glEnable(GL_BLEND);
34 break;
35+
36+ default:
37+ break;
38 }
39 }
40 }
41
42=== modified file 'src/graphic/gl/utils.cc'
43--- src/graphic/gl/utils.cc 2016-02-06 20:55:15 +0000
44+++ src/graphic/gl/utils.cc 2016-03-27 21:17:15 +0000
45@@ -204,6 +204,16 @@
46 }
47 }
48
49+void State::delete_texture(const GLuint texture)
50+{
51+ unbind_texture_if_bound(texture);
52+ glDeleteTextures(1, &texture);
53+
54+ if (current_framebuffer_texture_ == texture) {
55+ current_framebuffer_texture_ = 0;
56+ }
57+}
58+
59 void State::bind_framebuffer(const GLuint framebuffer, const GLuint texture) {
60 if (current_framebuffer_ == framebuffer && current_framebuffer_texture_ == texture) {
61 return;
62
63=== modified file 'src/graphic/gl/utils.h'
64--- src/graphic/gl/utils.h 2016-03-14 19:49:52 +0000
65+++ src/graphic/gl/utils.h 2016-03-27 21:17:15 +0000
66@@ -121,6 +121,8 @@
67 // needed before the texture is used as target for rendering.
68 void unbind_texture_if_bound(GLuint texture);
69
70+ void delete_texture(GLuint texture);
71+
72 // Calls glEnableVertexAttribArray on all 'entries' and disables all others
73 // that are activated. 'entries' is taken by value on purpose.
74 void enable_vertex_attrib_array(std::unordered_set<GLint> entries);
75
76=== modified file 'src/graphic/rendertarget.cc'
77--- src/graphic/rendertarget.cc 2016-03-14 19:49:52 +0000
78+++ src/graphic/rendertarget.cc 2016-03-27 21:17:15 +0000
79@@ -133,11 +133,11 @@
80 }
81 }
82
83-void RenderTarget::fill_rect(const Rect& rect, const RGBAColor& clr)
84+void RenderTarget::fill_rect(const Rect& rect, const RGBAColor& clr, BlendMode blend_mode)
85 {
86 Rect r(rect);
87 if (clip(r))
88- surface_->fill_rect(r, clr);
89+ surface_->fill_rect(r, clr, blend_mode);
90 }
91
92 void RenderTarget::brighten_rect(const Rect& rect, int32_t factor)
93
94=== modified file 'src/graphic/rendertarget.h'
95--- src/graphic/rendertarget.h 2016-03-14 19:49:52 +0000
96+++ src/graphic/rendertarget.h 2016-03-27 21:17:15 +0000
97@@ -61,7 +61,7 @@
98 const RGBColor& color,
99 float width);
100 void draw_rect(const Rect&, const RGBColor&);
101- void fill_rect(const Rect&, const RGBAColor&);
102+ void fill_rect(const Rect&, const RGBAColor&, BlendMode blend_mode = BlendMode::Copy);
103 void brighten_rect(const Rect&, int32_t factor);
104
105 void blit(const Point& dst,
106
107=== modified file 'src/graphic/surface.cc'
108--- src/graphic/surface.cc 2016-03-08 09:38:16 +0000
109+++ src/graphic/surface.cc 2016-03-27 21:17:15 +0000
110@@ -111,9 +111,9 @@
111
112 } // namespace
113
114-void Surface::fill_rect(const Rect& rc, const RGBAColor& clr) {
115+void Surface::fill_rect(const Rect& rc, const RGBAColor& clr, BlendMode blend_mode) {
116 const FloatRect rect = rect_to_gl_renderbuffer(width(), height(), rc);
117- do_fill_rect(rect, clr, BlendMode::Copy);
118+ do_fill_rect(rect, clr, blend_mode);
119 }
120
121 void Surface::brighten_rect(const Rect& rc, const int32_t factor)
122
123=== modified file 'src/graphic/surface.h'
124--- src/graphic/surface.h 2016-02-19 19:10:44 +0000
125+++ src/graphic/surface.h 2016-03-27 21:17:15 +0000
126@@ -61,9 +61,8 @@
127 void
128 blit_monochrome(const Rect& dst, const Image&, const Rect& srcrc, const RGBAColor& multiplier);
129
130- /// Draws a filled rect to the destination. No blending takes place, the values
131- // in the target are just replaced (i.e. / BlendMode would be BlendMode::Copy).
132- void fill_rect(const Rect&, const RGBAColor&);
133+ /// Draws a filled rect to the destination.
134+ void fill_rect(const Rect&, const RGBAColor&, BlendMode blend_mode = BlendMode::Copy);
135
136 // Draw a 'width' pixel wide line to the destination. 'points' are taken by
137 // value on purpose.
138
139=== modified file 'src/graphic/texture.cc'
140--- src/graphic/texture.cc 2016-03-19 11:47:00 +0000
141+++ src/graphic/texture.cc 2016-03-27 21:17:15 +0000
142@@ -170,8 +170,7 @@
143 Texture::~Texture()
144 {
145 if (owns_texture_) {
146- Gl::State::instance().unbind_texture_if_bound(blit_data_.texture_id);
147- glDeleteTextures(1, &blit_data_.texture_id);
148+ Gl::State::instance().delete_texture(blit_data_.texture_id);
149 }
150 }
151
152
153=== modified file 'src/wui/chatoverlay.cc'
154--- src/wui/chatoverlay.cc 2016-02-25 08:47:48 +0000
155+++ src/wui/chatoverlay.cc 2016-03-27 21:17:15 +0000
156@@ -193,10 +193,9 @@
157 const int32_t top = get_h() - height - 2 * MARGIN;
158 const int width = std::min<int>(get_w(), im->width());
159
160- // TODO(unknown): alpha channel not respected
161 if (!m->transparent_) {
162 Rect rect(0, top, width, height);
163- dst.fill_rect(rect, RGBAColor(50, 50, 50, 128));
164+ dst.fill_rect(rect, RGBAColor(50, 50, 50, 128), BlendMode::Default);
165 }
166 int32_t topcrop = im->height() - height;
167 Rect cropRect(0, topcrop, width, height);

Subscribers

People subscribed via source and target branches

to status/vote changes: