OLD | NEW |
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" | |
16 #include "cc/base/region.h" | 15 #include "cc/base/region.h" |
17 #include "cc/base/switches.h" | 16 #include "cc/base/switches.h" |
18 #include "cc/blink/web_animation_impl.h" | 17 #include "cc/blink/web_animation_impl.h" |
19 #include "cc/blink/web_blend_mode.h" | 18 #include "cc/blink/web_blend_mode.h" |
20 #include "cc/blink/web_filter_operations_impl.h" | 19 #include "cc/blink/web_filter_operations_impl.h" |
21 #include "cc/blink/web_to_cc_animation_delegate_adapter.h" | 20 #include "cc/blink/web_to_cc_animation_delegate_adapter.h" |
22 #include "cc/layers/layer.h" | 21 #include "cc/layers/layer.h" |
23 #include "cc/layers/layer_position_constraint.h" | 22 #include "cc/layers/layer_position_constraint.h" |
24 #include "cc/trees/layer_tree_host.h" | 23 #include "cc/trees/layer_tree_host.h" |
25 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 24 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
(...skipping 29 matching lines...) Expand all Loading... |
55 layer_->SetLayerClient(this); | 54 layer_->SetLayerClient(this); |
56 } | 55 } |
57 | 56 |
58 WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer) : layer_(layer) { | 57 WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer) : layer_(layer) { |
59 web_layer_client_ = nullptr; | 58 web_layer_client_ = nullptr; |
60 layer_->SetLayerClient(this); | 59 layer_->SetLayerClient(this); |
61 } | 60 } |
62 | 61 |
63 WebLayerImpl::~WebLayerImpl() { | 62 WebLayerImpl::~WebLayerImpl() { |
64 layer_->ClearRenderSurface(); | 63 layer_->ClearRenderSurface(); |
65 if (animation_delegate_adapter_.get()) | |
66 layer_->set_layer_animation_delegate(nullptr); | |
67 web_layer_client_ = nullptr; | 64 web_layer_client_ = nullptr; |
68 } | 65 } |
69 | 66 |
70 // static | 67 // static |
71 bool WebLayerImpl::UsingPictureLayer() { | 68 bool WebLayerImpl::UsingPictureLayer() { |
72 return g_impl_side_painting_enabled; | 69 return g_impl_side_painting_enabled; |
73 } | 70 } |
74 | 71 |
75 // static | 72 // static |
76 void WebLayerImpl::SetImplSidePaintingEnabled(bool enabled) { | 73 void WebLayerImpl::SetImplSidePaintingEnabled(bool enabled) { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 static_cast<const WebFilterOperationsImpl&>(filters); | 226 static_cast<const WebFilterOperationsImpl&>(filters); |
230 layer_->SetFilters(filters_impl.AsFilterOperations()); | 227 layer_->SetFilters(filters_impl.AsFilterOperations()); |
231 } | 228 } |
232 | 229 |
233 void WebLayerImpl::setBackgroundFilters(const WebFilterOperations& filters) { | 230 void WebLayerImpl::setBackgroundFilters(const WebFilterOperations& filters) { |
234 const WebFilterOperationsImpl& filters_impl = | 231 const WebFilterOperationsImpl& filters_impl = |
235 static_cast<const WebFilterOperationsImpl&>(filters); | 232 static_cast<const WebFilterOperationsImpl&>(filters); |
236 layer_->SetBackgroundFilters(filters_impl.AsFilterOperations()); | 233 layer_->SetBackgroundFilters(filters_impl.AsFilterOperations()); |
237 } | 234 } |
238 | 235 |
239 void WebLayerImpl::setAnimationDelegate( | |
240 blink::WebCompositorAnimationDelegate* delegate) { | |
241 animation_delegate_adapter_.reset( | |
242 new WebToCCAnimationDelegateAdapter(delegate)); | |
243 layer_->set_layer_animation_delegate(animation_delegate_adapter_.get()); | |
244 } | |
245 | |
246 bool WebLayerImpl::addAnimation(blink::WebCompositorAnimation* animation) { | |
247 bool result = layer_->AddAnimation( | |
248 static_cast<WebCompositorAnimationImpl*>(animation)->PassAnimation()); | |
249 delete animation; | |
250 return result; | |
251 } | |
252 | |
253 void WebLayerImpl::removeAnimation(int animation_id) { | |
254 layer_->RemoveAnimation(animation_id); | |
255 } | |
256 | |
257 void WebLayerImpl::removeAnimation( | |
258 int animation_id, | |
259 blink::WebCompositorAnimation::TargetProperty target_property) { | |
260 layer_->RemoveAnimation( | |
261 animation_id, static_cast<Animation::TargetProperty>(target_property)); | |
262 } | |
263 | |
264 void WebLayerImpl::pauseAnimation(int animation_id, double time_offset) { | |
265 layer_->PauseAnimation(animation_id, time_offset); | |
266 } | |
267 | |
268 bool WebLayerImpl::hasActiveAnimation() { | |
269 return layer_->HasActiveAnimation(); | |
270 } | |
271 | |
272 void WebLayerImpl::setForceRenderSurface(bool force_render_surface) { | 236 void WebLayerImpl::setForceRenderSurface(bool force_render_surface) { |
273 layer_->SetForceRenderSurface(force_render_surface); | 237 layer_->SetForceRenderSurface(force_render_surface); |
274 } | 238 } |
275 | 239 |
276 void WebLayerImpl::setScrollPositionDouble(blink::WebDoublePoint position) { | 240 void WebLayerImpl::setScrollPositionDouble(blink::WebDoublePoint position) { |
277 layer_->SetScrollOffset(gfx::ScrollOffset(position.x, position.y)); | 241 layer_->SetScrollOffset(gfx::ScrollOffset(position.x, position.y)); |
278 } | 242 } |
279 | 243 |
280 void WebLayerImpl::setScrollCompensationAdjustment( | 244 void WebLayerImpl::setScrollCompensationAdjustment( |
281 blink::WebDoublePoint position) { | 245 blink::WebDoublePoint position) { |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 if (parent) | 494 if (parent) |
531 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); | 495 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); |
532 layer_->SetClipParent(clip_parent); | 496 layer_->SetClipParent(clip_parent); |
533 } | 497 } |
534 | 498 |
535 Layer* WebLayerImpl::layer() const { | 499 Layer* WebLayerImpl::layer() const { |
536 return layer_.get(); | 500 return layer_.get(); |
537 } | 501 } |
538 | 502 |
539 } // namespace cc_blink | 503 } // namespace cc_blink |
OLD | NEW |