Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: cc/blink/web_layer_impl.cc

Issue 1468753002: Reland of Remove blink::WebLayerClient and WebGraphicsLayerDebugInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: do not access members of m_contentsLayer Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/blink/web_layer_impl.h ('k') | cc/layers/layer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
14 #include "base/trace_event/trace_event_impl.h" 14 #include "base/trace_event/trace_event_impl.h"
15 #include "cc/animation/animation.h" 15 #include "cc/animation/animation.h"
16 #include "cc/base/region.h" 16 #include "cc/base/region.h"
17 #include "cc/base/switches.h" 17 #include "cc/base/switches.h"
18 #include "cc/blink/web_animation_impl.h" 18 #include "cc/blink/web_animation_impl.h"
19 #include "cc/blink/web_blend_mode.h" 19 #include "cc/blink/web_blend_mode.h"
20 #include "cc/blink/web_filter_operations_impl.h" 20 #include "cc/blink/web_filter_operations_impl.h"
21 #include "cc/blink/web_to_cc_animation_delegate_adapter.h" 21 #include "cc/blink/web_to_cc_animation_delegate_adapter.h"
22 #include "cc/layers/layer.h" 22 #include "cc/layers/layer.h"
23 #include "cc/layers/layer_position_constraint.h" 23 #include "cc/layers/layer_position_constraint.h"
24 #include "cc/layers/layer_settings.h" 24 #include "cc/layers/layer_settings.h"
25 #include "cc/trees/layer_tree_host.h" 25 #include "cc/trees/layer_tree_host.h"
26 #include "third_party/WebKit/public/platform/WebFloatPoint.h" 26 #include "third_party/WebKit/public/platform/WebFloatPoint.h"
27 #include "third_party/WebKit/public/platform/WebFloatRect.h" 27 #include "third_party/WebKit/public/platform/WebFloatRect.h"
28 #include "third_party/WebKit/public/platform/WebGraphicsLayerDebugInfo.h"
29 #include "third_party/WebKit/public/platform/WebLayerClient.h"
30 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" 28 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h"
31 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" 29 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h"
32 #include "third_party/WebKit/public/platform/WebSize.h" 30 #include "third_party/WebKit/public/platform/WebSize.h"
33 #include "third_party/skia/include/utils/SkMatrix44.h" 31 #include "third_party/skia/include/utils/SkMatrix44.h"
34 #include "ui/gfx/geometry/rect_conversions.h" 32 #include "ui/gfx/geometry/rect_conversions.h"
35 #include "ui/gfx/geometry/vector2d_conversions.h" 33 #include "ui/gfx/geometry/vector2d_conversions.h"
36 34
37 using cc::Animation; 35 using cc::Animation;
38 using cc::Layer; 36 using cc::Layer;
39 using blink::WebLayer; 37 using blink::WebLayer;
40 using blink::WebFloatPoint; 38 using blink::WebFloatPoint;
41 using blink::WebVector; 39 using blink::WebVector;
42 using blink::WebRect; 40 using blink::WebRect;
43 using blink::WebSize; 41 using blink::WebSize;
44 using blink::WebColor; 42 using blink::WebColor;
45 using blink::WebFilterOperations; 43 using blink::WebFilterOperations;
46 44
47 namespace cc_blink { 45 namespace cc_blink {
48 namespace { 46 namespace {
49 47
50 base::LazyInstance<cc::LayerSettings> g_layer_settings = 48 base::LazyInstance<cc::LayerSettings> g_layer_settings =
51 LAZY_INSTANCE_INITIALIZER; 49 LAZY_INSTANCE_INITIALIZER;
52 50
53 } // namespace 51 } // namespace
54 52
55 WebLayerImpl::WebLayerImpl() 53 WebLayerImpl::WebLayerImpl()
56 : layer_(Layer::Create(LayerSettings())), contents_opaque_is_fixed_(false) { 54 : layer_(Layer::Create(LayerSettings())), contents_opaque_is_fixed_(false) {
57 web_layer_client_ = nullptr;
58 layer_->SetLayerClient(this);
59 } 55 }
60 56
61 WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer) 57 WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer)
62 : layer_(layer), contents_opaque_is_fixed_(false) { 58 : layer_(layer), contents_opaque_is_fixed_(false) {
63 web_layer_client_ = nullptr;
64 layer_->SetLayerClient(this);
65 } 59 }
66 60
67 WebLayerImpl::~WebLayerImpl() { 61 WebLayerImpl::~WebLayerImpl() {
68 if (animation_delegate_adapter_.get()) 62 if (animation_delegate_adapter_.get())
69 layer_->set_layer_animation_delegate(nullptr); 63 layer_->set_layer_animation_delegate(nullptr);
70 web_layer_client_ = nullptr;
71 layer_->SetLayerClient(nullptr); 64 layer_->SetLayerClient(nullptr);
72 } 65 }
73 66
74 // static 67 // static
75 void WebLayerImpl::SetLayerSettings(const cc::LayerSettings& settings) { 68 void WebLayerImpl::SetLayerSettings(const cc::LayerSettings& settings) {
76 g_layer_settings.Get() = settings; 69 g_layer_settings.Get() = settings;
77 } 70 }
78 71
79 // static 72 // static
80 const cc::LayerSettings& WebLayerImpl::LayerSettings() { 73 const cc::LayerSettings& WebLayerImpl::LayerSettings() {
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 base::Unretained(scroll_client))); 479 base::Unretained(scroll_client)));
487 } else { 480 } else {
488 layer_->set_did_scroll_callback(base::Closure()); 481 layer_->set_did_scroll_callback(base::Closure());
489 } 482 }
490 } 483 }
491 484
492 bool WebLayerImpl::isOrphan() const { 485 bool WebLayerImpl::isOrphan() const {
493 return !layer_->layer_tree_host(); 486 return !layer_->layer_tree_host();
494 } 487 }
495 488
496 void WebLayerImpl::setWebLayerClient(blink::WebLayerClient* client) { 489 void WebLayerImpl::setLayerClient(cc::LayerClient* client) {
497 web_layer_client_ = client; 490 layer_->SetLayerClient(client);
498 } 491 }
499 492
500 class TracedDebugInfo : public base::trace_event::ConvertableToTraceFormat { 493 const cc::Layer* WebLayerImpl::ccLayer() const {
501 public: 494 return layer_.get();
502 // This object takes ownership of the debug_info object.
503 explicit TracedDebugInfo(blink::WebGraphicsLayerDebugInfo* debug_info)
504 : debug_info_(debug_info) {}
505 void AppendAsTraceFormat(std::string* out) const override {
506 DCHECK(thread_checker_.CalledOnValidThread());
507 blink::WebString web_string;
508 debug_info_->appendAsTraceFormat(&web_string);
509 out->append(web_string.utf8());
510 }
511
512 private:
513 ~TracedDebugInfo() override {}
514 scoped_ptr<blink::WebGraphicsLayerDebugInfo> debug_info_;
515 base::ThreadChecker thread_checker_;
516 };
517
518 scoped_refptr<base::trace_event::ConvertableToTraceFormat>
519 WebLayerImpl::TakeDebugInfo() {
520 if (!web_layer_client_)
521 return nullptr;
522 blink::WebGraphicsLayerDebugInfo* debug_info =
523 web_layer_client_->takeDebugInfoFor(this);
524
525 if (debug_info)
526 return new TracedDebugInfo(debug_info);
527 else
528 return nullptr;
529 } 495 }
530 496
531 void WebLayerImpl::setScrollParent(blink::WebLayer* parent) { 497 void WebLayerImpl::setScrollParent(blink::WebLayer* parent) {
532 cc::Layer* scroll_parent = nullptr; 498 cc::Layer* scroll_parent = nullptr;
533 if (parent) 499 if (parent)
534 scroll_parent = static_cast<WebLayerImpl*>(parent)->layer(); 500 scroll_parent = static_cast<WebLayerImpl*>(parent)->layer();
535 layer_->SetScrollParent(scroll_parent); 501 layer_->SetScrollParent(scroll_parent);
536 } 502 }
537 503
538 void WebLayerImpl::setClipParent(blink::WebLayer* parent) { 504 void WebLayerImpl::setClipParent(blink::WebLayer* parent) {
539 cc::Layer* clip_parent = nullptr; 505 cc::Layer* clip_parent = nullptr;
540 if (parent) 506 if (parent)
541 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); 507 clip_parent = static_cast<WebLayerImpl*>(parent)->layer();
542 layer_->SetClipParent(clip_parent); 508 layer_->SetClipParent(clip_parent);
543 } 509 }
544 510
545 Layer* WebLayerImpl::layer() const { 511 Layer* WebLayerImpl::layer() const {
546 return layer_.get(); 512 return layer_.get();
547 } 513 }
548 514
549 void WebLayerImpl::SetContentsOpaqueIsFixed(bool fixed) { 515 void WebLayerImpl::SetContentsOpaqueIsFixed(bool fixed) {
550 contents_opaque_is_fixed_ = fixed; 516 contents_opaque_is_fixed_ = fixed;
551 } 517 }
552 518
553 } // namespace cc_blink 519 } // namespace cc_blink
OLDNEW
« no previous file with comments | « cc/blink/web_layer_impl.h ('k') | cc/layers/layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698