aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkSpecialImage.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-03-21 13:26:13 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-21 13:26:22 +0000
commiteaa78c45002b4a6e43f4fe2028652b050132dad2 (patch)
tree00c45b889ac05a1a7e34a33f0e301bb2f73b4e5c /src/core/SkSpecialImage.cpp
parent107524c2a26e81ebeb2edaa62a96df3bcde0d0c7 (diff)
Revert "Make SkImage_Gpu be deferred"
This reverts commit 0db235bc0278887c344eb25b4681e9cca4cf892a. Reason for revert: cc_unittests failing Original change's description: > 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> > TBR=bsalomon@google.com,robertphillips@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: Ia15590a1fae04b52723713760fdbf0492ad36286 Reviewed-on: https://skia-review.googlesource.com/9962 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/core/SkSpecialImage.cpp')
-rw-r--r--src/core/SkSpecialImage.cpp38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index 4c7e96188a..411b0ea289 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -346,10 +346,17 @@ sk_sp<SkSpecialImage> SkSpecialImage::MakeFromRaster(const SkIRect& subset,
///////////////////////////////////////////////////////////////////////////////
#include "GrTexture.h"
-static sk_sp<SkImage> wrap_proxy_in_image(GrContext* context, sk_sp<GrTextureProxy> proxy,
+static sk_sp<SkImage> wrap_proxy_in_image(GrContext* context, GrTextureProxy* proxy,
SkAlphaType alphaType, sk_sp<SkColorSpace> colorSpace) {
- return sk_make_sp<SkImage_Gpu>(context, kNeedNewImageUniqueID, alphaType,
- std::move(proxy), std::move(colorSpace), SkBudgeted::kYes);
+ // 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);
}
class SkSpecialImage_Gpu : public SkSpecialImage_Base {
@@ -379,16 +386,21 @@ 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).
- sk_sp<SkImage> img = sk_sp<SkImage>(new SkImage_Gpu(canvas->getGrContext(),
- this->uniqueID(), fAlphaType,
- fTextureProxy,
- fColorSpace, SkBudgeted::kNo));
+ auto img = sk_sp<SkImage>(new SkImage_Gpu(this->uniqueID(), fAlphaType,
+ sk_ref_sp(tex),
+ fColorSpace, SkBudgeted::kNo));
canvas->drawImageRect(img, this->subset(),
dst, paint, SkCanvas::kStrict_SrcRectConstraint);
@@ -468,22 +480,16 @@ 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, fAlphaType, fColorSpace);
+ return wrap_proxy_in_image(fContext, fTextureProxy.get(), fAlphaType, fColorSpace);
}
sk_sp<GrTextureProxy> subsetProxy(GrSurfaceProxy::Copy(fContext, fTextureProxy.get(),
*subset, SkBudgeted::kYes));
- if (!subsetProxy) {
- return nullptr;
- }
- 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, subsetProxy.get(), fAlphaType, fColorSpace);
}
- return wrap_proxy_in_image(fContext, fTextureProxy, fAlphaType, fColorSpace);
+ return wrap_proxy_in_image(fContext, fTextureProxy.get(), fAlphaType, fColorSpace);
}
sk_sp<SkSurface> onMakeTightSurface(const SkImageFilter::OutputProperties& outProps,