/work/obj-fuzz/dist/include/mozilla/gfx/HelpersCairo.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 MOZILLA_GFX_HELPERSCAIRO_H_ |
8 | | #define MOZILLA_GFX_HELPERSCAIRO_H_ |
9 | | |
10 | | #include "2D.h" |
11 | | #include "cairo.h" |
12 | | #include "Logging.h" |
13 | | |
14 | | namespace mozilla { |
15 | | namespace gfx { |
16 | | |
17 | | static inline cairo_operator_t |
18 | | GfxOpToCairoOp(CompositionOp op) |
19 | 0 | { |
20 | 0 | switch (op) |
21 | 0 | { |
22 | 0 | case CompositionOp::OP_OVER: |
23 | 0 | return CAIRO_OPERATOR_OVER; |
24 | 0 | case CompositionOp::OP_ADD: |
25 | 0 | return CAIRO_OPERATOR_ADD; |
26 | 0 | case CompositionOp::OP_ATOP: |
27 | 0 | return CAIRO_OPERATOR_ATOP; |
28 | 0 | case CompositionOp::OP_OUT: |
29 | 0 | return CAIRO_OPERATOR_OUT; |
30 | 0 | case CompositionOp::OP_IN: |
31 | 0 | return CAIRO_OPERATOR_IN; |
32 | 0 | case CompositionOp::OP_SOURCE: |
33 | 0 | return CAIRO_OPERATOR_SOURCE; |
34 | 0 | case CompositionOp::OP_DEST_IN: |
35 | 0 | return CAIRO_OPERATOR_DEST_IN; |
36 | 0 | case CompositionOp::OP_DEST_OUT: |
37 | 0 | return CAIRO_OPERATOR_DEST_OUT; |
38 | 0 | case CompositionOp::OP_DEST_OVER: |
39 | 0 | return CAIRO_OPERATOR_DEST_OVER; |
40 | 0 | case CompositionOp::OP_DEST_ATOP: |
41 | 0 | return CAIRO_OPERATOR_DEST_ATOP; |
42 | 0 | case CompositionOp::OP_XOR: |
43 | 0 | return CAIRO_OPERATOR_XOR; |
44 | 0 | case CompositionOp::OP_MULTIPLY: |
45 | 0 | return CAIRO_OPERATOR_MULTIPLY; |
46 | 0 | case CompositionOp::OP_SCREEN: |
47 | 0 | return CAIRO_OPERATOR_SCREEN; |
48 | 0 | case CompositionOp::OP_OVERLAY: |
49 | 0 | return CAIRO_OPERATOR_OVERLAY; |
50 | 0 | case CompositionOp::OP_DARKEN: |
51 | 0 | return CAIRO_OPERATOR_DARKEN; |
52 | 0 | case CompositionOp::OP_LIGHTEN: |
53 | 0 | return CAIRO_OPERATOR_LIGHTEN; |
54 | 0 | case CompositionOp::OP_COLOR_DODGE: |
55 | 0 | return CAIRO_OPERATOR_COLOR_DODGE; |
56 | 0 | case CompositionOp::OP_COLOR_BURN: |
57 | 0 | return CAIRO_OPERATOR_COLOR_BURN; |
58 | 0 | case CompositionOp::OP_HARD_LIGHT: |
59 | 0 | return CAIRO_OPERATOR_HARD_LIGHT; |
60 | 0 | case CompositionOp::OP_SOFT_LIGHT: |
61 | 0 | return CAIRO_OPERATOR_SOFT_LIGHT; |
62 | 0 | case CompositionOp::OP_DIFFERENCE: |
63 | 0 | return CAIRO_OPERATOR_DIFFERENCE; |
64 | 0 | case CompositionOp::OP_EXCLUSION: |
65 | 0 | return CAIRO_OPERATOR_EXCLUSION; |
66 | 0 | case CompositionOp::OP_HUE: |
67 | 0 | return CAIRO_OPERATOR_HSL_HUE; |
68 | 0 | case CompositionOp::OP_SATURATION: |
69 | 0 | return CAIRO_OPERATOR_HSL_SATURATION; |
70 | 0 | case CompositionOp::OP_COLOR: |
71 | 0 | return CAIRO_OPERATOR_HSL_COLOR; |
72 | 0 | case CompositionOp::OP_LUMINOSITY: |
73 | 0 | return CAIRO_OPERATOR_HSL_LUMINOSITY; |
74 | 0 | case CompositionOp::OP_COUNT: |
75 | 0 | break; |
76 | 0 | } |
77 | 0 |
|
78 | 0 | return CAIRO_OPERATOR_OVER; |
79 | 0 | } Unexecuted instantiation: PrintTarget.cpp:mozilla::gfx::GfxOpToCairoOp(mozilla::gfx::CompositionOp) Unexecuted instantiation: gfxASurface.cpp:mozilla::gfx::GfxOpToCairoOp(mozilla::gfx::CompositionOp) Unexecuted instantiation: gfxFcPlatformFontList.cpp:mozilla::gfx::GfxOpToCairoOp(mozilla::gfx::CompositionOp) Unexecuted instantiation: gfxXlibNativeRenderer.cpp:mozilla::gfx::GfxOpToCairoOp(mozilla::gfx::CompositionOp) Unexecuted instantiation: Unified_cpp_gfx_thebes1.cpp:mozilla::gfx::GfxOpToCairoOp(mozilla::gfx::CompositionOp) Unexecuted instantiation: nsWindow.cpp:mozilla::gfx::GfxOpToCairoOp(mozilla::gfx::CompositionOp) Unexecuted instantiation: Unified_cpp_widget_gtk2.cpp:mozilla::gfx::GfxOpToCairoOp(mozilla::gfx::CompositionOp) |
80 | | |
81 | | static inline cairo_antialias_t |
82 | | GfxAntialiasToCairoAntialias(AntialiasMode antialias) |
83 | 0 | { |
84 | 0 | switch (antialias) |
85 | 0 | { |
86 | 0 | case AntialiasMode::NONE: |
87 | 0 | return CAIRO_ANTIALIAS_NONE; |
88 | 0 | case AntialiasMode::GRAY: |
89 | 0 | return CAIRO_ANTIALIAS_GRAY; |
90 | 0 | case AntialiasMode::SUBPIXEL: |
91 | 0 | return CAIRO_ANTIALIAS_SUBPIXEL; |
92 | 0 | default: |
93 | 0 | return CAIRO_ANTIALIAS_DEFAULT; |
94 | 0 | } |
95 | 0 | } Unexecuted instantiation: PrintTarget.cpp:mozilla::gfx::GfxAntialiasToCairoAntialias(mozilla::gfx::AntialiasMode) Unexecuted instantiation: gfxASurface.cpp:mozilla::gfx::GfxAntialiasToCairoAntialias(mozilla::gfx::AntialiasMode) Unexecuted instantiation: gfxFcPlatformFontList.cpp:mozilla::gfx::GfxAntialiasToCairoAntialias(mozilla::gfx::AntialiasMode) Unexecuted instantiation: gfxXlibNativeRenderer.cpp:mozilla::gfx::GfxAntialiasToCairoAntialias(mozilla::gfx::AntialiasMode) Unexecuted instantiation: Unified_cpp_gfx_thebes1.cpp:mozilla::gfx::GfxAntialiasToCairoAntialias(mozilla::gfx::AntialiasMode) Unexecuted instantiation: nsWindow.cpp:mozilla::gfx::GfxAntialiasToCairoAntialias(mozilla::gfx::AntialiasMode) Unexecuted instantiation: Unified_cpp_widget_gtk2.cpp:mozilla::gfx::GfxAntialiasToCairoAntialias(mozilla::gfx::AntialiasMode) |
96 | | |
97 | | static inline AntialiasMode |
98 | | CairoAntialiasToGfxAntialias(cairo_antialias_t aAntialias) |
99 | 0 | { |
100 | 0 | switch(aAntialias) { |
101 | 0 | case CAIRO_ANTIALIAS_NONE: |
102 | 0 | return AntialiasMode::NONE; |
103 | 0 | case CAIRO_ANTIALIAS_GRAY: |
104 | 0 | return AntialiasMode::GRAY; |
105 | 0 | case CAIRO_ANTIALIAS_SUBPIXEL: |
106 | 0 | return AntialiasMode::SUBPIXEL; |
107 | 0 | default: |
108 | 0 | return AntialiasMode::DEFAULT; |
109 | 0 | } |
110 | 0 | } Unexecuted instantiation: PrintTarget.cpp:mozilla::gfx::CairoAntialiasToGfxAntialias(_cairo_antialias) Unexecuted instantiation: gfxASurface.cpp:mozilla::gfx::CairoAntialiasToGfxAntialias(_cairo_antialias) Unexecuted instantiation: gfxFcPlatformFontList.cpp:mozilla::gfx::CairoAntialiasToGfxAntialias(_cairo_antialias) Unexecuted instantiation: gfxXlibNativeRenderer.cpp:mozilla::gfx::CairoAntialiasToGfxAntialias(_cairo_antialias) Unexecuted instantiation: Unified_cpp_gfx_thebes1.cpp:mozilla::gfx::CairoAntialiasToGfxAntialias(_cairo_antialias) Unexecuted instantiation: nsWindow.cpp:mozilla::gfx::CairoAntialiasToGfxAntialias(_cairo_antialias) Unexecuted instantiation: Unified_cpp_widget_gtk2.cpp:mozilla::gfx::CairoAntialiasToGfxAntialias(_cairo_antialias) |
111 | | |
112 | | static inline cairo_filter_t |
113 | | GfxSamplingFilterToCairoFilter(SamplingFilter filter) |
114 | 0 | { |
115 | 0 | switch (filter) |
116 | 0 | { |
117 | 0 | case SamplingFilter::GOOD: |
118 | 0 | return CAIRO_FILTER_GOOD; |
119 | 0 | case SamplingFilter::LINEAR: |
120 | 0 | return CAIRO_FILTER_BILINEAR; |
121 | 0 | case SamplingFilter::POINT: |
122 | 0 | return CAIRO_FILTER_NEAREST; |
123 | 0 | default: |
124 | 0 | MOZ_CRASH("GFX: bad Cairo filter"); |
125 | 0 | } |
126 | 0 |
|
127 | 0 | return CAIRO_FILTER_BILINEAR; |
128 | 0 | } Unexecuted instantiation: PrintTarget.cpp:mozilla::gfx::GfxSamplingFilterToCairoFilter(mozilla::gfx::SamplingFilter) Unexecuted instantiation: gfxASurface.cpp:mozilla::gfx::GfxSamplingFilterToCairoFilter(mozilla::gfx::SamplingFilter) Unexecuted instantiation: gfxFcPlatformFontList.cpp:mozilla::gfx::GfxSamplingFilterToCairoFilter(mozilla::gfx::SamplingFilter) Unexecuted instantiation: gfxXlibNativeRenderer.cpp:mozilla::gfx::GfxSamplingFilterToCairoFilter(mozilla::gfx::SamplingFilter) Unexecuted instantiation: Unified_cpp_gfx_thebes1.cpp:mozilla::gfx::GfxSamplingFilterToCairoFilter(mozilla::gfx::SamplingFilter) Unexecuted instantiation: nsWindow.cpp:mozilla::gfx::GfxSamplingFilterToCairoFilter(mozilla::gfx::SamplingFilter) Unexecuted instantiation: Unified_cpp_widget_gtk2.cpp:mozilla::gfx::GfxSamplingFilterToCairoFilter(mozilla::gfx::SamplingFilter) |
129 | | |
130 | | static inline cairo_extend_t |
131 | | GfxExtendToCairoExtend(ExtendMode extend) |
132 | 0 | { |
133 | 0 | switch (extend) |
134 | 0 | { |
135 | 0 | case ExtendMode::CLAMP: |
136 | 0 | return CAIRO_EXTEND_PAD; |
137 | 0 | // Cairo doesn't support tiling in only 1 direction, |
138 | 0 | // So we have to fallback and tile in both. |
139 | 0 | case ExtendMode::REPEAT_X: |
140 | 0 | case ExtendMode::REPEAT_Y: |
141 | 0 | case ExtendMode::REPEAT: |
142 | 0 | return CAIRO_EXTEND_REPEAT; |
143 | 0 | case ExtendMode::REFLECT: |
144 | 0 | return CAIRO_EXTEND_REFLECT; |
145 | 0 | } |
146 | 0 |
|
147 | 0 | return CAIRO_EXTEND_PAD; |
148 | 0 | } Unexecuted instantiation: PrintTarget.cpp:mozilla::gfx::GfxExtendToCairoExtend(mozilla::gfx::ExtendMode) Unexecuted instantiation: gfxASurface.cpp:mozilla::gfx::GfxExtendToCairoExtend(mozilla::gfx::ExtendMode) Unexecuted instantiation: gfxFcPlatformFontList.cpp:mozilla::gfx::GfxExtendToCairoExtend(mozilla::gfx::ExtendMode) Unexecuted instantiation: gfxXlibNativeRenderer.cpp:mozilla::gfx::GfxExtendToCairoExtend(mozilla::gfx::ExtendMode) Unexecuted instantiation: Unified_cpp_gfx_thebes1.cpp:mozilla::gfx::GfxExtendToCairoExtend(mozilla::gfx::ExtendMode) Unexecuted instantiation: nsWindow.cpp:mozilla::gfx::GfxExtendToCairoExtend(mozilla::gfx::ExtendMode) Unexecuted instantiation: Unified_cpp_widget_gtk2.cpp:mozilla::gfx::GfxExtendToCairoExtend(mozilla::gfx::ExtendMode) |
149 | | |
150 | | static inline cairo_format_t |
151 | | GfxFormatToCairoFormat(SurfaceFormat format) |
152 | 0 | { |
153 | 0 | switch (format) |
154 | 0 | { |
155 | 0 | case SurfaceFormat::A8R8G8B8_UINT32: |
156 | 0 | return CAIRO_FORMAT_ARGB32; |
157 | 0 | case SurfaceFormat::X8R8G8B8_UINT32: |
158 | 0 | return CAIRO_FORMAT_RGB24; |
159 | 0 | case SurfaceFormat::A8: |
160 | 0 | return CAIRO_FORMAT_A8; |
161 | 0 | case SurfaceFormat::R5G6B5_UINT16: |
162 | 0 | return CAIRO_FORMAT_RGB16_565; |
163 | 0 | default: |
164 | 0 | gfxCriticalError() << "Unknown image format " << (int)format; |
165 | 0 | return CAIRO_FORMAT_ARGB32; |
166 | 0 | } |
167 | 0 | } Unexecuted instantiation: PrintTarget.cpp:mozilla::gfx::GfxFormatToCairoFormat(mozilla::gfx::SurfaceFormat) Unexecuted instantiation: gfxASurface.cpp:mozilla::gfx::GfxFormatToCairoFormat(mozilla::gfx::SurfaceFormat) Unexecuted instantiation: gfxFcPlatformFontList.cpp:mozilla::gfx::GfxFormatToCairoFormat(mozilla::gfx::SurfaceFormat) Unexecuted instantiation: gfxXlibNativeRenderer.cpp:mozilla::gfx::GfxFormatToCairoFormat(mozilla::gfx::SurfaceFormat) Unexecuted instantiation: Unified_cpp_gfx_thebes1.cpp:mozilla::gfx::GfxFormatToCairoFormat(mozilla::gfx::SurfaceFormat) Unexecuted instantiation: nsWindow.cpp:mozilla::gfx::GfxFormatToCairoFormat(mozilla::gfx::SurfaceFormat) Unexecuted instantiation: Unified_cpp_widget_gtk2.cpp:mozilla::gfx::GfxFormatToCairoFormat(mozilla::gfx::SurfaceFormat) |
168 | | |
169 | | static inline cairo_format_t |
170 | | CairoContentToCairoFormat(cairo_content_t content) |
171 | 0 | { |
172 | 0 | switch (content) |
173 | 0 | { |
174 | 0 | case CAIRO_CONTENT_COLOR: |
175 | 0 | return CAIRO_FORMAT_RGB24; |
176 | 0 | case CAIRO_CONTENT_ALPHA: |
177 | 0 | return CAIRO_FORMAT_A8; |
178 | 0 | case CAIRO_CONTENT_COLOR_ALPHA: |
179 | 0 | return CAIRO_FORMAT_ARGB32; |
180 | 0 | default: |
181 | 0 | gfxCriticalError() << "Unknown cairo content type " << (int)content; |
182 | 0 | return CAIRO_FORMAT_A8; // least likely to cause OOB reads |
183 | 0 | } |
184 | 0 | } Unexecuted instantiation: PrintTarget.cpp:mozilla::gfx::CairoContentToCairoFormat(_cairo_content) Unexecuted instantiation: gfxASurface.cpp:mozilla::gfx::CairoContentToCairoFormat(_cairo_content) Unexecuted instantiation: gfxFcPlatformFontList.cpp:mozilla::gfx::CairoContentToCairoFormat(_cairo_content) Unexecuted instantiation: gfxXlibNativeRenderer.cpp:mozilla::gfx::CairoContentToCairoFormat(_cairo_content) Unexecuted instantiation: Unified_cpp_gfx_thebes1.cpp:mozilla::gfx::CairoContentToCairoFormat(_cairo_content) Unexecuted instantiation: nsWindow.cpp:mozilla::gfx::CairoContentToCairoFormat(_cairo_content) Unexecuted instantiation: Unified_cpp_widget_gtk2.cpp:mozilla::gfx::CairoContentToCairoFormat(_cairo_content) |
185 | | |
186 | | static inline cairo_content_t |
187 | | GfxFormatToCairoContent(SurfaceFormat format) |
188 | 0 | { |
189 | 0 | switch (format) |
190 | 0 | { |
191 | 0 | case SurfaceFormat::A8R8G8B8_UINT32: |
192 | 0 | return CAIRO_CONTENT_COLOR_ALPHA; |
193 | 0 | case SurfaceFormat::X8R8G8B8_UINT32: |
194 | 0 | case SurfaceFormat::R5G6B5_UINT16: //fall through |
195 | 0 | return CAIRO_CONTENT_COLOR; |
196 | 0 | case SurfaceFormat::A8: |
197 | 0 | return CAIRO_CONTENT_ALPHA; |
198 | 0 | default: |
199 | 0 | gfxCriticalError() << "Unknown image content format " << (int)format; |
200 | 0 | return CAIRO_CONTENT_COLOR_ALPHA; |
201 | 0 | } |
202 | 0 | } Unexecuted instantiation: PrintTarget.cpp:mozilla::gfx::GfxFormatToCairoContent(mozilla::gfx::SurfaceFormat) Unexecuted instantiation: gfxASurface.cpp:mozilla::gfx::GfxFormatToCairoContent(mozilla::gfx::SurfaceFormat) Unexecuted instantiation: gfxFcPlatformFontList.cpp:mozilla::gfx::GfxFormatToCairoContent(mozilla::gfx::SurfaceFormat) Unexecuted instantiation: gfxXlibNativeRenderer.cpp:mozilla::gfx::GfxFormatToCairoContent(mozilla::gfx::SurfaceFormat) Unexecuted instantiation: Unified_cpp_gfx_thebes1.cpp:mozilla::gfx::GfxFormatToCairoContent(mozilla::gfx::SurfaceFormat) Unexecuted instantiation: nsWindow.cpp:mozilla::gfx::GfxFormatToCairoContent(mozilla::gfx::SurfaceFormat) Unexecuted instantiation: Unified_cpp_widget_gtk2.cpp:mozilla::gfx::GfxFormatToCairoContent(mozilla::gfx::SurfaceFormat) |
203 | | |
204 | | static inline cairo_line_join_t |
205 | | GfxLineJoinToCairoLineJoin(JoinStyle style) |
206 | 0 | { |
207 | 0 | switch (style) |
208 | 0 | { |
209 | 0 | case JoinStyle::BEVEL: |
210 | 0 | return CAIRO_LINE_JOIN_BEVEL; |
211 | 0 | case JoinStyle::ROUND: |
212 | 0 | return CAIRO_LINE_JOIN_ROUND; |
213 | 0 | case JoinStyle::MITER: |
214 | 0 | return CAIRO_LINE_JOIN_MITER; |
215 | 0 | case JoinStyle::MITER_OR_BEVEL: |
216 | 0 | return CAIRO_LINE_JOIN_MITER; |
217 | 0 | } |
218 | 0 |
|
219 | 0 | return CAIRO_LINE_JOIN_MITER; |
220 | 0 | } Unexecuted instantiation: PrintTarget.cpp:mozilla::gfx::GfxLineJoinToCairoLineJoin(mozilla::gfx::JoinStyle) Unexecuted instantiation: gfxASurface.cpp:mozilla::gfx::GfxLineJoinToCairoLineJoin(mozilla::gfx::JoinStyle) Unexecuted instantiation: gfxFcPlatformFontList.cpp:mozilla::gfx::GfxLineJoinToCairoLineJoin(mozilla::gfx::JoinStyle) Unexecuted instantiation: gfxXlibNativeRenderer.cpp:mozilla::gfx::GfxLineJoinToCairoLineJoin(mozilla::gfx::JoinStyle) Unexecuted instantiation: Unified_cpp_gfx_thebes1.cpp:mozilla::gfx::GfxLineJoinToCairoLineJoin(mozilla::gfx::JoinStyle) Unexecuted instantiation: nsWindow.cpp:mozilla::gfx::GfxLineJoinToCairoLineJoin(mozilla::gfx::JoinStyle) Unexecuted instantiation: Unified_cpp_widget_gtk2.cpp:mozilla::gfx::GfxLineJoinToCairoLineJoin(mozilla::gfx::JoinStyle) |
221 | | |
222 | | static inline cairo_line_cap_t |
223 | | GfxLineCapToCairoLineCap(CapStyle style) |
224 | 0 | { |
225 | 0 | switch (style) |
226 | 0 | { |
227 | 0 | case CapStyle::BUTT: |
228 | 0 | return CAIRO_LINE_CAP_BUTT; |
229 | 0 | case CapStyle::ROUND: |
230 | 0 | return CAIRO_LINE_CAP_ROUND; |
231 | 0 | case CapStyle::SQUARE: |
232 | 0 | return CAIRO_LINE_CAP_SQUARE; |
233 | 0 | } |
234 | 0 |
|
235 | 0 | return CAIRO_LINE_CAP_BUTT; |
236 | 0 | } Unexecuted instantiation: PrintTarget.cpp:mozilla::gfx::GfxLineCapToCairoLineCap(mozilla::gfx::CapStyle) Unexecuted instantiation: gfxASurface.cpp:mozilla::gfx::GfxLineCapToCairoLineCap(mozilla::gfx::CapStyle) Unexecuted instantiation: gfxFcPlatformFontList.cpp:mozilla::gfx::GfxLineCapToCairoLineCap(mozilla::gfx::CapStyle) Unexecuted instantiation: gfxXlibNativeRenderer.cpp:mozilla::gfx::GfxLineCapToCairoLineCap(mozilla::gfx::CapStyle) Unexecuted instantiation: Unified_cpp_gfx_thebes1.cpp:mozilla::gfx::GfxLineCapToCairoLineCap(mozilla::gfx::CapStyle) Unexecuted instantiation: nsWindow.cpp:mozilla::gfx::GfxLineCapToCairoLineCap(mozilla::gfx::CapStyle) Unexecuted instantiation: Unified_cpp_widget_gtk2.cpp:mozilla::gfx::GfxLineCapToCairoLineCap(mozilla::gfx::CapStyle) |
237 | | |
238 | | static inline SurfaceFormat |
239 | | CairoContentToGfxFormat(cairo_content_t content) |
240 | 0 | { |
241 | 0 | switch (content) |
242 | 0 | { |
243 | 0 | case CAIRO_CONTENT_COLOR_ALPHA: |
244 | 0 | return SurfaceFormat::A8R8G8B8_UINT32; |
245 | 0 | case CAIRO_CONTENT_COLOR: |
246 | 0 | // BEWARE! format may be 565 |
247 | 0 | return SurfaceFormat::X8R8G8B8_UINT32; |
248 | 0 | case CAIRO_CONTENT_ALPHA: |
249 | 0 | return SurfaceFormat::A8; |
250 | 0 | } |
251 | 0 |
|
252 | 0 | return SurfaceFormat::B8G8R8A8; |
253 | 0 | } Unexecuted instantiation: PrintTarget.cpp:mozilla::gfx::CairoContentToGfxFormat(_cairo_content) Unexecuted instantiation: gfxASurface.cpp:mozilla::gfx::CairoContentToGfxFormat(_cairo_content) Unexecuted instantiation: gfxFcPlatformFontList.cpp:mozilla::gfx::CairoContentToGfxFormat(_cairo_content) Unexecuted instantiation: gfxXlibNativeRenderer.cpp:mozilla::gfx::CairoContentToGfxFormat(_cairo_content) Unexecuted instantiation: Unified_cpp_gfx_thebes1.cpp:mozilla::gfx::CairoContentToGfxFormat(_cairo_content) Unexecuted instantiation: nsWindow.cpp:mozilla::gfx::CairoContentToGfxFormat(_cairo_content) Unexecuted instantiation: Unified_cpp_widget_gtk2.cpp:mozilla::gfx::CairoContentToGfxFormat(_cairo_content) |
254 | | |
255 | | static inline SurfaceFormat |
256 | | CairoFormatToGfxFormat(cairo_format_t format) |
257 | 0 | { |
258 | 0 | switch (format) { |
259 | 0 | case CAIRO_FORMAT_ARGB32: |
260 | 0 | return SurfaceFormat::A8R8G8B8_UINT32; |
261 | 0 | case CAIRO_FORMAT_RGB24: |
262 | 0 | return SurfaceFormat::X8R8G8B8_UINT32; |
263 | 0 | case CAIRO_FORMAT_A8: |
264 | 0 | return SurfaceFormat::A8; |
265 | 0 | case CAIRO_FORMAT_RGB16_565: |
266 | 0 | return SurfaceFormat::R5G6B5_UINT16; |
267 | 0 | default: |
268 | 0 | gfxCriticalError() << "Unknown cairo format " << format; |
269 | 0 | return SurfaceFormat::UNKNOWN; |
270 | 0 | } |
271 | 0 | } Unexecuted instantiation: PrintTarget.cpp:mozilla::gfx::CairoFormatToGfxFormat(_cairo_format) Unexecuted instantiation: gfxASurface.cpp:mozilla::gfx::CairoFormatToGfxFormat(_cairo_format) Unexecuted instantiation: gfxFcPlatformFontList.cpp:mozilla::gfx::CairoFormatToGfxFormat(_cairo_format) Unexecuted instantiation: gfxXlibNativeRenderer.cpp:mozilla::gfx::CairoFormatToGfxFormat(_cairo_format) Unexecuted instantiation: Unified_cpp_gfx_thebes1.cpp:mozilla::gfx::CairoFormatToGfxFormat(_cairo_format) Unexecuted instantiation: nsWindow.cpp:mozilla::gfx::CairoFormatToGfxFormat(_cairo_format) Unexecuted instantiation: Unified_cpp_widget_gtk2.cpp:mozilla::gfx::CairoFormatToGfxFormat(_cairo_format) |
272 | | |
273 | | static inline FontHinting |
274 | | CairoHintingToGfxHinting(cairo_hint_style_t aHintStyle) |
275 | 0 | { |
276 | 0 | switch (aHintStyle) { |
277 | 0 | case CAIRO_HINT_STYLE_NONE: |
278 | 0 | return FontHinting::NONE; |
279 | 0 | case CAIRO_HINT_STYLE_SLIGHT: |
280 | 0 | return FontHinting::LIGHT; |
281 | 0 | case CAIRO_HINT_STYLE_MEDIUM: |
282 | 0 | return FontHinting::NORMAL; |
283 | 0 | case CAIRO_HINT_STYLE_FULL: |
284 | 0 | return FontHinting::FULL; |
285 | 0 | default: |
286 | 0 | return FontHinting::NORMAL; |
287 | 0 | } |
288 | 0 | } Unexecuted instantiation: PrintTarget.cpp:mozilla::gfx::CairoHintingToGfxHinting(_cairo_hint_style) Unexecuted instantiation: gfxASurface.cpp:mozilla::gfx::CairoHintingToGfxHinting(_cairo_hint_style) Unexecuted instantiation: gfxFcPlatformFontList.cpp:mozilla::gfx::CairoHintingToGfxHinting(_cairo_hint_style) Unexecuted instantiation: gfxXlibNativeRenderer.cpp:mozilla::gfx::CairoHintingToGfxHinting(_cairo_hint_style) Unexecuted instantiation: Unified_cpp_gfx_thebes1.cpp:mozilla::gfx::CairoHintingToGfxHinting(_cairo_hint_style) Unexecuted instantiation: nsWindow.cpp:mozilla::gfx::CairoHintingToGfxHinting(_cairo_hint_style) Unexecuted instantiation: Unified_cpp_widget_gtk2.cpp:mozilla::gfx::CairoHintingToGfxHinting(_cairo_hint_style) |
289 | | |
290 | | SurfaceFormat GfxFormatForCairoSurface(cairo_surface_t* surface); |
291 | | |
292 | | static inline void |
293 | | GfxMatrixToCairoMatrix(const Matrix& mat, cairo_matrix_t& retval) |
294 | 0 | { |
295 | 0 | cairo_matrix_init(&retval, mat._11, mat._12, mat._21, mat._22, mat._31, mat._32); |
296 | 0 | } Unexecuted instantiation: PrintTarget.cpp:mozilla::gfx::GfxMatrixToCairoMatrix(mozilla::gfx::BaseMatrix<float> const&, _cairo_matrix&) Unexecuted instantiation: gfxASurface.cpp:mozilla::gfx::GfxMatrixToCairoMatrix(mozilla::gfx::BaseMatrix<float> const&, _cairo_matrix&) Unexecuted instantiation: gfxFcPlatformFontList.cpp:mozilla::gfx::GfxMatrixToCairoMatrix(mozilla::gfx::BaseMatrix<float> const&, _cairo_matrix&) Unexecuted instantiation: gfxXlibNativeRenderer.cpp:mozilla::gfx::GfxMatrixToCairoMatrix(mozilla::gfx::BaseMatrix<float> const&, _cairo_matrix&) Unexecuted instantiation: Unified_cpp_gfx_thebes1.cpp:mozilla::gfx::GfxMatrixToCairoMatrix(mozilla::gfx::BaseMatrix<float> const&, _cairo_matrix&) Unexecuted instantiation: nsWindow.cpp:mozilla::gfx::GfxMatrixToCairoMatrix(mozilla::gfx::BaseMatrix<float> const&, _cairo_matrix&) Unexecuted instantiation: Unified_cpp_widget_gtk2.cpp:mozilla::gfx::GfxMatrixToCairoMatrix(mozilla::gfx::BaseMatrix<float> const&, _cairo_matrix&) |
297 | | |
298 | | static inline void |
299 | | SetCairoStrokeOptions(cairo_t* aCtx, const StrokeOptions& aStrokeOptions) |
300 | 0 | { |
301 | 0 | cairo_set_line_width(aCtx, aStrokeOptions.mLineWidth); |
302 | 0 |
|
303 | 0 | cairo_set_miter_limit(aCtx, aStrokeOptions.mMiterLimit); |
304 | 0 |
|
305 | 0 | if (aStrokeOptions.mDashPattern) { |
306 | 0 | // Convert array of floats to array of doubles |
307 | 0 | std::vector<double> dashes(aStrokeOptions.mDashLength); |
308 | 0 | bool nonZero = false; |
309 | 0 | for (size_t i = 0; i < aStrokeOptions.mDashLength; ++i) { |
310 | 0 | if (aStrokeOptions.mDashPattern[i] != 0) { |
311 | 0 | nonZero = true; |
312 | 0 | } |
313 | 0 | dashes[i] = aStrokeOptions.mDashPattern[i]; |
314 | 0 | } |
315 | 0 | // Avoid all-zero patterns that would trigger the CAIRO_STATUS_INVALID_DASH context error state. |
316 | 0 | if (nonZero) { |
317 | 0 | cairo_set_dash(aCtx, &dashes[0], aStrokeOptions.mDashLength, |
318 | 0 | aStrokeOptions.mDashOffset); |
319 | 0 | } |
320 | 0 | } |
321 | 0 |
|
322 | 0 | cairo_set_line_join(aCtx, GfxLineJoinToCairoLineJoin(aStrokeOptions.mLineJoin)); |
323 | 0 |
|
324 | 0 | cairo_set_line_cap(aCtx, GfxLineCapToCairoLineCap(aStrokeOptions.mLineCap)); |
325 | 0 | } Unexecuted instantiation: PrintTarget.cpp:mozilla::gfx::SetCairoStrokeOptions(_cairo*, mozilla::gfx::StrokeOptions const&) Unexecuted instantiation: gfxASurface.cpp:mozilla::gfx::SetCairoStrokeOptions(_cairo*, mozilla::gfx::StrokeOptions const&) Unexecuted instantiation: gfxFcPlatformFontList.cpp:mozilla::gfx::SetCairoStrokeOptions(_cairo*, mozilla::gfx::StrokeOptions const&) Unexecuted instantiation: gfxXlibNativeRenderer.cpp:mozilla::gfx::SetCairoStrokeOptions(_cairo*, mozilla::gfx::StrokeOptions const&) Unexecuted instantiation: Unified_cpp_gfx_thebes1.cpp:mozilla::gfx::SetCairoStrokeOptions(_cairo*, mozilla::gfx::StrokeOptions const&) Unexecuted instantiation: nsWindow.cpp:mozilla::gfx::SetCairoStrokeOptions(_cairo*, mozilla::gfx::StrokeOptions const&) Unexecuted instantiation: Unified_cpp_widget_gtk2.cpp:mozilla::gfx::SetCairoStrokeOptions(_cairo*, mozilla::gfx::StrokeOptions const&) |
326 | | |
327 | | static inline cairo_fill_rule_t |
328 | | GfxFillRuleToCairoFillRule(FillRule rule) |
329 | 0 | { |
330 | 0 | switch (rule) |
331 | 0 | { |
332 | 0 | case FillRule::FILL_WINDING: |
333 | 0 | return CAIRO_FILL_RULE_WINDING; |
334 | 0 | case FillRule::FILL_EVEN_ODD: |
335 | 0 | return CAIRO_FILL_RULE_EVEN_ODD; |
336 | 0 | } |
337 | 0 |
|
338 | 0 | return CAIRO_FILL_RULE_WINDING; |
339 | 0 | } Unexecuted instantiation: PrintTarget.cpp:mozilla::gfx::GfxFillRuleToCairoFillRule(mozilla::gfx::FillRule) Unexecuted instantiation: gfxASurface.cpp:mozilla::gfx::GfxFillRuleToCairoFillRule(mozilla::gfx::FillRule) Unexecuted instantiation: gfxFcPlatformFontList.cpp:mozilla::gfx::GfxFillRuleToCairoFillRule(mozilla::gfx::FillRule) Unexecuted instantiation: gfxXlibNativeRenderer.cpp:mozilla::gfx::GfxFillRuleToCairoFillRule(mozilla::gfx::FillRule) Unexecuted instantiation: Unified_cpp_gfx_thebes1.cpp:mozilla::gfx::GfxFillRuleToCairoFillRule(mozilla::gfx::FillRule) Unexecuted instantiation: nsWindow.cpp:mozilla::gfx::GfxFillRuleToCairoFillRule(mozilla::gfx::FillRule) Unexecuted instantiation: Unified_cpp_widget_gtk2.cpp:mozilla::gfx::GfxFillRuleToCairoFillRule(mozilla::gfx::FillRule) |
340 | | |
341 | | // RAII class for temporarily changing the cairo matrix transform. It will use |
342 | | // the given matrix transform while it is in scope. When it goes out of scope |
343 | | // it will put the cairo context back the way it was. |
344 | | |
345 | | class CairoTempMatrix |
346 | | { |
347 | | public: |
348 | | CairoTempMatrix(cairo_t* aCtx, const Matrix& aMatrix) |
349 | | : mCtx(aCtx) |
350 | | { |
351 | | cairo_get_matrix(aCtx, &mSaveMatrix); |
352 | | cairo_matrix_t matrix; |
353 | | GfxMatrixToCairoMatrix(aMatrix, matrix); |
354 | | cairo_set_matrix(aCtx, &matrix); |
355 | | } |
356 | | |
357 | | ~CairoTempMatrix() |
358 | | { |
359 | | cairo_set_matrix(mCtx, &mSaveMatrix); |
360 | | } |
361 | | |
362 | | private: |
363 | | cairo_t* mCtx; |
364 | | cairo_matrix_t mSaveMatrix; |
365 | | }; |
366 | | |
367 | | } // namespace gfx |
368 | | } // namespace mozilla |
369 | | |
370 | | #endif /* MOZILLA_GFX_HELPERSCAIRO_H_ */ |