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 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 "Resources.h" | 10 #include "Resources.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 const char* text = "The quick brown fox jumps over the lazy dog."; | 34 const char* text = "The quick brown fox jumps over the lazy dog."; |
35 | 35 |
36 // make textbloben | 36 // make textbloben |
37 SkPaint paint; | 37 SkPaint paint; |
38 paint.setTextSize(32); | 38 paint.setTextSize(32); |
39 paint.setLCDRenderText(true); | 39 paint.setLCDRenderText(true); |
40 | 40 |
41 // Setup our random scaler context | 41 // Setup our random scaler context |
42 SkAutoTUnref<SkTypeface> orig(sk_tool_utils::create_portable_typeface("s
ans-serif", | 42 SkAutoTUnref<SkTypeface> orig(sk_tool_utils::create_portable_typeface("s
ans-serif", |
43 Sk
Typeface::kBold)); | 43 Sk
Typeface::kBold)); |
44 if (NULL == orig) { | 44 if (nullptr == orig) { |
45 orig.reset(SkTypeface::RefDefault()); | 45 orig.reset(SkTypeface::RefDefault()); |
46 } | 46 } |
47 SkAutoTUnref<SkTypeface> random(new SkRandomTypeface(orig, paint, false)
); | 47 SkAutoTUnref<SkTypeface> random(new SkRandomTypeface(orig, paint, false)
); |
48 paint.setTypeface(random); | 48 paint.setTypeface(random); |
49 | 49 |
50 SkRect bounds; | 50 SkRect bounds; |
51 paint.measureText(text, strlen(text), &bounds); | 51 paint.measureText(text, strlen(text), &bounds); |
52 sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, 0); | 52 sk_tool_utils::add_to_text_blob(&builder, text, paint, 0, 0); |
53 | 53 |
54 // A8 | 54 // A8 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 SkString onShortName() override { | 86 SkString onShortName() override { |
87 return SkString("textblobrandomfont"); | 87 return SkString("textblobrandomfont"); |
88 } | 88 } |
89 | 89 |
90 SkISize onISize() override { | 90 SkISize onISize() override { |
91 return SkISize::Make(kWidth, kHeight); | 91 return SkISize::Make(kWidth, kHeight); |
92 } | 92 } |
93 | 93 |
94 void onDraw(SkCanvas* canvas) override { | 94 void onDraw(SkCanvas* canvas) override { |
95 // This GM exists to test a specific feature of the GPU backend. | 95 // This GM exists to test a specific feature of the GPU backend. |
96 if (NULL == canvas->getGrContext()) { | 96 if (nullptr == canvas->getGrContext()) { |
97 this->drawGpuOnlyMessage(canvas); | 97 this->drawGpuOnlyMessage(canvas); |
98 return; | 98 return; |
99 } | 99 } |
100 | 100 |
101 canvas->drawColor(sk_tool_utils::color_to_565(SK_ColorWHITE)); | 101 canvas->drawColor(sk_tool_utils::color_to_565(SK_ColorWHITE)); |
102 | 102 |
103 SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight); | 103 SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight); |
104 SkSurfaceProps props(0, kUnknown_SkPixelGeometry); | 104 SkSurfaceProps props(0, kUnknown_SkPixelGeometry); |
105 SkAutoTUnref<SkSurface> surface(canvas->newSurface(info, &props)); | 105 SkAutoTUnref<SkSurface> surface(canvas->newSurface(info, &props)); |
106 if (surface) { | 106 if (surface) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 static const int kHeight = 1600; | 144 static const int kHeight = 1600; |
145 | 145 |
146 typedef GM INHERITED; | 146 typedef GM INHERITED; |
147 }; | 147 }; |
148 | 148 |
149 ////////////////////////////////////////////////////////////////////////////// | 149 ////////////////////////////////////////////////////////////////////////////// |
150 | 150 |
151 DEF_GM(return new TextBlobRandomFont;) | 151 DEF_GM(return new TextBlobRandomFont;) |
152 } | 152 } |
153 #endif | 153 #endif |
OLD | NEW |