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

Side by Side Diff: tools/sk_tool_utils.cpp

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

Powered by Google App Engine
This is Rietveld 408576698