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

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

Issue 295193002: Get rid of graphics layer anchor points, and replace with transform origin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nit. 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 | Annotate | Revision Log
« no previous file with comments | « webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/renderer/compositor_bindings/web_layer_impl_fixed_bounds.h" 5 #include "webkit/renderer/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/public/platform/WebFloatPoint.h" 8 #include "third_party/WebKit/public/platform/WebFloatPoint.h"
9 #include "third_party/WebKit/public/platform/WebSize.h" 9 #include "third_party/WebKit/public/platform/WebSize.h"
10 #include "third_party/skia/include/utils/SkMatrix44.h" 10 #include "third_party/skia/include/utils/SkMatrix44.h"
(...skipping 12 matching lines...) Expand all
23 23
24 WebLayerImplFixedBounds::~WebLayerImplFixedBounds() { 24 WebLayerImplFixedBounds::~WebLayerImplFixedBounds() {
25 } 25 }
26 26
27 void WebLayerImplFixedBounds::invalidateRect(const blink::WebFloatRect& rect) { 27 void WebLayerImplFixedBounds::invalidateRect(const blink::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::setTransformOrigin(
34 const blink::WebFloatPoint& anchor_point) { 34 const blink::WebFloatPoint3D& transform_origin) {
35 if (anchor_point != this->anchorPoint()) { 35 if (transform_origin != this->transformOrigin()) {
36 layer_->SetAnchorPoint(anchor_point); 36 layer_->SetTransformOrigin(transform_origin);
37 UpdateLayerBoundsAndTransform(); 37 UpdateLayerBoundsAndTransform();
38 } 38 }
39 } 39 }
40 40
41 void WebLayerImplFixedBounds::setBounds(const blink::WebSize& bounds) { 41 void WebLayerImplFixedBounds::setBounds(const blink::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 }
(...skipping 23 matching lines...) Expand all
70 const gfx::Transform& transform) { 70 const gfx::Transform& transform) {
71 if (original_transform_ != transform) { 71 if (original_transform_ != transform) {
72 original_transform_ = transform; 72 original_transform_ = transform;
73 UpdateLayerBoundsAndTransform(); 73 UpdateLayerBoundsAndTransform();
74 } 74 }
75 } 75 }
76 76
77 void WebLayerImplFixedBounds::UpdateLayerBoundsAndTransform() { 77 void WebLayerImplFixedBounds::UpdateLayerBoundsAndTransform() {
78 if (fixed_bounds_.IsEmpty() || original_bounds_.IsEmpty() || 78 if (fixed_bounds_.IsEmpty() || original_bounds_.IsEmpty() ||
79 fixed_bounds_ == original_bounds_ || 79 fixed_bounds_ == original_bounds_ ||
80 // For now fall back to non-fixed bounds for non-zero anchor point. 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. 81 // TODO(wangxianzhu): Support non-zero anchor point for fixed bounds.
82 anchorPoint().x || anchorPoint().y) { 82 transformOrigin().x ||
83 transformOrigin().y) {
83 layer_->SetBounds(original_bounds_); 84 layer_->SetBounds(original_bounds_);
84 layer_->SetTransform(original_transform_); 85 layer_->SetTransform(original_transform_);
85 return; 86 return;
86 } 87 }
87 88
88 layer_->SetBounds(fixed_bounds_); 89 layer_->SetBounds(fixed_bounds_);
89 90
90 // Apply bounds scale (bounds/fixed_bounds) over original transform. 91 // Apply bounds scale (bounds/fixed_bounds) over original transform.
91 gfx::Transform transform_with_bounds_scale(original_transform_); 92 gfx::Transform transform_with_bounds_scale(original_transform_);
92 float bounds_scale_x = 93 float bounds_scale_x =
93 static_cast<float>(original_bounds_.width()) / fixed_bounds_.width(); 94 static_cast<float>(original_bounds_.width()) / fixed_bounds_.width();
94 float bounds_scale_y = 95 float bounds_scale_y =
95 static_cast<float>(original_bounds_.height()) / fixed_bounds_.height(); 96 static_cast<float>(original_bounds_.height()) / fixed_bounds_.height();
96 transform_with_bounds_scale.Scale(bounds_scale_x, bounds_scale_y); 97 transform_with_bounds_scale.Scale(bounds_scale_x, bounds_scale_y);
97 layer_->SetTransform(transform_with_bounds_scale); 98 layer_->SetTransform(transform_with_bounds_scale);
98 } 99 }
99 100
100 } // namespace webkit 101 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698