OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "webkit/renderer/compositor_bindings/web_layer_impl.h" | 5 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event_impl.h" | 8 #include "base/debug/trace_event_impl.h" |
| 9 #include "base/lazy_instance.h" |
9 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
10 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
11 #include "cc/animation/animation.h" | 12 #include "cc/animation/animation.h" |
12 #include "cc/base/region.h" | 13 #include "cc/base/region.h" |
| 14 #include "cc/base/switches.h" |
13 #include "cc/layers/layer.h" | 15 #include "cc/layers/layer.h" |
14 #include "cc/layers/layer_position_constraint.h" | 16 #include "cc/layers/layer_position_constraint.h" |
15 #include "third_party/WebKit/public/platform/WebCompositingReasons.h" | 17 #include "third_party/WebKit/public/platform/WebCompositingReasons.h" |
16 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 18 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
17 #include "third_party/WebKit/public/platform/WebFloatRect.h" | 19 #include "third_party/WebKit/public/platform/WebFloatRect.h" |
18 #include "third_party/WebKit/public/platform/WebGraphicsLayerDebugInfo.h" | 20 #include "third_party/WebKit/public/platform/WebGraphicsLayerDebugInfo.h" |
19 #include "third_party/WebKit/public/platform/WebLayerClient.h" | 21 #include "third_party/WebKit/public/platform/WebLayerClient.h" |
20 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" | 22 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" |
21 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" | 23 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" |
22 #include "third_party/WebKit/public/platform/WebSize.h" | 24 #include "third_party/WebKit/public/platform/WebSize.h" |
23 #include "third_party/skia/include/utils/SkMatrix44.h" | 25 #include "third_party/skia/include/utils/SkMatrix44.h" |
24 #include "webkit/renderer/compositor_bindings/web_animation_impl.h" | 26 #include "webkit/renderer/compositor_bindings/web_animation_impl.h" |
25 #include "webkit/renderer/compositor_bindings/web_blend_mode.h" | 27 #include "webkit/renderer/compositor_bindings/web_blend_mode.h" |
26 #include "webkit/renderer/compositor_bindings/web_filter_operations_impl.h" | 28 #include "webkit/renderer/compositor_bindings/web_filter_operations_impl.h" |
27 #include "webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapt
er.h" | 29 #include "webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapt
er.h" |
28 | 30 |
29 using cc::Animation; | 31 using cc::Animation; |
30 using cc::Layer; | 32 using cc::Layer; |
31 using blink::WebLayer; | 33 using blink::WebLayer; |
32 using blink::WebFloatPoint; | 34 using blink::WebFloatPoint; |
33 using blink::WebVector; | 35 using blink::WebVector; |
34 using blink::WebRect; | 36 using blink::WebRect; |
35 using blink::WebSize; | 37 using blink::WebSize; |
36 using blink::WebColor; | 38 using blink::WebColor; |
37 using blink::WebFilterOperations; | 39 using blink::WebFilterOperations; |
38 | 40 |
39 namespace webkit { | 41 namespace webkit { |
| 42 namespace { |
| 43 |
| 44 struct ImplSidePaintingStatus { |
| 45 ImplSidePaintingStatus() |
| 46 : enabled(cc::switches::IsImplSidePaintingEnabled()) { |
| 47 } |
| 48 bool enabled; |
| 49 }; |
| 50 base::LazyInstance<ImplSidePaintingStatus> g_impl_side_painting_status = |
| 51 LAZY_INSTANCE_INITIALIZER; |
| 52 |
| 53 } // namespace |
40 | 54 |
41 WebLayerImpl::WebLayerImpl() : layer_(Layer::Create()) { | 55 WebLayerImpl::WebLayerImpl() : layer_(Layer::Create()) { |
42 web_layer_client_ = NULL; | 56 web_layer_client_ = NULL; |
43 layer_->SetLayerClient(this); | 57 layer_->SetLayerClient(this); |
44 } | 58 } |
45 | 59 |
46 WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer) : layer_(layer) { | 60 WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer) : layer_(layer) { |
47 web_layer_client_ = NULL; | 61 web_layer_client_ = NULL; |
48 layer_->SetLayerClient(this); | 62 layer_->SetLayerClient(this); |
49 } | 63 } |
50 | 64 |
51 WebLayerImpl::~WebLayerImpl() { | 65 WebLayerImpl::~WebLayerImpl() { |
52 layer_->ClearRenderSurface(); | 66 layer_->ClearRenderSurface(); |
53 layer_->set_layer_animation_delegate(NULL); | 67 layer_->set_layer_animation_delegate(NULL); |
54 web_layer_client_ = NULL; | 68 web_layer_client_ = NULL; |
55 } | 69 } |
56 | 70 |
| 71 // static |
| 72 bool WebLayerImpl::UsingPictureLayer() { |
| 73 return g_impl_side_painting_status.Get().enabled; |
| 74 } |
| 75 |
57 int WebLayerImpl::id() const { return layer_->id(); } | 76 int WebLayerImpl::id() const { return layer_->id(); } |
58 | 77 |
59 void WebLayerImpl::invalidateRect(const blink::WebFloatRect& rect) { | 78 void WebLayerImpl::invalidateRect(const blink::WebFloatRect& rect) { |
60 layer_->SetNeedsDisplayRect(rect); | 79 layer_->SetNeedsDisplayRect(rect); |
61 } | 80 } |
62 | 81 |
63 void WebLayerImpl::invalidate() { layer_->SetNeedsDisplay(); } | 82 void WebLayerImpl::invalidate() { layer_->SetNeedsDisplay(); } |
64 | 83 |
65 void WebLayerImpl::addChild(WebLayer* child) { | 84 void WebLayerImpl::addChild(WebLayer* child) { |
66 layer_->AddChild(static_cast<WebLayerImpl*>(child)->layer()); | 85 layer_->AddChild(static_cast<WebLayerImpl*>(child)->layer()); |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 void WebLayerImpl::setClipParent(blink::WebLayer* parent) { | 461 void WebLayerImpl::setClipParent(blink::WebLayer* parent) { |
443 cc::Layer* clip_parent = NULL; | 462 cc::Layer* clip_parent = NULL; |
444 if (parent) | 463 if (parent) |
445 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); | 464 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); |
446 layer_->SetClipParent(clip_parent); | 465 layer_->SetClipParent(clip_parent); |
447 } | 466 } |
448 | 467 |
449 Layer* WebLayerImpl::layer() const { return layer_.get(); } | 468 Layer* WebLayerImpl::layer() const { return layer_.get(); } |
450 | 469 |
451 } // namespace webkit | 470 } // namespace webkit |
OLD | NEW |