OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkAnnotation.h" | 9 #include "SkAnnotation.h" |
10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "SkPathEffect.h" | 22 #include "SkPathEffect.h" |
23 #include "SkPictureFlat.h" | 23 #include "SkPictureFlat.h" |
24 #include "SkRasterizer.h" | 24 #include "SkRasterizer.h" |
25 #include "SkRRect.h" | 25 #include "SkRRect.h" |
26 #include "SkShader.h" | 26 #include "SkShader.h" |
27 #include "SkStream.h" | 27 #include "SkStream.h" |
28 #include "SkTSearch.h" | 28 #include "SkTSearch.h" |
29 #include "SkTypeface.h" | 29 #include "SkTypeface.h" |
30 #include "SkWriter32.h" | 30 #include "SkWriter32.h" |
31 | 31 |
32 #ifdef SK_DEBUG | |
33 // When debugging, allocate snuggly. | |
34 static const size_t kMinBlockSize = 0; | |
35 #else | |
36 // For peformance, make large allocations. | |
37 static const size_t kMinBlockSize = 16 * 1024; | |
38 #endif | |
39 | |
40 enum { | 32 enum { |
41 kSizeOfFlatRRect = sizeof(SkRect) + 4 * sizeof(SkVector) | 33 kSizeOfFlatRRect = sizeof(SkRect) + 4 * sizeof(SkVector) |
42 }; | 34 }; |
43 | 35 |
44 static bool isCrossProcess(uint32_t flags) { | 36 static bool isCrossProcess(uint32_t flags) { |
45 return SkToBool(flags & SkGPipeWriter::kCrossProcess_Flag); | 37 return SkToBool(flags & SkGPipeWriter::kCrossProcess_Flag); |
46 } | 38 } |
47 | 39 |
48 static SkFlattenable* get_paintflat(const SkPaint& paint, unsigned paintFlat) { | 40 static SkFlattenable* get_paintflat(const SkPaint& paint, unsigned paintFlat) { |
49 SkASSERT(paintFlat < kCount_PaintFlats); | 41 SkASSERT(paintFlat < kCount_PaintFlats); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 int flattenToIndex(SkFlattenable* obj, PaintFlats); | 343 int flattenToIndex(SkFlattenable* obj, PaintFlats); |
352 | 344 |
353 // Common code used by drawBitmap*. Behaves differently depending on the | 345 // Common code used by drawBitmap*. Behaves differently depending on the |
354 // type of SkBitmapHeap being used, which is determined by the flags used. | 346 // type of SkBitmapHeap being used, which is determined by the flags used. |
355 bool commonDrawBitmap(const SkBitmap& bm, DrawOps op, unsigned flags, | 347 bool commonDrawBitmap(const SkBitmap& bm, DrawOps op, unsigned flags, |
356 size_t opBytesNeeded, const SkPaint* paint); | 348 size_t opBytesNeeded, const SkPaint* paint); |
357 | 349 |
358 SkPaint fPaint; | 350 SkPaint fPaint; |
359 void writePaint(const SkPaint&); | 351 void writePaint(const SkPaint&); |
360 | 352 |
| 353 class AutoPipeNotify { |
| 354 public: |
| 355 AutoPipeNotify(SkGPipeCanvas* canvas) : fCanvas(canvas) {} |
| 356 ~AutoPipeNotify() { fCanvas->doNotify(); } |
| 357 private: |
| 358 SkGPipeCanvas* fCanvas; |
| 359 }; |
| 360 friend class AutoPipeNotify; |
| 361 |
361 typedef SkCanvas INHERITED; | 362 typedef SkCanvas INHERITED; |
362 }; | 363 }; |
363 | 364 |
364 void SkGPipeCanvas::flattenFactoryNames() { | 365 void SkGPipeCanvas::flattenFactoryNames() { |
365 const char* name; | 366 const char* name; |
366 while ((name = fFactorySet->getNextAddedFactoryName()) != NULL) { | 367 while ((name = fFactorySet->getNextAddedFactoryName()) != NULL) { |
367 size_t len = strlen(name); | 368 size_t len = strlen(name); |
368 if (this->needOpBytes(SkWriter32::WriteStringSize(name, len))) { | 369 if (this->needOpBytes(len)) { |
369 this->writeOp(kDef_Factory_DrawOp); | 370 this->writeOp(kDef_Factory_DrawOp); |
370 fWriter.writeString(name, len); | 371 fWriter.writeString(name, len); |
371 } | 372 } |
372 } | 373 } |
373 } | 374 } |
374 | 375 |
375 bool SkGPipeCanvas::shuttleBitmap(const SkBitmap& bm, int32_t slot) { | 376 bool SkGPipeCanvas::shuttleBitmap(const SkBitmap& bm, int32_t slot) { |
376 SkASSERT(shouldFlattenBitmaps(fFlags)); | 377 SkASSERT(shouldFlattenBitmaps(fFlags)); |
377 SkWriteBuffer buffer; | 378 SkWriteBuffer buffer; |
378 buffer.setNamedFactoryRecorder(fFactorySet); | 379 buffer.setNamedFactoryRecorder(fFactorySet); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 } | 414 } |
414 } | 415 } |
415 if (replaced) { | 416 if (replaced) { |
416 index = ~index; | 417 index = ~index; |
417 } | 418 } |
418 return index; | 419 return index; |
419 } | 420 } |
420 | 421 |
421 /////////////////////////////////////////////////////////////////////////////// | 422 /////////////////////////////////////////////////////////////////////////////// |
422 | 423 |
| 424 #define MIN_BLOCK_SIZE (16 * 1024) |
423 #define BITMAPS_TO_KEEP 5 | 425 #define BITMAPS_TO_KEEP 5 |
424 #define FLATTENABLES_TO_KEEP 10 | 426 #define FLATTENABLES_TO_KEEP 10 |
425 | 427 |
426 SkGPipeCanvas::SkGPipeCanvas(SkGPipeController* controller, | 428 SkGPipeCanvas::SkGPipeCanvas(SkGPipeController* controller, |
427 SkWriter32* writer, uint32_t flags, | 429 SkWriter32* writer, uint32_t flags, |
428 uint32_t width, uint32_t height) | 430 uint32_t width, uint32_t height) |
429 : SkCanvas(width, height) | 431 : SkCanvas(width, height) |
430 , fFactorySet(isCrossProcess(flags) ? SkNEW(SkNamedFactorySet) : NULL) | 432 , fFactorySet(isCrossProcess(flags) ? SkNEW(SkNamedFactorySet) : NULL) |
431 , fWriter(*writer) | 433 , fWriter(*writer) |
432 , fFlags(flags) | 434 , fFlags(flags) |
(...skipping 17 matching lines...) Expand all Loading... |
450 fBitmapHeap = SkNEW_ARGS(SkBitmapHeap, (fBitmapShuttle.get(), BITMAPS_TO
_KEEP)); | 452 fBitmapHeap = SkNEW_ARGS(SkBitmapHeap, (fBitmapShuttle.get(), BITMAPS_TO
_KEEP)); |
451 } else { | 453 } else { |
452 fBitmapHeap = SkNEW_ARGS(SkBitmapHeap, | 454 fBitmapHeap = SkNEW_ARGS(SkBitmapHeap, |
453 (BITMAPS_TO_KEEP, controller->numberOfReaders()
)); | 455 (BITMAPS_TO_KEEP, controller->numberOfReaders()
)); |
454 if (this->needOpBytes(sizeof(void*))) { | 456 if (this->needOpBytes(sizeof(void*))) { |
455 this->writeOp(kShareBitmapHeap_DrawOp); | 457 this->writeOp(kShareBitmapHeap_DrawOp); |
456 fWriter.writePtr(static_cast<void*>(fBitmapHeap)); | 458 fWriter.writePtr(static_cast<void*>(fBitmapHeap)); |
457 } | 459 } |
458 } | 460 } |
459 fFlattenableHeap.setBitmapStorage(fBitmapHeap); | 461 fFlattenableHeap.setBitmapStorage(fBitmapHeap); |
| 462 this->doNotify(); |
460 } | 463 } |
461 | 464 |
462 SkGPipeCanvas::~SkGPipeCanvas() { | 465 SkGPipeCanvas::~SkGPipeCanvas() { |
463 this->finish(true); | 466 this->finish(true); |
464 SkSafeUnref(fFactorySet); | 467 SkSafeUnref(fFactorySet); |
465 SkSafeUnref(fBitmapHeap); | 468 SkSafeUnref(fBitmapHeap); |
466 } | 469 } |
467 | 470 |
468 bool SkGPipeCanvas::needOpBytes(size_t needed) { | 471 bool SkGPipeCanvas::needOpBytes(size_t needed) { |
469 if (fDone) { | 472 if (fDone) { |
470 return false; | 473 return false; |
471 } | 474 } |
472 | 475 |
473 needed += 4; // size of DrawOp atom | 476 needed += 4; // size of DrawOp atom |
474 needed = SkTMax(kMinBlockSize, needed); | |
475 needed = SkAlign4(needed); | |
476 if (fWriter.bytesWritten() + needed > fBlockSize) { | 477 if (fWriter.bytesWritten() + needed > fBlockSize) { |
477 // We're making a new block. First push out the current block. | 478 // Before we wipe out any data that has already been written, read it |
| 479 // out. |
478 this->doNotify(); | 480 this->doNotify(); |
479 | 481 size_t blockSize = SkTMax<size_t>(MIN_BLOCK_SIZE, needed); |
480 void* block = fController->requestBlock(needed, &fBlockSize); | 482 void* block = fController->requestBlock(blockSize, &fBlockSize); |
481 if (NULL == block) { | 483 if (NULL == block) { |
482 // Do not notify the readers, which would call this function again. | 484 // Do not notify the readers, which would call this function again. |
483 this->finish(false); | 485 this->finish(false); |
484 return false; | 486 return false; |
485 } | 487 } |
486 SkASSERT(SkIsAlign4(fBlockSize)); | 488 SkASSERT(SkIsAlign4(fBlockSize)); |
487 fWriter.reset(block, fBlockSize); | 489 fWriter.reset(block, fBlockSize); |
488 fBytesNotified = 0; | 490 fBytesNotified = 0; |
489 } | 491 } |
490 return true; | 492 return true; |
(...skipping 10 matching lines...) Expand all Loading... |
501 this->writeOp(kDef_Typeface_DrawOp); | 503 this->writeOp(kDef_Typeface_DrawOp); |
502 writeTypeface(&fWriter, face); | 504 writeTypeface(&fWriter, face); |
503 } | 505 } |
504 } | 506 } |
505 } | 507 } |
506 return id; | 508 return id; |
507 } | 509 } |
508 | 510 |
509 /////////////////////////////////////////////////////////////////////////////// | 511 /////////////////////////////////////////////////////////////////////////////// |
510 | 512 |
| 513 #define NOTIFY_SETUP(canvas) \ |
| 514 AutoPipeNotify apn(canvas) |
| 515 |
511 void SkGPipeCanvas::willSave(SaveFlags flags) { | 516 void SkGPipeCanvas::willSave(SaveFlags flags) { |
| 517 NOTIFY_SETUP(this); |
512 if (this->needOpBytes()) { | 518 if (this->needOpBytes()) { |
513 this->writeOp(kSave_DrawOp, 0, flags); | 519 this->writeOp(kSave_DrawOp, 0, flags); |
514 } | 520 } |
515 | 521 |
516 this->INHERITED::willSave(flags); | 522 this->INHERITED::willSave(flags); |
517 } | 523 } |
518 | 524 |
519 SkCanvas::SaveLayerStrategy SkGPipeCanvas::willSaveLayer(const SkRect* bounds, c
onst SkPaint* paint, | 525 SkCanvas::SaveLayerStrategy SkGPipeCanvas::willSaveLayer(const SkRect* bounds, c
onst SkPaint* paint, |
520 SaveFlags saveFlags) { | 526 SaveFlags saveFlags) { |
| 527 NOTIFY_SETUP(this); |
521 size_t size = 0; | 528 size_t size = 0; |
522 unsigned opFlags = 0; | 529 unsigned opFlags = 0; |
523 | 530 |
524 if (bounds) { | 531 if (bounds) { |
525 opFlags |= kSaveLayer_HasBounds_DrawOpFlag; | 532 opFlags |= kSaveLayer_HasBounds_DrawOpFlag; |
526 size += sizeof(SkRect); | 533 size += sizeof(SkRect); |
527 } | 534 } |
528 if (paint) { | 535 if (paint) { |
529 opFlags |= kSaveLayer_HasPaint_DrawOpFlag; | 536 opFlags |= kSaveLayer_HasPaint_DrawOpFlag; |
530 this->writePaint(*paint); | 537 this->writePaint(*paint); |
531 } | 538 } |
532 | 539 |
533 if (this->needOpBytes(size)) { | 540 if (this->needOpBytes(size)) { |
534 this->writeOp(kSaveLayer_DrawOp, opFlags, saveFlags); | 541 this->writeOp(kSaveLayer_DrawOp, opFlags, saveFlags); |
535 if (bounds) { | 542 if (bounds) { |
536 fWriter.writeRect(*bounds); | 543 fWriter.writeRect(*bounds); |
537 } | 544 } |
538 } | 545 } |
539 | 546 |
540 if (kNoSaveLayer == fFirstSaveLayerStackLevel){ | 547 if (kNoSaveLayer == fFirstSaveLayerStackLevel){ |
541 fFirstSaveLayerStackLevel = this->getSaveCount(); | 548 fFirstSaveLayerStackLevel = this->getSaveCount(); |
542 } | 549 } |
543 | 550 |
544 this->INHERITED::willSaveLayer(bounds, paint, saveFlags); | 551 this->INHERITED::willSaveLayer(bounds, paint, saveFlags); |
545 // we don't create a layer | 552 // we don't create a layer |
546 return kNoLayer_SaveLayerStrategy; | 553 return kNoLayer_SaveLayerStrategy; |
547 } | 554 } |
548 | 555 |
549 void SkGPipeCanvas::willRestore() { | 556 void SkGPipeCanvas::willRestore() { |
| 557 NOTIFY_SETUP(this); |
550 if (this->needOpBytes()) { | 558 if (this->needOpBytes()) { |
551 this->writeOp(kRestore_DrawOp); | 559 this->writeOp(kRestore_DrawOp); |
552 } | 560 } |
553 | 561 |
554 if (this->getSaveCount() - 1 == fFirstSaveLayerStackLevel){ | 562 if (this->getSaveCount() - 1 == fFirstSaveLayerStackLevel){ |
555 fFirstSaveLayerStackLevel = kNoSaveLayer; | 563 fFirstSaveLayerStackLevel = kNoSaveLayer; |
556 } | 564 } |
557 | 565 |
558 this->INHERITED::willRestore(); | 566 this->INHERITED::willRestore(); |
559 } | 567 } |
(...skipping 20 matching lines...) Expand all Loading... |
580 | 588 |
581 void SkGPipeCanvas::recordConcat(const SkMatrix& m) { | 589 void SkGPipeCanvas::recordConcat(const SkMatrix& m) { |
582 if (this->needOpBytes(m.writeToMemory(NULL))) { | 590 if (this->needOpBytes(m.writeToMemory(NULL))) { |
583 this->writeOp(kConcat_DrawOp); | 591 this->writeOp(kConcat_DrawOp); |
584 fWriter.writeMatrix(m); | 592 fWriter.writeMatrix(m); |
585 } | 593 } |
586 } | 594 } |
587 | 595 |
588 void SkGPipeCanvas::didConcat(const SkMatrix& matrix) { | 596 void SkGPipeCanvas::didConcat(const SkMatrix& matrix) { |
589 if (!matrix.isIdentity()) { | 597 if (!matrix.isIdentity()) { |
| 598 NOTIFY_SETUP(this); |
590 switch (matrix.getType()) { | 599 switch (matrix.getType()) { |
591 case SkMatrix::kTranslate_Mask: | 600 case SkMatrix::kTranslate_Mask: |
592 this->recordTranslate(matrix); | 601 this->recordTranslate(matrix); |
593 break; | 602 break; |
594 case SkMatrix::kScale_Mask: | 603 case SkMatrix::kScale_Mask: |
595 this->recordScale(matrix); | 604 this->recordScale(matrix); |
596 break; | 605 break; |
597 default: | 606 default: |
598 this->recordConcat(matrix); | 607 this->recordConcat(matrix); |
599 break; | 608 break; |
600 } | 609 } |
601 } | 610 } |
602 | 611 |
603 this->INHERITED::didConcat(matrix); | 612 this->INHERITED::didConcat(matrix); |
604 } | 613 } |
605 | 614 |
606 void SkGPipeCanvas::didSetMatrix(const SkMatrix& matrix) { | 615 void SkGPipeCanvas::didSetMatrix(const SkMatrix& matrix) { |
| 616 NOTIFY_SETUP(this); |
607 if (this->needOpBytes(matrix.writeToMemory(NULL))) { | 617 if (this->needOpBytes(matrix.writeToMemory(NULL))) { |
608 this->writeOp(kSetMatrix_DrawOp); | 618 this->writeOp(kSetMatrix_DrawOp); |
609 fWriter.writeMatrix(matrix); | 619 fWriter.writeMatrix(matrix); |
610 } | 620 } |
611 this->INHERITED::didSetMatrix(matrix); | 621 this->INHERITED::didSetMatrix(matrix); |
612 } | 622 } |
613 | 623 |
614 void SkGPipeCanvas::onClipRect(const SkRect& rect, SkRegion::Op rgnOp, | 624 void SkGPipeCanvas::onClipRect(const SkRect& rect, SkRegion::Op rgnOp, |
615 ClipEdgeStyle edgeStyle) { | 625 ClipEdgeStyle edgeStyle) { |
| 626 NOTIFY_SETUP(this); |
616 if (this->needOpBytes(sizeof(SkRect))) { | 627 if (this->needOpBytes(sizeof(SkRect))) { |
617 unsigned flags = 0; | 628 unsigned flags = 0; |
618 if (kSoft_ClipEdgeStyle == edgeStyle) { | 629 if (kSoft_ClipEdgeStyle == edgeStyle) { |
619 flags = kClip_HasAntiAlias_DrawOpFlag; | 630 flags = kClip_HasAntiAlias_DrawOpFlag; |
620 } | 631 } |
621 this->writeOp(kClipRect_DrawOp, flags, rgnOp); | 632 this->writeOp(kClipRect_DrawOp, flags, rgnOp); |
622 fWriter.writeRect(rect); | 633 fWriter.writeRect(rect); |
623 } | 634 } |
624 this->INHERITED::onClipRect(rect, rgnOp, edgeStyle); | 635 this->INHERITED::onClipRect(rect, rgnOp, edgeStyle); |
625 } | 636 } |
626 | 637 |
627 void SkGPipeCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op rgnOp, | 638 void SkGPipeCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op rgnOp, |
628 ClipEdgeStyle edgeStyle) { | 639 ClipEdgeStyle edgeStyle) { |
| 640 NOTIFY_SETUP(this); |
629 if (this->needOpBytes(kSizeOfFlatRRect)) { | 641 if (this->needOpBytes(kSizeOfFlatRRect)) { |
630 unsigned flags = 0; | 642 unsigned flags = 0; |
631 if (kSoft_ClipEdgeStyle == edgeStyle) { | 643 if (kSoft_ClipEdgeStyle == edgeStyle) { |
632 flags = kClip_HasAntiAlias_DrawOpFlag; | 644 flags = kClip_HasAntiAlias_DrawOpFlag; |
633 } | 645 } |
634 this->writeOp(kClipRRect_DrawOp, flags, rgnOp); | 646 this->writeOp(kClipRRect_DrawOp, flags, rgnOp); |
635 fWriter.writeRRect(rrect); | 647 fWriter.writeRRect(rrect); |
636 } | 648 } |
637 this->INHERITED::onClipRRect(rrect, rgnOp, edgeStyle); | 649 this->INHERITED::onClipRRect(rrect, rgnOp, edgeStyle); |
638 } | 650 } |
639 | 651 |
640 void SkGPipeCanvas::onClipPath(const SkPath& path, SkRegion::Op rgnOp, | 652 void SkGPipeCanvas::onClipPath(const SkPath& path, SkRegion::Op rgnOp, |
641 ClipEdgeStyle edgeStyle) { | 653 ClipEdgeStyle edgeStyle) { |
| 654 NOTIFY_SETUP(this); |
642 if (this->needOpBytes(path.writeToMemory(NULL))) { | 655 if (this->needOpBytes(path.writeToMemory(NULL))) { |
643 unsigned flags = 0; | 656 unsigned flags = 0; |
644 if (kSoft_ClipEdgeStyle == edgeStyle) { | 657 if (kSoft_ClipEdgeStyle == edgeStyle) { |
645 flags = kClip_HasAntiAlias_DrawOpFlag; | 658 flags = kClip_HasAntiAlias_DrawOpFlag; |
646 } | 659 } |
647 this->writeOp(kClipPath_DrawOp, flags, rgnOp); | 660 this->writeOp(kClipPath_DrawOp, flags, rgnOp); |
648 fWriter.writePath(path); | 661 fWriter.writePath(path); |
649 } | 662 } |
650 // we just pass on the bounds of the path | 663 // we just pass on the bounds of the path |
651 this->INHERITED::onClipRect(path.getBounds(), rgnOp, edgeStyle); | 664 this->INHERITED::onClipRect(path.getBounds(), rgnOp, edgeStyle); |
652 } | 665 } |
653 | 666 |
654 void SkGPipeCanvas::onClipRegion(const SkRegion& region, SkRegion::Op rgnOp) { | 667 void SkGPipeCanvas::onClipRegion(const SkRegion& region, SkRegion::Op rgnOp) { |
| 668 NOTIFY_SETUP(this); |
655 if (this->needOpBytes(region.writeToMemory(NULL))) { | 669 if (this->needOpBytes(region.writeToMemory(NULL))) { |
656 this->writeOp(kClipRegion_DrawOp, 0, rgnOp); | 670 this->writeOp(kClipRegion_DrawOp, 0, rgnOp); |
657 fWriter.writeRegion(region); | 671 fWriter.writeRegion(region); |
658 } | 672 } |
659 this->INHERITED::onClipRegion(region, rgnOp); | 673 this->INHERITED::onClipRegion(region, rgnOp); |
660 } | 674 } |
661 | 675 |
662 /////////////////////////////////////////////////////////////////////////////// | 676 /////////////////////////////////////////////////////////////////////////////// |
663 | 677 |
664 void SkGPipeCanvas::clear(SkColor color) { | 678 void SkGPipeCanvas::clear(SkColor color) { |
| 679 NOTIFY_SETUP(this); |
665 unsigned flags = 0; | 680 unsigned flags = 0; |
666 if (color) { | 681 if (color) { |
667 flags |= kClear_HasColor_DrawOpFlag; | 682 flags |= kClear_HasColor_DrawOpFlag; |
668 } | 683 } |
669 if (this->needOpBytes(sizeof(SkColor))) { | 684 if (this->needOpBytes(sizeof(SkColor))) { |
670 this->writeOp(kDrawClear_DrawOp, flags, 0); | 685 this->writeOp(kDrawClear_DrawOp, flags, 0); |
671 if (color) { | 686 if (color) { |
672 fWriter.write32(color); | 687 fWriter.write32(color); |
673 } | 688 } |
674 } | 689 } |
675 } | 690 } |
676 | 691 |
677 void SkGPipeCanvas::drawPaint(const SkPaint& paint) { | 692 void SkGPipeCanvas::drawPaint(const SkPaint& paint) { |
| 693 NOTIFY_SETUP(this); |
678 this->writePaint(paint); | 694 this->writePaint(paint); |
679 if (this->needOpBytes()) { | 695 if (this->needOpBytes()) { |
680 this->writeOp(kDrawPaint_DrawOp); | 696 this->writeOp(kDrawPaint_DrawOp); |
681 } | 697 } |
682 } | 698 } |
683 | 699 |
684 void SkGPipeCanvas::drawPoints(PointMode mode, size_t count, | 700 void SkGPipeCanvas::drawPoints(PointMode mode, size_t count, |
685 const SkPoint pts[], const SkPaint& paint) { | 701 const SkPoint pts[], const SkPaint& paint) { |
686 if (count) { | 702 if (count) { |
| 703 NOTIFY_SETUP(this); |
687 this->writePaint(paint); | 704 this->writePaint(paint); |
688 if (this->needOpBytes(4 + count * sizeof(SkPoint))) { | 705 if (this->needOpBytes(4 + count * sizeof(SkPoint))) { |
689 this->writeOp(kDrawPoints_DrawOp, mode, 0); | 706 this->writeOp(kDrawPoints_DrawOp, mode, 0); |
690 fWriter.write32(SkToU32(count)); | 707 fWriter.write32(SkToU32(count)); |
691 fWriter.write(pts, count * sizeof(SkPoint)); | 708 fWriter.write(pts, count * sizeof(SkPoint)); |
692 } | 709 } |
693 } | 710 } |
694 } | 711 } |
695 | 712 |
696 void SkGPipeCanvas::drawOval(const SkRect& rect, const SkPaint& paint) { | 713 void SkGPipeCanvas::drawOval(const SkRect& rect, const SkPaint& paint) { |
| 714 NOTIFY_SETUP(this); |
697 this->writePaint(paint); | 715 this->writePaint(paint); |
698 if (this->needOpBytes(sizeof(SkRect))) { | 716 if (this->needOpBytes(sizeof(SkRect))) { |
699 this->writeOp(kDrawOval_DrawOp); | 717 this->writeOp(kDrawOval_DrawOp); |
700 fWriter.writeRect(rect); | 718 fWriter.writeRect(rect); |
701 } | 719 } |
702 } | 720 } |
703 | 721 |
704 void SkGPipeCanvas::drawRect(const SkRect& rect, const SkPaint& paint) { | 722 void SkGPipeCanvas::drawRect(const SkRect& rect, const SkPaint& paint) { |
| 723 NOTIFY_SETUP(this); |
705 this->writePaint(paint); | 724 this->writePaint(paint); |
706 if (this->needOpBytes(sizeof(SkRect))) { | 725 if (this->needOpBytes(sizeof(SkRect))) { |
707 this->writeOp(kDrawRect_DrawOp); | 726 this->writeOp(kDrawRect_DrawOp); |
708 fWriter.writeRect(rect); | 727 fWriter.writeRect(rect); |
709 } | 728 } |
710 } | 729 } |
711 | 730 |
712 void SkGPipeCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) { | 731 void SkGPipeCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) { |
| 732 NOTIFY_SETUP(this); |
713 this->writePaint(paint); | 733 this->writePaint(paint); |
714 if (this->needOpBytes(kSizeOfFlatRRect)) { | 734 if (this->needOpBytes(kSizeOfFlatRRect)) { |
715 this->writeOp(kDrawRRect_DrawOp); | 735 this->writeOp(kDrawRRect_DrawOp); |
716 fWriter.writeRRect(rrect); | 736 fWriter.writeRRect(rrect); |
717 } | 737 } |
718 } | 738 } |
719 | 739 |
720 void SkGPipeCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, | 740 void SkGPipeCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, |
721 const SkPaint& paint) { | 741 const SkPaint& paint) { |
| 742 NOTIFY_SETUP(this); |
722 this->writePaint(paint); | 743 this->writePaint(paint); |
723 if (this->needOpBytes(kSizeOfFlatRRect * 2)) { | 744 if (this->needOpBytes(kSizeOfFlatRRect * 2)) { |
724 this->writeOp(kDrawDRRect_DrawOp); | 745 this->writeOp(kDrawDRRect_DrawOp); |
725 fWriter.writeRRect(outer); | 746 fWriter.writeRRect(outer); |
726 fWriter.writeRRect(inner); | 747 fWriter.writeRRect(inner); |
727 } | 748 } |
728 } | 749 } |
729 | 750 |
730 void SkGPipeCanvas::drawPath(const SkPath& path, const SkPaint& paint) { | 751 void SkGPipeCanvas::drawPath(const SkPath& path, const SkPaint& paint) { |
| 752 NOTIFY_SETUP(this); |
731 this->writePaint(paint); | 753 this->writePaint(paint); |
732 if (this->needOpBytes(path.writeToMemory(NULL))) { | 754 if (this->needOpBytes(path.writeToMemory(NULL))) { |
733 this->writeOp(kDrawPath_DrawOp); | 755 this->writeOp(kDrawPath_DrawOp); |
734 fWriter.writePath(path); | 756 fWriter.writePath(path); |
735 } | 757 } |
736 } | 758 } |
737 | 759 |
738 bool SkGPipeCanvas::commonDrawBitmap(const SkBitmap& bm, DrawOps op, | 760 bool SkGPipeCanvas::commonDrawBitmap(const SkBitmap& bm, DrawOps op, |
739 unsigned flags, | 761 unsigned flags, |
740 size_t opBytesNeeded, | 762 size_t opBytesNeeded, |
741 const SkPaint* paint) { | 763 const SkPaint* paint) { |
742 if (fDone) { | |
743 return false; | |
744 } | |
745 | |
746 if (paint != NULL) { | 764 if (paint != NULL) { |
747 flags |= kDrawBitmap_HasPaint_DrawOpFlag; | 765 flags |= kDrawBitmap_HasPaint_DrawOpFlag; |
748 this->writePaint(*paint); | 766 this->writePaint(*paint); |
749 } | 767 } |
750 | |
751 // This needs to run first so its calls to needOpBytes() and writes | |
752 // don't interlace with the needOpBytes() and writes below. | |
753 SkASSERT(fBitmapHeap != NULL); | |
754 int32_t bitmapIndex = fBitmapHeap->insert(bm); | |
755 if (SkBitmapHeap::INVALID_SLOT == bitmapIndex) { | |
756 return false; | |
757 } | |
758 | |
759 if (this->needOpBytes(opBytesNeeded)) { | 768 if (this->needOpBytes(opBytesNeeded)) { |
| 769 SkASSERT(fBitmapHeap != NULL); |
| 770 int32_t bitmapIndex = fBitmapHeap->insert(bm); |
| 771 if (SkBitmapHeap::INVALID_SLOT == bitmapIndex) { |
| 772 return false; |
| 773 } |
760 this->writeOp(op, flags, bitmapIndex); | 774 this->writeOp(op, flags, bitmapIndex); |
761 return true; | 775 return true; |
762 } | 776 } |
763 return false; | 777 return false; |
764 } | 778 } |
765 | 779 |
766 void SkGPipeCanvas::drawBitmap(const SkBitmap& bm, SkScalar left, SkScalar top, | 780 void SkGPipeCanvas::drawBitmap(const SkBitmap& bm, SkScalar left, SkScalar top, |
767 const SkPaint* paint) { | 781 const SkPaint* paint) { |
| 782 NOTIFY_SETUP(this); |
768 size_t opBytesNeeded = sizeof(SkScalar) * 2; | 783 size_t opBytesNeeded = sizeof(SkScalar) * 2; |
769 | 784 |
770 if (this->commonDrawBitmap(bm, kDrawBitmap_DrawOp, 0, opBytesNeeded, paint))
{ | 785 if (this->commonDrawBitmap(bm, kDrawBitmap_DrawOp, 0, opBytesNeeded, paint))
{ |
771 fWriter.writeScalar(left); | 786 fWriter.writeScalar(left); |
772 fWriter.writeScalar(top); | 787 fWriter.writeScalar(top); |
773 } | 788 } |
774 } | 789 } |
775 | 790 |
776 void SkGPipeCanvas::drawBitmapRectToRect(const SkBitmap& bm, const SkRect* src, | 791 void SkGPipeCanvas::drawBitmapRectToRect(const SkBitmap& bm, const SkRect* src, |
777 const SkRect& dst, const SkPaint* paint
, | 792 const SkRect& dst, const SkPaint* paint
, |
778 DrawBitmapRectFlags dbmrFlags) { | 793 DrawBitmapRectFlags dbmrFlags) { |
| 794 NOTIFY_SETUP(this); |
779 size_t opBytesNeeded = sizeof(SkRect); | 795 size_t opBytesNeeded = sizeof(SkRect); |
780 bool hasSrc = src != NULL; | 796 bool hasSrc = src != NULL; |
781 unsigned flags; | 797 unsigned flags; |
782 if (hasSrc) { | 798 if (hasSrc) { |
783 flags = kDrawBitmap_HasSrcRect_DrawOpFlag; | 799 flags = kDrawBitmap_HasSrcRect_DrawOpFlag; |
784 opBytesNeeded += sizeof(int32_t) * 4; | 800 opBytesNeeded += sizeof(int32_t) * 4; |
785 } else { | 801 } else { |
786 flags = 0; | 802 flags = 0; |
787 } | 803 } |
788 if (dbmrFlags & kBleed_DrawBitmapRectFlag) { | 804 if (dbmrFlags & kBleed_DrawBitmapRectFlag) { |
789 flags |= kDrawBitmap_Bleed_DrawOpFlag; | 805 flags |= kDrawBitmap_Bleed_DrawOpFlag; |
790 } | 806 } |
791 | 807 |
792 if (this->commonDrawBitmap(bm, kDrawBitmapRectToRect_DrawOp, flags, opBytesN
eeded, paint)) { | 808 if (this->commonDrawBitmap(bm, kDrawBitmapRectToRect_DrawOp, flags, opBytesN
eeded, paint)) { |
793 if (hasSrc) { | 809 if (hasSrc) { |
794 fWriter.writeRect(*src); | 810 fWriter.writeRect(*src); |
795 } | 811 } |
796 fWriter.writeRect(dst); | 812 fWriter.writeRect(dst); |
797 } | 813 } |
798 } | 814 } |
799 | 815 |
800 void SkGPipeCanvas::drawBitmapMatrix(const SkBitmap& bm, const SkMatrix& matrix, | 816 void SkGPipeCanvas::drawBitmapMatrix(const SkBitmap& bm, const SkMatrix& matrix, |
801 const SkPaint* paint) { | 817 const SkPaint* paint) { |
| 818 NOTIFY_SETUP(this); |
802 size_t opBytesNeeded = matrix.writeToMemory(NULL); | 819 size_t opBytesNeeded = matrix.writeToMemory(NULL); |
803 | 820 |
804 if (this->commonDrawBitmap(bm, kDrawBitmapMatrix_DrawOp, 0, opBytesNeeded, p
aint)) { | 821 if (this->commonDrawBitmap(bm, kDrawBitmapMatrix_DrawOp, 0, opBytesNeeded, p
aint)) { |
805 fWriter.writeMatrix(matrix); | 822 fWriter.writeMatrix(matrix); |
806 } | 823 } |
807 } | 824 } |
808 | 825 |
809 void SkGPipeCanvas::drawBitmapNine(const SkBitmap& bm, const SkIRect& center, | 826 void SkGPipeCanvas::drawBitmapNine(const SkBitmap& bm, const SkIRect& center, |
810 const SkRect& dst, const SkPaint* paint) { | 827 const SkRect& dst, const SkPaint* paint) { |
| 828 NOTIFY_SETUP(this); |
811 size_t opBytesNeeded = sizeof(int32_t) * 4 + sizeof(SkRect); | 829 size_t opBytesNeeded = sizeof(int32_t) * 4 + sizeof(SkRect); |
812 | 830 |
813 if (this->commonDrawBitmap(bm, kDrawBitmapNine_DrawOp, 0, opBytesNeeded, pai
nt)) { | 831 if (this->commonDrawBitmap(bm, kDrawBitmapNine_DrawOp, 0, opBytesNeeded, pai
nt)) { |
814 fWriter.write32(center.fLeft); | 832 fWriter.write32(center.fLeft); |
815 fWriter.write32(center.fTop); | 833 fWriter.write32(center.fTop); |
816 fWriter.write32(center.fRight); | 834 fWriter.write32(center.fRight); |
817 fWriter.write32(center.fBottom); | 835 fWriter.write32(center.fBottom); |
818 fWriter.writeRect(dst); | 836 fWriter.writeRect(dst); |
819 } | 837 } |
820 } | 838 } |
821 | 839 |
822 void SkGPipeCanvas::drawSprite(const SkBitmap& bm, int left, int top, | 840 void SkGPipeCanvas::drawSprite(const SkBitmap& bm, int left, int top, |
823 const SkPaint* paint) { | 841 const SkPaint* paint) { |
| 842 NOTIFY_SETUP(this); |
824 size_t opBytesNeeded = sizeof(int32_t) * 2; | 843 size_t opBytesNeeded = sizeof(int32_t) * 2; |
825 | 844 |
826 if (this->commonDrawBitmap(bm, kDrawSprite_DrawOp, 0, opBytesNeeded, paint))
{ | 845 if (this->commonDrawBitmap(bm, kDrawSprite_DrawOp, 0, opBytesNeeded, paint))
{ |
827 fWriter.write32(left); | 846 fWriter.write32(left); |
828 fWriter.write32(top); | 847 fWriter.write32(top); |
829 } | 848 } |
830 } | 849 } |
831 | 850 |
832 void SkGPipeCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x,
SkScalar y, | 851 void SkGPipeCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x,
SkScalar y, |
833 const SkPaint& paint) { | 852 const SkPaint& paint) { |
834 if (byteLength) { | 853 if (byteLength) { |
| 854 NOTIFY_SETUP(this); |
835 this->writePaint(paint); | 855 this->writePaint(paint); |
836 if (this->needOpBytes(4 + SkAlign4(byteLength) + 2 * sizeof(SkScalar)))
{ | 856 if (this->needOpBytes(4 + SkAlign4(byteLength) + 2 * sizeof(SkScalar)))
{ |
837 this->writeOp(kDrawText_DrawOp); | 857 this->writeOp(kDrawText_DrawOp); |
838 fWriter.write32(SkToU32(byteLength)); | 858 fWriter.write32(SkToU32(byteLength)); |
839 fWriter.writePad(text, byteLength); | 859 fWriter.writePad(text, byteLength); |
840 fWriter.writeScalar(x); | 860 fWriter.writeScalar(x); |
841 fWriter.writeScalar(y); | 861 fWriter.writeScalar(y); |
842 } | 862 } |
843 } | 863 } |
844 } | 864 } |
845 | 865 |
846 void SkGPipeCanvas::onDrawPosText(const void* text, size_t byteLength, const SkP
oint pos[], | 866 void SkGPipeCanvas::onDrawPosText(const void* text, size_t byteLength, const SkP
oint pos[], |
847 const SkPaint& paint) { | 867 const SkPaint& paint) { |
848 if (byteLength) { | 868 if (byteLength) { |
| 869 NOTIFY_SETUP(this); |
849 this->writePaint(paint); | 870 this->writePaint(paint); |
850 int count = paint.textToGlyphs(text, byteLength, NULL); | 871 int count = paint.textToGlyphs(text, byteLength, NULL); |
851 if (this->needOpBytes(4 + SkAlign4(byteLength) + 4 + count * sizeof(SkPo
int))) { | 872 if (this->needOpBytes(4 + SkAlign4(byteLength) + 4 + count * sizeof(SkPo
int))) { |
852 this->writeOp(kDrawPosText_DrawOp); | 873 this->writeOp(kDrawPosText_DrawOp); |
853 fWriter.write32(SkToU32(byteLength)); | 874 fWriter.write32(SkToU32(byteLength)); |
854 fWriter.writePad(text, byteLength); | 875 fWriter.writePad(text, byteLength); |
855 fWriter.write32(count); | 876 fWriter.write32(count); |
856 fWriter.write(pos, count * sizeof(SkPoint)); | 877 fWriter.write(pos, count * sizeof(SkPoint)); |
857 } | 878 } |
858 } | 879 } |
859 } | 880 } |
860 | 881 |
861 void SkGPipeCanvas::onDrawPosTextH(const void* text, size_t byteLength, const Sk
Scalar xpos[], | 882 void SkGPipeCanvas::onDrawPosTextH(const void* text, size_t byteLength, const Sk
Scalar xpos[], |
862 SkScalar constY, const SkPaint& paint) { | 883 SkScalar constY, const SkPaint& paint) { |
863 if (byteLength) { | 884 if (byteLength) { |
| 885 NOTIFY_SETUP(this); |
864 this->writePaint(paint); | 886 this->writePaint(paint); |
865 int count = paint.textToGlyphs(text, byteLength, NULL); | 887 int count = paint.textToGlyphs(text, byteLength, NULL); |
866 if (this->needOpBytes(4 + SkAlign4(byteLength) + 4 + count * sizeof(SkSc
alar) + 4)) { | 888 if (this->needOpBytes(4 + SkAlign4(byteLength) + 4 + count * sizeof(SkSc
alar) + 4)) { |
867 this->writeOp(kDrawPosTextH_DrawOp); | 889 this->writeOp(kDrawPosTextH_DrawOp); |
868 fWriter.write32(SkToU32(byteLength)); | 890 fWriter.write32(SkToU32(byteLength)); |
869 fWriter.writePad(text, byteLength); | 891 fWriter.writePad(text, byteLength); |
870 fWriter.write32(count); | 892 fWriter.write32(count); |
871 fWriter.write(xpos, count * sizeof(SkScalar)); | 893 fWriter.write(xpos, count * sizeof(SkScalar)); |
872 fWriter.writeScalar(constY); | 894 fWriter.writeScalar(constY); |
873 } | 895 } |
874 } | 896 } |
875 } | 897 } |
876 | 898 |
877 void SkGPipeCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const
SkPath& path, | 899 void SkGPipeCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const
SkPath& path, |
878 const SkMatrix* matrix, const SkPaint& pain
t) { | 900 const SkMatrix* matrix, const SkPaint& pain
t) { |
879 if (byteLength) { | 901 if (byteLength) { |
| 902 NOTIFY_SETUP(this); |
880 unsigned flags = 0; | 903 unsigned flags = 0; |
881 size_t size = 4 + SkAlign4(byteLength) + path.writeToMemory(NULL); | 904 size_t size = 4 + SkAlign4(byteLength) + path.writeToMemory(NULL); |
882 if (matrix) { | 905 if (matrix) { |
883 flags |= kDrawTextOnPath_HasMatrix_DrawOpFlag; | 906 flags |= kDrawTextOnPath_HasMatrix_DrawOpFlag; |
884 size += matrix->writeToMemory(NULL); | 907 size += matrix->writeToMemory(NULL); |
885 } | 908 } |
886 this->writePaint(paint); | 909 this->writePaint(paint); |
887 if (this->needOpBytes(size)) { | 910 if (this->needOpBytes(size)) { |
888 this->writeOp(kDrawTextOnPath_DrawOp, flags, 0); | 911 this->writeOp(kDrawTextOnPath_DrawOp, flags, 0); |
889 | 912 |
(...skipping 15 matching lines...) Expand all Loading... |
905 | 928 |
906 void SkGPipeCanvas::drawVertices(VertexMode vmode, int vertexCount, | 929 void SkGPipeCanvas::drawVertices(VertexMode vmode, int vertexCount, |
907 const SkPoint vertices[], const SkPoint texs[], | 930 const SkPoint vertices[], const SkPoint texs[], |
908 const SkColor colors[], SkXfermode* xfer, | 931 const SkColor colors[], SkXfermode* xfer, |
909 const uint16_t indices[], int indexCount, | 932 const uint16_t indices[], int indexCount, |
910 const SkPaint& paint) { | 933 const SkPaint& paint) { |
911 if (0 == vertexCount) { | 934 if (0 == vertexCount) { |
912 return; | 935 return; |
913 } | 936 } |
914 | 937 |
| 938 NOTIFY_SETUP(this); |
| 939 size_t size = 4 + vertexCount * sizeof(SkPoint); |
915 this->writePaint(paint); | 940 this->writePaint(paint); |
916 | 941 unsigned flags = 0; |
917 unsigned flags = 0; // flags pack with the op, so don't need extra space th
emselves | |
918 | |
919 size_t size = 0; | |
920 size += 4; // vmode | |
921 size += 4; // vertexCount | |
922 size += vertexCount * sizeof(SkPoint); // vertices | |
923 if (texs) { | 942 if (texs) { |
924 flags |= kDrawVertices_HasTexs_DrawOpFlag; | 943 flags |= kDrawVertices_HasTexs_DrawOpFlag; |
925 size += vertexCount * sizeof(SkPoint); | 944 size += vertexCount * sizeof(SkPoint); |
926 } | 945 } |
927 if (colors) { | 946 if (colors) { |
928 flags |= kDrawVertices_HasColors_DrawOpFlag; | 947 flags |= kDrawVertices_HasColors_DrawOpFlag; |
929 size += vertexCount * sizeof(SkColor); | 948 size += vertexCount * sizeof(SkColor); |
930 } | 949 } |
| 950 if (indices && indexCount > 0) { |
| 951 flags |= kDrawVertices_HasIndices_DrawOpFlag; |
| 952 size += 4 + SkAlign4(indexCount * sizeof(uint16_t)); |
| 953 } |
931 if (xfer && !SkXfermode::IsMode(xfer, SkXfermode::kModulate_Mode)) { | 954 if (xfer && !SkXfermode::IsMode(xfer, SkXfermode::kModulate_Mode)) { |
932 flags |= kDrawVertices_HasXfermode_DrawOpFlag; | 955 flags |= kDrawVertices_HasXfermode_DrawOpFlag; |
933 size += sizeof(int32_t); // SkXfermode::Mode | 956 size += sizeof(int32_t); // mode enum |
934 } | |
935 if (indices && indexCount > 0) { | |
936 flags |= kDrawVertices_HasIndices_DrawOpFlag; | |
937 size += 4; // indexCount | |
938 size += SkAlign4(indexCount * sizeof(uint16_t)); // indices | |
939 } | 957 } |
940 | 958 |
941 if (this->needOpBytes(size)) { | 959 if (this->needOpBytes(size)) { |
942 this->writeOp(kDrawVertices_DrawOp, flags, 0); | 960 this->writeOp(kDrawVertices_DrawOp, flags, 0); |
943 fWriter.write32(vmode); | 961 fWriter.write32(vmode); |
944 fWriter.write32(vertexCount); | 962 fWriter.write32(vertexCount); |
945 fWriter.write(vertices, vertexCount * sizeof(SkPoint)); | 963 fWriter.write(vertices, vertexCount * sizeof(SkPoint)); |
946 if (flags & kDrawVertices_HasTexs_DrawOpFlag) { | 964 if (texs) { |
947 fWriter.write(texs, vertexCount * sizeof(SkPoint)); | 965 fWriter.write(texs, vertexCount * sizeof(SkPoint)); |
948 } | 966 } |
949 if (flags & kDrawVertices_HasColors_DrawOpFlag) { | 967 if (colors) { |
950 fWriter.write(colors, vertexCount * sizeof(SkColor)); | 968 fWriter.write(colors, vertexCount * sizeof(SkColor)); |
951 } | 969 } |
952 if (flags & kDrawVertices_HasXfermode_DrawOpFlag) { | 970 if (flags & kDrawVertices_HasXfermode_DrawOpFlag) { |
953 SkXfermode::Mode mode = SkXfermode::kModulate_Mode; | 971 SkXfermode::Mode mode = SkXfermode::kModulate_Mode; |
954 SkAssertResult(xfer->asMode(&mode)); | 972 (void)xfer->asMode(&mode); |
955 fWriter.write32(mode); | 973 fWriter.write32(mode); |
956 } | 974 } |
957 if (flags & kDrawVertices_HasIndices_DrawOpFlag) { | 975 if (indices && indexCount > 0) { |
958 fWriter.write32(indexCount); | 976 fWriter.write32(indexCount); |
959 fWriter.writePad(indices, indexCount * sizeof(uint16_t)); | 977 fWriter.writePad(indices, indexCount * sizeof(uint16_t)); |
960 } | 978 } |
961 } | 979 } |
962 } | 980 } |
963 | 981 |
964 void SkGPipeCanvas::drawData(const void* ptr, size_t size) { | 982 void SkGPipeCanvas::drawData(const void* ptr, size_t size) { |
965 if (size && ptr) { | 983 if (size && ptr) { |
| 984 NOTIFY_SETUP(this); |
966 unsigned data = 0; | 985 unsigned data = 0; |
967 if (size < (1 << DRAWOPS_DATA_BITS)) { | 986 if (size < (1 << DRAWOPS_DATA_BITS)) { |
968 data = (unsigned)size; | 987 data = (unsigned)size; |
969 } | 988 } |
970 if (this->needOpBytes(4 + SkAlign4(size))) { | 989 if (this->needOpBytes(4 + SkAlign4(size))) { |
971 this->writeOp(kDrawData_DrawOp, 0, data); | 990 this->writeOp(kDrawData_DrawOp, 0, data); |
972 if (0 == data) { | 991 if (0 == data) { |
973 fWriter.write32(SkToU32(size)); | 992 fWriter.write32(SkToU32(size)); |
974 } | 993 } |
975 fWriter.writePad(ptr, size); | 994 fWriter.writePad(ptr, size); |
976 } | 995 } |
977 } | 996 } |
978 } | 997 } |
979 | 998 |
980 void SkGPipeCanvas::beginCommentGroup(const char* description) { | 999 void SkGPipeCanvas::beginCommentGroup(const char* description) { |
981 // ignore for now | 1000 // ignore for now |
982 } | 1001 } |
983 | 1002 |
984 void SkGPipeCanvas::addComment(const char* kywd, const char* value) { | 1003 void SkGPipeCanvas::addComment(const char* kywd, const char* value) { |
985 // ignore for now | 1004 // ignore for now |
986 } | 1005 } |
987 | 1006 |
988 void SkGPipeCanvas::endCommentGroup() { | 1007 void SkGPipeCanvas::endCommentGroup() { |
989 // ignore for now | 1008 // ignore for now |
990 } | 1009 } |
991 | 1010 |
992 void SkGPipeCanvas::flushRecording(bool detachCurrentBlock) { | 1011 void SkGPipeCanvas::flushRecording(bool detachCurrentBlock) { |
993 this->doNotify(); | 1012 doNotify(); |
994 if (detachCurrentBlock) { | 1013 if (detachCurrentBlock) { |
995 // force a new block to be requested for the next recorded command | 1014 // force a new block to be requested for the next recorded command |
996 fBlockSize = 0; | 1015 fBlockSize = 0; |
997 } | 1016 } |
998 } | 1017 } |
999 | 1018 |
1000 size_t SkGPipeCanvas::freeMemoryIfPossible(size_t bytesToFree) { | 1019 size_t SkGPipeCanvas::freeMemoryIfPossible(size_t bytesToFree) { |
1001 return (NULL == fBitmapHeap) ? 0 : fBitmapHeap->freeMemoryIfPossible(bytesTo
Free); | 1020 return (NULL == fBitmapHeap) ? 0 : fBitmapHeap->freeMemoryIfPossible(bytesTo
Free); |
1002 } | 1021 } |
1003 | 1022 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1223 return fCanvas->shuttleBitmap(bitmap, slot); | 1242 return fCanvas->shuttleBitmap(bitmap, slot); |
1224 } | 1243 } |
1225 | 1244 |
1226 void BitmapShuttle::removeCanvas() { | 1245 void BitmapShuttle::removeCanvas() { |
1227 if (NULL == fCanvas) { | 1246 if (NULL == fCanvas) { |
1228 return; | 1247 return; |
1229 } | 1248 } |
1230 fCanvas->unref(); | 1249 fCanvas->unref(); |
1231 fCanvas = NULL; | 1250 fCanvas = NULL; |
1232 } | 1251 } |
OLD | NEW |