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

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

Issue 1419913002: Remove blink::WebLayerClient and WebGraphicsLayerDebugInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: try making webcore_shared link with base to fix win dbg component Created 5 years, 2 months 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
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/trees/layer_tree_host.h" 24 #include "cc/trees/layer_tree_host.h"
25 #include "third_party/WebKit/public/platform/WebFloatPoint.h" 25 #include "third_party/WebKit/public/platform/WebFloatPoint.h"
26 #include "third_party/WebKit/public/platform/WebFloatRect.h" 26 #include "third_party/WebKit/public/platform/WebFloatRect.h"
27 #include "third_party/WebKit/public/platform/WebGraphicsLayerDebugInfo.h"
28 #include "third_party/WebKit/public/platform/WebLayerClient.h"
29 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" 27 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h"
30 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" 28 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h"
31 #include "third_party/WebKit/public/platform/WebSize.h" 29 #include "third_party/WebKit/public/platform/WebSize.h"
32 #include "third_party/skia/include/utils/SkMatrix44.h" 30 #include "third_party/skia/include/utils/SkMatrix44.h"
33 #include "ui/gfx/geometry/rect_conversions.h" 31 #include "ui/gfx/geometry/rect_conversions.h"
34 #include "ui/gfx/geometry/vector2d_conversions.h" 32 #include "ui/gfx/geometry/vector2d_conversions.h"
35 33
36 using cc::Animation; 34 using cc::Animation;
37 using cc::Layer; 35 using cc::Layer;
38 using blink::WebLayer; 36 using blink::WebLayer;
39 using blink::WebFloatPoint; 37 using blink::WebFloatPoint;
40 using blink::WebVector; 38 using blink::WebVector;
41 using blink::WebRect; 39 using blink::WebRect;
42 using blink::WebSize; 40 using blink::WebSize;
43 using blink::WebColor; 41 using blink::WebColor;
44 using blink::WebFilterOperations; 42 using blink::WebFilterOperations;
45 43
46 namespace cc_blink { 44 namespace cc_blink {
47 namespace { 45 namespace {
48 46
49 base::LazyInstance<cc::LayerSettings> g_layer_settings = 47 base::LazyInstance<cc::LayerSettings> g_layer_settings =
50 LAZY_INSTANCE_INITIALIZER; 48 LAZY_INSTANCE_INITIALIZER;
51 49
52 } // namespace 50 } // namespace
53 51
54 WebLayerImpl::WebLayerImpl() 52 WebLayerImpl::WebLayerImpl()
55 : layer_(Layer::Create(LayerSettings())), contents_opaque_is_fixed_(false) { 53 : layer_(Layer::Create(LayerSettings())), contents_opaque_is_fixed_(false) {
56 web_layer_client_ = nullptr;
57 layer_->SetLayerClient(this);
58 } 54 }
59 55
60 WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer) 56 WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer)
61 : layer_(layer), contents_opaque_is_fixed_(false) { 57 : layer_(layer), contents_opaque_is_fixed_(false) {
62 web_layer_client_ = nullptr;
63 layer_->SetLayerClient(this);
64 } 58 }
65 59
66 WebLayerImpl::~WebLayerImpl() { 60 WebLayerImpl::~WebLayerImpl() {
67 if (animation_delegate_adapter_.get()) 61 if (animation_delegate_adapter_.get())
68 layer_->set_layer_animation_delegate(nullptr); 62 layer_->set_layer_animation_delegate(nullptr);
69 web_layer_client_ = nullptr;
70 layer_->SetLayerClient(nullptr); 63 layer_->SetLayerClient(nullptr);
71 } 64 }
72 65
73 // static 66 // static
74 void WebLayerImpl::SetLayerSettings(const cc::LayerSettings& settings) { 67 void WebLayerImpl::SetLayerSettings(const cc::LayerSettings& settings) {
75 g_layer_settings.Get() = settings; 68 g_layer_settings.Get() = settings;
76 } 69 }
77 70
78 // static 71 // static
79 const cc::LayerSettings& WebLayerImpl::LayerSettings() { 72 const cc::LayerSettings& WebLayerImpl::LayerSettings() {
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 base::Unretained(scroll_client))); 474 base::Unretained(scroll_client)));
482 } else { 475 } else {
483 layer_->set_did_scroll_callback(base::Closure()); 476 layer_->set_did_scroll_callback(base::Closure());
484 } 477 }
485 } 478 }
486 479
487 bool WebLayerImpl::isOrphan() const { 480 bool WebLayerImpl::isOrphan() const {
488 return !layer_->layer_tree_host(); 481 return !layer_->layer_tree_host();
489 } 482 }
490 483
491 void WebLayerImpl::setWebLayerClient(blink::WebLayerClient* client) { 484 void WebLayerImpl::setLayerClient(cc::LayerClient* client) {
492 web_layer_client_ = client; 485 layer_->SetLayerClient(client);
493 } 486 }
494 487
495 class TracedDebugInfo : public base::trace_event::ConvertableToTraceFormat { 488 const cc::Layer* WebLayerImpl::ccLayer() const {
danakj 2015/10/23 17:53:39 part of me wonders if this should return void* to
jbroman 2015/10/23 17:58:59 If people (including the whole of you) would like
danakj 2015/10/23 18:01:04 It'll just be weird if the WebLayer API still exis
496 public: 489 return layer_.get();
497 // This object takes ownership of the debug_info object.
498 explicit TracedDebugInfo(blink::WebGraphicsLayerDebugInfo* debug_info)
499 : debug_info_(debug_info) {}
500 void AppendAsTraceFormat(std::string* out) const override {
501 DCHECK(thread_checker_.CalledOnValidThread());
502 blink::WebString web_string;
503 debug_info_->appendAsTraceFormat(&web_string);
504 out->append(web_string.utf8());
505 }
506
507 private:
508 ~TracedDebugInfo() override {}
509 scoped_ptr<blink::WebGraphicsLayerDebugInfo> debug_info_;
510 base::ThreadChecker thread_checker_;
511 };
512
513 scoped_refptr<base::trace_event::ConvertableToTraceFormat>
514 WebLayerImpl::TakeDebugInfo() {
515 if (!web_layer_client_)
516 return nullptr;
517 blink::WebGraphicsLayerDebugInfo* debug_info =
518 web_layer_client_->takeDebugInfoFor(this);
519
520 if (debug_info)
521 return new TracedDebugInfo(debug_info);
522 else
523 return nullptr;
524 } 490 }
525 491
526 void WebLayerImpl::setScrollParent(blink::WebLayer* parent) { 492 void WebLayerImpl::setScrollParent(blink::WebLayer* parent) {
527 cc::Layer* scroll_parent = nullptr; 493 cc::Layer* scroll_parent = nullptr;
528 if (parent) 494 if (parent)
529 scroll_parent = static_cast<WebLayerImpl*>(parent)->layer(); 495 scroll_parent = static_cast<WebLayerImpl*>(parent)->layer();
530 layer_->SetScrollParent(scroll_parent); 496 layer_->SetScrollParent(scroll_parent);
531 } 497 }
532 498
533 void WebLayerImpl::setClipParent(blink::WebLayer* parent) { 499 void WebLayerImpl::setClipParent(blink::WebLayer* parent) {
534 cc::Layer* clip_parent = nullptr; 500 cc::Layer* clip_parent = nullptr;
535 if (parent) 501 if (parent)
536 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); 502 clip_parent = static_cast<WebLayerImpl*>(parent)->layer();
537 layer_->SetClipParent(clip_parent); 503 layer_->SetClipParent(clip_parent);
538 } 504 }
539 505
540 Layer* WebLayerImpl::layer() const { 506 Layer* WebLayerImpl::layer() const {
541 return layer_.get(); 507 return layer_.get();
542 } 508 }
543 509
544 void WebLayerImpl::SetContentsOpaqueIsFixed(bool fixed) { 510 void WebLayerImpl::SetContentsOpaqueIsFixed(bool fixed) {
545 contents_opaque_is_fixed_ = fixed; 511 contents_opaque_is_fixed_ = fixed;
546 } 512 }
547 513
548 } // namespace cc_blink 514 } // namespace cc_blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698