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

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

Issue 723593002: Start stripping out complicated parts of SkPicture{Record,Data}. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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
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 7
8 #include "SkPictureRecord.h" 8 #include "SkPictureRecord.h"
9 #include "SkDevice.h" 9 #include "SkDevice.h"
10 #include "SkPatchUtils.h" 10 #include "SkPatchUtils.h"
(...skipping 13 matching lines...) Expand all
24 static int const kUInt32Size = 4; 24 static int const kUInt32Size = 4;
25 25
26 static const uint32_t kSaveSize = kUInt32Size; 26 static const uint32_t kSaveSize = kUInt32Size;
27 #ifdef SK_DEBUG 27 #ifdef SK_DEBUG
28 static const uint32_t kSaveLayerNoBoundsSize = 4 * kUInt32Size; 28 static const uint32_t kSaveLayerNoBoundsSize = 4 * kUInt32Size;
29 static const uint32_t kSaveLayerWithBoundsSize = 4 * kUInt32Size + sizeof(SkRect ); 29 static const uint32_t kSaveLayerWithBoundsSize = 4 * kUInt32Size + sizeof(SkRect );
30 #endif//SK_DEBUG 30 #endif//SK_DEBUG
31 31
32 SkPictureRecord::SkPictureRecord(const SkISize& dimensions, uint32_t flags) 32 SkPictureRecord::SkPictureRecord(const SkISize& dimensions, uint32_t flags)
33 : INHERITED(dimensions.width(), dimensions.height()) 33 : INHERITED(dimensions.width(), dimensions.height())
34 , fFlattenableHeap(HEAP_BLOCK_SIZE)
35 , fPaints(&fFlattenableHeap)
36 , fRecordFlags(flags) { 34 , fRecordFlags(flags) {
37 35
38 fBitmapHeap = SkNEW(SkBitmapHeap); 36 fBitmapHeap = SkNEW(SkBitmapHeap);
39 fFlattenableHeap.setBitmapStorage(fBitmapHeap);
40 37
41 fFirstSavedLayerIndex = kNoSavedLayerIndex; 38 fFirstSavedLayerIndex = kNoSavedLayerIndex;
42 fInitialSaveCount = kNoInitialSave; 39 fInitialSaveCount = kNoInitialSave;
43 } 40 }
44 41
45 SkPictureRecord::~SkPictureRecord() { 42 SkPictureRecord::~SkPictureRecord() {
46 SkSafeUnref(fBitmapHeap); 43 SkSafeUnref(fBitmapHeap);
47 fFlattenableHeap.setBitmapStorage(NULL);
48 fPictureRefs.unrefAll(); 44 fPictureRefs.unrefAll();
49 fTextBlobRefs.unrefAll(); 45 fTextBlobRefs.unrefAll();
50 } 46 }
51 47
52 /////////////////////////////////////////////////////////////////////////////// 48 ///////////////////////////////////////////////////////////////////////////////
53 49
54 #ifdef SK_DEBUG 50 #ifdef SK_DEBUG
55 // Return the offset of the paint inside a given op's byte stream. A zero 51 // Return the offset of the paint inside a given op's byte stream. A zero
56 // return value means there is no paint (and you really shouldn't be calling 52 // return value means there is no paint (and you really shouldn't be calling
57 // this method) 53 // this method)
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 return index; 914 return index;
919 } 915 }
920 916
921 void SkPictureRecord::addMatrix(const SkMatrix& matrix) { 917 void SkPictureRecord::addMatrix(const SkMatrix& matrix) {
922 fWriter.writeMatrix(matrix); 918 fWriter.writeMatrix(matrix);
923 } 919 }
924 920
925 void SkPictureRecord::addPaintPtr(const SkPaint* paint) { 921 void SkPictureRecord::addPaintPtr(const SkPaint* paint) {
926 fContentInfo.onAddPaintPtr(paint); 922 fContentInfo.onAddPaintPtr(paint);
927 923
928 if (paint) { 924 if (paint) {
robertphillips 2014/11/12 17:14:42 I think 0 is used as a bad paint marker.
robertphillips 2014/11/12 17:17:52 Nevermind - I think this will work.
929 const SkFlatData* flat = fPaints.findAndReturnFlat(*paint); 925 fPaints.push_back(*paint);
930 SkASSERT(flat && flat->index() != 0); 926 this->addInt(fPaints.count());
931 this->addInt(flat->index());
932 } else { 927 } else {
933 this->addInt(0); 928 this->addInt(0);
934 } 929 }
935 } 930 }
936 931
937 int SkPictureRecord::addPathToHeap(const SkPath& path) { 932 int SkPictureRecord::addPathToHeap(const SkPath& path) {
938 if (NULL == fPathHeap) { 933 if (NULL == fPathHeap) {
939 fPathHeap.reset(SkNEW(SkPathHeap)); 934 fPathHeap.reset(SkNEW(SkPathHeap));
940 } 935 }
941 #ifdef SK_DEDUP_PICTURE_PATHS 936 #ifdef SK_DEDUP_PICTURE_PATHS
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { 1009 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) {
1015 int index = fTextBlobRefs.count(); 1010 int index = fTextBlobRefs.count();
1016 *fTextBlobRefs.append() = blob; 1011 *fTextBlobRefs.append() = blob;
1017 blob->ref(); 1012 blob->ref();
1018 // follow the convention of recording a 1-based index 1013 // follow the convention of recording a 1-based index
1019 this->addInt(index + 1); 1014 this->addInt(index + 1);
1020 } 1015 }
1021 1016
1022 /////////////////////////////////////////////////////////////////////////////// 1017 ///////////////////////////////////////////////////////////////////////////////
1023 1018
OLDNEW
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | tests/BitmapHeapTest.cpp » ('j') | tests/BitmapHeapTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698