Detect discarded SkPictureShader pixel refs.

This doesn't address the more general problem, but reduces the race
window significantly.

BUG=440282
R=reed@google.com

Review URL: https://codereview.chromium.org/787043006
This commit is contained in:
fmalita 2014-12-10 12:17:58 -08:00 committed by Commit bot
parent f3e218c215
commit 387a01a635

View File

@ -77,7 +77,14 @@ struct BitmapShaderRec : public SkResourceCache::Rec {
SkAutoTUnref<SkShader>* result = reinterpret_cast<SkAutoTUnref<SkShader>*>(contextShader);
result->reset(SkRef(rec.fShader.get()));
return true;
SkBitmap tile;
rec.fShader.get()->asABitmap(&tile, NULL, NULL);
// FIXME: this doesn't protect the pixels from being discarded as soon as we unlock.
// Should be handled via a pixel ref generator instead
// (https://code.google.com/p/skia/issues/detail?id=3220).
SkAutoLockPixels alp(tile, true);
return tile.getPixels() != NULL;
}
};