Clean up dead clear() code in SkRecord.
This removes the SkRecords::Clear struct and everything that refers to it. Notice there is nothing actually creating a Clear, which means this is all dead code. Now that all ops obey the clip, I don't think we need the weird inflate-empty-to-epsilon hack for BBH queries. BUG=skia: Review URL: https://codereview.chromium.org/835813002
This commit is contained in:
parent
5f2ee72f97
commit
49aabde6ef
@ -26,9 +26,7 @@ void SkRecordDraw(const SkRecord& record,
|
||||
// lets us query the BBH.
|
||||
SkRect query;
|
||||
if (!canvas->getClipBounds(&query)) {
|
||||
// We want to make sure our query rectangle is never totally empty.
|
||||
// Clear ignores the clip, so it must draw even if the clip is logically empty.
|
||||
query = SkRect::MakeWH(SK_ScalarNearlyZero, SK_ScalarNearlyZero);
|
||||
query.setEmpty();
|
||||
}
|
||||
|
||||
SkTDArray<unsigned> ops;
|
||||
@ -81,7 +79,6 @@ template <> void Draw::draw(const NoOp&) {}
|
||||
DRAW(Restore, restore());
|
||||
DRAW(Save, save());
|
||||
DRAW(SaveLayer, saveLayer(r.bounds, r.paint, r.flags));
|
||||
DRAW(Clear, clear(r.color));
|
||||
DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix)));
|
||||
|
||||
DRAW(ClipPath, clipPath(r.path, r.opAA.op, r.opAA.aa));
|
||||
@ -218,7 +215,6 @@ public:
|
||||
fCTM->mapRect(&rect);
|
||||
|
||||
// Nothing can draw outside the current clip.
|
||||
// (Only bounded ops call into this method, so oddballs like Clear don't matter here.)
|
||||
if (!rect.intersect(fCurrentClipBounds)) {
|
||||
return Bounds::MakeEmpty();
|
||||
}
|
||||
@ -388,7 +384,6 @@ private:
|
||||
// FIXME: this method could use better bounds
|
||||
Bounds bounds(const DrawText&) const { return fCurrentClipBounds; }
|
||||
|
||||
Bounds bounds(const Clear&) const { return fCullRect; } // Ignores the clip.
|
||||
Bounds bounds(const DrawPaint&) const { return fCurrentClipBounds; }
|
||||
Bounds bounds(const NoOp&) const { return Bounds::MakeEmpty(); } // NoOps don't draw.
|
||||
|
||||
|
@ -35,7 +35,6 @@ namespace SkRecords {
|
||||
M(ClipRRect) \
|
||||
M(ClipRect) \
|
||||
M(ClipRegion) \
|
||||
M(Clear) \
|
||||
M(BeginCommentGroup) \
|
||||
M(AddComment) \
|
||||
M(EndCommentGroup) \
|
||||
@ -236,9 +235,6 @@ RECORD3(ClipRRect, SkIRect, devBounds, SkRRect, rrect, RegionOpAndAA, opAA);
|
||||
RECORD3(ClipRect, SkIRect, devBounds, SkRect, rect, RegionOpAndAA, opAA);
|
||||
RECORD3(ClipRegion, SkIRect, devBounds, SkRegion, region, SkRegion::Op, op);
|
||||
|
||||
// Picture version 37 was last to record this op-code; clear is now non-virtual
|
||||
RECORD1(Clear, SkColor, color);
|
||||
|
||||
RECORD1(BeginCommentGroup, PODArray<char>, description);
|
||||
RECORD2(AddComment, PODArray<char>, key, PODArray<char>, value);
|
||||
RECORD0(EndCommentGroup);
|
||||
|
@ -63,7 +63,7 @@ private:
|
||||
};
|
||||
|
||||
// Test to verify the playback of an empty picture
|
||||
//
|
||||
//
|
||||
class DrawEmptyPictureBBHTest : public PictureBBHTestBase {
|
||||
public:
|
||||
DrawEmptyPictureBBHTest()
|
||||
@ -78,7 +78,7 @@ public:
|
||||
//
|
||||
class EmptyClipPictureBBHTest : public PictureBBHTestBase {
|
||||
public:
|
||||
EmptyClipPictureBBHTest()
|
||||
EmptyClipPictureBBHTest()
|
||||
: PictureBBHTestBase(2, 2, 3, 3) { }
|
||||
|
||||
virtual void doTest(SkCanvas& playbackCanvas, SkCanvas& recordingCanvas) SK_OVERRIDE {
|
||||
@ -101,35 +101,3 @@ DEF_TEST(PictureBBH, reporter) {
|
||||
EmptyClipPictureBBHTest emptyClipPictureTest;
|
||||
emptyClipPictureTest.run(reporter);
|
||||
}
|
||||
|
||||
static void test_clear(skiatest::Reporter* r, SkBBHFactory* factory) {
|
||||
// SkPicture should always call clear()s on the target canvas, even if its clip is empty.
|
||||
SkPictureRecorder src, dst;
|
||||
|
||||
// A picture that's just clear().
|
||||
src.beginRecording(1,1, factory)
|
||||
->clear(SK_ColorGREEN);
|
||||
SkAutoTUnref<SkPicture> srcPic(src.endRecording());
|
||||
|
||||
// A target canvas with an empty clip.
|
||||
SkCanvas* c = dst.beginRecording(1,1, NULL);
|
||||
c->clipRect(SkRect::MakeEmpty());
|
||||
srcPic->playback(c);
|
||||
SkAutoTUnref<SkPicture> dstPic(dst.endRecording());
|
||||
|
||||
// Should be Clip - Save - Clear - Restore.
|
||||
// Buggy implementations might return 1 (just Clip) or 3 (Clip - Save - Restore).
|
||||
// TODO: can we just search that it contains "clear"? <reed>
|
||||
REPORTER_ASSERT(r, dstPic->approximateOpCount() == 4 || dstPic->approximateOpCount() == 2);
|
||||
}
|
||||
|
||||
DEF_TEST(PictureBBH_Clear, r) {
|
||||
test_clear(r, NULL);
|
||||
|
||||
SkTileGridFactory::TileGridInfo grid = { {1,1}, {0,0}, {0,0} };
|
||||
SkTileGridFactory tilegrid(grid);
|
||||
test_clear(r, &tilegrid);
|
||||
|
||||
SkRTreeFactory rtree;
|
||||
test_clear(r, &rtree);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user