OLD | NEW |
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 "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 MIN_WRITER_SIZE 16384 | |
17 #define HEAP_BLOCK_SIZE 4096 | 16 #define HEAP_BLOCK_SIZE 4096 |
18 | 17 |
19 enum { | 18 enum { |
20 // just need a value that save or getSaveCount would never return | 19 // just need a value that save or getSaveCount would never return |
21 kNoInitialSave = -1, | 20 kNoInitialSave = -1, |
22 }; | 21 }; |
23 | 22 |
24 // 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. |
25 static int const kUInt32Size = 4; | 24 static int const kUInt32Size = 4; |
26 | 25 |
27 static const uint32_t kSaveSize = 2 * kUInt32Size; | 26 static const uint32_t kSaveSize = 2 * kUInt32Size; |
28 static const uint32_t kSaveLayerNoBoundsSize = 4 * kUInt32Size; | 27 static const uint32_t kSaveLayerNoBoundsSize = 4 * kUInt32Size; |
29 static const uint32_t kSaveLayerWithBoundsSize = 4 * kUInt32Size + sizeof(SkRect
); | 28 static const uint32_t kSaveLayerWithBoundsSize = 4 * kUInt32Size + sizeof(SkRect
); |
30 | 29 |
31 SkPictureRecord::SkPictureRecord(uint32_t flags, SkBaseDevice* device) : | 30 SkPictureRecord::SkPictureRecord(uint32_t flags, SkBaseDevice* device) : |
32 INHERITED(device), | 31 INHERITED(device), |
33 fBoundingHierarchy(NULL), | 32 fBoundingHierarchy(NULL), |
34 fStateTree(NULL), | 33 fStateTree(NULL), |
35 fFlattenableHeap(HEAP_BLOCK_SIZE), | 34 fFlattenableHeap(HEAP_BLOCK_SIZE), |
36 fMatrices(&fFlattenableHeap), | 35 fMatrices(&fFlattenableHeap), |
37 fPaints(&fFlattenableHeap), | 36 fPaints(&fFlattenableHeap), |
38 fRegions(&fFlattenableHeap), | 37 fRegions(&fFlattenableHeap), |
39 fWriter(MIN_WRITER_SIZE), | |
40 fRecordFlags(flags) { | 38 fRecordFlags(flags) { |
41 #ifdef SK_DEBUG_SIZE | 39 #ifdef SK_DEBUG_SIZE |
42 fPointBytes = fRectBytes = fTextBytes = 0; | 40 fPointBytes = fRectBytes = fTextBytes = 0; |
43 fPointWrites = fRectWrites = fTextWrites = 0; | 41 fPointWrites = fRectWrites = fTextWrites = 0; |
44 #endif | 42 #endif |
45 | 43 |
46 fRestoreOffsetStack.setReserve(32); | 44 fRestoreOffsetStack.setReserve(32); |
47 | 45 |
48 fBitmapHeap = SkNEW(SkBitmapHeap); | 46 fBitmapHeap = SkNEW(SkBitmapHeap); |
49 fFlattenableHeap.setBitmapStorage(fBitmapHeap); | 47 fFlattenableHeap.setBitmapStorage(fBitmapHeap); |
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1530 void SkPictureRecord::validateRegions() const { | 1528 void SkPictureRecord::validateRegions() const { |
1531 int count = fRegions.count(); | 1529 int count = fRegions.count(); |
1532 SkASSERT((unsigned) count < 0x1000); | 1530 SkASSERT((unsigned) count < 0x1000); |
1533 for (int index = 0; index < count; index++) { | 1531 for (int index = 0; index < count; index++) { |
1534 const SkFlatData* region = fRegions[index]; | 1532 const SkFlatData* region = fRegions[index]; |
1535 SkASSERT(region); | 1533 SkASSERT(region); |
1536 // region->validate(); | 1534 // region->validate(); |
1537 } | 1535 } |
1538 } | 1536 } |
1539 #endif | 1537 #endif |
OLD | NEW |