| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
| 17 #include "base/trace_event/trace_event_impl.h" | 17 #include "base/trace_event/trace_event_impl.h" |
| 18 #include "cc/animation/animation.h" | 18 #include "cc/animation/animation.h" |
| 19 #include "cc/base/region.h" | 19 #include "cc/base/region.h" |
| 20 #include "cc/base/switches.h" | 20 #include "cc/base/switches.h" |
| 21 #include "cc/blink/web_animation_impl.h" | |
| 22 #include "cc/blink/web_blend_mode.h" | 21 #include "cc/blink/web_blend_mode.h" |
| 23 #include "cc/blink/web_filter_operations_impl.h" | |
| 24 #include "cc/blink/web_to_cc_animation_delegate_adapter.h" | 22 #include "cc/blink/web_to_cc_animation_delegate_adapter.h" |
| 25 #include "cc/layers/layer.h" | 23 #include "cc/layers/layer.h" |
| 26 #include "cc/layers/layer_position_constraint.h" | 24 #include "cc/layers/layer_position_constraint.h" |
| 27 #include "cc/layers/layer_settings.h" | 25 #include "cc/layers/layer_settings.h" |
| 28 #include "cc/trees/layer_tree_host.h" | 26 #include "cc/trees/layer_tree_host.h" |
| 29 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 27 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
| 30 #include "third_party/WebKit/public/platform/WebFloatRect.h" | 28 #include "third_party/WebKit/public/platform/WebFloatRect.h" |
| 31 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" | 29 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" |
| 32 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" | 30 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" |
| 33 #include "third_party/WebKit/public/platform/WebSize.h" | 31 #include "third_party/WebKit/public/platform/WebSize.h" |
| 34 #include "third_party/skia/include/utils/SkMatrix44.h" | 32 #include "third_party/skia/include/utils/SkMatrix44.h" |
| 35 #include "ui/gfx/geometry/rect_conversions.h" | 33 #include "ui/gfx/geometry/rect_conversions.h" |
| 36 #include "ui/gfx/geometry/vector2d_conversions.h" | 34 #include "ui/gfx/geometry/vector2d_conversions.h" |
| 37 | 35 |
| 38 using cc::Animation; | 36 using cc::Animation; |
| 39 using cc::Layer; | 37 using cc::Layer; |
| 40 using blink::WebLayer; | 38 using blink::WebLayer; |
| 41 using blink::WebFloatPoint; | 39 using blink::WebFloatPoint; |
| 42 using blink::WebVector; | 40 using blink::WebVector; |
| 43 using blink::WebRect; | 41 using blink::WebRect; |
| 44 using blink::WebSize; | 42 using blink::WebSize; |
| 45 using blink::WebColor; | 43 using blink::WebColor; |
| 46 using blink::WebFilterOperations; | |
| 47 | 44 |
| 48 namespace cc_blink { | 45 namespace cc_blink { |
| 49 namespace { | 46 namespace { |
| 50 | 47 |
| 51 base::LazyInstance<cc::LayerSettings> g_layer_settings = | 48 base::LazyInstance<cc::LayerSettings> g_layer_settings = |
| 52 LAZY_INSTANCE_INITIALIZER; | 49 LAZY_INSTANCE_INITIALIZER; |
| 53 | 50 |
| 54 } // namespace | 51 } // namespace |
| 55 | 52 |
| 56 WebLayerImpl::WebLayerImpl() | 53 WebLayerImpl::WebLayerImpl() |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 } | 220 } |
| 224 | 221 |
| 225 void WebLayerImpl::setBackgroundColor(WebColor color) { | 222 void WebLayerImpl::setBackgroundColor(WebColor color) { |
| 226 layer_->SetBackgroundColor(color); | 223 layer_->SetBackgroundColor(color); |
| 227 } | 224 } |
| 228 | 225 |
| 229 WebColor WebLayerImpl::backgroundColor() const { | 226 WebColor WebLayerImpl::backgroundColor() const { |
| 230 return layer_->background_color(); | 227 return layer_->background_color(); |
| 231 } | 228 } |
| 232 | 229 |
| 233 void WebLayerImpl::setFilters(const WebFilterOperations& filters) { | 230 void WebLayerImpl::setFilters(const cc::FilterOperations& filters) { |
| 234 const WebFilterOperationsImpl& filters_impl = | 231 layer_->SetFilters(filters); |
| 235 static_cast<const WebFilterOperationsImpl&>(filters); | |
| 236 layer_->SetFilters(filters_impl.AsFilterOperations()); | |
| 237 } | 232 } |
| 238 | 233 |
| 239 void WebLayerImpl::setBackgroundFilters(const WebFilterOperations& filters) { | 234 void WebLayerImpl::setBackgroundFilters(const cc::FilterOperations& filters) { |
| 240 const WebFilterOperationsImpl& filters_impl = | 235 layer_->SetBackgroundFilters(filters); |
| 241 static_cast<const WebFilterOperationsImpl&>(filters); | |
| 242 layer_->SetBackgroundFilters(filters_impl.AsFilterOperations()); | |
| 243 } | 236 } |
| 244 | 237 |
| 245 void WebLayerImpl::setAnimationDelegate( | 238 void WebLayerImpl::setAnimationDelegate( |
| 246 blink::WebCompositorAnimationDelegate* delegate) { | 239 blink::WebCompositorAnimationDelegate* delegate) { |
| 247 if (!delegate) { | 240 if (!delegate) { |
| 248 animation_delegate_adapter_.reset(); | 241 animation_delegate_adapter_.reset(); |
| 249 layer_->set_layer_animation_delegate(nullptr); | 242 layer_->set_layer_animation_delegate(nullptr); |
| 250 return; | 243 return; |
| 251 } | 244 } |
| 252 animation_delegate_adapter_.reset( | 245 animation_delegate_adapter_.reset( |
| 253 new WebToCCAnimationDelegateAdapter(delegate)); | 246 new WebToCCAnimationDelegateAdapter(delegate)); |
| 254 layer_->set_layer_animation_delegate(animation_delegate_adapter_.get()); | 247 layer_->set_layer_animation_delegate(animation_delegate_adapter_.get()); |
| 255 } | 248 } |
| 256 | 249 |
| 257 bool WebLayerImpl::addAnimation(blink::WebCompositorAnimation* animation) { | 250 bool WebLayerImpl::addAnimation(cc::Animation* animation) { |
| 258 bool result = layer_->AddAnimation( | 251 return layer_->AddAnimation(make_scoped_ptr(animation)); |
| 259 static_cast<WebCompositorAnimationImpl*>(animation)->PassAnimation()); | |
| 260 delete animation; | |
| 261 return result; | |
| 262 } | 252 } |
| 263 | 253 |
| 264 void WebLayerImpl::removeAnimation(int animation_id) { | 254 void WebLayerImpl::removeAnimation(int animation_id) { |
| 265 layer_->RemoveAnimation(animation_id); | 255 layer_->RemoveAnimation(animation_id); |
| 266 } | 256 } |
| 267 | 257 |
| 268 void WebLayerImpl::pauseAnimation(int animation_id, double time_offset) { | 258 void WebLayerImpl::pauseAnimation(int animation_id, double time_offset) { |
| 269 layer_->PauseAnimation(animation_id, time_offset); | 259 layer_->PauseAnimation(animation_id, time_offset); |
| 270 } | 260 } |
| 271 | 261 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 | 488 |
| 499 Layer* WebLayerImpl::layer() const { | 489 Layer* WebLayerImpl::layer() const { |
| 500 return layer_.get(); | 490 return layer_.get(); |
| 501 } | 491 } |
| 502 | 492 |
| 503 void WebLayerImpl::SetContentsOpaqueIsFixed(bool fixed) { | 493 void WebLayerImpl::SetContentsOpaqueIsFixed(bool fixed) { |
| 504 contents_opaque_is_fixed_ = fixed; | 494 contents_opaque_is_fixed_ = fixed; |
| 505 } | 495 } |
| 506 | 496 |
| 507 } // namespace cc_blink | 497 } // namespace cc_blink |
| OLD | NEW |