| 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/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "cc/animation/animation.h" | 9 #include "cc/animation/animation.h" |
| 10 #include "cc/base/region.h" | 10 #include "cc/base/region.h" |
| 11 #include "cc/layers/layer.h" | 11 #include "cc/layers/layer.h" |
| 12 #include "cc/layers/layer_position_constraint.h" | 12 #include "cc/layers/layer_position_constraint.h" |
| 13 #include "third_party/WebKit/public/platform/WebCompositingReasons.h" | 13 #include "third_party/WebKit/public/platform/WebCompositingReasons.h" |
| 14 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 14 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
| 15 #include "third_party/WebKit/public/platform/WebFloatRect.h" | 15 #include "third_party/WebKit/public/platform/WebFloatRect.h" |
| 16 #include "third_party/WebKit/public/platform/WebLayerClient.h" |
| 16 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" | 17 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" |
| 17 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" | 18 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" |
| 18 #include "third_party/WebKit/public/platform/WebSize.h" | 19 #include "third_party/WebKit/public/platform/WebSize.h" |
| 19 #include "third_party/skia/include/utils/SkMatrix44.h" | 20 #include "third_party/skia/include/utils/SkMatrix44.h" |
| 20 #include "webkit/renderer/compositor_bindings/web_animation_impl.h" | 21 #include "webkit/renderer/compositor_bindings/web_animation_impl.h" |
| 21 #include "webkit/renderer/compositor_bindings/web_filter_operations_impl.h" | 22 #include "webkit/renderer/compositor_bindings/web_filter_operations_impl.h" |
| 22 #include "webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapt
er.h" | 23 #include "webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapt
er.h" |
| 23 | 24 |
| 24 using cc::Animation; | 25 using cc::Animation; |
| 25 using cc::Layer; | 26 using cc::Layer; |
| 26 using WebKit::WebLayer; | 27 using WebKit::WebLayer; |
| 27 using WebKit::WebFloatPoint; | 28 using WebKit::WebFloatPoint; |
| 28 using WebKit::WebVector; | 29 using WebKit::WebVector; |
| 29 using WebKit::WebRect; | 30 using WebKit::WebRect; |
| 30 using WebKit::WebSize; | 31 using WebKit::WebSize; |
| 31 using WebKit::WebColor; | 32 using WebKit::WebColor; |
| 32 using WebKit::WebFilterOperations; | 33 using WebKit::WebFilterOperations; |
| 33 | 34 |
| 34 namespace webkit { | 35 namespace webkit { |
| 35 | 36 |
| 36 WebLayerImpl::WebLayerImpl() : layer_(Layer::Create()) {} | 37 WebLayerImpl::WebLayerImpl() : layer_(Layer::Create()) { |
| 38 web_layer_client_ = NULL; |
| 39 layer_->SetLayerClient(this); |
| 40 } |
| 37 | 41 |
| 38 WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer) : layer_(layer) {} | 42 WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer) : layer_(layer) { |
| 43 web_layer_client_ = NULL; |
| 44 layer_->SetLayerClient(this); |
| 45 } |
| 39 | 46 |
| 40 WebLayerImpl::~WebLayerImpl() { | 47 WebLayerImpl::~WebLayerImpl() { |
| 41 layer_->ClearRenderSurface(); | 48 layer_->ClearRenderSurface(); |
| 42 layer_->set_layer_animation_delegate(NULL); | 49 layer_->set_layer_animation_delegate(NULL); |
| 50 web_layer_client_ = NULL; |
| 43 } | 51 } |
| 44 | 52 |
| 45 int WebLayerImpl::id() const { return layer_->id(); } | 53 int WebLayerImpl::id() const { return layer_->id(); } |
| 46 | 54 |
| 47 void WebLayerImpl::invalidateRect(const WebKit::WebFloatRect& rect) { | 55 void WebLayerImpl::invalidateRect(const WebKit::WebFloatRect& rect) { |
| 48 layer_->SetNeedsDisplayRect(rect); | 56 layer_->SetNeedsDisplayRect(rect); |
| 49 } | 57 } |
| 50 | 58 |
| 51 void WebLayerImpl::invalidate() { layer_->SetNeedsDisplay(); } | 59 void WebLayerImpl::invalidate() { layer_->SetNeedsDisplay(); } |
| 52 | 60 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 void WebLayerImpl::setBackgroundFilters(const WebFilterOperations& filters) { | 175 void WebLayerImpl::setBackgroundFilters(const WebFilterOperations& filters) { |
| 168 const WebFilterOperationsImpl& filters_impl = | 176 const WebFilterOperationsImpl& filters_impl = |
| 169 static_cast<const WebFilterOperationsImpl&>(filters); | 177 static_cast<const WebFilterOperationsImpl&>(filters); |
| 170 layer_->SetBackgroundFilters(filters_impl.AsFilterOperations()); | 178 layer_->SetBackgroundFilters(filters_impl.AsFilterOperations()); |
| 171 } | 179 } |
| 172 | 180 |
| 173 void WebLayerImpl::setFilter(SkImageFilter* filter) { | 181 void WebLayerImpl::setFilter(SkImageFilter* filter) { |
| 174 layer_->SetFilter(skia::SharePtr(filter)); | 182 layer_->SetFilter(skia::SharePtr(filter)); |
| 175 } | 183 } |
| 176 | 184 |
| 177 void WebLayerImpl::setDebugName(WebKit::WebString name) { | |
| 178 layer_->SetDebugName(UTF16ToASCII(name)); | |
| 179 } | |
| 180 | |
| 181 void WebLayerImpl::setCompositingReasons( | 185 void WebLayerImpl::setCompositingReasons( |
| 182 WebKit::WebCompositingReasons reasons) { | 186 WebKit::WebCompositingReasons reasons) { |
| 183 layer_->SetCompositingReasons(reasons); | 187 layer_->SetCompositingReasons(reasons); |
| 184 } | 188 } |
| 185 | 189 |
| 186 void WebLayerImpl::setAnimationDelegate( | 190 void WebLayerImpl::setAnimationDelegate( |
| 187 WebKit::WebAnimationDelegate* delegate) { | 191 WebKit::WebAnimationDelegate* delegate) { |
| 188 animation_delegate_adapter_.reset( | 192 animation_delegate_adapter_.reset( |
| 189 new WebToCCAnimationDelegateAdapter(delegate)); | 193 new WebToCCAnimationDelegateAdapter(delegate)); |
| 190 layer_->set_layer_animation_delegate(animation_delegate_adapter_.get()); | 194 layer_->set_layer_animation_delegate(animation_delegate_adapter_.get()); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 layer_->set_did_scroll_callback(base::Closure()); | 363 layer_->set_did_scroll_callback(base::Closure()); |
| 360 } | 364 } |
| 361 } | 365 } |
| 362 | 366 |
| 363 bool WebLayerImpl::isOrphan() const { return !layer_->layer_tree_host(); } | 367 bool WebLayerImpl::isOrphan() const { return !layer_->layer_tree_host(); } |
| 364 | 368 |
| 365 void WebLayerImpl::setWebLayerClient(WebKit::WebLayerClient* client) { | 369 void WebLayerImpl::setWebLayerClient(WebKit::WebLayerClient* client) { |
| 366 web_layer_client_ = client; | 370 web_layer_client_ = client; |
| 367 } | 371 } |
| 368 | 372 |
| 373 std::string WebLayerImpl::DebugName() { |
| 374 if (!web_layer_client_) |
| 375 return std::string(); |
| 376 |
| 377 std::string name = web_layer_client_->debugName(this).utf8(); |
| 378 DCHECK(IsStringASCII(name)); |
| 379 return name; |
| 380 } |
| 381 |
| 369 Layer* WebLayerImpl::layer() const { return layer_.get(); } | 382 Layer* WebLayerImpl::layer() const { return layer_.get(); } |
| 370 | 383 |
| 371 } // namespace webkit | 384 } // namespace webkit |
| OLD | NEW |