1 /*
2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #include "config.h"
27 #include "TransformationMatrix.h"
28
29 #if USE(CA)
30
31 #include "FloatConversion.h"
32 #include <QuartzCore/CATransform3D.h>
33
34 namespace WebCore {
35
TransformationMatrix(const CATransform3D & t)36 TransformationMatrix::TransformationMatrix(const CATransform3D& t)
37 {
38 setMatrix(
39 t.m11, t.m12, t.m13, t.m14,
40 t.m21, t.m22, t.m23, t.m24,
41 t.m31, t.m32, t.m33, t.m34,
42 t.m41, t.m42, t.m43, t.m44);
43 }
44
operator CATransform3D() const45 TransformationMatrix::operator CATransform3D() const
46 {
47 CATransform3D toT3D;
48 toT3D.m11 = narrowPrecisionToFloat(m11());
49 toT3D.m12 = narrowPrecisionToFloat(m12());
50 toT3D.m13 = narrowPrecisionToFloat(m13());
51 toT3D.m14 = narrowPrecisionToFloat(m14());
52 toT3D.m21 = narrowPrecisionToFloat(m21());
53 toT3D.m22 = narrowPrecisionToFloat(m22());
54 toT3D.m23 = narrowPrecisionToFloat(m23());
55 toT3D.m24 = narrowPrecisionToFloat(m24());
56 toT3D.m31 = narrowPrecisionToFloat(m31());
57 toT3D.m32 = narrowPrecisionToFloat(m32());
58 toT3D.m33 = narrowPrecisionToFloat(m33());
59 toT3D.m34 = narrowPrecisionToFloat(m34());
60 toT3D.m41 = narrowPrecisionToFloat(m41());
61 toT3D.m42 = narrowPrecisionToFloat(m42());
62 toT3D.m43 = narrowPrecisionToFloat(m43());
63 toT3D.m44 = narrowPrecisionToFloat(m44());
64 return toT3D;
65 }
66
67 }
68
69 #endif // USE(CA)
70