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 #include "sk_tool_utils.h" | 8 #include "sk_tool_utils.h" |
9 #include "sk_tool_utils_flags.h" | 9 #include "sk_tool_utils_flags.h" |
10 | 10 |
11 #include "Resources.h" | 11 #include "Resources.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 const char* osName = platform_os_name(); | 68 const char* osName = platform_os_name(); |
69 if (!strcmp(osName, "Android") || !strcmp(osName, "Ubuntu")) { | 69 if (!strcmp(osName, "Android") || !strcmp(osName, "Ubuntu")) { |
70 return "CBDT"; | 70 return "CBDT"; |
71 } | 71 } |
72 if (!strncmp(osName, "Mac", 3)) { | 72 if (!strncmp(osName, "Mac", 3)) { |
73 return "SBIX"; | 73 return "SBIX"; |
74 } | 74 } |
75 return ""; | 75 return ""; |
76 } | 76 } |
77 | 77 |
78 void emoji_typeface(SkAutoTUnref<SkTypeface>* tf) { | 78 sk_sp<SkTypeface> emoji_typeface() { |
79 if (!strcmp(sk_tool_utils::platform_os_emoji(), "CBDT")) { | 79 if (!strcmp(sk_tool_utils::platform_os_emoji(), "CBDT")) { |
80 tf->reset(GetResourceAsTypeface("/fonts/Funkster.ttf")); | 80 return MakeResourceAsTypeface("/fonts/Funkster.ttf"); |
81 return; | |
82 } | 81 } |
83 if (!strcmp(sk_tool_utils::platform_os_emoji(), "SBIX")) { | 82 if (!strcmp(sk_tool_utils::platform_os_emoji(), "SBIX")) { |
84 tf->reset(SkTypeface::CreateFromName("Apple Color Emoji", SkTypeface::kN
ormal)); | 83 return SkTypeface::MakeFromName("Apple Color Emoji", SkTypeface::kNormal
); |
85 return; | |
86 } | 84 } |
87 tf->reset(nullptr); | 85 return nullptr; |
88 return; | |
89 } | 86 } |
90 | 87 |
91 const char* emoji_sample_text() { | 88 const char* emoji_sample_text() { |
92 if (!strcmp(sk_tool_utils::platform_os_emoji(), "CBDT")) { | 89 if (!strcmp(sk_tool_utils::platform_os_emoji(), "CBDT")) { |
93 return "Hamburgefons"; | 90 return "Hamburgefons"; |
94 } | 91 } |
95 if (!strcmp(sk_tool_utils::platform_os_emoji(), "SBIX")) { | 92 if (!strcmp(sk_tool_utils::platform_os_emoji(), "SBIX")) { |
96 return "\xF0\x9F\x92\xB0" "\xF0\x9F\x8F\xA1" "\xF0\x9F\x8E\x85" // 💰🏡🎅 | 93 return "\xF0\x9F\x92\xB0" "\xF0\x9F\x8F\xA1" "\xF0\x9F\x8E\x85" // 💰🏡🎅 |
97 "\xF0\x9F\x8D\xAA" "\xF0\x9F\x8D\x95" "\xF0\x9F\x9A\x80" // 🍪🍕🚀 | 94 "\xF0\x9F\x8D\xAA" "\xF0\x9F\x8D\x95" "\xF0\x9F\x9A\x80" // 🍪🍕🚀 |
98 "\xF0\x9F\x9A\xBB" "\xF0\x9F\x92\xA9" "\xF0\x9F\x93\xB7" // 🚻💩📷 | 95 "\xF0\x9F\x9A\xBB" "\xF0\x9F\x92\xA9" "\xF0\x9F\x93\xB7" // 🚻💩📷 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 return "unexpected colortype"; | 149 return "unexpected colortype"; |
153 } | 150 } |
154 } | 151 } |
155 | 152 |
156 SkColor color_to_565(SkColor color) { | 153 SkColor color_to_565(SkColor color) { |
157 SkPMColor pmColor = SkPreMultiplyColor(color); | 154 SkPMColor pmColor = SkPreMultiplyColor(color); |
158 U16CPU color16 = SkPixel32ToPixel16(pmColor); | 155 U16CPU color16 = SkPixel32ToPixel16(pmColor); |
159 return SkPixel16ToColor(color16); | 156 return SkPixel16ToColor(color16); |
160 } | 157 } |
161 | 158 |
162 SkTypeface* create_portable_typeface(const char* name, SkTypeface::Style style)
{ | 159 sk_sp<SkTypeface> create_portable_typeface(const char* name, SkTypeface::Style s
tyle) { |
163 return create_font(name, style); | 160 return create_font(name, style); |
164 } | 161 } |
165 | 162 |
166 void set_portable_typeface(SkPaint* paint, const char* name, SkTypeface::Style s
tyle) { | 163 void set_portable_typeface(SkPaint* paint, const char* name, SkTypeface::Style s
tyle) { |
167 SkTypeface* face = create_font(name, style); | 164 paint->setTypeface(create_font(name, style)); |
168 SkSafeUnref(paint->setTypeface(face)); | |
169 } | 165 } |
170 | 166 |
171 void write_pixels(SkCanvas* canvas, const SkBitmap& bitmap, int x, int y, | 167 void write_pixels(SkCanvas* canvas, const SkBitmap& bitmap, int x, int y, |
172 SkColorType colorType, SkAlphaType alphaType) { | 168 SkColorType colorType, SkAlphaType alphaType) { |
173 SkBitmap tmp(bitmap); | 169 SkBitmap tmp(bitmap); |
174 tmp.lockPixels(); | 170 tmp.lockPixels(); |
175 | 171 |
176 const SkImageInfo info = SkImageInfo::Make(tmp.width(), tmp.height(), colorT
ype, alphaType); | 172 const SkImageInfo info = SkImageInfo::Make(tmp.width(), tmp.height(), colorT
ype, alphaType); |
177 | 173 |
178 canvas->writePixels(info, tmp.getPixels(), tmp.rowBytes(), x, y); | 174 canvas->writePixels(info, tmp.getPixels(), tmp.rowBytes(), x, y); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 for (int y = 0; y < src.height(); ++y) { | 433 for (int y = 0; y < src.height(); ++y) { |
438 for (int x = 0; x < src.width(); ++x) { | 434 for (int x = 0; x < src.width(); ++x) { |
439 *dst.getAddr32(x, y) = blur_pixel(src, x, y, kernel.get(), wh); | 435 *dst.getAddr32(x, y) = blur_pixel(src, x, y, kernel.get(), wh); |
440 } | 436 } |
441 } | 437 } |
442 | 438 |
443 return dst; | 439 return dst; |
444 } | 440 } |
445 | 441 |
446 } // namespace sk_tool_utils | 442 } // namespace sk_tool_utils |
OLD | NEW |