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

Side by Side Diff: tools/sk_tool_utils.cpp

Issue 348323003: use platform-independent font for gm (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add include tools for skimage Created 6 years, 6 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') | tools/sk_tool_utils_font.cpp » ('j') | 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 "../src/fonts/SkTestScalerContext.h"
9 10
10 #include "SkBitmap.h" 11 #include "SkBitmap.h"
11 #include "SkCanvas.h" 12 #include "SkCanvas.h"
12 13
13 namespace sk_tool_utils { 14 namespace sk_tool_utils {
14 15
16 bool gEnablePortableTypeface = false;
17
15 const char* colortype_name(SkColorType ct) { 18 const char* colortype_name(SkColorType ct) {
16 switch (ct) { 19 switch (ct) {
17 case kUnknown_SkColorType: return "Unknown"; 20 case kUnknown_SkColorType: return "Unknown";
18 case kAlpha_8_SkColorType: return "Alpha_8"; 21 case kAlpha_8_SkColorType: return "Alpha_8";
19 case kIndex_8_SkColorType: return "Index_8"; 22 case kIndex_8_SkColorType: return "Index_8";
20 case kARGB_4444_SkColorType: return "ARGB_4444"; 23 case kARGB_4444_SkColorType: return "ARGB_4444";
21 case kRGB_565_SkColorType: return "RGB_565"; 24 case kRGB_565_SkColorType: return "RGB_565";
22 case kRGBA_8888_SkColorType: return "RGBA_8888"; 25 case kRGBA_8888_SkColorType: return "RGBA_8888";
23 case kBGRA_8888_SkColorType: return "BGRA_8888"; 26 case kBGRA_8888_SkColorType: return "BGRA_8888";
24 default: 27 default:
25 SkASSERT(false); 28 SkASSERT(false);
26 return "unexpected colortype"; 29 return "unexpected colortype";
27 } 30 }
28 } 31 }
29 32
33 SkPaint::FontMetrics create_font(SkTDArray<SkPath*>& , SkTDArray<SkFixed>& );
34
35 void set_portable_typeface(SkPaint* paint, SkTypeface::Style style) {
36 if (gEnablePortableTypeface) {
37 SkSafeUnref(paint->setTypeface(CreateTestTypeface(create_font, style)));
38 }
39 }
40
30 void write_pixels(SkCanvas* canvas, const SkBitmap& bitmap, int x, int y, 41 void write_pixels(SkCanvas* canvas, const SkBitmap& bitmap, int x, int y,
31 SkColorType colorType, SkAlphaType alphaType) { 42 SkColorType colorType, SkAlphaType alphaType) {
32 SkBitmap tmp(bitmap); 43 SkBitmap tmp(bitmap);
33 tmp.lockPixels(); 44 tmp.lockPixels();
34 45
35 SkImageInfo info = tmp.info(); 46 SkImageInfo info = tmp.info();
36 info.fColorType = colorType; 47 info.fColorType = colorType;
37 info.fAlphaType = alphaType; 48 info.fAlphaType = alphaType;
38 49
39 canvas->writePixels(info, tmp.getPixels(), tmp.rowBytes(), x, y); 50 canvas->writePixels(info, tmp.getPixels(), tmp.rowBytes(), x, y);
40 } 51 }
41 52
42 } // namespace sk_tool_utils 53 } // namespace sk_tool_utils
OLDNEW
« no previous file with comments | « tools/sk_tool_utils.h ('k') | tools/sk_tool_utils_font.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698