+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.
--- /dev/null
+#import "KWQWMatrix.h"
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;
#include <qdrawutil.h>
#include <qpainter.h>
+#include <qwmatrix.h>
#include <kapplication.h>
#include <kdebug.h>
};
-class QWMatrix {
-public:
- QWMatrix() { }
- QWMatrix &scale(double, double) { return *this; }
-};
-
#endif
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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;
+}