Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds.cc

Issue 317163002: Moving compositor_bindings from webkit to content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changing dependencies due to failing ios bots Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds.h"
6
7 #include "cc/layers/layer.h"
8 #include "third_party/WebKit/public/platform/WebFloatPoint.h"
9 #include "third_party/WebKit/public/platform/WebSize.h"
10 #include "third_party/skia/include/utils/SkMatrix44.h"
11
12 using cc::Layer;
13
14 namespace webkit {
15
16 WebLayerImplFixedBounds::WebLayerImplFixedBounds() {
17 }
18
19 WebLayerImplFixedBounds::WebLayerImplFixedBounds(scoped_refptr<Layer> layer)
20 : WebLayerImpl(layer) {
21 }
22
23
24 WebLayerImplFixedBounds::~WebLayerImplFixedBounds() {
25 }
26
27 void WebLayerImplFixedBounds::invalidateRect(const blink::WebFloatRect& rect) {
28 // Partial invalidations seldom occur for such layers.
29 // Simply invalidate the whole layer to avoid transformation of coordinates.
30 invalidate();
31 }
32
33 void WebLayerImplFixedBounds::setTransformOrigin(
34 const blink::WebFloatPoint3D& transform_origin) {
35 if (transform_origin != this->transformOrigin()) {
36 layer_->SetTransformOrigin(transform_origin);
37 UpdateLayerBoundsAndTransform();
38 }
39 }
40
41 void WebLayerImplFixedBounds::setBounds(const blink::WebSize& bounds) {
42 if (original_bounds_ != gfx::Size(bounds)) {
43 original_bounds_ = bounds;
44 UpdateLayerBoundsAndTransform();
45 }
46 }
47
48 blink::WebSize WebLayerImplFixedBounds::bounds() const {
49 return original_bounds_;
50 }
51
52 void WebLayerImplFixedBounds::setTransform(const SkMatrix44& matrix) {
53 gfx::Transform transform;
54 transform.matrix() = matrix;
55 SetTransformInternal(transform);
56 }
57
58 SkMatrix44 WebLayerImplFixedBounds::transform() const {
59 return original_transform_.matrix();
60 }
61
62 void WebLayerImplFixedBounds::SetFixedBounds(gfx::Size fixed_bounds) {
63 if (fixed_bounds_ != fixed_bounds) {
64 fixed_bounds_ = fixed_bounds;
65 UpdateLayerBoundsAndTransform();
66 }
67 }
68
69 void WebLayerImplFixedBounds::SetTransformInternal(
70 const gfx::Transform& transform) {
71 if (original_transform_ != transform) {
72 original_transform_ = transform;
73 UpdateLayerBoundsAndTransform();
74 }
75 }
76
77 void WebLayerImplFixedBounds::UpdateLayerBoundsAndTransform() {
78 if (fixed_bounds_.IsEmpty() || original_bounds_.IsEmpty() ||
79 fixed_bounds_ == original_bounds_ ||
80 // For now fall back to non-fixed bounds for non-zero transform origin.
81 // TODO(wangxianzhu): Support non-zero anchor point for fixed bounds.
82 transformOrigin().x ||
83 transformOrigin().y) {
84 layer_->SetBounds(original_bounds_);
85 layer_->SetTransform(original_transform_);
86 return;
87 }
88
89 layer_->SetBounds(fixed_bounds_);
90
91 // Apply bounds scale (bounds/fixed_bounds) over original transform.
92 gfx::Transform transform_with_bounds_scale(original_transform_);
93 float bounds_scale_x =
94 static_cast<float>(original_bounds_.width()) / fixed_bounds_.width();
95 float bounds_scale_y =
96 static_cast<float>(original_bounds_.height()) / fixed_bounds_.height();
97 transform_with_bounds_scale.Scale(bounds_scale_x, bounds_scale_y);
98 layer_->SetTransform(transform_with_bounds_scale);
99 }
100
101 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698