Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(436)

Side by Side Diff: tools/sk_tool_utils.cpp

Issue 1248703004: make color emoji gm portable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more 565 color fixes Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/sk_tool_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkBitmap.h" 12 #include "SkBitmap.h"
12 #include "SkCanvas.h" 13 #include "SkCanvas.h"
13 #include "SkCommonFlags.h" 14 #include "SkCommonFlags.h"
14 #include "SkShader.h" 15 #include "SkShader.h"
15 #include "SkTestScalerContext.h" 16 #include "SkTestScalerContext.h"
16 #include "SkTextBlob.h" 17 #include "SkTextBlob.h"
17 18
18 DEFINE_bool(portableFonts, false, "Use portable fonts"); 19 DEFINE_bool(portableFonts, false, "Use portable fonts");
19 DEFINE_bool(resourceFonts, false, "Use resource fonts"); 20 DEFINE_bool(resourceFonts, false, "Use resource fonts");
20 21
21 namespace sk_tool_utils { 22 namespace sk_tool_utils {
22 23
24 const char* platform_os_emoji() {
25 const char* osName = platform_os_name();
26 if (!strcmp(osName, "Android") || !strcmp(osName, "Unbuntu")) {
27 return "CBDT";
28 }
29 if (!strncmp(osName, "Mac", 3)) {
30 return "SBIX";
31 }
32 return "";
33 }
34
35 SkTypeface* emoji_typeface() {
36 if (!strcmp(sk_tool_utils::platform_os_emoji(), "CBDT")) {
37 return GetResourceAsTypeface("/fonts/Funkster.ttf");
38 }
39 if (!strcmp(sk_tool_utils::platform_os_emoji(), "SBIX")) {
40 return SkTypeface::CreateFromName("Apple Color Emoji", SkTypeface::kNorm al);
41 }
42 return NULL;
43 }
44
45 const char* emoji_sample_text() {
46 if (!strcmp(sk_tool_utils::platform_os_emoji(), "CBDT")) {
47 return "Hamburgefons";
48 }
49 if (!strcmp(sk_tool_utils::platform_os_emoji(), "SBIX")) {
50 return "\xF0\x9F\x92\xB0" "\xF0\x9F\x8F\xA1" "\xF0\x9F\x8E\x85" // πŸ’°πŸ‘πŸŽ…
51 "\xF0\x9F\x8D\xAA" "\xF0\x9F\x8D\x95" "\xF0\x9F\x9A\x80" // πŸͺπŸ•πŸš€
52 "\xF0\x9F\x9A\xBB" "\xF0\x9F\x92\xA9" "\xF0\x9F\x93\xB7" // πŸš»πŸ’©πŸ“·
53 "\xF0\x9F\x93\xA6" // πŸ“¦
54 "\xF0\x9F\x87\xBA" "\xF0\x9F\x87\xB8" "\xF0\x9F\x87\xA6"; // πŸ‡ΊπŸ‡ΈπŸ‡¦
55 }
56 return "";
57 }
58
23 const char* platform_os_name() { 59 const char* platform_os_name() {
24 for (int index = 0; index < FLAGS_key.count(); index += 2) { 60 for (int index = 0; index < FLAGS_key.count(); index += 2) {
25 if (!strcmp("os", FLAGS_key[index])) { 61 if (!strcmp("os", FLAGS_key[index])) {
26 return FLAGS_key[index + 1]; 62 return FLAGS_key[index + 1];
27 } 63 }
28 } 64 }
29 // when running SampleApp or dm without a --key pair, omit the platform name 65 // when running SampleApp or dm without a --key pair, omit the platform name
30 return ""; 66 return "";
31 } 67 }
32 68
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 paint.textToGlyphs(text, len, glyphs.begin()); 159 paint.textToGlyphs(text, len, glyphs.begin());
124 160
125 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 161 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
126 const SkTextBlobBuilder::RunBuffer& run = builder->allocRun(paint, glyphs.co unt(), x, y, 162 const SkTextBlobBuilder::RunBuffer& run = builder->allocRun(paint, glyphs.co unt(), x, y,
127 NULL); 163 NULL);
128 memcpy(run.glyphs, glyphs.begin(), glyphs.count() * sizeof(uint16_t)); 164 memcpy(run.glyphs, glyphs.begin(), glyphs.count() * sizeof(uint16_t));
129 } 165 }
130 166
131 167
132 } // namespace sk_tool_utils 168 } // namespace sk_tool_utils
OLDNEW
« no previous file with comments | « tools/sk_tool_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698