Chromium Code Reviews| Index: src/core/SkPictureRecord.h |
| =================================================================== |
| --- src/core/SkPictureRecord.h (revision 9110) |
| +++ src/core/SkPictureRecord.h (working copy) |
| @@ -16,6 +16,10 @@ |
| #include "SkTemplates.h" |
| #include "SkWriter32.h" |
| +#ifndef SK_RECORD_BOUNDS_IN_PICTURE |
| +#define SK_RECORD_BOUNDS_IN_PICTURE 0 |
| +#endif |
| + |
| class SkPictureStateTree; |
| class SkBBoxHierarchy; |
| @@ -84,8 +88,10 @@ |
| virtual void drawData(const void*, size_t) SK_OVERRIDE; |
| virtual bool isDrawingToLayer() const SK_OVERRIDE; |
| +#if !(SK_RECORD_BOUNDS_IN_PICTURE) |
| void addFontMetricsTopBottom(const SkPaint& paint, const SkFlatData&, |
| SkScalar minY, SkScalar maxY); |
| +#endif |
| const SkTDArray<SkPicture* >& getPictureRefs() const { |
| return fPictureRefs; |
| @@ -102,6 +108,7 @@ |
| void beginRecording(); |
| void endRecording(); |
| + static bool canRecordBounds(DrawType op); |
| private: |
| bool updateClipConservativelyUsingBounds(const SkRect&, SkRegion::Op, |
| bool doAA, bool inverseFilled); |
| @@ -113,13 +120,16 @@ |
| SkTDArray<int32_t> fRestoreOffsetStack; |
| int fFirstSavedLayerIndex; |
| enum { |
| - kNoSavedLayerIndex = -1 |
| + kNoSavedLayerIndex = -1, |
| }; |
| + static const uint32_t kInvalidOffset = ~0; |
| /* |
| - * Write the 'drawType' operation and chunk size to the skp. 'size' |
| - * can potentially be increased if the chunk size needs its own storage |
| - * location (i.e., it overflows 24 bits). |
| + * Write the 'drawType' operation, chunk size and optionally the draw |
| + * bounds to the skp. 'size' can potentially be increased if the chunk |
| + * size needs its own storage location (i.e., it overflows 24 bits). |
| + * Bounds are recorded in device space, if canRecordBounds(drawType) |
| + * returns true; |
|
Tom Hudson
2013/05/14 17:00:49
Nit: trailing semicolon - did you mean to do more
|
| * Returns the start offset of the chunk. This is the location at which |
| * the opcode & size are stored. |
| * TODO: since we are handing the size into here we could call reserve |
| @@ -128,29 +138,9 @@ |
| * end of blocks could go unused). Possibly add a second addDraw that |
| * operates in this manner. |
| */ |
| - uint32_t addDraw(DrawType drawType, uint32_t* size) { |
| - uint32_t offset = fWriter.size(); |
| + uint32_t addDraw(DrawType drawType, uint32_t* size, const SkPaint* paint = NULL, |
| + const SkRect* localBounds = NULL); |
| - this->predrawNotify(); |
| - |
| - #ifdef SK_DEBUG_TRACE |
| - SkDebugf("add %s\n", DrawTypeToString(drawType)); |
| - #endif |
| - |
| - SkASSERT(0 != *size); |
| - SkASSERT(((uint8_t) drawType) == drawType); |
| - |
| - if (0 != (*size & ~MASK_24) || *size == MASK_24) { |
| - fWriter.writeInt(PACK_8_24(drawType, MASK_24)); |
| - *size += 1; |
| - fWriter.writeInt(*size); |
| - } else { |
| - fWriter.writeInt(PACK_8_24(drawType, *size)); |
| - } |
| - |
| - return offset; |
| - } |
| - |
| void addInt(int value) { |
| fWriter.writeInt(value); |
| } |
| @@ -222,7 +212,9 @@ |
| // Allocated in the constructor and managed by this class. |
| SkBitmapHeap* fBitmapHeap; |
| - |
| +#if SK_RECORD_BOUNDS_IN_PICTURE |
| + SkIRect fLastDrawBounds; |
| +#endif |
| private: |
| SkChunkFlatController fFlattenableHeap; |