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

Side by Side Diff: gm/textblobgeometrychange.cpp

Issue 1135813007: fix for cached textblobs look garbled (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more Created 5 years, 7 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 | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "gm.h"
9
10 #include "SkCanvas.h"
11 #include "SkSurface.h"
12 #include "SkTextBlob.h"
13
14 // This tests that we don't try to reuse textblobs from the GPU textblob cache a cross pixel geometry
15 // changes when we have LCD. crbug/486744
16 namespace skiagm {
17 class TextBlobGeometryChange : public GM {
18 public:
19 TextBlobGeometryChange() { }
20
21 protected:
22 SkString onShortName() override {
23 return SkString("textblobgeometrychange");
24 }
25
26 SkISize onISize() override {
27 return SkISize::Make(kWidth, kHeight);
28 }
29
30 void onDraw(SkCanvas* canvas) override {
31 const char text[] = "Hamburgefons";
32
33 SkPaint paint;
34 sk_tool_utils::set_portable_typeface(&paint);
35 paint.setTextSize(20);
36 paint.setAntiAlias(true);
37 paint.setLCDRenderText(true);
38
39 SkTextBlobBuilder builder;
40
41 sk_tool_utils::add_to_text_blob(&builder, text, paint, 10, 10);
42
43 SkAutoTUnref<const SkTextBlob> blob(builder.build());
44
45 SkImageInfo info = SkImageInfo::MakeN32Premul(200, 200);
46 SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
47 SkAutoTUnref<SkSurface> surface(canvas->newSurface(info, &props));
48 if (surface) {
49 SkCanvas* c = surface->getCanvas();
50
51 // LCD text on white background
52 SkRect rect = SkRect::MakeLTRB(0.f, 0.f, SkIntToScalar(kWidth), kHei ght / 2.f);
53 SkPaint rectPaint;
54 rectPaint.setColor(0xffffffff);
55 canvas->drawRect(rect, rectPaint);
56 canvas->drawTextBlob(blob.get(), 10, 50, paint);
57
58 // This should not look garbled since we should disable LCD text in this case
59 // (i.e., unknown pixel geometry)
60 c->clear(0x00ffffff);
61 c->drawTextBlob(blob.get(), 10, 150, paint);
62 surface->draw(canvas, 0, 0, nullptr);
63 } else {
64 const char* text = "This test requires a surface";
65 size_t len = strlen(text);
66 SkPaint paint;
67 canvas->drawText(text, len, 10, 100, paint);
68 }
69 }
70
71 private:
72 static const int kWidth = 200;
73 static const int kHeight = 200;
74
75 typedef GM INHERITED;
76 };
77
78 //////////////////////////////////////////////////////////////////////////////
79
80 DEF_GM( return SkNEW(TextBlobGeometryChange); )
81 }
OLDNEW
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698