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

Side by Side Diff: tools/sk_tool_utils.cpp

Issue 1076593002: Start canonicalizing color for all A8 textblobs (Closed) Base URL: https://skia.googlesource.com/skia.git@atcachemasks
Patch Set: nits Created 5 years, 8 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
11 #include "SkBitmap.h" 11 #include "SkBitmap.h"
12 #include "SkCanvas.h" 12 #include "SkCanvas.h"
13 #include "SkShader.h" 13 #include "SkShader.h"
14 #include "SkTestScalerContext.h" 14 #include "SkTestScalerContext.h"
15 #include "SkTextBlob.h"
15 16
16 DEFINE_bool(portableFonts, false, "Use portable fonts"); 17 DEFINE_bool(portableFonts, false, "Use portable fonts");
17 DEFINE_bool(resourceFonts, false, "Use resource fonts"); 18 DEFINE_bool(resourceFonts, false, "Use resource fonts");
18 19
19 namespace sk_tool_utils { 20 namespace sk_tool_utils {
20 21
21 const char* colortype_name(SkColorType ct) { 22 const char* colortype_name(SkColorType ct) {
22 switch (ct) { 23 switch (ct) {
23 case kUnknown_SkColorType: return "Unknown"; 24 case kUnknown_SkColorType: return "Unknown";
24 case kAlpha_8_SkColorType: return "Alpha_8"; 25 case kAlpha_8_SkColorType: return "Alpha_8";
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 bm, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode); 71 bm, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
71 } 72 }
72 73
73 void draw_checkerboard(SkCanvas* canvas, SkColor c1, SkColor c2, int size) { 74 void draw_checkerboard(SkCanvas* canvas, SkColor c1, SkColor c2, int size) {
74 SkPaint paint; 75 SkPaint paint;
75 paint.setShader(create_checkerboard_shader(c1, c2, size))->unref(); 76 paint.setShader(create_checkerboard_shader(c1, c2, size))->unref();
76 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 77 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
77 canvas->drawPaint(paint); 78 canvas->drawPaint(paint);
78 } 79 }
79 80
81 void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const SkPain t& origPaint,
82 SkScalar x, SkScalar y) {
83 SkPaint paint(origPaint);
84 SkTDArray<uint16_t> glyphs;
85
86 size_t len = strlen(text);
87 glyphs.append(paint.textToGlyphs(text, len, NULL));
88 paint.textToGlyphs(text, len, glyphs.begin());
89
90 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
91 const SkTextBlobBuilder::RunBuffer& run = builder->allocRun(paint, glyphs.co unt(), x, y,
92 NULL);
93 memcpy(run.glyphs, glyphs.begin(), glyphs.count() * sizeof(uint16_t));
94 }
95
96
80 } // namespace sk_tool_utils 97 } // 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