impl preroll for all image backends

BUG=skia:

Review URL: https://codereview.chromium.org/1341043002
This commit is contained in:
reed 2015-09-14 11:17:23 -07:00 committed by Commit bot
parent 5a744b7801
commit efd50daa28
3 changed files with 8 additions and 12 deletions

View File

@ -55,7 +55,14 @@ bool SkImage::readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dst
}
void SkImage::preroll(GrContext* ctx) const {
as_IB(this)->onPreroll(ctx);
// For now, and to maintain parity w/ previous pixelref behavior, we just force the image
// to produce a cached raster-bitmap form, so that drawing to a raster canvas should be fast.
//
SkBitmap bm;
if (as_IB(this)->getROPixels(&bm)) {
bm.lockPixels();
bm.unlockPixels();
}
}
SkShader* SkImage::newShader(SkShader::TileMode tileX,

View File

@ -52,8 +52,6 @@ public:
virtual bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
int srcX, int srcY) const;
virtual void onPreroll(GrContext*) const {}
virtual GrTexture* peekTexture() const { return nullptr; }
// return a read-only copy of the pixels. We promise to not modify them,

View File

@ -64,7 +64,6 @@ public:
SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) const override;
bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY) const override;
void onPreroll(GrContext*) const override;
const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const override;
SkData* onRefEncoded() const override;
bool getROPixels(SkBitmap*) const override;
@ -164,14 +163,6 @@ const void* SkImage_Raster::onPeekPixels(SkImageInfo* infoPtr, size_t* rowBytesP
return fBitmap.getPixels();
}
void SkImage_Raster::onPreroll(GrContext* ctx) const {
// SkImage can be called from lots of threads, but our fBitmap is *not* thread-safe,
// so we have to perform this lock/unlock in a non-racy way... we make a copy!
SkBitmap localShallowCopy(fBitmap);
localShallowCopy.lockPixels();
localShallowCopy.unlockPixels();
}
SkData* SkImage_Raster::onRefEncoded() const {
SkPixelRef* pr = fBitmap.pixelRef();
const SkImageInfo prInfo = pr->info();