| 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" | |
| 15 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 16 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 17 #include "base/trace_event/trace_event_impl.h" | 16 #include "base/trace_event/trace_event_impl.h" |
| 18 #include "cc/animation/animation.h" | |
| 19 #include "cc/base/region.h" | 17 #include "cc/base/region.h" |
| 20 #include "cc/base/switches.h" | 18 #include "cc/base/switches.h" |
| 21 #include "cc/blink/web_blend_mode.h" | 19 #include "cc/blink/web_blend_mode.h" |
| 22 #include "cc/blink/web_to_cc_animation_delegate_adapter.h" | |
| 23 #include "cc/layers/layer.h" | 20 #include "cc/layers/layer.h" |
| 24 #include "cc/layers/layer_position_constraint.h" | 21 #include "cc/layers/layer_position_constraint.h" |
| 25 #include "cc/layers/layer_settings.h" | 22 #include "cc/layers/layer_settings.h" |
| 26 #include "cc/trees/layer_tree_host.h" | 23 #include "cc/trees/layer_tree_host.h" |
| 27 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 24 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
| 28 #include "third_party/WebKit/public/platform/WebFloatRect.h" | 25 #include "third_party/WebKit/public/platform/WebFloatRect.h" |
| 29 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" | 26 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" |
| 30 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" | 27 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" |
| 31 #include "third_party/WebKit/public/platform/WebSize.h" | 28 #include "third_party/WebKit/public/platform/WebSize.h" |
| 32 #include "third_party/skia/include/utils/SkMatrix44.h" | 29 #include "third_party/skia/include/utils/SkMatrix44.h" |
| 33 #include "ui/gfx/geometry/rect_conversions.h" | 30 #include "ui/gfx/geometry/rect_conversions.h" |
| 34 #include "ui/gfx/geometry/vector2d_conversions.h" | 31 #include "ui/gfx/geometry/vector2d_conversions.h" |
| 35 | 32 |
| 36 using cc::Animation; | 33 using cc::Animation; |
| 37 using cc::Layer; | 34 using cc::Layer; |
| 38 using blink::WebLayer; | 35 using blink::WebLayer; |
| 39 using blink::WebFloatPoint; | 36 using blink::WebFloatPoint; |
| 40 using blink::WebVector; | 37 using blink::WebVector; |
| 41 using blink::WebRect; | 38 using blink::WebRect; |
| 42 using blink::WebSize; | 39 using blink::WebSize; |
| 43 using blink::WebColor; | 40 using blink::WebColor; |
| 44 | 41 |
| 45 namespace cc_blink { | 42 namespace cc_blink { |
| 46 namespace { | |
| 47 | |
| 48 base::LazyInstance<cc::LayerSettings> g_layer_settings = | |
| 49 LAZY_INSTANCE_INITIALIZER; | |
| 50 | |
| 51 } // namespace | |
| 52 | 43 |
| 53 WebLayerImpl::WebLayerImpl() | 44 WebLayerImpl::WebLayerImpl() |
| 54 : layer_(Layer::Create(LayerSettings())), contents_opaque_is_fixed_(false) { | 45 : layer_(Layer::Create(cc::LayerSettings())), |
| 55 } | 46 contents_opaque_is_fixed_(false) {} |
| 56 | 47 |
| 57 WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer) | 48 WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer) |
| 58 : layer_(layer), contents_opaque_is_fixed_(false) { | 49 : layer_(layer), contents_opaque_is_fixed_(false) { |
| 59 } | 50 } |
| 60 | 51 |
| 61 WebLayerImpl::~WebLayerImpl() { | 52 WebLayerImpl::~WebLayerImpl() { |
| 62 if (animation_delegate_adapter_.get()) | |
| 63 layer_->set_layer_animation_delegate(nullptr); | |
| 64 layer_->SetLayerClient(nullptr); | 53 layer_->SetLayerClient(nullptr); |
| 65 } | 54 } |
| 66 | 55 |
| 67 // static | |
| 68 void WebLayerImpl::SetLayerSettings(const cc::LayerSettings& settings) { | |
| 69 g_layer_settings.Get() = settings; | |
| 70 } | |
| 71 | |
| 72 // static | |
| 73 const cc::LayerSettings& WebLayerImpl::LayerSettings() { | |
| 74 return g_layer_settings.Get(); | |
| 75 } | |
| 76 | |
| 77 int WebLayerImpl::id() const { | 56 int WebLayerImpl::id() const { |
| 78 return layer_->id(); | 57 return layer_->id(); |
| 79 } | 58 } |
| 80 | 59 |
| 81 void WebLayerImpl::invalidateRect(const blink::WebRect& rect) { | 60 void WebLayerImpl::invalidateRect(const blink::WebRect& rect) { |
| 82 layer_->SetNeedsDisplayRect(rect); | 61 layer_->SetNeedsDisplayRect(rect); |
| 83 } | 62 } |
| 84 | 63 |
| 85 void WebLayerImpl::invalidate() { | 64 void WebLayerImpl::invalidate() { |
| 86 layer_->SetNeedsDisplay(); | 65 layer_->SetNeedsDisplay(); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 } | 207 } |
| 229 | 208 |
| 230 void WebLayerImpl::setFilters(const cc::FilterOperations& filters) { | 209 void WebLayerImpl::setFilters(const cc::FilterOperations& filters) { |
| 231 layer_->SetFilters(filters); | 210 layer_->SetFilters(filters); |
| 232 } | 211 } |
| 233 | 212 |
| 234 void WebLayerImpl::setBackgroundFilters(const cc::FilterOperations& filters) { | 213 void WebLayerImpl::setBackgroundFilters(const cc::FilterOperations& filters) { |
| 235 layer_->SetBackgroundFilters(filters); | 214 layer_->SetBackgroundFilters(filters); |
| 236 } | 215 } |
| 237 | 216 |
| 238 void WebLayerImpl::setAnimationDelegate( | 217 bool WebLayerImpl::hasActiveAnimationForTesting() { |
| 239 blink::WebCompositorAnimationDelegate* delegate) { | |
| 240 if (!delegate) { | |
| 241 animation_delegate_adapter_.reset(); | |
| 242 layer_->set_layer_animation_delegate(nullptr); | |
| 243 return; | |
| 244 } | |
| 245 animation_delegate_adapter_.reset( | |
| 246 new WebToCCAnimationDelegateAdapter(delegate)); | |
| 247 layer_->set_layer_animation_delegate(animation_delegate_adapter_.get()); | |
| 248 } | |
| 249 | |
| 250 bool WebLayerImpl::addAnimation(cc::Animation* animation) { | |
| 251 return layer_->AddAnimation(make_scoped_ptr(animation)); | |
| 252 } | |
| 253 | |
| 254 void WebLayerImpl::removeAnimation(int animation_id) { | |
| 255 layer_->RemoveAnimation(animation_id); | |
| 256 } | |
| 257 | |
| 258 void WebLayerImpl::pauseAnimation(int animation_id, double time_offset) { | |
| 259 layer_->PauseAnimation(animation_id, time_offset); | |
| 260 } | |
| 261 | |
| 262 void WebLayerImpl::abortAnimation(int animation_id) { | |
| 263 layer_->AbortAnimation(animation_id); | |
| 264 } | |
| 265 | |
| 266 bool WebLayerImpl::hasActiveAnimation() { | |
| 267 return layer_->HasActiveAnimation(); | 218 return layer_->HasActiveAnimation(); |
| 268 } | 219 } |
| 269 | 220 |
| 270 void WebLayerImpl::setForceRenderSurface(bool force_render_surface) { | 221 void WebLayerImpl::setForceRenderSurface(bool force_render_surface) { |
| 271 layer_->SetForceRenderSurface(force_render_surface); | 222 layer_->SetForceRenderSurface(force_render_surface); |
| 272 } | 223 } |
| 273 | 224 |
| 274 void WebLayerImpl::setScrollPositionDouble(blink::WebDoublePoint position) { | 225 void WebLayerImpl::setScrollPositionDouble(blink::WebDoublePoint position) { |
| 275 layer_->SetScrollOffset(gfx::ScrollOffset(position.x, position.y)); | 226 layer_->SetScrollOffset(gfx::ScrollOffset(position.x, position.y)); |
| 276 } | 227 } |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 445 |
| 495 Layer* WebLayerImpl::layer() const { | 446 Layer* WebLayerImpl::layer() const { |
| 496 return layer_.get(); | 447 return layer_.get(); |
| 497 } | 448 } |
| 498 | 449 |
| 499 void WebLayerImpl::SetContentsOpaqueIsFixed(bool fixed) { | 450 void WebLayerImpl::SetContentsOpaqueIsFixed(bool fixed) { |
| 500 contents_opaque_is_fixed_ = fixed; | 451 contents_opaque_is_fixed_ = fixed; |
| 501 } | 452 } |
| 502 | 453 |
| 503 } // namespace cc_blink | 454 } // namespace cc_blink |
| OLD | NEW |