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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/sk_tool_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/sk_tool_utils.cpp
diff --git a/tools/sk_tool_utils.cpp b/tools/sk_tool_utils.cpp
index c3e574a08e3f63b7adede0ce1f6cf4e3112c9179..1a88086a41eaa42ffb6b1540f27162ab2e52e034 100644
--- a/tools/sk_tool_utils.cpp
+++ b/tools/sk_tool_utils.cpp
@@ -12,6 +12,7 @@
#include "SkCanvas.h"
#include "SkShader.h"
#include "SkTestScalerContext.h"
+#include "SkTextBlob.h"
DEFINE_bool(portableFonts, false, "Use portable fonts");
DEFINE_bool(resourceFonts, false, "Use resource fonts");
@@ -77,4 +78,20 @@ void draw_checkerboard(SkCanvas* canvas, SkColor c1, SkColor c2, int size) {
canvas->drawPaint(paint);
}
+void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const SkPaint& origPaint,
+ SkScalar x, SkScalar y) {
+ SkPaint paint(origPaint);
+ SkTDArray<uint16_t> glyphs;
+
+ size_t len = strlen(text);
+ glyphs.append(paint.textToGlyphs(text, len, NULL));
+ paint.textToGlyphs(text, len, glyphs.begin());
+
+ paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
+ const SkTextBlobBuilder::RunBuffer& run = builder->allocRun(paint, glyphs.count(), x, y,
+ NULL);
+ memcpy(run.glyphs, glyphs.begin(), glyphs.count() * sizeof(uint16_t));
+}
+
+
} // namespace sk_tool_utils
« 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