| OLD | NEW |
| 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/compositor/gl/opengl_visitor.h" | 5 #include "window_manager/compositor/gl/opengl_visitor.h" |
| 6 | 6 |
| 7 #include <sys/time.h> | 7 #include <sys/time.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <ctime> | 10 #include <ctime> |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 GL_TEXTURE_WRAP_S, | 429 GL_TEXTURE_WRAP_S, |
| 430 GL_CLAMP_TO_EDGE); | 430 GL_CLAMP_TO_EDGE); |
| 431 gl_interface_->TexParameterf(GL_TEXTURE_2D, | 431 gl_interface_->TexParameterf(GL_TEXTURE_2D, |
| 432 GL_TEXTURE_WRAP_T, | 432 GL_TEXTURE_WRAP_T, |
| 433 GL_CLAMP_TO_EDGE); | 433 GL_CLAMP_TO_EDGE); |
| 434 gl_interface_->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, | 434 gl_interface_->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, |
| 435 container->width(), container->height(), | 435 container->width(), container->height(), |
| 436 0, pixel_data_format, GL_UNSIGNED_BYTE, | 436 0, pixel_data_format, GL_UNSIGNED_BYTE, |
| 437 container->data()); | 437 container->data()); |
| 438 CHECK_GL_ERROR(gl_interface_); | 438 CHECK_GL_ERROR(gl_interface_); |
| 439 OpenGlTextureData* data = new OpenGlTextureData(gl_interface_); | 439 scoped_ptr<OpenGlTextureData> data(new OpenGlTextureData(gl_interface_)); |
| 440 data->SetTexture(new_texture); | 440 data->SetTexture(new_texture); |
| 441 data->set_has_alpha(ImageFormatUsesAlpha(container->format())); | 441 data->set_has_alpha(ImageFormatUsesAlpha(container->format())); |
| 442 actor->set_texture_data(data); | 442 actor->set_texture_data(data.release()); |
| 443 } | 443 } |
| 444 | 444 |
| 445 void OpenGlDrawVisitor::VisitImage(RealCompositor::ImageActor* actor) { | 445 void OpenGlDrawVisitor::VisitImage(RealCompositor::ImageActor* actor) { |
| 446 if (!actor->IsVisible()) | 446 if (!actor->IsVisible()) |
| 447 return; | 447 return; |
| 448 | 448 |
| 449 PROFILER_MARKER_BEGIN(VisitImage); | 449 PROFILER_MARKER_BEGIN(VisitImage); |
| 450 | 450 |
| 451 // All ImageActors are also QuadActors, and so we let the | 451 // All ImageActors are also QuadActors, and so we let the |
| 452 // QuadActor do all the actual drawing. | 452 // QuadActor do all the actual drawing. |
| 453 VisitQuad(actor); | 453 VisitQuad(actor); |
| 454 PROFILER_MARKER_END(VisitImage); | 454 PROFILER_MARKER_END(VisitImage); |
| 455 } | 455 } |
| 456 | 456 |
| 457 void OpenGlDrawVisitor::VisitTexturePixmap( | 457 void OpenGlDrawVisitor::VisitTexturePixmap( |
| 458 RealCompositor::TexturePixmapActor* actor) { | 458 RealCompositor::TexturePixmapActor* actor) { |
| 459 if (!actor->IsVisible()) | 459 if (!actor->IsVisible()) |
| 460 return; | 460 return; |
| 461 | 461 |
| 462 PROFILER_MARKER_BEGIN(VisitTexturePixmap); | 462 PROFILER_MARKER_BEGIN(VisitTexturePixmap); |
| 463 | 463 |
| 464 // Make sure there's a bound texture. | 464 // Make sure there's a bound texture. |
| 465 if (!actor->texture_data()) { | 465 if (!actor->texture_data()) { |
| 466 if (!actor->pixmap()) { | 466 if (!actor->pixmap()) { |
| 467 PROFILER_MARKER_END(VisitTexturePixmap); | 467 PROFILER_MARKER_END(VisitTexturePixmap); |
| 468 return; | 468 return; |
| 469 } | 469 } |
| 470 | 470 |
| 471 OpenGlPixmapData* data = new OpenGlPixmapData(this); | 471 scoped_ptr<OpenGlPixmapData> data(new OpenGlPixmapData(this)); |
| 472 if (!data->Init(actor)) { | 472 if (!data->Init(actor)) { |
| 473 PROFILER_MARKER_END(VisitTexturePixmap); | 473 PROFILER_MARKER_END(VisitTexturePixmap); |
| 474 return; | 474 return; |
| 475 } | 475 } |
| 476 data->set_has_alpha(!actor->pixmap_is_opaque()); | 476 data->set_has_alpha(!actor->pixmap_is_opaque()); |
| 477 actor->set_texture_data(data); | 477 actor->set_texture_data(data.release()); |
| 478 } | 478 } |
| 479 | 479 |
| 480 // All texture pixmaps are also QuadActors, and so we let the | 480 // All texture pixmaps are also QuadActors, and so we let the |
| 481 // QuadActor do all the actual drawing. | 481 // QuadActor do all the actual drawing. |
| 482 VisitQuad(actor); | 482 VisitQuad(actor); |
| 483 PROFILER_MARKER_END(VisitTexturePixmap); | 483 PROFILER_MARKER_END(VisitTexturePixmap); |
| 484 } | 484 } |
| 485 | 485 |
| 486 void OpenGlDrawVisitor::VisitQuad(RealCompositor::QuadActor* actor) { | 486 void OpenGlDrawVisitor::VisitQuad(RealCompositor::QuadActor* actor) { |
| 487 if (!actor->IsVisible()) | 487 if (!actor->IsVisible()) |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 ++iterator) { | 710 ++iterator) { |
| 711 RealCompositor::Actor* child = *iterator; | 711 RealCompositor::Actor* child = *iterator; |
| 712 if (!child->IsVisible()) | 712 if (!child->IsVisible()) |
| 713 continue; | 713 continue; |
| 714 #ifdef EXTRA_LOGGING | 714 #ifdef EXTRA_LOGGING |
| 715 DLOG(INFO) << "Drawing child " << child->name() | 715 DLOG(INFO) << "Drawing child " << child->name() |
| 716 << " (visible: " << child->IsVisible() | 716 << " (visible: " << child->IsVisible() |
| 717 << ", opacity: " << child->opacity() | 717 << ", opacity: " << child->opacity() |
| 718 << ", is_opaque: " << child->is_opaque() << ")"; | 718 << ", is_opaque: " << child->is_opaque() << ")"; |
| 719 #endif | 719 #endif |
| 720 | 720 |
| 721 // TODO: move this down into the Visit* functions | 721 // TODO: move this down into the Visit* functions |
| 722 if (child->is_opaque() && child->opacity() * ancestor_opacity_ > 0.999) | 722 if (child->is_opaque() && child->opacity() * ancestor_opacity_ > 0.999) |
| 723 gl_interface_->Disable(GL_BLEND); | 723 gl_interface_->Disable(GL_BLEND); |
| 724 else | 724 else |
| 725 gl_interface_->Enable(GL_BLEND); | 725 gl_interface_->Enable(GL_BLEND); |
| 726 child->Accept(this); | 726 child->Accept(this); |
| 727 CHECK_GL_ERROR(gl_interface_); | 727 CHECK_GL_ERROR(gl_interface_); |
| 728 } | 728 } |
| 729 | 729 |
| 730 // Reset ancestor opacity. | 730 // Reset ancestor opacity. |
| 731 ancestor_opacity_ = original_opacity; | 731 ancestor_opacity_ = original_opacity; |
| 732 } | 732 } |
| 733 | 733 |
| 734 } // namespace window_manager | 734 } // namespace window_manager |
| OLD | NEW |