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 "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/blink/web_animation_impl.h" | 15 #include "cc/blink/web_animation_impl.h" |
16 #include "cc/blink/web_blend_mode.h" | 16 #include "cc/blink/web_blend_mode.h" |
17 #include "cc/blink/web_filter_operations_impl.h" | 17 #include "cc/blink/web_filter_operations_impl.h" |
18 #include "cc/blink/web_to_cc_animation_delegate_adapter.h" | 18 #include "cc/blink/web_to_cc_animation_delegate_adapter.h" |
19 #include "cc/layers/layer.h" | 19 #include "cc/layers/layer.h" |
20 #include "cc/layers/layer_position_constraint.h" | 20 #include "cc/layers/layer_position_constraint.h" |
21 #include "cc/trees/layer_tree_host.h" | 21 #include "cc/trees/layer_tree_host.h" |
22 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 22 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
23 #include "third_party/WebKit/public/platform/WebFloatRect.h" | 23 #include "third_party/WebKit/public/platform/WebFloatRect.h" |
24 #include "third_party/WebKit/public/platform/WebGraphicsLayerDebugInfo.h" | 24 #include "third_party/WebKit/public/platform/WebGraphicsLayerDebugInfo.h" |
25 #include "third_party/WebKit/public/platform/WebLayerClient.h" | 25 #include "third_party/WebKit/public/platform/WebLayerClient.h" |
26 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" | 26 #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" |
27 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" | 27 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" |
28 #include "third_party/WebKit/public/platform/WebSize.h" | 28 #include "third_party/WebKit/public/platform/WebSize.h" |
29 #include "third_party/skia/include/utils/SkMatrix44.h" | 29 #include "third_party/skia/include/utils/SkMatrix44.h" |
30 #include "ui/gfx/geometry/vector2d_conversions.h" | |
30 | 31 |
31 using cc::Animation; | 32 using cc::Animation; |
32 using cc::Layer; | 33 using cc::Layer; |
33 using blink::WebLayer; | 34 using blink::WebLayer; |
34 using blink::WebFloatPoint; | 35 using blink::WebFloatPoint; |
35 using blink::WebVector; | 36 using blink::WebVector; |
36 using blink::WebRect; | 37 using blink::WebRect; |
37 using blink::WebSize; | 38 using blink::WebSize; |
38 using blink::WebColor; | 39 using blink::WebColor; |
39 using blink::WebFilterOperations; | 40 using blink::WebFilterOperations; |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 } | 261 } |
261 | 262 |
262 bool WebLayerImpl::hasActiveAnimation() { | 263 bool WebLayerImpl::hasActiveAnimation() { |
263 return layer_->HasActiveAnimation(); | 264 return layer_->HasActiveAnimation(); |
264 } | 265 } |
265 | 266 |
266 void WebLayerImpl::setForceRenderSurface(bool force_render_surface) { | 267 void WebLayerImpl::setForceRenderSurface(bool force_render_surface) { |
267 layer_->SetForceRenderSurface(force_render_surface); | 268 layer_->SetForceRenderSurface(force_render_surface); |
268 } | 269 } |
269 | 270 |
271 void WebLayerImpl::setScrollPositionFloat( | |
272 const std::pair<double, double>& position) { | |
danakj
2014/09/25 15:13:30
are you allowed to use std::pair in the blink publ
Yufeng Shen (Slow to review)
2014/09/25 20:06:23
right, it is suggested to use a new type WebDouble
| |
273 layer_->SetScrollOffset(gfx::ScrollOffset(position.first, position.second)); | |
274 } | |
275 | |
276 std::pair<double, double> WebLayerImpl::scrollPositionFloat() const { | |
277 return std::pair<double, double>(layer_->scroll_offset().x(), | |
278 layer_->scroll_offset().y()); | |
279 } | |
280 | |
270 void WebLayerImpl::setScrollPosition(blink::WebPoint position) { | 281 void WebLayerImpl::setScrollPosition(blink::WebPoint position) { |
271 layer_->SetScrollOffset(gfx::Point(position).OffsetFromOrigin()); | 282 layer_->SetScrollOffset(gfx::ScrollOffset(position.x, position.y)); |
272 } | 283 } |
273 | 284 |
274 blink::WebPoint WebLayerImpl::scrollPosition() const { | 285 blink::WebPoint WebLayerImpl::scrollPosition() const { |
275 return gfx::PointAtOffsetFromOrigin(layer_->scroll_offset()); | 286 return gfx::PointAtOffsetFromOrigin( |
287 gfx::ToFlooredVector2d(layer_->scroll_offset())); | |
276 } | 288 } |
277 | 289 |
278 void WebLayerImpl::setScrollClipLayer(WebLayer* clip_layer) { | 290 void WebLayerImpl::setScrollClipLayer(WebLayer* clip_layer) { |
279 if (!clip_layer) { | 291 if (!clip_layer) { |
280 layer_->SetScrollClipLayerId(Layer::INVALID_ID); | 292 layer_->SetScrollClipLayerId(Layer::INVALID_ID); |
281 return; | 293 return; |
282 } | 294 } |
283 layer_->SetScrollClipLayerId(clip_layer->id()); | 295 layer_->SetScrollClipLayerId(clip_layer->id()); |
284 } | 296 } |
285 | 297 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
470 if (parent) | 482 if (parent) |
471 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); | 483 clip_parent = static_cast<WebLayerImpl*>(parent)->layer(); |
472 layer_->SetClipParent(clip_parent); | 484 layer_->SetClipParent(clip_parent); |
473 } | 485 } |
474 | 486 |
475 Layer* WebLayerImpl::layer() const { | 487 Layer* WebLayerImpl::layer() const { |
476 return layer_.get(); | 488 return layer_.get(); |
477 } | 489 } |
478 | 490 |
479 } // namespace cc_blink | 491 } // namespace cc_blink |
OLD | NEW |