diff options
author | vollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-14 19:28:01 +0000 |
---|---|---|
committer | vollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-14 19:28:01 +0000 |
commit | 9dc5f9d8c622c67132a957de43b66794be868a03 (patch) | |
tree | 153542a8c65ecfd6676ebf5a5ab1506dcc3dddcd /ui | |
parent | aab81df16eafb7ea7a495bb65aedc9e278cb4c23 (diff) | |
download | chromium_src-9dc5f9d8c622c67132a957de43b66794be868a03.zip chromium_src-9dc5f9d8c622c67132a957de43b66794be868a03.tar.gz chromium_src-9dc5f9d8c622c67132a957de43b66794be868a03.tar.bz2 |
Add support for perspective transforms
Adds the function ui::Transform::SetPerspectiveDepth which allows the construction of a perspective projection matrix based on http://www.w3.org/TR/css3-3d-transforms/#transform-functions.
BUG=123843
TEST=None
Review URL: https://chromiumcodereview.appspot.com/10332140
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136939 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gfx/transform.cc | 6 | ||||
-rw-r--r-- | ui/gfx/transform.h | 5 |
2 files changed, 11 insertions, 0 deletions
diff --git a/ui/gfx/transform.cc b/ui/gfx/transform.cc index 53695ed..123ca2b 100644 --- a/ui/gfx/transform.cc +++ b/ui/gfx/transform.cc @@ -73,6 +73,12 @@ void Transform::SetTranslate(float x, float y) { matrix_.get(2, 3)); } +void Transform::SetPerspectiveDepth(float depth) { + SkMatrix44 m; + m.set(3, 2, -1 / depth); + matrix_ = m; +} + void Transform::ConcatRotate(float degree) { SkMatrix44 rot; rot.setRotateDegreesAbout(0, 0, 1, SkFloatToScalar(degree)); diff --git a/ui/gfx/transform.h b/ui/gfx/transform.h index e56696e..893e4cd 100644 --- a/ui/gfx/transform.h +++ b/ui/gfx/transform.h @@ -52,6 +52,11 @@ class UI_EXPORT Transform { void SetTranslateY(float y); void SetTranslate(float x, float y); + // Creates a perspective matrix. + // Based on the 'perspective' operation from + // http://www.w3.org/TR/css3-3d-transforms/#transform-functions + void SetPerspectiveDepth(float depth); + // Applies a rotation on the current transformation. void ConcatRotate(float degree); |