remove kReturnNullForEmpty_FinishFlag feature
It's unused, and doesn't appear to be correct, returning nullptr too early when we should return a non-empty SkMiniPicture. The mini-recorder path will return a zero-allocation SkEmptyPicture anyway. Change-Id: I1be538049e731acfc2b0f8b4f30cafee434a91dc Reviewed-on: https://skia-review.googlesource.com/12626 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
This commit is contained in:
parent
6d72ed918d
commit
5bd984892d
@ -38,7 +38,6 @@ public:
|
||||
};
|
||||
|
||||
enum FinishFlags {
|
||||
kReturnNullForEmpty_FinishFlag = 1 << 0, // no draw-ops will return nullptr
|
||||
};
|
||||
|
||||
/** Returns the canvas that records the drawing commands.
|
||||
|
@ -56,21 +56,12 @@ sk_sp<SkPicture> SkPictureRecorder::finishRecordingAsPicture(uint32_t finishFlag
|
||||
fRecorder->restoreToCount(1); // If we were missing any restores, add them now.
|
||||
|
||||
if (fRecord->count() == 0) {
|
||||
if (finishFlags & kReturnNullForEmpty_FinishFlag) {
|
||||
return nullptr;
|
||||
}
|
||||
return fMiniRecorder.detachAsPicture(fCullRect);
|
||||
}
|
||||
|
||||
// TODO: delay as much of this work until just before first playback?
|
||||
SkRecordOptimize(fRecord.get());
|
||||
|
||||
if (fRecord->count() == 0) {
|
||||
if (finishFlags & kReturnNullForEmpty_FinishFlag) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
SkDrawableList* drawableList = fRecorder->getDrawableList();
|
||||
SkBigPicture::SnapshotArray* pictList =
|
||||
drawableList ? drawableList->newDrawableSnapshot() : nullptr;
|
||||
@ -125,12 +116,6 @@ sk_sp<SkDrawable> SkPictureRecorder::finishRecordingAsDrawable(uint32_t finishFl
|
||||
|
||||
SkRecordOptimize(fRecord.get());
|
||||
|
||||
if (fRecord->count() == 0) {
|
||||
if (finishFlags & kReturnNullForEmpty_FinishFlag) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (fBBH.get()) {
|
||||
SkAutoTMalloc<SkRect> bounds(fRecord->count());
|
||||
SkRecordFillBounds(fCullRect, *fRecord, bounds);
|
||||
|
@ -1136,67 +1136,3 @@ DEF_TEST(PictureGpuAnalyzer, r) {
|
||||
}
|
||||
|
||||
#endif // SK_SUPPORT_GPU
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Disable until we properly fix https://bugs.chromium.org/p/skia/issues/detail?id=5548
|
||||
#if 0
|
||||
static void empty_ops(SkCanvas* canvas) {
|
||||
}
|
||||
static void clip_ops(SkCanvas* canvas) {
|
||||
canvas->save();
|
||||
canvas->clipRect(SkRect::MakeWH(20, 20));
|
||||
canvas->restore();
|
||||
}
|
||||
static void matrix_ops(SkCanvas* canvas) {
|
||||
canvas->save();
|
||||
canvas->scale(2, 3);
|
||||
canvas->restore();
|
||||
}
|
||||
static void matrixclip_ops(SkCanvas* canvas) {
|
||||
canvas->save();
|
||||
canvas->scale(2, 3);
|
||||
canvas->clipRect(SkRect::MakeWH(20, 20));
|
||||
canvas->restore();
|
||||
}
|
||||
typedef void (*CanvasProc)(SkCanvas*);
|
||||
|
||||
// Test the kReturnNullForEmpty_FinishFlag option when recording
|
||||
//
|
||||
DEF_TEST(Picture_RecordEmpty, r) {
|
||||
const SkRect cull = SkRect::MakeWH(100, 100);
|
||||
|
||||
CanvasProc procs[] { empty_ops, clip_ops, matrix_ops, matrixclip_ops };
|
||||
|
||||
for (auto proc : procs) {
|
||||
{
|
||||
SkPictureRecorder rec;
|
||||
proc(rec.beginRecording(cull));
|
||||
sk_sp<SkPicture> pic = rec.finishRecordingAsPicture(0);
|
||||
REPORTER_ASSERT(r, pic.get());
|
||||
REPORTER_ASSERT(r, pic->approximateOpCount() == 0);
|
||||
}
|
||||
{
|
||||
SkPictureRecorder rec;
|
||||
proc(rec.beginRecording(cull));
|
||||
sk_sp<SkPicture> pic = rec.finishRecordingAsPicture(
|
||||
SkPictureRecorder::kReturnNullForEmpty_FinishFlag);
|
||||
REPORTER_ASSERT(r, !pic.get());
|
||||
}
|
||||
{
|
||||
SkPictureRecorder rec;
|
||||
proc(rec.beginRecording(cull));
|
||||
sk_sp<SkDrawable> dr = rec.finishRecordingAsDrawable(0);
|
||||
REPORTER_ASSERT(r, dr.get());
|
||||
}
|
||||
{
|
||||
SkPictureRecorder rec;
|
||||
proc(rec.beginRecording(cull));
|
||||
sk_sp<SkDrawable> dr = rec.finishRecordingAsDrawable(
|
||||
SkPictureRecorder::kReturnNullForEmpty_FinishFlag);
|
||||
REPORTER_ASSERT(r, !dr.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user