aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/textblobrandomfont.cpp
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-08-01 09:36:02 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-01 09:36:02 -0700
commita4a530614e9ba856aac3f16c29683e6a2a9153d9 (patch)
tree28b0df6a2121e76c29fffa02d7dcb51fc44464c6 /gm/textblobrandomfont.cpp
parent44c4851c91ac1779dfa5336defe05c251971cd45 (diff)
Add BW masks to random scaler context
TBR=bsalomon@google.com BUG=skia: Review URL: https://codereview.chromium.org/1270793003
Diffstat (limited to 'gm/textblobrandomfont.cpp')
-rw-r--r--gm/textblobrandomfont.cpp36
1 files changed, 28 insertions, 8 deletions
diff --git a/gm/textblobrandomfont.cpp b/gm/textblobrandomfont.cpp
index f7d3b5cb1c..5c90ae1ed2 100644
--- a/gm/textblobrandomfont.cpp
+++ b/gm/textblobrandomfont.cpp
@@ -49,14 +49,34 @@ protected:
SkRect bounds;
paint.measureText(text, strlen(text), &bounds);
-
- SkScalar yOffset = bounds.height();
sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, 0);
// A8
+ const char* bigtext1 = "The quick brown fox";
+ const char* bigtext2 = "jumps over the lazy dog.";
+ paint.setTextSize(160);
paint.setSubpixelText(false);
paint.setLCDRenderText(false);
- sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, yOffset - 32);
+ paint.measureText(bigtext1, strlen(bigtext1), &bounds);
+ SkScalar offset = bounds.height();
+ sk_tool_utils::add_to_text_blob(&builder, bigtext1, paint, 0, offset);
+
+ paint.measureText(bigtext2, strlen(bigtext2), &bounds);
+ offset += bounds.height();
+ sk_tool_utils::add_to_text_blob(&builder, bigtext2, paint, 0, offset);
+
+ // color emoji
+ SkAutoTUnref<SkTypeface> origEmoji;
+ sk_tool_utils::emoji_typeface(&origEmoji);
+ if (origEmoji) {
+ const char* emojiText = sk_tool_utils::emoji_sample_text();
+ paint.measureText(emojiText, strlen(emojiText), &bounds);
+ offset += bounds.height();
+ SkAutoTUnref<SkTypeface> randomEmoji(SkNEW_ARGS(SkRandomTypeface, (orig, paint,
+ false)));
+ paint.setTypeface(randomEmoji);
+ sk_tool_utils::add_to_text_blob(&builder, emojiText, paint, 0, offset);
+ }
// build
fBlob.reset(builder.build());
@@ -88,9 +108,9 @@ protected:
SkCanvas* c = surface->getCanvas();
- int stride = SkScalarCeilToInt(fBlob->bounds().height() / 2) + 10;
- int yOffset = stride;
- for (int i = 0; i < 10; i++) {
+ int stride = SkScalarCeilToInt(fBlob->bounds().height());
+ int yOffset = stride / 8;
+ for (int i = 0; i < 1; i++) {
// fiddle the canvas to force regen of textblobs
canvas->rotate(i % 2 ? 0.0f : -0.05f);
canvas->drawTextBlob(fBlob, 10.0f, SkIntToScalar(yOffset), paint);
@@ -119,8 +139,8 @@ protected:
private:
SkAutoTUnref<const SkTextBlob> fBlob;
- static const int kWidth = 1000;
- static const int kHeight = 1000;
+ static const int kWidth = 2000;
+ static const int kHeight = 1600;
typedef GM INHERITED;
};