OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "gm.h" | 8 #include "gm.h" |
9 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 const char* text = "AB"; | 28 const char* text = "AB"; |
29 sk_tool_utils::set_portable_typeface(&paint); | 29 sk_tool_utils::set_portable_typeface(&paint); |
30 | 30 |
31 SkRect bounds; | 31 SkRect bounds; |
32 paint.measureText(text, strlen(text), &bounds); | 32 paint.measureText(text, strlen(text), &bounds); |
33 | 33 |
34 SkScalar yOffset = bounds.height(); | 34 SkScalar yOffset = bounds.height(); |
35 sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, yOffset - 30); | 35 sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, yOffset - 30); |
36 | 36 |
37 // build | 37 // build |
38 fBlob.reset(builder.build()); | 38 fBlob = builder.make(); |
39 } | 39 } |
40 | 40 |
41 SkString onShortName() override { | 41 SkString onShortName() override { |
42 return SkString("textblobblockreordering"); | 42 return SkString("textblobblockreordering"); |
43 } | 43 } |
44 | 44 |
45 SkISize onISize() override { | 45 SkISize onISize() override { |
46 return SkISize::Make(kWidth, kHeight); | 46 return SkISize::Make(kWidth, kHeight); |
47 } | 47 } |
48 | 48 |
(...skipping 21 matching lines...) Expand all Loading... |
70 canvas->drawRect(bounds, redPaint); | 70 canvas->drawRect(bounds, redPaint); |
71 SkPaint srcInPaint(paint); | 71 SkPaint srcInPaint(paint); |
72 srcInPaint.setXfermodeMode(SkXfermode::kSrcIn_Mode); | 72 srcInPaint.setXfermodeMode(SkXfermode::kSrcIn_Mode); |
73 canvas->drawTextBlob(fBlob, 0, 0, srcInPaint); | 73 canvas->drawTextBlob(fBlob, 0, 0, srcInPaint); |
74 | 74 |
75 canvas->translate(SkIntToScalar(xDelta), SkIntToScalar(yDelta)); | 75 canvas->translate(SkIntToScalar(xDelta), SkIntToScalar(yDelta)); |
76 canvas->drawTextBlob(fBlob, 0, 0, paint); | 76 canvas->drawTextBlob(fBlob, 0, 0, paint); |
77 } | 77 } |
78 | 78 |
79 private: | 79 private: |
80 SkAutoTUnref<const SkTextBlob> fBlob; | 80 sk_sp<SkTextBlob> fBlob; |
81 | 81 |
82 static constexpr int kWidth = 275; | 82 static constexpr int kWidth = 275; |
83 static constexpr int kHeight = 200; | 83 static constexpr int kHeight = 200; |
84 | 84 |
85 typedef GM INHERITED; | 85 typedef GM INHERITED; |
86 }; | 86 }; |
87 | 87 |
88 ////////////////////////////////////////////////////////////////////////////// | 88 ////////////////////////////////////////////////////////////////////////////// |
89 | 89 |
90 DEF_GM(return new TextBlobBlockReordering;) | 90 DEF_GM(return new TextBlobBlockReordering;) |
91 } | 91 } |
OLD | NEW |