aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gm/flippity.cpp8
-rw-r--r--gm/texdata.cpp8
-rw-r--r--gm/texturedomaineffect.cpp10
-rw-r--r--gm/yuvtorgbeffect.cpp16
-rw-r--r--include/private/GrRenderTargetProxy.h2
-rw-r--r--include/private/GrSurfaceProxy.h39
-rw-r--r--include/private/GrTextureProxy.h2
-rw-r--r--src/effects/GrCircleBlurFragmentProcessor.cpp5
-rw-r--r--src/gpu/GrBitmapTextureMaker.cpp3
-rw-r--r--src/gpu/GrClipStackClip.cpp5
-rw-r--r--src/gpu/GrContext.cpp55
-rw-r--r--src/gpu/GrDrawOpAtlas.cpp22
-rw-r--r--src/gpu/GrOnFlushResourceProvider.cpp11
-rw-r--r--src/gpu/GrProxyProvider.cpp208
-rw-r--r--src/gpu/GrProxyProvider.h68
-rw-r--r--src/gpu/GrResourceProvider.cpp14
-rw-r--r--src/gpu/GrSoftwarePathRenderer.cpp7
-rw-r--r--src/gpu/GrSurfaceProxy.cpp175
-rw-r--r--src/gpu/GrTextureRenderTargetProxy.h2
-rw-r--r--src/gpu/SkGr.cpp35
-rw-r--r--src/gpu/SkGr.h4
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.h5
-rw-r--r--src/gpu/effects/GrRectBlurEffect.h4
-rw-r--r--src/gpu/effects/GrTextureStripAtlas.cpp6
-rw-r--r--src/gpu/ops/GrTextureOp.cpp8
-rw-r--r--src/image/SkImage_Gpu.cpp30
-rw-r--r--src/image/SkImage_Lazy.cpp2
-rw-r--r--tests/CopySurfaceTest.cpp16
-rw-r--r--tests/DetermineDomainModeTest.cpp3
-rw-r--r--tests/FloatingPointTextureTest.cpp8
-rw-r--r--tests/GLProgramsTest.cpp31
-rw-r--r--tests/GrPorterDuffTest.cpp6
-rw-r--r--tests/GrSurfaceTest.cpp32
-rw-r--r--tests/ImageFilterCacheTest.cpp6
-rw-r--r--tests/IntTextureTest.cpp31
-rw-r--r--tests/OnFlushCallbackTest.cpp12
-rw-r--r--tests/PackedConfigsTextureTest.cpp7
-rw-r--r--tests/ProcessorTest.cpp91
-rw-r--r--tests/ProxyConversionTest.cpp56
-rw-r--r--tests/ProxyRefTest.cpp37
-rw-r--r--tests/ProxyTest.cpp84
-rw-r--r--tests/ReadPixelsTest.cpp8
-rw-r--r--tests/ReadWriteAlphaTest.cpp12
-rw-r--r--tests/RectangleTextureTest.cpp8
-rw-r--r--tests/ResourceAllocatorTest.cpp9
-rw-r--r--tests/ResourceCacheTest.cpp6
-rw-r--r--tests/SRGBMipMapTest.cpp6
-rw-r--r--tests/SpecialImageTest.cpp20
-rw-r--r--tests/TestUtils.cpp7
-rw-r--r--tests/TextureProxyTest.cpp37
-rw-r--r--tests/VkUploadPixelsTests.cpp8
-rw-r--r--tests/WritePixelsTest.cpp6
52 files changed, 649 insertions, 652 deletions
diff --git a/gm/flippity.cpp b/gm/flippity.cpp
index 93813b943f..bd9930c9df 100644
--- a/gm/flippity.cpp
+++ b/gm/flippity.cpp
@@ -13,6 +13,7 @@
#if SK_SUPPORT_GPU
#include "GrContextPriv.h"
+#include "GrProxyProvider.h"
#include "SkImage_Gpu.h"
static const int kNumMatrices = 6;
@@ -93,6 +94,7 @@ static SkColor swap_red_and_blue(SkColor c) {
static sk_sp<SkImage> make_reference_image(GrContext* context,
const SkTArray<sk_sp<SkImage>>& labels,
bool bottomLeftOrigin) {
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
SkASSERT(kNumLabels == labels.count());
SkImageInfo ii = SkImageInfo::Make(kImageSize, kImageSize,
@@ -130,10 +132,8 @@ static sk_sp<SkImage> make_reference_image(GrContext* context,
}
}
- sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(
- context->contextPriv().proxyProvider(),
- desc, SkBudgeted::kYes,
- bm.getPixels(), bm.rowBytes());
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(desc, SkBudgeted::kYes,
+ bm.getPixels(), bm.rowBytes());
if (!proxy) {
return nullptr;
}
diff --git a/gm/texdata.cpp b/gm/texdata.cpp
index 4e44bccbdf..b4193a3423 100644
--- a/gm/texdata.cpp
+++ b/gm/texdata.cpp
@@ -12,6 +12,7 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrContextPriv.h"
+#include "GrProxyProvider.h"
#include "GrRenderTargetContext.h"
#include "GrTextureContext.h"
#include "GrFixedClip.h"
@@ -76,6 +77,7 @@ DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
return;
}
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
const SkImageInfo ii = SkImageInfo::Make(S, S, kBGRA_8888_SkColorType, kPremul_SkAlphaType);
SkAutoTArray<SkPMColor> gTextureData((2 * S) * (2 * S));
@@ -91,10 +93,8 @@ DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
desc.fHeight = 2 * S;
desc.fConfig = SkImageInfo2GrPixelConfig(ii, *context->caps());
- sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(
- context->contextPriv().proxyProvider(),
- desc, SkBudgeted::kNo,
- gTextureData.get(), 0);
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(desc, SkBudgeted::kNo,
+ gTextureData.get(), 0);
if (!proxy) {
return;
}
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp
index 7ee28b1ffb..57f012973f 100644
--- a/gm/texturedomaineffect.cpp
+++ b/gm/texturedomaineffect.cpp
@@ -13,6 +13,7 @@
#include "GrContext.h"
#include "GrContextPriv.h"
+#include "GrProxyProvider.h"
#include "GrRenderTargetContextPriv.h"
#include "SkBitmap.h"
#include "SkGr.h"
@@ -86,17 +87,16 @@ protected:
return;
}
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
GrSurfaceDesc desc;
desc.fOrigin = kTopLeft_GrSurfaceOrigin;
desc.fWidth = fBmp.width();
desc.fHeight = fBmp.height();
desc.fConfig = SkImageInfo2GrPixelConfig(fBmp.info(), *context->caps());
- sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(
- context->contextPriv().proxyProvider(),
- desc, SkBudgeted::kYes,
- fBmp.getPixels(),
- fBmp.rowBytes()));
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(desc, SkBudgeted::kYes,
+ fBmp.getPixels(),
+ fBmp.rowBytes());
if (!proxy) {
return;
}
diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp
index ba27719e3b..e314ea28bc 100644
--- a/gm/yuvtorgbeffect.cpp
+++ b/gm/yuvtorgbeffect.cpp
@@ -13,6 +13,7 @@
#include "GrContext.h"
#include "GrContextPriv.h"
+#include "GrProxyProvider.h"
#include "GrRenderTargetContextPriv.h"
#include "GrTextureProxy.h"
#include "SkBitmap.h"
@@ -82,6 +83,7 @@ protected:
return;
}
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
sk_sp<GrTextureProxy> proxy[3];
{
@@ -93,9 +95,9 @@ protected:
desc.fHeight = fBmp[i].height();
desc.fConfig = SkImageInfo2GrPixelConfig(fBmp[i].info(), *context->caps());
- proxy[i] = GrSurfaceProxy::MakeDeferred(context->contextPriv().proxyProvider(),
- desc, SkBudgeted::kYes,
- fBmp[i].getPixels(), fBmp[i].rowBytes());
+ proxy[i] = proxyProvider->createTextureProxy(desc, SkBudgeted::kYes,
+ fBmp[i].getPixels(),
+ fBmp[i].rowBytes());
if (!proxy[i]) {
return;
}
@@ -210,6 +212,7 @@ protected:
return;
}
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
sk_sp<GrTextureProxy> proxy[3];
{
@@ -223,10 +226,9 @@ protected:
desc.fHeight = fBmp[index].height();
desc.fConfig = SkImageInfo2GrPixelConfig(fBmp[index].info(), *context->caps());
- proxy[i] = GrSurfaceProxy::MakeDeferred(context->contextPriv().proxyProvider(),
- desc, SkBudgeted::kYes,
- fBmp[index].getPixels(),
- fBmp[index].rowBytes());
+ proxy[i] = proxyProvider->createTextureProxy(desc, SkBudgeted::kYes,
+ fBmp[index].getPixels(),
+ fBmp[index].rowBytes());
if (!proxy[i]) {
return;
}
diff --git a/include/private/GrRenderTargetProxy.h b/include/private/GrRenderTargetProxy.h
index bccb6a8b9e..1cd3d5d1a2 100644
--- a/include/private/GrRenderTargetProxy.h
+++ b/include/private/GrRenderTargetProxy.h
@@ -61,7 +61,7 @@ public:
bool refsWrappedObjects() const;
protected:
- friend class GrSurfaceProxy; // for ctors
+ friend class GrProxyProvider; // for ctors
// Deferred version
GrRenderTargetProxy(const GrCaps&, const GrSurfaceDesc&,
diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h
index 1a558fe5b5..5a2a4b536e 100644
--- a/include/private/GrSurfaceProxy.h
+++ b/include/private/GrSurfaceProxy.h
@@ -182,45 +182,9 @@ private:
class GrSurfaceProxy : public GrIORefProxy {
public:
- static sk_sp<GrSurfaceProxy> MakeWrapped(sk_sp<GrSurface>, GrSurfaceOrigin);
+ // DDL TODO: remove this entry point
static sk_sp<GrTextureProxy> MakeWrapped(sk_sp<GrTexture>, GrSurfaceOrigin);
- static sk_sp<GrTextureProxy> MakeDeferred(GrProxyProvider*,
- const GrSurfaceDesc&, SkBackingFit,
- SkBudgeted, uint32_t flags = 0);
-
- /**
- * Creates a proxy that will be mipmapped.
- *
- * @param desc Description of the texture properties.
- * @param budgeted Does the texture count against the resource cache budget?
- * @param texels A contiguous array of mipmap levels
- * @param mipLevelCount The amount of elements in the texels array
- */
- static sk_sp<GrTextureProxy> MakeDeferredMipMap(GrProxyProvider*,
- const GrSurfaceDesc& desc, SkBudgeted budgeted,
- const GrMipLevel texels[], int mipLevelCount,
- SkDestinationSurfaceColorMode mipColorMode =
- SkDestinationSurfaceColorMode::kLegacy);
-
- /**
- * Like the call above but there are no texels to upload. A texture proxy is returned that
- * simply has space allocated for the mips. We will allocated the full amount of mip levels
- * based on the width and height in the GrSurfaceDesc.
- */
- static sk_sp<GrTextureProxy> MakeDeferredMipMap(GrProxyProvider*,
- const GrSurfaceDesc& desc, SkBudgeted budgeted);
-
-
- // TODO: need to refine ownership semantics of 'srcData' if we're in completely
- // deferred mode
- static sk_sp<GrTextureProxy> MakeDeferred(GrProxyProvider*,
- const GrSurfaceDesc&, SkBudgeted,
- const void* srcData, size_t rowBytes);
-
- static sk_sp<GrTextureProxy> MakeWrappedBackend(GrContext*, const GrBackendTexture&,
- GrSurfaceOrigin);
-
using LazyInstantiateCallback = std::function<sk_sp<GrTexture>(GrResourceProvider*,
GrSurfaceOrigin* outOrigin)>;
@@ -234,6 +198,7 @@ public:
* (Stencil is not supported by this method.) The width and height must either both be greater
* than 0 or both less than or equal to zero. A non-positive value is a signal that the width
* and height are currently unknown.
+ * DDL TODO: remove this entry point
*/
static sk_sp<GrTextureProxy> MakeLazy(LazyInstantiateCallback&&, const GrSurfaceDesc& desc,
GrMipMapped, SkBackingFit fit, SkBudgeted budgeted);
diff --git a/include/private/GrTextureProxy.h b/include/private/GrTextureProxy.h
index d4daa8e94e..e9d4c50eeb 100644
--- a/include/private/GrTextureProxy.h
+++ b/include/private/GrTextureProxy.h
@@ -61,7 +61,9 @@ public:
const GrTextureProxyPriv texPriv() const;
protected:
+ // DDL TODO: rm the GrSurfaceProxy friending
friend class GrSurfaceProxy; // for ctors
+ friend class GrProxyProvider; // for ctors
friend class GrTextureProxyPriv;
// Deferred version
diff --git a/src/effects/GrCircleBlurFragmentProcessor.cpp b/src/effects/GrCircleBlurFragmentProcessor.cpp
index 55095e0099..d414e66aeb 100644
--- a/src/effects/GrCircleBlurFragmentProcessor.cpp
+++ b/src/effects/GrCircleBlurFragmentProcessor.cpp
@@ -227,8 +227,9 @@ static sk_sp<GrTextureProxy> create_profile_texture(GrProxyProvider* proxyProvid
create_circle_profile(sigma * scale, circleR * scale, kProfileTextureWidth));
}
- blurProfile = GrSurfaceProxy::MakeDeferred(proxyProvider, texDesc, SkBudgeted::kYes,
- profile.get(), 0);
+ // This will be an exact match texture
+ blurProfile = proxyProvider->createTextureProxy(texDesc, SkBudgeted::kYes,
+ profile.get(), 0);
if (!blurProfile) {
return nullptr;
}
diff --git a/src/gpu/GrBitmapTextureMaker.cpp b/src/gpu/GrBitmapTextureMaker.cpp
index 064b1aaaa4..7531bf6680 100644
--- a/src/gpu/GrBitmapTextureMaker.cpp
+++ b/src/gpu/GrBitmapTextureMaker.cpp
@@ -49,8 +49,7 @@ sk_sp<GrTextureProxy> GrBitmapTextureMaker::refOriginalTextureProxy(bool willBeM
if (!proxy) {
if (willBeMipped) {
- proxy = GrGenerateMipMapsAndUploadToTextureProxy(this->context(), fBitmap,
- dstColorSpace);
+ proxy = GrGenerateMipMapsAndUploadToTextureProxy(proxyProvider, fBitmap, dstColorSpace);
}
if (!proxy) {
proxy = GrUploadBitmapToTextureProxy(proxyProvider, fBitmap, dstColorSpace);
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index ce77369bb7..35fd52df0e 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -464,9 +464,8 @@ sk_sp<GrTextureProxy> GrClipStackClip::createSoftwareClipMask(
desc.fConfig = kAlpha_8_GrPixelConfig;
// MDB TODO: We're going to fill this proxy with an ASAP upload (which is out of order wrt
// to ops), so it can't have any pending IO.
- proxy = GrSurfaceProxy::MakeDeferred(proxyProvider, desc,
- SkBackingFit::kApprox, SkBudgeted::kYes,
- GrResourceProvider::kNoPendingIO_Flag);
+ proxy = proxyProvider->createProxy(desc, SkBackingFit::kApprox, SkBudgeted::kYes,
+ GrResourceProvider::kNoPendingIO_Flag);
auto uploader = skstd::make_unique<GrTDeferredProxyUploader<ClipMaskData>>(reducedClip);
GrTDeferredProxyUploader<ClipMaskData>* uploaderRaw = uploader.get();
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 131ac4562b..95d23441ac 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -530,10 +530,9 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceContext* dst,
sk_sp<GrTextureProxy> tempProxy;
if (GrGpu::kNoDraw_DrawPreference != drawPreference) {
- tempProxy = GrSurfaceProxy::MakeDeferred(this->proxyProvider(),
- tempDrawInfo.fTempSurfaceDesc,
- SkBackingFit::kApprox,
- SkBudgeted::kYes);
+ tempProxy = this->proxyProvider()->createProxy(tempDrawInfo.fTempSurfaceDesc,
+ SkBackingFit::kApprox,
+ SkBudgeted::kYes);
if (!tempProxy && GrGpu::kRequireDraw_DrawPreference == drawPreference) {
return false;
}
@@ -821,12 +820,10 @@ sk_sp<GrSurfaceContext> GrContextPriv::makeDeferredSurfaceContext(const GrSurfac
sk_sp<GrTextureProxy> proxy;
if (GrMipMapped::kNo == mipMapped) {
- proxy = GrSurfaceProxy::MakeDeferred(this->proxyProvider(), dstDesc, fit,
- isDstBudgeted);
+ proxy = this->proxyProvider()->createProxy(dstDesc, fit, isDstBudgeted);
} else {
SkASSERT(SkBackingFit::kExact == fit);
- proxy = GrSurfaceProxy::MakeDeferredMipMap(this->proxyProvider(), dstDesc,
- isDstBudgeted);
+ proxy = this->proxyProvider()->createMipMapProxy(dstDesc, isDstBudgeted);
}
if (!proxy) {
return nullptr;
@@ -840,12 +837,7 @@ sk_sp<GrTextureContext> GrContextPriv::makeBackendTextureContext(const GrBackend
sk_sp<SkColorSpace> colorSpace) {
ASSERT_SINGLE_OWNER_PRIV
- sk_sp<GrSurface> surface(fContext->resourceProvider()->wrapBackendTexture(tex));
- if (!surface) {
- return nullptr;
- }
-
- sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(surface), origin));
+ sk_sp<GrSurfaceProxy> proxy = this->proxyProvider()->createWrappedTextureProxy(tex, origin);
if (!proxy) {
return nullptr;
}
@@ -861,13 +853,8 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureRenderTargetContex
const SkSurfaceProps* props) {
ASSERT_SINGLE_OWNER_PRIV
- sk_sp<GrSurface> surface(
- fContext->resourceProvider()->wrapRenderableBackendTexture(tex, sampleCnt));
- if (!surface) {
- return nullptr;
- }
-
- sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(surface), origin));
+ sk_sp<GrTextureProxy> proxy(this->proxyProvider()->createWrappedTextureProxy(tex, origin,
+ sampleCnt));
if (!proxy) {
return nullptr;
}
@@ -883,12 +870,8 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendRenderTargetRenderTargetC
const SkSurfaceProps* surfaceProps) {
ASSERT_SINGLE_OWNER_PRIV
- sk_sp<GrRenderTarget> rt(fContext->resourceProvider()->wrapBackendRenderTarget(backendRT));
- if (!rt) {
- return nullptr;
- }
-
- sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(rt), origin));
+ sk_sp<GrSurfaceProxy> proxy = this->proxyProvider()->createWrappedRenderTargetProxy(backendRT,
+ origin);
if (!proxy) {
return nullptr;
}
@@ -903,24 +886,18 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureAsRenderTargetRend
GrSurfaceOrigin origin,
int sampleCnt,
sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* surfaceProps) {
+ const SkSurfaceProps* props) {
ASSERT_SINGLE_OWNER_PRIV
- sk_sp<GrSurface> surface(fContext->resourceProvider()->wrapBackendTextureAsRenderTarget(
- tex,
- sampleCnt));
- if (!surface) {
- return nullptr;
- }
-
- sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(surface), origin));
+ sk_sp<GrSurfaceProxy> proxy(this->proxyProvider()->createWrappedRenderTargetProxy(tex, origin,
+ sampleCnt));
if (!proxy) {
return nullptr;
}
return this->drawingManager()->makeRenderTargetContext(std::move(proxy),
std::move(colorSpace),
- surfaceProps);
+ props);
}
void GrContextPriv::addOnFlushCallbackObject(GrOnFlushCallbackObject* onFlushCBObject) {
@@ -987,9 +964,9 @@ sk_sp<GrRenderTargetContext> GrContext::makeDeferredRenderTargetContext(
sk_sp<GrTextureProxy> rtp;
if (GrMipMapped::kNo == mipMapped) {
- rtp = GrSurfaceProxy::MakeDeferred(fProxyProvider, desc, fit, budgeted);
+ rtp = fProxyProvider->createProxy(desc, fit, budgeted);
} else {
- rtp = GrSurfaceProxy::MakeDeferredMipMap(fProxyProvider, desc, budgeted);
+ rtp = fProxyProvider->createMipMapProxy(desc, budgeted);
}
if (!rtp) {
return nullptr;
diff --git a/src/gpu/GrDrawOpAtlas.cpp b/src/gpu/GrDrawOpAtlas.cpp
index c0358b79ea..0ba9deca04 100644
--- a/src/gpu/GrDrawOpAtlas.cpp
+++ b/src/gpu/GrDrawOpAtlas.cpp
@@ -8,8 +8,10 @@
#include "GrDrawOpAtlas.h"
#include "GrContext.h"
+#include "GrContextPriv.h"
#include "GrOpFlushState.h"
#include "GrRectanizer.h"
+#include "GrProxyProvider.h"
#include "GrResourceProvider.h"
#include "GrTexture.h"
#include "GrTracing.h"
@@ -452,6 +454,8 @@ bool GrDrawOpAtlas::createNewPage() {
return false;
}
+ GrProxyProvider* proxyProvider = fContext->contextPriv().proxyProvider();
+
GrSurfaceDesc desc;
desc.fFlags = kNone_GrSurfaceFlags;
desc.fOrigin = kTopLeft_GrSurfaceOrigin;
@@ -463,16 +467,14 @@ bool GrDrawOpAtlas::createNewPage() {
// guarantee we do not recieve a texture with pending IO
// TODO: Determine how to avoid having to do this. (https://bug.skia.org/4156)
static const uint32_t kFlags = GrResourceProvider::kNoPendingIO_Flag;
- sk_sp<GrTexture> texture(fContext->resourceProvider()->createApproxTexture(desc, kFlags));
- if (texture) {
- // MDB TODO: for now, wrap an instantiated texture. Having the deferred instantiation
- // possess the correct properties (e.g., no pendingIO) should fall out of the system but
- // should receive special attention.
- // Note: When switching over to the deferred proxy, use the kExact flag to create
- // the atlas and assert that the width & height are powers of 2.
- fProxies[fNumPages] = GrSurfaceProxy::MakeWrapped(std::move(texture),
- kTopLeft_GrSurfaceOrigin);
- }
+ // MDB TODO: for now, wrap an instantiated texture. Having the deferred instantiation
+ // possess the correct properties (e.g., no pendingIO) should fall out of the system but
+ // should receive special attention.
+ // Note: When switching over to the deferred proxy, use the kExact flag to create
+ // the atlas and assert that the width & height are powers of 2.
+ // DDL TODO: remove this use of createInstantitateProxy & convert it to a testing-only method.
+ fProxies[fNumPages] = proxyProvider->createInstantiatedProxy(desc, SkBackingFit::kApprox,
+ SkBudgeted::kYes, kFlags);
if (!fProxies[fNumPages]) {
return false;
}
diff --git a/src/gpu/GrOnFlushResourceProvider.cpp b/src/gpu/GrOnFlushResourceProvider.cpp
index a93c9eb9c6..7fcd30f941 100644
--- a/src/gpu/GrOnFlushResourceProvider.cpp
+++ b/src/gpu/GrOnFlushResourceProvider.cpp
@@ -9,6 +9,7 @@
#include "GrContextPriv.h"
#include "GrDrawingManager.h"
+#include "GrProxyProvider.h"
#include "GrSurfaceProxy.h"
sk_sp<GrRenderTargetContext> GrOnFlushResourceProvider::makeRenderTargetContext(
@@ -21,12 +22,10 @@ sk_sp<GrRenderTargetContext> GrOnFlushResourceProvider::makeRenderTargetContext(
// Because this is being allocated at the start of a flush we must ensure the proxy
// will, when instantiated, have no pending IO.
// TODO: fold the kNoPendingIO_Flag into GrSurfaceFlags?
- sk_sp<GrSurfaceProxy> proxy = GrSurfaceProxy::MakeDeferred(
- fDrawingMgr->getContext()->contextPriv().proxyProvider(),
- tmpDesc,
- SkBackingFit::kExact,
- SkBudgeted::kYes,
- GrResourceProvider::kNoPendingIO_Flag);
+ GrProxyProvider* proxyProvider = fDrawingMgr->getContext()->contextPriv().proxyProvider();
+ sk_sp<GrSurfaceProxy> proxy = proxyProvider->createProxy(tmpDesc, SkBackingFit::kExact,
+ SkBudgeted::kYes,
+ GrResourceProvider::kNoPendingIO_Flag);
if (!proxy->asRenderTargetProxy()) {
return nullptr;
}
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index c9617ad9c3..942d17ff61 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -8,13 +8,16 @@
#include "GrProxyProvider.h"
#include "GrCaps.h"
+#include "GrRenderTarget.h"
#include "GrResourceKey.h"
#include "GrResourceProvider.h"
#include "GrSurfaceProxy.h"
#include "GrSurfaceProxyPriv.h"
#include "GrTexture.h"
#include "GrTextureProxyCacheAccess.h"
+#include "GrTextureRenderTargetProxy.h"
#include "../private/GrSingleOwner.h"
+#include "SkMipMap.h"
#define ASSERT_SINGLE_OWNER \
SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);)
@@ -126,24 +129,54 @@ sk_sp<GrTextureProxy> GrProxyProvider::findOrCreateProxyByUniqueKey(const GrUniq
return result;
}
+sk_sp<GrTextureProxy> GrProxyProvider::createInstantiatedProxy(const GrSurfaceDesc& desc,
+ SkBackingFit fit,
+ SkBudgeted budgeted,
+ uint32_t flags) {
+ sk_sp<GrTexture> tex;
+
+ if (SkBackingFit::kApprox == fit) {
+ tex = fResourceProvider->createApproxTexture(desc, flags);
+ } else {
+ tex = fResourceProvider->createTexture(desc, budgeted, flags);
+ }
+ if (!tex) {
+ return nullptr;
+ }
+
+ SkASSERT(!tex->getUniqueKey().isValid());
+
+ if (tex->asRenderTarget()) {
+ return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(std::move(tex), desc.fOrigin));
+ }
+
+ return sk_sp<GrTextureProxy>(new GrTextureProxy(std::move(tex), desc.fOrigin));
+}
+
sk_sp<GrTextureProxy> GrProxyProvider::createTextureProxy(const GrSurfaceDesc& desc,
SkBudgeted budgeted,
- const GrMipLevel& mipLevel) {
+ const void* srcData, size_t rowBytes) {
ASSERT_SINGLE_OWNER
if (this->isAbandoned()) {
return nullptr;
}
- sk_sp<GrTexture> tex = fResourceProvider->createTexture(desc, budgeted, mipLevel);
- if (!tex) {
- return nullptr;
+ if (srcData) {
+ GrMipLevel mipLevel = { srcData, rowBytes };
+
+ sk_sp<GrTexture> tex = fResourceProvider->createTexture(desc, budgeted, mipLevel);
+ if (!tex) {
+ return nullptr;
+ }
+
+ return GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin);
}
- return GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin);
+ return this->createProxy(desc, SkBackingFit::kExact, budgeted);
}
-sk_sp<GrTextureProxy> GrProxyProvider::createTextureProxy(
+sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxy(
const GrSurfaceDesc& desc, SkBudgeted budgeted,
const GrMipLevel texels[], int mipLevelCount,
SkDestinationSurfaceColorMode mipColorMode) {
@@ -153,6 +186,38 @@ sk_sp<GrTextureProxy> GrProxyProvider::createTextureProxy(
return nullptr;
}
+ if (!mipLevelCount) {
+ if (texels) {
+ return nullptr;
+ }
+ return this->createProxy(desc, SkBackingFit::kExact, budgeted);
+ }
+ if (!texels) {
+ return nullptr;
+ }
+
+ if (1 == mipLevelCount) {
+ return this->createTextureProxy(desc, budgeted, texels[0].fPixels, texels[0].fRowBytes);
+ }
+
+#ifdef SK_DEBUG
+ // There are only three states we want to be in when uploading data to a mipped surface.
+ // 1) We have data to upload to all layers
+ // 2) We are not uploading data to any layers
+ // 3) We are only uploading data to the base layer
+ // We check here to make sure we do not have any other state.
+ bool firstLevelHasData = SkToBool(texels[0].fPixels);
+ bool allOtherLevelsHaveData = true, allOtherLevelsLackData = true;
+ for (int i = 1; i < mipLevelCount; ++i) {
+ if (texels[i].fPixels) {
+ allOtherLevelsLackData = false;
+ } else {
+ allOtherLevelsHaveData = false;
+ }
+ }
+ SkASSERT((firstLevelHasData && allOtherLevelsHaveData) || allOtherLevelsLackData);
+#endif
+
sk_sp<GrTexture> tex(fResourceProvider->createTexture(desc, budgeted,
texels, mipLevelCount,
mipColorMode));
@@ -163,6 +228,137 @@ sk_sp<GrTextureProxy> GrProxyProvider::createTextureProxy(
return GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin);
}
+sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxy(const GrSurfaceDesc& desc,
+ SkBudgeted budgeted) {
+ // SkMipMap doesn't include the base level in the level count so we have to add 1
+ int mipCount = SkMipMap::ComputeLevelCount(desc.fWidth, desc.fHeight) + 1;
+
+ std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[mipCount]);
+
+ // We don't want to upload any texel data
+ for (int i = 0; i < mipCount; i++) {
+ texels[i].fPixels = nullptr;
+ texels[i].fRowBytes = 0;
+ }
+
+ return this->createMipMapProxy(desc, budgeted, texels.get(), mipCount,
+ SkDestinationSurfaceColorMode::kLegacy);
+}
+
+sk_sp<GrTextureProxy> GrProxyProvider::createProxy(const GrSurfaceDesc& desc,
+ SkBackingFit fit,
+ SkBudgeted budgeted,
+ uint32_t flags) {
+ SkASSERT(0 == flags || GrResourceProvider::kNoPendingIO_Flag == flags);
+
+ const GrCaps* caps = this->caps();
+
+ // TODO: move this logic into GrResourceProvider!
+ // TODO: share this testing code with check_texture_creation_params
+ if (!caps->isConfigTexturable(desc.fConfig)) {
+ return nullptr;
+ }
+
+ bool willBeRT = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag);
+ if (willBeRT && !caps->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
+ return nullptr;
+ }
+
+ // We currently do not support multisampled textures
+ if (!willBeRT && desc.fSampleCnt > 0) {
+ return nullptr;
+ }
+
+ int maxSize;
+ if (willBeRT) {
+ maxSize = caps->maxRenderTargetSize();
+ } else {
+ maxSize = caps->maxTextureSize();
+ }
+
+ if (desc.fWidth > maxSize || desc.fHeight > maxSize || desc.fWidth <= 0 || desc.fHeight <= 0) {
+ return nullptr;
+ }
+
+ GrSurfaceDesc copyDesc = desc;
+ copyDesc.fSampleCnt = caps->getSampleCount(desc.fSampleCnt, desc.fConfig);
+
+#ifdef SK_DISABLE_DEFERRED_PROXIES
+ // Temporarily force instantiation for crbug.com/769760 and crbug.com/769898
+ sk_sp<GrTexture> tex;
+
+ if (SkBackingFit::kApprox == fit) {
+ tex = resourceProvider->createApproxTexture(copyDesc, flags);
+ } else {
+ tex = resourceProvider->createTexture(copyDesc, budgeted, flags);
+ }
+
+ if (!tex) {
+ return nullptr;
+ }
+
+ return GrSurfaceProxy::MakeWrapped(std::move(tex), copyDesc.fOrigin);
+#else
+ if (willBeRT) {
+ // We know anything we instantiate later from this deferred path will be
+ // both texturable and renderable
+ return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(*caps, copyDesc, fit,
+ budgeted, flags));
+ }
+
+ return sk_sp<GrTextureProxy>(new GrTextureProxy(copyDesc, fit, budgeted, nullptr, 0, flags));
+#endif
+}
+
+sk_sp<GrTextureProxy> GrProxyProvider::createWrappedTextureProxy(const GrBackendTexture& backendTex,
+ GrSurfaceOrigin origin) {
+ sk_sp<GrTexture> texture(fResourceProvider->wrapBackendTexture(backendTex));
+ if (!texture) {
+ return nullptr;
+ }
+ SkASSERT(!texture->asRenderTarget()); // Strictly a GrTexture
+
+ return GrSurfaceProxy::MakeWrapped(std::move(texture), origin);
+}
+
+sk_sp<GrTextureProxy> GrProxyProvider::createWrappedTextureProxy(const GrBackendTexture& tex,
+ GrSurfaceOrigin origin,
+ int sampleCnt) {
+ sk_sp<GrTexture> texture(fResourceProvider->wrapRenderableBackendTexture(tex, sampleCnt));
+ if (!texture) {
+ return nullptr;
+ }
+ SkASSERT(texture->asRenderTarget()); // A GrTextureRenderTarget
+
+ return GrSurfaceProxy::MakeWrapped(std::move(texture), origin);
+}
+
+sk_sp<GrSurfaceProxy> GrProxyProvider::createWrappedRenderTargetProxy(
+ const GrBackendRenderTarget& backendRT,
+ GrSurfaceOrigin origin) {
+ sk_sp<GrRenderTarget> rt(fResourceProvider->wrapBackendRenderTarget(backendRT));
+ if (!rt) {
+ return nullptr;
+ }
+ SkASSERT(!rt->asTexture()); // Strictly a GrRenderTarget
+ SkASSERT(!rt->getUniqueKey().isValid());
+
+ return sk_sp<GrSurfaceProxy>(new GrRenderTargetProxy(std::move(rt), origin));
+}
+
+sk_sp<GrSurfaceProxy> GrProxyProvider::createWrappedRenderTargetProxy(const GrBackendTexture& tex,
+ GrSurfaceOrigin origin,
+ int sampleCnt) {
+ sk_sp<GrRenderTarget> rt(fResourceProvider->wrapBackendTextureAsRenderTarget(tex, sampleCnt));
+ if (!rt) {
+ return nullptr;
+ }
+ SkASSERT(!rt->asTexture()); // Strictly a GrRenderTarget
+ SkASSERT(!rt->getUniqueKey().isValid());
+
+ return sk_sp<GrSurfaceProxy>(new GrRenderTargetProxy(std::move(rt), origin));
+}
+
bool GrProxyProvider::IsFunctionallyExact(GrSurfaceProxy* proxy) {
return proxy->priv().isExact() || (SkIsPow2(proxy->width()) && SkIsPow2(proxy->height()));
}
diff --git a/src/gpu/GrProxyProvider.h b/src/gpu/GrProxyProvider.h
index 404e020b43..1150c794a6 100644
--- a/src/gpu/GrProxyProvider.h
+++ b/src/gpu/GrProxyProvider.h
@@ -17,6 +17,7 @@
class GrCaps;
class GrResourceProvider;
class GrSingleOwner;
+class GrBackendRenderTarget;
/*
* A factory for creating GrSurfaceProxy-derived objects.
@@ -57,16 +58,75 @@ public:
sk_sp<GrTextureProxy> findOrCreateProxyByUniqueKey(const GrUniqueKey&, GrSurfaceOrigin);
/*
+ * Create a texture proxy that is backed by an instantiated GrSurface. This is almost entirely
+ * used by Skia's testing code.
+ * DDL TODO: remove the remaining Skia-internal use of this method and make it truly
+ * testing-only.
+ */
+ sk_sp<GrTextureProxy> createInstantiatedProxy(const GrSurfaceDesc&, SkBackingFit, SkBudgeted,
+ uint32_t flags = 0);
+
+ /*
* Create an un-mipmapped texture proxy with data.
+ * DDL TODO: need to refine ownership semantics of 'srcData' if we're in completely
+ * deferred mode
*/
- sk_sp<GrTextureProxy> createTextureProxy(const GrSurfaceDesc&, SkBudgeted, const GrMipLevel&);
+ sk_sp<GrTextureProxy> createTextureProxy(const GrSurfaceDesc&, SkBudgeted,
+ const void* srcData, size_t rowBytes);
/*
* Create a mipmapped texture proxy with data.
+ *
+ * @param desc Description of the texture properties.
+ * @param budgeted Does the texture count against the resource cache budget?
+ * @param texels A contiguous array of mipmap levels
+ * @param mipLevelCount The amount of elements in the texels array
*/
- sk_sp<GrTextureProxy> createTextureProxy(const GrSurfaceDesc&, SkBudgeted,
- const GrMipLevel texels[], int mipLevelCount,
- SkDestinationSurfaceColorMode mipColorMode);
+ sk_sp<GrTextureProxy> createMipMapProxy(const GrSurfaceDesc&, SkBudgeted,
+ const GrMipLevel texels[], int mipLevelCount,
+ SkDestinationSurfaceColorMode mipColorMode =
+ SkDestinationSurfaceColorMode::kLegacy);
+
+
+ /*
+ * Create a mipmapped texture proxy without any data.
+ *
+ * Like the call above but there are no texels to upload. A texture proxy is returned that
+ * simply has space allocated for the mips. We will allocated the full amount of mip levels
+ * based on the width and height in the GrSurfaceDesc.
+ */
+ sk_sp<GrTextureProxy> createMipMapProxy(const GrSurfaceDesc&, SkBudgeted);
+
+ /*
+ * Create a GrSurfaceProxy without any data.
+ */
+ sk_sp<GrTextureProxy> createProxy(const GrSurfaceDesc&, SkBackingFit, SkBudgeted,
+ uint32_t flags = 0);
+
+ /*
+ * Create a texture proxy that wraps a (non-renderable) backend texture.
+ */
+ sk_sp<GrTextureProxy> createWrappedTextureProxy(const GrBackendTexture&, GrSurfaceOrigin);
+
+ /*
+ * Create a texture proxy that wraps a backend texture and is both texture-able and renderable
+ */
+ sk_sp<GrTextureProxy> createWrappedTextureProxy(const GrBackendTexture&,
+ GrSurfaceOrigin,
+ int sampleCnt);
+
+ /*
+ * Create a render target proxy that wraps a backend rendertarget
+ */
+ sk_sp<GrSurfaceProxy> createWrappedRenderTargetProxy(const GrBackendRenderTarget&,
+ GrSurfaceOrigin);
+
+ /*
+ * Create a render target proxy that wraps a backend texture?
+ */
+ sk_sp<GrSurfaceProxy> createWrappedRenderTargetProxy(const GrBackendTexture& tex,
+ GrSurfaceOrigin origin,
+ int sampleCnt);
// 'proxy' is about to be used as a texture src or drawn to. This query can be used to
// determine if it is going to need a texture domain or a full clear.
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index 048b87fc4e..33773a8060 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -15,6 +15,7 @@
#include "GrGpu.h"
#include "GrPath.h"
#include "GrPathRendering.h"
+#include "GrProxyProvider.h"
#include "GrRenderTargetPriv.h"
#include "GrResourceCache.h"
#include "GrResourceKey.h"
@@ -128,19 +129,22 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc,
}
GrContext* context = fGpu->getContext();
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
SkImageInfo srcInfo;
if (make_info(desc.fWidth, desc.fHeight, desc.fConfig, &srcInfo)) {
- sk_sp<GrTexture> tex = this->getExactScratch(desc, budgeted, 0);
- sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(tex, desc.fOrigin);
+ // DDL TODO: remove this use of createInstantiatedProxy and convert it to a testing-only
+ // method.
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createInstantiatedProxy(desc,
+ SkBackingFit::kExact,
+ budgeted);
if (proxy) {
sk_sp<GrSurfaceContext> sContext =
context->contextPriv().makeWrappedSurfaceContext(std::move(proxy), nullptr);
if (sContext) {
if (sContext->writePixels(srcInfo, mipLevel.fPixels, mipLevel.fRowBytes, 0, 0)) {
- SkASSERT(sContext->asTextureProxy()->priv().peekTexture() == tex.get());
- return tex;
+ return sk_ref_sp(sContext->asTextureProxy()->priv().peekTexture());
}
}
}
@@ -464,7 +468,7 @@ sk_sp<GrRenderTarget> GrResourceProvider::wrapBackendTextureAsRenderTarget(
if (this->isAbandoned()) {
return nullptr;
}
- return this->gpu()->wrapBackendTextureAsRenderTarget(tex, sampleCnt);
+ return fGpu->wrapBackendTextureAsRenderTarget(tex, sampleCnt);
}
sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT GrResourceProvider::makeSemaphore(bool isOwned) {
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index 3fd5df453f..ff6a20fbe7 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -169,15 +169,18 @@ void GrSoftwarePathRenderer::DrawToTargetWithShapeMask(
static sk_sp<GrTextureProxy> make_deferred_mask_texture_proxy(GrContext* context, SkBackingFit fit,
int width, int height) {
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
+
GrSurfaceDesc desc;
desc.fOrigin = kTopLeft_GrSurfaceOrigin;
desc.fWidth = width;
desc.fHeight = height;
desc.fConfig = kAlpha_8_GrPixelConfig;
+
// MDB TODO: We're going to fill this proxy with an ASAP upload (which is out of order wrt to
// ops), so it can't have any pending IO.
- return GrSurfaceProxy::MakeDeferred(context->contextPriv().proxyProvider(), desc, fit,
- SkBudgeted::kYes, GrResourceProvider::kNoPendingIO_Flag);
+ return proxyProvider->createProxy(desc, fit, SkBudgeted::kYes,
+ GrResourceProvider::kNoPendingIO_Flag);
}
namespace {
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index e505a9c9bd..c9da6ce592 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -223,35 +223,6 @@ GrTextureOpList* GrSurfaceProxy::getLastTextureOpList() {
return fLastOpList ? fLastOpList->asTextureOpList() : nullptr;
}
-sk_sp<GrSurfaceProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrSurface> surf, GrSurfaceOrigin origin) {
- if (!surf) {
- return nullptr;
- }
-
- if (surf->getUniqueKey().isValid()) {
- // The proxy may already be in the hash. Thus we need to look for it first before creating
- // new one.
- GrProxyProvider* provider = surf->getContext()->contextPriv().proxyProvider();
- sk_sp<GrSurfaceProxy> proxy = provider->findProxyByUniqueKey(surf->getUniqueKey(), origin);
- if (proxy) {
- return proxy;
- }
- }
-
- if (surf->asTexture()) {
- if (surf->asRenderTarget()) {
- return sk_sp<GrSurfaceProxy>(new GrTextureRenderTargetProxy(std::move(surf), origin));
- } else {
- return sk_sp<GrSurfaceProxy>(new GrTextureProxy(std::move(surf), origin));
- }
- } else {
- SkASSERT(surf->asRenderTarget());
-
- // Not texturable
- return sk_sp<GrSurfaceProxy>(new GrRenderTargetProxy(std::move(surf), origin));
- }
-}
-
sk_sp<GrTextureProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrTexture> tex, GrSurfaceOrigin origin) {
if (!tex) {
return nullptr;
@@ -274,152 +245,6 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrTexture> tex, GrSurfac
}
}
-sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(GrProxyProvider* proxyProvider,
- const GrSurfaceDesc& desc,
- SkBackingFit fit,
- SkBudgeted budgeted,
- uint32_t flags) {
- SkASSERT(0 == flags || GrResourceProvider::kNoPendingIO_Flag == flags);
-
- const GrCaps* caps = proxyProvider->caps();
-
- // TODO: move this logic into GrResourceProvider!
- // TODO: share this testing code with check_texture_creation_params
- if (!caps->isConfigTexturable(desc.fConfig)) {
- return nullptr;
- }
-
- bool willBeRT = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag);
- if (willBeRT && !caps->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
- return nullptr;
- }
-
- // We currently do not support multisampled textures
- if (!willBeRT && desc.fSampleCnt > 0) {
- return nullptr;
- }
-
- int maxSize;
- if (willBeRT) {
- maxSize = caps->maxRenderTargetSize();
- } else {
- maxSize = caps->maxTextureSize();
- }
-
- if (desc.fWidth > maxSize || desc.fHeight > maxSize || desc.fWidth <= 0 || desc.fHeight <= 0) {
- return nullptr;
- }
-
- GrSurfaceDesc copyDesc = desc;
- copyDesc.fSampleCnt = caps->getSampleCount(desc.fSampleCnt, desc.fConfig);
-
-#ifdef SK_DISABLE_DEFERRED_PROXIES
- // Temporarily force instantiation for crbug.com/769760 and crbug.com/769898
- sk_sp<GrTexture> tex;
-
- if (SkBackingFit::kApprox == fit) {
- tex = resourceProvider->createApproxTexture(copyDesc, flags);
- } else {
- tex = resourceProvider->createTexture(copyDesc, budgeted, flags);
- }
-
- if (!tex) {
- return nullptr;
- }
-
- return GrSurfaceProxy::MakeWrapped(std::move(tex), copyDesc.fOrigin);
-#else
- if (willBeRT) {
- // We know anything we instantiate later from this deferred path will be
- // both texturable and renderable
- return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(*caps, copyDesc, fit,
- budgeted, flags));
- }
-
- return sk_sp<GrTextureProxy>(new GrTextureProxy(copyDesc, fit, budgeted, nullptr, 0, flags));
-#endif
-}
-
-sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(GrProxyProvider* proxyProvider,
- const GrSurfaceDesc& desc,
- SkBudgeted budgeted,
- const void* srcData,
- size_t rowBytes) {
- if (srcData) {
- GrMipLevel mipLevel = { srcData, rowBytes };
-
- return proxyProvider->createTextureProxy(desc, budgeted, mipLevel);
- }
-
- return GrSurfaceProxy::MakeDeferred(proxyProvider, desc, SkBackingFit::kExact, budgeted);
-}
-
-sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferredMipMap(GrProxyProvider* proxyProvider,
- const GrSurfaceDesc& desc,
- SkBudgeted budgeted) {
- // SkMipMap doesn't include the base level in the level count so we have to add 1
- int mipCount = SkMipMap::ComputeLevelCount(desc.fWidth, desc.fHeight) + 1;
-
- std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[mipCount]);
-
- // We don't want to upload any texel data
- for (int i = 0; i < mipCount; i++) {
- texels[i].fPixels = nullptr;
- texels[i].fRowBytes = 0;
- }
-
- return MakeDeferredMipMap(proxyProvider, desc, budgeted, texels.get(), mipCount);
-}
-
-sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferredMipMap(
- GrProxyProvider* proxyProvider,
- const GrSurfaceDesc& desc,
- SkBudgeted budgeted,
- const GrMipLevel texels[],
- int mipLevelCount,
- SkDestinationSurfaceColorMode mipColorMode) {
- if (!mipLevelCount) {
- if (texels) {
- return nullptr;
- }
- return GrSurfaceProxy::MakeDeferred(proxyProvider, desc, budgeted, nullptr, 0);
- }
- if (!texels) {
- return nullptr;
- }
-
- if (1 == mipLevelCount) {
- return proxyProvider->createTextureProxy(desc, budgeted, texels[0]);
- }
-
-#ifdef SK_DEBUG
- // There are only three states we want to be in when uploading data to a mipped surface.
- // 1) We have data to upload to all layers
- // 2) We are not uploading data to any layers
- // 3) We are only uploading data to the base layer
- // We check here to make sure we do not have any other state.
- bool firstLevelHasData = SkToBool(texels[0].fPixels);
- bool allOtherLevelsHaveData = true, allOtherLevelsLackData = true;
- for (int i = 1; i < mipLevelCount; ++i) {
- if (texels[i].fPixels) {
- allOtherLevelsLackData = false;
- } else {
- allOtherLevelsHaveData = false;
- }
- }
- SkASSERT((firstLevelHasData && allOtherLevelsHaveData) || allOtherLevelsLackData);
-#endif
-
- return proxyProvider->createTextureProxy(desc, budgeted, texels, mipLevelCount, mipColorMode);
-}
-
-sk_sp<GrTextureProxy> GrSurfaceProxy::MakeWrappedBackend(GrContext* context,
- const GrBackendTexture& backendTex,
- GrSurfaceOrigin origin) {
- sk_sp<GrTexture> tex(context->resourceProvider()->wrapBackendTexture(backendTex));
- return GrSurfaceProxy::MakeWrapped(std::move(tex), origin);
-}
-
sk_sp<GrTextureProxy> GrSurfaceProxy::MakeLazy(LazyInstantiateCallback&& callback,
const GrSurfaceDesc& desc,
GrMipMapped mipMapped,
diff --git a/src/gpu/GrTextureRenderTargetProxy.h b/src/gpu/GrTextureRenderTargetProxy.h
index 739f79744a..63cc4872b6 100644
--- a/src/gpu/GrTextureRenderTargetProxy.h
+++ b/src/gpu/GrTextureRenderTargetProxy.h
@@ -23,7 +23,9 @@
// the uniqueID of the RenderTarget/Texture it represents!
class GrTextureRenderTargetProxy : public GrTextureProxy, public GrRenderTargetProxy {
private:
+ // DDL TODO: rm the GrSurfaceProxy friending
friend class GrSurfaceProxy; // for ctors
+ friend class GrProxyProvider; // for ctors
// Deferred version
GrTextureRenderTargetProxy(const GrCaps&, const GrSurfaceDesc&,
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index da57a04787..8faa9d4557 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -92,8 +92,8 @@ sk_sp<GrTextureProxy> GrUploadPixmapToTextureProxy(GrProxyProvider* proxyProvide
ATRACE_ANDROID_FRAMEWORK("Upload Texture [%ux%u]", pixmap.width(), pixmap.height());
GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(pixmap.info(), *proxyProvider->caps());
- return GrSurfaceProxy::MakeDeferred(proxyProvider, desc, budgeted, pixmap.addr(),
- pixmap.rowBytes());
+
+ return proxyProvider->createTextureProxy(desc, budgeted, pixmap.addr(), pixmap.rowBytes());
}
////////////////////////////////////////////////////////////////////////////////
@@ -111,7 +111,7 @@ void GrInstallBitmapUniqueKeyInvalidator(const GrUniqueKey& key, SkPixelRef* pix
pixelRef->addGenIDChangeListener(new Invalidator(key));
}
-sk_sp<GrTextureProxy> GrGenerateMipMapsAndUploadToTextureProxy(GrContext* ctx,
+sk_sp<GrTextureProxy> GrGenerateMipMapsAndUploadToTextureProxy(GrProxyProvider* proxyProvider,
const SkBitmap& bitmap,
SkColorSpace* dstColorSpace) {
SkDestinationSurfaceColorMode colorMode = dstColorSpace
@@ -128,7 +128,7 @@ sk_sp<GrTextureProxy> GrGenerateMipMapsAndUploadToTextureProxy(GrContext* ctx,
}
ATRACE_ANDROID_FRAMEWORK("Upload MipMap Texture [%ux%u]", pixmap.width(), pixmap.height());
- GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(pixmap.info(), *ctx->resourceProvider()->caps());
+ GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(pixmap.info(), *proxyProvider->caps());
std::unique_ptr<SkMipMap> mipmaps(SkMipMap::Build(pixmap, colorMode, nullptr));
if (!mipmaps) {
return nullptr;
@@ -151,22 +151,18 @@ sk_sp<GrTextureProxy> GrGenerateMipMapsAndUploadToTextureProxy(GrContext* ctx,
texels[i].fRowBytes = generatedMipLevel.fPixmap.rowBytes();
}
- return GrSurfaceProxy::MakeDeferredMipMap(ctx->contextPriv().proxyProvider(),
- desc,
- SkBudgeted::kYes,
- texels.get(),
- mipLevelCount,
- colorMode);
+ return proxyProvider->createMipMapProxy(desc, SkBudgeted::kYes, texels.get(), mipLevelCount,
+ colorMode);
}
-sk_sp<GrTextureProxy> GrCopyBaseMipMapToTextureProxy(GrContext* ctx,
- GrTextureProxy* baseProxy) {
+sk_sp<GrTextureProxy> GrCopyBaseMipMapToTextureProxy(GrContext* ctx, GrTextureProxy* baseProxy) {
SkASSERT(baseProxy);
if (!ctx->caps()->isConfigCopyable(baseProxy->config())) {
return nullptr;
}
+ GrProxyProvider* proxyProvider = ctx->contextPriv().proxyProvider();
GrSurfaceDesc desc;
desc.fFlags = kNone_GrSurfaceFlags;
desc.fOrigin = baseProxy->origin();
@@ -175,9 +171,7 @@ sk_sp<GrTextureProxy> GrCopyBaseMipMapToTextureProxy(GrContext* ctx,
desc.fConfig = baseProxy->config();
desc.fSampleCnt = 0;
- sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferredMipMap(ctx->contextPriv().proxyProvider(),
- desc,
- SkBudgeted::kYes);
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createMipMapProxy(desc, SkBudgeted::kYes);
if (!proxy) {
return nullptr;
}
@@ -191,7 +185,8 @@ sk_sp<GrTextureProxy> GrCopyBaseMipMapToTextureProxy(GrContext* ctx,
}
-sk_sp<GrTextureProxy> GrUploadMipMapToTextureProxy(GrContext* ctx, const SkImageInfo& info,
+sk_sp<GrTextureProxy> GrUploadMipMapToTextureProxy(GrProxyProvider* proxyProvider,
+ const SkImageInfo& info,
const GrMipLevel texels[],
int mipLevelCount,
SkDestinationSurfaceColorMode colorMode) {
@@ -199,10 +194,10 @@ sk_sp<GrTextureProxy> GrUploadMipMapToTextureProxy(GrContext* ctx, const SkImage
return nullptr;
}
- return GrSurfaceProxy::MakeDeferredMipMap(ctx->contextPriv().proxyProvider(),
- GrImageInfoToSurfaceDesc(info, *ctx->caps()),
- SkBudgeted::kYes, texels,
- mipLevelCount, colorMode);
+ GrSurfaceDesc desc(GrImageInfoToSurfaceDesc(info, *proxyProvider->caps()));
+
+ return proxyProvider->createMipMapProxy(desc, SkBudgeted::kYes,
+ texels, mipLevelCount, colorMode);
}
sk_sp<GrTextureProxy> GrRefCachedBitmapTextureProxy(GrContext* ctx,
diff --git a/src/gpu/SkGr.h b/src/gpu/SkGr.h
index 87b602e034..3bf3ba9c5d 100644
--- a/src/gpu/SkGr.h
+++ b/src/gpu/SkGr.h
@@ -208,7 +208,7 @@ sk_sp<GrTextureProxy> GrRefCachedBitmapTextureProxy(GrContext*,
sk_sp<GrTextureProxy> GrUploadBitmapToTextureProxy(GrProxyProvider*, const SkBitmap&,
SkColorSpace* dstColorSpace);
-sk_sp<GrTextureProxy> GrGenerateMipMapsAndUploadToTextureProxy(GrContext*, const SkBitmap&,
+sk_sp<GrTextureProxy> GrGenerateMipMapsAndUploadToTextureProxy(GrProxyProvider*, const SkBitmap&,
SkColorSpace* dstColorSpace);
/**
@@ -226,7 +226,7 @@ sk_sp<GrTextureProxy> GrCopyBaseMipMapToTextureProxy(GrContext*,
/**
* Creates a new texture populated with the mipmap levels.
*/
-sk_sp<GrTextureProxy> GrUploadMipMapToTextureProxy(GrContext*, const SkImageInfo&,
+sk_sp<GrTextureProxy> GrUploadMipMapToTextureProxy(GrProxyProvider*, const SkImageInfo&,
const GrMipLevel texels[],
int mipLevelCount,
SkDestinationSurfaceColorMode colorMode);
diff --git a/src/gpu/effects/GrConfigConversionEffect.h b/src/gpu/effects/GrConfigConversionEffect.h
index 9656c7fafb..46964f5c4a 100644
--- a/src/gpu/effects/GrConfigConversionEffect.h
+++ b/src/gpu/effects/GrConfigConversionEffect.h
@@ -16,6 +16,7 @@
#include "GrClip.h"
#include "GrContext.h"
#include "GrContextPriv.h"
+#include "GrProxyProvider.h"
#include "GrRenderTargetContext.h"
#include "GrFragmentProcessor.h"
#include "GrCoordTransform.h"
@@ -60,8 +61,8 @@ public:
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
- sk_sp<GrTextureProxy> dataProxy =
- GrSurfaceProxy::MakeDeferred(proxyProvider, desc, SkBudgeted::kYes, data, 0);
+ sk_sp<GrTextureProxy> dataProxy = proxyProvider->createTextureProxy(desc, SkBudgeted::kYes,
+ data, 0);
if (!dataProxy) {
return false;
}
diff --git a/src/gpu/effects/GrRectBlurEffect.h b/src/gpu/effects/GrRectBlurEffect.h
index 4f9b971d86..acc38b35c3 100644
--- a/src/gpu/effects/GrRectBlurEffect.h
+++ b/src/gpu/effects/GrRectBlurEffect.h
@@ -40,8 +40,8 @@ public:
std::unique_ptr<uint8_t[]> profile(SkBlurMask::ComputeBlurProfile(sigma));
- blurProfile = GrSurfaceProxy::MakeDeferred(proxyProvider, texDesc, SkBudgeted::kYes,
- profile.get(), 0);
+ blurProfile = proxyProvider->createTextureProxy(texDesc, SkBudgeted::kYes,
+ profile.get(), 0);
if (!blurProfile) {
return nullptr;
}
diff --git a/src/gpu/effects/GrTextureStripAtlas.cpp b/src/gpu/effects/GrTextureStripAtlas.cpp
index f39da2a2fe..ab02b6d6bb 100644
--- a/src/gpu/effects/GrTextureStripAtlas.cpp
+++ b/src/gpu/effects/GrTextureStripAtlas.cpp
@@ -218,10 +218,8 @@ void GrTextureStripAtlas::lockTexture() {
texDesc.fHeight = fDesc.fHeight;
texDesc.fConfig = fDesc.fConfig;
- proxy = GrSurfaceProxy::MakeDeferred(proxyProvider,
- texDesc, SkBackingFit::kExact,
- SkBudgeted::kYes,
- GrResourceProvider::kNoPendingIO_Flag);
+ proxy = proxyProvider->createProxy(texDesc, SkBackingFit::kExact, SkBudgeted::kYes,
+ GrResourceProvider::kNoPendingIO_Flag);
if (!proxy) {
return;
}
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp
index 6d735f51af..6e2e430a4d 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -793,6 +793,7 @@ std::unique_ptr<GrDrawOp> Make(sk_sp<GrTextureProxy> proxy, GrSamplerState::Filt
#if GR_TEST_UTILS
#include "GrContext.h"
#include "GrContextPriv.h"
+#include "GrProxyProvider.h"
GR_DRAW_OP_TEST_DEFINE(TextureOp) {
GrSurfaceDesc desc;
@@ -801,9 +802,10 @@ GR_DRAW_OP_TEST_DEFINE(TextureOp) {
desc.fWidth = random->nextULessThan(90) + 10;
desc.fOrigin = random->nextBool() ? kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin;
SkBackingFit fit = random->nextBool() ? SkBackingFit::kApprox : SkBackingFit::kExact;
- sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(
- context->contextPriv().proxyProvider(),
- desc, fit, SkBudgeted::kNo);
+
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(desc, fit, SkBudgeted::kNo);
+
SkRect rect = GrTest::TestRect(random);
SkRect srcRect;
srcRect.fLeft = random->nextRangeScalar(0.f, proxy->width() / 2.f);
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index e70ba05be5..20e8349aa2 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -19,6 +19,7 @@
#include "GrContextPriv.h"
#include "GrGpu.h"
#include "GrImageTextureMaker.h"
+#include "GrProxyProvider.h"
#include "GrRenderTargetContext.h"
#include "GrResourceProvider.h"
#include "GrSemaphore.h"
@@ -291,10 +292,10 @@ static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx,
tex->setRelease(releaseProc, releaseCtx);
}
- const SkBudgeted budgeted = SkBudgeted::kNo;
sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(tex), origin));
+
return sk_make_sp<SkImage_Gpu>(ctx, kNeedNewImageUniqueID,
- at, std::move(proxy), std::move(colorSpace), budgeted);
+ at, std::move(proxy), std::move(colorSpace), SkBudgeted::kNo);
}
sk_sp<SkImage> SkImage::MakeFromTexture(GrContext* ctx,
@@ -394,20 +395,22 @@ static sk_sp<SkImage> make_from_yuv_textures_copy(GrContext* ctx, SkYUVColorSpac
const SkISize yuvSizes[],
GrSurfaceOrigin origin,
sk_sp<SkColorSpace> imageColorSpace) {
+ GrProxyProvider* proxyProvider = ctx->contextPriv().proxyProvider();
+
if (!are_yuv_sizes_valid(yuvSizes, nv12)) {
return nullptr;
}
- sk_sp<GrTextureProxy> yProxy = GrSurfaceProxy::MakeWrappedBackend(ctx, yuvBackendTextures[0],
- origin);
- sk_sp<GrTextureProxy> uProxy = GrSurfaceProxy::MakeWrappedBackend(ctx, yuvBackendTextures[1],
- origin);
+ sk_sp<GrTextureProxy> yProxy = proxyProvider->createWrappedTextureProxy(yuvBackendTextures[0],
+ origin);
+ sk_sp<GrTextureProxy> uProxy = proxyProvider->createWrappedTextureProxy(yuvBackendTextures[1],
+ origin);
sk_sp<GrTextureProxy> vProxy;
if (nv12) {
vProxy = uProxy;
} else {
- vProxy = GrSurfaceProxy::MakeWrappedBackend(ctx, yuvBackendTextures[2], origin);
+ vProxy = proxyProvider->createWrappedTextureProxy(yuvBackendTextures[2], origin);
}
if (!yProxy || !uProxy || !vProxy) {
return nullptr;
@@ -605,15 +608,16 @@ sk_sp<SkImage> SkImage::MakeCrossContextFromPixmap(GrContext* context, const SkP
return SkImage::MakeRasterCopy(pixmap);
}
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
// Turn the pixmap into a GrTextureProxy
sk_sp<GrTextureProxy> proxy;
if (buildMips) {
SkBitmap bmp;
bmp.installPixels(pixmap);
- proxy = GrGenerateMipMapsAndUploadToTextureProxy(context, bmp, dstColorSpace);
+ proxy = GrGenerateMipMapsAndUploadToTextureProxy(proxyProvider, bmp, dstColorSpace);
} else {
- proxy = GrUploadPixmapToTextureProxy(context->contextPriv().proxyProvider(),
- pixmap, SkBudgeted::kYes, dstColorSpace);
+ proxy = GrUploadPixmapToTextureProxy(proxyProvider, pixmap, SkBudgeted::kYes,
+ dstColorSpace);
}
if (!proxy) {
@@ -1089,6 +1093,8 @@ sk_sp<SkImage> SkImage::MakeTextureFromMipMap(GrContext* ctx, const SkImageInfo&
if (!ctx) {
return nullptr;
}
+ GrProxyProvider* proxyProvider = ctx->contextPriv().proxyProvider();
+
// For images where the client is passing the mip data we require that all the mip levels have
// valid data.
for (int i = 0; i < mipLevelCount; ++i) {
@@ -1096,8 +1102,8 @@ sk_sp<SkImage> SkImage::MakeTextureFromMipMap(GrContext* ctx, const SkImageInfo&
return nullptr;
}
}
- sk_sp<GrTextureProxy> proxy(GrUploadMipMapToTextureProxy(ctx, info, texels, mipLevelCount,
- colorMode));
+ sk_sp<GrTextureProxy> proxy(GrUploadMipMapToTextureProxy(proxyProvider, info,
+ texels, mipLevelCount, colorMode));
if (!proxy) {
return nullptr;
}
diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp
index ae4dfd6c70..53ebc0ccff 100644
--- a/src/image/SkImage_Lazy.cpp
+++ b/src/image/SkImage_Lazy.cpp
@@ -829,7 +829,7 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(GrContext* ctx,
SkBitmap bitmap;
if (!proxy && this->lockAsBitmap(&bitmap, chint, format, genPixelsInfo, behavior)) {
if (willBeMipped) {
- proxy = GrGenerateMipMapsAndUploadToTextureProxy(ctx, bitmap, dstColorSpace);
+ proxy = GrGenerateMipMapsAndUploadToTextureProxy(proxyProvider, bitmap, dstColorSpace);
}
if (!proxy) {
proxy = GrUploadBitmapToTextureProxy(proxyProvider, bitmap, dstColorSpace);
diff --git a/tests/CopySurfaceTest.cpp b/tests/CopySurfaceTest.cpp
index 0d9fc86460..1c31bbf485 100644
--- a/tests/CopySurfaceTest.cpp
+++ b/tests/CopySurfaceTest.cpp
@@ -11,6 +11,7 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrContextPriv.h"
+#include "GrProxyProvider.h"
#include "GrResourceProvider.h"
#include "GrSurfaceContext.h"
#include "GrSurfaceProxy.h"
@@ -74,17 +75,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) {
dstDesc.fOrigin = dOrigin;
dstDesc.fFlags = dFlags;
- sk_sp<GrTextureProxy> src(GrSurfaceProxy::MakeDeferred(
- proxyProvider,
- srcDesc, SkBudgeted::kNo,
- srcPixels.get(),
- kRowBytes));
-
- sk_sp<GrTextureProxy> dst(GrSurfaceProxy::MakeDeferred(
- proxyProvider,
- dstDesc, SkBudgeted::kNo,
- dstPixels.get(),
- kRowBytes));
+ sk_sp<GrTextureProxy> src = proxyProvider->createTextureProxy(
+ srcDesc, SkBudgeted::kNo, srcPixels.get(), kRowBytes);
+ sk_sp<GrTextureProxy> dst = proxyProvider->createTextureProxy(
+ dstDesc, SkBudgeted::kNo, dstPixels.get(), kRowBytes);
if (!src || !dst) {
ERRORF(reporter,
"Could not create surfaces for copy surface test.");
diff --git a/tests/DetermineDomainModeTest.cpp b/tests/DetermineDomainModeTest.cpp
index 5848ca8f8a..7833da4bdf 100644
--- a/tests/DetermineDomainModeTest.cpp
+++ b/tests/DetermineDomainModeTest.cpp
@@ -10,6 +10,7 @@
#if SK_SUPPORT_GPU
#include "GrContextPriv.h"
+#include "GrProxyProvider.h"
#include "GrSurfaceProxy.h"
#include "GrTextureProducer.h"
#include "GrTextureProxy.h"
@@ -133,7 +134,7 @@ static sk_sp<GrTextureProxy> create_proxy(GrProxyProvider* proxyProvider,
(isPowerOfTwo || isExact) ? RectInfo::kHard : RectInfo::kBad,
name);
- return GrSurfaceProxy::MakeDeferred(proxyProvider, desc, fit, SkBudgeted::kYes);
+ return proxyProvider->createProxy(desc, fit, SkBudgeted::kYes);
}
static RectInfo::EdgeType compute_inset_edgetype(RectInfo::EdgeType previous,
diff --git a/tests/FloatingPointTextureTest.cpp b/tests/FloatingPointTextureTest.cpp
index 95c27f2339..fe347d2ce6 100644
--- a/tests/FloatingPointTextureTest.cpp
+++ b/tests/FloatingPointTextureTest.cpp
@@ -18,7 +18,7 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrContextPriv.h"
-#include "GrResourceProvider.h"
+#include "GrProxyProvider.h"
#include "GrTextureProxy.h"
#include "SkHalf.h"
@@ -52,9 +52,9 @@ void runFPTest(skiatest::Reporter* reporter, GrContext* context,
desc.fWidth = DEV_W;
desc.fHeight = DEV_H;
desc.fConfig = config;
- sk_sp<GrTextureProxy> fpProxy = GrSurfaceProxy::MakeDeferred(proxyProvider,
- desc, SkBudgeted::kNo,
- controlPixelData.begin(), 0);
+
+ sk_sp<GrTextureProxy> fpProxy = proxyProvider->createTextureProxy(
+ desc, SkBudgeted::kNo, controlPixelData.begin(), 0);
// Floating point textures are NOT supported everywhere
if (!fpProxy) {
continue;
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 202e0854d4..cf920957be 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -266,19 +266,24 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma
sk_sp<GrTextureProxy> proxies[2];
// setup dummy textures
- GrSurfaceDesc dummyDesc;
- dummyDesc.fFlags = kRenderTarget_GrSurfaceFlag;
- dummyDesc.fOrigin = kBottomLeft_GrSurfaceOrigin;
- dummyDesc.fWidth = 34;
- dummyDesc.fHeight = 18;
- dummyDesc.fConfig = kRGBA_8888_GrPixelConfig;
- proxies[0] = GrSurfaceProxy::MakeDeferred(proxyProvider, dummyDesc, SkBudgeted::kNo, nullptr, 0);
- dummyDesc.fFlags = kNone_GrSurfaceFlags;
- dummyDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
- dummyDesc.fWidth = 16;
- dummyDesc.fHeight = 22;
- dummyDesc.fConfig = kAlpha_8_GrPixelConfig;
- proxies[1] = GrSurfaceProxy::MakeDeferred(proxyProvider, dummyDesc, SkBudgeted::kNo, nullptr, 0);
+ {
+ GrSurfaceDesc dummyDesc;
+ dummyDesc.fFlags = kRenderTarget_GrSurfaceFlag;
+ dummyDesc.fOrigin = kBottomLeft_GrSurfaceOrigin;
+ dummyDesc.fWidth = 34;
+ dummyDesc.fHeight = 18;
+ dummyDesc.fConfig = kRGBA_8888_GrPixelConfig;
+ proxies[0] = proxyProvider->createProxy(dummyDesc, SkBackingFit::kExact, SkBudgeted::kNo);
+ }
+ {
+ GrSurfaceDesc dummyDesc;
+ dummyDesc.fFlags = kNone_GrSurfaceFlags;
+ dummyDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
+ dummyDesc.fWidth = 16;
+ dummyDesc.fHeight = 22;
+ dummyDesc.fConfig = kAlpha_8_GrPixelConfig;
+ proxies[1] = proxyProvider->createProxy(dummyDesc, SkBackingFit::kExact, SkBudgeted::kNo);
+ }
if (!proxies[0] || !proxies[1]) {
SkDebugf("Could not allocate dummy textures");
diff --git a/tests/GrPorterDuffTest.cpp b/tests/GrPorterDuffTest.cpp
index 137d2aa76e..6c1f209527 100644
--- a/tests/GrPorterDuffTest.cpp
+++ b/tests/GrPorterDuffTest.cpp
@@ -13,6 +13,7 @@
#include "GrContextOptions.h"
#include "GrContextPriv.h"
#include "GrGpu.h"
+#include "GrProxyProvider.h"
#include "GrTest.h"
#include "GrXferProcessor.h"
#include "effects/GrPorterDuffXferProcessor.h"
@@ -1060,6 +1061,7 @@ DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, options) {
return;
}
+ GrProxyProvider* proxyProvider = ctx->contextPriv().proxyProvider();
const GrCaps& caps = *ctx->caps();
if (caps.shaderCaps()->dualSourceBlendingSupport()) {
SK_ABORT("Null context failed to honor request for no ARB_blend_func_extended.");
@@ -1072,8 +1074,8 @@ DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, options) {
GrXferProcessor::DstProxy fakeDstProxy;
{
- sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrappedBackend(ctx, backendTex,
- kTopLeft_GrSurfaceOrigin);
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createWrappedTextureProxy(
+ backendTex, kTopLeft_GrSurfaceOrigin);
fakeDstProxy.setProxy(std::move(proxy));
}
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index ecfd9f2433..582510c1b4 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -12,6 +12,7 @@
#include "GrContext.h"
#include "GrContextPriv.h"
#include "GrGpu.h"
+#include "GrProxyProvider.h"
#include "GrRenderTarget.h"
#include "GrResourceProvider.h"
#include "GrTest.h"
@@ -126,10 +127,10 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
texels[i].fPixels = pixelData.get();
texels[i].fRowBytes = rowBytes >> i;
}
- sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferredMipMap(proxyProvider,
- desc, SkBudgeted::kNo,
- texels.get(),
- levelCount);
+
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createMipMapProxy(
+ desc, SkBudgeted::kNo,
+ texels.get(), levelCount);
REPORTER_ASSERT(reporter, SkToBool(proxy.get()) ==
(caps->isConfigTexturable(desc.fConfig) &&
caps->mipMapSupport() &&
@@ -155,7 +156,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(InitialTextureClear, reporter, context_info)
GrSurfaceDesc desc;
desc.fWidth = desc.fHeight = kSize;
std::unique_ptr<uint32_t[]> data(new uint32_t[kSize * kSize]);
+
GrContext* context = context_info.grContext();
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
+
for (int c = 0; c <= kLast_GrPixelConfig; ++c) {
desc.fConfig = static_cast<GrPixelConfig>(c);
if (!context_info.grContext()->caps()->isConfigTexturable(desc.fConfig)) {
@@ -170,22 +174,16 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(InitialTextureClear, reporter, context_info)
for (GrSurfaceOrigin origin :
{kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin}) {
desc.fOrigin = origin;
- for (bool approx : {false, true}) {
- auto resourceProvider = context->resourceProvider();
+ for (auto fit : { SkBackingFit::kApprox, SkBackingFit::kExact }) {
// Try directly creating the texture.
// Do this twice in an attempt to hit the cache on the second time through.
for (int i = 0; i < 2; ++i) {
- sk_sp<GrTexture> tex;
- if (approx) {
- tex = sk_sp<GrTexture>(
- resourceProvider->createApproxTexture(desc, 0));
- } else {
- tex = resourceProvider->createTexture(desc, SkBudgeted::kYes);
- }
- if (!tex) {
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createInstantiatedProxy(
+ desc, fit, SkBudgeted::kYes);
+ if (!proxy) {
continue;
}
- auto proxy = GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin);
+
auto texCtx = context->contextPriv().makeWrappedSurfaceContext(
std::move(proxy), nullptr);
SkImageInfo info = SkImageInfo::Make(
@@ -212,9 +210,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(InitialTextureClear, reporter, context_info)
// Try creating the texture as a deferred proxy.
for (int i = 0; i < 2; ++i) {
auto surfCtx = context->contextPriv().makeDeferredSurfaceContext(
- desc, GrMipMapped::kNo,
- approx ? SkBackingFit::kApprox : SkBackingFit::kExact,
- SkBudgeted::kYes);
+ desc, GrMipMapped::kNo, fit, SkBudgeted::kYes);
if (!surfCtx) {
continue;
}
diff --git a/tests/ImageFilterCacheTest.cpp b/tests/ImageFilterCacheTest.cpp
index a722df0081..c33080888c 100644
--- a/tests/ImageFilterCacheTest.cpp
+++ b/tests/ImageFilterCacheTest.cpp
@@ -180,6 +180,7 @@ DEF_TEST(ImageFilterCache_ImageBackedRaster, reporter) {
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrContextPriv.h"
+#include "GrProxyProvider.h"
#include "GrResourceProvider.h"
#include "GrSurfaceProxyPriv.h"
#include "GrTest.h"
@@ -196,9 +197,8 @@ static sk_sp<GrTextureProxy> create_proxy(GrProxyProvider* proxyProvider) {
desc.fHeight = kFullSize;
desc.fConfig = kRGBA_8888_GrPixelConfig;
- return GrSurfaceProxy::MakeDeferred(proxyProvider,
- desc, SkBudgeted::kYes,
- srcBM.getPixels(), srcBM.rowBytes());
+ return proxyProvider->createTextureProxy(desc, SkBudgeted::kYes,
+ srcBM.getPixels(), srcBM.rowBytes());
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_ImageBackedGPU, reporter, ctxInfo) {
diff --git a/tests/IntTextureTest.cpp b/tests/IntTextureTest.cpp
index 74fbc5981e..2968c76d15 100644
--- a/tests/IntTextureTest.cpp
+++ b/tests/IntTextureTest.cpp
@@ -11,6 +11,7 @@
#include "GrClip.h"
#include "GrContext.h"
#include "GrContextPriv.h"
+#include "GrProxyProvider.h"
#include "GrRenderTargetContext.h"
#include "GrResourceProvider.h"
#include "GrTexture.h"
@@ -68,25 +69,25 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) {
levels[1].fPixels = testData.get();
levels[1].fRowBytes = (kS / 2) * sizeof(int32_t);
- sk_sp<GrTextureProxy> temp(GrSurfaceProxy::MakeDeferredMipMap(proxyProvider,
- desc, SkBudgeted::kYes,
- levels, 2));
+ sk_sp<GrTextureProxy> temp = proxyProvider->createMipMapProxy(
+ desc, SkBudgeted::kYes, levels, 2);
REPORTER_ASSERT(reporter, !temp);
}
- // Test that we can create an integer texture.
- sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(proxyProvider,
- desc, SkBudgeted::kYes,
- testData.get(), kRowBytes);
- REPORTER_ASSERT(reporter, proxy);
- if (!proxy) {
- return;
- }
+ sk_sp<GrSurfaceContext> sContext;
+ // Test that we can create a non-mipmapped integer texture.
+ {
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(desc, SkBudgeted::kYes,
+ testData.get(), kRowBytes);
+ REPORTER_ASSERT(reporter, proxy);
+ if (!proxy) {
+ return;
+ }
- sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeWrappedSurfaceContext(
- std::move(proxy), nullptr);
- if (!sContext) {
- return;
+ sContext = context->contextPriv().makeWrappedSurfaceContext(std::move(proxy), nullptr);
+ if (!sContext) {
+ return;
+ }
}
std::unique_ptr<int32_t[]> readData(new int32_t[kS * kS]);
diff --git a/tests/OnFlushCallbackTest.cpp b/tests/OnFlushCallbackTest.cpp
index 77ceb8975b..4ca7522ceb 100644
--- a/tests/OnFlushCallbackTest.cpp
+++ b/tests/OnFlushCallbackTest.cpp
@@ -14,6 +14,7 @@
#include "GrContextPriv.h"
#include "GrDefaultGeoProcFactory.h"
#include "GrOnFlushResourceProvider.h"
+#include "GrProxyProvider.h"
#include "GrRenderTargetContextPriv.h"
#include "GrResourceProvider.h"
#include "GrQuad.h"
@@ -474,17 +475,16 @@ sk_sp<GrTextureProxy> pre_create_atlas(GrContext* context) {
}
#else
// TODO: this is unfortunate and must be removed. We want the atlas to be created later.
-sk_sp<GrTextureProxy> pre_create_atlas(GrContext* context) {
+sk_sp<GrTextureProxy> pre_create_atlas(GrProxyProvider* proxyProvider) {
GrSurfaceDesc desc;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
desc.fWidth = 32;
desc.fHeight = 16;
desc.fConfig = kSkia8888_GrPixelConfig;
- return GrSurfaceProxy::MakeDeferred(context->contextPriv().proxyProvider(),
- desc, SkBackingFit::kExact,
- SkBudgeted::kYes,
- GrResourceProvider::kNoPendingIO_Flag);
+
+ return proxyProvider->createProxy(desc, SkBackingFit::kExact, SkBudgeted::kYes,
+ GrResourceProvider::kNoPendingIO_Flag);
}
#endif
@@ -520,7 +520,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(OnFlushCallbackTest, reporter, ctxInfo) {
// For now (until we add a GrSuperDeferredSimpleTextureEffect), we create the final atlas
// proxy ahead of time.
- sk_sp<GrTextureProxy> atlasDest = pre_create_atlas(context);
+ sk_sp<GrTextureProxy> atlasDest = pre_create_atlas(context->contextPriv().proxyProvider());
object.setAtlasDest(atlasDest);
diff --git a/tests/PackedConfigsTextureTest.cpp b/tests/PackedConfigsTextureTest.cpp
index 1f51d65b50..56950ec8a5 100644
--- a/tests/PackedConfigsTextureTest.cpp
+++ b/tests/PackedConfigsTextureTest.cpp
@@ -16,7 +16,7 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrContextPriv.h"
-#include "GrResourceProvider.h"
+#include "GrProxyProvider.h"
#include "GrTextureProxy.h"
static const int DEV_W = 10, DEV_H = 10;
@@ -120,9 +120,8 @@ static void run_test(skiatest::Reporter* reporter, GrContext* context,
desc.fConfig = config;
desc.fOrigin = origin;
- sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(proxyProvider,
- desc, SkBudgeted::kNo,
- controlPixelData.begin(), 0);
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(
+ desc, SkBudgeted::kNo, controlPixelData.begin(), 0);
SkASSERT(proxy);
sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeWrappedSurfaceContext(
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index d6d3635025..e675335118 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -14,6 +14,7 @@
#include "GrContext.h"
#include "GrContextPriv.h"
#include "GrGpuResource.h"
+#include "GrProxyProvider.h"
#include "GrRenderTargetContext.h"
#include "GrRenderTargetContextPriv.h"
#include "GrResourceProvider.h"
@@ -171,22 +172,14 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) {
kRGBA_8888_GrPixelConfig, nullptr));
{
bool texelBufferSupport = context->caps()->shaderCaps()->texelBufferSupport();
- sk_sp<GrTextureProxy> proxy1(
- GrSurfaceProxy::MakeDeferred(proxyProvider,
- desc, SkBackingFit::kExact,
- SkBudgeted::kYes));
- sk_sp<GrTextureProxy> proxy2
- (GrSurfaceProxy::MakeDeferred(proxyProvider,
- desc, SkBackingFit::kExact,
- SkBudgeted::kYes));
- sk_sp<GrTextureProxy> proxy3(
- GrSurfaceProxy::MakeDeferred(proxyProvider,
- desc, SkBackingFit::kExact,
- SkBudgeted::kYes));
- sk_sp<GrTextureProxy> proxy4(
- GrSurfaceProxy::MakeDeferred(proxyProvider,
- desc, SkBackingFit::kExact,
- SkBudgeted::kYes));
+ sk_sp<GrTextureProxy> proxy1 =
+ proxyProvider->createProxy(desc, SkBackingFit::kExact, SkBudgeted::kYes);
+ sk_sp<GrTextureProxy> proxy2 =
+ proxyProvider->createProxy(desc, SkBackingFit::kExact, SkBudgeted::kYes);
+ sk_sp<GrTextureProxy> proxy3 =
+ proxyProvider->createProxy(desc, SkBackingFit::kExact, SkBudgeted::kYes);
+ sk_sp<GrTextureProxy> proxy4 =
+ proxyProvider->createProxy(desc, SkBackingFit::kExact, SkBudgeted::kYes);
sk_sp<GrBuffer> buffer(texelBufferSupport
? context->resourceProvider()->createBuffer(
1024, GrBufferType::kTexel_GrBufferType,
@@ -296,9 +289,8 @@ void test_draw_op(GrRenderTargetContext* rtc, std::unique_ptr<GrFragmentProcesso
}
/** Initializes the two test texture proxies that are available to the FP test factories. */
-bool init_test_textures(GrContext* context, SkRandom* random, sk_sp<GrTextureProxy> proxies[2]) {
- GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
-
+bool init_test_textures(GrProxyProvider* proxyProvider, SkRandom* random,
+ sk_sp<GrTextureProxy> proxies[2]) {
static const int kTestTextureSize = 256;
GrSurfaceDesc desc;
desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
@@ -306,36 +298,41 @@ bool init_test_textures(GrContext* context, SkRandom* random, sk_sp<GrTexturePro
desc.fHeight = kTestTextureSize;
desc.fConfig = kRGBA_8888_GrPixelConfig;
- // Put premul data into the RGBA texture that the test FPs can optionally use.
- std::unique_ptr<GrColor[]> rgbaData(new GrColor[kTestTextureSize * kTestTextureSize]);
- for (int y = 0; y < kTestTextureSize; ++y) {
- for (int x = 0; x < kTestTextureSize; ++x) {
- rgbaData[kTestTextureSize * y + x] =
- input_texel_color(random->nextULessThan(256), random->nextULessThan(256));
+ {
+ // Put premul data into the RGBA texture that the test FPs can optionally use.
+ std::unique_ptr<GrColor[]> rgbaData(new GrColor[kTestTextureSize * kTestTextureSize]);
+ for (int y = 0; y < kTestTextureSize; ++y) {
+ for (int x = 0; x < kTestTextureSize; ++x) {
+ rgbaData[kTestTextureSize * y + x] =
+ input_texel_color(random->nextULessThan(256), random->nextULessThan(256));
+ }
}
+
+ proxies[0] = proxyProvider->createTextureProxy(desc, SkBudgeted::kYes,
+ rgbaData.get(),
+ kTestTextureSize * sizeof(GrColor));
}
- proxies[0] = GrSurfaceProxy::MakeDeferred(proxyProvider, desc, SkBudgeted::kYes,
- rgbaData.get(), kTestTextureSize * sizeof(GrColor));
-
- // Put random values into the alpha texture that the test FPs can optionally use.
- desc.fConfig = kAlpha_8_GrPixelConfig;
- std::unique_ptr<uint8_t[]> alphaData(new uint8_t[kTestTextureSize * kTestTextureSize]);
- for (int y = 0; y < kTestTextureSize; ++y) {
- for (int x = 0; x < kTestTextureSize; ++x) {
- alphaData[kTestTextureSize * y + x] = random->nextULessThan(256);
+
+ {
+ // Put random values into the alpha texture that the test FPs can optionally use.
+ desc.fConfig = kAlpha_8_GrPixelConfig;
+ std::unique_ptr<uint8_t[]> alphaData(new uint8_t[kTestTextureSize * kTestTextureSize]);
+ for (int y = 0; y < kTestTextureSize; ++y) {
+ for (int x = 0; x < kTestTextureSize; ++x) {
+ alphaData[kTestTextureSize * y + x] = random->nextULessThan(256);
+ }
}
+
+ proxies[1] = proxyProvider->createTextureProxy(desc, SkBudgeted::kYes,
+ alphaData.get(), kTestTextureSize);
}
- proxies[1] = GrSurfaceProxy::MakeDeferred(proxyProvider, desc, SkBudgeted::kYes,
- alphaData.get(), kTestTextureSize);
return proxies[0] && proxies[1];
}
// Creates a texture of premul colors used as the output of the fragment processor that precedes
// the fragment processor under test. Color values are those provided by input_texel_color().
-sk_sp<GrTextureProxy> make_input_texture(GrContext* context, int width, int height) {
- GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
-
+sk_sp<GrTextureProxy> make_input_texture(GrProxyProvider* proxyProvider, int width, int height) {
std::unique_ptr<GrColor[]> data(new GrColor[width * height]);
for (int y = 0; y < width; ++y) {
for (int x = 0; x < height; ++x) {
@@ -347,11 +344,14 @@ sk_sp<GrTextureProxy> make_input_texture(GrContext* context, int width, int heig
desc.fWidth = width;
desc.fHeight = height;
desc.fConfig = kRGBA_8888_GrPixelConfig;
- return GrSurfaceProxy::MakeDeferred(proxyProvider, desc, SkBudgeted::kYes,
- data.get(), width * sizeof(GrColor));
+
+ return proxyProvider->createTextureProxy(desc, SkBudgeted::kYes,
+ data.get(), width * sizeof(GrColor));
}
+
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
using FPFactory = GrFragmentProcessorTestFactory;
uint32_t seed = 0;
@@ -369,13 +369,13 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor
SkBackingFit::kExact, kRenderSize, kRenderSize, kRGBA_8888_GrPixelConfig, nullptr);
sk_sp<GrTextureProxy> proxies[2];
- if (!init_test_textures(context, &random, proxies)) {
+ if (!init_test_textures(proxyProvider, &random, proxies)) {
ERRORF(reporter, "Could not create test textures");
return;
}
GrProcessorTestData testData(&random, context, rtc.get(), proxies);
- auto inputTexture = make_input_texture(context, kRenderSize, kRenderSize);
+ auto inputTexture = make_input_texture(proxyProvider, kRenderSize, kRenderSize);
std::unique_ptr<GrColor[]> readData(new GrColor[kRenderSize * kRenderSize]);
// Because processor factories configure themselves in random ways, this is not exhaustive.
@@ -489,6 +489,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor
// progenitors.
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorCloneTest, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
SkRandom random;
@@ -498,13 +499,13 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorCloneTest, reporter, ctxInfo) {
SkBackingFit::kExact, kRenderSize, kRenderSize, kRGBA_8888_GrPixelConfig, nullptr);
sk_sp<GrTextureProxy> proxies[2];
- if (!init_test_textures(context, &random, proxies)) {
+ if (!init_test_textures(proxyProvider, &random, proxies)) {
ERRORF(reporter, "Could not create test textures");
return;
}
GrProcessorTestData testData(&random, context, rtc.get(), proxies);
- auto inputTexture = make_input_texture(context, kRenderSize, kRenderSize);
+ auto inputTexture = make_input_texture(proxyProvider, kRenderSize, kRenderSize);
std::unique_ptr<GrColor[]> readData1(new GrColor[kRenderSize * kRenderSize]);
std::unique_ptr<GrColor[]> readData2(new GrColor[kRenderSize * kRenderSize]);
auto readInfo = SkImageInfo::Make(kRenderSize, kRenderSize, kRGBA_8888_SkColorType,
diff --git a/tests/ProxyConversionTest.cpp b/tests/ProxyConversionTest.cpp
index fda71d72bf..98ceca72bf 100644
--- a/tests/ProxyConversionTest.cpp
+++ b/tests/ProxyConversionTest.cpp
@@ -12,14 +12,14 @@
#if SK_SUPPORT_GPU
#include "GrBackendSurface.h"
#include "GrContextPriv.h"
+#include "GrProxyProvider.h"
#include "GrRenderTarget.h"
#include "GrRenderTargetProxy.h"
-#include "GrResourceProvider.h"
#include "GrSurfaceProxy.h"
#include "GrTexture.h"
#include "GrTextureProxy.h"
-static sk_sp<GrSurfaceProxy> make_wrapped_FBO0(GrResourceProvider* provider,
+static sk_sp<GrSurfaceProxy> make_wrapped_FBO0(GrProxyProvider* provider,
skiatest::Reporter* reporter,
const GrSurfaceDesc& desc) {
GrGLFramebufferInfo fboInfo;
@@ -27,35 +27,25 @@ static sk_sp<GrSurfaceProxy> make_wrapped_FBO0(GrResourceProvider* provider,
GrBackendRenderTarget backendRT(desc.fWidth, desc.fHeight, desc.fSampleCnt, 8,
desc.fConfig, fboInfo);
- sk_sp<GrRenderTarget> defaultFBO(provider->wrapBackendRenderTarget(backendRT));
- SkASSERT(!defaultFBO->asTexture());
-
- return GrSurfaceProxy::MakeWrapped(std::move(defaultFBO), desc.fOrigin);
+ return provider->createWrappedRenderTargetProxy(backendRT, desc.fOrigin);
}
-static sk_sp<GrSurfaceProxy> make_wrapped_offscreen_rt(GrResourceProvider* provider,
- skiatest::Reporter* reporter,
- const GrSurfaceDesc& desc,
- SkBudgeted budgeted) {
+static sk_sp<GrSurfaceProxy> make_wrapped_offscreen_rt(GrProxyProvider* provider,
+ const GrSurfaceDesc& desc) {
SkASSERT(kRenderTarget_GrSurfaceFlag == desc.fFlags);
- sk_sp<GrTexture> tex(provider->createTexture(desc, budgeted));
-
- return GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin);
+ return provider->createInstantiatedProxy(desc, SkBackingFit::kExact, SkBudgeted::kYes);
}
-static sk_sp<GrSurfaceProxy> make_wrapped_texture(GrResourceProvider* provider,
- const GrSurfaceDesc& desc,
- SkBudgeted budgeted) {
- sk_sp<GrTexture> tex(provider->createTexture(desc, budgeted));
-
- return GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin);
+static sk_sp<GrSurfaceProxy> make_wrapped_texture(GrProxyProvider* provider,
+ const GrSurfaceDesc& desc) {
+ return provider->createInstantiatedProxy(desc, SkBackingFit::kExact, SkBudgeted::kYes);
}
// Test converting between RenderTargetProxies and TextureProxies for wrapped
// Proxies
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyConversionTest, reporter, ctxInfo) {
- GrResourceProvider* provider = ctxInfo.grContext()->resourceProvider();
+ GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider();
GrSurfaceDesc desc;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
@@ -66,7 +56,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyConversionTest, reporter, ctxInfo
if (kOpenGL_GrBackend == ctxInfo.backend()) {
// External on-screen render target.
- sk_sp<GrSurfaceProxy> sProxy(make_wrapped_FBO0(provider, reporter, desc));
+ sk_sp<GrSurfaceProxy> sProxy(make_wrapped_FBO0(proxyProvider, reporter, desc));
// RenderTarget-only
GrRenderTargetProxy* rtProxy = sProxy->asRenderTargetProxy();
@@ -77,9 +67,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyConversionTest, reporter, ctxInfo
{
// Internal offscreen render target.
- sk_sp<GrSurfaceProxy> sProxy(make_wrapped_offscreen_rt(provider,
- reporter, desc,
- SkBudgeted::kYes));
+ sk_sp<GrSurfaceProxy> sProxy(make_wrapped_offscreen_rt(proxyProvider, desc));
// Both RenderTarget and Texture
GrRenderTargetProxy* rtProxy = sProxy->asRenderTargetProxy();
@@ -92,7 +80,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyConversionTest, reporter, ctxInfo
{
// Internal offscreen render target - but through GrTextureProxy
- sk_sp<GrSurfaceProxy> sProxy(make_wrapped_texture(provider, desc, SkBudgeted::kYes));
+ sk_sp<GrSurfaceProxy> sProxy(make_wrapped_texture(proxyProvider, desc));
// Both RenderTarget and Texture
GrTextureProxy* tProxy = sProxy->asTextureProxy();
@@ -106,7 +94,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyConversionTest, reporter, ctxInfo
{
desc.fFlags = kNone_GrSurfaceFlags; // force no-RT
- sk_sp<GrSurfaceProxy> sProxy(make_wrapped_texture(provider, desc, SkBudgeted::kYes));
+ sk_sp<GrSurfaceProxy> sProxy(make_wrapped_texture(proxyProvider, desc));
// Texture-only
GrTextureProxy* tProxy = sProxy->asTextureProxy();
@@ -129,9 +117,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DefferredProxyConversionTest, reporter, ctxIn
desc.fConfig = kRGBA_8888_GrPixelConfig;
{
- sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(proxyProvider, desc,
- SkBackingFit::kApprox,
- SkBudgeted::kYes));
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(desc, SkBackingFit::kApprox,
+ SkBudgeted::kYes);
// Both RenderTarget and Texture
GrRenderTargetProxy* rtProxy = proxy->asRenderTargetProxy();
@@ -143,9 +130,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DefferredProxyConversionTest, reporter, ctxIn
}
{
- sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(proxyProvider, desc,
- SkBackingFit::kApprox,
- SkBudgeted::kYes));
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(desc, SkBackingFit::kApprox,
+ SkBudgeted::kYes);
// Both RenderTarget and Texture - but via GrTextureProxy
GrTextureProxy* tProxy = proxy->asTextureProxy();
@@ -160,10 +146,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DefferredProxyConversionTest, reporter, ctxIn
desc.fFlags = kNone_GrSurfaceFlags; // force no-RT
desc.fOrigin = kTopLeft_GrSurfaceOrigin;
- sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(proxyProvider, desc,
- SkBackingFit::kApprox,
- SkBudgeted::kYes));
-
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(desc, SkBackingFit::kApprox,
+ SkBudgeted::kYes);
// Texture-only
GrTextureProxy* tProxy = proxy->asTextureProxy();
REPORTER_ASSERT(reporter, tProxy);
diff --git a/tests/ProxyRefTest.cpp b/tests/ProxyRefTest.cpp
index 5bf3a57e7f..acd17be790 100644
--- a/tests/ProxyRefTest.cpp
+++ b/tests/ProxyRefTest.cpp
@@ -12,6 +12,7 @@
#if SK_SUPPORT_GPU
#include "GrContextPriv.h"
#include "GrGpuResourceRef.h"
+#include "GrProxyProvider.h"
#include "GrRenderTargetProxy.h"
#include "GrResourceProvider.h"
#include "GrSurfaceProxy.h"
@@ -65,7 +66,7 @@ static void check_refs(skiatest::Reporter* reporter,
SkASSERT(proxy->getPendingWriteCnt_TestOnly() == expectedNumWrites);
}
-static sk_sp<GrTextureProxy> make_deferred(GrContext* context) {
+static sk_sp<GrTextureProxy> make_deferred(GrProxyProvider* proxyProvider) {
GrSurfaceDesc desc;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
@@ -73,12 +74,11 @@ static sk_sp<GrTextureProxy> make_deferred(GrContext* context) {
desc.fHeight = kWidthHeight;
desc.fConfig = kRGBA_8888_GrPixelConfig;
- return GrSurfaceProxy::MakeDeferred(context->contextPriv().proxyProvider(), desc,
- SkBackingFit::kApprox, SkBudgeted::kYes,
- GrResourceProvider::kNoPendingIO_Flag);
+ return proxyProvider->createProxy(desc, SkBackingFit::kApprox, SkBudgeted::kYes,
+ GrResourceProvider::kNoPendingIO_Flag);
}
-static sk_sp<GrTextureProxy> make_wrapped(GrContext* context) {
+static sk_sp<GrTextureProxy> make_wrapped(GrProxyProvider* proxyProvider) {
GrSurfaceDesc desc;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
@@ -86,18 +86,17 @@ static sk_sp<GrTextureProxy> make_wrapped(GrContext* context) {
desc.fHeight = kWidthHeight;
desc.fConfig = kRGBA_8888_GrPixelConfig;
- sk_sp<GrTexture> tex(context->resourceProvider()->createTexture(desc, SkBudgeted::kNo));
-
- return GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin);
+ return proxyProvider->createInstantiatedProxy(desc, SkBackingFit::kExact, SkBudgeted::kNo);
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
- GrResourceProvider* provider = ctxInfo.grContext()->resourceProvider();
+ GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider();
+ GrResourceProvider* resourceProvider = ctxInfo.grContext()->resourceProvider();
for (auto make : { make_deferred, make_wrapped }) {
// A single write
{
- sk_sp<GrTextureProxy> proxy((*make)(ctxInfo.grContext()));
+ sk_sp<GrTextureProxy> proxy((*make)(proxyProvider));
if (proxy.get()) {
GrPendingIOResource<GrSurfaceProxy, kWrite_GrIOType> fWrite(proxy.get());
@@ -106,7 +105,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites);
- proxy->instantiate(provider);
+ proxy->instantiate(resourceProvider);
// In the deferred case, this checks that the refs transfered to the GrSurface
check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites);
@@ -115,7 +114,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
// A single read
{
- sk_sp<GrTextureProxy> proxy((*make)(ctxInfo.grContext()));
+ sk_sp<GrTextureProxy> proxy((*make)(proxyProvider));
if (proxy.get()) {
GrPendingIOResource<GrSurfaceProxy, kRead_GrIOType> fRead(proxy.get());
@@ -124,7 +123,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites);
- proxy->instantiate(provider);
+ proxy->instantiate(resourceProvider);
// In the deferred case, this checks that the refs transfered to the GrSurface
check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites);
@@ -133,7 +132,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
// A single read/write pair
{
- sk_sp<GrTextureProxy> proxy((*make)(ctxInfo.grContext()));
+ sk_sp<GrTextureProxy> proxy((*make)(proxyProvider));
if (proxy.get()) {
GrPendingIOResource<GrSurfaceProxy, kRW_GrIOType> fRW(proxy.get());
@@ -142,7 +141,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites);
- proxy->instantiate(provider);
+ proxy->instantiate(resourceProvider);
// In the deferred case, this checks that the refs transferred to the GrSurface
check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites);
@@ -151,7 +150,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
// Multiple normal refs
{
- sk_sp<GrTextureProxy> proxy((*make)(ctxInfo.grContext()));
+ sk_sp<GrTextureProxy> proxy((*make)(proxyProvider));
if (proxy.get()) {
proxy->ref();
proxy->ref();
@@ -161,7 +160,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
check_refs(reporter, proxy.get(), 3, 3,kExpectedReads, kExpectedWrites);
- proxy->instantiate(provider);
+ proxy->instantiate(resourceProvider);
// In the deferred case, this checks that the refs transferred to the GrSurface
check_refs(reporter, proxy.get(), 3, 3, kExpectedReads, kExpectedWrites);
@@ -173,7 +172,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
// Continue using (reffing) proxy after instantiation
{
- sk_sp<GrTextureProxy> proxy((*make)(ctxInfo.grContext()));
+ sk_sp<GrTextureProxy> proxy((*make)(proxyProvider));
if (proxy.get()) {
proxy->ref();
@@ -183,7 +182,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
check_refs(reporter, proxy.get(), 2, 2, 0, kExpectedWrites);
- proxy->instantiate(provider);
+ proxy->instantiate(resourceProvider);
// In the deferred case, this checks that the refs transfered to the GrSurface
check_refs(reporter, proxy.get(), 2, 2, 0, kExpectedWrites);
diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp
index 01c881c90b..077045f5db 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -13,6 +13,7 @@
#include "GrBackendSurface.h"
#include "GrContextPriv.h"
+#include "GrProxyProvider.h"
#include "GrRenderTargetPriv.h"
#include "GrRenderTargetProxy.h"
#include "GrResourceProvider.h"
@@ -26,17 +27,12 @@ static void check_surface(skiatest::Reporter* reporter,
GrSurfaceOrigin origin,
int width, int height,
GrPixelConfig config,
- const GrGpuResource::UniqueID& uniqueID,
SkBudgeted budgeted) {
REPORTER_ASSERT(reporter, proxy->origin() == origin);
REPORTER_ASSERT(reporter, proxy->width() == width);
REPORTER_ASSERT(reporter, proxy->height() == height);
REPORTER_ASSERT(reporter, proxy->config() == config);
- if (!uniqueID.isInvalid()) {
- REPORTER_ASSERT(reporter, proxy->uniqueID().asUInt() == uniqueID.asUInt());
- } else {
- REPORTER_ASSERT(reporter, !proxy->uniqueID().isInvalid());
- }
+ REPORTER_ASSERT(reporter, !proxy->uniqueID().isInvalid());
REPORTER_ASSERT(reporter, proxy->isBudgeted() == budgeted);
}
@@ -114,8 +110,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
GrResourceProvider* resourceProvider = ctxInfo.grContext()->resourceProvider();
const GrCaps& caps = *ctxInfo.grContext()->caps();
- const GrGpuResource::UniqueID kInvalidResourceID = GrGpuResource::UniqueID::InvalidID();
-
int attempt = 0; // useful for debugging
for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
@@ -141,9 +135,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
tex = resourceProvider->createTexture(desc, budgeted);
}
- sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(
- proxyProvider, desc,
- fit, budgeted));
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
+ desc, fit, budgeted);
REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy));
if (proxy) {
REPORTER_ASSERT(reporter, proxy->asRenderTargetProxy());
@@ -155,8 +148,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
proxy->gpuMemorySize();
check_surface(reporter, proxy.get(), origin,
- widthHeight, widthHeight, config,
- kInvalidResourceID, budgeted);
+ widthHeight, widthHeight, config, budgeted);
int supportedSamples = caps.getSampleCount(numSamples, config);
check_rendertarget(reporter, caps, resourceProvider,
proxy->asRenderTargetProxy(),
@@ -175,11 +167,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
tex = resourceProvider->createTexture(desc, budgeted);
}
- sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(
- proxyProvider,
- desc,
- fit,
- budgeted));
+ sk_sp<GrTextureProxy> proxy(proxyProvider->createProxy(
+ desc, fit, budgeted));
REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy));
if (proxy) {
// This forces the proxy to compute and cache its
@@ -190,8 +179,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
proxy->gpuMemorySize();
check_surface(reporter, proxy.get(), origin,
- widthHeight, widthHeight, config,
- kInvalidResourceID, budgeted);
+ widthHeight, widthHeight, config, budgeted);
check_texture(reporter, resourceProvider,
proxy->asTextureProxy(), fit, false);
}
@@ -207,6 +195,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
+ GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider();
GrResourceProvider* provider = ctxInfo.grContext()->resourceProvider();
const GrCaps& caps = *ctxInfo.grContext()->caps();
@@ -234,49 +223,45 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
GrBackendRenderTarget backendRT(kWidthHeight, kWidthHeight, numSamples, 8,
config, fboInfo);
- sk_sp<GrRenderTarget> defaultFBO(
- provider->wrapBackendRenderTarget(backendRT));
-
- sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(defaultFBO,
- origin));
+ sk_sp<GrSurfaceProxy> sProxy(proxyProvider->createWrappedRenderTargetProxy(
+ backendRT, origin));
check_surface(reporter, sProxy.get(), origin,
- kWidthHeight, kWidthHeight, config,
- defaultFBO->uniqueID(), SkBudgeted::kNo);
+ kWidthHeight, kWidthHeight, config, SkBudgeted::kNo);
check_rendertarget(reporter, caps, provider, sProxy->asRenderTargetProxy(),
supportedNumSamples, SkBackingFit::kExact, 0, true);
}
- sk_sp<GrTexture> tex;
-
- // Internal offscreen render target.
if (renderable) {
+ // Internal offscreen render target.
desc.fFlags = kRenderTarget_GrSurfaceFlag;
- tex = provider->createTexture(desc, budgeted);
- if (!tex) {
- continue; // This can fail on Mesa
+
+ sk_sp<GrSurfaceProxy> sProxy = proxyProvider->createInstantiatedProxy(
+ desc, SkBackingFit::kExact, budgeted);
+ if (!sProxy) {
+ continue; // This can fail on Mesa
}
- sk_sp<GrRenderTarget> rt(sk_ref_sp(tex->asRenderTarget()));
- sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(rt, origin));
check_surface(reporter, sProxy.get(), origin,
- kWidthHeight, kWidthHeight, config,
- rt->uniqueID(), budgeted);
+ kWidthHeight, kWidthHeight, config, budgeted);
check_rendertarget(reporter, caps, provider, sProxy->asRenderTargetProxy(),
supportedNumSamples, SkBackingFit::kExact,
caps.maxWindowRectangles(), true);
- }
-
- if (!tex) {
+ } else {
+ // Internal offscreen texture
SkASSERT(kNone_GrSurfaceFlags == desc.fFlags );
desc.fSampleCnt = 0;
- tex = provider->createTexture(desc, budgeted);
- }
- sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(tex, origin));
- check_surface(reporter, sProxy.get(), origin,
- kWidthHeight, kWidthHeight, config, tex->uniqueID(), budgeted);
- check_texture(reporter, provider, sProxy->asTextureProxy(),
- SkBackingFit::kExact, true);
+ sk_sp<GrSurfaceProxy> sProxy = proxyProvider->createInstantiatedProxy(
+ desc, SkBackingFit::kExact, budgeted);
+ if (!sProxy) {
+ continue;
+ }
+
+ check_surface(reporter, sProxy.get(), origin,
+ kWidthHeight, kWidthHeight, config, budgeted);
+ check_texture(reporter, provider, sProxy->asTextureProxy(),
+ SkBackingFit::kExact, true);
+ }
}
}
}
@@ -302,10 +287,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ZeroSizedProxyTest, reporter, ctxInfo) {
desc.fConfig = kRGBA_8888_GrPixelConfig;
desc.fSampleCnt = 0;
- sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(provider,
- desc,
- fit,
- SkBudgeted::kNo));
+ sk_sp<GrTextureProxy> proxy = provider->createProxy(desc, fit, SkBudgeted::kNo);
REPORTER_ASSERT(reporter, !proxy);
}
}
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index ec3e464b8c..47b4cd8ac2 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -18,6 +18,7 @@
#include "GrContext.h"
#include "GrContextFactory.h"
#include "GrContextPriv.h"
+#include "GrProxyProvider.h"
#include "SkGr.h"
#endif
@@ -463,10 +464,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Texture, reporter, ctxInfo) {
desc.fConfig = kSkia8888_GrPixelConfig;
desc.fOrigin = origin;
- sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(proxyProvider,
- desc, SkBudgeted::kNo,
- bmp.getPixels(),
- bmp.rowBytes());
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(desc, SkBudgeted::kNo,
+ bmp.getPixels(),
+ bmp.rowBytes());
sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeWrappedSurfaceContext(
std::move(proxy), nullptr);
diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp
index ee3588f5fc..00891c1677 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -12,6 +12,7 @@
#include "GrContext.h"
#include "GrContextPriv.h"
+#include "GrProxyProvider.h"
#include "GrResourceProvider.h"
#include "GrSurfaceContext.h"
#include "GrSurfaceProxy.h"
@@ -60,9 +61,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
// We are initializing the texture with zeros here
memset(alphaData, 0, X_SIZE * Y_SIZE);
- sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(proxyProvider,
- desc, SkBudgeted::kNo,
- alphaData, 0));
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(desc, SkBudgeted::kNo,
+ alphaData, 0);
if (!proxy) {
ERRORF(reporter, "Could not create alpha texture.");
return;
@@ -167,9 +167,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
rgbaData[y * X_SIZE + x] = GrColorPackRGBA(6, 7, 8, alphaData[y * X_SIZE + x]);
}
}
- sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(proxyProvider,
- desc, SkBudgeted::kNo,
- rgbaData, 0));
+
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(desc, SkBudgeted::kNo,
+ rgbaData, 0);
if (!proxy) {
// We always expect to be able to create a RGBA texture
if (!rt && kRGBA_8888_GrPixelConfig == desc.fConfig) {
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index f5453bd09d..16dc940e01 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -12,6 +12,7 @@
#include "GrClip.h"
#include "GrContext.h"
#include "GrContextPriv.h"
+#include "GrProxyProvider.h"
#include "GrRenderTargetContext.h"
#include "GrTest.h"
#include "gl/GLTestContext.h"
@@ -85,6 +86,7 @@ static void test_clear(skiatest::Reporter* reporter, GrSurfaceContext* rectConte
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(RectangleTexture, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
sk_gpu_test::GLTestContext* glContext = ctxInfo.glContext();
static const int kWidth = 13;
static const int kHeight = 13;
@@ -125,9 +127,9 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(RectangleTexture, reporter, ctxInfo) {
}
}
- sk_sp<GrTextureProxy> rectProxy = GrSurfaceProxy::MakeWrappedBackend(context,
- rectangleTex,
- origin);
+ sk_sp<GrTextureProxy> rectProxy = proxyProvider->createWrappedTextureProxy(
+ rectangleTex, origin);
+
if (!rectProxy) {
ERRORF(reporter, "Error creating proxy for rectangle texture.");
GR_GL_CALL(glContext->gl(), DeleteTextures(1, &rectTexID));
diff --git a/tests/ResourceAllocatorTest.cpp b/tests/ResourceAllocatorTest.cpp
index 8d196f6ba2..6ca4b0cf5c 100644
--- a/tests/ResourceAllocatorTest.cpp
+++ b/tests/ResourceAllocatorTest.cpp
@@ -14,6 +14,7 @@
#include "GrContextPriv.h"
#include "GrGpu.h"
+#include "GrProxyProvider.h"
#include "GrResourceAllocator.h"
#include "GrResourceProvider.h"
#include "GrSurfaceProxyPriv.h"
@@ -40,18 +41,18 @@ static sk_sp<GrSurfaceProxy> make_deferred(GrProxyProvider* proxyProvider, const
desc.fConfig = p.fConfig;
desc.fSampleCnt = p.fSampleCnt;
- return GrSurfaceProxy::MakeDeferred(proxyProvider, desc, p.fFit, SkBudgeted::kNo);
+ return proxyProvider->createProxy(desc, p.fFit, SkBudgeted::kNo);
}
static sk_sp<GrSurfaceProxy> make_backend(GrContext* context, const ProxyParams& p,
GrBackendTexture* backendTex) {
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
+
*backendTex = context->getGpu()->createTestingOnlyBackendTexture(nullptr, p.fSize, p.fSize,
p.fConfig, false,
GrMipMapped::kNo);
- sk_sp<GrSurface> tex = context->resourceProvider()->wrapBackendTexture(*backendTex,
- kBorrow_GrWrapOwnership);
- return GrSurfaceProxy::MakeWrapped(std::move(tex), p.fOrigin);
+ return proxyProvider->createWrappedTextureProxy(*backendTex, p.fOrigin);
}
static void cleanup_backend(GrContext* context, GrBackendTexture* backendTex) {
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index 27d197143d..96cda795df 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -16,6 +16,7 @@
#include "GrGpu.h"
#include "GrGpuResourceCacheAccess.h"
#include "GrGpuResourcePriv.h"
+#include "GrProxyProvider.h"
#include "GrRenderTargetPriv.h"
#include "GrResourceCache.h"
#include "GrResourceProvider.h"
@@ -1632,7 +1633,7 @@ static sk_sp<GrTexture> make_normal_texture(GrResourceProvider* provider,
return provider->createTexture(desc, SkBudgeted::kYes);
}
-static sk_sp<GrTextureProxy> make_mipmap_proxy(GrProxyProvider* provider,
+static sk_sp<GrTextureProxy> make_mipmap_proxy(GrProxyProvider* proxyProvider,
GrSurfaceFlags flags,
int width, int height,
int sampleCnt) {
@@ -1668,8 +1669,7 @@ static sk_sp<GrTextureProxy> make_mipmap_proxy(GrProxyProvider* provider,
desc.fConfig = kRGBA_8888_GrPixelConfig;
desc.fSampleCnt = sampleCnt;
- return GrSurfaceProxy::MakeDeferredMipMap(provider, desc, SkBudgeted::kYes,
- texels.get(), mipLevelCount);
+ return proxyProvider->createMipMapProxy(desc, SkBudgeted::kYes, texels.get(), mipLevelCount);
}
// Exercise GrSurface::gpuMemorySize for different combos of MSAA, RT-only,
diff --git a/tests/SRGBMipMapTest.cpp b/tests/SRGBMipMapTest.cpp
index b74663d3a2..7d6f6a9546 100644
--- a/tests/SRGBMipMapTest.cpp
+++ b/tests/SRGBMipMapTest.cpp
@@ -11,6 +11,7 @@
#include "GrClip.h"
#include "GrContext.h"
#include "GrContextPriv.h"
+#include "GrProxyProvider.h"
#include "GrRenderTargetContext.h"
#include "SkCanvas.h"
#include "SkGr.h"
@@ -131,9 +132,8 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SRGBMipMaps, reporter, ctxInfo) {
desc.fConfig = kSRGBA_8888_GrPixelConfig;
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
- sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(proxyProvider,
- desc, SkBudgeted::kNo,
- texData, 0);
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(
+ desc, SkBudgeted::kNo, texData, 0);
// Create two render target contexts (L32 and S32)
sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::MakeSRGB();
diff --git a/tests/SpecialImageTest.cpp b/tests/SpecialImageTest.cpp
index 6dfcfc4bd3..4b86697296 100644
--- a/tests/SpecialImageTest.cpp
+++ b/tests/SpecialImageTest.cpp
@@ -18,6 +18,7 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrContextPriv.h"
+#include "GrProxyProvider.h"
#include "GrSurfaceProxy.h"
#include "GrTextureProxy.h"
#include "SkGr.h"
@@ -207,6 +208,7 @@ static void test_texture_backed(skiatest::Reporter* reporter,
// Test out the SkSpecialImage::makeTextureImage entry point
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_MakeTexture, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
SkBitmap bm = create_bm();
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
@@ -235,10 +237,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_MakeTexture, reporter, ctxInfo)
// gpu
const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bm.info(), *context->caps());
- sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(
- context->contextPriv().proxyProvider(),
- desc, SkBudgeted::kNo,
- bm.getPixels(), bm.rowBytes()));
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(
+ desc, SkBudgeted::kNo, bm.getPixels(), bm.rowBytes());
if (!proxy) {
return;
}
@@ -265,13 +265,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_MakeTexture, reporter, ctxInfo)
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
SkBitmap bm = create_bm();
const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bm.info(), *context->caps());
- sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(context->contextPriv().proxyProvider(),
- desc, SkBudgeted::kNo,
- bm.getPixels(), bm.rowBytes()));
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(
+ desc, SkBudgeted::kNo, bm.getPixels(), bm.rowBytes());
if (!proxy) {
return;
}
@@ -300,6 +300,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, ctxInfo) {
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_DeferredGpu, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
SkBitmap bm = create_bm();
GrSurfaceDesc desc;
@@ -309,9 +310,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_DeferredGpu, reporter, ctxInfo)
desc.fHeight = kFullSize;
desc.fConfig = kSkia8888_GrPixelConfig;
- sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(context->contextPriv().proxyProvider(),
- desc, SkBudgeted::kNo,
- bm.getPixels(), 0));
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(
+ desc, SkBudgeted::kNo, bm.getPixels(), bm.rowBytes());
if (!proxy) {
return;
}
diff --git a/tests/TestUtils.cpp b/tests/TestUtils.cpp
index 588d479a10..463a8e9e34 100644
--- a/tests/TestUtils.cpp
+++ b/tests/TestUtils.cpp
@@ -9,6 +9,7 @@
#if SK_SUPPORT_GPU
+#include "GrProxyProvider.h"
#include "GrSurfaceContext.h"
#include "GrSurfaceProxy.h"
#include "GrTextureProxy.h"
@@ -111,9 +112,9 @@ void test_copy_to_surface(skiatest::Reporter* reporter, GrProxyProvider* proxyPr
copySrcDesc.fOrigin = (kNone_GrSurfaceFlags == flags) ? kTopLeft_GrSurfaceOrigin
: kBottomLeft_GrSurfaceOrigin;
- sk_sp<GrTextureProxy> src(GrSurfaceProxy::MakeDeferred(proxyProvider,
- copySrcDesc,
- SkBudgeted::kYes, pixels.get(), 0));
+ sk_sp<GrTextureProxy> src = proxyProvider->createTextureProxy(copySrcDesc, SkBudgeted::kYes,
+ pixels.get(), 0);
+
dstContext->copy(src.get());
test_read_pixels(reporter, dstContext, pixels.get(), testName);
diff --git a/tests/TextureProxyTest.cpp b/tests/TextureProxyTest.cpp
index 425fab26c1..82a726db99 100644
--- a/tests/TextureProxyTest.cpp
+++ b/tests/TextureProxyTest.cpp
@@ -45,11 +45,10 @@ static GrSurfaceDesc make_desc(GrSurfaceFlags flags) {
static sk_sp<GrTextureProxy> deferred_tex(skiatest::Reporter* reporter,
GrContext* context, SkBackingFit fit) {
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
- GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
+ const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(desc, fit, SkBudgeted::kYes);
// Only budgeted & wrapped external proxies get to carry uniqueKeys
- sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(proxyProvider, desc, fit,
- SkBudgeted::kYes);
REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
return proxy;
}
@@ -57,31 +56,22 @@ static sk_sp<GrTextureProxy> deferred_tex(skiatest::Reporter* reporter,
static sk_sp<GrTextureProxy> deferred_texRT(skiatest::Reporter* reporter,
GrContext* context, SkBackingFit fit) {
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
- GrSurfaceDesc desc = make_desc(kRenderTarget_GrSurfaceFlag);
+ const GrSurfaceDesc desc = make_desc(kRenderTarget_GrSurfaceFlag);
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(desc, fit, SkBudgeted::kYes);
// Only budgeted & wrapped external proxies get to carry uniqueKeys
- sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(proxyProvider, desc, fit,
- SkBudgeted::kYes);
REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
return proxy;
}
static sk_sp<GrTextureProxy> wrapped(skiatest::Reporter* reporter,
GrContext* context, SkBackingFit fit) {
- GrResourceProvider* resourceProvider = context->resourceProvider();
-
- GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
-
- sk_sp<GrTexture> tex;
- if (SkBackingFit::kApprox == fit) {
- tex = sk_sp<GrTexture>(resourceProvider->createApproxTexture(desc, 0));
- } else {
- // Only budgeted & wrapped external proxies get to carry uniqueKeys
- tex = resourceProvider->createTexture(desc, SkBudgeted::kYes);
- }
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
+ const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
- sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(std::move(tex),
- kBottomLeft_GrSurfaceOrigin);
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createInstantiatedProxy(desc, fit,
+ SkBudgeted::kYes);
+ // Only budgeted & wrapped external proxies get to carry uniqueKeys
REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
return proxy;
}
@@ -99,7 +89,7 @@ static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter,
builder[0] = kUniqueKeyData++;
builder.finish();
- GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
+ const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
sk_sp<GrTexture> tex;
if (SkBackingFit::kApprox == fit) {
@@ -119,18 +109,19 @@ static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter,
static sk_sp<GrTextureProxy> create_wrapped_backend(GrContext* context, SkBackingFit fit,
sk_sp<GrTexture>* backingSurface) {
- GrResourceProvider* provider = context->resourceProvider();
+ GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
+ GrResourceProvider* resourceProvider = context->resourceProvider();
const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
- *backingSurface = provider->createTexture(desc, SkBudgeted::kNo);
+ *backingSurface = resourceProvider->createTexture(desc, SkBudgeted::kNo);
if (!(*backingSurface)) {
return nullptr;
}
GrBackendTexture backendTex = (*backingSurface)->getBackendTexture();
- return GrSurfaceProxy::MakeWrappedBackend(context, backendTex, kBottomLeft_GrSurfaceOrigin);
+ return proxyProvider->createWrappedTextureProxy(backendTex, kBottomLeft_GrSurfaceOrigin);
}
diff --git a/tests/VkUploadPixelsTests.cpp b/tests/VkUploadPixelsTests.cpp
index d05ca779f3..6f79df7a87 100644
--- a/tests/VkUploadPixelsTests.cpp
+++ b/tests/VkUploadPixelsTests.cpp
@@ -13,6 +13,7 @@
#include "GrContextFactory.h"
#include "GrContextPriv.h"
+#include "GrProxyProvider.h"
#include "GrSurfaceProxy.h"
#include "GrTest.h"
#include "SkGr.h"
@@ -73,9 +74,8 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, GrPixe
SkColorType ct;
SkAssertResult(GrPixelConfigToColorType(config, &ct));
- sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(proxyProvider,
- surfDesc, SkBudgeted::kNo,
- srcBuffer, 0);
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(surfDesc, SkBudgeted::kNo,
+ srcBuffer, 0);
REPORTER_ASSERT(reporter, proxy);
if (proxy) {
sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeWrappedSurfaceContext(
@@ -107,7 +107,7 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, GrPixe
surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin;
- proxy = GrSurfaceProxy::MakeDeferred(proxyProvider, surfDesc, SkBudgeted::kNo, srcBuffer, 0);
+ proxy = proxyProvider->createTextureProxy(surfDesc, SkBudgeted::kNo, srcBuffer, 0);
REPORTER_ASSERT(reporter, proxy);
if (proxy) {
sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeWrappedSurfaceContext(
diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp
index 9a76dcf15b..b3da67bb96 100644
--- a/tests/WritePixelsTest.cpp
+++ b/tests/WritePixelsTest.cpp
@@ -17,6 +17,7 @@
#include "GrContext.h"
#include "GrContextPriv.h"
#include "GrGpu.h"
+#include "GrProxyProvider.h"
#include "GrTest.h"
#endif
@@ -501,9 +502,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WritePixelsPendingIO, reporter, ctxInfo) {
desc.fHeight = 64;
desc.fConfig = kRGBA_8888_GrPixelConfig;
- sk_sp<GrTextureProxy> temp = GrSurfaceProxy::MakeDeferred(proxyProvider, desc,
- SkBackingFit::kApprox,
- SkBudgeted::kYes);
+ sk_sp<GrTextureProxy> temp = proxyProvider->createProxy(desc, SkBackingFit::kApprox,
+ SkBudgeted::kYes);
temp->instantiate(context->resourceProvider());
}