Remove SkSpecialImage's GrTexture-based ctors

Change-Id: Id71b8ab0477cd1d459089d97af27d63f9f08d21b
Reviewed-on: https://skia-review.googlesource.com/7889
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2017-02-21 10:19:29 -05:00 committed by Skia Commit-Bot
parent e812d496aa
commit 2c6d2bfced
7 changed files with 67 additions and 71 deletions

View File

@ -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

View File

@ -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,

View File

@ -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,

View File

@ -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;

View File

@ -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()));

View File

@ -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);

View File

@ -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;
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> 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);
}