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

Side by Side Diff: tools/sk_tool_utils.cpp

Issue 1182833004: make emptypath portable; add 565 color utility (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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') | 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 16 matching lines...) Expand all
27 case kARGB_4444_SkColorType: return "ARGB_4444"; 27 case kARGB_4444_SkColorType: return "ARGB_4444";
28 case kRGB_565_SkColorType: return "RGB_565"; 28 case kRGB_565_SkColorType: return "RGB_565";
29 case kRGBA_8888_SkColorType: return "RGBA_8888"; 29 case kRGBA_8888_SkColorType: return "RGBA_8888";
30 case kBGRA_8888_SkColorType: return "BGRA_8888"; 30 case kBGRA_8888_SkColorType: return "BGRA_8888";
31 default: 31 default:
32 SkASSERT(false); 32 SkASSERT(false);
33 return "unexpected colortype"; 33 return "unexpected colortype";
34 } 34 }
35 } 35 }
36 36
37 void color_to_565(SkColor* color) {
38 SkPMColor pmColor = SkPreMultiplyColor(*color);
39 U16CPU color16 = SkPixel32ToPixel16(pmColor);
40 *color = SkPixel16ToColor(color16);
41 }
42
37 SkTypeface* create_portable_typeface(const char* name, SkTypeface::Style style) { 43 SkTypeface* create_portable_typeface(const char* name, SkTypeface::Style style) {
38 SkTypeface* face; 44 SkTypeface* face;
39 if (FLAGS_portableFonts) { 45 if (FLAGS_portableFonts) {
40 face = create_font(name, style); 46 face = create_font(name, style);
41 } else if (FLAGS_resourceFonts) { 47 } else if (FLAGS_resourceFonts) {
42 face = resource_font(name, style); 48 face = resource_font(name, style);
43 } else { 49 } else {
44 face = SkTypeface::CreateFromName(name, style); 50 face = SkTypeface::CreateFromName(name, style);
45 } 51 }
46 return face; 52 return face;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 paint.textToGlyphs(text, len, glyphs.begin()); 103 paint.textToGlyphs(text, len, glyphs.begin());
98 104
99 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 105 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
100 const SkTextBlobBuilder::RunBuffer& run = builder->allocRun(paint, glyphs.co unt(), x, y, 106 const SkTextBlobBuilder::RunBuffer& run = builder->allocRun(paint, glyphs.co unt(), x, y,
101 NULL); 107 NULL);
102 memcpy(run.glyphs, glyphs.begin(), glyphs.count() * sizeof(uint16_t)); 108 memcpy(run.glyphs, glyphs.begin(), glyphs.count() * sizeof(uint16_t));
103 } 109 }
104 110
105 111
106 } // namespace sk_tool_utils 112 } // 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