1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
10 #include "gfxMatrix.h"
14 #include "mozilla/gfx/Matrix.h"
15 #include "mozilla/gfx/Point.h"
16 #include "mozilla/gfx/Rect.h"
17 #include "mozilla/gfx/Types.h"
22 inline Rect
ToRect(const gfxRect
& aRect
) {
23 return Rect(Float(aRect
.X()), Float(aRect
.Y()), Float(aRect
.Width()),
24 Float(aRect
.Height()));
27 inline RectDouble
ToRectDouble(const gfxRect
& aRect
) {
28 return RectDouble(aRect
.X(), aRect
.Y(), aRect
.Width(), aRect
.Height());
31 inline Matrix
ToMatrix(const gfxMatrix
& aMatrix
) {
32 return Matrix(Float(aMatrix
._11
), Float(aMatrix
._12
), Float(aMatrix
._21
),
33 Float(aMatrix
._22
), Float(aMatrix
._31
), Float(aMatrix
._32
));
36 inline gfxMatrix
ThebesMatrix(const Matrix
& aMatrix
) {
37 return gfxMatrix(aMatrix
._11
, aMatrix
._12
, aMatrix
._21
, aMatrix
._22
,
38 aMatrix
._31
, aMatrix
._32
);
41 inline Point
ToPoint(const gfxPoint
& aPoint
) {
42 return Point(Float(aPoint
.x
), Float(aPoint
.y
));
45 inline Size
ToSize(const gfxSize
& aSize
) {
46 return Size(Float(aSize
.width
), Float(aSize
.height
));
49 inline gfxPoint
ThebesPoint(const Point
& aPoint
) {
50 return gfxPoint(aPoint
.x
, aPoint
.y
);
53 inline gfxSize
ThebesSize(const Size
& aSize
) {
54 return gfxSize(aSize
.width
, aSize
.height
);
57 inline gfxRect
ThebesRect(const Rect
& aRect
) {
58 return gfxRect(aRect
.X(), aRect
.Y(), aRect
.Width(), aRect
.Height());
61 inline gfxRect
ThebesRect(const IntRect
& aRect
) {
62 return gfxRect(aRect
.X(), aRect
.Y(), aRect
.Width(), aRect
.Height());
65 inline gfxRect
ThebesRect(const RectDouble
& aRect
) {
66 return gfxRect(aRect
.X(), aRect
.Y(), aRect
.Width(), aRect
.Height());
69 inline gfxImageFormat
SurfaceFormatToImageFormat(SurfaceFormat aFormat
) {
71 case SurfaceFormat::B8G8R8A8
:
72 return SurfaceFormat::A8R8G8B8_UINT32
;
73 case SurfaceFormat::B8G8R8X8
:
74 return SurfaceFormat::X8R8G8B8_UINT32
;
75 case SurfaceFormat::R5G6B5_UINT16
:
76 return SurfaceFormat::R5G6B5_UINT16
;
77 case SurfaceFormat::A8
:
78 return SurfaceFormat::A8
;
80 return SurfaceFormat::UNKNOWN
;
84 inline SurfaceFormat
ImageFormatToSurfaceFormat(gfxImageFormat aFormat
) {
86 case SurfaceFormat::A8R8G8B8_UINT32
:
87 return SurfaceFormat::B8G8R8A8
;
88 case SurfaceFormat::X8R8G8B8_UINT32
:
89 return SurfaceFormat::B8G8R8X8
;
90 case SurfaceFormat::R5G6B5_UINT16
:
91 return SurfaceFormat::R5G6B5_UINT16
;
92 case SurfaceFormat::A8
:
93 return SurfaceFormat::A8
;
95 case SurfaceFormat::UNKNOWN
:
96 return SurfaceFormat::B8G8R8A8
;
100 inline gfxContentType
ContentForFormat(const SurfaceFormat
& aFormat
) {
102 case SurfaceFormat::R5G6B5_UINT16
:
103 case SurfaceFormat::B8G8R8X8
:
104 case SurfaceFormat::R8G8B8X8
:
105 return gfxContentType::COLOR
;
106 case SurfaceFormat::A8
:
107 return gfxContentType::ALPHA
;
108 case SurfaceFormat::B8G8R8A8
:
109 case SurfaceFormat::R8G8B8A8
:
111 return gfxContentType::COLOR_ALPHA
;
116 } // namespace mozilla