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

Unified Diff: ui/gfx/transform.h

Issue 7044062: Use SkMatrix44 for the underlying implementation of ui::Transform (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: No more templates Created 9 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 side-by-side diff with in-line comments
Download patch
Index: ui/gfx/transform.h
diff --git a/ui/gfx/transform.h b/ui/gfx/transform.h
index 3fdfc3235a36c79eab4508d7481e9c05e8a83278..b07b3ac40cdace1e0ac7d352d9779c4da0d8274c 100644
--- a/ui/gfx/transform.h
+++ b/ui/gfx/transform.h
@@ -6,20 +6,18 @@
#define UI_GFX_TRANSFORM_H_
#pragma once
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "third_party/skia/include/core/SkMatrix.h"
+#include "third_party/skia/include/utils/SkMatrix44.h"
namespace gfx {
-class Point;
class Rect;
+class Point;
+class Point3f;
}
namespace ui {
-// 3x3 transformation matrix. Transform is cheap and explicitly allows
+// 4x4 transformation matrix. Transform is cheap and explicitly allows
// copy/assign.
-// TODO: make this a 4x4.
class Transform {
public:
Transform();
@@ -57,43 +55,55 @@ class Transform {
void ConcatTranslate(float x, float y);
// Applies a transformation on the current transformation
- // (i.e. 'this = this * transform;'). Returns true if the result can be
- // represented.
- bool PreconcatTransform(const Transform& transform);
+ // (i.e. 'this = this * transform;').
+ void PreconcatTransform(const Transform& transform);
// Applies a transformation on the current transformation
- // (i.e. 'this = transform * this;'). Returns true if the result can be
- // represented.
- bool ConcatTransform(const Transform& transform);
+ // (i.e. 'this = transform * this;').
+ void ConcatTransform(const Transform& transform);
// Does the transformation change anything?
bool HasChange() const;
// Applies the transformation on the point. Returns true if the point is
// transformed successfully.
- bool TransformPoint(gfx::Point* point);
+ bool TransformPoint(gfx::Point3f& point) const;
+
+ // Applies the transformation on the point. Returns true if the point is
+ // transformed successfully. Rounds the result to the nearest point.
+ bool TransformPoint(gfx::Point& point) const;
- // Applies the reverse transformation on the point. Returns true if the point
- // is transformed successfully.
- bool TransformPointReverse(gfx::Point* point);
+ // Applies the reverse transformation on the point. Returns true if the
+ // transformation can be inverted.
+ bool TransformPointReverse(gfx::Point3f& point) const;
+
+ // Applies the reverse transformation on the point. Returns true if the
+ // transformation can be inverted. Rounds the result to the nearest point.
+ bool TransformPointReverse(gfx::Point& point) const;
// Applies transformation on the rectangle. Returns true if the rectangle is
// transformed successfully.
- bool TransformRect(gfx::Rect* rect);
+ bool TransformRect(gfx::Rect* rect) const;
// Applies the reverse transformation on the rectangle. Returns true if the
// rectangle is transformed successfully.
- bool TransformRectReverse(gfx::Rect* rect);
+ bool TransformRectReverse(gfx::Rect* rect) const;
// Returns the underlying matrix.
- const SkMatrix& matrix() const { return matrix_; }
+ const SkMatrix44& matrix() const { return matrix_; }
private:
- SkMatrix matrix_;
+ void TransformPointInternal(const SkMatrix44& xform,
+ gfx::Point& point) const;
+
+ void TransformPointInternal(const SkMatrix44& xform,
+ gfx::Point3f& point) const;
+
+ SkMatrix44 matrix_;
// copy/assign are allowed.
};
-} // namespace ui
+}// namespace ui
#endif // UI_GFX_TRANSFORM_H_

Powered by Google App Engine
This is Rietveld 408576698