| 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 "SkTextBlobRunIterator.h" |
| 11 | 11 |
| 12 #include "Test.h" | 12 #include "Test.h" |
| 13 | 13 |
| 14 class TextBlobTester { | 14 class TextBlobTester { |
| 15 public: | 15 public: |
| 16 // This unit test feeds an SkTextBlobBuilder various runs then checks to see
if | 16 // This unit test feeds an SkTextBlobBuilder various runs then checks to see
if |
| 17 // the result contains the provided data and merges runs when appropriate. | 17 // the result contains the provided data and merges runs when appropriate. |
| 18 static void TestBuilder(skiatest::Reporter* reporter) { | 18 static void TestBuilder(skiatest::Reporter* reporter) { |
| 19 SkTextBlobBuilder builder; | 19 SkTextBlobBuilder builder; |
| 20 | 20 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 unsigned posCount = 0; | 189 unsigned posCount = 0; |
| 190 | 190 |
| 191 for (unsigned i = 0; i < inCount; ++i) { | 191 for (unsigned i = 0; i < inCount; ++i) { |
| 192 AddRun(font, in[i].count, in[i].pos, SkPoint::Make(in[i].x, in[i].y)
, builder); | 192 AddRun(font, in[i].count, in[i].pos, SkPoint::Make(in[i].x, in[i].y)
, builder); |
| 193 glyphCount += in[i].count; | 193 glyphCount += in[i].count; |
| 194 posCount += in[i].count * in[i].pos; | 194 posCount += in[i].count * in[i].pos; |
| 195 } | 195 } |
| 196 | 196 |
| 197 SkAutoTUnref<const SkTextBlob> blob(builder.build()); | 197 SkAutoTUnref<const SkTextBlob> blob(builder.build()); |
| 198 | 198 |
| 199 SkTextBlob::RunIterator it(blob); | 199 SkTextBlobRunIterator it(blob); |
| 200 for (unsigned i = 0; i < outCount; ++i) { | 200 for (unsigned i = 0; i < outCount; ++i) { |
| 201 REPORTER_ASSERT(reporter, !it.done()); | 201 REPORTER_ASSERT(reporter, !it.done()); |
| 202 REPORTER_ASSERT(reporter, out[i].pos == it.positioning()); | 202 REPORTER_ASSERT(reporter, out[i].pos == it.positioning()); |
| 203 REPORTER_ASSERT(reporter, out[i].count == it.glyphCount()); | 203 REPORTER_ASSERT(reporter, out[i].count == it.glyphCount()); |
| 204 if (SkTextBlob::kDefault_Positioning == out[i].pos) { | 204 if (SkTextBlob::kDefault_Positioning == out[i].pos) { |
| 205 REPORTER_ASSERT(reporter, out[i].x == it.offset().x()); | 205 REPORTER_ASSERT(reporter, out[i].x == it.offset().x()); |
| 206 REPORTER_ASSERT(reporter, out[i].y == it.offset().y()); | 206 REPORTER_ASSERT(reporter, out[i].y == it.offset().y()); |
| 207 } else if (SkTextBlob::kHorizontal_Positioning == out[i].pos) { | 207 } else if (SkTextBlob::kHorizontal_Positioning == out[i].pos) { |
| 208 REPORTER_ASSERT(reporter, out[i].y == it.offset().y()); | 208 REPORTER_ASSERT(reporter, out[i].y == it.offset().y()); |
| 209 } | 209 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 default: | 254 default: |
| 255 SkFAIL("unhandled positioning value"); | 255 SkFAIL("unhandled positioning value"); |
| 256 } | 256 } |
| 257 } | 257 } |
| 258 }; | 258 }; |
| 259 | 259 |
| 260 DEF_TEST(TextBlob_builder, reporter) { | 260 DEF_TEST(TextBlob_builder, reporter) { |
| 261 TextBlobTester::TestBuilder(reporter); | 261 TextBlobTester::TestBuilder(reporter); |
| 262 TextBlobTester::TestBounds(reporter); | 262 TextBlobTester::TestBounds(reporter); |
| 263 } | 263 } |
| OLD | NEW |