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/Rect.h"
16 #include "mozilla/gfx/2D.h"
21 inline Rect
ToRect(const gfxRect
& aRect
) {
22 return Rect(Float(aRect
.X()), Float(aRect
.Y()), Float(aRect
.Width()),
23 Float(aRect
.Height()));
26 inline RectDouble
ToRectDouble(const gfxRect
& aRect
) {
27 return RectDouble(aRect
.X(), aRect
.Y(), aRect
.Width(), aRect
.Height());
30 inline Matrix
ToMatrix(const gfxMatrix
& aMatrix
) {
31 return Matrix(Float(aMatrix
._11
), Float(aMatrix
._12
), Float(aMatrix
._21
),
32 Float(aMatrix
._22
), Float(aMatrix
._31
), Float(aMatrix
._32
));
35 inline gfxMatrix
ThebesMatrix(const Matrix
& aMatrix
) {
36 return gfxMatrix(aMatrix
._11
, aMatrix
._12
, aMatrix
._21
, aMatrix
._22
,
37 aMatrix
._31
, aMatrix
._32
);
40 inline Point
ToPoint(const gfxPoint
& aPoint
) {
41 return Point(Float(aPoint
.x
), Float(aPoint
.y
));
44 inline Size
ToSize(const gfxSize
& aSize
) {
45 return Size(Float(aSize
.width
), Float(aSize
.height
));
48 inline gfxPoint
ThebesPoint(const Point
& aPoint
) {
49 return gfxPoint(aPoint
.x
, aPoint
.y
);
52 inline gfxSize
ThebesSize(const Size
& aSize
) {
53 return gfxSize(aSize
.width
, aSize
.height
);
56 inline gfxRect
ThebesRect(const Rect
& aRect
) {
57 return gfxRect(aRect
.X(), aRect
.Y(), aRect
.Width(), aRect
.Height());
60 inline gfxRect
ThebesRect(const IntRect
& aRect
) {
61 return gfxRect(aRect
.X(), aRect
.Y(), aRect
.Width(), aRect
.Height());
64 inline gfxRect
ThebesRect(const RectDouble
& aRect
) {
65 return gfxRect(aRect
.X(), aRect
.Y(), aRect
.Width(), aRect
.Height());
68 inline gfxImageFormat
SurfaceFormatToImageFormat(SurfaceFormat aFormat
) {
70 case SurfaceFormat::B8G8R8A8
:
71 return SurfaceFormat::A8R8G8B8_UINT32
;
72 case SurfaceFormat::B8G8R8X8
:
73 return SurfaceFormat::X8R8G8B8_UINT32
;
74 case SurfaceFormat::R5G6B5_UINT16
:
75 return SurfaceFormat::R5G6B5_UINT16
;
76 case SurfaceFormat::A8
:
77 return SurfaceFormat::A8
;
79 return SurfaceFormat::UNKNOWN
;
83 inline SurfaceFormat
ImageFormatToSurfaceFormat(gfxImageFormat aFormat
) {
85 case SurfaceFormat::A8R8G8B8_UINT32
:
86 return SurfaceFormat::B8G8R8A8
;
87 case SurfaceFormat::X8R8G8B8_UINT32
:
88 return SurfaceFormat::B8G8R8X8
;
89 case SurfaceFormat::R5G6B5_UINT16
:
90 return SurfaceFormat::R5G6B5_UINT16
;
91 case SurfaceFormat::A8
:
92 return SurfaceFormat::A8
;
94 case SurfaceFormat::UNKNOWN
:
95 return SurfaceFormat::B8G8R8A8
;
99 inline gfxContentType
ContentForFormat(const SurfaceFormat
& aFormat
) {
101 case SurfaceFormat::R5G6B5_UINT16
:
102 case SurfaceFormat::B8G8R8X8
:
103 case SurfaceFormat::R8G8B8X8
:
104 return gfxContentType::COLOR
;
105 case SurfaceFormat::A8
:
106 return gfxContentType::ALPHA
;
107 case SurfaceFormat::B8G8R8A8
:
108 case SurfaceFormat::R8G8B8A8
:
110 return gfxContentType::COLOR_ALPHA
;
115 } // namespace mozilla