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

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

Issue 12774006: cc: Chromify Layer and LayerImpl classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: MoreAndroidCompilings 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/layer.h" 7 #include "cc/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/WebKit/Source/Platform/chromium/public/WebTransformationMa trix.h" 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMa trix.h"
(...skipping 18 matching lines...) Expand all
29 29
30 void WebLayerImplFixedBounds::invalidateRect(const WebFloatRect& rect) { 30 void WebLayerImplFixedBounds::invalidateRect(const WebFloatRect& rect) {
31 // Partial invalidations seldom occur for such layers. 31 // Partial invalidations seldom occur for such layers.
32 // Simply invalidate the whole layer to avoid transformation of coordinates. 32 // Simply invalidate the whole layer to avoid transformation of coordinates.
33 invalidate(); 33 invalidate();
34 } 34 }
35 35
36 void WebLayerImplFixedBounds::setAnchorPoint( 36 void WebLayerImplFixedBounds::setAnchorPoint(
37 const WebFloatPoint& anchor_point) { 37 const WebFloatPoint& anchor_point) {
38 if (anchor_point != this->anchorPoint()) { 38 if (anchor_point != this->anchorPoint()) {
39 layer_->setAnchorPoint(anchor_point); 39 layer_->SetAnchorPoint(anchor_point);
40 UpdateLayerBoundsAndTransform(); 40 UpdateLayerBoundsAndTransform();
41 } 41 }
42 } 42 }
43 43
44 void WebLayerImplFixedBounds::setBounds(const WebSize& bounds) { 44 void WebLayerImplFixedBounds::setBounds(const WebSize& bounds) {
45 if (original_bounds_ != gfx::Size(bounds)) { 45 if (original_bounds_ != gfx::Size(bounds)) {
46 original_bounds_ = bounds; 46 original_bounds_ = bounds;
47 UpdateLayerBoundsAndTransform(); 47 UpdateLayerBoundsAndTransform();
48 } 48 }
49 } 49 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 106 }
107 } 107 }
108 108
109 void WebLayerImplFixedBounds::UpdateLayerBoundsAndTransform() 109 void WebLayerImplFixedBounds::UpdateLayerBoundsAndTransform()
110 { 110 {
111 if (fixed_bounds_.IsEmpty() || original_bounds_.IsEmpty() || 111 if (fixed_bounds_.IsEmpty() || original_bounds_.IsEmpty() ||
112 fixed_bounds_ == original_bounds_ || 112 fixed_bounds_ == original_bounds_ ||
113 // For now fall back to non-fixed bounds for non-zero anchor point. 113 // For now fall back to non-fixed bounds for non-zero anchor point.
114 // TODO(wangxianzhu): Support non-zero anchor point for fixed bounds. 114 // TODO(wangxianzhu): Support non-zero anchor point for fixed bounds.
115 anchorPoint().x || anchorPoint().y) { 115 anchorPoint().x || anchorPoint().y) {
116 layer_->setBounds(original_bounds_); 116 layer_->SetBounds(original_bounds_);
117 layer_->setTransform(original_transform_); 117 layer_->SetTransform(original_transform_);
118 layer_->setSublayerTransform(original_sublayer_transform_); 118 layer_->SetSublayerTransform(original_sublayer_transform_);
119 return; 119 return;
120 } 120 }
121 121
122 layer_->setBounds(fixed_bounds_); 122 layer_->SetBounds(fixed_bounds_);
123 123
124 // Apply bounds scale (bounds/fixed_bounds) over original transform. 124 // Apply bounds scale (bounds/fixed_bounds) over original transform.
125 gfx::Transform transform_with_bounds_scale(original_transform_); 125 gfx::Transform transform_with_bounds_scale(original_transform_);
126 float bounds_scale_x = 126 float bounds_scale_x =
127 static_cast<float>(original_bounds_.width()) / fixed_bounds_.width(); 127 static_cast<float>(original_bounds_.width()) / fixed_bounds_.width();
128 float bounds_scale_y = 128 float bounds_scale_y =
129 static_cast<float>(original_bounds_.height()) / fixed_bounds_.height(); 129 static_cast<float>(original_bounds_.height()) / fixed_bounds_.height();
130 transform_with_bounds_scale.Scale(bounds_scale_x, bounds_scale_y); 130 transform_with_bounds_scale.Scale(bounds_scale_x, bounds_scale_y);
131 layer_->setTransform(transform_with_bounds_scale); 131 layer_->SetTransform(transform_with_bounds_scale);
132 132
133 // As we apply extra scale transform on this layer which will propagate to the 133 // As we apply extra scale transform on this layer which will propagate to the
134 // sublayers, here undo the scale on sublayers. 134 // sublayers, here undo the scale on sublayers.
135 gfx::Transform sublayer_transform_with_inverse_bounds_scale; 135 gfx::Transform sublayer_transform_with_inverse_bounds_scale;
136 sublayer_transform_with_inverse_bounds_scale.Scale(1.f / bounds_scale_x, 136 sublayer_transform_with_inverse_bounds_scale.Scale(1.f / bounds_scale_x,
137 1.f / bounds_scale_y); 137 1.f / bounds_scale_y);
138 sublayer_transform_with_inverse_bounds_scale.PreconcatTransform( 138 sublayer_transform_with_inverse_bounds_scale.PreconcatTransform(
139 original_sublayer_transform_); 139 original_sublayer_transform_);
140 layer_->setSublayerTransform(sublayer_transform_with_inverse_bounds_scale); 140 layer_->SetSublayerTransform(sublayer_transform_with_inverse_bounds_scale);
141 } 141 }
142 142
143 } // namespace WebKit 143 } // namespace WebKit
OLDNEW
« no previous file with comments | « webkit/compositor_bindings/web_layer_impl.cc ('k') | webkit/compositor_bindings/web_layer_impl_fixed_bounds_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698