OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkPaint.h" | 8 #include "SkPaint.h" |
9 #include "SkPoint.h" | 9 #include "SkPoint.h" |
10 #include "SkTextBlob.h" | 10 #include "SkTextBlob.h" |
11 | 11 |
12 #include "Test.h" | 12 #include "Test.h" |
13 | 13 |
14 | 14 |
15 class TextBlobTester { | 15 class TextBlobTester { |
16 public: | 16 public: |
17 // This unit test feeds an SkTextBlobBuilder various runs then checks to see
if | 17 // This unit test feeds an SkTextBlobBuilder various runs then checks to see
if |
18 // the result contains the provided data and merges runs when appropriate. | 18 // the result contains the provided data and merges runs when appropriate. |
19 static void TestBuilder(skiatest::Reporter* reporter) { | 19 static void TestBuilder(skiatest::Reporter* reporter) { |
20 SkTextBlobBuilder builder; | 20 SkTextBlobBuilder builder; |
21 | 21 |
22 // empty run set | 22 // empty run set |
23 RunBuilderTest(reporter, builder, NULL, 0, NULL, 0); | 23 RunBuilderTest(reporter, builder, nullptr, 0, nullptr, 0); |
24 | 24 |
25 RunDef set1[] = { | 25 RunDef set1[] = { |
26 { 128, SkTextBlob::kDefault_Positioning, 100, 100 }, | 26 { 128, SkTextBlob::kDefault_Positioning, 100, 100 }, |
27 }; | 27 }; |
28 RunBuilderTest(reporter, builder, set1, SK_ARRAY_COUNT(set1), set1, SK_A
RRAY_COUNT(set1)); | 28 RunBuilderTest(reporter, builder, set1, SK_ARRAY_COUNT(set1), set1, SK_A
RRAY_COUNT(set1)); |
29 | 29 |
30 RunDef set2[] = { | 30 RunDef set2[] = { |
31 { 128, SkTextBlob::kHorizontal_Positioning, 100, 100 }, | 31 { 128, SkTextBlob::kHorizontal_Positioning, 100, 100 }, |
32 }; | 32 }; |
33 RunBuilderTest(reporter, builder, set2, SK_ARRAY_COUNT(set2), set2, SK_A
RRAY_COUNT(set2)); | 33 RunBuilderTest(reporter, builder, set2, SK_ARRAY_COUNT(set2), set2, SK_A
RRAY_COUNT(set2)); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 } | 199 } |
200 | 200 |
201 it.next(); | 201 it.next(); |
202 } | 202 } |
203 | 203 |
204 REPORTER_ASSERT(reporter, it.done()); | 204 REPORTER_ASSERT(reporter, it.done()); |
205 } | 205 } |
206 | 206 |
207 static void AddRun(const SkPaint& font, int count, SkTextBlob::GlyphPosition
ing pos, | 207 static void AddRun(const SkPaint& font, int count, SkTextBlob::GlyphPosition
ing pos, |
208 const SkPoint& offset, SkTextBlobBuilder& builder, | 208 const SkPoint& offset, SkTextBlobBuilder& builder, |
209 const SkRect* bounds = NULL) { | 209 const SkRect* bounds = nullptr) { |
210 switch (pos) { | 210 switch (pos) { |
211 case SkTextBlob::kDefault_Positioning: { | 211 case SkTextBlob::kDefault_Positioning: { |
212 const SkTextBlobBuilder::RunBuffer& rb = builder.allocRun(font, coun
t, offset.x(), | 212 const SkTextBlobBuilder::RunBuffer& rb = builder.allocRun(font, coun
t, offset.x(), |
213 offset.y()
, bounds); | 213 offset.y()
, bounds); |
214 for (int i = 0; i < count; ++i) { | 214 for (int i = 0; i < count; ++i) { |
215 rb.glyphs[i] = i; | 215 rb.glyphs[i] = i; |
216 } | 216 } |
217 } break; | 217 } break; |
218 case SkTextBlob::kHorizontal_Positioning: { | 218 case SkTextBlob::kHorizontal_Positioning: { |
219 const SkTextBlobBuilder::RunBuffer& rb = builder.allocRunPosH(font,
count, offset.y(), | 219 const SkTextBlobBuilder::RunBuffer& rb = builder.allocRunPosH(font,
count, offset.y(), |
(...skipping 14 matching lines...) Expand all Loading... |
234 default: | 234 default: |
235 SkFAIL("unhandled positioning value"); | 235 SkFAIL("unhandled positioning value"); |
236 } | 236 } |
237 } | 237 } |
238 }; | 238 }; |
239 | 239 |
240 DEF_TEST(TextBlob_builder, reporter) { | 240 DEF_TEST(TextBlob_builder, reporter) { |
241 TextBlobTester::TestBuilder(reporter); | 241 TextBlobTester::TestBuilder(reporter); |
242 TextBlobTester::TestBounds(reporter); | 242 TextBlobTester::TestBounds(reporter); |
243 } | 243 } |
OLD | NEW |