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

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

Issue 267293007: Fix rendering artifacts in pull-saveLayers-forward mode (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Fix bug in unit test Created 6 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
« no previous file with comments | « src/core/SkPicturePlayback.h ('k') | src/core/SkPictureStateTree.h » ('j') | 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 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 #include <new> 7 #include <new>
8 #include "SkBBoxHierarchy.h" 8 #include "SkBBoxHierarchy.h"
9 #include "SkPicturePlayback.h" 9 #include "SkPicturePlayback.h"
10 #include "SkPictureRecord.h" 10 #include "SkPictureRecord.h"
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 } 889 }
890 } 890 }
891 891
892 if (NULL != fReplacements) { 892 if (NULL != fReplacements) {
893 // Potentially replace a block of operations with a single drawBitma p call 893 // Potentially replace a block of operations with a single drawBitma p call
894 SkPicturePlayback::PlaybackReplacements::ReplacementInfo* temp = 894 SkPicturePlayback::PlaybackReplacements::ReplacementInfo* temp =
895 fReplacements->lookupByStart(reader. offset()); 895 fReplacements->lookupByStart(reader. offset());
896 if (NULL != temp) { 896 if (NULL != temp) {
897 SkASSERT(NULL != temp->fBM); 897 SkASSERT(NULL != temp->fBM);
898 SkASSERT(NULL != temp->fPaint); 898 SkASSERT(NULL != temp->fPaint);
899 canvas.save();
900 canvas.setMatrix(initialMatrix);
899 canvas.drawBitmap(*temp->fBM, temp->fPos.fX, temp->fPos.fY, temp ->fPaint); 901 canvas.drawBitmap(*temp->fBM, temp->fPos.fX, temp->fPos.fY, temp ->fPaint);
902 canvas.restore();
900 903
901 if (it.isValid()) { 904 if (it.isValid()) {
902 // This save is needed since the BBH will automatically issu e 905 // This save is needed since the BBH will automatically issu e
903 // a restore to balanced the saveLayer we're skipping 906 // a restore to balanced the saveLayer we're skipping
904 canvas.save(); 907 canvas.save();
905 // Note: This skipping only works if the client only issues
906 // well behaved saveLayer calls (i.e., doesn't use
907 // kMatrix_SaveFlag or kClip_SaveFlag in isolation)
908 908
909 // At this point we know that the PictureStateTree was aimin g 909 // At this point we know that the PictureStateTree was aimin g
910 // for some draw op within temp's saveLayer (although potent ially 910 // for some draw op within temp's saveLayer (although potent ially
911 // in a separate saveLayer nested inside it). 911 // in a separate saveLayer nested inside it).
912 // We need to skip all the operations inside temp's range 912 // We need to skip all the operations inside temp's range
913 // along with all the associated state changes but update 913 // along with all the associated state changes but update
914 // the state tree to the first operation outside temp's rang e. 914 // the state tree to the first operation outside temp's rang e.
915 SkASSERT(it.peekDraw() >= temp->fStart && it.peekDraw() <= t emp->fStop);
916 915
917 while (kDrawComplete != it.peekDraw() && it.peekDraw() <= te mp->fStop) { 916 uint32_t skipTo;
918 it.skipDraw(); 917 do {
919 } 918 skipTo = it.nextDraw();
919 if (kDrawComplete == skipTo) {
920 break;
921 }
920 922
921 if (kDrawComplete == it.peekDraw()) { 923 if (skipTo <= temp->fStop) {
924 reader.setOffset(skipTo);
925 uint32_t size;
926 DrawType op = read_op_and_size(&reader, &size);
927 // Since we are relying on the normal SkPictureState Tree
928 // playback we need to convert any nested saveLayer calls
929 // it may issue into saves (so that all its internal
930 // restores will be balanced).
931 if (SAVE_LAYER == op) {
932 canvas.save();
933 }
934 }
935 } while (skipTo <= temp->fStop);
936
937 if (kDrawComplete == skipTo) {
922 break; 938 break;
923 } 939 }
924 940
925 uint32_t skipTo = it.nextDraw();
926 reader.setOffset(skipTo); 941 reader.setOffset(skipTo);
927 } else { 942 } else {
928 reader.setOffset(temp->fStop); 943 reader.setOffset(temp->fStop);
929 uint32_t size; 944 uint32_t size;
930 SkDEBUGCODE(DrawType op =) read_op_and_size(&reader, &size); 945 SkDEBUGCODE(DrawType op =) read_op_and_size(&reader, &size);
931 SkASSERT(RESTORE == op); 946 SkASSERT(RESTORE == op);
932 } 947 }
933 continue; 948 continue;
934 } 949 }
935 } 950 }
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 for (index = 0; index < fPictureCount; index++) 1838 for (index = 0; index < fPictureCount; index++)
1824 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ), 1839 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ),
1825 "picture%p, ", fPictureRefs[index]); 1840 "picture%p, ", fPictureRefs[index]);
1826 if (fPictureCount > 0) 1841 if (fPictureCount > 0)
1827 SkDebugf("%s0};\n", pBuffer); 1842 SkDebugf("%s0};\n", pBuffer);
1828 1843
1829 const_cast<SkPicturePlayback*>(this)->dumpStream(); 1844 const_cast<SkPicturePlayback*>(this)->dumpStream();
1830 } 1845 }
1831 1846
1832 #endif 1847 #endif
OLDNEW
« no previous file with comments | « src/core/SkPicturePlayback.h ('k') | src/core/SkPictureStateTree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698