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

Side by Side Diff: tools/sk_tool_utils.cpp

Issue 1512333002: SkPixelSerializer: remove deprecated virtual (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
225 void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const SkPain t& origPaint, 238 void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const SkPain t& origPaint,
226 SkScalar x, SkScalar y) { 239 SkScalar x, SkScalar y) {
227 SkPaint paint(origPaint); 240 SkPaint paint(origPaint);
228 SkTDArray<uint16_t> glyphs; 241 SkTDArray<uint16_t> glyphs;
229 242
230 size_t len = strlen(text); 243 size_t len = strlen(text);
231 glyphs.append(paint.textToGlyphs(text, len, nullptr)); 244 glyphs.append(paint.textToGlyphs(text, len, nullptr));
232 paint.textToGlyphs(text, len, glyphs.begin()); 245 paint.textToGlyphs(text, len, glyphs.begin());
233 246
234 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 247 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 for (int y = 0; y < src.height(); ++y) { 450 for (int y = 0; y < src.height(); ++y) {
438 for (int x = 0; x < src.width(); ++x) { 451 for (int x = 0; x < src.width(); ++x) {
439 *dst.getAddr32(x, y) = blur_pixel(src, x, y, kernel.get(), wh); 452 *dst.getAddr32(x, y) = blur_pixel(src, x, y, kernel.get(), wh);
440 } 453 }
441 } 454 }
442 455
443 return dst; 456 return dst;
444 } 457 }
445 458
446 } // namespace sk_tool_utils 459 } // 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