Preserve SKP cullrects on deserialization

Let's not ignore the offset.

R=reed@google.com,mtklein@google.com

Review URL: https://codereview.chromium.org/1235953004
This commit is contained in:
fmalita 2015-07-14 13:12:25 -07:00 committed by Commit bot
parent e8c5666e03
commit 2ecc000536
2 changed files with 21 additions and 3 deletions

View File

@ -134,9 +134,7 @@ SkPicture* SkPicture::Forwardport(const SkPictInfo& info, const SkPictureData* d
}
SkPicturePlayback playback(data);
SkPictureRecorder r;
playback.draw(r.beginRecording(SkScalarCeilToInt(info.fCullRect.width()),
SkScalarCeilToInt(info.fCullRect.height())),
nullptr/*no callback*/);
playback.draw(r.beginRecording(info.fCullRect), nullptr/*no callback*/);
return r.endRecording();
}

View File

@ -1342,3 +1342,23 @@ DEF_TEST(MiniRecorderLeftHanging, r) {
REPORTER_ASSERT(r, rec.drawRect(SkRect::MakeWH(20,30), paint));
// Don't call rec.detachPicture(). Test succeeds by not asserting or leaking the shader.
}
DEF_TEST(Picture_preserveCullRect, r) {
SkPictureRecorder recorder;
SkCanvas* c = recorder.beginRecording(SkRect::MakeLTRB(1, 2, 3, 4));
c->clear(SK_ColorCYAN);
SkAutoTUnref<SkPicture> picture(recorder.endRecording());
SkDynamicMemoryWStream wstream;
picture->serialize(&wstream);
SkAutoTDelete<SkStream> rstream(wstream.detachAsStream());
SkAutoTUnref<SkPicture> deserializedPicture(SkPicture::CreateFromStream(rstream));
REPORTER_ASSERT(r, SkToBool(deserializedPicture));
REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1);
REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2);
REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3);
REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4);
}