OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BD-style license that can be | 4 * Use of this source code is governed by a BD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "gm.h" | 8 #include "gm.h" |
9 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 SkPaint paint; | 33 SkPaint paint; |
34 sk_tool_utils::set_portable_typeface(&paint); | 34 sk_tool_utils::set_portable_typeface(&paint); |
35 paint.setTextSize(20); | 35 paint.setTextSize(20); |
36 paint.setAntiAlias(true); | 36 paint.setAntiAlias(true); |
37 paint.setLCDRenderText(true); | 37 paint.setLCDRenderText(true); |
38 | 38 |
39 SkTextBlobBuilder builder; | 39 SkTextBlobBuilder builder; |
40 | 40 |
41 sk_tool_utils::add_to_text_blob(&builder, text, paint, 10, 10); | 41 sk_tool_utils::add_to_text_blob(&builder, text, paint, 10, 10); |
42 | 42 |
43 SkAutoTUnref<const SkTextBlob> blob(builder.build()); | 43 sk_sp<SkTextBlob> blob(builder.make()); |
44 | 44 |
45 SkImageInfo info = SkImageInfo::MakeN32Premul(200, 200); | 45 SkImageInfo info = SkImageInfo::MakeN32Premul(200, 200); |
46 SkSurfaceProps props(0, kUnknown_SkPixelGeometry); | 46 SkSurfaceProps props(0, kUnknown_SkPixelGeometry); |
47 auto surface = canvas->makeSurface(info, &props); | 47 auto surface = canvas->makeSurface(info, &props); |
48 if (!surface) { | 48 if (!surface) { |
49 surface = SkSurface::MakeRaster(info, &props); | 49 surface = SkSurface::MakeRaster(info, &props); |
50 } | 50 } |
51 SkCanvas* c = surface->getCanvas(); | 51 SkCanvas* c = surface->getCanvas(); |
52 | 52 |
53 // LCD text on white background | 53 // LCD text on white background |
54 SkRect rect = SkRect::MakeLTRB(0.f, 0.f, SkIntToScalar(kWidth), kHeight
/ 2.f); | 54 SkRect rect = SkRect::MakeLTRB(0.f, 0.f, SkIntToScalar(kWidth), kHeight
/ 2.f); |
55 SkPaint rectPaint; | 55 SkPaint rectPaint; |
56 rectPaint.setColor(0xffffffff); | 56 rectPaint.setColor(0xffffffff); |
57 canvas->drawRect(rect, rectPaint); | 57 canvas->drawRect(rect, rectPaint); |
58 canvas->drawTextBlob(blob.get(), 10, 50, paint); | 58 canvas->drawTextBlob(blob, 10, 50, paint); |
59 | 59 |
60 // This should not look garbled since we should disable LCD text in this
case | 60 // This should not look garbled since we should disable LCD text in this
case |
61 // (i.e., unknown pixel geometry) | 61 // (i.e., unknown pixel geometry) |
62 c->clear(0x00ffffff); | 62 c->clear(0x00ffffff); |
63 c->drawTextBlob(blob.get(), 10, 150, paint); | 63 c->drawTextBlob(blob, 10, 150, paint); |
64 surface->draw(canvas, 0, 0, nullptr); | 64 surface->draw(canvas, 0, 0, nullptr); |
65 } | 65 } |
66 | 66 |
67 private: | 67 private: |
68 static constexpr int kWidth = 200; | 68 static constexpr int kWidth = 200; |
69 static constexpr int kHeight = 200; | 69 static constexpr int kHeight = 200; |
70 | 70 |
71 typedef GM INHERITED; | 71 typedef GM INHERITED; |
72 }; | 72 }; |
73 | 73 |
74 ////////////////////////////////////////////////////////////////////////////// | 74 ////////////////////////////////////////////////////////////////////////////// |
75 | 75 |
76 DEF_GM(return new TextBlobGeometryChange;) | 76 DEF_GM(return new TextBlobGeometryChange;) |
77 } | 77 } |
OLD | NEW |