aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image/SkImage_Raster.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-03-27 11:08:16 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-27 16:31:02 +0000
commit3798c86f6885f0b47fb2e659a43b48a4468a97ef (patch)
tree8670d4adcc7889af63b4168256f0325aa78aa3bd /src/image/SkImage_Raster.cpp
parent465748c246dde8c131effdfa69aed82ef7a48af8 (diff)
Remove GrFragmentProcessor-derived class' GrTexture-based ctors
Split out into: https://skia-review.googlesource.com/c/8881/ (Switch GrTextureStripAtlas over to GrTextureProxies) https://skia-review.googlesource.com/c/8942/ (Wrap cached GrTextures in GrTextureProxies (e.g., blur profiles, nine-patch blurs, etc.)) https://skia-review.googlesource.com/c/8997/ (Clean up/remove unused GrFragmentProcessor-derived ctors) https://skia-review.googlesource.com/c/9191/ (Switch SkImageGenerator over to generating GrTextureProxies) https://skia-review.googlesource.com/c/9448/ (Switch GrYUVProvider over to GrTextureProxies) https://skia-review.googlesource.com/c/9559/ (Preparatory Proxification) https://skia-review.googlesource.com/c/9626/ (Consolidate Proxy caching code in GrResourceProvider) https://skia-review.googlesource.com/c/9683/ (More pre-emptive proxification) https://skia-review.googlesource.com/c/9917/ (Make experimental Perlin noise shader take texture proxies) https://skia-review.googlesource.com/c/9961/ (rename makeCopyForTextureParams to isACopyNeededForTextureParams) https://skia-review.googlesource.com/c/9945/ (Make SkImageCacherator be deferred) https://skia-review.googlesource.com/c/10180/ (Add new proxy-based DetermineDomainMode w/ test) Change-Id: Ia33389d92360e542a9d2bf395948deb04d017465 Reviewed-on: https://skia-review.googlesource.com/8823 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/image/SkImage_Raster.cpp')
-rw-r--r--src/image/SkImage_Raster.cpp39
1 files changed, 14 insertions, 25 deletions
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index a4c7c7de89..30262ddbc3 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -121,7 +121,7 @@ public:
sk_sp<SkImage> onMakeColorSpace(sk_sp<SkColorSpace>) const override;
#if SK_SUPPORT_GPU
- sk_sp<GrTexture> refPinnedTexture(uint32_t* uniqueID) const override;
+ sk_sp<GrTextureProxy> refPinnedTextureProxy(uint32_t* uniqueID) const override;
bool onPinAsTexture(GrContext*) const override;
void onUnpinAsTexture(GrContext*) const override;
#endif
@@ -130,7 +130,7 @@ private:
SkBitmap fBitmap;
#if SK_SUPPORT_GPU
- mutable sk_sp<GrTexture> fPinnedTexture;
+ mutable sk_sp<GrTextureProxy> fPinnedProxy;
mutable int32_t fPinnedCount = 0;
mutable uint32_t fPinnedUniqueID = 0;
#endif
@@ -158,7 +158,7 @@ SkImage_Raster::SkImage_Raster(const Info& info, sk_sp<SkData> data, size_t rowB
SkImage_Raster::~SkImage_Raster() {
#if SK_SUPPORT_GPU
- SkASSERT(nullptr == fPinnedTexture.get()); // want the caller to have manually unpinned
+ SkASSERT(nullptr == fPinnedProxy.get()); // want the caller to have manually unpinned
#endif
}
@@ -192,13 +192,12 @@ sk_sp<GrTextureProxy> SkImage_Raster::asTextureProxyRef(GrContext* context,
}
uint32_t uniqueID;
- sk_sp<GrTexture> tex = this->refPinnedTexture(&uniqueID);
+ sk_sp<GrTextureProxy> tex = this->refPinnedTextureProxy(&uniqueID);
if (tex) {
- GrTextureAdjuster adjuster(context, fPinnedTexture.get(),
+ GrTextureAdjuster adjuster(context, fPinnedProxy,
fBitmap.alphaType(), fBitmap.bounds(),
fPinnedUniqueID, fBitmap.colorSpace());
- tex.reset(adjuster.refTextureSafeForParams(params, nullptr, scaleAdjust));
- return GrSurfaceProxy::MakeWrapped(std::move(tex));
+ return adjuster.refTextureProxySafeForParams(params, nullptr, scaleAdjust);
}
return GrRefCachedBitmapTextureProxy(context, fBitmap, params, scaleAdjust);
@@ -207,33 +206,26 @@ sk_sp<GrTextureProxy> SkImage_Raster::asTextureProxyRef(GrContext* context,
#if SK_SUPPORT_GPU
-sk_sp<GrTexture> SkImage_Raster::refPinnedTexture(uint32_t* uniqueID) const {
- if (fPinnedTexture) {
+sk_sp<GrTextureProxy> SkImage_Raster::refPinnedTextureProxy(uint32_t* uniqueID) const {
+ if (fPinnedProxy) {
SkASSERT(fPinnedCount > 0);
SkASSERT(fPinnedUniqueID != 0);
*uniqueID = fPinnedUniqueID;
- return fPinnedTexture;
+ return fPinnedProxy;
}
return nullptr;
}
bool SkImage_Raster::onPinAsTexture(GrContext* ctx) const {
- if (fPinnedTexture) {
+ if (fPinnedProxy) {
SkASSERT(fPinnedCount > 0);
SkASSERT(fPinnedUniqueID != 0);
- SkASSERT(fPinnedTexture->getContext() == ctx);
} else {
SkASSERT(fPinnedCount == 0);
SkASSERT(fPinnedUniqueID == 0);
- sk_sp<GrTextureProxy> proxy = GrRefCachedBitmapTextureProxy(
- ctx, fBitmap,
- GrSamplerParams::ClampNoFilter(),
- nullptr);
- if (!proxy) {
- return false;
- }
- fPinnedTexture.reset(SkSafeRef(proxy->instantiate(ctx->resourceProvider())));
- if (!fPinnedTexture) {
+ fPinnedProxy = GrRefCachedBitmapTextureProxy(ctx, fBitmap,
+ GrSamplerParams::ClampNoFilter(), nullptr);
+ if (!fPinnedProxy) {
return false;
}
fPinnedUniqueID = fBitmap.getGenerationID();
@@ -247,12 +239,9 @@ void SkImage_Raster::onUnpinAsTexture(GrContext* ctx) const {
// Note: we always decrement, even if fPinnedTexture is null
SkASSERT(fPinnedCount > 0);
SkASSERT(fPinnedUniqueID != 0);
- if (fPinnedTexture) {
- SkASSERT(fPinnedTexture->getContext() == ctx);
- }
if (0 == --fPinnedCount) {
- fPinnedTexture.reset(nullptr);
+ fPinnedProxy.reset(nullptr);
fPinnedUniqueID = 0;
}
}