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