Record pixel ref's gen ID in picture

Review URL: http://codereview.appspot.com/6325046/



git-svn-id: http://skia.googlecode.com/svn/trunk@4289 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
bsalomon@google.com 2012-06-21 20:13:04 +00:00
Родитель a320194e42
Коммит 7aa876bfbf
2 изменённых файлов: 13 добавлений и 2 удалений

Просмотреть файл

@ -197,7 +197,8 @@ void SkPicture::draw(SkCanvas* surface) {
#include "SkStream.h" #include "SkStream.h"
#define PICTURE_VERSION 1 #define PICTURE_VERSION 2
// Version 2 adds SkPixelRef's generation ID.
SkPicture::SkPicture(SkStream* stream) : SkRefCnt() { SkPicture::SkPicture(SkStream* stream) : SkRefCnt() {
if (stream->readU32() != PICTURE_VERSION) { if (stream->readU32() != PICTURE_VERSION) {

Просмотреть файл

@ -72,8 +72,8 @@ SkPixelRef::SkPixelRef(SkFlattenableReadBuffer& buffer, SkBaseMutex* mutex)
fPixels = NULL; fPixels = NULL;
fColorTable = NULL; // we do not track ownership of this fColorTable = NULL; // we do not track ownership of this
fLockCount = 0; fLockCount = 0;
fGenerationID = 0; // signal to rebuild
fIsImmutable = buffer.readBool(); fIsImmutable = buffer.readBool();
fGenerationID = buffer.readU32();
fPreLocked = false; fPreLocked = false;
} }
@ -89,6 +89,16 @@ void SkPixelRef::setPreLocked(void* pixels, SkColorTable* ctable) {
void SkPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const { void SkPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer); this->INHERITED::flatten(buffer);
buffer.writeBool(fIsImmutable); buffer.writeBool(fIsImmutable);
// We write the gen ID into the picture for within-process recording. This
// is safe since the same genID will never refer to two different sets of
// pixels (barring overflow). However, each process has its own "namespace"
// of genIDs. So for cross-process recording we write a zero which will
// trigger assignment of a new genID in playback.
if (buffer.isCrossProcess()) {
buffer.write32(0);
} else {
buffer.write32(fGenerationID);
}
} }
void SkPixelRef::lockPixels() { void SkPixelRef::lockPixels() {