From 4363a2d5bf871628db03808ba1af8a66ba4218b6 Mon Sep 17 00:00:00 2001 From: "vollick@chromium.org" Date: Fri, 16 Mar 2012 22:31:16 +0000 Subject: Adds a new layer animation element which owns an interpolated transform. This allows more control over the interpolation, and in particular, it allows for a rotation about a pivot. BUG=None TEST=None Review URL: http://codereview.chromium.org/9704070 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127269 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/gfx/transform.cc | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'ui/gfx/transform.cc') diff --git a/ui/gfx/transform.cc b/ui/gfx/transform.cc index 3f0b8ea..53695ed 100644 --- a/ui/gfx/transform.cc +++ b/ui/gfx/transform.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -38,6 +38,13 @@ void Transform::SetRotate(float degree) { matrix_.setRotateDegreesAbout(0, 0, 1, SkFloatToScalar(degree)); } +void Transform::SetRotateAbout(const gfx::Point3f& axis, float degree) { + matrix_.setRotateDegreesAbout(axis.x(), + axis.y(), + axis.z(), + SkFloatToScalar(degree)); +} + void Transform::SetScaleX(float x) { matrix_.set(0, 0, SkFloatToScalar(x)); } @@ -47,10 +54,9 @@ void Transform::SetScaleY(float y) { } void Transform::SetScale(float x, float y) { - matrix_.setScale( - SkFloatToScalar(x), - SkFloatToScalar(y), - matrix_.get(2, 2)); + matrix_.setScale(SkFloatToScalar(x), + SkFloatToScalar(y), + matrix_.get(2, 2)); } void Transform::SetTranslateX(float x) { @@ -62,10 +68,9 @@ void Transform::SetTranslateY(float y) { } void Transform::SetTranslate(float x, float y) { - matrix_.setTranslate( - SkFloatToScalar(x), - SkFloatToScalar(y), - matrix_.get(2, 3)); + matrix_.setTranslate(SkFloatToScalar(x), + SkFloatToScalar(y), + matrix_.get(2, 3)); } void Transform::ConcatRotate(float degree) { @@ -74,6 +79,15 @@ void Transform::ConcatRotate(float degree) { matrix_.postConcat(rot); } +void Transform::ConcatRotateAbout(const gfx::Point3f& axis, float degree) { + SkMatrix44 rot; + rot.setRotateDegreesAbout(axis.x(), + axis.y(), + axis.z(), + SkFloatToScalar(degree)); + matrix_.postConcat(rot); +} + void Transform::ConcatScale(float x, float y) { SkMatrix44 scale; scale.setScale(SkFloatToScalar(x), SkFloatToScalar(y), 1); -- cgit v1.1