const SkScalar w = fSrc->cullRect().width(),
h = fSrc->cullRect().height();
+ uint32_t flags = SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag
+ | SkPictureRecorder::kPlaybackDrawPicture_RecordFlag;
for (int i = 0; i < loops; i++) {
SkPictureRecorder recorder;
- fSrc->playback(recorder.beginRecording(w, h, fUseBBH ? &factory : NULL,
- SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag));
+ fSrc->playback(recorder.beginRecording(w, h, fUseBBH ? &factory : NULL, flags));
SkSafeUnref(recorder.endRecording());
}
}
enum RecordFlags {
// This flag indicates that, if some BHH is being computed, saveLayer
// information should also be extracted at the same time.
- kComputeSaveLayerInfo_RecordFlag = 0x01
+ kComputeSaveLayerInfo_RecordFlag = 0x01,
+
+ // If you call drawPicture() on the recording canvas, this flag forces
+ // that to use SkPicture::playback() immediately rather than (e.g.) reffing the picture.
+ kPlaybackDrawPicture_RecordFlag = 0x02,
};
/** Returns the canvas that records the drawing commands.
if (!fRecord) {
fRecord.reset(SkNEW(SkRecord));
}
- fRecorder->reset(fRecord.get(), cullRect, &fMiniRecorder);
+ SkRecorder::DrawPictureMode dpm = (recordFlags & kPlaybackDrawPicture_RecordFlag)
+ ? SkRecorder::Playback_DrawPictureMode
+ : SkRecorder::Record_DrawPictureMode;
+ fRecorder->reset(fRecord.get(), cullRect, dpm, &fMiniRecorder);
fActivelyRecording = true;
return this->getRecordingCanvas();
}
*/
#include "SkBigPicture.h"
+#include "SkCanvasPriv.h"
#include "SkPatchUtils.h"
#include "SkPicture.h"
#include "SkPictureUtils.h"
SkRecorder::SkRecorder(SkRecord* record, int width, int height, SkMiniRecorder* mr)
: SkCanvas(SkIRect::MakeWH(width, height), SkCanvas::kConservativeRasterClip_InitFlag)
+ , fDrawPictureMode(Record_DrawPictureMode)
, fApproxBytesUsedBySubPictures(0)
, fRecord(record)
, fMiniRecorder(mr) {}
SkRecorder::SkRecorder(SkRecord* record, const SkRect& bounds, SkMiniRecorder* mr)
: SkCanvas(bounds.roundOut(), SkCanvas::kConservativeRasterClip_InitFlag)
+ , fDrawPictureMode(Record_DrawPictureMode)
, fApproxBytesUsedBySubPictures(0)
, fRecord(record)
, fMiniRecorder(mr) {}
-void SkRecorder::reset(SkRecord* record, const SkRect& bounds, SkMiniRecorder* mr) {
+void SkRecorder::reset(SkRecord* record, const SkRect& bounds,
+ DrawPictureMode dpm, SkMiniRecorder* mr) {
this->forgetRecord();
+ fDrawPictureMode = dpm;
fRecord = record;
this->resetForNextPicture(bounds.roundOut());
fMiniRecorder = mr;
}
void SkRecorder::onDrawPicture(const SkPicture* pic, const SkMatrix* matrix, const SkPaint* paint) {
- fApproxBytesUsedBySubPictures += SkPictureUtils::ApproximateBytesUsed(pic);
- APPEND(DrawPicture, this->copy(paint), pic, matrix ? *matrix : SkMatrix::I());
+ if (fDrawPictureMode == Record_DrawPictureMode) {
+ fApproxBytesUsedBySubPictures += SkPictureUtils::ApproximateBytesUsed(pic);
+ APPEND(DrawPicture, this->copy(paint), pic, matrix ? *matrix : SkMatrix::I());
+ } else {
+ SkASSERT(fDrawPictureMode == Playback_DrawPictureMode);
+ SkAutoCanvasMatrixPaint acmp(this, matrix, paint, pic->cullRect());
+ pic->playback(this);
+ }
}
void SkRecorder::onDrawVertices(VertexMode vmode,
SkRecorder(SkRecord*, int width, int height, SkMiniRecorder* = nullptr); // legacy version
SkRecorder(SkRecord*, const SkRect& bounds, SkMiniRecorder* = nullptr);
- void reset(SkRecord*, const SkRect& bounds, SkMiniRecorder* = nullptr);
+ enum DrawPictureMode { Record_DrawPictureMode, Playback_DrawPictureMode };
+ void reset(SkRecord*, const SkRect& bounds, DrawPictureMode, SkMiniRecorder* = nullptr);
size_t approxBytesUsedBySubPictures() const { return fApproxBytesUsedBySubPictures; }
return devBounds;
}
+ DrawPictureMode fDrawPictureMode;
size_t fApproxBytesUsedBySubPictures;
SkRecord* fRecord;
SkAutoTDelete<SkDrawableList> fDrawableList;