SkPicture* result = new SkPicture;
// have to disable the optimizations while generating the picture
- SkCanvas* canvas = result->beginRecording(100, 100,
- SkPicture::kDisableRecordOptimizations_RecordingFlag);
+ SkCanvas* canvas = result->beginRecording(100, 100);
+ result->internalOnly_EnableOpts(false);
SkPaint saveLayerPaint;
saveLayerPaint.setColor(0xCC000000);
SkPicture* result = new SkPicture;
// have to disable the optimizations while generating the picture
- SkCanvas* canvas = result->beginRecording(100, 100,
- SkPicture::kDisableRecordOptimizations_RecordingFlag);
+ SkCanvas* canvas = result->beginRecording(100, 100);
+ result->internalOnly_EnableOpts(false);
SkPaint saveLayerPaint;
saveLayerPaint.setColor(0xCC000000);
discarded if you serialize into a stream and then deserialize.
*/
kOptimizeForClippedPlayback_RecordingFlag = 0x02,
- /*
- This flag disables all the picture recording optimizations (i.e.,
- those in SkPictureRecord). It is mainly intended for testing the
- existing optimizations (i.e., to actually have the pattern
- appear in an .skp we have to disable the optimization). This
- option doesn't affect the optimizations controlled by
- 'kOptimizeForClippedPlayback_RecordingFlag'.
- */
- kDisableRecordOptimizations_RecordingFlag = 0x04
};
/** Returns the canvas that records the drawing commands.
static bool InternalOnly_StreamIsSKP(SkStream*, SkPictInfo*);
static bool InternalOnly_BufferIsSKP(SkReadBuffer&, SkPictInfo*);
+ /** Enable/disable all the picture recording optimizations (i.e.,
+ those in SkPictureRecord). It is mainly intended for testing the
+ existing optimizations (i.e., to actually have the pattern
+ appear in an .skp we have to disable the optimization). Call right
+ after 'beginRecording'.
+ */
+ void internalOnly_EnableOpts(bool enableOpts);
+
protected:
// V2 : adds SkPixelRef's generation ID.
// V3 : PictInfo tag at beginning, and EOF tag at the end
SkDELETE(fPlayback);
}
+void SkPicture::internalOnly_EnableOpts(bool enableOpts) {
+ if (NULL != fRecord) {
+ fRecord->internalOnly_EnableOpts(enableOpts);
+ }
+}
+
void SkPicture::swap(SkPicture& other) {
SkTSwap(fRecord, other.fRecord);
SkTSwap(fPlayback, other.fPlayback);
, fStateTree(NULL)
, fFlattenableHeap(HEAP_BLOCK_SIZE)
, fPaints(&fFlattenableHeap)
- , fRecordFlags(flags) {
+ , fRecordFlags(flags)
+ , fOptsEnabled(true) {
#ifdef SK_DEBUG_SIZE
fPointBytes = fRectBytes = fTextBytes = 0;
fPointWrites = fRectWrites = fTextWrites = 0;
}
size_t opt = 0;
- if (!(fRecordFlags & SkPicture::kDisableRecordOptimizations_RecordingFlag)) {
+ if (fOptsEnabled) {
for (opt = 0; opt < SK_ARRAY_COUNT(gPictureRecordOpts); ++opt) {
if (0 != (gPictureRecordOpts[opt].fFlags & kSkipIfBBoxHierarchy_Flag)
&& NULL != fBoundingHierarchy) {
}
}
- if ((fRecordFlags & SkPicture::kDisableRecordOptimizations_RecordingFlag) ||
- SK_ARRAY_COUNT(gPictureRecordOpts) == opt) {
+ if (!fOptsEnabled || SK_ARRAY_COUNT(gPictureRecordOpts) == opt) {
// No optimization fired so add the RESTORE
this->recordRestore();
}
void beginRecording();
void endRecording();
+ void internalOnly_EnableOpts(bool optsEnabled) {
+ fOptsEnabled = optsEnabled;
+ }
+
private:
void handleOptimization(int opt);
int recordRestoreOffsetPlaceholder(SkRegion::Op);
SkTDArray<SkPicture*> fPictureRefs;
uint32_t fRecordFlags;
- int fInitialSaveCount;
+ bool fOptsEnabled;
+ int fInitialSaveCount;
friend class SkPicturePlayback;
friend class SkPictureTester; // for unit testing