266 {
267 if (lineCount == 0) {
268
269
270 int draws = this->
drawTile(canvas, baseRect, quad, edgeAA, tileID, *quadCount);
271 *quadCount = *quadCount + 1;
272 return draws;
273 }
274
275 static constexpr int kTL = 0;
276 static constexpr int kTR = 1;
277 static constexpr int kBR = 2;
278 static constexpr int kBL = 3;
279 static constexpr int kS0 = 4;
280 static constexpr int kS1 = 5;
281
283 if (quad) {
284
285 for (
int i = 0;
i < 4; ++
i) {
287 }
288 } else {
289
291 }
292
293
294
295 int splitIndices[2];
296 int intersectionCount = 0;
297 for (
int i = 0;
i < 4; ++
i) {
301
302
303 bool duplicate = false;
304 for (int j = 0; j < intersectionCount; ++j) {
306 duplicate = true;
307 break;
308 }
309 }
310 if (!duplicate) {
312 splitIndices[intersectionCount] =
i;
313 intersectionCount++;
314 }
315 }
316 }
317
318 if (intersectionCount < 2) {
319
320
322 canvas, tileID, baseRect, quad, edgeAA,
lines + 2, lineCount - 1, quadCount);
323 }
324
326
327
328
329
330
332 int s2 = -1;
333 if (splitIndices[1] - splitIndices[0] == 2) {
334
335 if (splitIndices[0] == 0) {
338 } else {
341 }
342 } else {
343
344
345
346
347 switch(splitIndices[0]) {
348 case 0:
349
350 if (splitIndices[1] == 1) {
355 } else {
361 }
362 break;
363 case 1:
364
370 break;
371 case 2:
372
378 break;
379 case 3:
380
381
382 default:
384 return 0;
385 }
386 }
387
389 bool subAA[4];
390 int draws = 0;
391 for (
int i = 0;
i < subtiles.
size(); ++
i) {
392
393 for (int j = 0; j < 4; ++j) {
394 int p = subtiles[
i][j];
396
397 int np = j == 3 ? subtiles[
i][0] : subtiles[
i][j + 1];
398
399
400
401 if ((
p >= kS0 && (np == s2 || np >= kS0)) ||
402 ((np >= kS0) && (
p == s2 ||
p >= kS0))) {
403
404 subAA[j] = false;
405 } else {
406
407
408 subAA[j] = edgeAA[j];
409 }
410 }
411
412
413 draws += this->
clipTile(canvas, tileID, baseRect, sub, subAA,
lines + 2, lineCount - 1,
414 quadCount);
415 }
416 return draws;
417 }
static bool intersect(const SkPoint &p0, const SkPoint &n0, const SkPoint &p1, const SkPoint &n1, SkScalar *t)
static const uint16_t kTL
static const uint16_t kBL
static const uint16_t kBR
static const uint16_t kTR
static const int points[]
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
virtual int drawTile(SkCanvas *canvas, const SkRect &rect, const SkPoint clip[4], const bool edgeAA[4], int tileID, int quadID)=0
int clipTile(SkCanvas *canvas, int tileID, const SkRect &baseRect, const SkPoint quad[4], const bool edgeAA[4], const SkPoint lines[], int lineCount, int *quadCount)
static bool intersect_line_segments(const SkPoint &p0, const SkPoint &p1, const SkPoint &l0, const SkPoint &l1, SkPoint *intersect)
void toQuad(SkPoint quad[4]) const