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>
diff --git a/src/gpu/GrBitmapTextureMaker.cpp b/src/gpu/GrBitmapTextureMaker.cpp
index cff052f..24cb05f 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* 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 @@
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 091d776..6716fde 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 @@
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 c69f79e..a0682f4 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -413,11 +413,11 @@
// 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 @@
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 @@
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> 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 cc7cba0..49b8c96 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -295,7 +295,7 @@
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 @@
return false;
}
}
- GrTexture* texture = tempProxy->instantiate(this->textureProvider());
+ GrTexture* texture = tempProxy->instantiate(this->resourceProvider());
if (!texture) {
return false;
}
@@ -621,7 +621,7 @@
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 @@
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 @@
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 @@
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<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 @@
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 99b3a09..95f30c0 100644
--- a/src/gpu/GrCoordTransform.cpp
+++ b/src/gpu/GrCoordTransform.cpp
@@ -77,7 +77,7 @@
// 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 e9fd356..143bdd8 100644
--- a/src/gpu/GrDrawOpAtlas.cpp
+++ b/src/gpu/GrDrawOpAtlas.cpp
@@ -28,7 +28,7 @@
// 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 @@
// 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 @@
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 3a7110e..d670e16 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -219,7 +219,7 @@
if (!pr && allowSW) {
if (!fSoftwarePathRenderer) {
fSoftwarePathRenderer =
- new GrSoftwarePathRenderer(fContext->textureProvider(),
+ new GrSoftwarePathRenderer(fContext->resourceProvider(),
fOptionsForPathRendererChain.fAllowPathMaskCaching);
}
if (fSoftwarePathRenderer->canDrawPath(args)) {
@@ -256,7 +256,7 @@
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 201b22c..3abe8f8 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -122,17 +122,17 @@
}
/**
- * 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 @@
// 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 8214d2c..2365c21 100644
--- a/src/gpu/GrProcessor.cpp
+++ b/src/gpu/GrProcessor.cpp
@@ -208,18 +208,18 @@
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 @@
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 @@
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 8b6de51..1ddf8df 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -112,7 +112,7 @@
}
GrRenderTarget* GrRenderTargetContext::instantiate() {
- return fRenderTargetProxy->instantiate(fContext->textureProvider());
+ return fRenderTargetProxy->instantiate(fContext->resourceProvider());
}
GrTextureProxy* GrRenderTargetContext::asTextureProxy() {
@@ -144,14 +144,14 @@
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 @@
// 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 @@
// 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 @@
// 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 @@
// 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 34d67be..44f23d4 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 @@
: 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 272c6a6..636f16c 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 c0d1a50..5ecaac3 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 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 @@
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 @@
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 @@
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 @@
*/
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 @@
*/
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 @@
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 073aec4..f7e518b 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -151,7 +151,7 @@
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 89d8842..4c744fd 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 b51ce63..eb5495c 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 @@
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 @@
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 @@
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 7dec4be..c8d2f8b 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 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 @@
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 b8fc56d..f95c312 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 @@
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 @@
}
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 @@
}
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 @@
#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<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(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 27f8d6d..63d9a11 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 @@
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* 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 75c9e30..ffcddbc 100644
--- a/src/gpu/GrTextureContext.cpp
+++ b/src/gpu/GrTextureContext.cpp
@@ -77,7 +77,7 @@
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 @@
#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 @@
}
// 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 @@
}
// 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 ac89af7..bd0840b 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 @@
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 @@
}
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 3790f27..0000000
--- 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 dd139cc..0000000
--- 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 9a65140..0b34309 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 @@
: 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 132b680..683bd63 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 6eaba4c..c3d197e 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 @@
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* 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 @@
}
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<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 bbce742..8283910 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -127,7 +127,7 @@
: 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 6a4cca5..d629902 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -219,7 +219,7 @@
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 19f5e2a..a5f68d9 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -234,7 +234,7 @@
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 @@
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 @@
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 acfc0d1..01cad66 100644
--- a/src/gpu/effects/GrSingleTextureEffect.cpp
+++ b/src/gpu/effects/GrSingleTextureEffect.cpp
@@ -52,7 +52,7 @@
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 @@
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 @@
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 39bc3cc..2ac6af8 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -423,7 +423,7 @@
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 1791b20..df36e65 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 @@
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 @@
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 e09e185..78ac9ba 100644
--- a/src/gpu/effects/GrYUVEffect.cpp
+++ b/src/gpu/effects/GrYUVEffect.cpp
@@ -159,10 +159,10 @@
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 6af442e..524928b 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 {