/src/mozilla-central/gfx/thebes/gfx2DGlue.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #ifndef GFX_2D_GLUE_H |
8 | | #define GFX_2D_GLUE_H |
9 | | |
10 | | #include "gfxPlatform.h" |
11 | | #include "gfxRect.h" |
12 | | #include "gfxMatrix.h" |
13 | | #include "gfxContext.h" |
14 | | #include "mozilla/gfx/Matrix.h" |
15 | | #include "mozilla/gfx/Rect.h" |
16 | | #include "mozilla/gfx/2D.h" |
17 | | |
18 | | namespace mozilla { |
19 | | namespace gfx { |
20 | | |
21 | | inline Rect ToRect(const gfxRect &aRect) |
22 | | { |
23 | | return Rect(Float(aRect.X()), Float(aRect.Y()), |
24 | | Float(aRect.Width()), Float(aRect.Height())); |
25 | | } |
26 | | |
27 | | inline RectDouble ToRectDouble(const gfxRect &aRect) |
28 | | { |
29 | | return RectDouble(aRect.X(), aRect.Y(), aRect.Width(), aRect.Height()); |
30 | | } |
31 | | |
32 | | inline Matrix ToMatrix(const gfxMatrix &aMatrix) |
33 | 0 | { |
34 | 0 | return Matrix(Float(aMatrix._11), Float(aMatrix._12), Float(aMatrix._21), |
35 | 0 | Float(aMatrix._22), Float(aMatrix._31), Float(aMatrix._32)); |
36 | 0 | } |
37 | | |
38 | | inline gfxMatrix ThebesMatrix(const Matrix &aMatrix) |
39 | | { |
40 | | return gfxMatrix(aMatrix._11, aMatrix._12, aMatrix._21, |
41 | | aMatrix._22, aMatrix._31, aMatrix._32); |
42 | | } |
43 | | |
44 | | inline Point ToPoint(const gfxPoint &aPoint) |
45 | | { |
46 | | return Point(Float(aPoint.x), Float(aPoint.y)); |
47 | | } |
48 | | |
49 | | inline Size ToSize(const gfxSize &aSize) |
50 | | { |
51 | | return Size(Float(aSize.width), Float(aSize.height)); |
52 | | } |
53 | | |
54 | | inline gfxPoint ThebesPoint(const Point &aPoint) |
55 | | { |
56 | | return gfxPoint(aPoint.x, aPoint.y); |
57 | | } |
58 | | |
59 | | inline gfxSize ThebesSize(const Size &aSize) |
60 | | { |
61 | | return gfxSize(aSize.width, aSize.height); |
62 | | } |
63 | | |
64 | | inline gfxRect ThebesRect(const Rect &aRect) |
65 | | { |
66 | | return gfxRect(aRect.X(), aRect.Y(), aRect.Width(), aRect.Height()); |
67 | | } |
68 | | |
69 | | inline gfxRect ThebesRect(const IntRect &aRect) |
70 | | { |
71 | | return gfxRect(aRect.X(), aRect.Y(), aRect.Width(), aRect.Height()); |
72 | | } |
73 | | |
74 | | inline gfxRect ThebesRect(const RectDouble &aRect) |
75 | | { |
76 | | return gfxRect(aRect.X(), aRect.Y(), aRect.Width(), aRect.Height()); |
77 | | } |
78 | | |
79 | | inline gfxImageFormat SurfaceFormatToImageFormat(SurfaceFormat aFormat) |
80 | | { |
81 | | switch (aFormat) { |
82 | | case SurfaceFormat::B8G8R8A8: |
83 | | return SurfaceFormat::A8R8G8B8_UINT32; |
84 | | case SurfaceFormat::B8G8R8X8: |
85 | | return SurfaceFormat::X8R8G8B8_UINT32; |
86 | | case SurfaceFormat::R5G6B5_UINT16: |
87 | | return SurfaceFormat::R5G6B5_UINT16; |
88 | | case SurfaceFormat::A8: |
89 | | return SurfaceFormat::A8; |
90 | | default: |
91 | | return SurfaceFormat::UNKNOWN; |
92 | | } |
93 | | } |
94 | | |
95 | | inline SurfaceFormat ImageFormatToSurfaceFormat(gfxImageFormat aFormat) |
96 | | { |
97 | | switch (aFormat) { |
98 | | case SurfaceFormat::A8R8G8B8_UINT32: |
99 | | return SurfaceFormat::B8G8R8A8; |
100 | | case SurfaceFormat::X8R8G8B8_UINT32: |
101 | | return SurfaceFormat::B8G8R8X8; |
102 | | case SurfaceFormat::R5G6B5_UINT16: |
103 | | return SurfaceFormat::R5G6B5_UINT16; |
104 | | case SurfaceFormat::A8: |
105 | | return SurfaceFormat::A8; |
106 | | default: |
107 | | case SurfaceFormat::UNKNOWN: |
108 | | return SurfaceFormat::B8G8R8A8; |
109 | | } |
110 | | } |
111 | | |
112 | | inline gfxContentType ContentForFormat(const SurfaceFormat &aFormat) |
113 | | { |
114 | | switch (aFormat) { |
115 | | case SurfaceFormat::R5G6B5_UINT16: |
116 | | case SurfaceFormat::B8G8R8X8: |
117 | | case SurfaceFormat::R8G8B8X8: |
118 | | return gfxContentType::COLOR; |
119 | | case SurfaceFormat::A8: |
120 | | return gfxContentType::ALPHA; |
121 | | case SurfaceFormat::B8G8R8A8: |
122 | | case SurfaceFormat::R8G8B8A8: |
123 | | default: |
124 | | return gfxContentType::COLOR_ALPHA; |
125 | | } |
126 | | } |
127 | | |
128 | | } // namespace gfx |
129 | | } // namespace mozilla |
130 | | |
131 | | #endif |