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

Side by Side Diff: cc/animation/transform_operations.cc

Issue 642983003: cc: Make PictureLayerImpl use a better choice for animated raster scale. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: animationscale: scaledownstillcheckssize Created 6 years, 2 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
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 "cc/animation/transform_operations.h" 5 #include "cc/animation/transform_operations.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ui/gfx/animation/tween.h" 9 #include "ui/gfx/animation/tween.h"
10 #include "ui/gfx/box_f.h" 10 #include "ui/gfx/box_f.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 case TransformOperation::TransformOperationRotate: 107 case TransformOperation::TransformOperationRotate:
108 case TransformOperation::TransformOperationScale: 108 case TransformOperation::TransformOperationScale:
109 case TransformOperation::TransformOperationSkew: 109 case TransformOperation::TransformOperationSkew:
110 case TransformOperation::TransformOperationPerspective: 110 case TransformOperation::TransformOperationPerspective:
111 return false; 111 return false;
112 } 112 }
113 } 113 }
114 return true; 114 return true;
115 } 115 }
116 116
117 bool TransformOperations::MaximumScale(const TransformOperations& from,
118 SkMScalar min_progress,
119 SkMScalar max_progress,
120 float* max_scale) const {
121 if (!MatchesTypes(from))
122 return false;
123
124 gfx::Vector3dF from_scale;
125 gfx::Vector3dF to_scale;
126
127 if (!from.ScaleComponent(&from_scale) || !ScaleComponent(&to_scale))
128 return false;
129
130 gfx::Vector3dF scale_at_min_progress(
131 std::abs(gfx::Tween::FloatValueBetween(
132 min_progress, from_scale.x(), to_scale.x())),
133 std::abs(gfx::Tween::FloatValueBetween(
134 min_progress, from_scale.y(), to_scale.y())),
135 std::abs(gfx::Tween::FloatValueBetween(
136 min_progress, from_scale.z(), to_scale.z())));
137 gfx::Vector3dF scale_at_max_progress(
138 std::abs(gfx::Tween::FloatValueBetween(
139 max_progress, from_scale.x(), to_scale.x())),
140 std::abs(gfx::Tween::FloatValueBetween(
141 max_progress, from_scale.y(), to_scale.y())),
142 std::abs(gfx::Tween::FloatValueBetween(
143 max_progress, from_scale.z(), to_scale.z())));
144
145 gfx::Vector3dF max_scale_3d = scale_at_min_progress;
146 max_scale_3d.SetToMax(scale_at_max_progress);
147 *max_scale =
148 std::max(max_scale_3d.x(), std::max(max_scale_3d.y(), max_scale_3d.z()));
149 return true;
150 }
151
152 bool TransformOperations::ScaleComponent(gfx::Vector3dF* scale) const { 117 bool TransformOperations::ScaleComponent(gfx::Vector3dF* scale) const {
153 *scale = gfx::Vector3dF(1.f, 1.f, 1.f); 118 *scale = gfx::Vector3dF(1.f, 1.f, 1.f);
154 bool has_scale_component = false; 119 bool has_scale_component = false;
155 for (size_t i = 0; i < operations_.size(); ++i) { 120 for (size_t i = 0; i < operations_.size(); ++i) {
156 switch (operations_[i].type) { 121 switch (operations_[i].type) {
157 case TransformOperation::TransformOperationIdentity: 122 case TransformOperation::TransformOperationIdentity:
158 case TransformOperation::TransformOperationTranslate: 123 case TransformOperation::TransformOperationTranslate:
159 continue; 124 continue;
160 case TransformOperation::TransformOperationMatrix: 125 case TransformOperation::TransformOperationMatrix:
161 if (!operations_[i].matrix.IsIdentityOrTranslation()) 126 if (!operations_[i].matrix.IsIdentityOrTranslation())
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 decomposed_transform_.reset(new gfx::DecomposedTransform()); 289 decomposed_transform_.reset(new gfx::DecomposedTransform());
325 gfx::Transform transform = Apply(); 290 gfx::Transform transform = Apply();
326 if (!gfx::DecomposeTransform(decomposed_transform_.get(), transform)) 291 if (!gfx::DecomposeTransform(decomposed_transform_.get(), transform))
327 return false; 292 return false;
328 decomposed_transform_dirty_ = false; 293 decomposed_transform_dirty_ = false;
329 } 294 }
330 return true; 295 return true;
331 } 296 }
332 297
333 } // namespace cc 298 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698