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

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

Issue 249453002: First step in pulling SkPicturePlayback & SkPictureRecord out of SkPicture (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: cleanup 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/SkPictureRecord.h ('k') | tests/CanvasTest.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 7
8 #include "SkPictureRecord.h" 8 #include "SkPictureRecord.h"
9 #include "SkTSearch.h" 9 #include "SkTSearch.h"
10 #include "SkPixelRef.h" 10 #include "SkPixelRef.h"
11 #include "SkRRect.h" 11 #include "SkRRect.h"
12 #include "SkBBoxHierarchy.h" 12 #include "SkBBoxHierarchy.h"
13 #include "SkDevice.h" 13 #include "SkDevice.h"
14 #include "SkPictureStateTree.h" 14 #include "SkPictureStateTree.h"
15 15
16 #define HEAP_BLOCK_SIZE 4096 16 #define HEAP_BLOCK_SIZE 4096
17 17
18 enum { 18 enum {
19 // just need a value that save or getSaveCount would never return 19 // just need a value that save or getSaveCount would never return
20 kNoInitialSave = -1, 20 kNoInitialSave = -1,
21 }; 21 };
22 22
23 // A lot of basic types get stored as a uint32_t: bools, ints, paint indices, et c. 23 // A lot of basic types get stored as a uint32_t: bools, ints, paint indices, et c.
24 static int const kUInt32Size = 4; 24 static int const kUInt32Size = 4;
25 25
26 static const uint32_t kSaveSize = 2 * kUInt32Size; 26 static const uint32_t kSaveSize = 2 * kUInt32Size;
27 static const uint32_t kSaveLayerNoBoundsSize = 4 * kUInt32Size; 27 static const uint32_t kSaveLayerNoBoundsSize = 4 * kUInt32Size;
28 static const uint32_t kSaveLayerWithBoundsSize = 4 * kUInt32Size + sizeof(SkRect ); 28 static const uint32_t kSaveLayerWithBoundsSize = 4 * kUInt32Size + sizeof(SkRect );
29 29
30 SkPictureRecord::SkPictureRecord(const SkISize& dimensions, uint32_t flags) 30 SkPictureRecord::SkPictureRecord(SkPicture* picture, const SkISize& dimensions, uint32_t flags)
31 : INHERITED(dimensions.width(), dimensions.height()) 31 : INHERITED(dimensions.width(), dimensions.height())
32 , fBoundingHierarchy(NULL) 32 , fBoundingHierarchy(NULL)
33 , fStateTree(NULL) 33 , fStateTree(NULL)
34 , fFlattenableHeap(HEAP_BLOCK_SIZE) 34 , fFlattenableHeap(HEAP_BLOCK_SIZE)
35 , fPaints(&fFlattenableHeap) 35 , fPaints(&fFlattenableHeap)
36 , fRecordFlags(flags) 36 , fRecordFlags(flags)
37 , fOptsEnabled(true) { 37 , fOptsEnabled(true) {
38 #ifdef SK_DEBUG_SIZE 38 #ifdef SK_DEBUG_SIZE
39 fPointBytes = fRectBytes = fTextBytes = 0; 39 fPointBytes = fRectBytes = fTextBytes = 0;
40 fPointWrites = fRectWrites = fTextWrites = 0; 40 fPointWrites = fRectWrites = fTextWrites = 0;
41 #endif 41 #endif
42 42
43 fPicture = picture;
43 fBitmapHeap = SkNEW(SkBitmapHeap); 44 fBitmapHeap = SkNEW(SkBitmapHeap);
44 fFlattenableHeap.setBitmapStorage(fBitmapHeap); 45 fFlattenableHeap.setBitmapStorage(fBitmapHeap);
45 fPathHeap = NULL; // lazy allocate
46 46
47 #ifndef SK_COLLAPSE_MATRIX_CLIP_STATE 47 #ifndef SK_COLLAPSE_MATRIX_CLIP_STATE
48 fFirstSavedLayerIndex = kNoSavedLayerIndex; 48 fFirstSavedLayerIndex = kNoSavedLayerIndex;
49 #endif 49 #endif
50 50
51 fInitialSaveCount = kNoInitialSave; 51 fInitialSaveCount = kNoInitialSave;
52 52
53 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 53 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
54 fMCMgr.init(this); 54 fMCMgr.init(this);
55 #endif 55 #endif
56 } 56 }
57 57
58 SkPictureRecord::~SkPictureRecord() { 58 SkPictureRecord::~SkPictureRecord() {
59 SkSafeUnref(fBitmapHeap); 59 SkSafeUnref(fBitmapHeap);
60 SkSafeUnref(fPathHeap);
61 SkSafeUnref(fBoundingHierarchy); 60 SkSafeUnref(fBoundingHierarchy);
62 SkSafeUnref(fStateTree); 61 SkSafeUnref(fStateTree);
63 fFlattenableHeap.setBitmapStorage(NULL); 62 fFlattenableHeap.setBitmapStorage(NULL);
64 fPictureRefs.unrefAll(); 63 fPictureRefs.unrefAll();
65 } 64 }
66 65
67 /////////////////////////////////////////////////////////////////////////////// 66 ///////////////////////////////////////////////////////////////////////////////
68 67
69 // Return the offset of the paint inside a given op's byte stream. A zero 68 // Return the offset of the paint inside a given op's byte stream. A zero
70 // return value means there is no paint (and you really shouldn't be calling 69 // return value means there is no paint (and you really shouldn't be calling
(...skipping 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 this->addFlatPaint(data); 1582 this->addFlatPaint(data);
1584 return data; 1583 return data;
1585 } 1584 }
1586 1585
1587 void SkPictureRecord::addFlatPaint(const SkFlatData* flatPaint) { 1586 void SkPictureRecord::addFlatPaint(const SkFlatData* flatPaint) {
1588 int index = flatPaint ? flatPaint->index() : 0; 1587 int index = flatPaint ? flatPaint->index() : 0;
1589 this->addInt(index); 1588 this->addInt(index);
1590 } 1589 }
1591 1590
1592 int SkPictureRecord::addPathToHeap(const SkPath& path) { 1591 int SkPictureRecord::addPathToHeap(const SkPath& path) {
1593 if (NULL == fPathHeap) { 1592 return fPicture->addPathToHeap(path);
1594 fPathHeap = SkNEW(SkPathHeap);
1595 }
1596 #ifdef SK_DEDUP_PICTURE_PATHS
1597 return fPathHeap->insert(path);
1598 #else
1599 return fPathHeap->append(path);
1600 #endif
1601 } 1593 }
1602 1594
1603 void SkPictureRecord::addPath(const SkPath& path) { 1595 void SkPictureRecord::addPath(const SkPath& path) {
1604 this->addInt(this->addPathToHeap(path)); 1596 this->addInt(this->addPathToHeap(path));
1605 } 1597 }
1606 1598
1607 void SkPictureRecord::addPicture(SkPicture& picture) { 1599 void SkPictureRecord::addPicture(SkPicture& picture) {
1608 int index = fPictureRefs.find(&picture); 1600 int index = fPictureRefs.find(&picture);
1609 if (index < 0) { // not found 1601 if (index < 0) { // not found
1610 index = fPictureRefs.count(); 1602 index = fPictureRefs.count();
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 void SkPictureRecord::validateRegions() const { 1799 void SkPictureRecord::validateRegions() const {
1808 int count = fRegions.count(); 1800 int count = fRegions.count();
1809 SkASSERT((unsigned) count < 0x1000); 1801 SkASSERT((unsigned) count < 0x1000);
1810 for (int index = 0; index < count; index++) { 1802 for (int index = 0; index < count; index++) {
1811 const SkFlatData* region = fRegions[index]; 1803 const SkFlatData* region = fRegions[index];
1812 SkASSERT(region); 1804 SkASSERT(region);
1813 // region->validate(); 1805 // region->validate();
1814 } 1806 }
1815 } 1807 }
1816 #endif 1808 #endif
OLDNEW
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | tests/CanvasTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698