| 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 16 matching lines...) Expand all Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |