| 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/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 9 #include "cc/animation/animation.h" | 10 #include "cc/animation/animation.h" |
| 10 #include "cc/base/region.h" | 11 #include "cc/base/region.h" |
| 11 #include "cc/layers/layer.h" | 12 #include "cc/layers/layer.h" |
| 12 #include "cc/layers/layer_position_constraint.h" | 13 #include "cc/layers/layer_position_constraint.h" |
| 13 #include "third_party/WebKit/public/platform/WebCompositingReasons.h" | 14 #include "third_party/WebKit/public/platform/WebCompositingReasons.h" |
| 14 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 15 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
| 15 #include "third_party/WebKit/public/platform/WebFloatRect.h" | 16 #include "third_party/WebKit/public/platform/WebFloatRect.h" |
| 17 #include "third_party/WebKit/public/platform/WebGraphicsLayerDebugInfo.h" |
| 16 #include "third_party/WebKit/public/platform/WebLayerClient.h" | 18 #include "third_party/WebKit/public/platform/WebLayerClient.h" |
| 17 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" | 19 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" |
| 18 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" | 20 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" |
| 19 #include "third_party/WebKit/public/platform/WebSize.h" | 21 #include "third_party/WebKit/public/platform/WebSize.h" |
| 20 #include "third_party/skia/include/utils/SkMatrix44.h" | 22 #include "third_party/skia/include/utils/SkMatrix44.h" |
| 21 #include "webkit/renderer/compositor_bindings/web_animation_impl.h" | 23 #include "webkit/renderer/compositor_bindings/web_animation_impl.h" |
| 22 #include "webkit/renderer/compositor_bindings/web_filter_operations_impl.h" | 24 #include "webkit/renderer/compositor_bindings/web_filter_operations_impl.h" |
| 23 #include "webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapt
er.h" | 25 #include "webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapt
er.h" |
| 24 | 26 |
| 25 using cc::Animation; | 27 using cc::Animation; |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 layer_->set_did_scroll_callback(base::Closure()); | 367 layer_->set_did_scroll_callback(base::Closure()); |
| 366 } | 368 } |
| 367 } | 369 } |
| 368 | 370 |
| 369 bool WebLayerImpl::isOrphan() const { return !layer_->layer_tree_host(); } | 371 bool WebLayerImpl::isOrphan() const { return !layer_->layer_tree_host(); } |
| 370 | 372 |
| 371 void WebLayerImpl::setWebLayerClient(blink::WebLayerClient* client) { | 373 void WebLayerImpl::setWebLayerClient(blink::WebLayerClient* client) { |
| 372 web_layer_client_ = client; | 374 web_layer_client_ = client; |
| 373 } | 375 } |
| 374 | 376 |
| 377 // TODO(chrishtr): move DebugName into this class. |
| 378 class TracedDebugInfo : public base::debug::ConvertableToTraceFormat { |
| 379 public: |
| 380 // This object takes ownership of the debug_info object. |
| 381 explicit TracedDebugInfo(blink::WebGraphicsLayerDebugInfo* debug_info) : |
| 382 debug_info_(debug_info) {} |
| 383 virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE { |
| 384 blink::WebString web_string; |
| 385 debug_info_->appendAsTraceFormat(&web_string); |
| 386 out->append(web_string.utf8()); |
| 387 } |
| 388 private: |
| 389 virtual ~TracedDebugInfo() {} |
| 390 scoped_ptr<blink::WebGraphicsLayerDebugInfo> debug_info_; |
| 391 }; |
| 392 |
| 393 base::debug::ConvertableToTraceFormat* WebLayerImpl::TakeDebugInfo() { |
| 394 if (!web_layer_client_) |
| 395 return NULL; |
| 396 blink::WebGraphicsLayerDebugInfo* debug_info = |
| 397 web_layer_client_->takeDebugInfo(); |
| 398 |
| 399 if (debug_info) |
| 400 return new TracedDebugInfo(debug_info); |
| 401 else |
| 402 return NULL; |
| 403 } |
| 404 |
| 375 std::string WebLayerImpl::DebugName() { | 405 std::string WebLayerImpl::DebugName() { |
| 376 if (!web_layer_client_) | 406 if (!web_layer_client_) |
| 377 return std::string(); | 407 return std::string(); |
| 378 | 408 |
| 379 std::string name = web_layer_client_->debugName(this).utf8(); | 409 std::string name = web_layer_client_->debugName(this).utf8(); |
| 380 DCHECK(IsStringASCII(name)); | 410 DCHECK(IsStringASCII(name)); |
| 381 return name; | 411 return name; |
| 382 } | 412 } |
| 383 | 413 |
| 384 void WebLayerImpl::setScrollParent(blink::WebLayer* parent) { | 414 void WebLayerImpl::setScrollParent(blink::WebLayer* parent) { |
| 385 cc::Layer* scroll_parent = NULL; | 415 cc::Layer* scroll_parent = NULL; |
| 386 if (parent) | 416 if (parent) |
| 387 scroll_parent = static_cast<WebLayerImpl*>(parent)->layer(); | 417 scroll_parent = static_cast<WebLayerImpl*>(parent)->layer(); |
| 388 layer_->SetScrollParent(scroll_parent); | 418 layer_->SetScrollParent(scroll_parent); |
| 389 } | 419 } |
| 390 | 420 |
| 391 void WebLayerImpl::setClipParent(blink::WebLayer* parent) { | 421 void WebLayerImpl::setClipParent(blink::WebLayer* parent) { |
| 392 cc::Layer* clip_parent = NULL; | 422 cc::Layer* clip_parent = NULL; |
| 393 if (parent) | 423 if (parent) |
| 394 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); | 424 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); |
| 395 layer_->SetClipParent(clip_parent); | 425 layer_->SetClipParent(clip_parent); |
| 396 } | 426 } |
| 397 | 427 |
| 398 Layer* WebLayerImpl::layer() const { return layer_.get(); } | 428 Layer* WebLayerImpl::layer() const { return layer_.get(); } |
| 399 | 429 |
| 400 } // namespace webkit | 430 } // namespace webkit |
| OLD | NEW |