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 scoped_refptr<base::debug::ConvertableToTraceFormat> | |
394 WebLayerImpl::TakeDebugInfo() { | |
395 if (!web_layer_client_) | |
396 return NULL; | |
397 blink::WebGraphicsLayerDebugInfo* debug_info = | |
398 web_layer_client_->takeDebugInfo(); | |
399 | |
400 if (debug_info) | |
401 return scoped_refptr<base::debug::ConvertableToTraceFormat>( | |
danakj
2013/12/03 00:38:18
nit: you don't need to wrap this with the construc
chrishtr_gmail.com
2013/12/03 00:44:08
Done.
| |
402 new TracedDebugInfo(debug_info)); | |
403 else | |
404 return NULL; | |
405 } | |
406 | |
375 std::string WebLayerImpl::DebugName() { | 407 std::string WebLayerImpl::DebugName() { |
376 if (!web_layer_client_) | 408 if (!web_layer_client_) |
377 return std::string(); | 409 return std::string(); |
378 | 410 |
379 std::string name = web_layer_client_->debugName(this).utf8(); | 411 std::string name = web_layer_client_->debugName(this).utf8(); |
380 DCHECK(IsStringASCII(name)); | 412 DCHECK(IsStringASCII(name)); |
381 return name; | 413 return name; |
382 } | 414 } |
383 | 415 |
384 void WebLayerImpl::setScrollParent(blink::WebLayer* parent) { | 416 void WebLayerImpl::setScrollParent(blink::WebLayer* parent) { |
385 cc::Layer* scroll_parent = NULL; | 417 cc::Layer* scroll_parent = NULL; |
386 if (parent) | 418 if (parent) |
387 scroll_parent = static_cast<WebLayerImpl*>(parent)->layer(); | 419 scroll_parent = static_cast<WebLayerImpl*>(parent)->layer(); |
388 layer_->SetScrollParent(scroll_parent); | 420 layer_->SetScrollParent(scroll_parent); |
389 } | 421 } |
390 | 422 |
391 void WebLayerImpl::setClipParent(blink::WebLayer* parent) { | 423 void WebLayerImpl::setClipParent(blink::WebLayer* parent) { |
392 cc::Layer* clip_parent = NULL; | 424 cc::Layer* clip_parent = NULL; |
393 if (parent) | 425 if (parent) |
394 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); | 426 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); |
395 layer_->SetClipParent(clip_parent); | 427 layer_->SetClipParent(clip_parent); |
396 } | 428 } |
397 | 429 |
398 Layer* WebLayerImpl::layer() const { return layer_.get(); } | 430 Layer* WebLayerImpl::layer() const { return layer_.get(); } |
399 | 431 |
400 } // namespace webkit | 432 } // namespace webkit |
OLD | NEW |