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

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: Fixed. 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
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 21 matching lines...) Expand all
68 68
69 void WebLayerImplFixedBounds::SetTransformInternal( 69 void WebLayerImplFixedBounds::SetTransformInternal(
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 LOG(ERROR) << "WebLayerImplFixedBounds::UpdateLayerBoundsAndTransform";
enne (OOO) 2014/06/03 22:25:52 ಠ_ಠ
78 if (fixed_bounds_.IsEmpty() || original_bounds_.IsEmpty() || 79 if (fixed_bounds_.IsEmpty() || original_bounds_.IsEmpty() ||
79 fixed_bounds_ == original_bounds_ || 80 fixed_bounds_ == original_bounds_ ||
80 // For now fall back to non-fixed bounds for non-zero anchor point. 81 // 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 // TODO(wangxianzhu): Support non-zero anchor point for fixed bounds.
82 anchorPoint().x || anchorPoint().y) { 83 transformOrigin().x ||
84 transformOrigin().y) {
83 layer_->SetBounds(original_bounds_); 85 layer_->SetBounds(original_bounds_);
84 layer_->SetTransform(original_transform_); 86 layer_->SetTransform(original_transform_);
85 return; 87 return;
86 } 88 }
87 89
88 layer_->SetBounds(fixed_bounds_); 90 layer_->SetBounds(fixed_bounds_);
89 91
90 // Apply bounds scale (bounds/fixed_bounds) over original transform. 92 // Apply bounds scale (bounds/fixed_bounds) over original transform.
91 gfx::Transform transform_with_bounds_scale(original_transform_); 93 gfx::Transform transform_with_bounds_scale(original_transform_);
92 float bounds_scale_x = 94 float bounds_scale_x =
93 static_cast<float>(original_bounds_.width()) / fixed_bounds_.width(); 95 static_cast<float>(original_bounds_.width()) / fixed_bounds_.width();
94 float bounds_scale_y = 96 float bounds_scale_y =
95 static_cast<float>(original_bounds_.height()) / fixed_bounds_.height(); 97 static_cast<float>(original_bounds_.height()) / fixed_bounds_.height();
96 transform_with_bounds_scale.Scale(bounds_scale_x, bounds_scale_y); 98 transform_with_bounds_scale.Scale(bounds_scale_x, bounds_scale_y);
97 layer_->SetTransform(transform_with_bounds_scale); 99 layer_->SetTransform(transform_with_bounds_scale);
98 } 100 }
99 101
100 } // namespace webkit 102 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698