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 "content/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/debug/trace_event_impl.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
12 #include "cc/animation/animation.h" | 12 #include "cc/animation/animation.h" |
13 #include "cc/base/region.h" | 13 #include "cc/base/region.h" |
14 #include "cc/base/switches.h" | 14 #include "cc/base/switches.h" |
15 #include "cc/layers/layer.h" | 15 #include "cc/layers/layer.h" |
16 #include "cc/layers/layer_position_constraint.h" | 16 #include "cc/layers/layer_position_constraint.h" |
17 #include "cc/trees/layer_tree_host.h" | 17 #include "cc/trees/layer_tree_host.h" |
| 18 #include "content/renderer/compositor_bindings/web_animation_impl.h" |
| 19 #include "content/renderer/compositor_bindings/web_blend_mode.h" |
| 20 #include "content/renderer/compositor_bindings/web_filter_operations_impl.h" |
| 21 #include "content/renderer/compositor_bindings/web_to_cc_animation_delegate_adap
ter.h" |
18 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 22 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
19 #include "third_party/WebKit/public/platform/WebFloatRect.h" | 23 #include "third_party/WebKit/public/platform/WebFloatRect.h" |
20 #include "third_party/WebKit/public/platform/WebGraphicsLayerDebugInfo.h" | 24 #include "third_party/WebKit/public/platform/WebGraphicsLayerDebugInfo.h" |
21 #include "third_party/WebKit/public/platform/WebLayerClient.h" | 25 #include "third_party/WebKit/public/platform/WebLayerClient.h" |
22 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" | 26 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" |
23 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" | 27 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" |
24 #include "third_party/WebKit/public/platform/WebSize.h" | 28 #include "third_party/WebKit/public/platform/WebSize.h" |
25 #include "third_party/skia/include/utils/SkMatrix44.h" | 29 #include "third_party/skia/include/utils/SkMatrix44.h" |
26 #include "webkit/renderer/compositor_bindings/web_animation_impl.h" | |
27 #include "webkit/renderer/compositor_bindings/web_blend_mode.h" | |
28 #include "webkit/renderer/compositor_bindings/web_filter_operations_impl.h" | |
29 #include "webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapt
er.h" | |
30 | 30 |
31 using cc::Animation; | 31 using cc::Animation; |
32 using cc::Layer; | 32 using cc::Layer; |
33 using blink::WebLayer; | 33 using blink::WebLayer; |
34 using blink::WebFloatPoint; | 34 using blink::WebFloatPoint; |
35 using blink::WebVector; | 35 using blink::WebVector; |
36 using blink::WebRect; | 36 using blink::WebRect; |
37 using blink::WebSize; | 37 using blink::WebSize; |
38 using blink::WebColor; | 38 using blink::WebColor; |
39 using blink::WebFilterOperations; | 39 using blink::WebFilterOperations; |
40 | 40 |
41 namespace webkit { | 41 namespace content { |
42 namespace { | 42 namespace { |
43 | 43 |
44 bool g_impl_side_painting_enabled = false; | 44 bool g_impl_side_painting_enabled = false; |
45 | 45 |
46 } // namespace | 46 } // namespace |
47 | 47 |
48 WebLayerImpl::WebLayerImpl() : layer_(Layer::Create()) { | 48 WebLayerImpl::WebLayerImpl() : layer_(Layer::Create()) { |
49 web_layer_client_ = NULL; | 49 web_layer_client_ = NULL; |
50 layer_->SetLayerClient(this); | 50 layer_->SetLayerClient(this); |
51 } | 51 } |
(...skipping 12 matching lines...) Expand all Loading... |
64 // static | 64 // static |
65 bool WebLayerImpl::UsingPictureLayer() { | 65 bool WebLayerImpl::UsingPictureLayer() { |
66 return g_impl_side_painting_enabled; | 66 return g_impl_side_painting_enabled; |
67 } | 67 } |
68 | 68 |
69 // static | 69 // static |
70 void WebLayerImpl::SetImplSidePaintingEnabled(bool enabled) { | 70 void WebLayerImpl::SetImplSidePaintingEnabled(bool enabled) { |
71 g_impl_side_painting_enabled = enabled; | 71 g_impl_side_painting_enabled = enabled; |
72 } | 72 } |
73 | 73 |
74 int WebLayerImpl::id() const { return layer_->id(); } | 74 int WebLayerImpl::id() const { |
| 75 return layer_->id(); |
| 76 } |
75 | 77 |
76 void WebLayerImpl::invalidateRect(const blink::WebFloatRect& rect) { | 78 void WebLayerImpl::invalidateRect(const blink::WebFloatRect& rect) { |
77 layer_->SetNeedsDisplayRect(rect); | 79 layer_->SetNeedsDisplayRect(rect); |
78 } | 80 } |
79 | 81 |
80 void WebLayerImpl::invalidate() { layer_->SetNeedsDisplay(); } | 82 void WebLayerImpl::invalidate() { |
| 83 layer_->SetNeedsDisplay(); |
| 84 } |
81 | 85 |
82 void WebLayerImpl::addChild(WebLayer* child) { | 86 void WebLayerImpl::addChild(WebLayer* child) { |
83 layer_->AddChild(static_cast<WebLayerImpl*>(child)->layer()); | 87 layer_->AddChild(static_cast<WebLayerImpl*>(child)->layer()); |
84 } | 88 } |
85 | 89 |
86 void WebLayerImpl::insertChild(WebLayer* child, size_t index) { | 90 void WebLayerImpl::insertChild(WebLayer* child, size_t index) { |
87 layer_->InsertChild(static_cast<WebLayerImpl*>(child)->layer(), index); | 91 layer_->InsertChild(static_cast<WebLayerImpl*>(child)->layer(), index); |
88 } | 92 } |
89 | 93 |
90 void WebLayerImpl::replaceChild(WebLayer* reference, WebLayer* new_layer) { | 94 void WebLayerImpl::replaceChild(WebLayer* reference, WebLayer* new_layer) { |
91 layer_->ReplaceChild(static_cast<WebLayerImpl*>(reference)->layer(), | 95 layer_->ReplaceChild(static_cast<WebLayerImpl*>(reference)->layer(), |
92 static_cast<WebLayerImpl*>(new_layer)->layer()); | 96 static_cast<WebLayerImpl*>(new_layer)->layer()); |
93 } | 97 } |
94 | 98 |
95 void WebLayerImpl::removeFromParent() { layer_->RemoveFromParent(); } | 99 void WebLayerImpl::removeFromParent() { |
| 100 layer_->RemoveFromParent(); |
| 101 } |
96 | 102 |
97 void WebLayerImpl::removeAllChildren() { layer_->RemoveAllChildren(); } | 103 void WebLayerImpl::removeAllChildren() { |
| 104 layer_->RemoveAllChildren(); |
| 105 } |
98 | 106 |
99 void WebLayerImpl::setAnchorPoint(const WebFloatPoint& anchor_point) { | 107 void WebLayerImpl::setAnchorPoint(const WebFloatPoint& anchor_point) { |
100 layer_->SetAnchorPoint(anchor_point); | 108 layer_->SetAnchorPoint(anchor_point); |
101 } | 109 } |
102 | 110 |
103 WebFloatPoint WebLayerImpl::anchorPoint() const { | 111 WebFloatPoint WebLayerImpl::anchorPoint() const { |
104 return layer_->anchor_point(); | 112 return layer_->anchor_point(); |
105 } | 113 } |
106 | 114 |
107 void WebLayerImpl::setAnchorPointZ(float anchor_point_z) { | 115 void WebLayerImpl::setAnchorPointZ(float anchor_point_z) { |
108 layer_->SetAnchorPointZ(anchor_point_z); | 116 layer_->SetAnchorPointZ(anchor_point_z); |
109 } | 117 } |
110 | 118 |
111 float WebLayerImpl::anchorPointZ() const { return layer_->anchor_point_z(); } | 119 float WebLayerImpl::anchorPointZ() const { |
| 120 return layer_->anchor_point_z(); |
| 121 } |
112 | 122 |
113 void WebLayerImpl::setBounds(const WebSize& size) { layer_->SetBounds(size); } | 123 void WebLayerImpl::setBounds(const WebSize& size) { |
| 124 layer_->SetBounds(size); |
| 125 } |
114 | 126 |
115 WebSize WebLayerImpl::bounds() const { return layer_->bounds(); } | 127 WebSize WebLayerImpl::bounds() const { |
| 128 return layer_->bounds(); |
| 129 } |
116 | 130 |
117 void WebLayerImpl::setMasksToBounds(bool masks_to_bounds) { | 131 void WebLayerImpl::setMasksToBounds(bool masks_to_bounds) { |
118 layer_->SetMasksToBounds(masks_to_bounds); | 132 layer_->SetMasksToBounds(masks_to_bounds); |
119 } | 133 } |
120 | 134 |
121 bool WebLayerImpl::masksToBounds() const { return layer_->masks_to_bounds(); } | 135 bool WebLayerImpl::masksToBounds() const { |
| 136 return layer_->masks_to_bounds(); |
| 137 } |
122 | 138 |
123 void WebLayerImpl::setMaskLayer(WebLayer* maskLayer) { | 139 void WebLayerImpl::setMaskLayer(WebLayer* maskLayer) { |
124 layer_->SetMaskLayer( | 140 layer_->SetMaskLayer( |
125 maskLayer ? static_cast<WebLayerImpl*>(maskLayer)->layer() : 0); | 141 maskLayer ? static_cast<WebLayerImpl*>(maskLayer)->layer() : 0); |
126 } | 142 } |
127 | 143 |
128 void WebLayerImpl::setReplicaLayer(WebLayer* replica_layer) { | 144 void WebLayerImpl::setReplicaLayer(WebLayer* replica_layer) { |
129 layer_->SetReplicaLayer( | 145 layer_->SetReplicaLayer( |
130 replica_layer ? static_cast<WebLayerImpl*>(replica_layer)->layer() : 0); | 146 replica_layer ? static_cast<WebLayerImpl*>(replica_layer)->layer() : 0); |
131 } | 147 } |
132 | 148 |
133 void WebLayerImpl::setOpacity(float opacity) { layer_->SetOpacity(opacity); } | 149 void WebLayerImpl::setOpacity(float opacity) { |
| 150 layer_->SetOpacity(opacity); |
| 151 } |
134 | 152 |
135 float WebLayerImpl::opacity() const { return layer_->opacity(); } | 153 float WebLayerImpl::opacity() const { |
| 154 return layer_->opacity(); |
| 155 } |
136 | 156 |
137 void WebLayerImpl::setBlendMode(blink::WebBlendMode blend_mode) { | 157 void WebLayerImpl::setBlendMode(blink::WebBlendMode blend_mode) { |
138 layer_->SetBlendMode(BlendModeToSkia(blend_mode)); | 158 layer_->SetBlendMode(BlendModeToSkia(blend_mode)); |
139 } | 159 } |
140 | 160 |
141 blink::WebBlendMode WebLayerImpl::blendMode() const { | 161 blink::WebBlendMode WebLayerImpl::blendMode() const { |
142 return BlendModeFromSkia(layer_->blend_mode()); | 162 return BlendModeFromSkia(layer_->blend_mode()); |
143 } | 163 } |
144 | 164 |
145 void WebLayerImpl::setIsRootForIsolatedGroup(bool isolate) { | 165 void WebLayerImpl::setIsRootForIsolatedGroup(bool isolate) { |
146 layer_->SetIsRootForIsolatedGroup(isolate); | 166 layer_->SetIsRootForIsolatedGroup(isolate); |
147 } | 167 } |
148 | 168 |
149 bool WebLayerImpl::isRootForIsolatedGroup() { | 169 bool WebLayerImpl::isRootForIsolatedGroup() { |
150 return layer_->is_root_for_isolated_group(); | 170 return layer_->is_root_for_isolated_group(); |
151 } | 171 } |
152 | 172 |
153 void WebLayerImpl::setOpaque(bool opaque) { layer_->SetContentsOpaque(opaque); } | 173 void WebLayerImpl::setOpaque(bool opaque) { |
| 174 layer_->SetContentsOpaque(opaque); |
| 175 } |
154 | 176 |
155 bool WebLayerImpl::opaque() const { return layer_->contents_opaque(); } | 177 bool WebLayerImpl::opaque() const { |
| 178 return layer_->contents_opaque(); |
| 179 } |
156 | 180 |
157 void WebLayerImpl::setPosition(const WebFloatPoint& position) { | 181 void WebLayerImpl::setPosition(const WebFloatPoint& position) { |
158 layer_->SetPosition(position); | 182 layer_->SetPosition(position); |
159 } | 183 } |
160 | 184 |
161 WebFloatPoint WebLayerImpl::position() const { return layer_->position(); } | 185 WebFloatPoint WebLayerImpl::position() const { |
| 186 return layer_->position(); |
| 187 } |
162 | 188 |
163 void WebLayerImpl::setTransform(const SkMatrix44& matrix) { | 189 void WebLayerImpl::setTransform(const SkMatrix44& matrix) { |
164 gfx::Transform transform; | 190 gfx::Transform transform; |
165 transform.matrix() = matrix; | 191 transform.matrix() = matrix; |
166 layer_->SetTransform(transform); | 192 layer_->SetTransform(transform); |
167 } | 193 } |
168 | 194 |
169 SkMatrix44 WebLayerImpl::transform() const { | 195 SkMatrix44 WebLayerImpl::transform() const { |
170 return layer_->transform().matrix(); | 196 return layer_->transform().matrix(); |
171 } | 197 } |
172 | 198 |
173 void WebLayerImpl::setDrawsContent(bool draws_content) { | 199 void WebLayerImpl::setDrawsContent(bool draws_content) { |
174 layer_->SetIsDrawable(draws_content); | 200 layer_->SetIsDrawable(draws_content); |
175 } | 201 } |
176 | 202 |
177 bool WebLayerImpl::drawsContent() const { return layer_->DrawsContent(); } | 203 bool WebLayerImpl::drawsContent() const { |
| 204 return layer_->DrawsContent(); |
| 205 } |
178 | 206 |
179 void WebLayerImpl::setShouldFlattenTransform(bool flatten) { | 207 void WebLayerImpl::setShouldFlattenTransform(bool flatten) { |
180 layer_->SetShouldFlattenTransform(flatten); | 208 layer_->SetShouldFlattenTransform(flatten); |
181 } | 209 } |
182 | 210 |
183 void WebLayerImpl::setRenderingContext(int context) { | 211 void WebLayerImpl::setRenderingContext(int context) { |
184 layer_->SetIs3dSorted(context != 0); | 212 layer_->SetIs3dSorted(context != 0); |
185 } | 213 } |
186 | 214 |
187 void WebLayerImpl::setUseParentBackfaceVisibility( | 215 void WebLayerImpl::setUseParentBackfaceVisibility( |
(...skipping 14 matching lines...) Expand all Loading... |
202 static_cast<const WebFilterOperationsImpl&>(filters); | 230 static_cast<const WebFilterOperationsImpl&>(filters); |
203 layer_->SetFilters(filters_impl.AsFilterOperations()); | 231 layer_->SetFilters(filters_impl.AsFilterOperations()); |
204 } | 232 } |
205 | 233 |
206 void WebLayerImpl::setBackgroundFilters(const WebFilterOperations& filters) { | 234 void WebLayerImpl::setBackgroundFilters(const WebFilterOperations& filters) { |
207 const WebFilterOperationsImpl& filters_impl = | 235 const WebFilterOperationsImpl& filters_impl = |
208 static_cast<const WebFilterOperationsImpl&>(filters); | 236 static_cast<const WebFilterOperationsImpl&>(filters); |
209 layer_->SetBackgroundFilters(filters_impl.AsFilterOperations()); | 237 layer_->SetBackgroundFilters(filters_impl.AsFilterOperations()); |
210 } | 238 } |
211 | 239 |
212 void WebLayerImpl::setAnimationDelegate( | 240 void WebLayerImpl::setAnimationDelegate(blink::WebAnimationDelegate* delegate) { |
213 blink::WebAnimationDelegate* delegate) { | |
214 animation_delegate_adapter_.reset( | 241 animation_delegate_adapter_.reset( |
215 new WebToCCAnimationDelegateAdapter(delegate)); | 242 new WebToCCAnimationDelegateAdapter(delegate)); |
216 layer_->set_layer_animation_delegate(animation_delegate_adapter_.get()); | 243 layer_->set_layer_animation_delegate(animation_delegate_adapter_.get()); |
217 } | 244 } |
218 | 245 |
219 bool WebLayerImpl::addAnimation(blink::WebAnimation* animation) { | 246 bool WebLayerImpl::addAnimation(blink::WebAnimation* animation) { |
220 bool result = layer_->AddAnimation( | 247 bool result = layer_->AddAnimation( |
221 static_cast<WebAnimationImpl*>(animation)->PassAnimation()); | 248 static_cast<WebAnimationImpl*>(animation)->PassAnimation()); |
222 delete animation; | 249 delete animation; |
223 return result; | 250 return result; |
224 } | 251 } |
225 | 252 |
226 void WebLayerImpl::removeAnimation(int animation_id) { | 253 void WebLayerImpl::removeAnimation(int animation_id) { |
227 layer_->RemoveAnimation(animation_id); | 254 layer_->RemoveAnimation(animation_id); |
228 } | 255 } |
229 | 256 |
230 void WebLayerImpl::removeAnimation( | 257 void WebLayerImpl::removeAnimation( |
231 int animation_id, | 258 int animation_id, |
232 blink::WebAnimation::TargetProperty target_property) { | 259 blink::WebAnimation::TargetProperty target_property) { |
233 layer_->layer_animation_controller()->RemoveAnimation( | 260 layer_->layer_animation_controller()->RemoveAnimation( |
234 animation_id, | 261 animation_id, static_cast<Animation::TargetProperty>(target_property)); |
235 static_cast<Animation::TargetProperty>(target_property)); | |
236 } | 262 } |
237 | 263 |
238 void WebLayerImpl::pauseAnimation(int animation_id, double time_offset) { | 264 void WebLayerImpl::pauseAnimation(int animation_id, double time_offset) { |
239 layer_->PauseAnimation(animation_id, time_offset); | 265 layer_->PauseAnimation(animation_id, time_offset); |
240 } | 266 } |
241 | 267 |
242 bool WebLayerImpl::hasActiveAnimation() { return layer_->HasActiveAnimation(); } | 268 bool WebLayerImpl::hasActiveAnimation() { |
| 269 return layer_->HasActiveAnimation(); |
| 270 } |
243 | 271 |
244 void WebLayerImpl::setForceRenderSurface(bool force_render_surface) { | 272 void WebLayerImpl::setForceRenderSurface(bool force_render_surface) { |
245 layer_->SetForceRenderSurface(force_render_surface); | 273 layer_->SetForceRenderSurface(force_render_surface); |
246 } | 274 } |
247 | 275 |
248 void WebLayerImpl::setScrollPosition(blink::WebPoint position) { | 276 void WebLayerImpl::setScrollPosition(blink::WebPoint position) { |
249 layer_->SetScrollOffset(gfx::Point(position).OffsetFromOrigin()); | 277 layer_->SetScrollOffset(gfx::Point(position).OffsetFromOrigin()); |
250 } | 278 } |
251 | 279 |
252 blink::WebPoint WebLayerImpl::scrollPosition() const { | 280 blink::WebPoint WebLayerImpl::scrollPosition() const { |
253 return gfx::PointAtOffsetFromOrigin(layer_->scroll_offset()); | 281 return gfx::PointAtOffsetFromOrigin(layer_->scroll_offset()); |
254 } | 282 } |
255 | 283 |
256 void WebLayerImpl::setScrollClipLayer(WebLayer* clip_layer) { | 284 void WebLayerImpl::setScrollClipLayer(WebLayer* clip_layer) { |
257 if (!clip_layer) { | 285 if (!clip_layer) { |
258 layer_->SetScrollClipLayerId(Layer::INVALID_ID); | 286 layer_->SetScrollClipLayerId(Layer::INVALID_ID); |
259 return; | 287 return; |
260 } | 288 } |
261 layer_->SetScrollClipLayerId(clip_layer->id()); | 289 layer_->SetScrollClipLayerId(clip_layer->id()); |
262 } | 290 } |
263 | 291 |
264 bool WebLayerImpl::scrollable() const { return layer_->scrollable(); } | 292 bool WebLayerImpl::scrollable() const { |
| 293 return layer_->scrollable(); |
| 294 } |
265 | 295 |
266 void WebLayerImpl::setUserScrollable(bool horizontal, bool vertical) { | 296 void WebLayerImpl::setUserScrollable(bool horizontal, bool vertical) { |
267 layer_->SetUserScrollable(horizontal, vertical); | 297 layer_->SetUserScrollable(horizontal, vertical); |
268 } | 298 } |
269 | 299 |
270 bool WebLayerImpl::userScrollableHorizontal() const { | 300 bool WebLayerImpl::userScrollableHorizontal() const { |
271 return layer_->user_scrollable_horizontal(); | 301 return layer_->user_scrollable_horizontal(); |
272 } | 302 } |
273 | 303 |
274 bool WebLayerImpl::userScrollableVertical() const { | 304 bool WebLayerImpl::userScrollableVertical() const { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 408 |
379 void WebLayerImpl::setPositionConstraint( | 409 void WebLayerImpl::setPositionConstraint( |
380 const blink::WebLayerPositionConstraint& constraint) { | 410 const blink::WebLayerPositionConstraint& constraint) { |
381 layer_->SetPositionConstraint(ToLayerPositionConstraint(constraint)); | 411 layer_->SetPositionConstraint(ToLayerPositionConstraint(constraint)); |
382 } | 412 } |
383 | 413 |
384 blink::WebLayerPositionConstraint WebLayerImpl::positionConstraint() const { | 414 blink::WebLayerPositionConstraint WebLayerImpl::positionConstraint() const { |
385 return ToWebLayerPositionConstraint(layer_->position_constraint()); | 415 return ToWebLayerPositionConstraint(layer_->position_constraint()); |
386 } | 416 } |
387 | 417 |
388 void WebLayerImpl::setScrollClient( | 418 void WebLayerImpl::setScrollClient(blink::WebLayerScrollClient* scroll_client) { |
389 blink::WebLayerScrollClient* scroll_client) { | |
390 if (scroll_client) { | 419 if (scroll_client) { |
391 layer_->set_did_scroll_callback( | 420 layer_->set_did_scroll_callback( |
392 base::Bind(&blink::WebLayerScrollClient::didScroll, | 421 base::Bind(&blink::WebLayerScrollClient::didScroll, |
393 base::Unretained(scroll_client))); | 422 base::Unretained(scroll_client))); |
394 } else { | 423 } else { |
395 layer_->set_did_scroll_callback(base::Closure()); | 424 layer_->set_did_scroll_callback(base::Closure()); |
396 } | 425 } |
397 } | 426 } |
398 | 427 |
399 bool WebLayerImpl::isOrphan() const { return !layer_->layer_tree_host(); } | 428 bool WebLayerImpl::isOrphan() const { |
| 429 return !layer_->layer_tree_host(); |
| 430 } |
400 | 431 |
401 void WebLayerImpl::setWebLayerClient(blink::WebLayerClient* client) { | 432 void WebLayerImpl::setWebLayerClient(blink::WebLayerClient* client) { |
402 web_layer_client_ = client; | 433 web_layer_client_ = client; |
403 } | 434 } |
404 | 435 |
405 class TracedDebugInfo : public base::debug::ConvertableToTraceFormat { | 436 class TracedDebugInfo : public base::debug::ConvertableToTraceFormat { |
406 public: | 437 public: |
407 // This object takes ownership of the debug_info object. | 438 // This object takes ownership of the debug_info object. |
408 explicit TracedDebugInfo(blink::WebGraphicsLayerDebugInfo* debug_info) : | 439 explicit TracedDebugInfo(blink::WebGraphicsLayerDebugInfo* debug_info) |
409 debug_info_(debug_info) {} | 440 : debug_info_(debug_info) {} |
410 virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE { | 441 virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE { |
411 DCHECK(thread_checker_.CalledOnValidThread()); | 442 DCHECK(thread_checker_.CalledOnValidThread()); |
412 blink::WebString web_string; | 443 blink::WebString web_string; |
413 debug_info_->appendAsTraceFormat(&web_string); | 444 debug_info_->appendAsTraceFormat(&web_string); |
414 out->append(web_string.utf8()); | 445 out->append(web_string.utf8()); |
415 } | 446 } |
| 447 |
416 private: | 448 private: |
417 virtual ~TracedDebugInfo() {} | 449 virtual ~TracedDebugInfo() {} |
418 scoped_ptr<blink::WebGraphicsLayerDebugInfo> debug_info_; | 450 scoped_ptr<blink::WebGraphicsLayerDebugInfo> debug_info_; |
419 base::ThreadChecker thread_checker_; | 451 base::ThreadChecker thread_checker_; |
420 }; | 452 }; |
421 | 453 |
422 scoped_refptr<base::debug::ConvertableToTraceFormat> | 454 scoped_refptr<base::debug::ConvertableToTraceFormat> |
423 WebLayerImpl::TakeDebugInfo() { | 455 WebLayerImpl::TakeDebugInfo() { |
424 if (!web_layer_client_) | 456 if (!web_layer_client_) |
425 return NULL; | 457 return NULL; |
426 blink::WebGraphicsLayerDebugInfo* debug_info = | 458 blink::WebGraphicsLayerDebugInfo* debug_info = |
427 web_layer_client_->takeDebugInfoFor(this); | 459 web_layer_client_->takeDebugInfoFor(this); |
428 | 460 |
429 if (debug_info) | 461 if (debug_info) |
430 return new TracedDebugInfo(debug_info); | 462 return new TracedDebugInfo(debug_info); |
431 else | 463 else |
432 return NULL; | 464 return NULL; |
433 } | 465 } |
434 | 466 |
435 void WebLayerImpl::setScrollParent(blink::WebLayer* parent) { | 467 void WebLayerImpl::setScrollParent(blink::WebLayer* parent) { |
436 cc::Layer* scroll_parent = NULL; | 468 cc::Layer* scroll_parent = NULL; |
437 if (parent) | 469 if (parent) |
438 scroll_parent = static_cast<WebLayerImpl*>(parent)->layer(); | 470 scroll_parent = static_cast<WebLayerImpl*>(parent)->layer(); |
439 layer_->SetScrollParent(scroll_parent); | 471 layer_->SetScrollParent(scroll_parent); |
440 } | 472 } |
441 | 473 |
442 void WebLayerImpl::setClipParent(blink::WebLayer* parent) { | 474 void WebLayerImpl::setClipParent(blink::WebLayer* parent) { |
443 cc::Layer* clip_parent = NULL; | 475 cc::Layer* clip_parent = NULL; |
444 if (parent) | 476 if (parent) |
445 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); | 477 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); |
446 layer_->SetClipParent(clip_parent); | 478 layer_->SetClipParent(clip_parent); |
447 } | 479 } |
448 | 480 |
449 Layer* WebLayerImpl::layer() const { return layer_.get(); } | 481 Layer* WebLayerImpl::layer() const { |
| 482 return layer_.get(); |
| 483 } |
450 | 484 |
451 } // namespace webkit | 485 } // namespace content |
OLD | NEW |