aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/core/SkBlurImageFilter.cpp12
-rw-r--r--src/core/SkSpecialImage.cpp22
-rw-r--r--src/core/SkSpecialImage.h9
-rw-r--r--src/core/SkSpecialSurface.cpp5
-rw-r--r--src/gpu/SkGpuDevice.cpp5
-rw-r--r--tests/ImageFilterCacheTest.cpp33
-rw-r--r--tests/SpecialImageTest.cpp54
7 files changed, 68 insertions, 72 deletions
diff --git a/src/core/SkBlurImageFilter.cpp b/src/core/SkBlurImageFilter.cpp
index 462edb545a..4c68437fde 100644
--- a/src/core/SkBlurImageFilter.cpp
+++ b/src/core/SkBlurImageFilter.cpp
@@ -173,11 +173,13 @@ sk_sp<SkSpecialImage> SkBlurImageFilterImpl::onFilterImage(SkSpecialImage* sourc
return nullptr;
}
- return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(dstBounds.width(), dstBounds.height()),
- kNeedNewImageUniqueID_SpecialImage,
- renderTargetContext->asTexture(),
- renderTargetContext->refColorSpace(),
- &source->props());
+ return SkSpecialImage::MakeDeferredFromGpu(context,
+ SkIRect::MakeWH(dstBounds.width(),
+ dstBounds.height()),
+ kNeedNewImageUniqueID_SpecialImage,
+ renderTargetContext->asTextureProxyRef(),
+ renderTargetContext->refColorSpace(),
+ &source->props());
}
#endif
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index 7d6dc66d61..c523ae833f 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -364,17 +364,6 @@ static sk_sp<SkImage> wrap_proxy_in_image(GrContext* context, GrTextureProxy* pr
class SkSpecialImage_Gpu : public SkSpecialImage_Base {
public:
- SkSpecialImage_Gpu(const SkIRect& subset,
- uint32_t uniqueID, sk_sp<GrTexture> tex, SkAlphaType at,
- sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* props)
- : INHERITED(subset, uniqueID, props)
- , fContext(tex->getContext())
- , fTextureProxy(GrSurfaceProxy::MakeWrapped(std::move(tex)))
- , fAlphaType(at)
- , fColorSpace(std::move(colorSpace))
- , fAddedRasterVersionToCache(false) {
- }
-
SkSpecialImage_Gpu(GrContext* context, const SkIRect& subset,
uint32_t uniqueID, sk_sp<GrTextureProxy> proxy, SkAlphaType at,
sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* props)
@@ -527,17 +516,6 @@ private:
typedef SkSpecialImage_Base INHERITED;
};
-sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(const SkIRect& subset,
- uint32_t uniqueID,
- sk_sp<GrTexture> tex,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* props,
- SkAlphaType at) {
- SkASSERT(rect_fits(subset, tex->width(), tex->height()));
- return sk_make_sp<SkSpecialImage_Gpu>(subset, uniqueID, std::move(tex), at,
- std::move(colorSpace), props);
-}
-
sk_sp<SkSpecialImage> SkSpecialImage::MakeDeferredFromGpu(GrContext* context,
const SkIRect& subset,
uint32_t uniqueID,
diff --git a/src/core/SkSpecialImage.h b/src/core/SkSpecialImage.h
index 3edc820495..33de36ca23 100644
--- a/src/core/SkSpecialImage.h
+++ b/src/core/SkSpecialImage.h
@@ -36,7 +36,7 @@ enum {
* This is a restricted form of SkImage solely intended for internal use. It
* differs from SkImage in that:
* - it can only be backed by raster or gpu (no generators)
- * - it can be backed by a GrTexture larger than its nominal bounds
+ * - it can be backed by a GrTextureProxy larger than its nominal bounds
* - it can't be drawn tiled
* - it can't be drawn with MIPMAPs
* It is similar to SkImage in that it abstracts how the pixels are stored/represented.
@@ -79,13 +79,6 @@ public:
const SkBitmap&,
const SkSurfaceProps* = nullptr);
#if SK_SUPPORT_GPU
- static sk_sp<SkSpecialImage> MakeFromGpu(const SkIRect& subset,
- uint32_t uniqueID,
- sk_sp<GrTexture>,
- sk_sp<SkColorSpace>,
- const SkSurfaceProps* = nullptr,
- SkAlphaType at = kPremul_SkAlphaType);
-
static sk_sp<SkSpecialImage> MakeDeferredFromGpu(GrContext*,
const SkIRect& subset,
uint32_t uniqueID,
diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp
index ee0b192263..381e3d8eb1 100644
--- a/src/core/SkSpecialSurface.cpp
+++ b/src/core/SkSpecialSurface.cpp
@@ -139,10 +139,11 @@ public:
if (!fRenderTargetContext->asTexture()) {
return nullptr;
}
- sk_sp<SkSpecialImage> tmp(SkSpecialImage::MakeFromGpu(
+ sk_sp<SkSpecialImage> tmp(SkSpecialImage::MakeDeferredFromGpu(
+ fCanvas->getGrContext(),
this->subset(),
kNeedNewImageUniqueID_SpecialImage,
- fRenderTargetContext->asTexture(),
+ fRenderTargetContext->asTextureProxyRef(),
fRenderTargetContext->refColorSpace(),
&this->props()));
fRenderTargetContext = nullptr;
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index ad1359c1e8..f1cbda7cb7 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1163,7 +1163,7 @@ void SkGpuDevice::drawSpecial(const SkDraw& draw,
}
SkASSERT(result->isTextureBacked());
- sk_sp<GrTextureProxy> proxy = result->asTextureProxyRef(fContext.get());
+ sk_sp<GrTextureProxy> proxy = result->asTextureProxyRef(this->context());
if (!proxy) {
return;
}
@@ -1175,7 +1175,8 @@ void SkGpuDevice::drawSpecial(const SkDraw& draw,
sk_sp<GrColorSpaceXform> colorSpaceXform =
GrColorSpaceXform::Make(result->getColorSpace(), fRenderTargetContext->getColorSpace());
- sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(fContext.get(),
+
+ sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(this->context(),
std::move(proxy),
std::move(colorSpaceXform),
SkMatrix::I()));
diff --git a/tests/ImageFilterCacheTest.cpp b/tests/ImageFilterCacheTest.cpp
index 393269adf6..d2d543c1f9 100644
--- a/tests/ImageFilterCacheTest.cpp
+++ b/tests/ImageFilterCacheTest.cpp
@@ -192,6 +192,24 @@ static GrTexture* create_texture(GrContext* context) {
return context->textureProvider()->createTexture(desc, SkBudgeted::kNo, srcBM.getPixels(), 0);
}
+static sk_sp<GrTextureProxy> create_proxy(GrContext* context) {
+ SkBitmap srcBM = create_bm();
+
+ GrSurfaceDesc desc;
+ desc.fConfig = kRGBA_8888_GrPixelConfig;
+ desc.fFlags = kNone_GrSurfaceFlags;
+ desc.fWidth = kFullSize;
+ desc.fHeight = kFullSize;
+
+ sk_sp<GrSurfaceProxy> proxy = GrSurfaceProxy::MakeDeferred(*context->caps(),
+ context->textureProvider(),
+ desc, SkBudgeted::kYes,
+ srcBM.getPixels(),
+ srcBM.rowBytes());
+ return sk_ref_sp(proxy->asTextureProxy());
+}
+
+
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_ImageBackedGPU, reporter, ctxInfo) {
sk_sp<GrTexture> srcTexture(create_texture(ctxInfo.grContext()));
if (!srcTexture) {
@@ -234,23 +252,26 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_ImageBackedGPU, reporter, ct
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_GPUBacked, reporter, ctxInfo) {
+ GrContext* context = ctxInfo.grContext();
- sk_sp<GrTexture> srcTexture(create_texture(ctxInfo.grContext()));
- if (!srcTexture) {
+ sk_sp<GrTextureProxy> srcProxy(create_proxy(context));
+ if (!srcProxy) {
return;
}
const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize);
- sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromGpu(full,
+ sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeDeferredFromGpu(
+ context, full,
kNeedNewImageUniqueID_SpecialImage,
- srcTexture, nullptr));
+ srcProxy, nullptr));
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
- sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromGpu(subset,
+ sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeDeferredFromGpu(
+ context, subset,
kNeedNewImageUniqueID_SpecialImage,
- srcTexture, nullptr));
+ srcProxy, nullptr));
test_find_existing(reporter, fullImg, subsetImg);
test_dont_find_if_diff_key(reporter, fullImg, subsetImg);
diff --git a/tests/SpecialImageTest.cpp b/tests/SpecialImageTest.cpp
index 80cacde960..77015c4aa2 100644
--- a/tests/SpecialImageTest.cpp
+++ b/tests/SpecialImageTest.cpp
@@ -18,6 +18,7 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrSurfaceProxy.h"
+#include "SkGrPriv.h"
#endif
@@ -60,7 +61,7 @@ static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* rep
REPORTER_ASSERT(reporter, kSmallerSize == subset.height());
//--------------
- // Test that peekTexture reports the correct backing type
+ // Test that isTextureBacked reports the correct backing type
REPORTER_ASSERT(reporter, isGPUBacked == img->isTextureBacked());
#if SK_SUPPORT_GPU
@@ -230,25 +231,23 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_MakeTexture, reporter, ctxInfo)
{
// gpu
- GrSurfaceDesc desc;
- desc.fConfig = kSkia8888_GrPixelConfig;
- desc.fFlags = kNone_GrSurfaceFlags;
- desc.fWidth = kFullSize;
- desc.fHeight = kFullSize;
-
- sk_sp<GrTexture> texture(context->textureProvider()->createTexture(desc,
- SkBudgeted::kNo,
- bm.getPixels(),
- 0));
- if (!texture) {
+ const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bm.info(), *context->caps());
+
+ sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeDeferred(*context->caps(),
+ context->textureProvider(),
+ desc, SkBudgeted::kNo,
+ bm.getPixels(), bm.rowBytes()));
+ if (!proxy || !proxy->asTextureProxy()) {
return;
}
- sk_sp<SkSpecialImage> gpuImage(SkSpecialImage::MakeFromGpu(
+ sk_sp<SkSpecialImage> gpuImage(SkSpecialImage::MakeDeferredFromGpu(
+ context,
SkIRect::MakeWH(kFullSize,
kFullSize),
kNeedNewImageUniqueID_SpecialImage,
- std::move(texture), nullptr));
+ sk_ref_sp(proxy->asTextureProxy()),
+ nullptr));
{
sk_sp<SkSpecialImage> fromGPU(gpuImage->makeTextureImage(context));
@@ -268,31 +267,32 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
SkBitmap bm = create_bm();
- GrSurfaceDesc desc;
- desc.fConfig = kSkia8888_GrPixelConfig;
- desc.fFlags = kNone_GrSurfaceFlags;
- desc.fWidth = kFullSize;
- desc.fHeight = kFullSize;
+ const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bm.info(), *context->caps());
- sk_sp<GrTexture> texture(context->textureProvider()->createTexture(desc,
- SkBudgeted::kNo,
- bm.getPixels(), 0));
- if (!texture) {
+ sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeDeferred(*context->caps(),
+ context->textureProvider(),
+ desc, SkBudgeted::kNo,
+ bm.getPixels(), bm.rowBytes()));
+ if (!proxy || !proxy->asTextureProxy()) {
return;
}
- sk_sp<SkSpecialImage> fullSImg(SkSpecialImage::MakeFromGpu(
+ sk_sp<SkSpecialImage> fullSImg(SkSpecialImage::MakeDeferredFromGpu(
+ context,
SkIRect::MakeWH(kFullSize, kFullSize),
kNeedNewImageUniqueID_SpecialImage,
- texture, nullptr));
+ sk_ref_sp(proxy->asTextureProxy()),
+ nullptr));
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
{
- sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromGpu(
+ sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeDeferredFromGpu(
+ context,
subset,
kNeedNewImageUniqueID_SpecialImage,
- texture, nullptr));
+ sk_ref_sp(proxy->asTextureProxy()),
+ nullptr));
test_image(subSImg1, reporter, context, true, kPad, kFullSize);
}