aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image/SkImage_Gpu.cpp
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-04-11 12:03:44 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-11 16:38:17 +0000
commit7a542c559a6e584107b94e6254ac3c7f9f24b591 (patch)
tree9186b5ae154b580e20b3dc40f437e44f546c467b /src/image/SkImage_Gpu.cpp
parent77443974ea96912fa39079a4bf82ab791ec3c922 (diff)
Change bitmapcache to not rely on lockpixels.
The Rec in the cache is the owner of the pixel memory - discardable or - malloc Each external client has a pixelref that just points to those pixels, and whose destructor will notify the rec. This eliminates the dependency on lockPixels in pixelref, freeing us to remove that entirely from pixelref. Bug: skia: Change-Id: If45ed0ae202a1211336626364235215253e8aa7c Reviewed-on: https://skia-review.googlesource.com/10300 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Matt Sarett <msarett@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
Diffstat (limited to 'src/image/SkImage_Gpu.cpp')
-rw-r--r--src/image/SkImage_Gpu.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 119eb911e8..4bd04e1f4c 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -77,8 +77,17 @@ bool SkImage_Gpu::getROPixels(SkBitmap* dst, SkColorSpace* dstColorSpace, Cachin
SkImageInfo ii = make_info(this->width(), this->height(), this->alphaType(),
sk_ref_sp(dstColorSpace));
- if (!dst->tryAllocPixels(ii)) {
- return false;
+ SkBitmapCache::RecPtr rec = nullptr;
+ SkPixmap pmap;
+ if (kAllow_CachingHint == chint) {
+ rec = SkBitmapCache::Alloc(desc, ii, &pmap);
+ if (!rec) {
+ return false;
+ }
+ } else {
+ if (!dst->tryAllocPixels(ii)) {
+ return false;
+ }
}
sk_sp<GrSurfaceContext> sContext = fContext->contextPriv().makeWrappedSurfaceContext(
@@ -88,13 +97,12 @@ bool SkImage_Gpu::getROPixels(SkBitmap* dst, SkColorSpace* dstColorSpace, Cachin
return false;
}
- if (!sContext->readPixels(dst->info(), dst->getPixels(), dst->rowBytes(), 0, 0)) {
+ if (!sContext->readPixels(pmap.info(), pmap.writable_addr(), pmap.rowBytes(), 0, 0)) {
return false;
}
- dst->pixelRef()->setImmutableWithID(this->uniqueID());
- if (kAllow_CachingHint == chint) {
- SkBitmapCache::Add(desc, *dst);
+ if (rec) {
+ SkBitmapCache::Add(std::move(rec), dst);
fAddedRasterVersionToCache.store(true);
}
return true;