Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(883)

Side by Side Diff: gles/opengles_visitor.cc

Issue 3599002: wm: Add two pass rendering to OpenGL|ES backend. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/window_manager.git
Patch Set: final. Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gles/opengles_visitor.h ('k') | gles/real_gles2_interface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "window_manager/gles/opengles_visitor.h" 5 #include "window_manager/gles/opengles_visitor.h"
6 6
7 #include <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 #include <xcb/damage.h> 8 #include <xcb/damage.h>
9 9
10 #include <EGL/egl.h> 10 #include <EGL/egl.h>
(...skipping 15 matching lines...) Expand all
26 // Work around broken eglext.h headers 26 // Work around broken eglext.h headers
27 #ifndef EGL_NO_IMAGE_KHR 27 #ifndef EGL_NO_IMAGE_KHR
28 #define EGL_NO_IMAGE_KHR (static_cast<EGLImageKHR>(0)) 28 #define EGL_NO_IMAGE_KHR (static_cast<EGLImageKHR>(0))
29 #endif 29 #endif
30 #ifndef EGL_IMAGE_PRESERVED_KHR 30 #ifndef EGL_IMAGE_PRESERVED_KHR
31 #define EGL_IMAGE_PRESERVED_KHR 0x30D2 31 #define EGL_IMAGE_PRESERVED_KHR 0x30D2
32 #endif 32 #endif
33 33
34 namespace window_manager { 34 namespace window_manager {
35 35
36 // Base for rendering passes.
37 class BasePass : virtual public RealCompositor::ActorVisitor {
38 public:
39 explicit BasePass(const OpenGlesDrawVisitor* gles_visitor)
40 : gles_visitor_(gles_visitor) {}
41 virtual ~BasePass() {}
42 virtual void VisitActor(RealCompositor::Actor* actor) {}
43 virtual void VisitContainer(RealCompositor::ContainerActor* actor) = 0;
44 virtual void VisitTexturePixmap(RealCompositor::TexturePixmapActor* actor);
45 virtual void VisitQuad(RealCompositor::QuadActor* actor) = 0;
46 virtual void VisitImage(RealCompositor::ImageActor* actor) {
47 VisitQuad(actor);
48 }
49
50 protected:
51 const OpenGlesDrawVisitor* gles_visitor() const { return gles_visitor_; }
52
53 private:
54 const OpenGlesDrawVisitor* gles_visitor_; // Not owned.
55
56 DISALLOW_COPY_AND_ASSIGN(BasePass);
57 };
58
59 // Back to front pass with blending on.
60 class TransparentPass : public BasePass {
61 public:
62 explicit TransparentPass(const OpenGlesDrawVisitor* gles_visitor)
63 : BasePass(gles_visitor) {}
64 virtual ~TransparentPass() {}
65 virtual void VisitStage(RealCompositor::StageActor* actor);
66 virtual void VisitContainer(RealCompositor::ContainerActor* actor);
67 virtual void VisitQuad(RealCompositor::QuadActor* actor) {
68 gles_visitor()->DrawQuad(actor, ancestor_opacity_);
69 }
70
71 private:
72 // Cumulative opacity of the ancestors
73 float ancestor_opacity_;
74
75 DISALLOW_COPY_AND_ASSIGN(TransparentPass);
76 };
77
78 // Front to back pass with blending off.
79 class OpaquePass : public BasePass {
80 public:
81 explicit OpaquePass(const OpenGlesDrawVisitor* gles_visitor)
82 : BasePass(gles_visitor) {}
83 virtual ~OpaquePass() {}
84 virtual void VisitContainer(RealCompositor::ContainerActor* actor);
85 virtual void VisitQuad(RealCompositor::QuadActor* actor) {
86 gles_visitor()->DrawQuad(actor, 1.f);
87 }
88
89 private:
90 DISALLOW_COPY_AND_ASSIGN(OpaquePass);
91 };
92
36 OpenGlesDrawVisitor::OpenGlesDrawVisitor(Gles2Interface* gl, 93 OpenGlesDrawVisitor::OpenGlesDrawVisitor(Gles2Interface* gl,
37 RealCompositor* compositor, 94 RealCompositor* compositor,
38 Compositor::StageActor* stage) 95 Compositor::StageActor* stage)
39 : gl_(gl), 96 : gl_(gl),
40 compositor_(compositor), 97 compositor_(compositor),
41 stage_(stage), 98 stage_(stage),
42 x_connection_(compositor_->x_conn()), 99 x_connection_(compositor_->x_conn()),
43 has_fullscreen_actor_(false) { 100 has_fullscreen_actor_(false) {
44 CHECK(gl_); 101 CHECK(gl_);
45 egl_display_ = gl_->egl_display(); 102 egl_display_ = gl_->egl_display();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 gl_->GenBuffers(1, &vertex_buffer_object_); 149 gl_->GenBuffers(1, &vertex_buffer_object_);
93 CHECK(vertex_buffer_object_ > 0) << "VBO allocation failed."; 150 CHECK(vertex_buffer_object_ > 0) << "VBO allocation failed.";
94 gl_->BindBuffer(GL_ARRAY_BUFFER, vertex_buffer_object_); 151 gl_->BindBuffer(GL_ARRAY_BUFFER, vertex_buffer_object_);
95 static float kQuad[] = { 152 static float kQuad[] = {
96 0.f, 0.f, 153 0.f, 0.f,
97 0.f, 1.f, 154 0.f, 1.f,
98 1.f, 0.f, 155 1.f, 0.f,
99 1.f, 1.f, 156 1.f, 1.f,
100 }; 157 };
101 gl_->BufferData(GL_ARRAY_BUFFER, sizeof(kQuad), kQuad, GL_STATIC_DRAW); 158 gl_->BufferData(GL_ARRAY_BUFFER, sizeof(kQuad), kQuad, GL_STATIC_DRAW);
159
160 // Unchanging state
161 gl_->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
162 gl_->Enable(GL_DEPTH_TEST);
102 } 163 }
103 164
104 OpenGlesDrawVisitor::~OpenGlesDrawVisitor() { 165 OpenGlesDrawVisitor::~OpenGlesDrawVisitor() {
105 delete tex_color_shader_; 166 delete tex_color_shader_;
106 delete tex_shade_shader_; 167 delete tex_shade_shader_;
107 delete no_alpha_color_shader_; 168 delete no_alpha_color_shader_;
108 delete no_alpha_shade_shader_; 169 delete no_alpha_shade_shader_;
109 170
110 gl_->DeleteBuffers(1, &vertex_buffer_object_); 171 gl_->DeleteBuffers(1, &vertex_buffer_object_);
111 172
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 actor->unset_was_resized(); 240 actor->unset_was_resized();
180 } 241 }
181 242
182 // No need to clear color buffer if something will cover up the screen. 243 // No need to clear color buffer if something will cover up the screen.
183 if (has_fullscreen_actor_) 244 if (has_fullscreen_actor_)
184 gl_->Clear(GL_DEPTH_BUFFER_BIT); 245 gl_->Clear(GL_DEPTH_BUFFER_BIT);
185 else 246 else
186 gl_->Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 247 gl_->Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
187 248
188 projection_ = actor->projection(); 249 projection_ = actor->projection();
189 ancestor_opacity_ = actor->opacity();
190 250
191 // Back to front rendering 251 // Front to back opaque rendering pass
192 // TODO: Switch to two pass Z-buffered rendering 252 OpaquePass opaque_pass(this);
193 gl_->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 253 actor->Accept(&opaque_pass);
254
255 // Back to front rendering transparent pass
194 gl_->Enable(GL_BLEND); 256 gl_->Enable(GL_BLEND);
195 257 gl_->DepthMask(GL_FALSE);
196 // Back to front rendering 258 TransparentPass transparent_pass(this);
197 const RealCompositor::ActorVector children = actor->GetChildren(); 259 actor->Accept(&transparent_pass);
198 for (RealCompositor::ActorVector::const_reverse_iterator i = 260 gl_->DepthMask(GL_TRUE);
199 children.rbegin(); i != children.rend(); ++i) { 261 gl_->Disable(GL_BLEND);
200 (*i)->Accept(this);
201 }
202 262
203 gl_->EglSwapBuffers(egl_display_, egl_surface_); 263 gl_->EglSwapBuffers(egl_display_, egl_surface_);
204 } 264 }
205 265
206 void OpenGlesDrawVisitor::VisitTexturePixmap( 266 void OpenGlesDrawVisitor::CreateTextureData(
267 RealCompositor::TexturePixmapActor* actor) const {
268 OpenGlesEglImageData image_data(gl_);
269
270 if (!image_data.Bind(actor))
271 return;
272
273 OpenGlesTextureData* texture = new OpenGlesTextureData(gl_);
274 image_data.BindTexture(texture, !actor->pixmap_is_opaque());
275 actor->set_texture_data(texture);
276 }
277
278 void BasePass::VisitTexturePixmap(
207 RealCompositor::TexturePixmapActor* actor) { 279 RealCompositor::TexturePixmapActor* actor) {
208 if (!actor->IsVisible()) 280 if (!actor->IsVisible())
209 return; 281 return;
210 282
211 if (!actor->texture_data()) { 283 if (!actor->texture_data())
212 OpenGlesEglImageData image_data(gl_); 284 gles_visitor_->CreateTextureData(actor);
213
214 if (!image_data.Bind(actor))
215 return;
216
217 OpenGlesTextureData* texture = new OpenGlesTextureData(gl_);
218 image_data.BindTexture(texture, !actor->pixmap_is_opaque());
219 actor->set_texture_data(texture);
220 }
221 285
222 VisitQuad(actor); 286 VisitQuad(actor);
223 } 287 }
224 288
225 void OpenGlesDrawVisitor::VisitQuad(RealCompositor::QuadActor* actor) { 289 void TransparentPass::VisitStage(RealCompositor::StageActor* actor) {
290 ancestor_opacity_ = actor->opacity();
291 VisitContainer(actor);
292 }
293
294 void OpenGlesDrawVisitor::DrawQuad(RealCompositor::QuadActor* actor,
295 float ancestor_opacity) const {
226 if (!actor->IsVisible()) 296 if (!actor->IsVisible())
227 return; 297 return;
228 298
229 // This must live until after the draw call, so it's at the top level 299 // This must live until after the draw call, so it's at the top level
230 scoped_array<float> colors; 300 GLfloat colors[4 * 4];
231 301
232 // mvp matrix 302 // mvp matrix
233 Matrix4 mvp = projection_ * actor->model_view(); 303 Matrix4 mvp = projection_ * actor->model_view();
234 304
235 // texture 305 // texture
236 TextureData* texture_data = actor->texture_data(); 306 TextureData* texture_data = actor->texture_data();
237 gl_->BindTexture(GL_TEXTURE_2D, 307 gl_->BindTexture(GL_TEXTURE_2D,
238 texture_data ? texture_data->texture() : 0); 308 texture_data ? texture_data->texture() : 0);
239 const bool texture_has_alpha = texture_data ? 309 const bool texture_has_alpha = texture_data ?
240 texture_data->has_alpha() : 310 texture_data->has_alpha() :
241 true; 311 true;
242 312
243 // shader 313 // shader
244 if (actor->dimmed_opacity_begin() == 0.f && 314 if (actor->dimmed_opacity_begin() == 0.f &&
245 actor->dimmed_opacity_end() == 0.f) { 315 actor->dimmed_opacity_end() == 0.f) {
246 if (texture_has_alpha) { 316 if (texture_has_alpha) {
247 gl_->UseProgram(tex_color_shader_->program()); 317 gl_->UseProgram(tex_color_shader_->program());
248 gl_->UniformMatrix4fv(tex_color_shader_->MvpLocation(), 1, GL_FALSE, 318 gl_->UniformMatrix4fv(tex_color_shader_->MvpLocation(), 1, GL_FALSE,
249 &mvp[0][0]); 319 &mvp[0][0]);
250 gl_->Uniform1i(tex_color_shader_->SamplerLocation(), 0); 320 gl_->Uniform1i(tex_color_shader_->SamplerLocation(), 0);
251 gl_->Uniform4f(tex_color_shader_->ColorLocation(), actor->color().red, 321 gl_->Uniform4f(tex_color_shader_->ColorLocation(), actor->color().red,
252 actor->color().green, actor->color().blue, 322 actor->color().green, actor->color().blue,
253 actor->opacity() * ancestor_opacity_); 323 actor->opacity() * ancestor_opacity);
254 324
255 gl_->BindBuffer(GL_ARRAY_BUFFER, vertex_buffer_object_); 325 gl_->BindBuffer(GL_ARRAY_BUFFER, vertex_buffer_object_);
256 gl_->VertexAttribPointer(tex_color_shader_->PosLocation(), 326 gl_->VertexAttribPointer(tex_color_shader_->PosLocation(),
257 2, GL_FLOAT, GL_FALSE, 0, 0); 327 2, GL_FLOAT, GL_FALSE, 0, 0);
258 gl_->VertexAttribPointer(tex_color_shader_->TexInLocation(), 328 gl_->VertexAttribPointer(tex_color_shader_->TexInLocation(),
259 2, GL_FLOAT, GL_FALSE, 0, 0); 329 2, GL_FLOAT, GL_FALSE, 0, 0);
260 tex_color_shader_->EnableVertexAttribs(); 330 tex_color_shader_->EnableVertexAttribs();
261 } else { 331 } else {
262 gl_->UseProgram(no_alpha_color_shader_->program()); 332 gl_->UseProgram(no_alpha_color_shader_->program());
263 gl_->UniformMatrix4fv(no_alpha_color_shader_->MvpLocation(), 1, GL_FALSE, 333 gl_->UniformMatrix4fv(no_alpha_color_shader_->MvpLocation(), 1, GL_FALSE,
264 &mvp[0][0]); 334 &mvp[0][0]);
265 gl_->Uniform1i(no_alpha_color_shader_->SamplerLocation(), 0); 335 gl_->Uniform1i(no_alpha_color_shader_->SamplerLocation(), 0);
266 gl_->Uniform4f(no_alpha_color_shader_->ColorLocation(), 336 gl_->Uniform4f(no_alpha_color_shader_->ColorLocation(),
267 actor->color().red, actor->color().green, 337 actor->color().red, actor->color().green,
268 actor->color().blue, 338 actor->color().blue,
269 actor->opacity() * ancestor_opacity_); 339 actor->opacity() * ancestor_opacity);
270 340
271 gl_->BindBuffer(GL_ARRAY_BUFFER, vertex_buffer_object_); 341 gl_->BindBuffer(GL_ARRAY_BUFFER, vertex_buffer_object_);
272 gl_->VertexAttribPointer(no_alpha_color_shader_->PosLocation(), 342 gl_->VertexAttribPointer(no_alpha_color_shader_->PosLocation(),
273 2, GL_FLOAT, GL_FALSE, 0, 0); 343 2, GL_FLOAT, GL_FALSE, 0, 0);
274 gl_->VertexAttribPointer(no_alpha_color_shader_->TexInLocation(), 344 gl_->VertexAttribPointer(no_alpha_color_shader_->TexInLocation(),
275 2, GL_FLOAT, GL_FALSE, 0, 0); 345 2, GL_FLOAT, GL_FALSE, 0, 0);
276 no_alpha_color_shader_->EnableVertexAttribs(); 346 no_alpha_color_shader_->EnableVertexAttribs();
277 } 347 }
278 } else { 348 } else {
279 const float actor_opacity = actor->opacity() * ancestor_opacity_; 349 const float actor_opacity = actor->opacity() * ancestor_opacity;
280 const float dimmed_transparency_begin = 1.f - actor->dimmed_opacity_begin(); 350 const float dimmed_transparency_begin = 1.f - actor->dimmed_opacity_begin();
281 const float dimmed_transparency_end = 1.f - actor->dimmed_opacity_end(); 351 const float dimmed_transparency_end = 1.f - actor->dimmed_opacity_end();
282 352
283 // TODO: Consider managing a ring buffer in a VBO ourselves. Could be 353 // TODO: Consider managing a ring buffer in a VBO ourselves. Could be
284 // better performance depending on driver quality. 354 // better performance depending on driver quality.
285 colors_[ 0] = dimmed_transparency_begin * actor->color().red; 355 colors[ 0] = dimmed_transparency_begin * actor->color().red;
286 colors_[ 1] = dimmed_transparency_begin * actor->color().green; 356 colors[ 1] = dimmed_transparency_begin * actor->color().green;
287 colors_[ 2] = dimmed_transparency_begin * actor->color().blue; 357 colors[ 2] = dimmed_transparency_begin * actor->color().blue;
288 colors_[ 3] = actor_opacity; 358 colors[ 3] = actor_opacity;
289 359
290 colors_[ 4] = dimmed_transparency_begin * actor->color().red; 360 colors[ 4] = dimmed_transparency_begin * actor->color().red;
291 colors_[ 5] = dimmed_transparency_begin * actor->color().green; 361 colors[ 5] = dimmed_transparency_begin * actor->color().green;
292 colors_[ 6] = dimmed_transparency_begin * actor->color().blue; 362 colors[ 6] = dimmed_transparency_begin * actor->color().blue;
293 colors_[ 7] = actor_opacity; 363 colors[ 7] = actor_opacity;
294 364
295 colors_[ 8] = dimmed_transparency_end * actor->color().red; 365 colors[ 8] = dimmed_transparency_end * actor->color().red;
296 colors_[ 9] = dimmed_transparency_end * actor->color().green; 366 colors[ 9] = dimmed_transparency_end * actor->color().green;
297 colors_[10] = dimmed_transparency_end * actor->color().blue; 367 colors[10] = dimmed_transparency_end * actor->color().blue;
298 colors_[11] = actor_opacity; 368 colors[11] = actor_opacity;
299 369
300 colors_[12] = dimmed_transparency_end * actor->color().red; 370 colors[12] = dimmed_transparency_end * actor->color().red;
301 colors_[13] = dimmed_transparency_end * actor->color().green; 371 colors[13] = dimmed_transparency_end * actor->color().green;
302 colors_[14] = dimmed_transparency_end * actor->color().blue; 372 colors[14] = dimmed_transparency_end * actor->color().blue;
303 colors_[15] = actor_opacity; 373 colors[15] = actor_opacity;
304 374
305 if (texture_has_alpha) { 375 if (texture_has_alpha) {
306 gl_->UseProgram(tex_shade_shader_->program()); 376 gl_->UseProgram(tex_shade_shader_->program());
307 gl_->UniformMatrix4fv(tex_shade_shader_->MvpLocation(), 1, GL_FALSE, 377 gl_->UniformMatrix4fv(tex_shade_shader_->MvpLocation(), 1, GL_FALSE,
308 &mvp[0][0]); 378 &mvp[0][0]);
309 gl_->Uniform1i(tex_shade_shader_->SamplerLocation(), 0); 379 gl_->Uniform1i(tex_shade_shader_->SamplerLocation(), 0);
310 gl_->BindBuffer(GL_ARRAY_BUFFER, vertex_buffer_object_); 380 gl_->BindBuffer(GL_ARRAY_BUFFER, vertex_buffer_object_);
311 gl_->VertexAttribPointer(tex_shade_shader_->PosLocation(), 381 gl_->VertexAttribPointer(tex_shade_shader_->PosLocation(),
312 2, GL_FLOAT, GL_FALSE, 0, 0); 382 2, GL_FLOAT, GL_FALSE, 0, 0);
313 gl_->VertexAttribPointer(tex_shade_shader_->TexInLocation(), 383 gl_->VertexAttribPointer(tex_shade_shader_->TexInLocation(),
314 2, GL_FLOAT, GL_FALSE, 0, 0); 384 2, GL_FLOAT, GL_FALSE, 0, 0);
315 gl_->BindBuffer(GL_ARRAY_BUFFER, 0); 385 gl_->BindBuffer(GL_ARRAY_BUFFER, 0);
316 gl_->VertexAttribPointer(tex_shade_shader_->ColorInLocation(), 386 gl_->VertexAttribPointer(tex_shade_shader_->ColorInLocation(),
317 4, GL_FLOAT, GL_FALSE, 0, colors_); 387 4, GL_FLOAT, GL_FALSE, 0, colors);
318 tex_shade_shader_->EnableVertexAttribs(); 388 tex_shade_shader_->EnableVertexAttribs();
319 } else { 389 } else {
320 gl_->UseProgram(no_alpha_shade_shader_->program()); 390 gl_->UseProgram(no_alpha_shade_shader_->program());
321 gl_->UniformMatrix4fv(no_alpha_shade_shader_->MvpLocation(), 1, GL_FALSE, 391 gl_->UniformMatrix4fv(no_alpha_shade_shader_->MvpLocation(), 1, GL_FALSE,
322 &mvp[0][0]); 392 &mvp[0][0]);
323 gl_->Uniform1i(no_alpha_shade_shader_->SamplerLocation(), 0); 393 gl_->Uniform1i(no_alpha_shade_shader_->SamplerLocation(), 0);
324 gl_->BindBuffer(GL_ARRAY_BUFFER, vertex_buffer_object_); 394 gl_->BindBuffer(GL_ARRAY_BUFFER, vertex_buffer_object_);
325 gl_->VertexAttribPointer(no_alpha_shade_shader_->PosLocation(), 395 gl_->VertexAttribPointer(no_alpha_shade_shader_->PosLocation(),
326 2, GL_FLOAT, GL_FALSE, 0, 0); 396 2, GL_FLOAT, GL_FALSE, 0, 0);
327 gl_->VertexAttribPointer(no_alpha_shade_shader_->TexInLocation(), 397 gl_->VertexAttribPointer(no_alpha_shade_shader_->TexInLocation(),
328 2, GL_FLOAT, GL_FALSE, 0, 0); 398 2, GL_FLOAT, GL_FALSE, 0, 0);
329 gl_->BindBuffer(GL_ARRAY_BUFFER, 0); 399 gl_->BindBuffer(GL_ARRAY_BUFFER, 0);
330 gl_->VertexAttribPointer(no_alpha_shade_shader_->ColorInLocation(), 400 gl_->VertexAttribPointer(no_alpha_shade_shader_->ColorInLocation(),
331 4, GL_FLOAT, GL_FALSE, 0, colors_); 401 4, GL_FLOAT, GL_FALSE, 0, colors);
332 no_alpha_shade_shader_->EnableVertexAttribs(); 402 no_alpha_shade_shader_->EnableVertexAttribs();
333 } 403 }
334 } 404 }
335 405
336 // Draw 406 // Draw
337 gl_->DrawArrays(GL_TRIANGLE_STRIP, 0, 4); 407 gl_->DrawArrays(GL_TRIANGLE_STRIP, 0, 4);
338 } 408 }
339 409
340 void OpenGlesDrawVisitor::VisitContainer( 410 void TransparentPass::VisitContainer(
341 RealCompositor::ContainerActor* actor) { 411 RealCompositor::ContainerActor* actor) {
342 if (!actor->IsVisible()) 412 if (!actor->IsVisible())
343 return; 413 return;
344 414
345 LOG(INFO) << "Visit container: " << actor->name(); 415 LOG(INFO) << "Visit container: " << actor->name();
346 416
347 const float original_opacity = ancestor_opacity_; 417 const float original_opacity = ancestor_opacity_;
348 ancestor_opacity_ *= actor->opacity(); 418 ancestor_opacity_ *= actor->opacity();
349 419
350 // Back to front rendering 420 // Back to front rendering
351 const RealCompositor::ActorVector children = actor->GetChildren(); 421 const RealCompositor::ActorVector children = actor->GetChildren();
352 for (RealCompositor::ActorVector::const_reverse_iterator i = 422 for (RealCompositor::ActorVector::const_reverse_iterator i =
353 children.rbegin(); i != children.rend(); ++i) { 423 children.rbegin(); i != children.rend(); ++i) {
354 (*i)->Accept(this); 424 if (ancestor_opacity_ <= 0.999f || (*i)->has_children() ||
425 !(*i)->is_opaque())
426 (*i)->Accept(this);
355 } 427 }
356 428
357 // Reset opacity. 429 // Reset opacity.
358 ancestor_opacity_ = original_opacity; 430 ancestor_opacity_ = original_opacity;
359 } 431 }
360 432
433 void OpaquePass::VisitContainer(
434 RealCompositor::ContainerActor* actor) {
435 if (!actor->IsVisible())
436 return;
437
438 LOG(INFO) << "Visit container: " << actor->name();
439
440 // Front to back rendering
441 const RealCompositor::ActorVector children = actor->GetChildren();
442 for (RealCompositor::ActorVector::const_iterator i = children.begin();
443 i != children.end(); ++i) {
444 if ((*i)->is_opaque())
445 (*i)->Accept(this);
446 }
447 }
448
361 OpenGlesTextureData::OpenGlesTextureData(Gles2Interface* gl) 449 OpenGlesTextureData::OpenGlesTextureData(Gles2Interface* gl)
362 : gl_(gl) {} 450 : gl_(gl) {}
363 451
364 OpenGlesTextureData::~OpenGlesTextureData() { 452 OpenGlesTextureData::~OpenGlesTextureData() {
365 gl_->DeleteTextures(1, texture_ptr()); 453 gl_->DeleteTextures(1, texture_ptr());
366 } 454 }
367 455
368 void OpenGlesTextureData::SetTexture(GLuint texture) { 456 void OpenGlesTextureData::SetTexture(GLuint texture) {
369 gl_->DeleteTextures(1, texture_ptr()); 457 gl_->DeleteTextures(1, texture_ptr());
370 set_texture(texture); 458 set_texture(texture);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 507 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
420 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 508 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
421 gl_->EGLImageTargetTexture2DOES(GL_TEXTURE_2D, 509 gl_->EGLImageTargetTexture2DOES(GL_TEXTURE_2D,
422 static_cast<GLeglImageOES>(egl_image_)); 510 static_cast<GLeglImageOES>(egl_image_));
423 511
424 texture_data->SetTexture(texture); 512 texture_data->SetTexture(texture);
425 texture_data->set_has_alpha(has_alpha); 513 texture_data->set_has_alpha(has_alpha);
426 } 514 }
427 515
428 } // namespace window_manager 516 } // namespace window_manager
OLDNEW
« no previous file with comments | « gles/opengles_visitor.h ('k') | gles/real_gles2_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698