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" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 REPORTER_ASSERT(reporter, blob->bounds() == SkRect::MakeXYWH(0, 5, 6
5, 65)); | 142 REPORTER_ASSERT(reporter, blob->bounds() == SkRect::MakeXYWH(0, 5, 6
5, 65)); |
143 } | 143 } |
144 | 144 |
145 { | 145 { |
146 // Verify empty blob bounds after building some non-empty blobs. | 146 // Verify empty blob bounds after building some non-empty blobs. |
147 SkAutoTUnref<const SkTextBlob> blob(builder.build()); | 147 SkAutoTUnref<const SkTextBlob> blob(builder.build()); |
148 REPORTER_ASSERT(reporter, blob->bounds().isEmpty()); | 148 REPORTER_ASSERT(reporter, blob->bounds().isEmpty()); |
149 } | 149 } |
150 | 150 |
151 // Implicit bounds | 151 // Implicit bounds |
152 // FIXME: not supported yet. | 152 |
| 153 { |
| 154 // Exercise the empty bounds path, and ensure that RunRecord-aligned
pos buffers |
| 155 // don't trigger asserts (http://crbug.com/542643). |
| 156 SkPaint p; |
| 157 p.setTextSize(0); |
| 158 p.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
| 159 |
| 160 const char* txt = "BOOO"; |
| 161 const size_t len = strlen(txt); |
| 162 const SkTextBlobBuilder::RunBuffer& buffer = builder.allocRunPos(p,
(int)len); |
| 163 p.textToGlyphs(txt, len, buffer.glyphs); |
| 164 memset(buffer.pos, 0, sizeof(SkScalar) * len * 2); |
| 165 SkAutoTUnref<const SkTextBlob> blob(builder.build()); |
| 166 REPORTER_ASSERT(reporter, blob->bounds().isEmpty()); |
| 167 } |
153 } | 168 } |
154 | 169 |
155 private: | 170 private: |
156 struct RunDef { | 171 struct RunDef { |
157 unsigned count; | 172 unsigned count; |
158 SkTextBlob::GlyphPositioning pos; | 173 SkTextBlob::GlyphPositioning pos; |
159 SkScalar x, y; | 174 SkScalar x, y; |
160 }; | 175 }; |
161 | 176 |
162 static void RunBuilderTest(skiatest::Reporter* reporter, SkTextBlobBuilder&
builder, | 177 static void RunBuilderTest(skiatest::Reporter* reporter, SkTextBlobBuilder&
builder, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 default: | 249 default: |
235 SkFAIL("unhandled positioning value"); | 250 SkFAIL("unhandled positioning value"); |
236 } | 251 } |
237 } | 252 } |
238 }; | 253 }; |
239 | 254 |
240 DEF_TEST(TextBlob_builder, reporter) { | 255 DEF_TEST(TextBlob_builder, reporter) { |
241 TextBlobTester::TestBuilder(reporter); | 256 TextBlobTester::TestBuilder(reporter); |
242 TextBlobTester::TestBounds(reporter); | 257 TextBlobTester::TestBounds(reporter); |
243 } | 258 } |
OLD | NEW |