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

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

Issue 12496013: Move compositor bindings implementations out of WebKit::, fix style (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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 "webkit/compositor_bindings/web_layer_impl_fixed_bounds.h" 5 #include "webkit/compositor_bindings/web_layer_impl_fixed_bounds.h"
6 6
7 #include "cc/layers/layer.h" 7 #include "cc/layers/layer.h"
8 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatPoint.h" 8 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatPoint.h"
9 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" 9 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
10 #include "third_party/skia/include/utils/SkMatrix44.h" 10 #include "third_party/skia/include/utils/SkMatrix44.h"
11 11
12 using cc::Layer; 12 using cc::Layer;
13 13
14 namespace WebKit { 14 namespace webkit {
15 15
16 WebLayerImplFixedBounds::WebLayerImplFixedBounds() { 16 WebLayerImplFixedBounds::WebLayerImplFixedBounds() {
17 } 17 }
18 18
19 WebLayerImplFixedBounds::WebLayerImplFixedBounds(scoped_refptr<Layer> layer) 19 WebLayerImplFixedBounds::WebLayerImplFixedBounds(scoped_refptr<Layer> layer)
20 : WebLayerImpl(layer) { 20 : WebLayerImpl(layer) {
21 } 21 }
22 22
23 23
24 WebLayerImplFixedBounds::~WebLayerImplFixedBounds() { 24 WebLayerImplFixedBounds::~WebLayerImplFixedBounds() {
25 } 25 }
26 26
27 void WebLayerImplFixedBounds::invalidateRect(const WebFloatRect& rect) { 27 void WebLayerImplFixedBounds::invalidateRect(const WebKit::WebFloatRect& rect) {
28 // Partial invalidations seldom occur for such layers. 28 // Partial invalidations seldom occur for such layers.
29 // Simply invalidate the whole layer to avoid transformation of coordinates. 29 // Simply invalidate the whole layer to avoid transformation of coordinates.
30 invalidate(); 30 invalidate();
31 } 31 }
32 32
33 void WebLayerImplFixedBounds::setAnchorPoint( 33 void WebLayerImplFixedBounds::setAnchorPoint(
34 const WebFloatPoint& anchor_point) { 34 const WebKit::WebFloatPoint& anchor_point) {
35 if (anchor_point != this->anchorPoint()) { 35 if (anchor_point != this->anchorPoint()) {
36 layer_->SetAnchorPoint(anchor_point); 36 layer_->SetAnchorPoint(anchor_point);
37 UpdateLayerBoundsAndTransform(); 37 UpdateLayerBoundsAndTransform();
38 } 38 }
39 } 39 }
40 40
41 void WebLayerImplFixedBounds::setBounds(const WebSize& bounds) { 41 void WebLayerImplFixedBounds::setBounds(const WebKit::WebSize& bounds) {
42 if (original_bounds_ != gfx::Size(bounds)) { 42 if (original_bounds_ != gfx::Size(bounds)) {
43 original_bounds_ = bounds; 43 original_bounds_ = bounds;
44 UpdateLayerBoundsAndTransform(); 44 UpdateLayerBoundsAndTransform();
45 } 45 }
46 } 46 }
47 47
48 WebSize WebLayerImplFixedBounds::bounds() const { 48 WebKit::WebSize WebLayerImplFixedBounds::bounds() const {
49 return original_bounds_; 49 return original_bounds_;
50 } 50 }
51 51
52 void WebLayerImplFixedBounds::setSublayerTransform(const SkMatrix44& matrix) { 52 void WebLayerImplFixedBounds::setSublayerTransform(const SkMatrix44& matrix) {
53 gfx::Transform transform; 53 gfx::Transform transform;
54 transform.matrix() = matrix; 54 transform.matrix() = matrix;
55 SetSublayerTransformInternal(transform); 55 SetSublayerTransformInternal(transform);
56 } 56 }
57 57
58 SkMatrix44 WebLayerImplFixedBounds::sublayerTransform() const { 58 SkMatrix44 WebLayerImplFixedBounds::sublayerTransform() const {
59 return original_sublayer_transform_.matrix(); 59 return original_sublayer_transform_.matrix();
60 } 60 }
61 61
62 void WebLayerImplFixedBounds::setTransform(const SkMatrix44& matrix) { 62 void WebLayerImplFixedBounds::setTransform(const SkMatrix44& matrix) {
63 gfx::Transform transform; 63 gfx::Transform transform;
64 transform.matrix() = matrix; 64 transform.matrix() = matrix;
65 SetTransformInternal(transform); 65 SetTransformInternal(transform);
66 } 66 }
67 67
68 SkMatrix44 WebLayerImplFixedBounds::transform() const { 68 SkMatrix44 WebLayerImplFixedBounds::transform() const {
69 return original_transform_.matrix(); 69 return original_transform_.matrix();
70 } 70 }
71 71
72 void WebLayerImplFixedBounds::SetFixedBounds(const gfx::Size& fixed_bounds) { 72 void WebLayerImplFixedBounds::SetFixedBounds(gfx::Size fixed_bounds) {
73 if (fixed_bounds_ != fixed_bounds) { 73 if (fixed_bounds_ != fixed_bounds) {
74 fixed_bounds_ = fixed_bounds; 74 fixed_bounds_ = fixed_bounds;
75 UpdateLayerBoundsAndTransform(); 75 UpdateLayerBoundsAndTransform();
76 } 76 }
77 } 77 }
78 78
79 void WebLayerImplFixedBounds::SetSublayerTransformInternal( 79 void WebLayerImplFixedBounds::SetSublayerTransformInternal(
80 const gfx::Transform& transform) { 80 const gfx::Transform& transform) {
81 if (original_sublayer_transform_ != transform) { 81 if (original_sublayer_transform_ != transform) {
82 original_sublayer_transform_ = transform; 82 original_sublayer_transform_ = transform;
83 UpdateLayerBoundsAndTransform(); 83 UpdateLayerBoundsAndTransform();
84 } 84 }
85 } 85 }
86 86
87 void WebLayerImplFixedBounds::SetTransformInternal( 87 void WebLayerImplFixedBounds::SetTransformInternal(
88 const gfx::Transform& transform) { 88 const gfx::Transform& transform) {
89 if (original_transform_ != transform) { 89 if (original_transform_ != transform) {
90 original_transform_ = transform; 90 original_transform_ = transform;
91 UpdateLayerBoundsAndTransform(); 91 UpdateLayerBoundsAndTransform();
92 } 92 }
93 } 93 }
94 94
95 void WebLayerImplFixedBounds::UpdateLayerBoundsAndTransform() 95 void WebLayerImplFixedBounds::UpdateLayerBoundsAndTransform() {
96 {
97 if (fixed_bounds_.IsEmpty() || original_bounds_.IsEmpty() || 96 if (fixed_bounds_.IsEmpty() || original_bounds_.IsEmpty() ||
98 fixed_bounds_ == original_bounds_ || 97 fixed_bounds_ == original_bounds_ ||
99 // For now fall back to non-fixed bounds for non-zero anchor point. 98 // For now fall back to non-fixed bounds for non-zero anchor point.
100 // TODO(wangxianzhu): Support non-zero anchor point for fixed bounds. 99 // TODO(wangxianzhu): Support non-zero anchor point for fixed bounds.
101 anchorPoint().x || anchorPoint().y) { 100 anchorPoint().x || anchorPoint().y) {
102 layer_->SetBounds(original_bounds_); 101 layer_->SetBounds(original_bounds_);
103 layer_->SetTransform(original_transform_); 102 layer_->SetTransform(original_transform_);
104 layer_->SetSublayerTransform(original_sublayer_transform_); 103 layer_->SetSublayerTransform(original_sublayer_transform_);
105 return; 104 return;
106 } 105 }
(...skipping 12 matching lines...) Expand all
119 // As we apply extra scale transform on this layer which will propagate to the 118 // As we apply extra scale transform on this layer which will propagate to the
120 // sublayers, here undo the scale on sublayers. 119 // sublayers, here undo the scale on sublayers.
121 gfx::Transform sublayer_transform_with_inverse_bounds_scale; 120 gfx::Transform sublayer_transform_with_inverse_bounds_scale;
122 sublayer_transform_with_inverse_bounds_scale.Scale(1.f / bounds_scale_x, 121 sublayer_transform_with_inverse_bounds_scale.Scale(1.f / bounds_scale_x,
123 1.f / bounds_scale_y); 122 1.f / bounds_scale_y);
124 sublayer_transform_with_inverse_bounds_scale.PreconcatTransform( 123 sublayer_transform_with_inverse_bounds_scale.PreconcatTransform(
125 original_sublayer_transform_); 124 original_sublayer_transform_);
126 layer_->SetSublayerTransform(sublayer_transform_with_inverse_bounds_scale); 125 layer_->SetSublayerTransform(sublayer_transform_with_inverse_bounds_scale);
127 } 126 }
128 127
129 } // namespace WebKit 128 } // namespace WebKit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698