OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef sk_tool_utils_DEFINED | 8 #ifndef sk_tool_utils_DEFINED |
9 #define sk_tool_utils_DEFINED | 9 #define sk_tool_utils_DEFINED |
10 | 10 |
11 #include "SkColor.h" | 11 #include "SkColor.h" |
12 #include "SkImageEncoder.h" | 12 #include "SkImageEncoder.h" |
13 #include "SkImageInfo.h" | 13 #include "SkImageInfo.h" |
14 #include "SkPixelSerializer.h" | 14 #include "SkPixelSerializer.h" |
15 #include "SkTypeface.h" | 15 #include "SkTypeface.h" |
16 | 16 |
17 class SkBitmap; | 17 class SkBitmap; |
18 class SkCanvas; | 18 class SkCanvas; |
19 class SkPaint; | 19 class SkPaint; |
20 class SkShader; | 20 class SkShader; |
21 class SkTestFont; | 21 class SkTestFont; |
22 class SkTextBlobBuilder; | 22 class SkTextBlobBuilder; |
23 | 23 |
24 namespace sk_tool_utils { | 24 namespace sk_tool_utils { |
25 | 25 |
26 const char* colortype_name(SkColorType); | 26 const char* colortype_name(SkColorType); |
| 27 |
| 28 /** |
| 29 * Map opaque colors from 8888 to 565. |
| 30 */ |
27 SkColor color_to_565(SkColor color); | 31 SkColor color_to_565(SkColor color); |
| 32 |
| 33 /** |
| 34 * Return a color emoji typeface if available. |
| 35 */ |
28 void emoji_typeface(SkAutoTUnref<SkTypeface>* ); | 36 void emoji_typeface(SkAutoTUnref<SkTypeface>* ); |
| 37 |
| 38 /** |
| 39 * If the platform supports color emoji, return sample text the emoji can re
nder. |
| 40 */ |
29 const char* emoji_sample_text(); | 41 const char* emoji_sample_text(); |
| 42 |
| 43 /** |
| 44 * If the platform supports color emoji, return the type (i.e. "CBDT", "SBIX
", ""). |
| 45 */ |
30 const char* platform_os_emoji(); | 46 const char* platform_os_emoji(); |
| 47 |
| 48 /** |
| 49 * Return the platform name with the version number ("Mac10.9", "Win8", etc.
) if available. |
| 50 */ |
31 const char* platform_os_name(); | 51 const char* platform_os_name(); |
| 52 |
| 53 /** |
| 54 * Return the platform name without the version number ("Mac", "Win", etc.)
if available. |
| 55 */ |
| 56 SkString major_platform_os_name(); |
| 57 |
| 58 /** |
| 59 * Return the platform extra config (e.g. "GDI") if available. |
| 60 */ |
32 const char* platform_extra_config(const char* config); | 61 const char* platform_extra_config(const char* config); |
33 | 62 |
34 /** | 63 /** |
| 64 * Map serif, san-serif, and monospace to the platform-specific font name. |
| 65 */ |
| 66 const char* platform_font_name(const char* name); |
| 67 |
| 68 /** |
35 * Sets the paint to use a platform-independent text renderer if FLAGS_porta
bleFonts is set. | 69 * Sets the paint to use a platform-independent text renderer if FLAGS_porta
bleFonts is set. |
36 * FIXME: will become obsolete as GMs migrate to set portable typeface alway
s. | 70 * FIXME: will become obsolete as GMs migrate to set portable typeface alway
s. |
37 */ | 71 */ |
38 void set_portable_typeface(SkPaint* paint, const char* name = NULL, | 72 void set_portable_typeface(SkPaint* paint, const char* name = NULL, |
39 SkTypeface::Style style = SkTypeface::kNormal); | 73 SkTypeface::Style style = SkTypeface::kNormal); |
| 74 |
| 75 /** |
| 76 * Sets the paint to use a platform-independent text renderer |
| 77 */ |
40 void set_portable_typeface_always(SkPaint* paint, const char* name = NULL, | 78 void set_portable_typeface_always(SkPaint* paint, const char* name = NULL, |
41 SkTypeface::Style style = SkTypeface::kNormal); | 79 SkTypeface::Style style = SkTypeface::kNormal); |
| 80 |
| 81 /** |
| 82 * Returns a platform-independent text renderer if FLAGS_portableFonts is se
t. |
| 83 * FIXME: will become obsolete as GMs migrate to set portable typeface alway
s. |
| 84 */ |
42 SkTypeface* create_portable_typeface(const char* name, SkTypeface::Style sty
le); | 85 SkTypeface* create_portable_typeface(const char* name, SkTypeface::Style sty
le); |
| 86 |
| 87 /** |
| 88 * Returns a platform-independent text renderer. |
| 89 */ |
43 SkTypeface* create_portable_typeface_always(const char* name, SkTypeface::St
yle style); | 90 SkTypeface* create_portable_typeface_always(const char* name, SkTypeface::St
yle style); |
| 91 |
44 /** Call to clean up portable font references. */ | 92 /** Call to clean up portable font references. */ |
45 void release_portable_typefaces(); | 93 void release_portable_typefaces(); |
46 void report_used_chars(); | |
47 | 94 |
48 /** | 95 /** |
49 * Call canvas->writePixels() by using the pixels from bitmap, but with an
info that claims | 96 * Call canvas->writePixels() by using the pixels from bitmap, but with an
info that claims |
50 * the pixels are colorType + alphaType | 97 * the pixels are colorType + alphaType |
51 */ | 98 */ |
52 void write_pixels(SkCanvas*, const SkBitmap&, int x, int y, SkColorType, SkA
lphaType); | 99 void write_pixels(SkCanvas*, const SkBitmap&, int x, int y, SkColorType, SkA
lphaType); |
53 | 100 |
54 // private to sk_tool_utils | 101 // private to sk_tool_utils |
55 SkTypeface* create_font(const char* name, SkTypeface::Style ); | 102 SkTypeface* create_font(const char* name, SkTypeface::Style ); |
56 SkTypeface* resource_font(const char* name, SkTypeface::Style ); | |
57 | 103 |
58 /** Returns a newly created CheckerboardShader. */ | 104 /** Returns a newly created CheckerboardShader. */ |
59 SkShader* create_checkerboard_shader(SkColor c1, SkColor c2, int size); | 105 SkShader* create_checkerboard_shader(SkColor c1, SkColor c2, int size); |
60 | 106 |
61 /** Draw a checkerboard pattern in the current canvas, restricted to | 107 /** Draw a checkerboard pattern in the current canvas, restricted to |
62 the current clip, using SkXfermode::kSrc_Mode. */ | 108 the current clip, using SkXfermode::kSrc_Mode. */ |
63 void draw_checkerboard(SkCanvas* canvas, | 109 void draw_checkerboard(SkCanvas* canvas, |
64 SkColor color1, | 110 SkColor color1, |
65 SkColor color2, | 111 SkColor color2, |
66 int size); | 112 int size); |
(...skipping 15 matching lines...) Expand all Loading... |
82 } | 128 } |
83 }; | 129 }; |
84 | 130 |
85 // A helper for inserting a drawtext call into a SkTextBlobBuilder | 131 // A helper for inserting a drawtext call into a SkTextBlobBuilder |
86 void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const Sk
Paint& origPaint, | 132 void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const Sk
Paint& origPaint, |
87 SkScalar x, SkScalar y); | 133 SkScalar x, SkScalar y); |
88 | 134 |
89 } // namespace sk_tool_utils | 135 } // namespace sk_tool_utils |
90 | 136 |
91 #endif // sk_tool_utils_DEFINED | 137 #endif // sk_tool_utils_DEFINED |
OLD | NEW |