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

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

Issue 227603006: hack Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: yet more hackage Created 6 years, 8 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/gpu/GrContext.cpp » ('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 "SkOffsetTable.h" 9 #include "SkOffsetTable.h"
10 #include "SkPicturePlayback.h" 10 #include "SkPicturePlayback.h"
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 ~SkAutoResetOpID() { 854 ~SkAutoResetOpID() {
855 if (NULL != fPlayback) { 855 if (NULL != fPlayback) {
856 fPlayback->resetOpID(); 856 fPlayback->resetOpID();
857 } 857 }
858 } 858 }
859 859
860 private: 860 private:
861 SkPicturePlayback* fPlayback; 861 SkPicturePlayback* fPlayback;
862 }; 862 };
863 863
864 void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback) { 864 SkPicturePlayback::Foo* SkPicturePlayback::Bar::lookupStart(size_t start) {
865 for (int i = 0; i < fFoo.count(); ++i) {
866 if (start == fFoo[i].fStart) {
867 return &fFoo[i];
868 }
869 }
870
871 return NULL;
872 }
873
874 SkPicturePlayback::Foo* SkPicturePlayback::Bar::lookupStop(size_t stop) {
875 for (int i = 0; i < fFoo.count(); ++i) {
876 if (stop == fFoo[i].fStop) {
877 return &fFoo[i];
878 }
879 }
880
881 return NULL;
882 }
883
884 void SkPicturePlayback::draw(SkCanvas& canvas,
885 int start, int stop,
886 SkDrawPictureCallback* callback,
887 Bar* foo) {
865 SkAutoResetOpID aroi(this); 888 SkAutoResetOpID aroi(this);
866 SkASSERT(0 == fCurOffset); 889 SkASSERT(0 == fCurOffset);
867 890
868 #ifdef ENABLE_TIME_DRAW 891 #ifdef ENABLE_TIME_DRAW
869 SkAutoTime at("SkPicture::draw", 50); 892 SkAutoTime at("SkPicture::draw", 50);
870 #endif 893 #endif
871 894
872 #ifdef SPEW_CLIP_SKIPPING 895 #ifdef SPEW_CLIP_SKIPPING
873 SkipClipRec skipRect, skipRRect, skipRegion, skipPath, skipCull; 896 SkipClipRec skipRect, skipRRect, skipRegion, skipPath, skipCull;
874 int opCount = 0; 897 int opCount = 0;
875 #endif 898 #endif
876 899
877 #ifdef SK_BUILD_FOR_ANDROID 900 #ifdef SK_BUILD_FOR_ANDROID
878 SkAutoMutexAcquire autoMutex(fDrawMutex); 901 SkAutoMutexAcquire autoMutex(fDrawMutex);
879 #endif 902 #endif
880 903
881 // kDrawComplete will be the signal that we have reached the end of 904 // kDrawComplete will be the signal that we have reached the end of
882 // the command stream 905 // the command stream
883 static const uint32_t kDrawComplete = SK_MaxU32; 906 static const uint32_t kDrawComplete = SK_MaxU32;
884 907
885 SkReader32 reader(fOpData->bytes(), fOpData->size()); 908 SkReader32 reader(fOpData->bytes(), fOpData->size());
886 TextContainer text; 909 TextContainer text;
887 const SkTDArray<void*>* activeOps = NULL; 910 const SkTDArray<void*>* activeOps = NULL;
888 911
889 if (NULL != fStateTree && NULL != fBoundingHierarchy) { 912 if (start == -1 ) {
890 SkRect clipBounds; 913 if (NULL != fStateTree && NULL != fBoundingHierarchy) {
891 if (canvas.getClipBounds(&clipBounds)) { 914 SkRect clipBounds;
892 SkIRect query; 915 if (canvas.getClipBounds(&clipBounds)) {
893 clipBounds.roundOut(&query); 916 SkIRect query;
917 clipBounds.roundOut(&query);
894 918
895 const SkPicture::OperationList& activeOpsList = this->getActiveOps(q uery); 919 const SkPicture::OperationList& activeOpsList = this->getActiveO ps(query);
896 if (activeOpsList.valid()) { 920 if (activeOpsList.valid()) {
897 if (0 == activeOpsList.numOps()) { 921 if (0 == activeOpsList.numOps()) {
898 return; // nothing to draw 922 return; // nothing to draw
923 }
924
925 // Since the opList is valid we know it is our derived class
926 activeOps = &((const CachedOperationList&)activeOpsList).fOp s;
899 } 927 }
900
901 // Since the opList is valid we know it is our derived class
902 activeOps = &((const CachedOperationList&)activeOpsList).fOps;
903 } 928 }
904 } 929 }
905 } 930 }
906 931
907 SkPictureStateTree::Iterator it = (NULL == activeOps) ? 932 SkPictureStateTree::Iterator it = (NULL == activeOps) ?
908 SkPictureStateTree::Iterator() : 933 SkPictureStateTree::Iterator() :
909 fStateTree->getIterator(*activeOps, &canvas); 934 fStateTree->getIterator(*activeOps, &canvas);
910 935
936 if (start != -1) {
937 reader.setOffset(start);
938 uint32_t size;
939 SkDEBUGCODE(DrawType op =) read_op_and_size(&reader, &size);
940 SkASSERT(SAVE_LAYER == op);
941 reader.setOffset(start+size);
942 }
943
911 if (it.isValid()) { 944 if (it.isValid()) {
912 uint32_t skipTo = it.draw(); 945 uint32_t skipTo = it.draw();
913 if (kDrawComplete == skipTo) { 946 if (kDrawComplete == skipTo) {
914 return; 947 return;
915 } 948 }
916 reader.setOffset(skipTo); 949 reader.setOffset(skipTo);
917 } 950 }
918 951
919 this->preLoadBitmaps(activeOps); 952 this->preLoadBitmaps(activeOps);
920 953
(...skipping 12 matching lines...) Expand all
933 while (!reader.eof()) { 966 while (!reader.eof()) {
934 if (callback && callback->abortDrawing()) { 967 if (callback && callback->abortDrawing()) {
935 canvas.restoreToCount(originalSaveCount); 968 canvas.restoreToCount(originalSaveCount);
936 return; 969 return;
937 } 970 }
938 #ifdef SK_BUILD_FOR_ANDROID 971 #ifdef SK_BUILD_FOR_ANDROID
939 if (fAbortCurrentPlayback) { 972 if (fAbortCurrentPlayback) {
940 return; 973 return;
941 } 974 }
942 #endif 975 #endif
976 if (stop != -1) {
977 if (reader.offset() >= (unsigned int) stop) {
978 uint32_t size;
979 SkDEBUGCODE(DrawType op =) read_op_and_size(&reader, &size);
980 SkASSERT(RESTORE == op);
981 return;
982 }
983 }
984
985 if (NULL != foo) {
986 #if 0
987 // replace the saveLayer/restore block with a drawBitmap call
988 SkPicturePlayback::Foo* temp = foo->lookupStart(reader.offset());
989
990 if (NULL != temp) {
991 SkASSERT(NULL != temp->fBM);
992 canvas.drawBitmap(*temp->fBM, temp->fPos.fX, temp->fPos.fY, temp ->fPaint);
993
994 reader.setOffset(temp->fStop);
995 uint32_t size;
996 SkDEBUGCODE(DrawType op =) read_op_and_size(&reader, &size);
997 SkASSERT(RESTORE == op);
998 continue;
999 }
1000 #else
1001 // execute the saveLayer/restore block but follow it with a drawBitm ap call
1002 // This is intended (with conversion of saveLayers to saves) to
1003 // separate out the overhead of the saveLayer render target changes
1004 // from all the other work
1005 SkPicturePlayback::Foo* temp = foo->lookupStop(reader.offset());
1006 if (NULL != temp) {
1007 SkASSERT(NULL != temp->fBM);
1008 uint32_t size;
1009 SkDEBUGCODE(DrawType op =) read_op_and_size(&reader, &size);
1010 SkASSERT(RESTORE == op);
1011
1012 canvas.restore();
1013
1014 canvas.drawBitmap(*temp->fBM, temp->fPos.fX, temp->fPos.fY, temp ->fPaint);
1015 continue;
1016 }
1017 #endif
1018 }
943 1019
944 #ifdef SPEW_CLIP_SKIPPING 1020 #ifdef SPEW_CLIP_SKIPPING
945 opCount++; 1021 opCount++;
946 #endif 1022 #endif
947 1023
948 fCurOffset = reader.offset(); 1024 fCurOffset = reader.offset();
949 uint32_t size; 1025 uint32_t size;
950 DrawType op = read_op_and_size(&reader, &size); 1026 DrawType op = read_op_and_size(&reader, &size);
951 size_t skipTo = 0; 1027 size_t skipTo = 0;
952 if (NOOP == op) { 1028 if (NOOP == op) {
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 case RESTORE: 1341 case RESTORE:
1266 canvas.restore(); 1342 canvas.restore();
1267 break; 1343 break;
1268 case ROTATE: 1344 case ROTATE:
1269 canvas.rotate(reader.readScalar()); 1345 canvas.rotate(reader.readScalar());
1270 break; 1346 break;
1271 case SAVE: 1347 case SAVE:
1272 canvas.save((SkCanvas::SaveFlags) reader.readInt()); 1348 canvas.save((SkCanvas::SaveFlags) reader.readInt());
1273 break; 1349 break;
1274 case SAVE_LAYER: { 1350 case SAVE_LAYER: {
1351 #if 1
1275 const SkRect* boundsPtr = this->getRectPtr(reader); 1352 const SkRect* boundsPtr = this->getRectPtr(reader);
1276 const SkPaint* paint = this->getPaint(reader); 1353 const SkPaint* paint = this->getPaint(reader);
1277 canvas.saveLayer(boundsPtr, paint, (SkCanvas::SaveFlags) reader. readInt()); 1354 canvas.saveLayer(boundsPtr, paint, (SkCanvas::SaveFlags) reader. readInt());
1355 #else
1356 // replace all saveLayers with a save
1357 this->getRectPtr(reader);
1358 this->getPaint(reader);
1359 canvas.save((SkCanvas::SaveFlags) reader.readInt());
1360 #endif
1278 } break; 1361 } break;
1279 case SCALE: { 1362 case SCALE: {
1280 SkScalar sx = reader.readScalar(); 1363 SkScalar sx = reader.readScalar();
1281 SkScalar sy = reader.readScalar(); 1364 SkScalar sy = reader.readScalar();
1282 canvas.scale(sx, sy); 1365 canvas.scale(sx, sy);
1283 } break; 1366 } break;
1284 case SET_MATRIX: { 1367 case SET_MATRIX: {
1285 SkMatrix matrix; 1368 SkMatrix matrix;
1286 this->getMatrix(reader, &matrix); 1369 this->getMatrix(reader, &matrix);
1287 matrix.postConcat(initialMatrix); 1370 matrix.postConcat(initialMatrix);
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1831 for (index = 0; index < fPictureCount; index++) 1914 for (index = 0; index < fPictureCount; index++)
1832 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ), 1915 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ),
1833 "picture%p, ", fPictureRefs[index]); 1916 "picture%p, ", fPictureRefs[index]);
1834 if (fPictureCount > 0) 1917 if (fPictureCount > 0)
1835 SkDebugf("%s0};\n", pBuffer); 1918 SkDebugf("%s0};\n", pBuffer);
1836 1919
1837 const_cast<SkPicturePlayback*>(this)->dumpStream(); 1920 const_cast<SkPicturePlayback*>(this)->dumpStream();
1838 } 1921 }
1839 1922
1840 #endif 1923 #endif
OLDNEW
« no previous file with comments | « src/core/SkPicturePlayback.h ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698