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 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 sk_tool_utils::set_portable_typeface(&paint); | 215 sk_tool_utils::set_portable_typeface(&paint); |
216 paint.setColor(c); | 216 paint.setColor(c); |
217 paint.setTextSize(SkIntToScalar(textSize)); | 217 paint.setTextSize(SkIntToScalar(textSize)); |
218 | 218 |
219 canvas.clear(0x00000000); | 219 canvas.clear(0x00000000); |
220 canvas.drawText(str, strlen(str), SkIntToScalar(x), SkIntToScalar(y), paint)
; | 220 canvas.drawText(str, strlen(str), SkIntToScalar(x), SkIntToScalar(y), paint)
; |
221 | 221 |
222 return bitmap; | 222 return bitmap; |
223 } | 223 } |
224 | 224 |
225 bool PngPixelSerializer::onUseEncodedData(const void*, size_t) { return true; } | |
226 SkData* PngPixelSerializer::onEncode(const SkPixmap& pixmap) { | |
227 SkBitmap bm; | |
228 if (!bm.installPixels(pixmap.info(), | |
229 const_cast<void*>(pixmap.addr()), | |
230 pixmap.rowBytes(), | |
231 pixmap.ctable(), | |
232 nullptr, nullptr)) { | |
233 return nullptr; | |
234 } | |
235 return SkImageEncoder::EncodeData(bm, SkImageEncoder::kPNG_Type, 100); | |
236 } | |
237 | |
238 void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const SkPain
t& origPaint, | 225 void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const SkPain
t& origPaint, |
239 SkScalar x, SkScalar y) { | 226 SkScalar x, SkScalar y) { |
240 SkPaint paint(origPaint); | 227 SkPaint paint(origPaint); |
241 SkTDArray<uint16_t> glyphs; | 228 SkTDArray<uint16_t> glyphs; |
242 | 229 |
243 size_t len = strlen(text); | 230 size_t len = strlen(text); |
244 glyphs.append(paint.textToGlyphs(text, len, nullptr)); | 231 glyphs.append(paint.textToGlyphs(text, len, nullptr)); |
245 paint.textToGlyphs(text, len, glyphs.begin()); | 232 paint.textToGlyphs(text, len, glyphs.begin()); |
246 | 233 |
247 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 234 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 for (int y = 0; y < src.height(); ++y) { | 437 for (int y = 0; y < src.height(); ++y) { |
451 for (int x = 0; x < src.width(); ++x) { | 438 for (int x = 0; x < src.width(); ++x) { |
452 *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); |
453 } | 440 } |
454 } | 441 } |
455 | 442 |
456 return dst; | 443 return dst; |
457 } | 444 } |
458 | 445 |
459 } // namespace sk_tool_utils | 446 } // namespace sk_tool_utils |
OLD | NEW |