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