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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkPatchUtils.h" | 9 #include "SkPatchUtils.h" |
10 #include "SkPictureData.h" | 10 #include "SkPictureData.h" |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 } | 412 } |
413 } break; | 413 } break; |
414 case DRAW_POS_TEXT_TOP_BOTTOM: { | 414 case DRAW_POS_TEXT_TOP_BOTTOM: { |
415 const SkPaint* paint = fPictureData->getPaint(reader); | 415 const SkPaint* paint = fPictureData->getPaint(reader); |
416 TextContainer text; | 416 TextContainer text; |
417 get_text(reader, &text); | 417 get_text(reader, &text); |
418 size_t points = reader->readInt(); | 418 size_t points = reader->readInt(); |
419 const SkPoint* pos = (const SkPoint*)reader->skip(points * sizeof(Sk
Point)); | 419 const SkPoint* pos = (const SkPoint*)reader->skip(points * sizeof(Sk
Point)); |
420 const SkScalar top = reader->readScalar(); | 420 const SkScalar top = reader->readScalar(); |
421 const SkScalar bottom = reader->readScalar(); | 421 const SkScalar bottom = reader->readScalar(); |
422 if (!canvas->quickRejectY(top, bottom) && paint) { | 422 SkRect clip; |
| 423 canvas->getClipBounds(&clip); |
| 424 if (top < clip.fBottom && bottom > clip.fTop && paint) { |
423 canvas->drawPosText(text.text(), text.length(), pos, *paint); | 425 canvas->drawPosText(text.text(), text.length(), pos, *paint); |
424 } | 426 } |
425 } break; | 427 } break; |
426 case DRAW_POS_TEXT_H: { | 428 case DRAW_POS_TEXT_H: { |
427 const SkPaint* paint = fPictureData->getPaint(reader); | 429 const SkPaint* paint = fPictureData->getPaint(reader); |
428 TextContainer text; | 430 TextContainer text; |
429 get_text(reader, &text); | 431 get_text(reader, &text); |
430 size_t xCount = reader->readInt(); | 432 size_t xCount = reader->readInt(); |
431 const SkScalar constY = reader->readScalar(); | 433 const SkScalar constY = reader->readScalar(); |
432 const SkScalar* xpos = (const SkScalar*)reader->skip(xCount * sizeof
(SkScalar)); | 434 const SkScalar* xpos = (const SkScalar*)reader->skip(xCount * sizeof
(SkScalar)); |
433 if (paint) { | 435 if (paint) { |
434 canvas->drawPosTextH(text.text(), text.length(), xpos, constY, *
paint); | 436 canvas->drawPosTextH(text.text(), text.length(), xpos, constY, *
paint); |
435 } | 437 } |
436 } break; | 438 } break; |
437 case DRAW_POS_TEXT_H_TOP_BOTTOM: { | 439 case DRAW_POS_TEXT_H_TOP_BOTTOM: { |
438 const SkPaint* paint = fPictureData->getPaint(reader); | 440 const SkPaint* paint = fPictureData->getPaint(reader); |
439 TextContainer text; | 441 TextContainer text; |
440 get_text(reader, &text); | 442 get_text(reader, &text); |
441 size_t xCount = reader->readInt(); | 443 size_t xCount = reader->readInt(); |
442 const SkScalar* xpos = (const SkScalar*)reader->skip((3 + xCount) *
sizeof(SkScalar)); | 444 const SkScalar* xpos = (const SkScalar*)reader->skip((3 + xCount) *
sizeof(SkScalar)); |
443 const SkScalar top = *xpos++; | 445 const SkScalar top = *xpos++; |
444 const SkScalar bottom = *xpos++; | 446 const SkScalar bottom = *xpos++; |
445 const SkScalar constY = *xpos++; | 447 const SkScalar constY = *xpos++; |
446 if (!canvas->quickRejectY(top, bottom) && paint) { | 448 SkRect clip; |
| 449 canvas->getClipBounds(&clip); |
| 450 if (top < clip.fBottom && bottom > clip.fTop && paint) { |
447 canvas->drawPosTextH(text.text(), text.length(), xpos, constY, *
paint); | 451 canvas->drawPosTextH(text.text(), text.length(), xpos, constY, *
paint); |
448 } | 452 } |
449 } break; | 453 } break; |
450 case DRAW_RECT: { | 454 case DRAW_RECT: { |
451 const SkPaint* paint = fPictureData->getPaint(reader); | 455 const SkPaint* paint = fPictureData->getPaint(reader); |
452 SkRect rect; | 456 SkRect rect; |
453 reader->readRect(&rect); | 457 reader->readRect(&rect); |
454 if (paint) { | 458 if (paint) { |
455 canvas->drawRect(rect, *paint); | 459 canvas->drawRect(rect, *paint); |
456 } | 460 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 } break; | 495 } break; |
492 case DRAW_TEXT_TOP_BOTTOM: { | 496 case DRAW_TEXT_TOP_BOTTOM: { |
493 const SkPaint* paint = fPictureData->getPaint(reader); | 497 const SkPaint* paint = fPictureData->getPaint(reader); |
494 TextContainer text; | 498 TextContainer text; |
495 get_text(reader, &text); | 499 get_text(reader, &text); |
496 const SkScalar* ptr = (const SkScalar*)reader->skip(4 * sizeof(SkSca
lar)); | 500 const SkScalar* ptr = (const SkScalar*)reader->skip(4 * sizeof(SkSca
lar)); |
497 // ptr[0] == x | 501 // ptr[0] == x |
498 // ptr[1] == y | 502 // ptr[1] == y |
499 // ptr[2] == top | 503 // ptr[2] == top |
500 // ptr[3] == bottom | 504 // ptr[3] == bottom |
501 if (!canvas->quickRejectY(ptr[2], ptr[3]) && paint) { | 505 SkRect clip; |
| 506 canvas->getClipBounds(&clip); |
| 507 float top = ptr[2]; |
| 508 float bottom = ptr[3]; |
| 509 if (top < clip.fBottom && bottom > clip.fTop && paint) { |
502 canvas->drawText(text.text(), text.length(), ptr[0], ptr[1], *pa
int); | 510 canvas->drawText(text.text(), text.length(), ptr[0], ptr[1], *pa
int); |
503 } | 511 } |
504 } break; | 512 } break; |
505 case DRAW_TEXT_ON_PATH: { | 513 case DRAW_TEXT_ON_PATH: { |
506 const SkPaint* paint = fPictureData->getPaint(reader); | 514 const SkPaint* paint = fPictureData->getPaint(reader); |
507 TextContainer text; | 515 TextContainer text; |
508 get_text(reader, &text); | 516 get_text(reader, &text); |
509 const SkPath& path = fPictureData->getPath(reader); | 517 const SkPath& path = fPictureData->getPath(reader); |
510 SkMatrix matrix; | 518 SkMatrix matrix; |
511 reader->readMatrix(&matrix); | 519 reader->readMatrix(&matrix); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 case TRANSLATE_Z: { | 639 case TRANSLATE_Z: { |
632 #ifdef SK_EXPERIMENTAL_SHADOWING | 640 #ifdef SK_EXPERIMENTAL_SHADOWING |
633 SkScalar dz = reader->readScalar(); | 641 SkScalar dz = reader->readScalar(); |
634 canvas->translateZ(dz); | 642 canvas->translateZ(dz); |
635 #endif | 643 #endif |
636 } break; | 644 } break; |
637 default: | 645 default: |
638 SkASSERTF(false, "Unknown draw type: %d", op); | 646 SkASSERTF(false, "Unknown draw type: %d", op); |
639 } | 647 } |
640 } | 648 } |
OLD | NEW |