| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef UI_GFX_TRANSFORM_H_ | 5 #ifndef UI_GFX_TRANSFORM_H_ |
| 6 #define UI_GFX_TRANSFORM_H_ | 6 #define UI_GFX_TRANSFORM_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "third_party/skia/include/utils/SkMatrix44.h" | 11 #include "third_party/skia/include/utils/SkMatrix44.h" |
| 12 #include "ui/gfx/gfx_export.h" | 12 #include "ui/gfx/gfx_export.h" |
| 13 #include "ui/gfx/vector2d_f.h" | 13 #include "ui/gfx/vector2d_f.h" |
| 14 | 14 |
| 15 namespace gfx { | 15 namespace gfx { |
| 16 | 16 |
| 17 class BoxF; |
| 17 class RectF; | 18 class RectF; |
| 18 class Point; | 19 class Point; |
| 19 class Point3F; | 20 class Point3F; |
| 20 class Vector3dF; | 21 class Vector3dF; |
| 21 | 22 |
| 22 // 4x4 transformation matrix. Transform is cheap and explicitly allows | 23 // 4x4 transformation matrix. Transform is cheap and explicitly allows |
| 23 // copy/assign. | 24 // copy/assign. |
| 24 class GFX_EXPORT Transform { | 25 class GFX_EXPORT Transform { |
| 25 public: | 26 public: |
| 26 | 27 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 void TransformPoint(Point* point) const; | 188 void TransformPoint(Point* point) const; |
| 188 | 189 |
| 189 // Applies the reverse transformation on the point. Returns true if the | 190 // Applies the reverse transformation on the point. Returns true if the |
| 190 // transformation can be inverted. | 191 // transformation can be inverted. |
| 191 bool TransformPointReverse(Point3F* point) const; | 192 bool TransformPointReverse(Point3F* point) const; |
| 192 | 193 |
| 193 // Applies the reverse transformation on the point. Returns true if the | 194 // Applies the reverse transformation on the point. Returns true if the |
| 194 // transformation can be inverted. Rounds the result to the nearest point. | 195 // transformation can be inverted. Rounds the result to the nearest point. |
| 195 bool TransformPointReverse(Point* point) const; | 196 bool TransformPointReverse(Point* point) const; |
| 196 | 197 |
| 197 // Applies transformation on the rectangle. Returns true if the transformed | 198 // Applies transformation on the given rect. After the function completes, |
| 198 // rectangle was axis aligned. If it returns false, rect will be the | 199 // |rect| will be the smallest axis aligned bounding rect containing the |
| 199 // smallest axis aligned bounding box containing the transformed rect. | 200 // transformed rect. |
| 200 void TransformRect(RectF* rect) const; | 201 void TransformRect(RectF* rect) const; |
| 201 | 202 |
| 202 // Applies the reverse transformation on the rectangle. Returns true if | 203 // Applies the reverse transformation on the given rect. After the function |
| 203 // the transformed rectangle was axis aligned. If it returns false, | 204 // completes, |rect| will be the smallest axis aligned bounding rect |
| 204 // rect will be the smallest axis aligned bounding box containing the | 205 // containing the transformed rect. Returns false if the matrix cannot be |
| 205 // transformed rect. | 206 // inverted. |
| 206 bool TransformRectReverse(RectF* rect) const; | 207 bool TransformRectReverse(RectF* rect) const; |
| 207 | 208 |
| 209 // Applies transformation on the given box. After the function completes, |
| 210 // |box| will be the smallest axis aligned bounding box containing the |
| 211 // transformed box. |
| 212 void TransformBox(BoxF* box) const; |
| 213 |
| 214 // Applies the reverse transformation on the given box. After the function |
| 215 // completes, |box| will be the smallest axis aligned bounding box |
| 216 // containing the transformed box. Returns false if the matrix cannot be |
| 217 // inverted. |
| 218 bool TransformBoxReverse(BoxF* box) const; |
| 219 |
| 208 // Decomposes |this| and |from|, interpolates the decomposed values, and | 220 // Decomposes |this| and |from|, interpolates the decomposed values, and |
| 209 // sets |this| to the reconstituted result. Returns false if either matrix | 221 // sets |this| to the reconstituted result. Returns false if either matrix |
| 210 // can't be decomposed. Uses routines described in this spec: | 222 // can't be decomposed. Uses routines described in this spec: |
| 211 // http://www.w3.org/TR/css3-3d-transforms/. | 223 // http://www.w3.org/TR/css3-3d-transforms/. |
| 212 // | 224 // |
| 213 // Note: this call is expensive since we need to decompose the transform. If | 225 // Note: this call is expensive since we need to decompose the transform. If |
| 214 // you're going to be calling this rapidly (e.g., in an animation) you should | 226 // you're going to be calling this rapidly (e.g., in an animation) you should |
| 215 // decompose once using gfx::DecomposeTransforms and reuse your | 227 // decompose once using gfx::DecomposeTransforms and reuse your |
| 216 // DecomposedTransform. | 228 // DecomposedTransform. |
| 217 bool Blend(const Transform& from, double progress); | 229 bool Blend(const Transform& from, double progress); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 241 Point3F* point) const; | 253 Point3F* point) const; |
| 242 | 254 |
| 243 SkMatrix44 matrix_; | 255 SkMatrix44 matrix_; |
| 244 | 256 |
| 245 // copy/assign are allowed. | 257 // copy/assign are allowed. |
| 246 }; | 258 }; |
| 247 | 259 |
| 248 } // namespace gfx | 260 } // namespace gfx |
| 249 | 261 |
| 250 #endif // UI_GFX_TRANSFORM_H_ | 262 #endif // UI_GFX_TRANSFORM_H_ |
| OLD | NEW |