Bug #: 3821
authoreseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Jul 2005 07:57:47 +0000 (07:57 +0000)
committereseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Jul 2005 07:57:47 +0000 (07:57 +0000)
Submitted by: eseidel
Reviewed by: mjs
        * ForwardingHeaders/qwmatrix.h: Added.
        * WebCore.pbproj/project.pbxproj: Added KWQMatrix.*
        * khtml/rendering/render_image.cpp: Now includes qwmatrix.h
        * kwq/KWQPixmap.h: Removed QWMatrix stub.
        * kwq/KWQWMatrix.h: Added.
        (QWMatrix::m11): simple accessors.
        (QWMatrix::m12):
        (QWMatrix::m21):
        (QWMatrix::m22):
        (QWMatrix::dx):
        (QWMatrix::dy):
        * kwq/KWQWMatrix.mm: Added.
        (QWMatrix::QWMatrix): All are standard Qt functions.
        (QWMatrix::setMatrix):
        (QWMatrix::map):
        (QWMatrix::isIdentity):
        (QWMatrix::reset):
        (QWMatrix::scale):
        (QWMatrix::rotate):
        (QWMatrix::translate):
        (QWMatrix::shear):
        (QWMatrix::det):
        (QWMatrix::isInvertible):
        (QWMatrix::invert):
        (QWMatrix::operator CGAffineTransform):
        (QWMatrix::operator== ):
        (QWMatrix::operator*= ):
        Simple white-room QWMatrix implementation entirely
        based on CGAffineTransform.
        http://bugzilla.opendarwin.org/show_bug.cgi?id=3821

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@9585 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog-2005-08-23
WebCore/ForwardingHeaders/qwmatrix.h [new file with mode: 0644]
WebCore/WebCore.pbproj/project.pbxproj
WebCore/khtml/rendering/render_image.cpp
WebCore/kwq/KWQPixmap.h
WebCore/kwq/KWQWMatrix.h [new file with mode: 0644]
WebCore/kwq/KWQWMatrix.mm [new file with mode: 0644]

index 445f91d6d79e4b68bfbbeb13f115f73da2f3c3dc..c170bd03636bb197815c14aac63fdac8018ef7d7 100644 (file)
@@ -1,3 +1,38 @@
+2005-07-05  Eric Seidel  <eseidel@apple.com>
+
+        Reviewed by mjs.
+
+        * ForwardingHeaders/qwmatrix.h: Added.
+        * WebCore.pbproj/project.pbxproj: Added KWQMatrix.*
+        * khtml/rendering/render_image.cpp: Now includes qwmatrix.h
+        * kwq/KWQPixmap.h: Removed QWMatrix stub.
+        * kwq/KWQWMatrix.h: Added.
+        (QWMatrix::m11): simple accessors.
+        (QWMatrix::m12):
+        (QWMatrix::m21):
+        (QWMatrix::m22):
+        (QWMatrix::dx):
+        (QWMatrix::dy):
+        * kwq/KWQWMatrix.mm: Added.
+        (QWMatrix::QWMatrix): All are standard Qt functions.
+        (QWMatrix::setMatrix):
+        (QWMatrix::map):
+        (QWMatrix::isIdentity):
+        (QWMatrix::reset):
+        (QWMatrix::scale):
+        (QWMatrix::rotate):
+        (QWMatrix::translate):
+        (QWMatrix::shear):
+        (QWMatrix::det):
+        (QWMatrix::isInvertible):
+        (QWMatrix::invert):
+        (QWMatrix::operator CGAffineTransform):
+        (QWMatrix::operator== ):
+        (QWMatrix::operator*= ):
+        Simple white-room QWMatrix implementation entirely 
+        based on CGAffineTransform.
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=3821
+
 2005-07-05  Eric Seidel  <eseidel@apple.com>
 
         Reviewed by mjs.
diff --git a/WebCore/ForwardingHeaders/qwmatrix.h b/WebCore/ForwardingHeaders/qwmatrix.h
new file mode 100644 (file)
index 0000000..ce1c001
--- /dev/null
@@ -0,0 +1 @@
+#import "KWQWMatrix.h"
index b8d51d0499223577b05191627aeee8b7187aaad5..bcf79a2e55fd3d4ede607fa925e89c74805c4636 100644 (file)
                                550A0BCE085F604D007353D6,
                                65F378290870D958000B2F94,
                                65F3782B0870D958000B2F94,
+                               A85D7C19087A6ED9006A9172,
                        );
                        isa = PBXHeadersBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
                                550A0BC9085F6039007353D6,
                                550A0BCD085F604D007353D6,
                                65F3782A0870D958000B2F94,
+                               A85D7C18087A6ED9006A9172,
                        );
                        isa = PBXSourcesBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
 //932
 //933
 //934
+//A80
+//A81
+//A82
+//A83
+//A84
+               A85D7C16087A6ED8006A9172 = {
+                       fileEncoding = 4;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.objcpp;
+                       path = KWQWMatrix.mm;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               A85D7C17087A6ED8006A9172 = {
+                       fileEncoding = 4;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
+                       path = KWQWMatrix.h;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               A85D7C18087A6ED9006A9172 = {
+                       fileRef = A85D7C16087A6ED8006A9172;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
+               A85D7C19087A6ED9006A9172 = {
+                       fileRef = A85D7C17087A6ED8006A9172;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
+//A80
+//A81
+//A82
+//A83
+//A84
 //BC0
 //BC1
 //BC2
                                F587853F02DE375901EA4122,
                                F58786C502DE3B8601EA4122,
                                F587854202DE375901EA4122,
+                               A85D7C17087A6ED8006A9172,
+                               A85D7C16087A6ED8006A9172,
                        );
                        isa = PBXGroup;
                        name = qt;
index eb832d169ffd798a67b94f181444e10fc48dc473..a164a62059b439323b244978ce88620d7daabd77 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <qdrawutil.h>
 #include <qpainter.h>
+#include <qwmatrix.h>
 
 #include <kapplication.h>
 #include <kdebug.h>
index 90ec94835ade4cb954400c4540bbbc95a3517dc0..41bef6fe341c4733044df5101f933857bbaa016f 100644 (file)
@@ -111,10 +111,4 @@ private:
 
 };
 
-class QWMatrix {
-public:
-    QWMatrix() { }
-    QWMatrix &scale(double, double) { return *this; }
-};
-
 #endif
diff --git a/WebCore/kwq/KWQWMatrix.h b/WebCore/kwq/KWQWMatrix.h
new file mode 100644 (file)
index 0000000..418fcc7
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2005 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 QWMATRIX_H_
+#define QWMATRIX_H_
+
+#include <ApplicationServices/ApplicationServices.h>
+
+class QWMatrix {
+public:
+    QWMatrix();
+    QWMatrix(double a, double b, double c, double d, double tx, double ty);
+    QWMatrix(CGAffineTransform transform);
+    
+    void setMatrix(double a, double b, double c, double d, double tx, double ty);
+    void map(double x, double y, double *x2, double *y2) const;
+    
+    bool isIdentity() const;
+    
+    double m11() const { return m_transform.a; }
+    double m12() const { return m_transform.b; }
+    double m21() const { return m_transform.c; }
+    double m22() const { return m_transform.d; }
+    double dx() const { return m_transform.tx; }
+    double dy() const { return m_transform.ty; }
+
+    void reset();
+    
+    QWMatrix &scale(double sx, double sy);
+    QWMatrix &rotate(double d);
+    QWMatrix &translate(double tx, double ty);
+    QWMatrix &shear(double sx, double sy);
+    
+    double det() const;
+    bool isInvertible() const;
+    QWMatrix invert() const;
+    
+    operator CGAffineTransform() const;
+    
+    bool operator== (const QWMatrix &) const;
+    QWMatrix &operator*= (const QWMatrix &);
+    
+private:
+    CGAffineTransform m_transform;
+};
+
+#endif
diff --git a/WebCore/kwq/KWQWMatrix.mm b/WebCore/kwq/KWQWMatrix.mm
new file mode 100644 (file)
index 0000000..564d4f5
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2005 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. 
+ */
+
+#import "KWQWMatrix.h"
+
+static const double deg2rad = 0.017453292519943295769; // pi/180
+
+QWMatrix::QWMatrix()
+{
+    m_transform = CGAffineTransformIdentity;
+}
+
+QWMatrix::QWMatrix(double a, double b, double c, double d, double tx, double ty)
+{
+    m_transform = CGAffineTransformMake(a,b,c,d,tx,ty);
+}
+
+QWMatrix::QWMatrix(CGAffineTransform t) {
+    m_transform = t;
+}
+
+void QWMatrix::setMatrix(double a, double b, double c, double d, double tx, double ty)
+{
+    m_transform = CGAffineTransformMake(a,b,c,d,tx,ty);
+}
+
+void QWMatrix::map(double x, double y, double *x2, double *y2) const
+{
+    CGPoint result = CGPointApplyAffineTransform(CGPointMake(x,y),m_transform);
+    *x2 = result.x;
+    *y2 = result.y;
+}
+
+bool QWMatrix::isIdentity() const
+{
+    return CGAffineTransformIsIdentity(m_transform);
+}
+
+void QWMatrix::reset()
+{
+    m_transform = CGAffineTransformIdentity;
+}
+
+QWMatrix &QWMatrix::scale(double sx, double sy)
+{
+    m_transform = CGAffineTransformScale(m_transform, sx, sy);
+    return *this;
+}
+
+QWMatrix &QWMatrix::rotate(double d)
+{
+    m_transform = CGAffineTransformRotate(m_transform, d * deg2rad);
+    return *this;
+}
+
+QWMatrix &QWMatrix::translate(double tx, double ty)
+{
+    m_transform = CGAffineTransformTranslate(m_transform, tx, ty);
+    return *this;
+}
+
+QWMatrix &QWMatrix::shear(double sx, double sy)
+{
+    CGAffineTransform shear = CGAffineTransformMake(1, sy, sx, 1, 0, 0);
+    m_transform = CGAffineTransformConcat(shear,m_transform);
+    return *this;
+}
+
+double QWMatrix::det() const
+{
+    return m_transform.a * m_transform.d - m_transform.b * m_transform.c;
+}
+
+bool QWMatrix::isInvertible() const
+{
+    return det() == 0.0;
+}
+
+QWMatrix QWMatrix::invert() const
+{
+    if (isInvertible())
+        return QWMatrix(CGAffineTransformInvert(m_transform));
+    return QWMatrix();
+}
+
+QWMatrix::operator CGAffineTransform() const
+{
+    return m_transform;
+}
+
+bool QWMatrix::operator== (const QWMatrix &m2) const
+{
+    return CGAffineTransformEqualToTransform(m_transform, CGAffineTransform(m2));
+}
+
+QWMatrix &QWMatrix::operator*= (const QWMatrix &m2)
+{
+    m_transform = CGAffineTransformConcat(m_transform, CGAffineTransform(m2));
+    return *this;
+}