Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(541)

Side by Side Diff: src/core/SkPicturePlayback.cpp

Issue 14598023: add SkDrawPictureCallback optional parameter to drawPicture(), which can abort the picture drawing. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« include/core/SkPicture.h ('K') | « src/core/SkPicturePlayback.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "SkPicturePlayback.h" 8 #include "SkPicturePlayback.h"
9 #include "SkPictureRecord.h" 9 #include "SkPictureRecord.h"
10 #include "SkTypeface.h" 10 #include "SkTypeface.h"
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 *size = 0; 649 *size = 0;
650 } else { 650 } else {
651 UNPACK_8_24(temp, op, *size); 651 UNPACK_8_24(temp, op, *size);
652 if (MASK_24 == *size) { 652 if (MASK_24 == *size) {
653 *size = reader->readInt(); 653 *size = reader->readInt();
654 } 654 }
655 } 655 }
656 return (DrawType) op; 656 return (DrawType) op;
657 } 657 }
658 658
659 void SkPicturePlayback::draw(SkCanvas& canvas) { 659 void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback) {
660 #ifdef ENABLE_TIME_DRAW 660 #ifdef ENABLE_TIME_DRAW
661 SkAutoTime at("SkPicture::draw", 50); 661 SkAutoTime at("SkPicture::draw", 50);
662 #endif 662 #endif
663 663
664 #ifdef SPEW_CLIP_SKIPPING 664 #ifdef SPEW_CLIP_SKIPPING
665 SkipClipRec skipRect, skipRRect, skipRegion, skipPath; 665 SkipClipRec skipRect, skipRRect, skipRegion, skipPath;
666 #endif 666 #endif
667 667
668 #ifdef SK_BUILD_FOR_ANDROID 668 #ifdef SK_BUILD_FOR_ANDROID
669 SkAutoMutexAcquire autoMutex(fDrawMutex); 669 SkAutoMutexAcquire autoMutex(fDrawMutex);
(...skipping 29 matching lines...) Expand all
699 if (it.isValid()) { 699 if (it.isValid()) {
700 uint32_t skipTo = it.draw(); 700 uint32_t skipTo = it.draw();
701 if (kDrawComplete == skipTo) { 701 if (kDrawComplete == skipTo) {
702 return; 702 return;
703 } 703 }
704 reader.setOffset(skipTo); 704 reader.setOffset(skipTo);
705 } 705 }
706 706
707 // Record this, so we can concat w/ it if we encounter a setMatrix() 707 // Record this, so we can concat w/ it if we encounter a setMatrix()
708 SkMatrix initialMatrix = canvas.getTotalMatrix(); 708 SkMatrix initialMatrix = canvas.getTotalMatrix();
709 int originalSaveCount = canvas.getSaveCount();
709 710
710 #ifdef SK_BUILD_FOR_ANDROID 711 #ifdef SK_BUILD_FOR_ANDROID
711 fAbortCurrentPlayback = false; 712 fAbortCurrentPlayback = false;
712 #endif 713 #endif
713 714
714 while (!reader.eof()) { 715 while (!reader.eof()) {
716 if (callback && callback->abortDrawing()) {
717 canvas.restoreToCount(originalSaveCount);
718 return;
719 }
715 #ifdef SK_BUILD_FOR_ANDROID 720 #ifdef SK_BUILD_FOR_ANDROID
robertphillips 2013/05/16 15:04:23 can this be folded into the new system?
716 if (fAbortCurrentPlayback) { 721 if (fAbortCurrentPlayback) {
717 return; 722 return;
718 } 723 }
719 #endif 724 #endif
720 725
721 size_t curOffset = reader.offset(); 726 size_t curOffset = reader.offset();
722 uint32_t size; 727 uint32_t size;
723 DrawType op = read_op_and_size(&reader, &size); 728 DrawType op = read_op_and_size(&reader, &size);
724 size_t skipTo = 0; 729 size_t skipTo = 0;
725 #ifdef SK_DEVELOPER 730 #ifdef SK_DEVELOPER
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 for (index = 0; index < fRegionCount; index++) 1592 for (index = 0; index < fRegionCount; index++)
1588 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ), 1593 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ),
1589 "region%p, ", &fRegions[index]); 1594 "region%p, ", &fRegions[index]);
1590 if (fRegionCount > 0) 1595 if (fRegionCount > 0)
1591 SkDebugf("%s0};\n", pBuffer); 1596 SkDebugf("%s0};\n", pBuffer);
1592 1597
1593 const_cast<SkPicturePlayback*>(this)->dumpStream(); 1598 const_cast<SkPicturePlayback*>(this)->dumpStream();
1594 } 1599 }
1595 1600
1596 #endif 1601 #endif
OLDNEW
« include/core/SkPicture.h ('K') | « src/core/SkPicturePlayback.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698