OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "cc/blink/web_layer_impl.h" | 5 #include "cc/blink/web_layer_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event_impl.h" | |
9 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
10 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
11 #include "base/threading/thread_checker.h" | |
12 #include "cc/animation/animation.h" | 10 #include "cc/animation/animation.h" |
13 #include "cc/base/region.h" | 11 #include "cc/base/region.h" |
14 #include "cc/base/switches.h" | 12 #include "cc/base/switches.h" |
| 13 #include "cc/blink/blink_layer_debug_info.h" |
15 #include "cc/blink/web_animation_impl.h" | 14 #include "cc/blink/web_animation_impl.h" |
16 #include "cc/blink/web_blend_mode.h" | 15 #include "cc/blink/web_blend_mode.h" |
17 #include "cc/blink/web_filter_operations_impl.h" | 16 #include "cc/blink/web_filter_operations_impl.h" |
18 #include "cc/blink/web_to_cc_animation_delegate_adapter.h" | 17 #include "cc/blink/web_to_cc_animation_delegate_adapter.h" |
19 #include "cc/layers/layer.h" | 18 #include "cc/layers/layer.h" |
20 #include "cc/layers/layer_position_constraint.h" | 19 #include "cc/layers/layer_position_constraint.h" |
21 #include "cc/trees/layer_tree_host.h" | 20 #include "cc/trees/layer_tree_host.h" |
22 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 21 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
23 #include "third_party/WebKit/public/platform/WebFloatRect.h" | 22 #include "third_party/WebKit/public/platform/WebFloatRect.h" |
24 #include "third_party/WebKit/public/platform/WebGraphicsLayerDebugInfo.h" | |
25 #include "third_party/WebKit/public/platform/WebLayerClient.h" | 23 #include "third_party/WebKit/public/platform/WebLayerClient.h" |
26 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" | 24 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" |
27 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" | 25 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" |
28 #include "third_party/WebKit/public/platform/WebSize.h" | 26 #include "third_party/WebKit/public/platform/WebSize.h" |
29 #include "third_party/skia/include/utils/SkMatrix44.h" | 27 #include "third_party/skia/include/utils/SkMatrix44.h" |
30 | 28 |
31 using cc::Animation; | 29 using cc::Animation; |
32 using cc::Layer; | 30 using cc::Layer; |
33 using blink::WebLayer; | 31 using blink::WebLayer; |
34 using blink::WebFloatPoint; | 32 using blink::WebFloatPoint; |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 } | 418 } |
421 | 419 |
422 bool WebLayerImpl::isOrphan() const { | 420 bool WebLayerImpl::isOrphan() const { |
423 return !layer_->layer_tree_host(); | 421 return !layer_->layer_tree_host(); |
424 } | 422 } |
425 | 423 |
426 void WebLayerImpl::setWebLayerClient(blink::WebLayerClient* client) { | 424 void WebLayerImpl::setWebLayerClient(blink::WebLayerClient* client) { |
427 web_layer_client_ = client; | 425 web_layer_client_ = client; |
428 } | 426 } |
429 | 427 |
430 class TracedDebugInfo : public base::debug::ConvertableToTraceFormat { | 428 scoped_refptr<cc::LayerDebugInfo> WebLayerImpl::TakeDebugInfo() { |
431 public: | |
432 // This object takes ownership of the debug_info object. | |
433 explicit TracedDebugInfo(blink::WebGraphicsLayerDebugInfo* debug_info) | |
434 : debug_info_(debug_info) {} | |
435 virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE { | |
436 DCHECK(thread_checker_.CalledOnValidThread()); | |
437 blink::WebString web_string; | |
438 debug_info_->appendAsTraceFormat(&web_string); | |
439 out->append(web_string.utf8()); | |
440 } | |
441 | |
442 private: | |
443 virtual ~TracedDebugInfo() {} | |
444 scoped_ptr<blink::WebGraphicsLayerDebugInfo> debug_info_; | |
445 base::ThreadChecker thread_checker_; | |
446 }; | |
447 | |
448 scoped_refptr<base::debug::ConvertableToTraceFormat> | |
449 WebLayerImpl::TakeDebugInfo() { | |
450 if (!web_layer_client_) | 429 if (!web_layer_client_) |
451 return NULL; | 430 return NULL; |
452 blink::WebGraphicsLayerDebugInfo* debug_info = | 431 blink::WebGraphicsLayerDebugInfo* debug_info = |
453 web_layer_client_->takeDebugInfoFor(this); | 432 web_layer_client_->takeDebugInfoFor(this); |
454 | 433 |
455 if (debug_info) | 434 if (debug_info) |
456 return new TracedDebugInfo(debug_info); | 435 return new BlinkLayerDebugInfo(debug_info); |
457 else | 436 else |
458 return NULL; | 437 return NULL; |
459 } | 438 } |
460 | 439 |
461 void WebLayerImpl::setScrollParent(blink::WebLayer* parent) { | 440 void WebLayerImpl::setScrollParent(blink::WebLayer* parent) { |
462 cc::Layer* scroll_parent = NULL; | 441 cc::Layer* scroll_parent = NULL; |
463 if (parent) | 442 if (parent) |
464 scroll_parent = static_cast<WebLayerImpl*>(parent)->layer(); | 443 scroll_parent = static_cast<WebLayerImpl*>(parent)->layer(); |
465 layer_->SetScrollParent(scroll_parent); | 444 layer_->SetScrollParent(scroll_parent); |
466 } | 445 } |
467 | 446 |
468 void WebLayerImpl::setClipParent(blink::WebLayer* parent) { | 447 void WebLayerImpl::setClipParent(blink::WebLayer* parent) { |
469 cc::Layer* clip_parent = NULL; | 448 cc::Layer* clip_parent = NULL; |
470 if (parent) | 449 if (parent) |
471 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); | 450 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); |
472 layer_->SetClipParent(clip_parent); | 451 layer_->SetClipParent(clip_parent); |
473 } | 452 } |
474 | 453 |
475 Layer* WebLayerImpl::layer() const { | 454 Layer* WebLayerImpl::layer() const { |
476 return layer_.get(); | 455 return layer_.get(); |
477 } | 456 } |
478 | 457 |
479 } // namespace cc_blink | 458 } // namespace cc_blink |
OLD | NEW |