Bug 1874684 - Part 28: Return DateDuration from DifferenceISODateTime. r=mgaudet
[gecko.git] / gfx / thebes / gfx2DGlue.h
blob578d7425026e81e2d6a1cf5b0c293f8be50498f3
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/. */
7 #ifndef GFX_2D_GLUE_H
8 #define GFX_2D_GLUE_H
10 #include "gfxMatrix.h"
11 #include "gfxPoint.h"
12 #include "gfxRect.h"
13 #include "gfxTypes.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"
19 namespace mozilla {
20 namespace gfx {
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) {
70 switch (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;
79 default:
80 return SurfaceFormat::UNKNOWN;
84 inline SurfaceFormat ImageFormatToSurfaceFormat(gfxImageFormat aFormat) {
85 switch (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;
94 default:
95 case SurfaceFormat::UNKNOWN:
96 return SurfaceFormat::B8G8R8A8;
100 inline gfxContentType ContentForFormat(const SurfaceFormat& aFormat) {
101 switch (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:
110 default:
111 return gfxContentType::COLOR_ALPHA;
115 } // namespace gfx
116 } // namespace mozilla
118 #endif