diff options
author | Brian Osman <brianosman@google.com> | 2017-03-04 08:12:46 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-03-04 13:49:47 +0000 |
commit | 32342f032e1dfd133040324f851f0365f9d4cb51 (patch) | |
tree | 56cc2ae886ef068ff0ebb13a22c9357b40cdc6dd | |
parent | ae9718f1d40556ed5a49e616dbe54087f4d0d546 (diff) |
Rebase and fix chromium
Combine texture provider and resource provider
Largely mechanical. Only three places that were calling createApprox
via texture provider (ie without flags), so that was simple.
BUG=skia:
Change-Id: I876367bcdc6a8db736deedab1028de1972015509
Reviewed-on: https://skia-review.googlesource.com/9176
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
88 files changed, 624 insertions, 736 deletions
diff --git a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp index 980593f8fe..a90baae1de 100644 --- a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp +++ b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp @@ -622,7 +622,7 @@ private: class GrPerlinNoise2Effect : public GrFragmentProcessor { public: - static sk_sp<GrFragmentProcessor> Make(GrTextureProvider* textureProvider, + static sk_sp<GrFragmentProcessor> Make(GrResourceProvider* resourceProvider, SkPerlinNoiseShader2::Type type, int numOctaves, bool stitchTiles, SkPerlinNoiseShader2::PaintingData* paintingData, @@ -630,7 +630,7 @@ public: sk_sp<GrTextureProxy> noiseProxy, const SkMatrix& matrix) { return sk_sp<GrFragmentProcessor>( - new GrPerlinNoise2Effect(textureProvider, type, numOctaves, stitchTiles, paintingData, + new GrPerlinNoise2Effect(resourceProvider, type, numOctaves, stitchTiles, paintingData, std::move(permutationsProxy), std::move(noiseProxy), matrix)); } @@ -665,7 +665,7 @@ private: fPaintingData->fStitchDataInit == s.fPaintingData->fStitchDataInit; } - GrPerlinNoise2Effect(GrTextureProvider* textureProvider, + GrPerlinNoise2Effect(GrResourceProvider* resourceProvider, SkPerlinNoiseShader2::Type type, int numOctaves, bool stitchTiles, SkPerlinNoiseShader2::PaintingData* paintingData, sk_sp<GrTextureProxy> permutationsProxy, @@ -675,8 +675,8 @@ private: , fType(type) , fNumOctaves(numOctaves) , fStitchTiles(stitchTiles) - , fPermutationsSampler(textureProvider, std::move(permutationsProxy)) - , fNoiseSampler(textureProvider, std::move(noiseProxy)) + , fPermutationsSampler(resourceProvider, std::move(permutationsProxy)) + , fNoiseSampler(resourceProvider, std::move(noiseProxy)) , fPaintingData(paintingData) { this->initClassID<GrPerlinNoise2Effect>(); this->addTextureSampler(&fPermutationsSampler); @@ -1347,7 +1347,7 @@ sk_sp<GrFragmentProcessor> SkPerlinNoiseShader2::asFragmentProcessor(const AsFPA if (permutationsProxy && noiseProxy) { sk_sp<GrFragmentProcessor> inner( - GrPerlinNoise2Effect::Make(args.fContext->textureProvider(), + GrPerlinNoise2Effect::Make(args.fContext->resourceProvider(), fType, fNumOctaves, fStitchTiles, diff --git a/gm/etc1.cpp b/gm/etc1.cpp index b22a27f63f..e960a26c7e 100644 --- a/gm/etc1.cpp +++ b/gm/etc1.cpp @@ -80,7 +80,7 @@ protected: desc.fHeight = kTexHeight; sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(*context->caps(), - context->textureProvider(), + context->resourceProvider(), desc, SkBudgeted::kYes, fETC1Data.get(), 0); if (!proxy) { diff --git a/gm/texdata.cpp b/gm/texdata.cpp index 106b87e6dc..0ba20e0403 100644 --- a/gm/texdata.cpp +++ b/gm/texdata.cpp @@ -92,7 +92,7 @@ DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) { desc.fConfig = SkImageInfo2GrPixelConfig(ii, *context->caps()); sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(*context->caps(), - context->textureProvider(), + context->resourceProvider(), desc, SkBudgeted::kNo, gTextureData.get(), 0); if (!proxy) { diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp index 8be917d4f4..2d96bea8f6 100644 --- a/gm/texturedomaineffect.cpp +++ b/gm/texturedomaineffect.cpp @@ -91,7 +91,7 @@ protected: desc.fConfig = SkImageInfo2GrPixelConfig(fBmp.info(), *context->caps()); sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(*context->caps(), - context->textureProvider(), + context->resourceProvider(), desc, SkBudgeted::kYes, fBmp.getPixels(), fBmp.rowBytes())); diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp index 03d103a9b7..85f31d27d9 100644 --- a/gm/yuvtorgbeffect.cpp +++ b/gm/yuvtorgbeffect.cpp @@ -93,7 +93,7 @@ protected: desc.fConfig = SkImageInfo2GrPixelConfig(fBmp[i].info(), *context->caps()); proxy[i] = GrSurfaceProxy::MakeDeferred(*context->caps(), - context->textureProvider(), + context->resourceProvider(), desc, SkBudgeted::kYes, fBmp[i].getPixels(), fBmp[i].rowBytes()); if (!proxy[i]) { @@ -226,7 +226,7 @@ protected: desc.fConfig = SkImageInfo2GrPixelConfig(fBmp[index].info(), *context->caps()); proxy[i] = GrSurfaceProxy::MakeDeferred(*context->caps(), - context->textureProvider(), + context->resourceProvider(), desc, SkBudgeted::kYes, fBmp[index].getPixels(), fBmp[index].rowBytes()); diff --git a/gn/gpu.gni b/gn/gpu.gni index e57a91904f..a7f7543b27 100644 --- a/gn/gpu.gni +++ b/gn/gpu.gni @@ -211,8 +211,6 @@ skia_gpu_sources = [ "$_src/gpu/GrTexturePriv.h", "$_src/gpu/GrTextureProducer.cpp", "$_src/gpu/GrTextureProducer.h", - "$_src/gpu/GrTextureProvider.cpp", - "$_src/gpu/GrTextureProvider.h", "$_src/gpu/GrTextureProxy.cpp", "$_src/gpu/GrTextureRenderTargetProxy.cpp", "$_src/gpu/GrTextureToYUVPlanes.cpp", diff --git a/include/core/SkMaskFilter.h b/include/core/SkMaskFilter.h index 3475429f47..957050a51d 100644 --- a/include/core/SkMaskFilter.h +++ b/include/core/SkMaskFilter.h @@ -22,9 +22,9 @@ class GrRenderTargetContext; class GrPaint; class GrFragmentProcessor; class GrRenderTarget; +class GrResourceProvider; class GrTexture; class GrTextureProxy; -class GrTextureProvider; class SkBitmap; class SkBlitter; class SkCachedData; @@ -115,7 +115,7 @@ public: * Try to directly render the mask filter into the target. Returns true if drawing was * successful. If false is returned then paint is unmodified. */ - virtual bool directFilterMaskGPU(GrTextureProvider* texProvider, + virtual bool directFilterMaskGPU(GrResourceProvider* resourceProvider, GrRenderTargetContext* renderTargetContext, GrPaint&& paint, const GrClip&, diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index 702fdb64eb..3a7fd545b5 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -37,7 +37,6 @@ class GrResourceCache; class GrResourceProvider; class GrTextBlobCache; class GrTextContext; -class GrTextureProvider; class GrSamplerParams; class GrVertexBuffer; class GrSwizzle; @@ -146,9 +145,6 @@ public: */ void setResourceCacheLimits(int maxResources, size_t maxResourceBytes); - GrTextureProvider* textureProvider() { return fTextureProvider; } - const GrTextureProvider* textureProvider() const { return fTextureProvider; } - /** * Frees GPU created by the context. Can be called to reduce GPU memory * pressure. @@ -382,12 +378,7 @@ private: GrGpu* fGpu; const GrCaps* fCaps; GrResourceCache* fResourceCache; - // this union exists because the inheritance of GrTextureProvider->GrResourceProvider - // is in a private header. - union { - GrResourceProvider* fResourceProvider; - GrTextureProvider* fTextureProvider; - }; + GrResourceProvider* fResourceProvider; sk_sp<GrContextThreadSafeProxy> fThreadSafeProxy; @@ -401,7 +392,7 @@ private: // In debug builds we guard against improper thread handling // This guard is passed to the GrDrawingManager and, from there to all the - // GrRenderTargetContexts. It is also passed to the GrTextureProvider and SkGpuDevice. + // GrRenderTargetContexts. It is also passed to the GrResourceProvider and SkGpuDevice. mutable GrSingleOwner fSingleOwner; struct CleanUpData { diff --git a/include/gpu/GrProcessor.h b/include/gpu/GrProcessor.h index 1fee5a3f8e..8caec8e531 100644 --- a/include/gpu/GrProcessor.h +++ b/include/gpu/GrProcessor.h @@ -22,7 +22,7 @@ class GrContext; class GrCoordTransform; class GrInvariantOutput; -class GrTextureProvider; +class GrResourceProvider; class GrTextureProxy; /** @@ -216,15 +216,15 @@ public: SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode, GrShaderFlags visibility = kFragment_GrShaderFlag); - // MDB TODO: ultimately we shouldn't need the texProvider parameter - TextureSampler(GrTextureProvider*, sk_sp<GrTextureProxy>, const GrSamplerParams&); - explicit TextureSampler(GrTextureProvider*, sk_sp<GrTextureProxy>, + // MDB TODO: ultimately we shouldn't need the resource provider parameter + TextureSampler(GrResourceProvider*, sk_sp<GrTextureProxy>, const GrSamplerParams&); + explicit TextureSampler(GrResourceProvider*, sk_sp<GrTextureProxy>, GrSamplerParams::FilterMode = GrSamplerParams::kNone_FilterMode, SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode, GrShaderFlags visibility = kFragment_GrShaderFlag); - void reset(GrTextureProvider*, sk_sp<GrTextureProxy>, const GrSamplerParams&, + void reset(GrResourceProvider*, sk_sp<GrTextureProxy>, const GrSamplerParams&, GrShaderFlags visibility = kFragment_GrShaderFlag); - void reset(GrTextureProvider*, sk_sp<GrTextureProxy>, + void reset(GrResourceProvider*, sk_sp<GrTextureProxy>, GrSamplerParams::FilterMode = GrSamplerParams::kNone_FilterMode, SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode, GrShaderFlags visibility = kFragment_GrShaderFlag); diff --git a/include/gpu/GrRenderTargetContext.h b/include/gpu/GrRenderTargetContext.h index ed8ac04382..594ec96f1f 100644 --- a/include/gpu/GrRenderTargetContext.h +++ b/include/gpu/GrRenderTargetContext.h @@ -360,7 +360,7 @@ public: GrRenderTarget* accessRenderTarget() { // TODO: usage of this entry point needs to be reduced and potentially eliminated // since it ends the deferral of the GrRenderTarget's allocation - return fRenderTargetProxy->instantiate(fContext->textureProvider()); + return fRenderTargetProxy->instantiate(fContext->resourceProvider()); } GrSurfaceProxy* asSurfaceProxy() override { return fRenderTargetProxy.get(); } diff --git a/include/private/GrRenderTargetProxy.h b/include/private/GrRenderTargetProxy.h index 3bf506c951..adc7553941 100644 --- a/include/private/GrRenderTargetProxy.h +++ b/include/private/GrRenderTargetProxy.h @@ -12,7 +12,7 @@ #include "GrSurfaceProxy.h" #include "GrTypes.h" -class GrTextureProvider; +class GrResourceProvider; // This class delays the acquisition of RenderTargets until they are actually // required @@ -24,7 +24,7 @@ public: const GrRenderTargetProxy* asRenderTargetProxy() const override { return this; } // Actually instantiate the backing rendertarget, if necessary. - GrRenderTarget* instantiate(GrTextureProvider* texProvider); + GrRenderTarget* instantiate(GrResourceProvider* resourceProvider); bool isStencilBufferMultisampled() const { return fDesc.fSampleCnt > 0; } diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h index 91a4c3ce67..25a6fb3074 100644 --- a/include/private/GrSurfaceProxy.h +++ b/include/private/GrSurfaceProxy.h @@ -16,10 +16,10 @@ class GrCaps; class GrRenderTargetOpList; class GrRenderTargetProxy; +class GrResourceProvider; class GrSurfaceContext; class GrSurfaceProxyPriv; class GrTextureOpList; -class GrTextureProvider; class GrTextureProxy; //#define SK_DISABLE_DEFERRED_PROXIES 1 @@ -172,13 +172,13 @@ public: static sk_sp<GrSurfaceProxy> MakeWrapped(sk_sp<GrSurface>); static sk_sp<GrTextureProxy> MakeWrapped(sk_sp<GrTexture>); - static sk_sp<GrTextureProxy> MakeDeferred(GrTextureProvider*, const GrCaps&, + static sk_sp<GrTextureProxy> MakeDeferred(GrResourceProvider*, const GrCaps&, const GrSurfaceDesc&, SkBackingFit, SkBudgeted, uint32_t flags = 0); // TODO: need to refine ownership semantics of 'srcData' if we're in completely // deferred mode - static sk_sp<GrTextureProxy> MakeDeferred(const GrCaps&, GrTextureProvider*, + static sk_sp<GrTextureProxy> MakeDeferred(const GrCaps&, GrResourceProvider*, const GrSurfaceDesc&, SkBudgeted, const void* srcData, size_t rowBytes); @@ -237,7 +237,7 @@ public: */ UniqueID uniqueID() const { return fUniqueID; } - GrSurface* instantiate(GrTextureProvider* texProvider); + GrSurface* instantiate(GrResourceProvider* resourceProvider); /** * Helper that gets the width and height of the surface as a bounding rectangle. diff --git a/include/private/GrTextureProxy.h b/include/private/GrTextureProxy.h index f4c52fb6e0..9383ec7fac 100644 --- a/include/private/GrTextureProxy.h +++ b/include/private/GrTextureProxy.h @@ -12,8 +12,8 @@ #include "GrTexture.h" class GrCaps; +class GrResourceProvider; class GrTextureOpList; -class GrTextureProvider; // This class delays the acquisition of textures until they are actually required class GrTextureProxy : virtual public GrSurfaceProxy { @@ -22,7 +22,7 @@ public: const GrTextureProxy* asTextureProxy() const override { return this; } // Actually instantiate the backing texture, if necessary - GrTexture* instantiate(GrTextureProvider*); + GrTexture* instantiate(GrResourceProvider*); protected: friend class GrSurfaceProxy; // for ctors diff --git a/src/core/SkGpuBlurUtils.cpp b/src/core/SkGpuBlurUtils.cpp index bc40c38a42..43f28cb61d 100644 --- a/src/core/SkGpuBlurUtils.cpp +++ b/src/core/SkGpuBlurUtils.cpp @@ -199,7 +199,7 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context, // Chrome is crashing with proxies when they need to be instantiated. // Force an instantiation here (where, in olden days, we used to require a GrTexture) // to see if the input is already un-instantiable. - GrTexture* temp = srcProxy->instantiate(context->textureProvider()); + GrTexture* temp = srcProxy->instantiate(context->resourceProvider()); if (!temp) { return nullptr; } diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp index c33a008baa..b4f9e8b949 100644 --- a/src/core/SkImageCacherator.cpp +++ b/src/core/SkImageCacherator.cpp @@ -21,8 +21,8 @@ #include "GrGpuResourcePriv.h" #include "GrImageTextureMaker.h" #include "GrResourceKey.h" +#include "GrResourceProvider.h" #include "GrSamplerParams.h" -#include "GrTextureProvider.h" #include "GrYUVProvider.h" #include "SkGr.h" #include "SkGrPriv.h" @@ -467,7 +467,7 @@ static GrTexture* load_compressed_into_texture(GrContext* ctx, SkData* data, GrS } desc.fConfig = config; - return ctx->textureProvider()->createTexture(desc, SkBudgeted::kYes, rawStart, 0); + return ctx->resourceProvider()->createTexture(desc, SkBudgeted::kYes, rawStart, 0); } #endif @@ -486,10 +486,10 @@ public: } }; -static GrTexture* set_key_and_return(GrTextureProvider* texProvider, +static GrTexture* set_key_and_return(GrResourceProvider* resourceProvider, GrTexture* tex, const GrUniqueKey& key) { if (key.isValid()) { - texProvider->assignUniqueKeyToTexture(key, tex); + resourceProvider->assignUniqueKeyToTexture(key, tex); } return tex; } @@ -538,7 +538,7 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& ori // 1. Check the cache for a pre-existing one if (key.isValid()) { - if (GrTexture* tex = ctx->textureProvider()->findAndRefTextureByUniqueKey(key)) { + if (GrTexture* tex = ctx->resourceProvider()->findAndRefTextureByUniqueKey(key)) { SK_HISTOGRAM_ENUMERATION("LockTexturePath", kPreExisting_LockTexturePath, kLockTexturePathCount); return tex; @@ -556,9 +556,9 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& ori if (sk_sp<GrTextureProxy> proxy = generator->generateTexture(ctx, cacheInfo, fOrigin)) { SK_HISTOGRAM_ENUMERATION("LockTexturePath", kNative_LockTexturePath, kLockTexturePathCount); - GrTexture* tex2 = proxy->instantiate(ctx->textureProvider()); + GrTexture* tex2 = proxy->instantiate(ctx->resourceProvider()); if (tex2) { - return set_key_and_return(ctx->textureProvider(), SkSafeRef(tex2), key); + return set_key_and_return(ctx->resourceProvider(), SkSafeRef(tex2), key); } } } @@ -586,7 +586,7 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& ori if (tex) { SK_HISTOGRAM_ENUMERATION("LockTexturePath", kYUV_LockTexturePath, kLockTexturePathCount); - return set_key_and_return(ctx->textureProvider(), tex.release(), key); + return set_key_and_return(ctx->resourceProvider(), tex.release(), key); } } @@ -603,7 +603,7 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& ori if (tex) { SK_HISTOGRAM_ENUMERATION("LockTexturePath", kRGBA_LockTexturePath, kLockTexturePathCount); - return set_key_and_return(ctx->textureProvider(), tex, key); + return set_key_and_return(ctx->resourceProvider(), tex, key); } } SK_HISTOGRAM_ENUMERATION("LockTexturePath", kFailure_LockTexturePath, diff --git a/src/core/SkMaskFilter.cpp b/src/core/SkMaskFilter.cpp index 59dbe2e000..e856058433 100644 --- a/src/core/SkMaskFilter.cpp +++ b/src/core/SkMaskFilter.cpp @@ -314,7 +314,7 @@ bool SkMaskFilter::canFilterMaskGPU(const SkRRect& devRRect, return false; } -bool SkMaskFilter::directFilterMaskGPU(GrTextureProvider* texProvider, +bool SkMaskFilter::directFilterMaskGPU(GrResourceProvider* resourceProvider, GrRenderTargetContext* renderTargetContext, GrPaint&&, const GrClip&, diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp index ad5ef4d869..9ded6aafd8 100644 --- a/src/core/SkSpecialImage.cpp +++ b/src/core/SkSpecialImage.cpp @@ -349,7 +349,7 @@ sk_sp<SkSpecialImage> SkSpecialImage::MakeFromRaster(const SkIRect& subset, static sk_sp<SkImage> wrap_proxy_in_image(GrContext* context, GrTextureProxy* proxy, SkAlphaType alphaType, sk_sp<SkColorSpace> colorSpace) { // TODO: add GrTextureProxy-backed SkImage_Gpus - GrTexture* tex = proxy->instantiate(context->textureProvider()); + GrTexture* tex = proxy->instantiate(context->resourceProvider()); if (!tex) { return nullptr; } @@ -390,7 +390,7 @@ public: this->subset().width(), this->subset().height()); // TODO: add GrTextureProxy-backed SkImage_Gpus - GrTexture* tex = fTextureProxy->instantiate(fContext->textureProvider()); + GrTexture* tex = fTextureProxy->instantiate(fContext->resourceProvider()); if (!tex) { return; } @@ -432,7 +432,7 @@ public: } // Reading back to an SkBitmap ends deferral - GrTexture* texture = fTextureProxy->instantiate(fContext->textureProvider()); + GrTexture* texture = fTextureProxy->instantiate(fContext->resourceProvider()); if (!texture) { return false; } diff --git a/src/effects/GrAlphaThresholdFragmentProcessor.cpp b/src/effects/GrAlphaThresholdFragmentProcessor.cpp index 464dc5e242..897d44768f 100644 --- a/src/effects/GrAlphaThresholdFragmentProcessor.cpp +++ b/src/effects/GrAlphaThresholdFragmentProcessor.cpp @@ -39,14 +39,14 @@ GrAlphaThresholdFragmentProcessor::GrAlphaThresholdFragmentProcessor( , fOuterThreshold(outerThreshold) , fImageCoordTransform(context, SkMatrix::I(), proxy.get(), GrSamplerParams::kNone_FilterMode) - , fImageTextureSampler(context->textureProvider(), std::move(proxy)) + , fImageTextureSampler(context->resourceProvider(), std::move(proxy)) , fColorSpaceXform(std::move(colorSpaceXform)) , fMaskCoordTransform( context, SkMatrix::MakeTrans(SkIntToScalar(-bounds.x()), SkIntToScalar(-bounds.y())), maskProxy.get(), GrSamplerParams::kNone_FilterMode) - , fMaskTextureSampler(context->textureProvider(), maskProxy) { + , fMaskTextureSampler(context->resourceProvider(), maskProxy) { this->initClassID<GrAlphaThresholdFragmentProcessor>(); this->addCoordTransform(&fImageCoordTransform); this->addTextureSampler(&fImageTextureSampler); diff --git a/src/effects/GrCircleBlurFragmentProcessor.cpp b/src/effects/GrCircleBlurFragmentProcessor.cpp index de4bb58231..f9f960cce5 100644 --- a/src/effects/GrCircleBlurFragmentProcessor.cpp +++ b/src/effects/GrCircleBlurFragmentProcessor.cpp @@ -10,7 +10,7 @@ #if SK_SUPPORT_GPU #include "GrContext.h" -#include "GrTextureProvider.h" +#include "GrResourceProvider.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" #include "glsl/GrGLSLProgramDataManager.h" @@ -82,7 +82,7 @@ void GrCircleBlurFragmentProcessor::GLSLProcessor::onSetData(const GrGLSLProgram /////////////////////////////////////////////////////////////////////////////// -GrCircleBlurFragmentProcessor::GrCircleBlurFragmentProcessor(GrTextureProvider* textureProvider, +GrCircleBlurFragmentProcessor::GrCircleBlurFragmentProcessor(GrResourceProvider* resourceProvider, const SkRect& circle, float textureRadius, float solidRadius, @@ -91,7 +91,7 @@ GrCircleBlurFragmentProcessor::GrCircleBlurFragmentProcessor(GrTextureProvider* , fCircle(circle) , fSolidRadius(solidRadius) , fTextureRadius(textureRadius) - , fBlurProfileSampler(textureProvider, std::move(blurProfile), + , fBlurProfileSampler(resourceProvider, std::move(blurProfile), GrSamplerParams::kBilerp_FilterMode) { this->initClassID<GrCircleBlurFragmentProcessor>(); this->addTextureSampler(&fBlurProfileSampler); @@ -260,7 +260,7 @@ static uint8_t* create_half_plane_profile(int profileWidth) { return profile; } -static sk_sp<GrTextureProxy> create_profile_texture(GrTextureProvider* textureProvider, +static sk_sp<GrTextureProxy> create_profile_texture(GrResourceProvider* resourceProvider, const SkRect& circle, float sigma, float* solidRadius, float* textureRadius) { @@ -300,7 +300,7 @@ static sk_sp<GrTextureProxy> create_profile_texture(GrTextureProvider* texturePr builder.finish(); // MDB TODO (caching): this side-steps the issue of texture proxies with unique IDs - sk_sp<GrTexture> blurProfile(textureProvider->findAndRefTextureByUniqueKey(key)); + sk_sp<GrTexture> blurProfile(resourceProvider->findAndRefTextureByUniqueKey(key)); if (!blurProfile) { static constexpr int kProfileTextureWidth = 512; GrSurfaceDesc texDesc; @@ -318,13 +318,13 @@ static sk_sp<GrTextureProxy> create_profile_texture(GrTextureProvider* texturePr kProfileTextureWidth)); } - blurProfile.reset(textureProvider->createTexture(texDesc, SkBudgeted::kYes, + blurProfile.reset(resourceProvider->createTexture(texDesc, SkBudgeted::kYes, profile.get(), 0)); if (!blurProfile) { return nullptr; } - textureProvider->assignUniqueKeyToTexture(key, blurProfile.get()); + resourceProvider->assignUniqueKeyToTexture(key, blurProfile.get()); } return GrSurfaceProxy::MakeWrapped(std::move(blurProfile)); @@ -332,16 +332,16 @@ static sk_sp<GrTextureProxy> create_profile_texture(GrTextureProvider* texturePr ////////////////////////////////////////////////////////////////////////////// -sk_sp<GrFragmentProcessor> GrCircleBlurFragmentProcessor::Make(GrTextureProvider* textureProvider, +sk_sp<GrFragmentProcessor> GrCircleBlurFragmentProcessor::Make(GrResourceProvider* resourceProvider, const SkRect& circle, float sigma) { float solidRadius; float textureRadius; - sk_sp<GrTextureProxy> profile(create_profile_texture(textureProvider, circle, sigma, + sk_sp<GrTextureProxy> profile(create_profile_texture(resourceProvider, circle, sigma, &solidRadius, &textureRadius)); if (!profile) { return nullptr; } - return sk_sp<GrFragmentProcessor>(new GrCircleBlurFragmentProcessor(textureProvider, + return sk_sp<GrFragmentProcessor>(new GrCircleBlurFragmentProcessor(resourceProvider, circle, textureRadius, solidRadius, std::move(profile))); @@ -356,7 +356,7 @@ sk_sp<GrFragmentProcessor> GrCircleBlurFragmentProcessor::TestCreate(GrProcessor SkScalar wh = d->fRandom->nextRangeScalar(100.f, 1000.f); SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f); SkRect circle = SkRect::MakeWH(wh, wh); - return GrCircleBlurFragmentProcessor::Make(d->context()->textureProvider(), circle, sigma); + return GrCircleBlurFragmentProcessor::Make(d->context()->resourceProvider(), circle, sigma); } #endif diff --git a/src/effects/GrCircleBlurFragmentProcessor.h b/src/effects/GrCircleBlurFragmentProcessor.h index 9b1fdbf08a..c6cf3ba923 100644 --- a/src/effects/GrCircleBlurFragmentProcessor.h +++ b/src/effects/GrCircleBlurFragmentProcessor.h @@ -16,7 +16,7 @@ #include "GrFragmentProcessor.h" #include "GrProcessorUnitTest.h" -class GrTextureProvider; +class GrResourceProvider; // This FP handles the special case of a blurred circle. It uses a 1D // profile that is just rotated about the origin of the circle. @@ -34,7 +34,7 @@ public: return str; } - static sk_sp<GrFragmentProcessor> Make(GrTextureProvider*, const SkRect& circle, float sigma); + static sk_sp<GrFragmentProcessor> Make(GrResourceProvider*, const SkRect& circle, float sigma); private: // This nested GLSL processor implementation is defined in the cpp file. @@ -45,7 +45,7 @@ private: * The x texture coord should map from 0 to 1 across the radius range of solidRadius to * solidRadius + textureRadius. */ - GrCircleBlurFragmentProcessor(GrTextureProvider*, const SkRect& circle, + GrCircleBlurFragmentProcessor(GrResourceProvider*, const SkRect& circle, float textureRadius, float innerRadius, sk_sp<GrTextureProxy> blurProfile); diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index 2ee942d316..7ca7aa8f15 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -19,11 +19,11 @@ #include "GrCircleBlurFragmentProcessor.h" #include "GrContext.h" #include "GrRenderTargetContext.h" +#include "GrResourceProvider.h" #include "GrTexture.h" #include "GrFragmentProcessor.h" #include "GrShaderCaps.h" #include "GrStyle.h" -#include "GrTextureProvider.h" #include "GrTextureProxy.h" #include "effects/GrSimpleTextureEffect.h" #include "glsl/GrGLSLFragmentProcessor.h" @@ -50,7 +50,7 @@ public: const SkIRect& clipBounds, const SkMatrix& ctm, SkRect* maskRect) const override; - bool directFilterMaskGPU(GrTextureProvider* texProvider, + bool directFilterMaskGPU(GrResourceProvider* resourceProvider, GrRenderTargetContext* renderTargetContext, GrPaint&&, const GrClip&, @@ -771,7 +771,7 @@ public: const char* name() const override { return "RectBlur"; } - static sk_sp<GrFragmentProcessor> Make(GrTextureProvider* textureProvider, + static sk_sp<GrFragmentProcessor> Make(GrResourceProvider* resourceProvider, const SkRect& rect, float sigma) { int doubleProfileSize = SkScalarCeilToInt(12*sigma); @@ -781,7 +781,7 @@ public: return nullptr; } - sk_sp<GrTextureProxy> blurProfile(CreateBlurProfileTexture(textureProvider, sigma)); + sk_sp<GrTextureProxy> blurProfile(CreateBlurProfileTexture(resourceProvider, sigma)); if (!blurProfile) { return nullptr; } @@ -805,7 +805,7 @@ public: precision = kDefault_GrSLPrecision; } - return sk_sp<GrFragmentProcessor>(new GrRectBlurEffect(textureProvider, rect, sigma, + return sk_sp<GrFragmentProcessor>(new GrRectBlurEffect(resourceProvider, rect, sigma, std::move(blurProfile), precision)); } @@ -814,7 +814,7 @@ public: GrSLPrecision precision() const { return fPrecision; } private: - GrRectBlurEffect(GrTextureProvider*, const SkRect& rect, float sigma, + GrRectBlurEffect(GrResourceProvider*, const SkRect& rect, float sigma, sk_sp<GrTextureProxy> blurProfile, GrSLPrecision fPrecision); GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; @@ -823,7 +823,7 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; - static sk_sp<GrTextureProxy> CreateBlurProfileTexture(GrTextureProvider*, float sigma); + static sk_sp<GrTextureProxy> CreateBlurProfileTexture(GrResourceProvider*, float sigma); SkRect fRect; float fSigma; @@ -942,8 +942,8 @@ void GrGLRectBlurEffect::onSetData(const GrGLSLProgramDataManager& pdman, } // MDB TODO (caching): This side-steps the issue of texture proxies with unique IDs -sk_sp<GrTextureProxy> GrRectBlurEffect::CreateBlurProfileTexture(GrTextureProvider* textureProvider, - float sigma) { +sk_sp<GrTextureProxy> GrRectBlurEffect::CreateBlurProfileTexture( + GrResourceProvider* resourceProvider, float sigma) { GrSurfaceDesc texDesc; unsigned int profileSize = SkScalarCeilToInt(6*sigma); @@ -959,30 +959,30 @@ sk_sp<GrTextureProxy> GrRectBlurEffect::CreateBlurProfileTexture(GrTextureProvid builder[0] = profileSize; builder.finish(); - sk_sp<GrTexture> blurProfile(textureProvider->findAndRefTextureByUniqueKey(key)); + sk_sp<GrTexture> blurProfile(resourceProvider->findAndRefTextureByUniqueKey(key)); if (!blurProfile) { std::unique_ptr<uint8_t[]> profile(SkBlurMask::ComputeBlurProfile(sigma)); - blurProfile.reset(textureProvider->createTexture(texDesc, SkBudgeted::kYes, + blurProfile.reset(resourceProvider->createTexture(texDesc, SkBudgeted::kYes, profile.get(), 0)); if (!blurProfile) { return nullptr; } - textureProvider->assignUniqueKeyToTexture(key, blurProfile.get()); + resourceProvider->assignUniqueKeyToTexture(key, blurProfile.get()); } return GrSurfaceProxy::MakeWrapped(std::move(blurProfile)); } -GrRectBlurEffect::GrRectBlurEffect(GrTextureProvider* textureProvider, +GrRectBlurEffect::GrRectBlurEffect(GrResourceProvider* resourceProvider, const SkRect& rect, float sigma, sk_sp<GrTextureProxy> blurProfile, GrSLPrecision precision) : INHERITED(kCompatibleWithCoverageAsAlpha_OptimizationFlag) , fRect(rect) , fSigma(sigma) - , fBlurProfileSampler(textureProvider, std::move(blurProfile)) + , fBlurProfileSampler(resourceProvider, std::move(blurProfile)) , fPrecision(precision) { this->initClassID<GrRectBlurEffect>(); this->addTextureSampler(&fBlurProfileSampler); @@ -1009,12 +1009,12 @@ sk_sp<GrFragmentProcessor> GrRectBlurEffect::TestCreate(GrProcessorTestData* d) float sigma = d->fRandom->nextRangeF(3,8); float width = d->fRandom->nextRangeF(200,300); float height = d->fRandom->nextRangeF(200,300); - return GrRectBlurEffect::Make(d->context()->textureProvider(), SkRect::MakeWH(width, height), + return GrRectBlurEffect::Make(d->context()->resourceProvider(), SkRect::MakeWH(width, height), sigma); } #endif -bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider, +bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrResourceProvider* resourceProvider, GrRenderTargetContext* renderTargetContext, GrPaint&& paint, const GrClip& clip, @@ -1041,9 +1041,9 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider, SkScalar pad = 3.0f * xformedSigma; rect.outset(pad, pad); - fp = GrRectBlurEffect::Make(texProvider, rect, xformedSigma); + fp = GrRectBlurEffect::Make(resourceProvider, rect, xformedSigma); } else if (path.isOval(&rect) && SkScalarNearlyEqual(rect.width(), rect.height())) { - fp = GrCircleBlurFragmentProcessor::Make(texProvider, rect, xformedSigma); + fp = GrCircleBlurFragmentProcessor::Make(resourceProvider, rect, xformedSigma); // expand the rect for the coverage geometry int pad = SkScalarCeilToInt(6*xformedSigma)/2; @@ -1085,7 +1085,7 @@ public: private: GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; - GrRRectBlurEffect(GrTextureProvider*, float sigma, const SkRRect&, + GrRRectBlurEffect(GrResourceProvider*, float sigma, const SkRRect&, sk_sp<GrTextureProxy> profileProxy); virtual void onGetGLSLProcessorKey(const GrShaderCaps& caps, @@ -1121,7 +1121,7 @@ static sk_sp<GrTextureProxy> find_or_create_rrect_blur_mask(GrContext* context, } builder.finish(); - sk_sp<GrTexture> mask(context->textureProvider()->findAndRefTextureByUniqueKey(key)); + sk_sp<GrTexture> mask(context->resourceProvider()->findAndRefTextureByUniqueKey(key)); if (!mask) { // TODO: this could be approx but the texture coords will need to be updated sk_sp<GrRenderTargetContext> rtc(context->makeDeferredRenderTargetContextWithFallback( @@ -1157,7 +1157,7 @@ static sk_sp<GrTextureProxy> find_or_create_rrect_blur_mask(GrContext* context, if (!mask) { return nullptr; } - context->textureProvider()->assignUniqueKeyToTexture(key, mask.get()); + context->resourceProvider()->assignUniqueKeyToTexture(key, mask.get()); } return GrSurfaceProxy::MakeWrapped(std::move(mask)); @@ -1200,19 +1200,19 @@ sk_sp<GrFragmentProcessor> GrRRectBlurEffect::Make(GrContext* context, return nullptr; } - return sk_sp<GrFragmentProcessor>(new GrRRectBlurEffect(context->textureProvider(), + return sk_sp<GrFragmentProcessor>(new GrRRectBlurEffect(context->resourceProvider(), xformedSigma, devRRect, std::move(mask))); } -GrRRectBlurEffect::GrRRectBlurEffect(GrTextureProvider* textureProvider, +GrRRectBlurEffect::GrRRectBlurEffect(GrResourceProvider* resourceProvider, float sigma, const SkRRect& rrect, sk_sp<GrTextureProxy> ninePatchProxy) : INHERITED(kCompatibleWithCoverageAsAlpha_OptimizationFlag) , fRRect(rrect) , fSigma(sigma) - , fNinePatchSampler(textureProvider, std::move(ninePatchProxy)) { + , fNinePatchSampler(resourceProvider, std::move(ninePatchProxy)) { this->initClassID<GrRRectBlurEffect>(); this->addTextureSampler(&fNinePatchSampler); } @@ -1369,9 +1369,9 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context, SkScalar pad = 3.0f * xformedSigma; const SkRect dstCoverageRect = devRRect.rect().makeOutset(pad, pad); - fp = GrRectBlurEffect::Make(context->textureProvider(), dstCoverageRect, xformedSigma); + fp = GrRectBlurEffect::Make(context->resourceProvider(), dstCoverageRect, xformedSigma); } else { - fp = GrCircleBlurFragmentProcessor::Make(context->textureProvider(), + fp = GrCircleBlurFragmentProcessor::Make(context->resourceProvider(), devRRect.rect(), xformedSigma); } diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp index 3c0a2d582a..00059817dd 100644 --- a/src/effects/SkDisplacementMapEffect.cpp +++ b/src/effects/SkDisplacementMapEffect.cpp @@ -498,11 +498,11 @@ GrDisplacementMapEffect::GrDisplacementMapEffect( : kNone_OptimizationFlags) , fDisplacementTransform(context, offsetMatrix, displacement.get(), GrSamplerParams::kNone_FilterMode) - , fDisplacementSampler(context->textureProvider(), displacement) + , fDisplacementSampler(context->resourceProvider(), displacement) , fColorTransform(context, color.get(), GrSamplerParams::kNone_FilterMode) , fDomain(color.get(), GrTextureDomain::MakeTexelDomain(SkIRect::MakeSize(colorDimensions)), GrTextureDomain::kDecal_Mode) - , fColorSampler(context->textureProvider(), color) + , fColorSampler(context->resourceProvider(), color) , fColorSpaceXform(std::move(colorSpaceXform)) , fXChannelSelector(xChannelSelector) , fYChannelSelector(yChannelSelector) diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp index 5f8fe32f08..4ebf36a803 100644 --- a/src/effects/SkPerlinNoiseShader.cpp +++ b/src/effects/SkPerlinNoiseShader.cpp @@ -486,7 +486,7 @@ private: class GrPerlinNoiseEffect : public GrFragmentProcessor { public: - static sk_sp<GrFragmentProcessor> Make(GrTextureProvider* textureProvider, + static sk_sp<GrFragmentProcessor> Make(GrResourceProvider* resourceProvider, SkPerlinNoiseShader::Type type, int numOctaves, bool stitchTiles, SkPerlinNoiseShader::PaintingData* paintingData, @@ -494,7 +494,7 @@ public: sk_sp<GrTextureProxy> noiseProxy, const SkMatrix& matrix) { return sk_sp<GrFragmentProcessor>( - new GrPerlinNoiseEffect(textureProvider, type, numOctaves, stitchTiles, paintingData, + new GrPerlinNoiseEffect(resourceProvider, type, numOctaves, stitchTiles, paintingData, std::move(permutationsProxy), std::move(noiseProxy), matrix)); } @@ -528,7 +528,7 @@ private: fPaintingData->fStitchDataInit == s.fPaintingData->fStitchDataInit; } - GrPerlinNoiseEffect(GrTextureProvider* textureProvider, + GrPerlinNoiseEffect(GrResourceProvider* resourceProvider, SkPerlinNoiseShader::Type type, int numOctaves, bool stitchTiles, SkPerlinNoiseShader::PaintingData* paintingData, sk_sp<GrTextureProxy> permutationsProxy, sk_sp<GrTextureProxy> noiseProxy, @@ -538,8 +538,8 @@ private: , fCoordTransform(matrix) , fNumOctaves(numOctaves) , fStitchTiles(stitchTiles) - , fPermutationsSampler(textureProvider, std::move(permutationsProxy)) - , fNoiseSampler(textureProvider, std::move(noiseProxy)) + , fPermutationsSampler(resourceProvider, std::move(permutationsProxy)) + , fNoiseSampler(resourceProvider, std::move(noiseProxy)) , fPaintingData(paintingData) { this->initClassID<GrPerlinNoiseEffect>(); this->addTextureSampler(&fPermutationsSampler); @@ -926,7 +926,7 @@ sk_sp<GrFragmentProcessor> SkPerlinNoiseShader::asFragmentProcessor(const AsFPAr m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1); if (permutationsProxy && noiseProxy) { sk_sp<GrFragmentProcessor> inner( - GrPerlinNoiseEffect::Make(args.fContext->textureProvider(), + GrPerlinNoiseEffect::Make(args.fContext->resourceProvider(), fType, fNumOctaves, fStitchTiles, diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp index b63ed47ad9..ba3f084d74 100644 --- a/src/effects/SkTableColorFilter.cpp +++ b/src/effects/SkTableColorFilter.cpp @@ -515,7 +515,7 @@ sk_sp<GrFragmentProcessor> ColorTableEffect::Make(GrContext* context, const SkBi ColorTableEffect::ColorTableEffect(GrContext* context, sk_sp<GrTextureProxy> proxy, GrTextureStripAtlas* atlas, int row, unsigned flags) : INHERITED(kNone_OptimizationFlags) // Not bothering with table-specific optimizations. - , fTextureSampler(context->textureProvider(), std::move(proxy)) + , fTextureSampler(context->resourceProvider(), std::move(proxy)) , fAtlas(atlas) , fRow(row) { this->initClassID<ColorTableEffect>(); diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp index 32189c57ad..bba9f857cd 100644 --- a/src/effects/gradients/SkGradientShader.cpp +++ b/src/effects/gradients/SkGradientShader.cpp @@ -1702,7 +1702,7 @@ GrGradientEffect::GrGradientEffect(const CreateArgs& args, bool isOpaque) fCoordTransform.reset(args.fContext, *args.fMatrix, fAtlas->asTextureProxyRef().get(), params.filterMode(), false); - fTextureSampler.reset(args.fContext->textureProvider(), + fTextureSampler.reset(args.fContext->resourceProvider(), fAtlas->asTextureProxyRef(), params); } else { // In this instance we know the params are: @@ -1719,7 +1719,7 @@ GrGradientEffect::GrGradientEffect(const CreateArgs& args, bool isOpaque) // This is 2/2 places where auto-normalization is disabled fCoordTransform.reset(args.fContext, *args.fMatrix, proxy.get(), params.filterMode(), false); - fTextureSampler.reset(args.fContext->textureProvider(), + fTextureSampler.reset(args.fContext->resourceProvider(), std::move(proxy), params); fYCoord = SK_ScalarHalf; } diff --git a/src/effects/shadows/SkAmbientShadowMaskFilter.cpp b/src/effects/shadows/SkAmbientShadowMaskFilter.cpp index b6f5392cb1..561d77dd67 100644 --- a/src/effects/shadows/SkAmbientShadowMaskFilter.cpp +++ b/src/effects/shadows/SkAmbientShadowMaskFilter.cpp @@ -34,7 +34,7 @@ public: const SkIRect& clipBounds, const SkMatrix& ctm, SkRect* maskRect) const override; - bool directFilterMaskGPU(GrTextureProvider* texProvider, + bool directFilterMaskGPU(GrResourceProvider* resourceProvider, GrRenderTargetContext* drawContext, GrPaint&&, const GrClip&, @@ -139,7 +139,7 @@ bool SkAmbientShadowMaskFilterImpl::canFilterMaskGPU(const SkRRect& devRRect, static const float kHeightFactor = 1.0f / 128.0f; static const float kGeomFactor = 64.0f; -bool SkAmbientShadowMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider, +bool SkAmbientShadowMaskFilterImpl::directFilterMaskGPU(GrResourceProvider* resourceProvider, GrRenderTargetContext* rtContext, GrPaint&& paint, const GrClip& clip, diff --git a/src/effects/shadows/SkSpotShadowMaskFilter.cpp b/src/effects/shadows/SkSpotShadowMaskFilter.cpp index 99a03db091..0a97320ddf 100644 --- a/src/effects/shadows/SkSpotShadowMaskFilter.cpp +++ b/src/effects/shadows/SkSpotShadowMaskFilter.cpp @@ -35,7 +35,7 @@ public: const SkIRect& clipBounds, const SkMatrix& ctm, SkRect* maskRect) const override; - bool directFilterMaskGPU(GrTextureProvider* texProvider, + bool directFilterMaskGPU(GrResourceProvider* resourceProvider, GrRenderTargetContext* drawContext, GrPaint&&, const GrClip&, @@ -156,7 +156,7 @@ bool SkSpotShadowMaskFilterImpl::canFilterMaskGPU(const SkRRect& devRRect, return true; } -bool SkSpotShadowMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider, +bool SkSpotShadowMaskFilterImpl::directFilterMaskGPU(GrResourceProvider* resourceProvider, GrRenderTargetContext* rtContext, GrPaint&& paint, const GrClip& clip, diff --git a/src/gpu/GrBitmapTextureMaker.cpp b/src/gpu/GrBitmapTextureMaker.cpp index cff052fa53..24cb05f937 100644 --- a/src/gpu/GrBitmapTextureMaker.cpp +++ b/src/gpu/GrBitmapTextureMaker.cpp @@ -9,7 +9,7 @@ #include "GrContext.h" #include "GrGpuResourcePriv.h" -#include "GrTextureProvider.h" +#include "GrResourceProvider.h" #include "SkBitmap.h" #include "SkGrPriv.h" #include "SkPixelRef.h" @@ -32,7 +32,7 @@ GrTexture* GrBitmapTextureMaker::refOriginalTexture(bool willBeMipped, GrTexture* tex = nullptr; if (fOriginalKey.isValid()) { - tex = this->context()->textureProvider()->findAndRefTextureByUniqueKey(fOriginalKey); + tex = this->context()->resourceProvider()->findAndRefTextureByUniqueKey(fOriginalKey); if (tex) { return tex; } @@ -44,7 +44,7 @@ GrTexture* GrBitmapTextureMaker::refOriginalTexture(bool willBeMipped, tex = GrUploadBitmapToTexture(this->context(), fBitmap); } if (tex && fOriginalKey.isValid()) { - this->context()->textureProvider()->assignUniqueKeyToTexture(fOriginalKey, tex); + this->context()->resourceProvider()->assignUniqueKeyToTexture(fOriginalKey, tex); GrInstallBitmapUniqueKeyInvalidator(fOriginalKey, fBitmap.pixelRef()); } return tex; diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp index 091d7766ba..6716fdec77 100644 --- a/src/gpu/GrBlurUtils.cpp +++ b/src/gpu/GrBlurUtils.cpp @@ -12,11 +12,11 @@ #include "GrContextPriv.h" #include "GrFixedClip.h" #include "GrRenderTargetContextPriv.h" +#include "GrResourceProvider.h" #include "effects/GrSimpleTextureEffect.h" #include "GrStyle.h" #include "GrTexture.h" #include "GrTextureProxy.h" -#include "GrTextureProvider.h" #include "SkDraw.h" #include "SkGrPriv.h" #include "SkMaskFilter.h" @@ -207,7 +207,7 @@ static void draw_path_with_mask_filter(GrContext* context, return; } - if (maskFilter->directFilterMaskGPU(context->textureProvider(), + if (maskFilter->directFilterMaskGPU(context->resourceProvider(), renderTargetContext, std::move(paint), clip, diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp index c69f79e402..a0682f444d 100644 --- a/src/gpu/GrClipStackClip.cpp +++ b/src/gpu/GrClipStackClip.cpp @@ -413,11 +413,11 @@ static void add_invalidate_on_pop_message(const SkClipStack& stack, int32_t clip // MDB TODO (caching): this side-steps the issue of texture proxies cached by unique ID sk_sp<GrTextureProxy> GrClipStackClip::createAlphaClipMask(GrContext* context, const GrReducedClip& reducedClip) const { - GrTextureProvider* texProvider = context->textureProvider(); + GrResourceProvider* resourceProvider = context->resourceProvider(); GrUniqueKey key; create_clip_mask_key(reducedClip.elementsGenID(), reducedClip.ibounds(), &key); - sk_sp<GrTexture> texture(texProvider->findAndRefTextureByUniqueKey(key)); + sk_sp<GrTexture> texture(resourceProvider->findAndRefTextureByUniqueKey(key)); if (texture) { return GrSurfaceProxy::MakeWrapped(std::move(texture)); } @@ -441,12 +441,12 @@ sk_sp<GrTextureProxy> GrClipStackClip::createAlphaClipMask(GrContext* context, return nullptr; } - GrTexture* tex = result->instantiate(context->textureProvider()); + GrTexture* tex = result->instantiate(context->resourceProvider()); if (!tex) { return nullptr; } - context->textureProvider()->assignUniqueKeyToTexture(key, tex); + context->resourceProvider()->assignUniqueKeyToTexture(key, tex); add_invalidate_on_pop_message(*fStack, reducedClip.elementsGenID(), key); return result; @@ -459,7 +459,7 @@ sk_sp<GrTextureProxy> GrClipStackClip::createSoftwareClipMask( GrUniqueKey key; create_clip_mask_key(reducedClip.elementsGenID(), reducedClip.ibounds(), &key); - sk_sp<GrTexture> texture(context->textureProvider()->findAndRefTextureByUniqueKey(key)); + sk_sp<GrTexture> texture(context->resourceProvider()->findAndRefTextureByUniqueKey(key)); if (texture) { return GrSurfaceProxy::MakeWrapped(std::move(texture)); } @@ -517,12 +517,12 @@ sk_sp<GrTextureProxy> GrClipStackClip::createSoftwareClipMask( sk_sp<GrTextureProxy> result(helper.toTexture(context, SkBackingFit::kApprox)); - GrTexture* tex = result->instantiate(context->textureProvider()); + GrTexture* tex = result->instantiate(context->resourceProvider()); if (!tex) { return nullptr; } - context->textureProvider()->assignUniqueKeyToTexture(key, tex); + context->resourceProvider()->assignUniqueKeyToTexture(key, tex); add_invalidate_on_pop_message(*fStack, reducedClip.elementsGenID(), key); return result; } diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index cc7cba08ad..49b8c96c16 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -295,7 +295,7 @@ bool GrContext::writeSurfacePixels(GrSurface* surface, SkColorSpace* dstColorSpa sk_sp<GrTextureProxy> tempProxy; if (GrGpu::kNoDraw_DrawPreference != drawPreference) { - tempProxy = GrSurfaceProxy::MakeDeferred(this->textureProvider(), + tempProxy = GrSurfaceProxy::MakeDeferred(this->resourceProvider(), *this->caps(), tempDrawInfo.fTempSurfaceDesc, SkBackingFit::kApprox, @@ -329,7 +329,7 @@ bool GrContext::writeSurfacePixels(GrSurface* surface, SkColorSpace* dstColorSpa return false; } } - GrTexture* texture = tempProxy->instantiate(this->textureProvider()); + GrTexture* texture = tempProxy->instantiate(this->resourceProvider()); if (!texture) { return false; } @@ -621,7 +621,7 @@ sk_sp<GrSurfaceContext> GrContextPriv::makeDeferredSurfaceContext(const GrSurfac SkBackingFit fit, SkBudgeted isDstBudgeted) { - sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(fContext->textureProvider(), + sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(fContext->resourceProvider(), *fContext->caps(), dstDesc, fit, isDstBudgeted); if (!proxy) { @@ -636,7 +636,7 @@ sk_sp<GrSurfaceContext> GrContextPriv::makeBackendSurfaceContext(const GrBackend GrWrapOwnership ownership) { ASSERT_SINGLE_OWNER_PRIV - sk_sp<GrSurface> surface(fContext->textureProvider()->wrapBackendTexture(desc, ownership)); + sk_sp<GrSurface> surface(fContext->resourceProvider()->wrapBackendTexture(desc, ownership)); if (!surface) { return nullptr; } @@ -657,7 +657,7 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureRenderTargetContex ASSERT_SINGLE_OWNER_PRIV SkASSERT(desc.fFlags & kRenderTarget_GrBackendTextureFlag); - sk_sp<GrSurface> surface(fContext->textureProvider()->wrapBackendTexture(desc, ownership)); + sk_sp<GrSurface> surface(fContext->resourceProvider()->wrapBackendTexture(desc, ownership)); if (!surface) { return nullptr; } @@ -677,7 +677,7 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendRenderTargetRenderTargetC const SkSurfaceProps* surfaceProps) { ASSERT_SINGLE_OWNER_PRIV - sk_sp<GrRenderTarget> rt(fContext->textureProvider()->wrapBackendRenderTarget(desc)); + sk_sp<GrRenderTarget> rt(fContext->resourceProvider()->wrapBackendRenderTarget(desc)); if (!rt) { return nullptr; } @@ -786,9 +786,9 @@ sk_sp<GrRenderTargetContext> GrContext::makeRenderTargetContext(SkBackingFit fit sk_sp<GrTexture> tex; if (SkBackingFit::kExact == fit) { - tex.reset(this->textureProvider()->createTexture(desc, budgeted)); + tex.reset(this->resourceProvider()->createTexture(desc, budgeted)); } else { - tex.reset(this->textureProvider()->createApproxTexture(desc)); + tex.reset(this->resourceProvider()->createApproxTexture(desc, 0)); } if (!tex) { return nullptr; @@ -821,7 +821,7 @@ sk_sp<GrRenderTargetContext> GrContext::makeDeferredRenderTargetContext( desc.fConfig = config; desc.fSampleCnt = sampleCnt; - sk_sp<GrTextureProxy> rtp = GrSurfaceProxy::MakeDeferred(this->textureProvider(), + sk_sp<GrTextureProxy> rtp = GrSurfaceProxy::MakeDeferred(this->resourceProvider(), *this->caps(), desc, fit, budgeted); if (!rtp) { return nullptr; diff --git a/src/gpu/GrCoordTransform.cpp b/src/gpu/GrCoordTransform.cpp index 99b3a09fc9..95f30c02ee 100644 --- a/src/gpu/GrCoordTransform.cpp +++ b/src/gpu/GrCoordTransform.cpp @@ -77,7 +77,7 @@ void GrCoordTransform::reset(GrContext* context, const SkMatrix& m, // MDB TODO: just GrCaps is needed for this method // MDB TODO: once all the coord transforms take a proxy just store it here and // instantiate later - fTexture = proxy->instantiate(context->textureProvider()); + fTexture = proxy->instantiate(context->resourceProvider()); fNormalize = normalize; fReverseY = kBottomLeft_GrSurfaceOrigin == proxy->origin(); diff --git a/src/gpu/GrDrawOpAtlas.cpp b/src/gpu/GrDrawOpAtlas.cpp index e9fd356ca3..143bdd81fb 100644 --- a/src/gpu/GrDrawOpAtlas.cpp +++ b/src/gpu/GrDrawOpAtlas.cpp @@ -28,7 +28,7 @@ std::unique_ptr<GrDrawOpAtlas> GrDrawOpAtlas::Make(GrContext* ctx, GrPixelConfig // 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(ctx->textureProvider()->createApproxTexture(desc, kFlags)); + sk_sp<GrTexture> texture(ctx->resourceProvider()->createApproxTexture(desc, kFlags)); if (!texture) { return nullptr; } @@ -210,7 +210,7 @@ inline bool GrDrawOpAtlas::updatePlot(GrDrawOp::Target* target, AtlasID* id, Plo // MDB TODO: this is currently fine since the atlas' proxy is always pre-instantiated. // Once it is deferred more care must be taken upon instantiation failure. - GrTexture* texture = fProxy->instantiate(fContext->textureProvider()); + GrTexture* texture = fProxy->instantiate(fContext->resourceProvider()); if (!texture) { return false; } @@ -289,7 +289,7 @@ bool GrDrawOpAtlas::addToAtlas(AtlasID* id, GrDrawOp::Target* target, int width, sk_sp<Plot> plotsp(SkRef(newPlot.get())); // MDB TODO: this is currently fine since the atlas' proxy is always pre-instantiated. // Once it is deferred more care must be taken upon instantiation failure. - GrTexture* texture = fProxy->instantiate(fContext->textureProvider()); + GrTexture* texture = fProxy->instantiate(fContext->resourceProvider()); if (!texture) { return false; } diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp index 3a7110ef52..d670e16b73 100644 --- a/src/gpu/GrDrawingManager.cpp +++ b/src/gpu/GrDrawingManager.cpp @@ -219,7 +219,7 @@ GrPathRenderer* GrDrawingManager::getPathRenderer(const GrPathRenderer::CanDrawP if (!pr && allowSW) { if (!fSoftwarePathRenderer) { fSoftwarePathRenderer = - new GrSoftwarePathRenderer(fContext->textureProvider(), + new GrSoftwarePathRenderer(fContext->resourceProvider(), fOptionsForPathRendererChain.fAllowPathMaskCaching); } if (fSoftwarePathRenderer->canDrawPath(args)) { @@ -256,7 +256,7 @@ sk_sp<GrRenderTargetContext> GrDrawingManager::makeRenderTargetContext( if (useDIF && fContext->caps()->shaderCaps()->pathRenderingSupport() && rtp->isStencilBufferMultisampled()) { // TODO: defer stencil buffer attachment for PathRenderingDrawContext - sk_sp<GrRenderTarget> rt(sk_ref_sp(rtp->instantiate(fContext->textureProvider()))); + sk_sp<GrRenderTarget> rt(sk_ref_sp(rtp->instantiate(fContext->resourceProvider()))); if (!rt) { return nullptr; } diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index 201b22c8ab..3abe8f8194 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -122,17 +122,17 @@ public: } /** - * Implements GrTextureProvider::wrapBackendTexture + * Implements GrResourceProvider::wrapBackendTexture */ sk_sp<GrTexture> wrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership); /** - * Implements GrTextureProvider::wrapBackendRenderTarget + * Implements GrResourceProvider::wrapBackendRenderTarget */ sk_sp<GrRenderTarget> wrapBackendRenderTarget(const GrBackendRenderTargetDesc&,GrWrapOwnership); /** - * Implements GrTextureProvider::wrapBackendTextureAsRenderTarget + * Implements GrResourceProvider::wrapBackendTextureAsRenderTarget */ sk_sp<GrRenderTarget> wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&); @@ -480,14 +480,14 @@ public: // Determines whether a texture will need to be rescaled in order to be used with the // GrSamplerParams. This variation is called when the caller will create a new texture using the - // texture provider from a non-texture src (cpu-backed image, ...). + // resource provider from a non-texture src (cpu-backed image, ...). bool makeCopyForTextureParams(int width, int height, const GrSamplerParams&, GrTextureProducer::CopyParams*, SkScalar scaleAdjust[2]) const; // Like the above but this variation should be called when the caller is not creating the // original texture but rather was handed the original texture. It adds additional checks // relevant to original textures that were created external to Skia via - // GrTextureProvider::wrap methods. + // GrResourceProvider::wrap methods. bool makeCopyForTextureParams(GrTexture* texture, const GrSamplerParams& params, GrTextureProducer::CopyParams* copyParams, SkScalar scaleAdjust[2]) const { diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp index 8214d2c416..2365c21229 100644 --- a/src/gpu/GrProcessor.cpp +++ b/src/gpu/GrProcessor.cpp @@ -208,18 +208,18 @@ GrProcessor::TextureSampler::TextureSampler(GrTexture* texture, this->reset(texture, filterMode, tileXAndY, visibility); } -GrProcessor::TextureSampler::TextureSampler(GrTextureProvider* texProvider, +GrProcessor::TextureSampler::TextureSampler(GrResourceProvider* resourceProvider, sk_sp<GrTextureProxy> proxy, const GrSamplerParams& params) { - this->reset(texProvider, std::move(proxy), params); + this->reset(resourceProvider, std::move(proxy), params); } -GrProcessor::TextureSampler::TextureSampler(GrTextureProvider* texProvider, +GrProcessor::TextureSampler::TextureSampler(GrResourceProvider* resourceProvider, sk_sp<GrTextureProxy> proxy, GrSamplerParams::FilterMode filterMode, SkShader::TileMode tileXAndY, GrShaderFlags visibility) { - this->reset(texProvider, std::move(proxy), filterMode, tileXAndY, visibility); + this->reset(resourceProvider, std::move(proxy), filterMode, tileXAndY, visibility); } void GrProcessor::TextureSampler::reset(GrTexture* texture, @@ -243,13 +243,13 @@ void GrProcessor::TextureSampler::reset(GrTexture* texture, fVisibility = visibility; } -void GrProcessor::TextureSampler::reset(GrTextureProvider* texProvider, +void GrProcessor::TextureSampler::reset(GrResourceProvider* resourceProvider, sk_sp<GrTextureProxy> proxy, const GrSamplerParams& params, GrShaderFlags visibility) { // For now, end the deferral at this time. Once all the TextureSamplers are swapped over // to taking a GrSurfaceProxy just use the IORefs on the proxy - GrTexture* texture = proxy->instantiate(texProvider); + GrTexture* texture = proxy->instantiate(resourceProvider); SkASSERT(texture); fTexture.set(SkRef(texture), kRead_GrIOType); fParams = params; @@ -257,14 +257,14 @@ void GrProcessor::TextureSampler::reset(GrTextureProvider* texProvider, fVisibility = visibility; } -void GrProcessor::TextureSampler::reset(GrTextureProvider* texProvider, +void GrProcessor::TextureSampler::reset(GrResourceProvider* resourceProvider, sk_sp<GrTextureProxy> proxy, GrSamplerParams::FilterMode filterMode, SkShader::TileMode tileXAndY, GrShaderFlags visibility) { // For now, end the deferral at this time. Once all the TextureSamplers are swapped over // to taking a GrSurfaceProxy just use the IORefs on the proxy - GrTexture* texture = proxy->instantiate(texProvider); + GrTexture* texture = proxy->instantiate(resourceProvider); SkASSERT(texture); fTexture.set(SkRef(texture), kRead_GrIOType); filterMode = SkTMin(filterMode, texture->texturePriv().highestFilterMode()); diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index 8b6de51e64..1ddf8df511 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -112,7 +112,7 @@ GrRenderTargetContext::~GrRenderTargetContext() { } GrRenderTarget* GrRenderTargetContext::instantiate() { - return fRenderTargetProxy->instantiate(fContext->textureProvider()); + return fRenderTargetProxy->instantiate(fContext->resourceProvider()); } GrTextureProxy* GrRenderTargetContext::asTextureProxy() { @@ -144,14 +144,14 @@ bool GrRenderTargetContext::onCopy(GrSurfaceProxy* srcProxy, GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrRenderTargetContext::copy"); // TODO: defer instantiation until flush time - sk_sp<GrSurface> src(sk_ref_sp(srcProxy->instantiate(fContext->textureProvider()))); + sk_sp<GrSurface> src(sk_ref_sp(srcProxy->instantiate(fContext->resourceProvider()))); if (!src) { return false; } // TODO: This needs to be fixed up since it ends the deferral of the GrRenderTarget. sk_sp<GrRenderTarget> rt( - sk_ref_sp(fRenderTargetProxy->instantiate(fContext->textureProvider()))); + sk_ref_sp(fRenderTargetProxy->instantiate(fContext->resourceProvider()))); if (!rt) { return false; } @@ -175,7 +175,7 @@ bool GrRenderTargetContext::onReadPixels(const SkImageInfo& dstInfo, void* dstBu // Deferral of the VRAM resources must end in this instance anyway sk_sp<GrRenderTarget> rt( - sk_ref_sp(fRenderTargetProxy->instantiate(fContext->textureProvider()))); + sk_ref_sp(fRenderTargetProxy->instantiate(fContext->resourceProvider()))); if (!rt) { return false; } @@ -198,7 +198,7 @@ bool GrRenderTargetContext::onWritePixels(const SkImageInfo& srcInfo, const void // Deferral of the VRAM resources must end in this instance anyway sk_sp<GrRenderTarget> rt( - sk_ref_sp(fRenderTargetProxy->instantiate(fContext->textureProvider()))); + sk_ref_sp(fRenderTargetProxy->instantiate(fContext->resourceProvider()))); if (!rt) { return false; } @@ -261,7 +261,7 @@ void GrRenderTargetContext::discard() { // TODO: This needs to be fixed up since it ends the deferral of the GrRenderTarget. sk_sp<GrRenderTarget> rt( - sk_ref_sp(fRenderTargetProxy->instantiate(fContext->textureProvider()))); + sk_ref_sp(fRenderTargetProxy->instantiate(fContext->resourceProvider()))); if (!rt) { return; } @@ -1313,7 +1313,7 @@ void GrRenderTargetContext::prepareForExternalIO() { // Deferral of the VRAM resources must end in this instance anyway sk_sp<GrRenderTarget> rt( - sk_ref_sp(fRenderTargetProxy->instantiate(fContext->textureProvider()))); + sk_ref_sp(fRenderTargetProxy->instantiate(fContext->resourceProvider()))); if (!rt) { return; } diff --git a/src/gpu/GrRenderTargetProxy.cpp b/src/gpu/GrRenderTargetProxy.cpp index 34d67be3ef..44f23d484b 100644 --- a/src/gpu/GrRenderTargetProxy.cpp +++ b/src/gpu/GrRenderTargetProxy.cpp @@ -11,7 +11,7 @@ #include "GrGpuResourcePriv.h" #include "GrRenderTargetOpList.h" #include "GrRenderTargetPriv.h" -#include "GrTextureProvider.h" +#include "GrResourceProvider.h" #include "GrTextureRenderTargetProxy.h" // Deferred version @@ -43,10 +43,10 @@ int GrRenderTargetProxy::maxWindowRectangles(const GrCaps& caps) const { : 0; } -GrRenderTarget* GrRenderTargetProxy::instantiate(GrTextureProvider* texProvider) { +GrRenderTarget* GrRenderTargetProxy::instantiate(GrResourceProvider* resourceProvider) { SkASSERT(fDesc.fFlags & GrSurfaceFlags::kRenderTarget_GrSurfaceFlag); - GrSurface* surf = INHERITED::instantiate(texProvider); + GrSurface* surf = INHERITED::instantiate(resourceProvider); if (!surf || !surf->asRenderTarget()) { return nullptr; } diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp index 272c6a6ee7..636f16c0c1 100644 --- a/src/gpu/GrResourceProvider.cpp +++ b/src/gpu/GrResourceProvider.cpp @@ -16,16 +16,198 @@ #include "GrResourceCache.h" #include "GrResourceKey.h" #include "GrStencilAttachment.h" +#include "GrTexturePriv.h" +#include "../private/GrSingleOwner.h" #include "SkMathPriv.h" GR_DECLARE_STATIC_UNIQUE_KEY(gQuadIndexBufferKey); +const int GrResourceProvider::kMinScratchTextureSize = 16; + +#define ASSERT_SINGLE_OWNER \ + SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);) + GrResourceProvider::GrResourceProvider(GrGpu* gpu, GrResourceCache* cache, GrSingleOwner* owner) - : INHERITED(gpu, cache, owner) { + : fCache(cache) + , fGpu(gpu) +#ifdef SK_DEBUG + , fSingleOwner(owner) +#endif + { GR_DEFINE_STATIC_UNIQUE_KEY(gQuadIndexBufferKey); fQuadIndexBufferKey = gQuadIndexBufferKey; } + +GrTexture* GrResourceProvider::createMipMappedTexture(const GrSurfaceDesc& desc, + SkBudgeted budgeted, const GrMipLevel* texels, + int mipLevelCount, uint32_t flags) { + ASSERT_SINGLE_OWNER + + if (this->isAbandoned()) { + return nullptr; + } + if (mipLevelCount && !texels) { + return nullptr; + } + for (int i = 0; i < mipLevelCount; ++i) { + if (!texels[i].fPixels) { + return nullptr; + } + } + if (mipLevelCount > 1 && GrPixelConfigIsSint(desc.fConfig)) { + return nullptr; + } + if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) && + !fGpu->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { + return nullptr; + } + if (!GrPixelConfigIsCompressed(desc.fConfig)) { + if (mipLevelCount < 2) { + flags |= kExact_Flag | kNoCreate_Flag; + if (GrTexture* texture = this->refScratchTexture(desc, flags)) { + if (!mipLevelCount || + texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, + texels[0].fPixels, texels[0].fRowBytes)) { + if (SkBudgeted::kNo == budgeted) { + texture->resourcePriv().makeUnbudgeted(); + } + return texture; + } + texture->unref(); + } + } + } + + SkTArray<GrMipLevel> texelsShallowCopy(mipLevelCount); + for (int i = 0; i < mipLevelCount; ++i) { + texelsShallowCopy.push_back(texels[i]); + } + return fGpu->createTexture(desc, budgeted, texelsShallowCopy); +} + +GrTexture* GrResourceProvider::createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, + const void* srcData, size_t rowBytes, uint32_t flags) { + GrMipLevel tempTexels; + GrMipLevel* texels = nullptr; + int levelCount = 0; + if (srcData) { + tempTexels.fPixels = srcData; + tempTexels.fRowBytes = rowBytes; + texels = &tempTexels; + levelCount = 1; + } + return this->createMipMappedTexture(desc, budgeted, texels, levelCount, flags); +} + +GrTexture* GrResourceProvider::createApproxTexture(const GrSurfaceDesc& desc, uint32_t flags) { + ASSERT_SINGLE_OWNER + SkASSERT(0 == flags || kNoPendingIO_Flag == flags); + return this->internalCreateApproxTexture(desc, flags); +} + +GrTexture* GrResourceProvider::internalCreateApproxTexture(const GrSurfaceDesc& desc, + uint32_t scratchFlags) { + ASSERT_SINGLE_OWNER + if (this->isAbandoned()) { + return nullptr; + } + // Currently we don't recycle compressed textures as scratch. + if (GrPixelConfigIsCompressed(desc.fConfig)) { + return nullptr; + } else { + return this->refScratchTexture(desc, scratchFlags); + } +} + +GrTexture* GrResourceProvider::refScratchTexture(const GrSurfaceDesc& inDesc, + uint32_t flags) { + ASSERT_SINGLE_OWNER + SkASSERT(!this->isAbandoned()); + SkASSERT(!GrPixelConfigIsCompressed(inDesc.fConfig)); + + SkTCopyOnFirstWrite<GrSurfaceDesc> desc(inDesc); + + if (fGpu->caps()->reuseScratchTextures() || (desc->fFlags & kRenderTarget_GrSurfaceFlag)) { + if (!(kExact_Flag & flags)) { + // bin by pow2 with a reasonable min + GrSurfaceDesc* wdesc = desc.writable(); + wdesc->fWidth = SkTMax(kMinScratchTextureSize, GrNextPow2(desc->fWidth)); + wdesc->fHeight = SkTMax(kMinScratchTextureSize, GrNextPow2(desc->fHeight)); + } + + GrScratchKey key; + GrTexturePriv::ComputeScratchKey(*desc, &key); + uint32_t scratchFlags = 0; + if (kNoPendingIO_Flag & flags) { + scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag; + } else if (!(desc->fFlags & kRenderTarget_GrSurfaceFlag)) { + // If it is not a render target then it will most likely be populated by + // writePixels() which will trigger a flush if the texture has pending IO. + scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag; + } + GrGpuResource* resource = fCache->findAndRefScratchResource(key, + GrSurface::WorstCaseSize(*desc), + scratchFlags); + if (resource) { + GrSurface* surface = static_cast<GrSurface*>(resource); + GrRenderTarget* rt = surface->asRenderTarget(); + if (rt && fGpu->caps()->discardRenderTargetSupport()) { + rt->discard(); + } + return surface->asTexture(); + } + } + + if (!(kNoCreate_Flag & flags)) { + return fGpu->createTexture(*desc, SkBudgeted::kYes); + } + + return nullptr; +} + +sk_sp<GrTexture> GrResourceProvider::wrapBackendTexture(const GrBackendTextureDesc& desc, + GrWrapOwnership ownership) { + ASSERT_SINGLE_OWNER + if (this->isAbandoned()) { + return nullptr; + } + return fGpu->wrapBackendTexture(desc, ownership); +} + +sk_sp<GrRenderTarget> GrResourceProvider::wrapBackendRenderTarget( + const GrBackendRenderTargetDesc& desc) +{ + ASSERT_SINGLE_OWNER + return this->isAbandoned() ? nullptr + : fGpu->wrapBackendRenderTarget(desc, kBorrow_GrWrapOwnership); +} + +void GrResourceProvider::assignUniqueKeyToResource(const GrUniqueKey& key, + GrGpuResource* resource) { + ASSERT_SINGLE_OWNER + if (this->isAbandoned() || !resource) { + return; + } + resource->resourcePriv().setUniqueKey(key); +} + +GrGpuResource* GrResourceProvider::findAndRefResourceByUniqueKey(const GrUniqueKey& key) { + ASSERT_SINGLE_OWNER + return this->isAbandoned() ? nullptr : fCache->findAndRefUniqueResource(key); +} + +GrTexture* GrResourceProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& key) { + ASSERT_SINGLE_OWNER + GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key); + if (resource) { + GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture(); + SkASSERT(texture); + return texture; + } + return NULL; +} + const GrBuffer* GrResourceProvider::createInstancedIndexBuffer(const uint16_t* pattern, int patternSize, int reps, diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h index c0d1a50230..5ecaac3473 100644 --- a/src/gpu/GrResourceProvider.h +++ b/src/gpu/GrResourceProvider.h @@ -9,12 +9,9 @@ #define GrResourceProvider_DEFINED #include "GrBuffer.h" -#include "GrDrawOpAtlas.h" #include "GrGpu.h" #include "GrPathRange.h" -#include "GrTextureProvider.h" -class GrDrawOpAtlas; class GrPath; class GrRenderTarget; class GrSingleOwner; @@ -25,15 +22,12 @@ class SkPath; class SkTypeface; /** - * An extension of the texture provider for arbitrary resource types. This class is intended for - * use within the Gr code base, not by clients or extensions (e.g. third party GrProcessor - * derivatives). + * A factory for arbitrary resource types. This class is intended for use within the Gr code base. * - * This currently inherits from GrTextureProvider non-publically to force callers to provider - * make a flags (pendingIO) decision and not use the GrTP methods that don't take flags. This - * can be relaxed once https://bug.skia.org/4156 is fixed. + * Some members force callers to make a flags (pendingIO) decision. This can be relaxed once + * https://bug.skia.org/4156 is fixed. */ -class GrResourceProvider : protected GrTextureProvider { +class GrResourceProvider { public: GrResourceProvider(GrGpu* gpu, GrResourceCache* cache, GrSingleOwner* owner); @@ -41,6 +35,85 @@ public: return static_cast<T*>(this->findAndRefResourceByUniqueKey(key)); } + /////////////////////////////////////////////////////////////////////////// + // Textures + + /** + * Creates a new texture in the resource cache and returns it. The caller owns a + * ref on the returned texture which must be balanced by a call to unref. + * + * @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 + */ + GrTexture* createMipMappedTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, + const GrMipLevel* texels, int mipLevelCount, + uint32_t flags = 0); + + /** + * This function is a shim which creates a SkTArray<GrMipLevel> of size 1. + * It then calls createTexture with that SkTArray. + * + * @param srcData Pointer to the pixel values (optional). + * @param rowBytes The number of bytes between rows of the texture. Zero + * implies tightly packed rows. For compressed pixel configs, this + * field is ignored. + */ + GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, const void* srcData, + size_t rowBytes, uint32_t flags = 0); + + /** Shortcut for creating a texture with no initial data to upload. */ + GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, uint32_t flags = 0) { + return this->createTexture(desc, budgeted, nullptr, 0, flags); + } + + /** Assigns a unique key to the texture. The texture will be findable via this key using + findTextureByUniqueKey(). If an existing texture has this key, it's key will be removed. */ + void assignUniqueKeyToTexture(const GrUniqueKey& key, GrTexture* texture) { + SkASSERT(key.isValid()); + this->assignUniqueKeyToResource(key, texture); + } + + /** Finds a texture by unique key. If the texture is found it is ref'ed and returned. */ + GrTexture* findAndRefTextureByUniqueKey(const GrUniqueKey& key); + + /** + * Finds a texture that approximately matches the descriptor. Will be at least as large in width + * and height as desc specifies. If desc specifies that the texture should be a render target + * then result will be a render target. Format and sample count will always match the request. + * The contents of the texture are undefined. The caller owns a ref on the returned texture and + * must balance with a call to unref. + */ + GrTexture* createApproxTexture(const GrSurfaceDesc&, uint32_t flags); + + /////////////////////////////////////////////////////////////////////////// + // Wrapped Backend Surfaces + + /** + * Wraps an existing texture with a GrTexture object. + * + * OpenGL: if the object is a texture Gr may change its GL texture params + * when it is drawn. + * + * @return GrTexture object or NULL on failure. + */ + sk_sp<GrTexture> wrapBackendTexture(const GrBackendTextureDesc& desc, + GrWrapOwnership = kBorrow_GrWrapOwnership); + + /** + * Wraps an existing render target with a GrRenderTarget object. It is + * similar to wrapBackendTexture but can be used to draw into surfaces + * that are not also textures (e.g. FBO 0 in OpenGL, or an MSAA buffer that + * the client will resolve to a texture). Currently wrapped render targets + * always use the kBorrow_GrWrapOwnership semantics. + * + * @return GrRenderTarget object or NULL on failure. + */ + sk_sp<GrRenderTarget> wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc); + + static const int kMinScratchTextureSize; + /** * Either finds and refs, or creates an index buffer for instanced drawing with a specific * pattern if the index buffer is not found. If the return is non-null, the caller owns @@ -89,26 +162,24 @@ public: GrPathRange* createGlyphs(const SkTypeface*, const SkScalerContextEffects&, const SkDescriptor*, const GrStyle&); - using GrTextureProvider::createTexture; - using GrTextureProvider::assignUniqueKeyToResource; - using GrTextureProvider::findAndRefResourceByUniqueKey; - using GrTextureProvider::findAndRefTextureByUniqueKey; - using GrTextureProvider::abandon; - - /** These flags alias/extend GrTextureProvider::ScratchTextureFlags */ + /** These flags govern which scratch resources we are allowed to return */ enum Flags { + kExact_Flag = 0x1, + /** If the caller intends to do direct reads/writes to/from the CPU then this flag must be * set when accessing resources during a GrOpList flush. This includes the execution of * GrOp objects. The reason is that these memory operations are done immediately and * will occur out of order WRT the operations being flushed. * Make this automatic: https://bug.skia.org/4156 */ - kNoPendingIO_Flag = GrTextureProvider::kNoPendingIO_ScratchTextureFlag, + kNoPendingIO_Flag = 0x2, + + kNoCreate_Flag = 0x4, /** Normally the caps may indicate a preference for client-side buffers. Set this flag when * creating a buffer to guarantee it resides in GPU memory. */ - kRequireGpuMemory_Flag = GrTextureProvider::kLastScratchTextureFlag << 1, + kRequireGpuMemory_Flag = 0x8, }; /** @@ -125,10 +196,6 @@ public: GrBuffer* createBuffer(size_t size, GrBufferType intendedType, GrAccessPattern, uint32_t flags, const void* data = nullptr); - GrTexture* createApproxTexture(const GrSurfaceDesc& desc, uint32_t flags) { - SkASSERT(0 == flags || kNoPendingIO_Flag == flags); - return this->internalCreateApproxTexture(desc, flags); - } /** * If passed in render target already has a stencil buffer, return it. Otherwise attempt to @@ -136,9 +203,6 @@ public: */ GrStencilAttachment* attachStencilAttachment(GrRenderTarget* rt); - GrContext* context() { return this->gpu()->getContext(); } - const GrCaps* caps() { return this->gpu()->caps(); } - /** * Wraps an existing texture with a GrRenderTarget object. This is useful when the provided * texture has a format that cannot be textured from by Skia, but we want to raster to it. @@ -150,7 +214,40 @@ public: */ sk_sp<GrRenderTarget> wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc); + /** + * Assigns a unique key to a resource. If the key is associated with another resource that + * association is removed and replaced by this resource. + */ + void assignUniqueKeyToResource(const GrUniqueKey&, GrGpuResource*); + + /** + * Finds a resource in the cache, based on the specified key. This is intended for use in + * conjunction with addResourceToCache(). The return value will be NULL if not found. The + * caller must balance with a call to unref(). + */ + GrGpuResource* findAndRefResourceByUniqueKey(const GrUniqueKey&); + + void abandon() { + fCache = NULL; + fGpu = NULL; + } + private: + GrTexture* internalCreateApproxTexture(const GrSurfaceDesc& desc, uint32_t scratchTextureFlags); + + GrTexture* refScratchTexture(const GrSurfaceDesc&, uint32_t scratchTextureFlags); + + GrResourceCache* cache() { return fCache; } + const GrResourceCache* cache() const { return fCache; } + + GrGpu* gpu() { return fGpu; } + const GrGpu* gpu() const { return fGpu; } + + bool isAbandoned() const { + SkASSERT(SkToBool(fGpu) == SkToBool(fCache)); + return !SkToBool(fCache); + } + const GrBuffer* createInstancedIndexBuffer(const uint16_t* pattern, int patternSize, int reps, @@ -159,9 +256,12 @@ private: const GrBuffer* createQuadIndexBuffer(); + GrResourceCache* fCache; + GrGpu* fGpu; GrUniqueKey fQuadIndexBufferKey; - typedef GrTextureProvider INHERITED; + // In debug builds we guard against improper thread handling + SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;) }; #endif diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp index 073aec4fea..f7e518be97 100644 --- a/src/gpu/GrSWMaskHelper.cpp +++ b/src/gpu/GrSWMaskHelper.cpp @@ -151,7 +151,7 @@ sk_sp<GrTexture> GrSWMaskHelper::DrawShapeMaskToTexture(GrContext* context, return nullptr; } - return sk_ref_sp(tProxy->instantiate(context->textureProvider())); + return sk_ref_sp(tProxy->instantiate(context->resourceProvider())); } void GrSWMaskHelper::DrawToTargetWithShapeMask(GrTexture* texture, diff --git a/src/gpu/GrSWMaskHelper.h b/src/gpu/GrSWMaskHelper.h index 89d8842aa7..4c744fd08f 100644 --- a/src/gpu/GrSWMaskHelper.h +++ b/src/gpu/GrSWMaskHelper.h @@ -10,7 +10,6 @@ #include "GrColor.h" #include "GrRenderTargetContext.h" -#include "GrTextureProvider.h" #include "SkAutoPixmapStorage.h" #include "SkBitmap.h" #include "SkDraw.h" @@ -22,7 +21,6 @@ class GrClip; class GrPaint; class GrShape; -class GrTextureProvider; class GrStyle; class GrTexture; struct GrUserStencilSettings; diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp index b51ce630d0..eb5495ca08 100644 --- a/src/gpu/GrSoftwarePathRenderer.cpp +++ b/src/gpu/GrSoftwarePathRenderer.cpp @@ -10,16 +10,16 @@ #include "GrClip.h" #include "GrGpuResourcePriv.h" #include "GrPipelineBuilder.h" +#include "GrResourceProvider.h" #include "GrSWMaskHelper.h" #include "GrSurfaceContextPriv.h" -#include "GrTextureProvider.h" #include "ops/GrRectOpFactory.h" //////////////////////////////////////////////////////////////////////////////// bool GrSoftwarePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { // Pass on any style that applies. The caller will apply the style if a suitable renderer is // not found and try again with the new GrShape. - return !args.fShape->style().applies() && SkToBool(fTexProvider) && + return !args.fShape->style().applies() && SkToBool(fResourceProvider) && (args.fAAType == GrAAType::kCoverage || args.fAAType == GrAAType::kNone); } @@ -129,7 +129,7 @@ void GrSoftwarePathRenderer::DrawAroundInvPath(GrRenderTargetContext* renderTarg bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) { GR_AUDIT_TRAIL_AUTO_FRAME(args.fRenderTargetContext->auditTrail(), "GrSoftwarePathRenderer::onDrawPath"); - if (!fTexProvider) { + if (!fResourceProvider) { return false; } @@ -206,7 +206,7 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) { sk_sp<GrTexture> texture; if (useCache) { - texture.reset(fTexProvider->findAndRefTextureByUniqueKey(maskKey)); + texture.reset(fResourceProvider->findAndRefTextureByUniqueKey(maskKey)); } if (!texture) { SkBackingFit fit = useCache ? SkBackingFit::kExact : SkBackingFit::kApprox; @@ -219,7 +219,7 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) { return false; } if (useCache) { - fTexProvider->assignUniqueKeyToTexture(maskKey, texture.get()); + fResourceProvider->assignUniqueKeyToTexture(maskKey, texture.get()); } } if (inverseFilled) { diff --git a/src/gpu/GrSoftwarePathRenderer.h b/src/gpu/GrSoftwarePathRenderer.h index 7dec4be06e..c8d2f8b8d8 100644 --- a/src/gpu/GrSoftwarePathRenderer.h +++ b/src/gpu/GrSoftwarePathRenderer.h @@ -10,7 +10,7 @@ #include "GrPathRenderer.h" -class GrTextureProvider; +class GrResourceProvider; /** * This class uses the software side to render a path to an SkBitmap and @@ -18,8 +18,8 @@ class GrTextureProvider; */ class GrSoftwarePathRenderer : public GrPathRenderer { public: - GrSoftwarePathRenderer(GrTextureProvider* texProvider, bool allowCaching) - : fTexProvider(texProvider) + GrSoftwarePathRenderer(GrResourceProvider* resourceProvider, bool allowCaching) + : fResourceProvider(resourceProvider) , fAllowCaching(allowCaching) {} private: static void DrawNonAARect(GrRenderTargetContext* renderTargetContext, @@ -46,7 +46,7 @@ private: bool onDrawPath(const DrawPathArgs&) override; private: - GrTextureProvider* fTexProvider; + GrResourceProvider* fResourceProvider; bool fAllowCaching; typedef GrPathRenderer INHERITED; diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp index b8fc56dd0b..f95c312b1b 100644 --- a/src/gpu/GrSurfaceProxy.cpp +++ b/src/gpu/GrSurfaceProxy.cpp @@ -12,8 +12,8 @@ #include "GrContextPriv.h" #include "GrGpuResourcePriv.h" #include "GrOpList.h" +#include "GrResourceProvider.h" #include "GrSurfaceContext.h" -#include "GrTextureProvider.h" #include "GrTextureRenderTargetProxy.h" #include "SkMathPriv.h" @@ -36,15 +36,15 @@ GrSurfaceProxy::~GrSurfaceProxy() { SkSafeUnref(fLastOpList); } -GrSurface* GrSurfaceProxy::instantiate(GrTextureProvider* texProvider) { +GrSurface* GrSurfaceProxy::instantiate(GrResourceProvider* resourceProvider) { if (fTarget) { return fTarget; } if (SkBackingFit::kApprox == fFit) { - fTarget = texProvider->createApproxTexture(fDesc, fFlags); + fTarget = resourceProvider->createApproxTexture(fDesc, fFlags); } else { - fTarget = texProvider->createTexture(fDesc, fBudgeted, fFlags); + fTarget = resourceProvider->createTexture(fDesc, fBudgeted, fFlags); } if (!fTarget) { return nullptr; @@ -71,7 +71,7 @@ int GrSurfaceProxy::worstCaseWidth(const GrCaps& caps) const { } if (caps.reuseScratchTextures() || fDesc.fFlags & kRenderTarget_GrSurfaceFlag) { - return SkTMax(GrTextureProvider::kMinScratchTextureSize, GrNextPow2(fDesc.fWidth)); + return SkTMax(GrResourceProvider::kMinScratchTextureSize, GrNextPow2(fDesc.fWidth)); } return fDesc.fWidth; @@ -87,7 +87,7 @@ int GrSurfaceProxy::worstCaseHeight(const GrCaps& caps) const { } if (caps.reuseScratchTextures() || fDesc.fFlags & kRenderTarget_GrSurfaceFlag) { - return SkTMax(GrTextureProvider::kMinScratchTextureSize, GrNextPow2(fDesc.fHeight)); + return SkTMax(GrResourceProvider::kMinScratchTextureSize, GrNextPow2(fDesc.fHeight)); } return fDesc.fHeight; @@ -146,7 +146,7 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrTexture> tex) { #include "GrResourceProvider.h" -sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(GrTextureProvider* texProvider, +sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(GrResourceProvider* resourceProvider, const GrCaps& caps, const GrSurfaceDesc& desc, SkBackingFit fit, @@ -199,9 +199,9 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(GrTextureProvider* texProvide sk_sp<GrTexture> tex; if (SkBackingFit::kApprox == fit) { - tex.reset(texProvider->createApproxTexture(copyDesc)); + tex.reset(resourceProvider->createApproxTexture(copyDesc, 0)); } else { - tex.reset(texProvider->createTexture(copyDesc, budgeted)); + tex.reset(resourceProvider->createTexture(copyDesc, budgeted)); } if (!tex) { @@ -222,24 +222,25 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(GrTextureProvider* texProvide } sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(const GrCaps& caps, - GrTextureProvider* texProvider, + GrResourceProvider* resourceProvider, const GrSurfaceDesc& desc, SkBudgeted budgeted, const void* srcData, size_t rowBytes) { if (srcData) { // If we have srcData, for now, we create a wrapped GrTextureProxy - sk_sp<GrTexture> tex(texProvider->createTexture(desc, budgeted, srcData, rowBytes)); + sk_sp<GrTexture> tex(resourceProvider->createTexture(desc, budgeted, srcData, rowBytes)); return GrSurfaceProxy::MakeWrapped(std::move(tex)); } - return GrSurfaceProxy::MakeDeferred(texProvider, caps, desc, SkBackingFit::kExact, budgeted); + return GrSurfaceProxy::MakeDeferred(resourceProvider, caps, desc, SkBackingFit::kExact, + budgeted); } sk_sp<GrSurfaceProxy> GrSurfaceProxy::MakeWrappedBackend(GrContext* context, GrBackendTextureDesc& desc, GrWrapOwnership ownership) { - sk_sp<GrTexture> tex(context->textureProvider()->wrapBackendTexture(desc, ownership)); + sk_sp<GrTexture> tex(context->resourceProvider()->wrapBackendTexture(desc, ownership)); return GrSurfaceProxy::MakeWrapped(std::move(tex)); } diff --git a/src/gpu/GrTextureAdjuster.cpp b/src/gpu/GrTextureAdjuster.cpp index 27f8d6db9a..63d9a11be7 100644 --- a/src/gpu/GrTextureAdjuster.cpp +++ b/src/gpu/GrTextureAdjuster.cpp @@ -10,8 +10,8 @@ #include "GrContext.h" #include "GrGpu.h" #include "GrGpuResourcePriv.h" +#include "GrResourceProvider.h" #include "GrTexture.h" -#include "GrTextureProvider.h" #include "SkGrPriv.h" GrTextureAdjuster::GrTextureAdjuster(GrTexture* original, SkAlphaType alphaType, @@ -49,7 +49,7 @@ GrTexture* GrTextureAdjuster::refCopy(const CopyParams& copyParams) { GrUniqueKey key; this->makeCopyKey(copyParams, &key, nullptr); if (key.isValid()) { - GrTexture* cachedCopy = context->textureProvider()->findAndRefTextureByUniqueKey(key); + GrTexture* cachedCopy = context->resourceProvider()->findAndRefTextureByUniqueKey(key); if (cachedCopy) { return cachedCopy; } @@ -57,7 +57,7 @@ GrTexture* GrTextureAdjuster::refCopy(const CopyParams& copyParams) { GrTexture* copy = CopyOnGpu(texture, contentArea, copyParams); if (copy) { if (key.isValid()) { - context->textureProvider()->assignUniqueKeyToTexture(key, copy); + context->resourceProvider()->assignUniqueKeyToTexture(key, copy); this->didCacheCopy(key); } } diff --git a/src/gpu/GrTextureContext.cpp b/src/gpu/GrTextureContext.cpp index 75c9e308ef..ffcddbc289 100644 --- a/src/gpu/GrTextureContext.cpp +++ b/src/gpu/GrTextureContext.cpp @@ -77,7 +77,7 @@ bool GrTextureContext::onCopy(GrSurfaceProxy* srcProxy, GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrTextureContext::copy"); // TODO: defer instantiation until flush time - sk_sp<GrSurface> src(sk_ref_sp(srcProxy->instantiate(fContext->textureProvider()))); + sk_sp<GrSurface> src(sk_ref_sp(srcProxy->instantiate(fContext->resourceProvider()))); if (!src) { return false; } @@ -89,7 +89,7 @@ bool GrTextureContext::onCopy(GrSurfaceProxy* srcProxy, #endif // TODO: this needs to be fixed up since it ends the deferrable of the GrTexture - sk_sp<GrTexture> tex(sk_ref_sp(fTextureProxy->instantiate(fContext->textureProvider()))); + sk_sp<GrTexture> tex(sk_ref_sp(fTextureProxy->instantiate(fContext->resourceProvider()))); if (!tex) { return false; } @@ -122,7 +122,7 @@ bool GrTextureContext::onReadPixels(const SkImageInfo& dstInfo, void* dstBuffer, } // Deferral of the VRAM resources must end in this instance anyway - sk_sp<GrTexture> tex(sk_ref_sp(fTextureProxy->instantiate(fContext->textureProvider()))); + sk_sp<GrTexture> tex(sk_ref_sp(fTextureProxy->instantiate(fContext->resourceProvider()))); if (!tex) { return false; } @@ -145,7 +145,7 @@ bool GrTextureContext::onWritePixels(const SkImageInfo& srcInfo, const void* src } // Deferral of the VRAM resources must end in this instance anyway - sk_sp<GrTexture> tex(sk_ref_sp(fTextureProxy->instantiate(fContext->textureProvider()))); + sk_sp<GrTexture> tex(sk_ref_sp(fTextureProxy->instantiate(fContext->resourceProvider()))); if (!tex) { return false; } diff --git a/src/gpu/GrTextureMaker.cpp b/src/gpu/GrTextureMaker.cpp index ac89af7d87..bd0840b509 100644 --- a/src/gpu/GrTextureMaker.cpp +++ b/src/gpu/GrTextureMaker.cpp @@ -9,7 +9,7 @@ #include "GrContext.h" #include "GrGpu.h" -#include "GrTextureProvider.h" +#include "GrResourceProvider.h" GrTexture* GrTextureMaker::refTextureForParams(const GrSamplerParams& params, SkColorSpace* dstColorSpace, @@ -33,7 +33,7 @@ GrTexture* GrTextureMaker::refTextureForParams(const GrSamplerParams& params, GrUniqueKey copyKey; this->makeCopyKey(copyParams, ©Key, dstColorSpace); if (copyKey.isValid()) { - GrTexture* result = fContext->textureProvider()->findAndRefTextureByUniqueKey(copyKey); + GrTexture* result = fContext->resourceProvider()->findAndRefTextureByUniqueKey(copyKey); if (result) { return result; } @@ -45,7 +45,7 @@ GrTexture* GrTextureMaker::refTextureForParams(const GrSamplerParams& params, } if (copyKey.isValid()) { - fContext->textureProvider()->assignUniqueKeyToTexture(copyKey, result); + fContext->resourceProvider()->assignUniqueKeyToTexture(copyKey, result); this->didCacheCopy(copyKey); } return result; diff --git a/src/gpu/GrTextureProvider.cpp b/src/gpu/GrTextureProvider.cpp deleted file mode 100644 index 3790f27fcc..0000000000 --- a/src/gpu/GrTextureProvider.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "GrTextureProvider.h" - -#include "GrCaps.h" -#include "GrTexturePriv.h" -#include "GrResourceCache.h" -#include "GrGpu.h" -#include "../private/GrSingleOwner.h" -#include "SkMathPriv.h" -#include "SkTArray.h" -#include "SkTLazy.h" - -const int GrTextureProvider::kMinScratchTextureSize = 16; - -#define ASSERT_SINGLE_OWNER \ - SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);) - -GrTextureProvider::GrTextureProvider(GrGpu* gpu, GrResourceCache* cache, GrSingleOwner* singleOwner) - : fCache(cache) - , fGpu(gpu) -#ifdef SK_DEBUG - , fSingleOwner(singleOwner) -#endif - { -} - -GrTexture* GrTextureProvider::createMipMappedTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, - const GrMipLevel* texels, int mipLevelCount, - uint32_t flags) { - ASSERT_SINGLE_OWNER - - if (this->isAbandoned()) { - return nullptr; - } - if (mipLevelCount && !texels) { - return nullptr; - } - for (int i = 0; i < mipLevelCount; ++i) { - if (!texels[i].fPixels) { - return nullptr; - } - } - if (mipLevelCount > 1 && GrPixelConfigIsSint(desc.fConfig)) { - return nullptr; - } - if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) && - !fGpu->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { - return nullptr; - } - if (!GrPixelConfigIsCompressed(desc.fConfig)) { - if (mipLevelCount < 2) { - flags |= kExact_ScratchTextureFlag | kNoCreate_ScratchTextureFlag; - if (GrTexture* texture = this->refScratchTexture(desc, flags)) { - if (!mipLevelCount || - texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, - texels[0].fPixels, texels[0].fRowBytes)) { - if (SkBudgeted::kNo == budgeted) { - texture->resourcePriv().makeUnbudgeted(); - } - return texture; - } - texture->unref(); - } - } - } - - SkTArray<GrMipLevel> texelsShallowCopy(mipLevelCount); - for (int i = 0; i < mipLevelCount; ++i) { - texelsShallowCopy.push_back(texels[i]); - } - return fGpu->createTexture(desc, budgeted, texelsShallowCopy); -} - -GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, - const void* srcData, size_t rowBytes, uint32_t flags) { - GrMipLevel tempTexels; - GrMipLevel* texels = nullptr; - int levelCount = 0; - if (srcData) { - tempTexels.fPixels = srcData; - tempTexels.fRowBytes = rowBytes; - texels = &tempTexels; - levelCount = 1; - } - return this->createMipMappedTexture(desc, budgeted, texels, levelCount, flags); -} - -GrTexture* GrTextureProvider::createApproxTexture(const GrSurfaceDesc& desc, uint32_t flags) { - ASSERT_SINGLE_OWNER - return this->internalCreateApproxTexture(desc, flags); -} - -GrTexture* GrTextureProvider::internalCreateApproxTexture(const GrSurfaceDesc& desc, - uint32_t scratchFlags) { - ASSERT_SINGLE_OWNER - if (this->isAbandoned()) { - return nullptr; - } - // Currently we don't recycle compressed textures as scratch. - if (GrPixelConfigIsCompressed(desc.fConfig)) { - return nullptr; - } else { - return this->refScratchTexture(desc, scratchFlags); - } -} - -GrTexture* GrTextureProvider::refScratchTexture(const GrSurfaceDesc& inDesc, - uint32_t flags) { - ASSERT_SINGLE_OWNER - SkASSERT(!this->isAbandoned()); - SkASSERT(!GrPixelConfigIsCompressed(inDesc.fConfig)); - - SkTCopyOnFirstWrite<GrSurfaceDesc> desc(inDesc); - - if (fGpu->caps()->reuseScratchTextures() || (desc->fFlags & kRenderTarget_GrSurfaceFlag)) { - if (!(kExact_ScratchTextureFlag & flags)) { - // bin by pow2 with a reasonable min - GrSurfaceDesc* wdesc = desc.writable(); - wdesc->fWidth = SkTMax(kMinScratchTextureSize, GrNextPow2(desc->fWidth)); - wdesc->fHeight = SkTMax(kMinScratchTextureSize, GrNextPow2(desc->fHeight)); - } - - GrScratchKey key; - GrTexturePriv::ComputeScratchKey(*desc, &key); - uint32_t scratchFlags = 0; - if (kNoPendingIO_ScratchTextureFlag & flags) { - scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag; - } else if (!(desc->fFlags & kRenderTarget_GrSurfaceFlag)) { - // If it is not a render target then it will most likely be populated by - // writePixels() which will trigger a flush if the texture has pending IO. - scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag; - } - GrGpuResource* resource = fCache->findAndRefScratchResource(key, - GrSurface::WorstCaseSize(*desc), - scratchFlags); - if (resource) { - GrSurface* surface = static_cast<GrSurface*>(resource); - GrRenderTarget* rt = surface->asRenderTarget(); - if (rt && fGpu->caps()->discardRenderTargetSupport()) { - rt->discard(); - } - return surface->asTexture(); - } - } - - if (!(kNoCreate_ScratchTextureFlag & flags)) { - return fGpu->createTexture(*desc, SkBudgeted::kYes); - } - - return nullptr; -} - -sk_sp<GrTexture> GrTextureProvider::wrapBackendTexture(const GrBackendTextureDesc& desc, - GrWrapOwnership ownership) { - ASSERT_SINGLE_OWNER - if (this->isAbandoned()) { - return nullptr; - } - return fGpu->wrapBackendTexture(desc, ownership); -} - -sk_sp<GrRenderTarget> GrTextureProvider::wrapBackendRenderTarget( - const GrBackendRenderTargetDesc& desc) -{ - ASSERT_SINGLE_OWNER - return this->isAbandoned() ? nullptr - : fGpu->wrapBackendRenderTarget(desc, kBorrow_GrWrapOwnership); -} - -void GrTextureProvider::assignUniqueKeyToResource(const GrUniqueKey& key, GrGpuResource* resource) { - ASSERT_SINGLE_OWNER - if (this->isAbandoned() || !resource) { - return; - } - resource->resourcePriv().setUniqueKey(key); -} - -bool GrTextureProvider::existsResourceWithUniqueKey(const GrUniqueKey& key) const { - ASSERT_SINGLE_OWNER - return this->isAbandoned() ? false : fCache->hasUniqueKey(key); -} - -GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey(const GrUniqueKey& key) { - ASSERT_SINGLE_OWNER - return this->isAbandoned() ? nullptr : fCache->findAndRefUniqueResource(key); -} - -GrTexture* GrTextureProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& key) { - ASSERT_SINGLE_OWNER - GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key); - if (resource) { - GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture(); - SkASSERT(texture); - return texture; - } - return NULL; -} diff --git a/src/gpu/GrTextureProvider.h b/src/gpu/GrTextureProvider.h deleted file mode 100644 index dd139cc0e7..0000000000 --- a/src/gpu/GrTextureProvider.h +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef GrTextureProvider_DEFINED -#define GrTextureProvider_DEFINED - -#include "GrTexture.h" -#include "GrTypes.h" - -class GrSingleOwner; - -class SK_API GrTextureProvider { -public: - /////////////////////////////////////////////////////////////////////////// - // Textures - - /** - * Creates a new texture in the resource cache and returns it. The caller owns a - * ref on the returned texture which must be balanced by a call to unref. - * - * @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 - */ - GrTexture* createMipMappedTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, - const GrMipLevel* texels, int mipLevelCount, - uint32_t flags = 0); - - /** - * This function is a shim which creates a SkTArray<GrMipLevel> of size 1. - * It then calls createTexture with that SkTArray. - * - * @param srcData Pointer to the pixel values (optional). - * @param rowBytes The number of bytes between rows of the texture. Zero - * implies tightly packed rows. For compressed pixel configs, this - * field is ignored. - */ - GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, const void* srcData, - size_t rowBytes, uint32_t flags = 0); - - /** Shortcut for creating a texture with no initial data to upload. */ - GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, uint32_t flags = 0) { - return this->createTexture(desc, budgeted, nullptr, 0, flags); - } - - /** Assigns a unique key to the texture. The texture will be findable via this key using - findTextureByUniqueKey(). If an existing texture has this key, it's key will be removed. */ - void assignUniqueKeyToTexture(const GrUniqueKey& key, GrTexture* texture) { - SkASSERT(key.isValid()); - this->assignUniqueKeyToResource(key, texture); - } - - /** Finds a texture by unique key. If the texture is found it is ref'ed and returned. */ - GrTexture* findAndRefTextureByUniqueKey(const GrUniqueKey& key); - - /** - * Determines whether a texture is associated with the unique key. If the texture is found it - * will not be locked or returned. This call does not affect the priority of the resource for - * deletion. - */ - bool existsTextureWithUniqueKey(const GrUniqueKey& key) const { - return this->existsResourceWithUniqueKey(key); - } - - /** - * Finds a texture that approximately matches the descriptor. Will be at least as large in width - * and height as desc specifies. If desc specifies that the texture should be a render target - * then result will be a render target. Format and sample count will always match the request. - * The contents of the texture are undefined. The caller owns a ref on the returned texture and - * must balance with a call to unref. - */ - GrTexture* createApproxTexture(const GrSurfaceDesc&, uint32_t flags = 0); - - /** Legacy function that no longer should be used. */ - enum ScratchTexMatch { - kExact_ScratchTexMatch, - kApprox_ScratchTexMatch - }; - GrTexture* refScratchTexture(const GrSurfaceDesc& desc, ScratchTexMatch match, uint32_t flags) { - if (kApprox_ScratchTexMatch == match) { - return this->createApproxTexture(desc, flags); - } else { - return this->createTexture(desc, SkBudgeted::kYes, flags); - } - } - - /////////////////////////////////////////////////////////////////////////// - // Wrapped Backend Surfaces - - /** - * Wraps an existing texture with a GrTexture object. - * - * OpenGL: if the object is a texture Gr may change its GL texture params - * when it is drawn. - * - * @return GrTexture object or NULL on failure. - */ - sk_sp<GrTexture> wrapBackendTexture(const GrBackendTextureDesc& desc, - GrWrapOwnership = kBorrow_GrWrapOwnership); - - /** - * Wraps an existing render target with a GrRenderTarget object. It is - * similar to wrapBackendTexture but can be used to draw into surfaces - * that are not also textures (e.g. FBO 0 in OpenGL, or an MSAA buffer that - * the client will resolve to a texture). Currently wrapped render targets - * always use the kBorrow_GrWrapOwnership semantics. - * - * @return GrRenderTarget object or NULL on failure. - */ - sk_sp<GrRenderTarget> wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc); - - static const int kMinScratchTextureSize; - -protected: - GrTextureProvider(GrGpu* gpu, GrResourceCache* cache, GrSingleOwner* singleOwner); - - /** - * Assigns a unique key to a resource. If the key is associated with another resource that - * association is removed and replaced by this resource. - */ - void assignUniqueKeyToResource(const GrUniqueKey&, GrGpuResource*); - - /** - * Finds a resource in the cache, based on the specified key. This is intended for use in - * conjunction with addResourceToCache(). The return value will be NULL if not found. The - * caller must balance with a call to unref(). - */ - GrGpuResource* findAndRefResourceByUniqueKey(const GrUniqueKey&); - - /** - * Determines whether a resource is in the cache. If the resource is found it - * will not be locked or returned. This call does not affect the priority of - * the resource for deletion. - */ - bool existsResourceWithUniqueKey(const GrUniqueKey& key) const; - - enum ScratchTextureFlags { - kExact_ScratchTextureFlag = 0x1, - kNoPendingIO_ScratchTextureFlag = 0x2, // (http://skbug.com/4156) - kNoCreate_ScratchTextureFlag = 0x4, - kLastScratchTextureFlag = kNoCreate_ScratchTextureFlag - }; - - /** A common impl for GrTextureProvider and GrResourceProvider variants. */ - GrTexture* internalCreateApproxTexture(const GrSurfaceDesc& desc, uint32_t scratchTextureFlags); - - GrTexture* refScratchTexture(const GrSurfaceDesc&, uint32_t scratchTextureFlags); - - void abandon() { - fCache = NULL; - fGpu = NULL; - } - - GrResourceCache* cache() { return fCache; } - const GrResourceCache* cache() const { return fCache; } - - GrGpu* gpu() { return fGpu; } - const GrGpu* gpu() const { return fGpu; } - - bool isAbandoned() const { - SkASSERT(SkToBool(fGpu) == SkToBool(fCache)); - return !SkToBool(fCache); - } - -private: - GrResourceCache* fCache; - GrGpu* fGpu; - - // In debug builds we guard against improper thread handling - SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;) -}; - -#endif diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp index 9a65140816..0b3430926c 100644 --- a/src/gpu/GrTextureProxy.cpp +++ b/src/gpu/GrTextureProxy.cpp @@ -7,7 +7,7 @@ #include "GrTextureProxy.h" -#include "GrTextureProvider.h" +#include "GrResourceProvider.h" GrTextureProxy::GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit fit, SkBudgeted budgeted, const void* srcData, size_t /*rowBytes*/, uint32_t flags) @@ -19,8 +19,8 @@ GrTextureProxy::GrTextureProxy(sk_sp<GrSurface> surf) : INHERITED(std::move(surf), SkBackingFit::kExact) { } -GrTexture* GrTextureProxy::instantiate(GrTextureProvider* texProvider) { - GrSurface* surf = this->INHERITED::instantiate(texProvider); +GrTexture* GrTextureProxy::instantiate(GrResourceProvider* resourceProvider) { + GrSurface* surf = this->INHERITED::instantiate(resourceProvider); if (!surf) { return nullptr; } diff --git a/src/gpu/GrTextureToYUVPlanes.cpp b/src/gpu/GrTextureToYUVPlanes.cpp index 132b680626..683bd638d2 100644 --- a/src/gpu/GrTextureToYUVPlanes.cpp +++ b/src/gpu/GrTextureToYUVPlanes.cpp @@ -10,9 +10,9 @@ #include "effects/GrYUVEffect.h" #include "GrClip.h" #include "GrContext.h" -#include "GrRenderTargetContext.h" #include "GrPaint.h" -#include "GrTextureProvider.h" +#include "GrRenderTargetContext.h" +#include "GrResourceProvider.h" namespace { using MakeFPProc = sk_sp<GrFragmentProcessor> (*)(sk_sp<GrFragmentProcessor>, diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 6eaba4c7fe..c3d197e0a6 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -13,8 +13,8 @@ #include "GrContext.h" #include "GrGpuResourcePriv.h" #include "GrRenderTargetContext.h" +#include "GrResourceProvider.h" #include "GrTexturePriv.h" -#include "GrTextureProvider.h" #include "GrTextureProxy.h" #include "GrTypes.h" #include "GrXferProcessor.h" @@ -162,7 +162,7 @@ GrTexture* GrUploadPixmapToTexture(GrContext* ctx, const SkPixmap& pixmap, SkBud desc = GrImageInfoToSurfaceDesc(pmap->info(), *caps); } - return ctx->textureProvider()->createTexture(desc, budgeted, pmap->addr(), + return ctx->resourceProvider()->createTexture(desc, budgeted, pmap->addr(), pmap->rowBytes()); } @@ -240,10 +240,10 @@ GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext* ctx, const SkBitmap& b } { - GrTexture* texture = ctx->textureProvider()->createMipMappedTexture(desc, - SkBudgeted::kYes, - texels.get(), - mipLevelCount); + GrTexture* texture = ctx->resourceProvider()->createMipMappedTexture(desc, + SkBudgeted::kYes, + texels.get(), + mipLevelCount); if (texture) { texture->texturePriv().setMipColorMode(colorMode); } @@ -258,8 +258,8 @@ GrTexture* GrUploadMipMapToTexture(GrContext* ctx, const SkImageInfo& info, } const GrCaps* caps = ctx->caps(); - return ctx->textureProvider()->createMipMappedTexture(GrImageInfoToSurfaceDesc(info, *caps), - SkBudgeted::kYes, texels, + return ctx->resourceProvider()->createMipMappedTexture(GrImageInfoToSurfaceDesc(info, *caps), + SkBudgeted::kYes, texels, mipLevelCount); } @@ -284,12 +284,12 @@ sk_sp<GrTextureProxy> GrMakeCachedBitmapProxy(GrContext* context, const SkBitmap sk_sp<GrTexture> tex; if (originalKey.isValid()) { - tex.reset(context->textureProvider()->findAndRefTextureByUniqueKey(originalKey)); + tex.reset(context->resourceProvider()->findAndRefTextureByUniqueKey(originalKey)); } if (!tex) { tex.reset(GrUploadBitmapToTexture(context, bitmap)); if (tex && originalKey.isValid()) { - context->textureProvider()->assignUniqueKeyToTexture(originalKey, tex.get()); + context->resourceProvider()->assignUniqueKeyToTexture(originalKey, tex.get()); GrInstallBitmapUniqueKeyInvalidator(originalKey, bitmap.pixelRef()); } } diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp index bbce742c36..8283910494 100644 --- a/src/gpu/effects/GrBitmapTextGeoProc.cpp +++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp @@ -127,7 +127,7 @@ GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrContext* context, GrColor color, : fColor(color) , fLocalMatrix(localMatrix) , fUsesLocalCoords(usesLocalCoords) - , fTextureSampler(context->textureProvider(), std::move(proxy), params) + , fTextureSampler(context->resourceProvider(), std::move(proxy), params) , fInColor(nullptr) , fMaskFormat(format) { this->initClassID<GrBitmapTextGeoProc>(); diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp index 6a4cca5d77..d6299022e5 100644 --- a/src/gpu/effects/GrConfigConversionEffect.cpp +++ b/src/gpu/effects/GrConfigConversionEffect.cpp @@ -219,7 +219,7 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context desc.fConfig = kConfig; sk_sp<GrTextureProxy> dataProxy = GrSurfaceProxy::MakeDeferred(*context->caps(), - context->textureProvider(), + context->resourceProvider(), desc, SkBudgeted::kYes, data, 0); if (!dataProxy) { return; diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp index 19f5e2acbd..a5f68d9462 100644 --- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp +++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp @@ -234,7 +234,7 @@ GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(GrContext* context, bool usesLocalCoords) : fColor(color) , fViewMatrix(viewMatrix) - , fTextureSampler(context->textureProvider(), std::move(proxy), params) + , fTextureSampler(context->resourceProvider(), std::move(proxy), params) #ifdef SK_GAMMA_APPLY_TO_A8 , fDistanceAdjust(distanceAdjust) #endif @@ -481,7 +481,7 @@ GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc( bool usesLocalCoords) : fColor(color) , fViewMatrix(viewMatrix) - , fTextureSampler(context->textureProvider(), std::move(proxy), params) + , fTextureSampler(context->resourceProvider(), std::move(proxy), params) , fFlags(flags & kNonLCD_DistanceFieldEffectMask) , fInColor(nullptr) , fUsesLocalCoords(usesLocalCoords) { @@ -785,7 +785,7 @@ GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc( uint32_t flags, bool usesLocalCoords) : fColor(color) , fViewMatrix(viewMatrix) - , fTextureSampler(context->textureProvider(), std::move(proxy), params) + , fTextureSampler(context->resourceProvider(), std::move(proxy), params) , fDistanceAdjust(distanceAdjust) , fFlags(flags & kLCD_DistanceFieldEffectMask) , fUsesLocalCoords(usesLocalCoords) { diff --git a/src/gpu/effects/GrSingleTextureEffect.cpp b/src/gpu/effects/GrSingleTextureEffect.cpp index acfc0d142d..01cad6655c 100644 --- a/src/gpu/effects/GrSingleTextureEffect.cpp +++ b/src/gpu/effects/GrSingleTextureEffect.cpp @@ -52,7 +52,7 @@ GrSingleTextureEffect::GrSingleTextureEffect(GrContext* ctx, OptimizationFlags o const SkMatrix& m) : INHERITED(optFlags) , fCoordTransform(ctx, m, proxy.get(), GrSamplerParams::kNone_FilterMode) - , fTextureSampler(ctx->textureProvider(), std::move(proxy)) + , fTextureSampler(ctx->resourceProvider(), std::move(proxy)) , fColorSpaceXform(std::move(colorSpaceXform)) { this->addCoordTransform(&fCoordTransform); this->addTextureSampler(&fTextureSampler); @@ -65,7 +65,7 @@ GrSingleTextureEffect::GrSingleTextureEffect(GrContext* ctx, OptimizationFlags o GrSamplerParams::FilterMode filterMode) : INHERITED(optFlags) , fCoordTransform(ctx, m, proxy.get(), filterMode) - , fTextureSampler(ctx->textureProvider(), std::move(proxy), filterMode) + , fTextureSampler(ctx->resourceProvider(), std::move(proxy), filterMode) , fColorSpaceXform(std::move(colorSpaceXform)) { this->addCoordTransform(&fCoordTransform); this->addTextureSampler(&fTextureSampler); @@ -77,7 +77,7 @@ GrSingleTextureEffect::GrSingleTextureEffect(GrContext* ctx, OptimizationFlags o const SkMatrix& m, const GrSamplerParams& params) : INHERITED(optFlags) , fCoordTransform(ctx, m, proxy.get(), params.filterMode()) - , fTextureSampler(ctx->textureProvider(), std::move(proxy), params) + , fTextureSampler(ctx->resourceProvider(), std::move(proxy), params) , fColorSpaceXform(std::move(colorSpaceXform)) { this->addCoordTransform(&fCoordTransform); this->addTextureSampler(&fTextureSampler); diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp index 39bc3ccb8a..2ac6af8375 100644 --- a/src/gpu/effects/GrTextureDomain.cpp +++ b/src/gpu/effects/GrTextureDomain.cpp @@ -423,7 +423,7 @@ GrDeviceSpaceTextureDecalFragmentProcessor::GrDeviceSpaceTextureDecalFragmentPro const SkIRect& subset, const SkIPoint& deviceSpaceOffset) : INHERITED(kCompatibleWithCoverageAsAlpha_OptimizationFlag) - , fTextureSampler(context->textureProvider(), proxy, GrSamplerParams::ClampNoFilter()) + , fTextureSampler(context->resourceProvider(), proxy, GrSamplerParams::ClampNoFilter()) , fTextureDomain(proxy.get(), GrTextureDomain::MakeTexelDomain(subset), GrTextureDomain::kDecal_Mode) { this->addTextureSampler(&fTextureSampler); diff --git a/src/gpu/effects/GrTextureStripAtlas.cpp b/src/gpu/effects/GrTextureStripAtlas.cpp index 1791b20e70..df36e65070 100644 --- a/src/gpu/effects/GrTextureStripAtlas.cpp +++ b/src/gpu/effects/GrTextureStripAtlas.cpp @@ -10,7 +10,6 @@ #include "GrContextPriv.h" #include "GrResourceProvider.h" #include "GrSurfaceContext.h" -#include "GrTextureProvider.h" #include "SkGr.h" #include "SkPixelRef.h" #include "SkTSearch.h" @@ -209,9 +208,9 @@ void GrTextureStripAtlas::lockTexture() { builder.finish(); // MDB TODO (caching): this side-steps the issue of proxies with unique IDs - sk_sp<GrTexture> texture(fDesc.fContext->textureProvider()->findAndRefTextureByUniqueKey(key)); + sk_sp<GrTexture> texture(fDesc.fContext->resourceProvider()->findAndRefTextureByUniqueKey(key)); if (!texture) { - texture.reset(fDesc.fContext->textureProvider()->createTexture( + texture.reset(fDesc.fContext->resourceProvider()->createTexture( texDesc, SkBudgeted::kYes, nullptr, 0, GrResourceProvider::kNoPendingIO_Flag)); @@ -219,7 +218,7 @@ void GrTextureStripAtlas::lockTexture() { return; } - fDesc.fContext->textureProvider()->assignUniqueKeyToTexture(key, texture.get()); + fDesc.fContext->resourceProvider()->assignUniqueKeyToTexture(key, texture.get()); // This is a new texture, so all of our cache info is now invalid this->initLRU(); fKeyTable.rewind(); diff --git a/src/gpu/effects/GrYUVEffect.cpp b/src/gpu/effects/GrYUVEffect.cpp index e09e185b55..78ac9bab54 100644 --- a/src/gpu/effects/GrYUVEffect.cpp +++ b/src/gpu/effects/GrYUVEffect.cpp @@ -159,10 +159,10 @@ private: GrSamplerParams::FilterMode uvFilterMode, SkYUVColorSpace colorSpace, bool nv12) : INHERITED(kPreservesOpaqueInput_OptimizationFlag) , fYTransform(ctx, yuvMatrix[0], yProxy.get(), GrSamplerParams::kNone_FilterMode) - , fYSampler(ctx->textureProvider(), std::move(yProxy)) + , fYSampler(ctx->resourceProvider(), std::move(yProxy)) , fUTransform(ctx, yuvMatrix[1], uProxy.get(), uvFilterMode) - , fUSampler(ctx->textureProvider(), std::move(uProxy), uvFilterMode) - , fVSampler(ctx->textureProvider(), vProxy, uvFilterMode) + , fUSampler(ctx->resourceProvider(), std::move(uProxy), uvFilterMode) + , fVSampler(ctx->resourceProvider(), vProxy, uvFilterMode) , fColorSpace(colorSpace) , fNV12(nv12) { this->initClassID<YUVtoRGBEffect>(); diff --git a/src/gpu/effects/GrYUVEffect.h b/src/gpu/effects/GrYUVEffect.h index 6af442ea9a..524928b48a 100644 --- a/src/gpu/effects/GrYUVEffect.h +++ b/src/gpu/effects/GrYUVEffect.h @@ -12,7 +12,6 @@ class GrContext; class GrFragmentProcessor; -class GrTextureProvider; class GrTextureProxy; namespace GrYUVEffect { diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index 37a91932a2..ced544723e 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -17,10 +17,10 @@ #include "GrGpu.h" #include "GrImageTextureMaker.h" #include "GrRenderTargetContext.h" +#include "GrResourceProvider.h" #include "GrSemaphore.h" #include "GrTextureAdjuster.h" #include "GrTexturePriv.h" -#include "GrTextureProvider.h" #include "GrTextureProxy.h" #include "effects/GrYUVEffect.h" #include "SkCanvas.h" @@ -195,7 +195,7 @@ sk_sp<SkImage> SkImage_Gpu::onMakeSubset(const SkIRect& subset) const { } // TODO: make gpu images be proxy-backed so we don't need to do this - GrSurface* subTx = sContext->asSurfaceProxy()->instantiate(ctx->textureProvider()); + GrSurface* subTx = sContext->asSurfaceProxy()->instantiate(ctx->resourceProvider()); if (!subTx) { return nullptr; } @@ -215,7 +215,7 @@ static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx, const GrBackend if (desc.fWidth <= 0 || desc.fHeight <= 0) { return nullptr; } - sk_sp<GrTexture> tex = ctx->textureProvider()->wrapBackendTexture(desc, ownership); + sk_sp<GrTexture> tex = ctx->resourceProvider()->wrapBackendTexture(desc, ownership); if (!tex) { return nullptr; } diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index cf127e50bc..9fe813f206 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -114,7 +114,7 @@ sk_sp<SkImage> SkSurface_Gpu::onNewImageSnapshot(SkBudgeted budgeted) { } // TODO: add proxy-backed SkImage_Gpu - GrTexture* tex = srcProxy->instantiate(ctx->textureProvider())->asTexture(); + GrTexture* tex = srcProxy->instantiate(ctx->resourceProvider())->asTexture(); const SkImageInfo info = fDevice->imageInfo(); sk_sp<SkImage> image; diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp index 3530b88cea..d4b85872d8 100644 --- a/tests/ClearTest.cpp +++ b/tests/ClearTest.cpp @@ -12,8 +12,8 @@ #include "GrRenderTargetContext.h" #include "GrGpu.h" #include "GrRenderTarget.h" +#include "GrResourceProvider.h" #include "GrTexture.h" -#include "GrTextureProvider.h" static bool check_rect(GrRenderTargetContext* rtc, const SkIRect& rect, uint32_t expectedValue, uint32_t* actualValue, int* failX, int* failY) { diff --git a/tests/ClipStackTest.cpp b/tests/ClipStackTest.cpp index e3980504f2..c2b72c6d94 100644 --- a/tests/ClipStackTest.cpp +++ b/tests/ClipStackTest.cpp @@ -1441,7 +1441,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ClipMaskCache, reporter, ctxInfo) { stack.save(); stack.clipPath(path, m, SkClipOp::kIntersect, true); sk_sp<GrTextureProxy> mask = GrClipStackClip(&stack).testingOnly_createClipMask(context); - GrTexture* tex = mask->instantiate(context->textureProvider()); + GrTexture* tex = mask->instantiate(context->resourceProvider()); REPORTER_ASSERT(reporter, 0 == strcmp(tex->getUniqueKey().tag(), kTag)); // Make sure mask isn't pinned in cache. mask.reset(nullptr); diff --git a/tests/CopySurfaceTest.cpp b/tests/CopySurfaceTest.cpp index e1765d5809..828eff073e 100644 --- a/tests/CopySurfaceTest.cpp +++ b/tests/CopySurfaceTest.cpp @@ -11,10 +11,10 @@ #if SK_SUPPORT_GPU #include "GrContext.h" #include "GrContextPriv.h" +#include "GrResourceProvider.h" #include "GrSurfaceContext.h" #include "GrSurfaceProxy.h" #include "GrTexture.h" -#include "GrTextureProvider.h" #include "SkUtils.h" @@ -75,14 +75,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) { sk_sp<GrTextureProxy> src(GrSurfaceProxy::MakeDeferred( *context->caps(), - context->textureProvider(), + context->resourceProvider(), srcDesc, SkBudgeted::kNo, srcPixels.get(), kRowBytes)); sk_sp<GrTextureProxy> dst(GrSurfaceProxy::MakeDeferred( *context->caps(), - context->textureProvider(), + context->resourceProvider(), dstDesc, SkBudgeted::kNo, dstPixels.get(), kRowBytes)); diff --git a/tests/FloatingPointTextureTest.cpp b/tests/FloatingPointTextureTest.cpp index b19a071eef..4214e4eebf 100644 --- a/tests/FloatingPointTextureTest.cpp +++ b/tests/FloatingPointTextureTest.cpp @@ -17,8 +17,8 @@ #if SK_SUPPORT_GPU #include "GrContext.h" +#include "GrResourceProvider.h" #include "GrTexture.h" -#include "GrTextureProvider.h" #include "SkHalf.h" static const int DEV_W = 100, DEV_H = 100; @@ -51,7 +51,7 @@ void runFPTest(skiatest::Reporter* reporter, GrContext* context, desc.fHeight = DEV_H; desc.fConfig = config; desc.fOrigin = 0 == origin ? kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin; - sk_sp<GrTexture> fpTexture(context->textureProvider()->createTexture( + sk_sp<GrTexture> fpTexture(context->resourceProvider()->createTexture( desc, SkBudgeted::kNo, controlPixelData.begin(), 0)); // Floating point textures are NOT supported everywhere if (nullptr == fpTexture) { diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index 9c39abce07..7628847a48 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -292,13 +292,13 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) { dummyDesc.fWidth = 34; dummyDesc.fHeight = 18; sk_sp<GrTexture> dummyTexture1( - context->textureProvider()->createTexture(dummyDesc, SkBudgeted::kNo, nullptr, 0)); + context->resourceProvider()->createTexture(dummyDesc, SkBudgeted::kNo, nullptr, 0)); dummyDesc.fFlags = kNone_GrSurfaceFlags; dummyDesc.fConfig = kAlpha_8_GrPixelConfig; dummyDesc.fWidth = 16; dummyDesc.fHeight = 22; sk_sp<GrTexture> dummyTexture2( - context->textureProvider()->createTexture(dummyDesc, SkBudgeted::kNo, nullptr, 0)); + context->resourceProvider()->createTexture(dummyDesc, SkBudgeted::kNo, nullptr, 0)); if (!dummyTexture1 || ! dummyTexture2) { SkDebugf("Could not allocate dummy textures"); diff --git a/tests/GrPorterDuffTest.cpp b/tests/GrPorterDuffTest.cpp index bfbd97e387..c1d73ef251 100644 --- a/tests/GrPorterDuffTest.cpp +++ b/tests/GrPorterDuffTest.cpp @@ -1018,7 +1018,7 @@ DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, /*factory*/) { fakeDesc.fTextureHandle = backendTex; GrXferProcessor::DstTexture fakeDstTexture; fakeDstTexture.setTexture( - ctx->textureProvider()->wrapBackendTexture(fakeDesc, kBorrow_GrWrapOwnership)); + ctx->resourceProvider()->wrapBackendTexture(fakeDesc, kBorrow_GrWrapOwnership)); static const GrPipelineInput colorInputs[] = {GrPipelineInput(), GrPipelineInput(GrPipelineInput::Opaque::kYes), diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp index 5e52a0ad68..d98d0d0428 100644 --- a/tests/GrSurfaceTest.cpp +++ b/tests/GrSurfaceTest.cpp @@ -12,8 +12,8 @@ #include "GrContext.h" #include "GrGpu.h" #include "GrRenderTarget.h" +#include "GrResourceProvider.h" #include "GrTexture.h" -#include "GrTextureProvider.h" #include "GrSurfacePriv.h" #include "Test.h" @@ -27,7 +27,7 @@ DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrSurface, reporter, ctxInfo) { desc.fWidth = 256; desc.fHeight = 256; desc.fSampleCnt = 0; - GrSurface* texRT1 = context->textureProvider()->createTexture( + GrSurface* texRT1 = context->resourceProvider()->createTexture( desc, SkBudgeted::kNo, nullptr, 0); REPORTER_ASSERT(reporter, texRT1 == texRT1->asRenderTarget()); @@ -40,7 +40,7 @@ DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrSurface, reporter, ctxInfo) { static_cast<GrSurface*>(texRT1->asTexture())); desc.fFlags = kNone_GrSurfaceFlags; - GrSurface* tex1 = context->textureProvider()->createTexture(desc, SkBudgeted::kNo, nullptr, 0); + GrSurface* tex1 = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo, nullptr, 0); REPORTER_ASSERT(reporter, nullptr == tex1->asRenderTarget()); REPORTER_ASSERT(reporter, tex1 == tex1->asTexture()); REPORTER_ASSERT(reporter, static_cast<GrSurface*>(tex1) == tex1->asTexture()); @@ -55,7 +55,7 @@ DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrSurface, reporter, ctxInfo) { backendDesc.fHeight = 256; backendDesc.fSampleCnt = 0; backendDesc.fTextureHandle = backendTex; - sk_sp<GrSurface> texRT2 = context->textureProvider()->wrapBackendTexture( + sk_sp<GrSurface> texRT2 = context->resourceProvider()->wrapBackendTexture( backendDesc, kBorrow_GrWrapOwnership); REPORTER_ASSERT(reporter, texRT2.get() == texRT2->asRenderTarget()); REPORTER_ASSERT(reporter, texRT2.get() == texRT2->asTexture()); diff --git a/tests/ImageFilterCacheTest.cpp b/tests/ImageFilterCacheTest.cpp index 9e63c038df..3979581266 100644 --- a/tests/ImageFilterCacheTest.cpp +++ b/tests/ImageFilterCacheTest.cpp @@ -179,7 +179,7 @@ DEF_TEST(ImageFilterCache_ImageBackedRaster, reporter) { #if SK_SUPPORT_GPU #include "GrContext.h" -#include "GrTextureProvider.h" +#include "GrResourceProvider.h" static GrTexture* create_texture(GrContext* context) { SkBitmap srcBM = create_bm(); @@ -190,7 +190,7 @@ static GrTexture* create_texture(GrContext* context) { desc.fWidth = kFullSize; desc.fHeight = kFullSize; - return context->textureProvider()->createTexture(desc, SkBudgeted::kNo, srcBM.getPixels(), 0); + return context->resourceProvider()->createTexture(desc, SkBudgeted::kNo, srcBM.getPixels(), 0); } static sk_sp<GrTextureProxy> create_proxy(GrContext* context) { @@ -203,7 +203,7 @@ static sk_sp<GrTextureProxy> create_proxy(GrContext* context) { desc.fHeight = kFullSize; return GrSurfaceProxy::MakeDeferred(*context->caps(), - context->textureProvider(), + context->resourceProvider(), desc, SkBudgeted::kYes, srcBM.getPixels(), srcBM.rowBytes()); diff --git a/tests/ImageStorageTest.cpp b/tests/ImageStorageTest.cpp index d08ac6df63..42305066f6 100644 --- a/tests/ImageStorageTest.cpp +++ b/tests/ImageStorageTest.cpp @@ -11,8 +11,8 @@ #include "GrFragmentProcessor.h" #include "GrRenderTargetContext.h" +#include "GrResourceProvider.h" #include "GrTexture.h" -#include "GrTextureProvider.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" @@ -126,8 +126,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageStorageLoad, reporter, ctxInfo) { continue; } desc.fConfig = test.fConfig; - sk_sp<GrTexture> imageStorageTexture(context->textureProvider()->createTexture(desc, - SkBudgeted::kYes, test.fData.get(), 0)); + sk_sp<GrTexture> imageStorageTexture(context->resourceProvider()->createTexture( + desc, SkBudgeted::kYes, test.fData.get(), 0)); sk_sp<GrRenderTargetContext> rtContext = context->makeRenderTargetContext(SkBackingFit::kExact, kS, kS, diff --git a/tests/IntTextureTest.cpp b/tests/IntTextureTest.cpp index 518e195f9e..14b18b22af 100644 --- a/tests/IntTextureTest.cpp +++ b/tests/IntTextureTest.cpp @@ -10,8 +10,8 @@ #if SK_SUPPORT_GPU #include "GrContext.h" #include "GrRenderTargetContext.h" +#include "GrResourceProvider.h" #include "GrTexture.h" -#include "GrTextureProvider.h" #include "effects/GrSimpleTextureEffect.h" template <typename I> @@ -63,15 +63,15 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { levels[1].fPixels = testData.get(); levels[1].fRowBytes = (kS / 2) * sizeof(int32_t); - sk_sp<GrTexture> temp(context->textureProvider()->createMipMappedTexture(desc, - SkBudgeted::kYes, - levels, 2)); + sk_sp<GrTexture> temp(context->resourceProvider()->createMipMappedTexture(desc, + SkBudgeted::kYes, + levels, 2)); REPORTER_ASSERT(reporter, !temp); } // Test that we can create an integer texture. sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(*context->caps(), - context->textureProvider(), + context->resourceProvider(), desc, SkBudgeted::kYes, testData.get(), kRowBytes); @@ -80,7 +80,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { return; } - GrTexture* texture = proxy->instantiate(context->textureProvider()); + GrTexture* texture = proxy->instantiate(context->resourceProvider()); REPORTER_ASSERT(reporter, texture); if (!texture) { return; @@ -126,7 +126,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { } GrSurface* copySurface = dstContext->asTextureProxy()->instantiate( - context->textureProvider()); + context->resourceProvider()); REPORTER_ASSERT(reporter, copySurface); if (!copySurface) { return; @@ -256,8 +256,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { // No rendering to integer textures. GrSurfaceDesc intRTDesc = desc; intRTDesc.fFlags = kRenderTarget_GrSurfaceFlag; - sk_sp<GrTexture> temp(context->textureProvider()->createTexture(intRTDesc, - SkBudgeted::kYes)); + sk_sp<GrTexture> temp(context->resourceProvider()->createTexture(intRTDesc, + SkBudgeted::kYes)); REPORTER_ASSERT(reporter, !temp); } } diff --git a/tests/PackedConfigsTextureTest.cpp b/tests/PackedConfigsTextureTest.cpp index c948bf9004..4b8e3cd6f0 100644 --- a/tests/PackedConfigsTextureTest.cpp +++ b/tests/PackedConfigsTextureTest.cpp @@ -15,8 +15,8 @@ #if SK_SUPPORT_GPU #include "GrContext.h" +#include "GrResourceProvider.h" #include "GrTexture.h" -#include "GrTextureProvider.h" static const int DEV_W = 10, DEV_H = 10; static const SkIRect DEV_RECT = SkIRect::MakeWH(DEV_W, DEV_H); @@ -117,7 +117,7 @@ void runTest(skiatest::Reporter* reporter, GrContext* context, desc.fConfig = config; desc.fOrigin = 0 == origin ? kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin; - sk_sp<GrTexture> fpTexture(context->textureProvider()->createTexture( + sk_sp<GrTexture> fpTexture(context->resourceProvider()->createTexture( desc, SkBudgeted::kNo, controlPixelData.begin(), 0)); SkASSERT(fpTexture); fpTexture->readPixels(0, 0, DEV_W, DEV_H, kRGBA_8888_GrPixelConfig, readBuffer.begin(), 0); diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp index fc9ccf2816..25f1413bf6 100644 --- a/tests/PrimitiveProcessorTest.cpp +++ b/tests/PrimitiveProcessorTest.cpp @@ -17,7 +17,7 @@ #include "GrOpFlushState.h" #include "GrRenderTargetContext.h" #include "GrRenderTargetContextPriv.h" -#include "GrTextureProvider.h" +#include "GrResourceProvider.h" #include "SkString.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" #include "glsl/GrGLSLGeometryProcessor.h" diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp index 05be7bbea4..0b8f6febc7 100644 --- a/tests/ProcessorTest.cpp +++ b/tests/ProcessorTest.cpp @@ -72,7 +72,7 @@ private: const SkTArray<Image>& images) : INHERITED(kNone_OptimizationFlags), fSamplers(4), fBuffers(4), fImages(4) { for (const auto& proxy : proxies) { - this->addTextureSampler(&fSamplers.emplace_back(context->textureProvider(), proxy)); + this->addTextureSampler(&fSamplers.emplace_back(context->resourceProvider(), proxy)); } for (const auto& buffer : buffers) { this->addBufferAccess(&fBuffers.emplace_back(kRGBA_8888_GrPixelConfig, buffer.get())); @@ -138,7 +138,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) { { bool texelBufferSupport = context->caps()->shaderCaps()->texelBufferSupport(); bool imageLoadStoreSupport = context->caps()->shaderCaps()->imageLoadStoreSupport(); - sk_sp<GrTextureProxy> proxy1(GrSurfaceProxy::MakeDeferred(context->textureProvider(), + sk_sp<GrTextureProxy> proxy1(GrSurfaceProxy::MakeDeferred(context->resourceProvider(), *context->caps(), desc, SkBackingFit::kExact, SkBudgeted::kYes)); @@ -287,7 +287,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor texel_color(random.nextULessThan(256), random.nextULessThan(256)); } } - sk_sp<GrTexture> tex0(context->textureProvider()->createTexture( + sk_sp<GrTexture> tex0(context->resourceProvider()->createTexture( desc, SkBudgeted::kYes, rgbaData.get(), 256 * sizeof(GrColor))); // Put random values into the alpha texture that the test FPs can optionally use. @@ -298,8 +298,8 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor alphaData.get()[256 * y + x] = random.nextULessThan(256); } } - sk_sp<GrTexture> tex1(context->textureProvider()->createTexture(desc, SkBudgeted::kYes, - alphaData.get(), 256)); + sk_sp<GrTexture> tex1(context->resourceProvider()->createTexture(desc, SkBudgeted::kYes, + alphaData.get(), 256)); GrTexture* textures[] = {tex0.get(), tex1.get()}; GrProcessorTestData testData(&random, context, rtc.get(), textures); @@ -313,7 +313,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor desc.fConfig = kRGBA_8888_GrPixelConfig; sk_sp<GrTextureProxy> dataProxy = GrSurfaceProxy::MakeDeferred(*context->caps(), - context->textureProvider(), + context->resourceProvider(), desc, SkBudgeted::kYes, rgbaData.get(), 256 * sizeof(GrColor)); diff --git a/tests/ProxyConversionTest.cpp b/tests/ProxyConversionTest.cpp index 468ddd9cd8..9514a52c06 100644 --- a/tests/ProxyConversionTest.cpp +++ b/tests/ProxyConversionTest.cpp @@ -10,12 +10,12 @@ #include "Test.h" #if SK_SUPPORT_GPU +#include "GrRenderTargetProxy.h" +#include "GrResourceProvider.h" #include "GrSurfaceProxy.h" -#include "GrTextureProvider.h" #include "GrTextureProxy.h" -#include "GrRenderTargetProxy.h" -static sk_sp<GrSurfaceProxy> make_wrapped_FBO0(GrTextureProvider* provider, +static sk_sp<GrSurfaceProxy> make_wrapped_FBO0(GrResourceProvider* provider, skiatest::Reporter* reporter, const GrSurfaceDesc& desc) { GrBackendRenderTargetDesc backendDesc; @@ -33,7 +33,7 @@ static sk_sp<GrSurfaceProxy> make_wrapped_FBO0(GrTextureProvider* provider, return GrSurfaceProxy::MakeWrapped(std::move(defaultFBO)); } -static sk_sp<GrSurfaceProxy> make_wrapped_offscreen_rt(GrTextureProvider* provider, +static sk_sp<GrSurfaceProxy> make_wrapped_offscreen_rt(GrResourceProvider* provider, skiatest::Reporter* reporter, const GrSurfaceDesc& desc, SkBudgeted budgeted) { @@ -44,7 +44,7 @@ static sk_sp<GrSurfaceProxy> make_wrapped_offscreen_rt(GrTextureProvider* provid return GrSurfaceProxy::MakeWrapped(std::move(tex)); } -static sk_sp<GrSurfaceProxy> make_wrapped_texture(GrTextureProvider* provider, +static sk_sp<GrSurfaceProxy> make_wrapped_texture(GrResourceProvider* provider, const GrSurfaceDesc& desc, SkBudgeted budgeted) { sk_sp<GrTexture> tex(provider->createTexture(desc, budgeted)); @@ -55,7 +55,7 @@ static sk_sp<GrSurfaceProxy> make_wrapped_texture(GrTextureProvider* provider, // Test converting between RenderTargetProxies and TextureProxies for wrapped // Proxies DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyConversionTest, reporter, ctxInfo) { - GrTextureProvider* provider = ctxInfo.grContext()->textureProvider(); + GrResourceProvider* provider = ctxInfo.grContext()->resourceProvider(); GrSurfaceDesc desc; desc.fFlags = kRenderTarget_GrSurfaceFlag; @@ -119,7 +119,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyConversionTest, reporter, ctxInfo // Proxies DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DefferredProxyConversionTest, reporter, ctxInfo) { const GrCaps& caps = *ctxInfo.grContext()->caps(); - GrTextureProvider* texProvider = ctxInfo.grContext()->textureProvider(); + GrResourceProvider* resourceProvider = ctxInfo.grContext()->resourceProvider(); GrSurfaceDesc desc; desc.fFlags = kRenderTarget_GrSurfaceFlag; @@ -128,7 +128,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DefferredProxyConversionTest, reporter, ctxIn desc.fConfig = kRGBA_8888_GrPixelConfig; { - sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(texProvider, caps, desc, + sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(resourceProvider, caps, desc, SkBackingFit::kApprox, SkBudgeted::kYes)); @@ -142,7 +142,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DefferredProxyConversionTest, reporter, ctxIn } { - sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(texProvider, caps, desc, + sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(resourceProvider, caps, desc, SkBackingFit::kApprox, SkBudgeted::kYes)); @@ -158,7 +158,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DefferredProxyConversionTest, reporter, ctxIn { desc.fFlags = kNone_GrSurfaceFlags; // force no-RT - sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(texProvider, caps, desc, + sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(resourceProvider, caps, desc, SkBackingFit::kApprox, SkBudgeted::kYes)); diff --git a/tests/ProxyRefTest.cpp b/tests/ProxyRefTest.cpp index 83411d32c6..299ed23841 100644 --- a/tests/ProxyRefTest.cpp +++ b/tests/ProxyRefTest.cpp @@ -10,11 +10,11 @@ #include "Test.h" #if SK_SUPPORT_GPU -#include "GrSurfaceProxy.h" -#include "GrTextureProvider.h" -#include "GrTextureProxy.h" #include "GrRenderTargetPriv.h" #include "GrRenderTargetProxy.h" +#include "GrResourceProvider.h" +#include "GrSurfaceProxy.h" +#include "GrTextureProxy.h" int32_t GrIORefProxy::getProxyRefCnt_TestOnly() const { return fRefCnt; @@ -67,7 +67,7 @@ static void check_refs(skiatest::Reporter* reporter, SkASSERT(proxy->getPendingWriteCnt_TestOnly() == expectedNumWrites); } -static sk_sp<GrSurfaceProxy> make_deferred(const GrCaps& caps, GrTextureProvider* provider) { +static sk_sp<GrSurfaceProxy> make_deferred(const GrCaps& caps, GrResourceProvider* provider) { GrSurfaceDesc desc; desc.fFlags = kRenderTarget_GrSurfaceFlag; desc.fWidth = kWidthHeight; @@ -78,7 +78,7 @@ static sk_sp<GrSurfaceProxy> make_deferred(const GrCaps& caps, GrTextureProvider SkBackingFit::kApprox, SkBudgeted::kYes); } -static sk_sp<GrSurfaceProxy> make_wrapped(const GrCaps& caps, GrTextureProvider* provider) { +static sk_sp<GrSurfaceProxy> make_wrapped(const GrCaps& caps, GrResourceProvider* provider) { GrSurfaceDesc desc; desc.fFlags = kRenderTarget_GrSurfaceFlag; desc.fWidth = kWidthHeight; @@ -94,7 +94,7 @@ static sk_sp<GrSurfaceProxy> make_wrapped(const GrCaps& caps, GrTextureProvider* } DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) { - GrTextureProvider* provider = ctxInfo.grContext()->textureProvider(); + GrResourceProvider* provider = ctxInfo.grContext()->resourceProvider(); const GrCaps& caps = *ctxInfo.grContext()->caps(); // Currently the op itself takes a pending write and the render target op list does as well. diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp index 367ec0ce64..50af7f70ec 100644 --- a/tests/ProxyTest.cpp +++ b/tests/ProxyTest.cpp @@ -10,11 +10,11 @@ #include "Test.h" #if SK_SUPPORT_GPU -#include "GrSurfaceProxy.h" -#include "GrTextureProvider.h" -#include "GrTextureProxy.h" #include "GrRenderTargetPriv.h" #include "GrRenderTargetProxy.h" +#include "GrResourceProvider.h" +#include "GrSurfaceProxy.h" +#include "GrTextureProxy.h" // Check that the surface proxy's member vars are set as expected static void check_surface(skiatest::Reporter* reporter, @@ -38,7 +38,7 @@ static void check_surface(skiatest::Reporter* reporter, static void check_rendertarget(skiatest::Reporter* reporter, const GrCaps& caps, - GrTextureProvider* provider, + GrResourceProvider* provider, GrRenderTargetProxy* rtProxy, int numSamples, SkBackingFit fit, @@ -80,7 +80,7 @@ static void check_rendertarget(skiatest::Reporter* reporter, } static void check_texture(skiatest::Reporter* reporter, - GrTextureProvider* provider, + GrResourceProvider* provider, GrTextureProxy* texProxy, SkBackingFit fit, bool wasWrapped) { @@ -110,7 +110,7 @@ static void check_texture(skiatest::Reporter* reporter, DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) { - GrTextureProvider* provider = ctxInfo.grContext()->textureProvider(); + GrResourceProvider* provider = ctxInfo.grContext()->resourceProvider(); const GrCaps& caps = *ctxInfo.grContext()->caps(); const GrGpuResource::UniqueID kInvalidResourceID = GrGpuResource::UniqueID::InvalidID(); @@ -135,7 +135,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) { { sk_sp<GrTexture> tex; if (SkBackingFit::kApprox == fit) { - tex.reset(provider->createApproxTexture(desc)); + tex.reset(provider->createApproxTexture(desc, 0)); } else { tex.reset(provider->createTexture(desc, budgeted)); } @@ -169,7 +169,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) { { sk_sp<GrTexture> tex; if (SkBackingFit::kApprox == fit) { - tex.reset(provider->createApproxTexture(desc)); + tex.reset(provider->createApproxTexture(desc, 0)); } else { tex.reset(provider->createTexture(desc, budgeted)); } @@ -206,7 +206,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) { } DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { - GrTextureProvider* provider = ctxInfo.grContext()->textureProvider(); + GrResourceProvider* provider = ctxInfo.grContext()->resourceProvider(); const GrCaps& caps = *ctxInfo.grContext()->caps(); static const int kWidthHeight = 100; diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp index 214215419e..774f0af06a 100644 --- a/tests/ReadPixelsTest.cpp +++ b/tests/ReadPixelsTest.cpp @@ -16,7 +16,7 @@ #if SK_SUPPORT_GPU #include "GrContext.h" -#include "GrTextureProvider.h" +#include "GrResourceProvider.h" #include "SkGr.h" #endif @@ -481,7 +481,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Texture, reporter, ctxInfo) { desc.fHeight = DEV_H; desc.fConfig = kSkia8888_GrPixelConfig; desc.fOrigin = origin; - sk_sp<GrTexture> texture(ctxInfo.grContext()->textureProvider()->createTexture(desc, + sk_sp<GrTexture> texture(ctxInfo.grContext()->resourceProvider()->createTexture(desc, SkBudgeted::kNo)); test_readpixels_texture(reporter, texture.get()); } diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp index bfef33fa14..4fff156b98 100644 --- a/tests/ReadWriteAlphaTest.cpp +++ b/tests/ReadWriteAlphaTest.cpp @@ -12,9 +12,9 @@ #include "GrContext.h" #include "GrContextPriv.h" +#include "GrResourceProvider.h" #include "GrSurfaceContext.h" #include "GrSurfaceProxy.h" -#include "GrTextureProvider.h" #include "SkCanvas.h" #include "SkSurface.h" @@ -57,7 +57,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) { memset(alphaData, 0, X_SIZE * Y_SIZE); sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(*context->caps(), - context->textureProvider(), + context->resourceProvider(), desc, SkBudgeted::kNo, alphaData, 0)); @@ -161,7 +161,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) { } } sk_sp<GrTexture> texture( - context->textureProvider()->createTexture(desc, SkBudgeted::kNo, rgbaData, 0)); + context->resourceProvider()->createTexture(desc, SkBudgeted::kNo, rgbaData, 0)); if (!texture) { // We always expect to be able to create a RGBA texture if (!rt && kRGBA_8888_GrPixelConfig == desc.fConfig) { diff --git a/tests/RenderTargetContextTest.cpp b/tests/RenderTargetContextTest.cpp index 5917a2d9d4..632ae82838 100644 --- a/tests/RenderTargetContextTest.cpp +++ b/tests/RenderTargetContextTest.cpp @@ -71,7 +71,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RenderTargetContextTest, reporter, ctxInfo) { GrTextureProxy* tProxy = rtCtx->asTextureProxy(); REPORTER_ASSERT(reporter, tProxy); - GrTexture* tex = tProxy->instantiate(ctx->textureProvider()); + GrTexture* tex = tProxy->instantiate(ctx->resourceProvider()); REPORTER_ASSERT(reporter, tex); check_is_wrapped_status(reporter, rtCtx.get(), true); diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp index 39f64befcb..a2064ae557 100644 --- a/tests/ResourceCacheTest.cpp +++ b/tests/ResourceCacheTest.cpp @@ -100,15 +100,14 @@ DEF_GPUTEST_FOR_CONTEXTS(ResourceCacheStencilBuffers, &is_rendering_and_not_angl smallDesc.fHeight = 4; smallDesc.fSampleCnt = 0; - GrTextureProvider* cache = context->textureProvider(); GrResourceProvider* resourceProvider = context->resourceProvider(); // Test that two budgeted RTs with the same desc share a stencil buffer. - sk_sp<GrTexture> smallRT0(cache->createTexture(smallDesc, SkBudgeted::kYes)); + sk_sp<GrTexture> smallRT0(resourceProvider->createTexture(smallDesc, SkBudgeted::kYes)); if (smallRT0 && smallRT0->asRenderTarget()) { resourceProvider->attachStencilAttachment(smallRT0->asRenderTarget()); } - sk_sp<GrTexture> smallRT1(cache->createTexture(smallDesc, SkBudgeted::kYes)); + sk_sp<GrTexture> smallRT1(resourceProvider->createTexture(smallDesc, SkBudgeted::kYes)); if (smallRT1 && smallRT1->asRenderTarget()) { resourceProvider->attachStencilAttachment(smallRT1->asRenderTarget()); } @@ -120,7 +119,7 @@ DEF_GPUTEST_FOR_CONTEXTS(ResourceCacheStencilBuffers, &is_rendering_and_not_angl resourceProvider->attachStencilAttachment(smallRT1->asRenderTarget())); // An unbudgeted RT with the same desc should also share. - sk_sp<GrTexture> smallRT2(cache->createTexture(smallDesc, SkBudgeted::kNo)); + sk_sp<GrTexture> smallRT2(resourceProvider->createTexture(smallDesc, SkBudgeted::kNo)); if (smallRT2 && smallRT2->asRenderTarget()) { resourceProvider->attachStencilAttachment(smallRT2->asRenderTarget()); } @@ -137,7 +136,7 @@ DEF_GPUTEST_FOR_CONTEXTS(ResourceCacheStencilBuffers, &is_rendering_and_not_angl bigDesc.fWidth = 400; bigDesc.fHeight = 200; bigDesc.fSampleCnt = 0; - sk_sp<GrTexture> bigRT(cache->createTexture(bigDesc, SkBudgeted::kNo)); + sk_sp<GrTexture> bigRT(resourceProvider->createTexture(bigDesc, SkBudgeted::kNo)); if (bigRT && bigRT->asRenderTarget()) { resourceProvider->attachStencilAttachment(bigRT->asRenderTarget()); } @@ -151,7 +150,8 @@ DEF_GPUTEST_FOR_CONTEXTS(ResourceCacheStencilBuffers, &is_rendering_and_not_angl // An RT with a different sample count should not share. GrSurfaceDesc smallMSAADesc = smallDesc; smallMSAADesc.fSampleCnt = 4; - sk_sp<GrTexture> smallMSAART0(cache->createTexture(smallMSAADesc, SkBudgeted::kNo)); + sk_sp<GrTexture> smallMSAART0(resourceProvider->createTexture(smallMSAADesc, + SkBudgeted::kNo)); if (smallMSAART0 && smallMSAART0->asRenderTarget()) { resourceProvider->attachStencilAttachment(smallMSAART0->asRenderTarget()); } @@ -167,7 +167,8 @@ DEF_GPUTEST_FOR_CONTEXTS(ResourceCacheStencilBuffers, &is_rendering_and_not_angl resourceProvider->attachStencilAttachment(smallRT0->asRenderTarget()) != resourceProvider->attachStencilAttachment(smallMSAART0->asRenderTarget())); // A second MSAA RT should share with the first MSAA RT. - sk_sp<GrTexture> smallMSAART1(cache->createTexture(smallMSAADesc, SkBudgeted::kNo)); + sk_sp<GrTexture> smallMSAART1(resourceProvider->createTexture(smallMSAADesc, + SkBudgeted::kNo)); if (smallMSAART1 && smallMSAART1->asRenderTarget()) { resourceProvider->attachStencilAttachment(smallMSAART1->asRenderTarget()); } @@ -183,9 +184,9 @@ DEF_GPUTEST_FOR_CONTEXTS(ResourceCacheStencilBuffers, &is_rendering_and_not_angl smallMSAART0 && smallMSAART0->asRenderTarget() && smallMSAART0->asRenderTarget()->numColorSamples() < 8) { smallMSAADesc.fSampleCnt = 8; - smallMSAART1.reset(cache->createTexture(smallMSAADesc, SkBudgeted::kNo)); + smallMSAART1.reset(resourceProvider->createTexture(smallMSAADesc, SkBudgeted::kNo)); sk_sp<GrTexture> smallMSAART1( - cache->createTexture(smallMSAADesc, SkBudgeted::kNo)); + resourceProvider->createTexture(smallMSAADesc, SkBudgeted::kNo)); if (smallMSAART1 && smallMSAART1->asRenderTarget()) { resourceProvider->attachStencilAttachment(smallMSAART1->asRenderTarget()); } @@ -222,11 +223,11 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheWrappedResources, reporter, ctxI desc.fHeight = kH; desc.fTextureHandle = texHandles[0]; - sk_sp<GrTexture> borrowed(context->textureProvider()->wrapBackendTexture( + sk_sp<GrTexture> borrowed(context->resourceProvider()->wrapBackendTexture( desc, kBorrow_GrWrapOwnership)); desc.fTextureHandle = texHandles[1]; - sk_sp<GrTexture> adopted(context->textureProvider()->wrapBackendTexture( + sk_sp<GrTexture> adopted(context->resourceProvider()->wrapBackendTexture( desc, kAdopt_GrWrapOwnership)); REPORTER_ASSERT(reporter, borrowed != nullptr && adopted != nullptr); @@ -1383,7 +1384,7 @@ DEF_GPUTEST(ResourceCacheMisc, reporter, factory) { } //////////////////////////////////////////////////////////////////////////////// -static sk_sp<GrTexture> make_normal_texture(GrTextureProvider* provider, +static sk_sp<GrTexture> make_normal_texture(GrResourceProvider* provider, GrSurfaceFlags flags, int width, int height, int sampleCnt) { @@ -1397,7 +1398,7 @@ static sk_sp<GrTexture> make_normal_texture(GrTextureProvider* provider, return sk_sp<GrTexture>(provider->createTexture(desc, SkBudgeted::kYes)); } -static sk_sp<GrTexture> make_mipmap_texture(GrTextureProvider* provider, +static sk_sp<GrTexture> make_mipmap_texture(GrResourceProvider* provider, GrSurfaceFlags flags, int width, int height, int sampleCnt) { @@ -1440,7 +1441,7 @@ static sk_sp<GrTexture> make_mipmap_texture(GrTextureProvider* provider, // Texture-only, both-RT-and-Texture and MIPmapped DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GPUMemorySize, reporter, ctxInfo) { GrContext* context = ctxInfo.grContext(); - GrTextureProvider* provider = context->textureProvider(); + GrResourceProvider* provider = context->resourceProvider(); static const int kSize = 64; diff --git a/tests/SRGBMipMapTest.cpp b/tests/SRGBMipMapTest.cpp index 7865690cdf..e01d676554 100644 --- a/tests/SRGBMipMapTest.cpp +++ b/tests/SRGBMipMapTest.cpp @@ -10,7 +10,7 @@ #include "GrCaps.h" #include "GrContext.h" #include "GrRenderTargetContext.h" -#include "GrTextureProvider.h" +#include "GrResourceProvider.h" #include "gl/GrGLGpu.h" #include "SkCanvas.h" #include "SkSurface.h" @@ -118,8 +118,8 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SRGBMipMaps, reporter, ctxInfo) { desc.fWidth = texS; desc.fHeight = texS; - GrTextureProvider* texProvider = context->textureProvider(); - sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(*context->caps(), texProvider, + GrResourceProvider* resourceProvider = context->resourceProvider(); + sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(*context->caps(), resourceProvider, desc, SkBudgeted::kNo, texData, 0); diff --git a/tests/SRGBReadWritePixelsTest.cpp b/tests/SRGBReadWritePixelsTest.cpp index 847dafc5b8..5addc2e7fd 100644 --- a/tests/SRGBReadWritePixelsTest.cpp +++ b/tests/SRGBReadWritePixelsTest.cpp @@ -9,7 +9,7 @@ #if SK_SUPPORT_GPU #include "GrCaps.h" #include "GrContext.h" -#include "GrTextureProvider.h" +#include "GrResourceProvider.h" #include "SkCanvas.h" #include "SkSurface.h" @@ -163,7 +163,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SRGBReadWritePixels, reporter, ctxInfo) { desc.fConfig = kSRGBA_8888_GrPixelConfig; if (context->caps()->isConfigRenderable(desc.fConfig, false) && context->caps()->isConfigTexturable(desc.fConfig)) { - sk_sp<GrTexture> tex(context->textureProvider()->createTexture(desc, SkBudgeted::kNo)); + sk_sp<GrTexture> tex(context->resourceProvider()->createTexture(desc, SkBudgeted::kNo)); if (!tex) { ERRORF(reporter, "Could not create SRGBA texture."); return; @@ -202,7 +202,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SRGBReadWritePixels, reporter, ctxInfo) { } desc.fConfig = kRGBA_8888_GrPixelConfig; - tex.reset(context->textureProvider()->createTexture(desc, SkBudgeted::kNo)); + tex.reset(context->resourceProvider()->createTexture(desc, SkBudgeted::kNo)); if (!tex) { ERRORF(reporter, "Could not create RGBA texture."); return; diff --git a/tests/SpecialImageTest.cpp b/tests/SpecialImageTest.cpp index 82dd019dea..c033ebc529 100644 --- a/tests/SpecialImageTest.cpp +++ b/tests/SpecialImageTest.cpp @@ -234,7 +234,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_MakeTexture, reporter, ctxInfo) const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bm.info(), *context->caps()); sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(*context->caps(), - context->textureProvider(), + context->resourceProvider(), desc, SkBudgeted::kNo, bm.getPixels(), bm.rowBytes())); if (!proxy) { @@ -268,7 +268,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, ctxInfo) { const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bm.info(), *context->caps()); sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(*context->caps(), - context->textureProvider(), + context->resourceProvider(), desc, SkBudgeted::kNo, bm.getPixels(), bm.rowBytes())); if (!proxy) { @@ -308,7 +308,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_DeferredGpu, reporter, ctxInfo) desc.fHeight = kFullSize; sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(*context->caps(), - context->textureProvider(), + context->resourceProvider(), desc, SkBudgeted::kNo, bm.getPixels(), 0)); if (!proxy) { diff --git a/tests/TestUtils.cpp b/tests/TestUtils.cpp index 0e6e7b0d07..7ac18360da 100644 --- a/tests/TestUtils.cpp +++ b/tests/TestUtils.cpp @@ -107,7 +107,7 @@ void test_copy_to_surface(skiatest::Reporter* reporter, GrContext* context, copySrcDesc.fFlags = flags; sk_sp<GrTextureProxy> src(GrSurfaceProxy::MakeDeferred(*context->caps(), - context->textureProvider(), + context->resourceProvider(), copySrcDesc, SkBudgeted::kYes, pixels.get(), 0)); dstContext->copy(src.get()); diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp index 4df328cd62..ef3cc48e57 100644 --- a/tools/gpu/GrTest.cpp +++ b/tools/gpu/GrTest.cpp @@ -130,7 +130,7 @@ sk_sp<SkImage> GrContext::getFontAtlasImage_ForTesting(GrMaskFormat format) { return nullptr; } - GrTexture* tex = proxy->instantiate(this->textureProvider()); + GrTexture* tex = proxy->instantiate(this->resourceProvider()); if (!tex) { return nullptr; } |