summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/transforms
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-05 14:34:32 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-05 14:34:32 -0800
commit635860845790a19bf50bbc51ba8fb66a96dde068 (patch)
treeef6ad9ff73a5b57f65249d4232a202fa77e6a140 /WebCore/platform/graphics/transforms
parent8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2 (diff)
downloadexternal_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.zip
external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.gz
external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.bz2
auto import from //depot/cupcake/@136594
Diffstat (limited to 'WebCore/platform/graphics/transforms')
-rw-r--r--WebCore/platform/graphics/transforms/IdentityTransformOperation.h67
-rw-r--r--WebCore/platform/graphics/transforms/MatrixTransformOperation.cpp50
-rw-r--r--WebCore/platform/graphics/transforms/MatrixTransformOperation.h82
-rw-r--r--WebCore/platform/graphics/transforms/RotateTransformOperation.cpp40
-rw-r--r--WebCore/platform/graphics/transforms/RotateTransformOperation.h74
-rw-r--r--WebCore/platform/graphics/transforms/ScaleTransformOperation.cpp41
-rw-r--r--WebCore/platform/graphics/transforms/ScaleTransformOperation.h74
-rw-r--r--WebCore/platform/graphics/transforms/SkewTransformOperation.cpp41
-rw-r--r--WebCore/platform/graphics/transforms/SkewTransformOperation.h74
-rw-r--r--WebCore/platform/graphics/transforms/TransformOperation.h64
-rw-r--r--WebCore/platform/graphics/transforms/TransformOperations.cpp49
-rw-r--r--WebCore/platform/graphics/transforms/TransformOperations.h59
-rw-r--r--WebCore/platform/graphics/transforms/TransformationMatrix.cpp205
-rw-r--r--WebCore/platform/graphics/transforms/TransformationMatrix.h140
-rw-r--r--WebCore/platform/graphics/transforms/TranslateTransformOperation.cpp41
-rw-r--r--WebCore/platform/graphics/transforms/TranslateTransformOperation.h75
16 files changed, 1176 insertions, 0 deletions
diff --git a/WebCore/platform/graphics/transforms/IdentityTransformOperation.h b/WebCore/platform/graphics/transforms/IdentityTransformOperation.h
new file mode 100644
index 0000000..347737c
--- /dev/null
+++ b/WebCore/platform/graphics/transforms/IdentityTransformOperation.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
+ * (C) 2000 Antti Koivisto (koivisto@kde.org)
+ * (C) 2000 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef IdentityTransformOperation_h
+#define IdentityTransformOperation_h
+
+#include "TransformOperation.h"
+
+namespace WebCore {
+
+class IdentityTransformOperation : public TransformOperation {
+public:
+ static PassRefPtr<IdentityTransformOperation> create()
+ {
+ return adoptRef(new IdentityTransformOperation());
+ }
+
+private:
+ virtual bool isIdentity() const { return true; }
+ virtual OperationType getOperationType() const { return IDENTITY; }
+ virtual bool isSameType(const TransformOperation& o) const { return o.getOperationType() == IDENTITY; }
+
+ virtual bool operator==(const TransformOperation& o) const
+ {
+ return isSameType(o);
+ }
+
+ virtual bool apply(TransformationMatrix&, const IntSize&) const
+ {
+ return false;
+ }
+
+ virtual PassRefPtr<TransformOperation> blend(const TransformOperation*, double, bool = false)
+ {
+ return this;
+ }
+
+ IdentityTransformOperation()
+ {
+ }
+
+};
+
+} // namespace WebCore
+
+#endif // IdentityTransformOperation_h
diff --git a/WebCore/platform/graphics/transforms/MatrixTransformOperation.cpp b/WebCore/platform/graphics/transforms/MatrixTransformOperation.cpp
new file mode 100644
index 0000000..153d96d
--- /dev/null
+++ b/WebCore/platform/graphics/transforms/MatrixTransformOperation.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "MatrixTransformOperation.h"
+
+#include <algorithm>
+
+namespace WebCore {
+
+PassRefPtr<TransformOperation> MatrixTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity)
+{
+ if (from && !from->isSameType(*this))
+ return this;
+
+ // convert the TransformOperations into matrices
+ IntSize size;
+ TransformationMatrix fromT;
+ TransformationMatrix toT(m_a, m_b, m_c, m_d, m_e, m_f);
+ if (from) {
+ const MatrixTransformOperation* m = static_cast<const MatrixTransformOperation*>(from);
+ fromT.setMatrix(m->m_a, m->m_b, m->m_c, m->m_d, m->m_e, m->m_f);
+ }
+
+ if (blendToIdentity)
+ std::swap(fromT, toT);
+
+ toT.blend(fromT, progress);
+ return MatrixTransformOperation::create(toT.a(), toT.b(), toT.c(), toT.d(), toT.e(), toT.f());
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/graphics/transforms/MatrixTransformOperation.h b/WebCore/platform/graphics/transforms/MatrixTransformOperation.h
new file mode 100644
index 0000000..d272229
--- /dev/null
+++ b/WebCore/platform/graphics/transforms/MatrixTransformOperation.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
+ * (C) 2000 Antti Koivisto (koivisto@kde.org)
+ * (C) 2000 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef MatrixTransformOperation_h
+#define MatrixTransformOperation_h
+
+#include "TransformOperation.h"
+
+namespace WebCore {
+
+class MatrixTransformOperation : public TransformOperation {
+public:
+ static PassRefPtr<MatrixTransformOperation> create(double a, double b, double c, double d, double e, double f)
+ {
+ return adoptRef(new MatrixTransformOperation(a, b, c, d, e, f));
+ }
+
+private:
+ virtual bool isIdentity() const { return m_a == 1 && m_b == 0 && m_c == 0 && m_d == 1 && m_e == 0 && m_f == 0; }
+ virtual OperationType getOperationType() const { return MATRIX; }
+ virtual bool isSameType(const TransformOperation& o) const { return o.getOperationType() == MATRIX; }
+
+ virtual bool operator==(const TransformOperation& o) const
+ {
+ if (!isSameType(o))
+ return false;
+
+ const MatrixTransformOperation* m = static_cast<const MatrixTransformOperation*>(&o);
+ return m_a == m->m_a && m_b == m->m_b && m_c == m->m_c && m_d == m->m_d && m_e == m->m_e && m_f == m->m_f;
+ }
+
+ virtual bool apply(TransformationMatrix& transform, const IntSize&) const
+ {
+ TransformationMatrix matrix(m_a, m_b, m_c, m_d, m_e, m_f);
+ transform = matrix * transform;
+ return false;
+ }
+
+ virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false);
+
+ MatrixTransformOperation(double a, double b, double c, double d, double e, double f)
+ : m_a(a)
+ , m_b(b)
+ , m_c(c)
+ , m_d(d)
+ , m_e(e)
+ , m_f(f)
+ {
+ }
+
+ double m_a;
+ double m_b;
+ double m_c;
+ double m_d;
+ double m_e;
+ double m_f;
+};
+
+} // namespace WebCore
+
+#endif // MatrixTransformOperation_h
diff --git a/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp b/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp
new file mode 100644
index 0000000..4887cee
--- /dev/null
+++ b/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "RotateTransformOperation.h"
+
+namespace WebCore {
+
+PassRefPtr<TransformOperation> RotateTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity)
+{
+ if (from && !from->isSameType(*this))
+ return this;
+
+ if (blendToIdentity)
+ return RotateTransformOperation::create(m_angle - m_angle * progress, m_type);
+
+ const RotateTransformOperation* fromOp = static_cast<const RotateTransformOperation*>(from);
+ double fromAngle = fromOp ? fromOp->m_angle : 0;
+ return RotateTransformOperation::create(fromAngle + (m_angle - fromAngle) * progress, m_type);
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/graphics/transforms/RotateTransformOperation.h b/WebCore/platform/graphics/transforms/RotateTransformOperation.h
new file mode 100644
index 0000000..adc6c4c
--- /dev/null
+++ b/WebCore/platform/graphics/transforms/RotateTransformOperation.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
+ * (C) 2000 Antti Koivisto (koivisto@kde.org)
+ * (C) 2000 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef RotateTransformOperation_h
+#define RotateTransformOperation_h
+
+#include "TransformOperation.h"
+
+namespace WebCore {
+
+class RotateTransformOperation : public TransformOperation {
+public:
+ static PassRefPtr<RotateTransformOperation> create(double angle, OperationType type)
+ {
+ return adoptRef(new RotateTransformOperation(angle, type));
+ }
+
+ virtual bool isIdentity() const { return m_angle == 0; }
+ virtual OperationType getOperationType() const { return m_type; }
+ virtual bool isSameType(const TransformOperation& o) const { return o.getOperationType() == m_type; }
+
+ virtual bool operator==(const TransformOperation& o) const
+ {
+ if (!isSameType(o))
+ return false;
+ const RotateTransformOperation* r = static_cast<const RotateTransformOperation*>(&o);
+ return m_angle == r->m_angle;
+ }
+
+ virtual bool apply(TransformationMatrix& transform, const IntSize& /*borderBoxSize*/) const
+ {
+ transform.rotate(m_angle);
+ return false;
+ }
+
+ virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false);
+
+ double angle() const { return m_angle; }
+
+private:
+ RotateTransformOperation(double angle, OperationType type)
+ : m_angle(angle)
+ , m_type(type)
+ {
+ }
+
+ double m_angle;
+ OperationType m_type;
+};
+
+} // namespace WebCore
+
+#endif // RotateTransformOperation_h
diff --git a/WebCore/platform/graphics/transforms/ScaleTransformOperation.cpp b/WebCore/platform/graphics/transforms/ScaleTransformOperation.cpp
new file mode 100644
index 0000000..49a8fd8
--- /dev/null
+++ b/WebCore/platform/graphics/transforms/ScaleTransformOperation.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "ScaleTransformOperation.h"
+
+namespace WebCore {
+
+PassRefPtr<TransformOperation> ScaleTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity)
+{
+ if (from && !from->isSameType(*this))
+ return this;
+
+ if (blendToIdentity)
+ return ScaleTransformOperation::create(m_x + (1. - m_x) * progress, m_y + (1. - m_y) * progress, m_type);
+
+ const ScaleTransformOperation* fromOp = static_cast<const ScaleTransformOperation*>(from);
+ double fromX = fromOp ? fromOp->m_x : 1.;
+ double fromY = fromOp ? fromOp->m_y : 1.;
+ return ScaleTransformOperation::create(fromX + (m_x - fromX) * progress, fromY + (m_y - fromY) * progress, m_type);
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/graphics/transforms/ScaleTransformOperation.h b/WebCore/platform/graphics/transforms/ScaleTransformOperation.h
new file mode 100644
index 0000000..289f8a1
--- /dev/null
+++ b/WebCore/platform/graphics/transforms/ScaleTransformOperation.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
+ * (C) 2000 Antti Koivisto (koivisto@kde.org)
+ * (C) 2000 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef ScaleTransformOperation_h
+#define ScaleTransformOperation_h
+
+#include "TransformOperation.h"
+
+namespace WebCore {
+
+class ScaleTransformOperation : public TransformOperation {
+public:
+ static PassRefPtr<ScaleTransformOperation> create(double sx, double sy, OperationType type)
+ {
+ return adoptRef(new ScaleTransformOperation(sx, sy, type));
+ }
+
+private:
+ virtual bool isIdentity() const { return m_x == 1 && m_y == 1; }
+ virtual OperationType getOperationType() const { return m_type; }
+ virtual bool isSameType(const TransformOperation& o) const { return o.getOperationType() == m_type; }
+
+ virtual bool operator==(const TransformOperation& o) const
+ {
+ if (!isSameType(o))
+ return false;
+ const ScaleTransformOperation* s = static_cast<const ScaleTransformOperation*>(&o);
+ return m_x == s->m_x && m_y == s->m_y;
+ }
+
+ virtual bool apply(TransformationMatrix& transform, const IntSize&) const
+ {
+ transform.scale(m_x, m_y);
+ return false;
+ }
+
+ virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false);
+
+ ScaleTransformOperation(double sx, double sy, OperationType type)
+ : m_x(sx)
+ , m_y(sy)
+ , m_type(type)
+ {
+ }
+
+ double m_x;
+ double m_y;
+ OperationType m_type;
+};
+
+} // namespace WebCore
+
+#endif // ScaleTransformOperation_h
diff --git a/WebCore/platform/graphics/transforms/SkewTransformOperation.cpp b/WebCore/platform/graphics/transforms/SkewTransformOperation.cpp
new file mode 100644
index 0000000..2a430e9
--- /dev/null
+++ b/WebCore/platform/graphics/transforms/SkewTransformOperation.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "SkewTransformOperation.h"
+
+namespace WebCore {
+
+PassRefPtr<TransformOperation> SkewTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity)
+{
+ if (from && !from->isSameType(*this))
+ return this;
+
+ if (blendToIdentity)
+ return SkewTransformOperation::create(m_angleX - m_angleX * progress, m_angleY - m_angleY * progress, m_type);
+
+ const SkewTransformOperation* fromOp = static_cast<const SkewTransformOperation*>(from);
+ double fromAngleX = fromOp ? fromOp->m_angleX : 0;
+ double fromAngleY = fromOp ? fromOp->m_angleY : 0;
+ return SkewTransformOperation::create(fromAngleX + (m_angleX - fromAngleX) * progress, fromAngleY + (m_angleY - fromAngleY) * progress, m_type);
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/graphics/transforms/SkewTransformOperation.h b/WebCore/platform/graphics/transforms/SkewTransformOperation.h
new file mode 100644
index 0000000..6343710
--- /dev/null
+++ b/WebCore/platform/graphics/transforms/SkewTransformOperation.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
+ * (C) 2000 Antti Koivisto (koivisto@kde.org)
+ * (C) 2000 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef SkewTransformOperation_h
+#define SkewTransformOperation_h
+
+#include "TransformOperation.h"
+
+namespace WebCore {
+
+class SkewTransformOperation : public TransformOperation {
+public:
+ static PassRefPtr<SkewTransformOperation> create(double angleX, double angleY, OperationType type)
+ {
+ return adoptRef(new SkewTransformOperation(angleX, angleY, type));
+ }
+
+private:
+ virtual bool isIdentity() const { return m_angleX == 0 && m_angleY == 0; }
+ virtual OperationType getOperationType() const { return m_type; }
+ virtual bool isSameType(const TransformOperation& o) const { return o.getOperationType() == m_type; }
+
+ virtual bool operator==(const TransformOperation& o) const
+ {
+ if (!isSameType(o))
+ return false;
+ const SkewTransformOperation* s = static_cast<const SkewTransformOperation*>(&o);
+ return m_angleX == s->m_angleX && m_angleY == s->m_angleY;
+ }
+
+ virtual bool apply(TransformationMatrix& transform, const IntSize&) const
+ {
+ transform.skew(m_angleX, m_angleY);
+ return false;
+ }
+
+ virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false);
+
+ SkewTransformOperation(double angleX, double angleY, OperationType type)
+ : m_angleX(angleX)
+ , m_angleY(angleY)
+ , m_type(type)
+ {
+ }
+
+ double m_angleX;
+ double m_angleY;
+ OperationType m_type;
+};
+
+} // namespace WebCore
+
+#endif // SkewTransformOperation_h
diff --git a/WebCore/platform/graphics/transforms/TransformOperation.h b/WebCore/platform/graphics/transforms/TransformOperation.h
new file mode 100644
index 0000000..65a0def
--- /dev/null
+++ b/WebCore/platform/graphics/transforms/TransformOperation.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
+ * (C) 2000 Antti Koivisto (koivisto@kde.org)
+ * (C) 2000 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TransformOperation_h
+#define TransformOperation_h
+
+#include "TransformationMatrix.h"
+#include "IntSize.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+// CSS Transforms (may become part of CSS3)
+
+class TransformOperation : public RefCounted<TransformOperation> {
+public:
+ enum OperationType {
+ SCALE_X, SCALE_Y, SCALE,
+ TRANSLATE_X, TRANSLATE_Y, TRANSLATE,
+ ROTATE,
+ SKEW_X, SKEW_Y, SKEW,
+ MATRIX, IDENTITY, NONE
+ };
+
+ virtual ~TransformOperation() { }
+
+ virtual bool operator==(const TransformOperation&) const = 0;
+ bool operator!=(const TransformOperation& o) const { return !(*this == o); }
+
+ virtual bool isIdentity() const = 0;
+
+ virtual bool apply(TransformationMatrix&, const IntSize& borderBoxSize) const = 0;
+
+ virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) = 0;
+
+ virtual OperationType getOperationType() const = 0;
+ virtual bool isSameType(const TransformOperation&) const { return false; }
+};
+
+} // namespace WebCore
+
+#endif // TransformOperation_h
diff --git a/WebCore/platform/graphics/transforms/TransformOperations.cpp b/WebCore/platform/graphics/transforms/TransformOperations.cpp
new file mode 100644
index 0000000..3d71480
--- /dev/null
+++ b/WebCore/platform/graphics/transforms/TransformOperations.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "TransformOperations.h"
+
+#include "IdentityTransformOperation.h"
+
+namespace WebCore {
+
+TransformOperations::TransformOperations(bool makeIdentity)
+{
+ if (makeIdentity)
+ m_operations.append(IdentityTransformOperation::create());
+}
+
+bool TransformOperations::operator==(const TransformOperations& o) const
+{
+ if (m_operations.size() != o.m_operations.size())
+ return false;
+
+ unsigned s = m_operations.size();
+ for (unsigned i = 0; i < s; i++) {
+ if (*m_operations[i] != *o.m_operations[i])
+ return false;
+ }
+
+ return true;
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/graphics/transforms/TransformOperations.h b/WebCore/platform/graphics/transforms/TransformOperations.h
new file mode 100644
index 0000000..f929417
--- /dev/null
+++ b/WebCore/platform/graphics/transforms/TransformOperations.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
+ * (C) 2000 Antti Koivisto (koivisto@kde.org)
+ * (C) 2000 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TransformOperations_h
+#define TransformOperations_h
+
+#include "TransformOperation.h"
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class TransformOperations {
+public:
+ TransformOperations(bool makeIdentity = false);
+
+ bool operator==(const TransformOperations& o) const;
+ bool operator!=(const TransformOperations& o) const
+ {
+ return !(*this == o);
+ }
+
+ void apply(const IntSize& sz, TransformationMatrix& t) const
+ {
+ for (unsigned i = 0; i < m_operations.size(); ++i)
+ m_operations[i]->apply(t, sz);
+ }
+
+ Vector<RefPtr<TransformOperation> >& operations() { return m_operations; }
+ const Vector<RefPtr<TransformOperation> >& operations() const { return m_operations; }
+
+private:
+ Vector<RefPtr<TransformOperation> > m_operations;
+};
+
+} // namespace WebCore
+
+#endif // TransformOperations_h
diff --git a/WebCore/platform/graphics/transforms/TransformationMatrix.cpp b/WebCore/platform/graphics/transforms/TransformationMatrix.cpp
new file mode 100644
index 0000000..b48d572
--- /dev/null
+++ b/WebCore/platform/graphics/transforms/TransformationMatrix.cpp
@@ -0,0 +1,205 @@
+/*
+ * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "TransformationMatrix.h"
+
+#include "FloatRect.h"
+#include "FloatQuad.h"
+#include "IntRect.h"
+
+#include <wtf/MathExtras.h>
+
+namespace WebCore {
+
+static void affineTransformDecompose(const TransformationMatrix& matrix, double sr[9])
+{
+ TransformationMatrix m(matrix);
+
+ // Compute scaling factors
+ double sx = sqrt(m.a() * m.a() + m.b() * m.b());
+ double sy = sqrt(m.c() * m.c() + m.d() * m.d());
+
+ /* Compute cross product of transformed unit vectors. If negative,
+ one axis was flipped. */
+
+ if (m.a() * m.d() - m.c() * m.b() < 0.0) {
+ // Flip axis with minimum unit vector dot product
+
+ if (m.a() < m.d())
+ sx = -sx;
+ else
+ sy = -sy;
+ }
+
+ // Remove scale from matrix
+
+ m.scale(1.0 / sx, 1.0 / sy);
+
+ // Compute rotation
+
+ double angle = atan2(m.b(), m.a());
+
+ // Remove rotation from matrix
+
+ m.rotate(rad2deg(-angle));
+
+ // Return results
+
+ sr[0] = sx; sr[1] = sy; sr[2] = angle;
+ sr[3] = m.a(); sr[4] = m.b();
+ sr[5] = m.c(); sr[6] = m.d();
+ sr[7] = m.e(); sr[8] = m.f();
+}
+
+static void affineTransformCompose(TransformationMatrix& m, const double sr[9])
+{
+ m.setA(sr[3]);
+ m.setB(sr[4]);
+ m.setC(sr[5]);
+ m.setD(sr[6]);
+ m.setE(sr[7]);
+ m.setF(sr[8]);
+ m.rotate(rad2deg(sr[2]));
+ m.scale(sr[0], sr[1]);
+}
+
+bool TransformationMatrix::isInvertible() const
+{
+ return det() != 0.0;
+}
+
+TransformationMatrix& TransformationMatrix::multiply(const TransformationMatrix& other)
+{
+ return (*this) *= other;
+}
+
+TransformationMatrix& TransformationMatrix::scale(double s)
+{
+ return scale(s, s);
+}
+
+TransformationMatrix& TransformationMatrix::scaleNonUniform(double sx, double sy)
+{
+ return scale(sx, sy);
+}
+
+TransformationMatrix& TransformationMatrix::rotateFromVector(double x, double y)
+{
+ return rotate(rad2deg(atan2(y, x)));
+}
+
+TransformationMatrix& TransformationMatrix::flipX()
+{
+ return scale(-1.0f, 1.0f);
+}
+
+TransformationMatrix& TransformationMatrix::flipY()
+{
+ return scale(1.0f, -1.0f);
+}
+
+TransformationMatrix& TransformationMatrix::skew(double angleX, double angleY)
+{
+ return shear(tan(deg2rad(angleX)), tan(deg2rad(angleY)));
+}
+
+TransformationMatrix& TransformationMatrix::skewX(double angle)
+{
+ return shear(tan(deg2rad(angle)), 0.0f);
+}
+
+TransformationMatrix& TransformationMatrix::skewY(double angle)
+{
+ return shear(0.0f, tan(deg2rad(angle)));
+}
+
+TransformationMatrix makeMapBetweenRects(const FloatRect& source, const FloatRect& dest)
+{
+ TransformationMatrix transform;
+ transform.translate(dest.x() - source.x(), dest.y() - source.y());
+ transform.scale(dest.width() / source.width(), dest.height() / source.height());
+ return transform;
+}
+
+IntPoint TransformationMatrix::mapPoint(const IntPoint& point) const
+{
+ double x2, y2;
+ map(point.x(), point.y(), &x2, &y2);
+
+ // Round the point.
+ return IntPoint(lround(x2), lround(y2));
+}
+
+FloatPoint TransformationMatrix::mapPoint(const FloatPoint& point) const
+{
+ double x2, y2;
+ map(point.x(), point.y(), &x2, &y2);
+
+ return FloatPoint(static_cast<float>(x2), static_cast<float>(y2));
+}
+
+FloatQuad TransformationMatrix::mapQuad(const FloatQuad& quad) const
+{
+ // FIXME: avoid 4 seperate library calls. Point mapping really needs
+ // to be platform-independent code.
+ return FloatQuad(mapPoint(quad.p1()),
+ mapPoint(quad.p2()),
+ mapPoint(quad.p3()),
+ mapPoint(quad.p4()));
+}
+
+void TransformationMatrix::blend(const TransformationMatrix& from, double progress)
+{
+ double srA[9], srB[9];
+
+ affineTransformDecompose(from, srA);
+ affineTransformDecompose(*this, srB);
+
+ // If x-axis of one is flipped, and y-axis of the other, convert to an unflipped rotation.
+ if ((srA[0] < 0.0 && srB[1] < 0.0) || (srA[1] < 0.0 && srB[0] < 0.0)) {
+ srA[0] = -srA[0];
+ srA[1] = -srA[1];
+ srA[2] += srA[2] < 0 ? piDouble : -piDouble;
+ }
+
+ // Don't rotate the long way around.
+ srA[2] = fmod(srA[2], 2.0 * piDouble);
+ srB[2] = fmod(srB[2], 2.0 * piDouble);
+
+ if (fabs(srA[2] - srB[2]) > piDouble) {
+ if (srA[2] > srB[2])
+ srA[2] -= piDouble * 2.0;
+ else
+ srB[2] -= piDouble * 2.0;
+ }
+
+ for (int i = 0; i < 9; i++)
+ srA[i] = srA[i] + progress * (srB[i] - srA[i]);
+
+ affineTransformCompose(*this, srA);
+}
+
+}
diff --git a/WebCore/platform/graphics/transforms/TransformationMatrix.h b/WebCore/platform/graphics/transforms/TransformationMatrix.h
new file mode 100644
index 0000000..db121d1
--- /dev/null
+++ b/WebCore/platform/graphics/transforms/TransformationMatrix.h
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TransformationMatrix_h
+#define TransformationMatrix_h
+
+#if PLATFORM(CG)
+#include <CoreGraphics/CGAffineTransform.h>
+typedef CGAffineTransform PlatformTransformationMatrix;
+#elif PLATFORM(QT)
+#include <QMatrix>
+typedef QMatrix PlatformTransformationMatrix;
+#elif PLATFORM(CAIRO)
+#include <cairo.h>
+typedef cairo_matrix_t PlatformTransformationMatrix;
+#elif PLATFORM(SKIA) || PLATFORM(SGL)
+#include "SkMatrix.h"
+typedef SkMatrix PlatformTransformationMatrix;
+#elif PLATFORM(WX) && USE(WXGC)
+#include <wx/defs.h>
+#include <wx/graphics.h>
+typedef wxGraphicsMatrix PlatformTransformationMatrix;
+#endif
+
+namespace WebCore {
+
+class IntPoint;
+class IntRect;
+class FloatPoint;
+class FloatRect;
+class FloatQuad;
+
+class TransformationMatrix {
+public:
+ TransformationMatrix();
+ TransformationMatrix(double a, double b, double c, double d, double e, double f);
+#if !PLATFORM(WX) || USE(WXGC)
+ TransformationMatrix(const PlatformTransformationMatrix&);
+#endif
+
+ void setMatrix(double a, double b, double c, double d, double e, double f);
+ void map(double x, double y, double *x2, double *y2) const;
+
+ // Rounds the mapped point to the nearest integer value.
+ IntPoint mapPoint(const IntPoint&) const;
+
+ FloatPoint mapPoint(const FloatPoint&) const;
+
+ // Rounds the resulting mapped rectangle out. This is helpful for bounding
+ // box computations but may not be what is wanted in other contexts.
+ IntRect mapRect(const IntRect&) const;
+
+ FloatRect mapRect(const FloatRect&) const;
+
+ FloatQuad mapQuad(const FloatQuad&) const;
+
+ bool isIdentity() const;
+
+ double a() const;
+ void setA(double a);
+
+ double b() const;
+ void setB(double b);
+
+ double c() const;
+ void setC(double c);
+
+ double d() const;
+ void setD(double d);
+
+ double e() const;
+ void setE(double e);
+
+ double f() const;
+ void setF(double f);
+
+ void reset();
+
+ TransformationMatrix& multiply(const TransformationMatrix&);
+ TransformationMatrix& scale(double);
+ TransformationMatrix& scale(double sx, double sy);
+ TransformationMatrix& scaleNonUniform(double sx, double sy);
+ TransformationMatrix& rotate(double d);
+ TransformationMatrix& rotateFromVector(double x, double y);
+ TransformationMatrix& translate(double tx, double ty);
+ TransformationMatrix& shear(double sx, double sy);
+ TransformationMatrix& flipX();
+ TransformationMatrix& flipY();
+ TransformationMatrix& skew(double angleX, double angleY);
+ TransformationMatrix& skewX(double angle);
+ TransformationMatrix& skewY(double angle);
+
+ double det() const;
+ bool isInvertible() const;
+ TransformationMatrix inverse() const;
+
+ void blend(const TransformationMatrix& from, double progress);
+
+#if !PLATFORM(WX) || USE(WXGC)
+ operator PlatformTransformationMatrix() const;
+#endif
+
+ bool operator==(const TransformationMatrix&) const;
+ bool operator!=(const TransformationMatrix& other) const { return !(*this == other); }
+ TransformationMatrix& operator*=(const TransformationMatrix&);
+ TransformationMatrix operator*(const TransformationMatrix&);
+
+private:
+#if !PLATFORM(WX) || USE(WXGC)
+ PlatformTransformationMatrix m_transform;
+#endif
+};
+
+TransformationMatrix makeMapBetweenRects(const FloatRect& source, const FloatRect& dest);
+
+} // namespace WebCore
+
+#endif // TransformationMatrix_h
diff --git a/WebCore/platform/graphics/transforms/TranslateTransformOperation.cpp b/WebCore/platform/graphics/transforms/TranslateTransformOperation.cpp
new file mode 100644
index 0000000..47471c4
--- /dev/null
+++ b/WebCore/platform/graphics/transforms/TranslateTransformOperation.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "TranslateTransformOperation.h"
+
+namespace WebCore {
+
+PassRefPtr<TransformOperation> TranslateTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity)
+{
+ if (from && !from->isSameType(*this))
+ return this;
+
+ if (blendToIdentity)
+ return TranslateTransformOperation::create(Length(m_x.type()).blend(m_x, progress), Length(m_y.type()).blend(m_y, progress), m_type);
+
+ const TranslateTransformOperation* fromOp = static_cast<const TranslateTransformOperation*>(from);
+ Length fromX = fromOp ? fromOp->m_x : Length(m_x.type());
+ Length fromY = fromOp ? fromOp->m_y : Length(m_y.type());
+ return TranslateTransformOperation::create(m_x.blend(fromX, progress), m_y.blend(fromY, progress), m_type);
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/graphics/transforms/TranslateTransformOperation.h b/WebCore/platform/graphics/transforms/TranslateTransformOperation.h
new file mode 100644
index 0000000..61ccbcc
--- /dev/null
+++ b/WebCore/platform/graphics/transforms/TranslateTransformOperation.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
+ * (C) 2000 Antti Koivisto (koivisto@kde.org)
+ * (C) 2000 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TranslateTransformOperation_h
+#define TranslateTransformOperation_h
+
+#include "Length.h"
+#include "TransformOperation.h"
+
+namespace WebCore {
+
+class TranslateTransformOperation : public TransformOperation {
+public:
+ static PassRefPtr<TranslateTransformOperation> create(const Length& tx, const Length& ty, OperationType type)
+ {
+ return adoptRef(new TranslateTransformOperation(tx, ty, type));
+ }
+
+ virtual bool isIdentity() const { return m_x.calcFloatValue(1) == 0 && m_y.calcFloatValue(1) == 0; }
+ virtual OperationType getOperationType() const { return m_type; }
+ virtual bool isSameType(const TransformOperation& o) const { return o.getOperationType() == m_type; }
+
+ virtual bool operator==(const TransformOperation& o) const
+ {
+ if (!isSameType(o))
+ return false;
+ const TranslateTransformOperation* t = static_cast<const TranslateTransformOperation*>(&o);
+ return m_x == t->m_x && m_y == t->m_y;
+ }
+
+ virtual bool apply(TransformationMatrix& transform, const IntSize& borderBoxSize) const
+ {
+ transform.translate(m_x.calcFloatValue(borderBoxSize.width()), m_y.calcFloatValue(borderBoxSize.height()));
+ return m_x.type() == Percent || m_y.type() == Percent;
+ }
+
+ virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false);
+
+private:
+ TranslateTransformOperation(const Length& tx, const Length& ty, OperationType type)
+ : m_x(tx)
+ , m_y(ty)
+ , m_type(type)
+ {
+ }
+
+ Length m_x;
+ Length m_y;
+ OperationType m_type;
+};
+
+} // namespace WebCore
+
+#endif // TranslateTransformOperation_h