Chromium Code Reviews| Index: cc/transform_operations.h |
| diff --git a/cc/transform_operations.h b/cc/transform_operations.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e1bdb5653afb05a66ceefd17eb1312a6e9790162 |
| --- /dev/null |
| +++ b/cc/transform_operations.h |
| @@ -0,0 +1,74 @@ |
| +// Copyright 2013 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. |
| + |
| +#ifndef CC_TRANSFORM_OPERATIONS_H_ |
| +#define CC_TRANSFORM_OPERATIONS_H_ |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "cc/cc_export.h" |
| +#include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMatrix.h" |
| + |
| +namespace cc { |
| + |
| +struct TransformOperationsPrivate; |
| + |
| +// Transform operations are a decomposed transformation matrix. It can be |
| +// applied to obtain a WebTransformationMatrix at any time, and can be blended |
| +// intelligently with other transform operations, so long as they represent the |
| +// same decomposition. For example, if we have a transform that is made up of |
| +// a rotation followed by skew, it can be blended intelligently with another |
| +// transform made up of a rotation followed by a skew. Blending is possible if |
| +// we have two dissimilar sets of transform operations, but the effect may not |
| +// be what was intended. For more information, see the comments for the blend |
| +// function below. |
| +class CC_EXPORT TransformOperations { |
| + public: |
| + TransformOperations(); |
| + TransformOperations(const TransformOperations& other); |
| + virtual ~TransformOperations(); |
|
jamesr
2013/01/15 06:23:01
why virtual?
ajuma
2013/01/15 19:24:30
Fixed.
|
| + |
| + // Returns a transformation matrix representing these transform operations. |
| + virtual WebKit::WebTransformationMatrix Apply() const; |
|
jamesr
2013/01/15 06:23:01
why virtual? (same comment for the rest of the int
ajuma
2013/01/15 19:24:30
Fixed.
|
| + |
| + // Given another set of transform operations and a progress in the range |
| + // [0, 1], returns a transformation matrix representing the intermediate |
| + // value. If this->MatchesTypes(from), then each of the operations are |
| + // blended separately and then combined. Otherwise, the two sets of |
| + // transforms are baked to matrices (using apply), and the matrices are |
| + // then decomposed and interpolated. For more information, see |
| + // http://www.w3.org/TR/2011/WD-css3-2d-transforms-20111215/#matrix-decomposition. |
| + virtual WebKit::WebTransformationMatrix Blend( |
| + const TransformOperations& from, double progress) const; |
| + |
| + // Returns true if this operation and its descendants have the same types |
| + // as other and its descendants. |
| + virtual bool MatchesTypes(const TransformOperations& other) const; |
| + |
| + // Returns true if these operations can be blended. It will only return |
| + // false if we must resort to matrix interpolation, and matrix interpolation |
| + // fails (this can happen if either matrix cannot be decomposed). |
| + virtual bool CanBlendWith(const TransformOperations& other) const; |
| + |
| + virtual void AppendTranslate(double x, double y, double z); |
| + virtual void AppendRotate( |
| + double x, double y, double z, double degrees); |
| + virtual void AppendScale(double x, double y, double z); |
| + virtual void AppendSkew(double x, double y); |
| + virtual void AppendPerspective(double depth); |
| + virtual void AppendMatrix(const WebKit::WebTransformationMatrix& matrix); |
| + virtual void AppendIdentity(); |
| + virtual bool IsIdentity() const; |
| + |
| + private: |
| + void Initialize(); |
| + void Initialize(const TransformOperations& prototype); |
| + bool BlendInternal(const TransformOperations& from, double progress, |
| + WebKit::WebTransformationMatrix& result) const; |
| + |
| + scoped_ptr<TransformOperationsPrivate> private_; |
|
jamesr
2013/01/15 06:23:01
why the Private indirection?
In the WebKit API ve
ajuma
2013/01/15 19:24:30
Done.
|
| +}; |
| + |
| +} // namespace cc |
| + |
| +#endif // CC_TRANSFORM_OPERATIONS_H_ |