| 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 23 matching lines...) Expand all Loading... |
| 34 using blink::WebFloatPoint; | 34 using blink::WebFloatPoint; |
| 35 using blink::WebVector; | 35 using blink::WebVector; |
| 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 bool g_impl_side_painting_enabled = false; |
| 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 | 45 |
| 53 } // namespace | 46 } // namespace |
| 54 | 47 |
| 55 WebLayerImpl::WebLayerImpl() : layer_(Layer::Create()) { | 48 WebLayerImpl::WebLayerImpl() : layer_(Layer::Create()) { |
| 56 web_layer_client_ = NULL; | 49 web_layer_client_ = NULL; |
| 57 layer_->SetLayerClient(this); | 50 layer_->SetLayerClient(this); |
| 58 } | 51 } |
| 59 | 52 |
| 60 WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer) : layer_(layer) { | 53 WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer) : layer_(layer) { |
| 61 web_layer_client_ = NULL; | 54 web_layer_client_ = NULL; |
| 62 layer_->SetLayerClient(this); | 55 layer_->SetLayerClient(this); |
| 63 } | 56 } |
| 64 | 57 |
| 65 WebLayerImpl::~WebLayerImpl() { | 58 WebLayerImpl::~WebLayerImpl() { |
| 66 layer_->ClearRenderSurface(); | 59 layer_->ClearRenderSurface(); |
| 67 layer_->set_layer_animation_delegate(NULL); | 60 layer_->set_layer_animation_delegate(NULL); |
| 68 web_layer_client_ = NULL; | 61 web_layer_client_ = NULL; |
| 69 } | 62 } |
| 70 | 63 |
| 71 // static | 64 // static |
| 72 bool WebLayerImpl::UsingPictureLayer() { | 65 bool WebLayerImpl::UsingPictureLayer() { |
| 73 return g_impl_side_painting_status.Get().enabled; | 66 return g_impl_side_painting_enabled; |
| 67 } |
| 68 |
| 69 // static |
| 70 void WebLayerImpl::SetImplSidePaintingEnabled(bool enabled) { |
| 71 g_impl_side_painting_enabled = enabled; |
| 74 } | 72 } |
| 75 | 73 |
| 76 int WebLayerImpl::id() const { return layer_->id(); } | 74 int WebLayerImpl::id() const { return layer_->id(); } |
| 77 | 75 |
| 78 void WebLayerImpl::invalidateRect(const blink::WebFloatRect& rect) { | 76 void WebLayerImpl::invalidateRect(const blink::WebFloatRect& rect) { |
| 79 layer_->SetNeedsDisplayRect(rect); | 77 layer_->SetNeedsDisplayRect(rect); |
| 80 } | 78 } |
| 81 | 79 |
| 82 void WebLayerImpl::invalidate() { layer_->SetNeedsDisplay(); } | 80 void WebLayerImpl::invalidate() { layer_->SetNeedsDisplay(); } |
| 83 | 81 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 static_cast<const WebFilterOperationsImpl&>(filters); | 202 static_cast<const WebFilterOperationsImpl&>(filters); |
| 205 layer_->SetFilters(filters_impl.AsFilterOperations()); | 203 layer_->SetFilters(filters_impl.AsFilterOperations()); |
| 206 } | 204 } |
| 207 | 205 |
| 208 void WebLayerImpl::setBackgroundFilters(const WebFilterOperations& filters) { | 206 void WebLayerImpl::setBackgroundFilters(const WebFilterOperations& filters) { |
| 209 const WebFilterOperationsImpl& filters_impl = | 207 const WebFilterOperationsImpl& filters_impl = |
| 210 static_cast<const WebFilterOperationsImpl&>(filters); | 208 static_cast<const WebFilterOperationsImpl&>(filters); |
| 211 layer_->SetBackgroundFilters(filters_impl.AsFilterOperations()); | 209 layer_->SetBackgroundFilters(filters_impl.AsFilterOperations()); |
| 212 } | 210 } |
| 213 | 211 |
| 212 void WebLayerImpl::setHasGpuRasterizationHint(bool has_hint) { |
| 213 layer_->SetHasGpuRasterizationHint(has_hint); |
| 214 } |
| 215 |
| 214 void WebLayerImpl::setAnimationDelegate( | 216 void WebLayerImpl::setAnimationDelegate( |
| 215 blink::WebAnimationDelegate* delegate) { | 217 blink::WebAnimationDelegate* delegate) { |
| 216 animation_delegate_adapter_.reset( | 218 animation_delegate_adapter_.reset( |
| 217 new WebToCCAnimationDelegateAdapter(delegate)); | 219 new WebToCCAnimationDelegateAdapter(delegate)); |
| 218 layer_->set_layer_animation_delegate(animation_delegate_adapter_.get()); | 220 layer_->set_layer_animation_delegate(animation_delegate_adapter_.get()); |
| 219 } | 221 } |
| 220 | 222 |
| 221 bool WebLayerImpl::addAnimation(blink::WebAnimation* animation) { | 223 bool WebLayerImpl::addAnimation(blink::WebAnimation* animation) { |
| 222 bool result = layer_->AddAnimation( | 224 bool result = layer_->AddAnimation( |
| 223 static_cast<WebAnimationImpl*>(animation)->PassAnimation()); | 225 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) { | 440 void WebLayerImpl::setClipParent(blink::WebLayer* parent) { |
| 439 cc::Layer* clip_parent = NULL; | 441 cc::Layer* clip_parent = NULL; |
| 440 if (parent) | 442 if (parent) |
| 441 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); | 443 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); |
| 442 layer_->SetClipParent(clip_parent); | 444 layer_->SetClipParent(clip_parent); |
| 443 } | 445 } |
| 444 | 446 |
| 445 Layer* WebLayerImpl::layer() const { return layer_.get(); } | 447 Layer* WebLayerImpl::layer() const { return layer_.get(); } |
| 446 | 448 |
| 447 } // namespace webkit | 449 } // namespace webkit |
| OLD | NEW |