Chromium Code Reviews| 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/lazy_instance.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 using blink::WebRect; | 36 using blink::WebRect; |
| 37 using blink::WebSize; | 37 using blink::WebSize; |
| 38 using blink::WebColor; | 38 using blink::WebColor; |
| 39 using blink::WebFilterOperations; | 39 using blink::WebFilterOperations; |
| 40 | 40 |
| 41 namespace webkit { | 41 namespace webkit { |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 struct ImplSidePaintingStatus { | 44 struct ImplSidePaintingStatus { |
| 45 ImplSidePaintingStatus() | 45 ImplSidePaintingStatus() |
| 46 : enabled(cc::switches::IsImplSidePaintingEnabled()) { | 46 : enabled(false) { |
| 47 } | 47 } |
| 48 bool enabled; | 48 bool enabled; |
| 49 }; | 49 }; |
| 50 base::LazyInstance<ImplSidePaintingStatus> g_impl_side_painting_status = | 50 base::LazyInstance<ImplSidePaintingStatus> g_impl_side_painting_status = |
| 51 LAZY_INSTANCE_INITIALIZER; | 51 LAZY_INSTANCE_INITIALIZER; |
|
piman
2014/03/07 19:41:04
nit: at this point, a simple bool might suffice.
ajuma
2014/03/07 20:21:11
Done.
| |
| 52 | 52 |
| 53 } // namespace | 53 } // namespace |
| 54 | 54 |
| 55 WebLayerImpl::WebLayerImpl() : layer_(Layer::Create()) { | 55 WebLayerImpl::WebLayerImpl() : layer_(Layer::Create()) { |
| 56 web_layer_client_ = NULL; | 56 web_layer_client_ = NULL; |
| 57 layer_->SetLayerClient(this); | 57 layer_->SetLayerClient(this); |
| 58 } | 58 } |
| 59 | 59 |
| 60 WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer) : layer_(layer) { | 60 WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer) : layer_(layer) { |
| 61 web_layer_client_ = NULL; | 61 web_layer_client_ = NULL; |
| 62 layer_->SetLayerClient(this); | 62 layer_->SetLayerClient(this); |
| 63 } | 63 } |
| 64 | 64 |
| 65 WebLayerImpl::~WebLayerImpl() { | 65 WebLayerImpl::~WebLayerImpl() { |
| 66 layer_->ClearRenderSurface(); | 66 layer_->ClearRenderSurface(); |
| 67 layer_->set_layer_animation_delegate(NULL); | 67 layer_->set_layer_animation_delegate(NULL); |
| 68 web_layer_client_ = NULL; | 68 web_layer_client_ = NULL; |
| 69 } | 69 } |
| 70 | 70 |
| 71 // static | 71 // static |
| 72 bool WebLayerImpl::UsingPictureLayer() { | 72 bool WebLayerImpl::UsingPictureLayer() { |
| 73 return g_impl_side_painting_status.Get().enabled; | 73 return g_impl_side_painting_status.Get().enabled; |
| 74 } | 74 } |
| 75 | 75 |
| 76 // static | |
| 77 void WebLayerImpl::SetImplSidePaintingEnabled(bool enabled) { | |
| 78 g_impl_side_painting_status.Get().enabled = enabled; | |
| 79 } | |
| 80 | |
| 76 int WebLayerImpl::id() const { return layer_->id(); } | 81 int WebLayerImpl::id() const { return layer_->id(); } |
| 77 | 82 |
| 78 void WebLayerImpl::invalidateRect(const blink::WebFloatRect& rect) { | 83 void WebLayerImpl::invalidateRect(const blink::WebFloatRect& rect) { |
| 79 layer_->SetNeedsDisplayRect(rect); | 84 layer_->SetNeedsDisplayRect(rect); |
| 80 } | 85 } |
| 81 | 86 |
| 82 void WebLayerImpl::invalidate() { layer_->SetNeedsDisplay(); } | 87 void WebLayerImpl::invalidate() { layer_->SetNeedsDisplay(); } |
| 83 | 88 |
| 84 void WebLayerImpl::addChild(WebLayer* child) { | 89 void WebLayerImpl::addChild(WebLayer* child) { |
| 85 layer_->AddChild(static_cast<WebLayerImpl*>(child)->layer()); | 90 layer_->AddChild(static_cast<WebLayerImpl*>(child)->layer()); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 static_cast<const WebFilterOperationsImpl&>(filters); | 209 static_cast<const WebFilterOperationsImpl&>(filters); |
| 205 layer_->SetFilters(filters_impl.AsFilterOperations()); | 210 layer_->SetFilters(filters_impl.AsFilterOperations()); |
| 206 } | 211 } |
| 207 | 212 |
| 208 void WebLayerImpl::setBackgroundFilters(const WebFilterOperations& filters) { | 213 void WebLayerImpl::setBackgroundFilters(const WebFilterOperations& filters) { |
| 209 const WebFilterOperationsImpl& filters_impl = | 214 const WebFilterOperationsImpl& filters_impl = |
| 210 static_cast<const WebFilterOperationsImpl&>(filters); | 215 static_cast<const WebFilterOperationsImpl&>(filters); |
| 211 layer_->SetBackgroundFilters(filters_impl.AsFilterOperations()); | 216 layer_->SetBackgroundFilters(filters_impl.AsFilterOperations()); |
| 212 } | 217 } |
| 213 | 218 |
| 219 void WebLayerImpl::setHasGpuRasterizationHint(bool has_hint) { | |
| 220 layer_->SetHasGpuRasterizationHint(has_hint); | |
| 221 } | |
| 222 | |
| 214 void WebLayerImpl::setAnimationDelegate( | 223 void WebLayerImpl::setAnimationDelegate( |
| 215 blink::WebAnimationDelegate* delegate) { | 224 blink::WebAnimationDelegate* delegate) { |
| 216 animation_delegate_adapter_.reset( | 225 animation_delegate_adapter_.reset( |
| 217 new WebToCCAnimationDelegateAdapter(delegate)); | 226 new WebToCCAnimationDelegateAdapter(delegate)); |
| 218 layer_->set_layer_animation_delegate(animation_delegate_adapter_.get()); | 227 layer_->set_layer_animation_delegate(animation_delegate_adapter_.get()); |
| 219 } | 228 } |
| 220 | 229 |
| 221 bool WebLayerImpl::addAnimation(blink::WebAnimation* animation) { | 230 bool WebLayerImpl::addAnimation(blink::WebAnimation* animation) { |
| 222 bool result = layer_->AddAnimation( | 231 bool result = layer_->AddAnimation( |
| 223 static_cast<WebAnimationImpl*>(animation)->PassAnimation()); | 232 static_cast<WebAnimationImpl*>(animation)->PassAnimation()); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 438 void WebLayerImpl::setClipParent(blink::WebLayer* parent) { | 447 void WebLayerImpl::setClipParent(blink::WebLayer* parent) { |
| 439 cc::Layer* clip_parent = NULL; | 448 cc::Layer* clip_parent = NULL; |
| 440 if (parent) | 449 if (parent) |
| 441 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); | 450 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); |
| 442 layer_->SetClipParent(clip_parent); | 451 layer_->SetClipParent(clip_parent); |
| 443 } | 452 } |
| 444 | 453 |
| 445 Layer* WebLayerImpl::layer() const { return layer_.get(); } | 454 Layer* WebLayerImpl::layer() const { return layer_.get(); } |
| 446 | 455 |
| 447 } // namespace webkit | 456 } // namespace webkit |
| OLD | NEW |