aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkSpecialImage.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-03-20 14:37:13 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-21 11:39:41 +0000
commit0db235bc0278887c344eb25b4681e9cca4cf892a (patch)
tree853a3e84db8d689e36ff5e6730ac38d77a621f14 /src/core/SkSpecialImage.cpp
parent53262d0ff466668bfbc76893ba5a581203269572 (diff)
Make SkImage_Gpu be deferred
This CL removes the GrTexture-based ctor forcing everyone to create deferred SkImage_Gpus. split out into: https://skia-review.googlesource.com/c/9106/ (Remove atlas creation from GrResourceProvider) Change-Id: I266bbe089c242fe54d5b7adcc7895aa5a39440a0 Reviewed-on: https://skia-review.googlesource.com/6680 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/core/SkSpecialImage.cpp')
-rw-r--r--src/core/SkSpecialImage.cpp38
1 files changed, 16 insertions, 22 deletions
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index 411b0ea289..4c7e96188a 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -346,17 +346,10 @@ sk_sp<SkSpecialImage> SkSpecialImage::MakeFromRaster(const SkIRect& subset,
///////////////////////////////////////////////////////////////////////////////
#include "GrTexture.h"
-static sk_sp<SkImage> wrap_proxy_in_image(GrContext* context, GrTextureProxy* proxy,
+static sk_sp<SkImage> wrap_proxy_in_image(GrContext* context, sk_sp<GrTextureProxy> proxy,
SkAlphaType alphaType, sk_sp<SkColorSpace> colorSpace) {
- // TODO: add GrTextureProxy-backed SkImage_Gpus
- GrTexture* tex = proxy->instantiate(context->resourceProvider());
- if (!tex) {
- return nullptr;
- }
-
- return sk_make_sp<SkImage_Gpu>(kNeedNewImageUniqueID, alphaType,
- sk_ref_sp(tex),
- std::move(colorSpace), SkBudgeted::kYes);
+ return sk_make_sp<SkImage_Gpu>(context, kNeedNewImageUniqueID, alphaType,
+ std::move(proxy), std::move(colorSpace), SkBudgeted::kYes);
}
class SkSpecialImage_Gpu : public SkSpecialImage_Base {
@@ -386,21 +379,16 @@ public:
SkRect dst = SkRect::MakeXYWH(x, y,
this->subset().width(), this->subset().height());
- // TODO: add GrTextureProxy-backed SkImage_Gpus
- GrTexture* tex = fTextureProxy->instantiate(fContext->resourceProvider());
- if (!tex) {
- return;
- }
-
// TODO: In this instance we know we're going to draw a sub-portion of the backing
// texture into the canvas so it is okay to wrap it in an SkImage. This poses
// some problems for full deferral however in that when the deferred SkImage_Gpu
// instantiates itself it is going to have to either be okay with having a larger
// than expected backing texture (unlikely) or the 'fit' of the SurfaceProxy needs
// to be tightened (if it is deferred).
- auto img = sk_sp<SkImage>(new SkImage_Gpu(this->uniqueID(), fAlphaType,
- sk_ref_sp(tex),
- fColorSpace, SkBudgeted::kNo));
+ sk_sp<SkImage> img = sk_sp<SkImage>(new SkImage_Gpu(canvas->getGrContext(),
+ this->uniqueID(), fAlphaType,
+ fTextureProxy,
+ fColorSpace, SkBudgeted::kNo));
canvas->drawImageRect(img, this->subset(),
dst, paint, SkCanvas::kStrict_SrcRectConstraint);
@@ -480,16 +468,22 @@ public:
fTextureProxy->width() == subset->width() &&
fTextureProxy->height() == subset->height()) {
// The existing GrTexture is already tight so reuse it in the SkImage
- return wrap_proxy_in_image(fContext, fTextureProxy.get(), fAlphaType, fColorSpace);
+ return wrap_proxy_in_image(fContext, fTextureProxy, fAlphaType, fColorSpace);
}
sk_sp<GrTextureProxy> subsetProxy(GrSurfaceProxy::Copy(fContext, fTextureProxy.get(),
*subset, SkBudgeted::kYes));
+ if (!subsetProxy) {
+ return nullptr;
+ }
- return wrap_proxy_in_image(fContext, subsetProxy.get(), fAlphaType, fColorSpace);
+ SkASSERT(subsetProxy->priv().isExact());
+ // MDB: this is acceptable (wrapping subsetProxy in an SkImage) bc Copy will
+ // return a kExact-backed proxy
+ return wrap_proxy_in_image(fContext, std::move(subsetProxy), fAlphaType, fColorSpace);
}
- return wrap_proxy_in_image(fContext, fTextureProxy.get(), fAlphaType, fColorSpace);
+ return wrap_proxy_in_image(fContext, fTextureProxy, fAlphaType, fColorSpace);
}
sk_sp<SkSurface> onMakeTightSurface(const SkImageFilter::OutputProperties& outProps,