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

Side by Side Diff: cc/layers/painted_scrollbar_layer.cc

Issue 146713002: Revert of Pinch/Zoom Infrastructure & Plumbing CL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « cc/layers/painted_scrollbar_layer.h ('k') | cc/layers/painted_scrollbar_layer_impl.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/layers/painted_scrollbar_layer.h" 5 #include "cc/layers/painted_scrollbar_layer.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "cc/layers/painted_scrollbar_layer_impl.h" 10 #include "cc/layers/painted_scrollbar_layer_impl.h"
(...skipping 10 matching lines...) Expand all
21 namespace cc { 21 namespace cc {
22 22
23 scoped_ptr<LayerImpl> PaintedScrollbarLayer::CreateLayerImpl( 23 scoped_ptr<LayerImpl> PaintedScrollbarLayer::CreateLayerImpl(
24 LayerTreeImpl* tree_impl) { 24 LayerTreeImpl* tree_impl) {
25 return PaintedScrollbarLayerImpl::Create( 25 return PaintedScrollbarLayerImpl::Create(
26 tree_impl, id(), scrollbar_->Orientation()).PassAs<LayerImpl>(); 26 tree_impl, id(), scrollbar_->Orientation()).PassAs<LayerImpl>();
27 } 27 }
28 28
29 scoped_refptr<PaintedScrollbarLayer> PaintedScrollbarLayer::Create( 29 scoped_refptr<PaintedScrollbarLayer> PaintedScrollbarLayer::Create(
30 scoped_ptr<Scrollbar> scrollbar, 30 scoped_ptr<Scrollbar> scrollbar,
31 Layer* scroll_layer) { 31 int scroll_layer_id) {
32 return make_scoped_refptr( 32 return make_scoped_refptr(
33 new PaintedScrollbarLayer(scrollbar.Pass(), scroll_layer)); 33 new PaintedScrollbarLayer(scrollbar.Pass(), scroll_layer_id));
34 } 34 }
35 35
36 PaintedScrollbarLayer::PaintedScrollbarLayer( 36 PaintedScrollbarLayer::PaintedScrollbarLayer(
37 scoped_ptr<Scrollbar> scrollbar, 37 scoped_ptr<Scrollbar> scrollbar,
38 Layer* scroll_layer) 38 int scroll_layer_id)
39 : scrollbar_(scrollbar.Pass()), 39 : scrollbar_(scrollbar.Pass()),
40 scroll_layer_(scroll_layer), 40 scroll_layer_id_(scroll_layer_id),
41 clip_layer_(NULL),
42 thumb_thickness_(scrollbar_->ThumbThickness()), 41 thumb_thickness_(scrollbar_->ThumbThickness()),
43 thumb_length_(scrollbar_->ThumbLength()), 42 thumb_length_(scrollbar_->ThumbLength()),
44 is_overlay_(scrollbar_->IsOverlay()), 43 is_overlay_(scrollbar_->IsOverlay()),
45 has_thumb_(scrollbar_->HasThumb()) { 44 has_thumb_(scrollbar_->HasThumb()) {
46 if (!scrollbar_->IsOverlay()) 45 if (!scrollbar_->IsOverlay())
47 SetShouldScrollOnMainThread(true); 46 SetShouldScrollOnMainThread(true);
48 } 47 }
49 48
50 PaintedScrollbarLayer::~PaintedScrollbarLayer() {} 49 PaintedScrollbarLayer::~PaintedScrollbarLayer() {}
51 50
52 int PaintedScrollbarLayer::ScrollLayerId() const { 51 int PaintedScrollbarLayer::ScrollLayerId() const {
53 return scroll_layer_->id(); 52 return scroll_layer_id_;
54 } 53 }
55 54
56 void PaintedScrollbarLayer::SetScrollLayer(scoped_refptr<Layer> layer) { 55 void PaintedScrollbarLayer::SetScrollLayerId(int id) {
57 if (layer == scroll_layer_) 56 if (id == scroll_layer_id_)
58 return; 57 return;
59 58
60 scroll_layer_ = layer; 59 scroll_layer_id_ = id;
61 SetNeedsFullTreeSync(); 60 SetNeedsFullTreeSync();
62 } 61 }
63 62
64 void PaintedScrollbarLayer::SetClipLayer(scoped_refptr<Layer> layer) {
65 if (layer == clip_layer_)
66 return;
67
68 clip_layer_ = layer;
69 SetNeedsFullTreeSync();
70 }
71
72 bool PaintedScrollbarLayer::OpacityCanAnimateOnImplThread() const { 63 bool PaintedScrollbarLayer::OpacityCanAnimateOnImplThread() const {
73 return scrollbar_->IsOverlay(); 64 return scrollbar_->IsOverlay();
74 } 65 }
75 66
76 ScrollbarOrientation PaintedScrollbarLayer::orientation() const { 67 ScrollbarOrientation PaintedScrollbarLayer::orientation() const {
77 return scrollbar_->Orientation(); 68 return scrollbar_->Orientation();
78 } 69 }
79 70
80 int PaintedScrollbarLayer::MaxTextureSize() { 71 int PaintedScrollbarLayer::MaxTextureSize() {
81 DCHECK(layer_tree_host()); 72 DCHECK(layer_tree_host());
(...skipping 29 matching lines...) Expand all
111 page_scale_factor, 102 page_scale_factor,
112 animating_transform_to_screen, 103 animating_transform_to_screen,
113 contents_scale_x, 104 contents_scale_x,
114 contents_scale_y, 105 contents_scale_y,
115 content_bounds); 106 content_bounds);
116 } 107 }
117 108
118 void PaintedScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { 109 void PaintedScrollbarLayer::PushPropertiesTo(LayerImpl* layer) {
119 ContentsScalingLayer::PushPropertiesTo(layer); 110 ContentsScalingLayer::PushPropertiesTo(layer);
120 111
121 PushScrollClipPropertiesTo(layer);
122
123 PaintedScrollbarLayerImpl* scrollbar_layer = 112 PaintedScrollbarLayerImpl* scrollbar_layer =
124 static_cast<PaintedScrollbarLayerImpl*>(layer); 113 static_cast<PaintedScrollbarLayerImpl*>(layer);
125 114
126 scrollbar_layer->SetThumbThickness(thumb_thickness_); 115 scrollbar_layer->SetThumbThickness(thumb_thickness_);
127 scrollbar_layer->SetThumbLength(thumb_length_); 116 scrollbar_layer->SetThumbLength(thumb_length_);
128 if (orientation() == HORIZONTAL) { 117 if (orientation() == HORIZONTAL) {
129 scrollbar_layer->SetTrackStart( 118 scrollbar_layer->SetTrackStart(
130 track_rect_.x() - location_.x()); 119 track_rect_.x() - location_.x());
131 scrollbar_layer->SetTrackLength(track_rect_.width()); 120 scrollbar_layer->SetTrackLength(track_rect_.width());
132 } else { 121 } else {
133 scrollbar_layer->SetTrackStart( 122 scrollbar_layer->SetTrackStart(
134 track_rect_.y() - location_.y()); 123 track_rect_.y() - location_.y());
135 scrollbar_layer->SetTrackLength(track_rect_.height()); 124 scrollbar_layer->SetTrackLength(track_rect_.height());
136 } 125 }
137 126
138 if (track_resource_.get()) 127 if (track_resource_.get())
139 scrollbar_layer->set_track_ui_resource_id(track_resource_->id()); 128 scrollbar_layer->set_track_ui_resource_id(track_resource_->id());
140 if (thumb_resource_.get()) 129 if (thumb_resource_.get())
141 scrollbar_layer->set_thumb_ui_resource_id(thumb_resource_->id()); 130 scrollbar_layer->set_thumb_ui_resource_id(thumb_resource_->id());
142 131
143 scrollbar_layer->set_is_overlay_scrollbar(is_overlay_); 132 scrollbar_layer->set_is_overlay_scrollbar(is_overlay_);
144 } 133 }
145 134
146 ScrollbarLayerInterface* PaintedScrollbarLayer::ToScrollbarLayer() { 135 ScrollbarLayerInterface* PaintedScrollbarLayer::ToScrollbarLayer() {
147 return this; 136 return this;
148 } 137 }
149 138
150 void PaintedScrollbarLayer::PushScrollClipPropertiesTo(LayerImpl* layer) {
151 PaintedScrollbarLayerImpl* scrollbar_layer =
152 static_cast<PaintedScrollbarLayerImpl*>(layer);
153
154 scrollbar_layer->SetScrollLayerById(scroll_layer_ ? scroll_layer_->id()
155 : Layer::INVALID_ID);
156 scrollbar_layer->SetClipLayerById(clip_layer_ ? clip_layer_->id()
157 : Layer::INVALID_ID);
158 }
159
160 void PaintedScrollbarLayer::SetLayerTreeHost(LayerTreeHost* host) { 139 void PaintedScrollbarLayer::SetLayerTreeHost(LayerTreeHost* host) {
161 // When the LTH is set to null or has changed, then this layer should remove 140 // When the LTH is set to null or has changed, then this layer should remove
162 // all of its associated resources. 141 // all of its associated resources.
163 if (!host || host != layer_tree_host()) { 142 if (!host || host != layer_tree_host()) {
164 track_resource_.reset(); 143 track_resource_.reset();
165 thumb_resource_.reset(); 144 thumb_resource_.reset();
166 } 145 }
167 146
168 ContentsScalingLayer::SetLayerTreeHost(host); 147 ContentsScalingLayer::SetLayerTreeHost(host);
169 } 148 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 241
263 scrollbar_->PaintPart(&skcanvas, part, layer_rect); 242 scrollbar_->PaintPart(&skcanvas, part, layer_rect);
264 // Make sure that the pixels are no longer mutable to unavoid unnecessary 243 // Make sure that the pixels are no longer mutable to unavoid unnecessary
265 // allocation and copying. 244 // allocation and copying.
266 skbitmap.setImmutable(); 245 skbitmap.setImmutable();
267 246
268 return UIResourceBitmap(skbitmap); 247 return UIResourceBitmap(skbitmap);
269 } 248 }
270 249
271 } // namespace cc 250 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/painted_scrollbar_layer.h ('k') | cc/layers/painted_scrollbar_layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698