Bug 1862332 [wpt PR 42877] - WebKit export of https://bugs.webkit.org/show_bug.cgi...
[gecko.git] / gfx / harfbuzz / src / hb-cairo-utils.hh
bloba26bf59d918959ca8956c99c22eeb2f3f6d66ec2
1 /*
2 * Copyright © 2022 Red Hat, Inc
4 * This is part of HarfBuzz, a text shaping library.
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16 * DAMAGE.
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24 * Google Author(s): Matthias Clasen
27 #ifndef HB_CAIRO_UTILS_H
28 #define HB_CAIRO_UTILS_H
30 #include "hb.hh"
31 #include "hb-cairo.h"
34 typedef struct
36 cairo_scaled_font_t *scaled_font;
37 cairo_t *cr;
38 hb_map_t *color_cache;
39 } hb_cairo_context_t;
41 static inline cairo_operator_t
42 _hb_paint_composite_mode_to_cairo (hb_paint_composite_mode_t mode)
44 switch (mode)
46 case HB_PAINT_COMPOSITE_MODE_CLEAR: return CAIRO_OPERATOR_CLEAR;
47 case HB_PAINT_COMPOSITE_MODE_SRC: return CAIRO_OPERATOR_SOURCE;
48 case HB_PAINT_COMPOSITE_MODE_DEST: return CAIRO_OPERATOR_DEST;
49 case HB_PAINT_COMPOSITE_MODE_SRC_OVER: return CAIRO_OPERATOR_OVER;
50 case HB_PAINT_COMPOSITE_MODE_DEST_OVER: return CAIRO_OPERATOR_DEST_OVER;
51 case HB_PAINT_COMPOSITE_MODE_SRC_IN: return CAIRO_OPERATOR_IN;
52 case HB_PAINT_COMPOSITE_MODE_DEST_IN: return CAIRO_OPERATOR_DEST_IN;
53 case HB_PAINT_COMPOSITE_MODE_SRC_OUT: return CAIRO_OPERATOR_OUT;
54 case HB_PAINT_COMPOSITE_MODE_DEST_OUT: return CAIRO_OPERATOR_DEST_OUT;
55 case HB_PAINT_COMPOSITE_MODE_SRC_ATOP: return CAIRO_OPERATOR_ATOP;
56 case HB_PAINT_COMPOSITE_MODE_DEST_ATOP: return CAIRO_OPERATOR_DEST_ATOP;
57 case HB_PAINT_COMPOSITE_MODE_XOR: return CAIRO_OPERATOR_XOR;
58 case HB_PAINT_COMPOSITE_MODE_PLUS: return CAIRO_OPERATOR_ADD;
59 case HB_PAINT_COMPOSITE_MODE_SCREEN: return CAIRO_OPERATOR_SCREEN;
60 case HB_PAINT_COMPOSITE_MODE_OVERLAY: return CAIRO_OPERATOR_OVERLAY;
61 case HB_PAINT_COMPOSITE_MODE_DARKEN: return CAIRO_OPERATOR_DARKEN;
62 case HB_PAINT_COMPOSITE_MODE_LIGHTEN: return CAIRO_OPERATOR_LIGHTEN;
63 case HB_PAINT_COMPOSITE_MODE_COLOR_DODGE: return CAIRO_OPERATOR_COLOR_DODGE;
64 case HB_PAINT_COMPOSITE_MODE_COLOR_BURN: return CAIRO_OPERATOR_COLOR_BURN;
65 case HB_PAINT_COMPOSITE_MODE_HARD_LIGHT: return CAIRO_OPERATOR_HARD_LIGHT;
66 case HB_PAINT_COMPOSITE_MODE_SOFT_LIGHT: return CAIRO_OPERATOR_SOFT_LIGHT;
67 case HB_PAINT_COMPOSITE_MODE_DIFFERENCE: return CAIRO_OPERATOR_DIFFERENCE;
68 case HB_PAINT_COMPOSITE_MODE_EXCLUSION: return CAIRO_OPERATOR_EXCLUSION;
69 case HB_PAINT_COMPOSITE_MODE_MULTIPLY: return CAIRO_OPERATOR_MULTIPLY;
70 case HB_PAINT_COMPOSITE_MODE_HSL_HUE: return CAIRO_OPERATOR_HSL_HUE;
71 case HB_PAINT_COMPOSITE_MODE_HSL_SATURATION: return CAIRO_OPERATOR_HSL_SATURATION;
72 case HB_PAINT_COMPOSITE_MODE_HSL_COLOR: return CAIRO_OPERATOR_HSL_COLOR;
73 case HB_PAINT_COMPOSITE_MODE_HSL_LUMINOSITY: return CAIRO_OPERATOR_HSL_LUMINOSITY;
74 default: return CAIRO_OPERATOR_CLEAR;
78 HB_INTERNAL hb_bool_t
79 _hb_cairo_paint_glyph_image (hb_cairo_context_t *c,
80 hb_blob_t *blob,
81 unsigned width,
82 unsigned height,
83 hb_tag_t format,
84 float slant,
85 hb_glyph_extents_t *extents);
87 HB_INTERNAL void
88 _hb_cairo_paint_linear_gradient (hb_cairo_context_t *c,
89 hb_color_line_t *color_line,
90 float x0, float y0,
91 float x1, float y1,
92 float x2, float y2);
94 HB_INTERNAL void
95 _hb_cairo_paint_radial_gradient (hb_cairo_context_t *c,
96 hb_color_line_t *color_line,
97 float x0, float y0, float r0,
98 float x1, float y1, float r1);
100 HB_INTERNAL void
101 _hb_cairo_paint_sweep_gradient (hb_cairo_context_t *c,
102 hb_color_line_t *color_line,
103 float x0, float y0,
104 float start_angle, float end_angle);
107 #endif /* HB_CAIRO_UTILS_H */