| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 "ui/compositor/layer.h" | 5 #include "ui/compositor/layer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 web_layer_->setOpaque(fills_bounds_opaquely_); | 416 web_layer_->setOpaque(fills_bounds_opaquely_); |
| 417 web_layer_->setOpacity(visible_ ? opacity_ : 0.f); | 417 web_layer_->setOpacity(visible_ ? opacity_ : 0.f); |
| 418 web_layer_->setDebugBorderWidth(show_debug_borders_ ? 2 : 0); | 418 web_layer_->setDebugBorderWidth(show_debug_borders_ ? 2 : 0); |
| 419 web_layer_->setForceRenderSurface(force_render_surface_); | 419 web_layer_->setForceRenderSurface(force_render_surface_); |
| 420 RecomputeTransform(); | 420 RecomputeTransform(); |
| 421 RecomputeDebugBorderColor(); | 421 RecomputeDebugBorderColor(); |
| 422 } | 422 } |
| 423 RecomputeDrawsContentAndUVRect(); | 423 RecomputeDrawsContentAndUVRect(); |
| 424 } | 424 } |
| 425 | 425 |
| 426 void Layer::SetCompositorFrame(const WebKit::WebCompositorFrame& frame) { |
| 427 DCHECK_EQ(type_, LAYER_TEXTURED); |
| 428 layer_updated_externally_ = false; |
| 429 if (!delegated_renderer_layer_.get()) { |
| 430 // Switch to a different type of layer. |
| 431 web_layer_->removeAllChildren(); |
| 432 scoped_ptr<WebKit::WebContentLayer> old_content_layer( |
| 433 content_layer_.release()); |
| 434 scoped_ptr<WebKit::WebSolidColorLayer> old_solid_layer( |
| 435 solid_color_layer_.release()); |
| 436 scoped_ptr<WebKit::WebExternalTextureLayer> old_texture_layer( |
| 437 texture_layer_.release()); |
| 438 WebKit::WebLayer* new_layer = NULL; |
| 439 WebKit::WebCompositorSupport* compositor_support = |
| 440 WebKit::Platform::current()->compositorSupport(); |
| 441 delegated_renderer_layer_.reset( |
| 442 compositor_support->createDelegatedRendererLayer()); |
| 443 new_layer = delegated_renderer_layer_->layer(); |
| 444 if (parent_) { |
| 445 DCHECK(parent_->web_layer_); |
| 446 parent_->web_layer_->replaceChild(web_layer_, new_layer); |
| 447 } |
| 448 web_layer_= new_layer; |
| 449 for (size_t i = 0; i < children_.size(); ++i) { |
| 450 DCHECK(children_[i]->web_layer_); |
| 451 web_layer_->addChild(children_[i]->web_layer_); |
| 452 } |
| 453 web_layer_->setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f)); |
| 454 web_layer_->setOpaque(fills_bounds_opaquely_); |
| 455 web_layer_->setOpacity(visible_ ? opacity_ : 0.f); |
| 456 web_layer_->setDebugBorderWidth(show_debug_borders_ ? 2 : 0); |
| 457 web_layer_->setForceRenderSurface(force_render_surface_); |
| 458 RecomputeTransform(); |
| 459 RecomputeDebugBorderColor(); |
| 460 } |
| 461 delegated_renderer_layer_->setFrameData(frame); |
| 462 RecomputeDrawsContentAndUVRect(); |
| 463 } |
| 464 |
| 465 void Layer::GetRecycledResources(cc::TransferableResourceList* list) { |
| 466 if (delegated_renderer_layer_.get()) |
| 467 delegated_renderer_layer_->getRecycledResources(list); |
| 468 } |
| 469 |
| 426 void Layer::SetColor(SkColor color) { | 470 void Layer::SetColor(SkColor color) { |
| 427 DCHECK_EQ(type_, LAYER_SOLID_COLOR); | 471 DCHECK_EQ(type_, LAYER_SOLID_COLOR); |
| 428 // WebColor is equivalent to SkColor, per WebColor.h. | 472 // WebColor is equivalent to SkColor, per WebColor.h. |
| 429 solid_color_layer_->setBackgroundColor(static_cast<WebKit::WebColor>(color)); | 473 solid_color_layer_->setBackgroundColor(static_cast<WebKit::WebColor>(color)); |
| 430 SetFillsBoundsOpaquely(SkColorGetA(color) == 0xFF); | 474 SetFillsBoundsOpaquely(SkColorGetA(color) == 0xFF); |
| 431 } | 475 } |
| 432 | 476 |
| 433 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { | 477 bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { |
| 434 if (type_ == LAYER_SOLID_COLOR || (!delegate_ && !texture_)) | 478 if (type_ == LAYER_SOLID_COLOR || (!delegate_ && !texture_)) |
| 435 return false; | 479 return false; |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 return; | 821 return; |
| 778 unsigned int color = 0xFF000000; | 822 unsigned int color = 0xFF000000; |
| 779 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; | 823 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; |
| 780 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); | 824 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); |
| 781 if (!opaque) | 825 if (!opaque) |
| 782 color |= 0xFF; | 826 color |= 0xFF; |
| 783 web_layer_->setDebugBorderColor(color); | 827 web_layer_->setDebugBorderColor(color); |
| 784 } | 828 } |
| 785 | 829 |
| 786 } // namespace ui | 830 } // namespace ui |
| OLD | NEW |