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,
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));
}
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,
, 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);
if (permutationsProxy && noiseProxy) {
sk_sp<GrFragmentProcessor> inner(
- GrPerlinNoise2Effect::Make(args.fContext->textureProvider(),
+ GrPerlinNoise2Effect::Make(args.fContext->resourceProvider(),
fType,
fNumOctaves,
fStitchTiles,
desc.fHeight = kTexHeight;
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(*context->caps(),
- context->textureProvider(),
+ context->resourceProvider(),
desc, SkBudgeted::kYes,
fETC1Data.get(), 0);
if (!proxy) {
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) {
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()));
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]) {
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());
"$_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",
class GrPaint;
class GrFragmentProcessor;
class GrRenderTarget;
+class GrResourceProvider;
class GrTexture;
class GrTextureProxy;
-class GrTextureProvider;
class SkBitmap;
class SkBlitter;
class SkCachedData;
* 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&,
class GrResourceProvider;
class GrTextBlobCache;
class GrTextContext;
-class GrTextureProvider;
class GrSamplerParams;
class GrVertexBuffer;
class GrSwizzle;
*/
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.
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;
// 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 {
class GrContext;
class GrCoordTransform;
class GrInvariantOutput;
-class GrTextureProvider;
+class GrResourceProvider;
class GrTextureProxy;
/**
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);
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(); }
#include "GrSurfaceProxy.h"
#include "GrTypes.h"
-class GrTextureProvider;
+class GrResourceProvider;
// This class delays the acquisition of RenderTargets until they are actually
// required
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; }
class GrCaps;
class GrRenderTargetOpList;
class GrRenderTargetProxy;
+class GrResourceProvider;
class GrSurfaceContext;
class GrSurfaceProxyPriv;
class GrTextureOpList;
-class GrTextureProvider;
class GrTextureProxy;
//#define SK_DISABLE_DEFERRED_PROXIES 1
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);
*/
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.
#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 {
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
// 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;
}
#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"
}
desc.fConfig = config;
- return ctx->textureProvider()->createTexture(desc, SkBudgeted::kYes, rawStart, 0);
+ return ctx->resourceProvider()->createTexture(desc, SkBudgeted::kYes, rawStart, 0);
}
#endif
}
};
-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;
}
// 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;
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);
}
}
}
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);
}
}
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,
return false;
}
-bool SkMaskFilter::directFilterMaskGPU(GrTextureProvider* texProvider,
+bool SkMaskFilter::directFilterMaskGPU(GrResourceProvider* resourceProvider,
GrRenderTargetContext* renderTargetContext,
GrPaint&&,
const GrClip&,
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;
}
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;
}
}
// Reading back to an SkBitmap ends deferral
- GrTexture* texture = fTextureProxy->instantiate(fContext->textureProvider());
+ GrTexture* texture = fTextureProxy->instantiate(fContext->resourceProvider());
if (!texture) {
return false;
}
, 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);
#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"
///////////////////////////////////////////////////////////////////////////////
-GrCircleBlurFragmentProcessor::GrCircleBlurFragmentProcessor(GrTextureProvider* textureProvider,
+GrCircleBlurFragmentProcessor::GrCircleBlurFragmentProcessor(GrResourceProvider* resourceProvider,
const SkRect& circle,
float textureRadius,
float solidRadius,
, 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);
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) {
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;
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));
//////////////////////////////////////////////////////////////////////////////
-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)));
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
#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.
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.
* 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);
#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"
const SkIRect& clipBounds,
const SkMatrix& ctm,
SkRect* maskRect) const override;
- bool directFilterMaskGPU(GrTextureProvider* texProvider,
+ bool directFilterMaskGPU(GrResourceProvider* resourceProvider,
GrRenderTargetContext* renderTargetContext,
GrPaint&&,
const GrClip&,
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);
return nullptr;
}
- sk_sp<GrTextureProxy> blurProfile(CreateBlurProfileTexture(textureProvider, sigma));
+ sk_sp<GrTextureProxy> blurProfile(CreateBlurProfileTexture(resourceProvider, sigma));
if (!blurProfile) {
return nullptr;
}
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));
}
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;
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;
}
// 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);
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);
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,
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;
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,
}
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(
if (!mask) {
return nullptr;
}
- context->textureProvider()->assignUniqueKeyToTexture(key, mask.get());
+ context->resourceProvider()->assignUniqueKeyToTexture(key, mask.get());
}
return GrSurfaceProxy::MakeWrapped(std::move(mask));
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);
}
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);
}
: 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)
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,
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));
}
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,
, 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);
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,
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>();
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:
// 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;
}
const SkIRect& clipBounds,
const SkMatrix& ctm,
SkRect* maskRect) const override;
- bool directFilterMaskGPU(GrTextureProvider* texProvider,
+ bool directFilterMaskGPU(GrResourceProvider* resourceProvider,
GrRenderTargetContext* drawContext,
GrPaint&&,
const GrClip&,
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,
const SkIRect& clipBounds,
const SkMatrix& ctm,
SkRect* maskRect) const override;
- bool directFilterMaskGPU(GrTextureProvider* texProvider,
+ bool directFilterMaskGPU(GrResourceProvider* resourceProvider,
GrRenderTargetContext* drawContext,
GrPaint&&,
const GrClip&,
return true;
}
-bool SkSpotShadowMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider,
+bool SkSpotShadowMaskFilterImpl::directFilterMaskGPU(GrResourceProvider* resourceProvider,
GrRenderTargetContext* rtContext,
GrPaint&& paint,
const GrClip& clip,
#include "GrContext.h"
#include "GrGpuResourcePriv.h"
-#include "GrTextureProvider.h"
+#include "GrResourceProvider.h"
#include "SkBitmap.h"
#include "SkGrPriv.h"
#include "SkPixelRef.h"
GrTexture* tex = nullptr;
if (fOriginalKey.isValid()) {
- tex = this->context()->textureProvider()->findAndRefTextureByUniqueKey(fOriginalKey);
+ tex = this->context()->resourceProvider()->findAndRefTextureByUniqueKey(fOriginalKey);
if (tex) {
return tex;
}
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;
#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"
return;
}
- if (maskFilter->directFilterMaskGPU(context->textureProvider(),
+ if (maskFilter->directFilterMaskGPU(context->resourceProvider(),
renderTargetContext,
std::move(paint),
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));
}
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;
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));
}
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;
}
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,
return false;
}
}
- GrTexture* texture = tempProxy->instantiate(this->textureProvider());
+ GrTexture* texture = tempProxy->instantiate(this->resourceProvider());
if (!texture) {
return false;
}
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) {
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;
}
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;
}
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;
}
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;
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;
// 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();
// 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;
}
// 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;
}
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;
}
if (!pr && allowSW) {
if (!fSoftwarePathRenderer) {
fSoftwarePathRenderer =
- new GrSoftwarePathRenderer(fContext->textureProvider(),
+ new GrSoftwarePathRenderer(fContext->resourceProvider(),
fOptionsForPathRendererChain.fAllowPathMaskCaching);
}
if (fSoftwarePathRenderer->canDrawPath(args)) {
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;
}
}
/**
- * 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&);
// 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 {
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,
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;
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());
}
GrRenderTarget* GrRenderTargetContext::instantiate() {
- return fRenderTargetProxy->instantiate(fContext->textureProvider());
+ return fRenderTargetProxy->instantiate(fContext->resourceProvider());
}
GrTextureProxy* GrRenderTargetContext::asTextureProxy() {
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;
}
// 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;
}
// 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;
}
// 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;
}
// 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;
}
#include "GrGpuResourcePriv.h"
#include "GrRenderTargetOpList.h"
#include "GrRenderTargetPriv.h"
-#include "GrTextureProvider.h"
+#include "GrResourceProvider.h"
#include "GrTextureRenderTargetProxy.h"
// Deferred version
: 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;
}
#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,
#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;
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);
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
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,
};
/**
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
*/
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.
*/
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,
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
return nullptr;
}
- return sk_ref_sp(tProxy->instantiate(context->textureProvider()));
+ return sk_ref_sp(tProxy->instantiate(context->resourceProvider()));
}
void GrSWMaskHelper::DrawToTargetWithShapeMask(GrTexture* texture,
#include "GrColor.h"
#include "GrRenderTargetContext.h"
-#include "GrTextureProvider.h"
#include "SkAutoPixmapStorage.h"
#include "SkBitmap.h"
#include "SkDraw.h"
class GrClip;
class GrPaint;
class GrShape;
-class GrTextureProvider;
class GrStyle;
class GrTexture;
struct GrUserStencilSettings;
#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);
}
bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
GR_AUDIT_TRAIL_AUTO_FRAME(args.fRenderTargetContext->auditTrail(),
"GrSoftwarePathRenderer::onDrawPath");
- if (!fTexProvider) {
+ if (!fResourceProvider) {
return false;
}
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;
return false;
}
if (useCache) {
- fTexProvider->assignUniqueKeyToTexture(maskKey, texture.get());
+ fResourceProvider->assignUniqueKeyToTexture(maskKey, texture.get());
}
}
if (inverseFilled) {
#include "GrPathRenderer.h"
-class GrTextureProvider;
+class GrResourceProvider;
/**
* This class uses the software side to render a path to an SkBitmap and
*/
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,
bool onDrawPath(const DrawPathArgs&) override;
private:
- GrTextureProvider* fTexProvider;
+ GrResourceProvider* fResourceProvider;
bool fAllowCaching;
typedef GrPathRenderer INHERITED;
#include "GrContextPriv.h"
#include "GrGpuResourcePriv.h"
#include "GrOpList.h"
+#include "GrResourceProvider.h"
#include "GrSurfaceContext.h"
-#include "GrTextureProvider.h"
#include "GrTextureRenderTargetProxy.h"
#include "SkMathPriv.h"
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;
}
if (caps.reuseScratchTextures() || fDesc.fFlags & kRenderTarget_GrSurfaceFlag) {
- return SkTMax(GrTextureProvider::kMinScratchTextureSize, GrNextPow2(fDesc.fWidth));
+ return SkTMax(GrResourceProvider::kMinScratchTextureSize, GrNextPow2(fDesc.fWidth));
}
return fDesc.fWidth;
}
if (caps.reuseScratchTextures() || fDesc.fFlags & kRenderTarget_GrSurfaceFlag) {
- return SkTMax(GrTextureProvider::kMinScratchTextureSize, GrNextPow2(fDesc.fHeight));
+ return SkTMax(GrResourceProvider::kMinScratchTextureSize, GrNextPow2(fDesc.fHeight));
}
return fDesc.fHeight;
#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,
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) {
}
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));
}
#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,
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;
}
GrTexture* copy = CopyOnGpu(texture, contentArea, copyParams);
if (copy) {
if (key.isValid()) {
- context->textureProvider()->assignUniqueKeyToTexture(key, copy);
+ context->resourceProvider()->assignUniqueKeyToTexture(key, copy);
this->didCacheCopy(key);
}
}
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;
}
#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;
}
}
// 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;
}
}
// 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;
}
#include "GrContext.h"
#include "GrGpu.h"
-#include "GrTextureProvider.h"
+#include "GrResourceProvider.h"
GrTexture* GrTextureMaker::refTextureForParams(const GrSamplerParams& params,
SkColorSpace* dstColorSpace,
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;
}
}
if (copyKey.isValid()) {
- fContext->textureProvider()->assignUniqueKeyToTexture(copyKey, result);
+ fContext->resourceProvider()->assignUniqueKeyToTexture(copyKey, result);
this->didCacheCopy(copyKey);
}
return result;
+++ /dev/null
-/*
- * 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;
-}
+++ /dev/null
-/*
- * 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
#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)
: 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;
}
#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>,
#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"
desc = GrImageInfoToSurfaceDesc(pmap->info(), *caps);
}
- return ctx->textureProvider()->createTexture(desc, budgeted, pmap->addr(),
+ return ctx->resourceProvider()->createTexture(desc, budgeted, pmap->addr(),
pmap->rowBytes());
}
}
{
- 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);
}
}
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);
}
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());
}
}
: 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>();
desc.fConfig = kConfig;
sk_sp<GrTextureProxy> dataProxy = GrSurfaceProxy::MakeDeferred(*context->caps(),
- context->textureProvider(),
+ context->resourceProvider(),
desc, SkBudgeted::kYes, data, 0);
if (!dataProxy) {
return;
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
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) {
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) {
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);
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);
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);
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);
#include "GrContextPriv.h"
#include "GrResourceProvider.h"
#include "GrSurfaceContext.h"
-#include "GrTextureProvider.h"
#include "SkGr.h"
#include "SkPixelRef.h"
#include "SkTSearch.h"
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));
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();
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>();
class GrContext;
class GrFragmentProcessor;
-class GrTextureProvider;
class GrTextureProxy;
namespace GrYUVEffect {
#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"
}
// 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;
}
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;
}
}
// 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;
#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) {
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);
#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"
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));
#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;
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) {
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");
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),
#include "GrContext.h"
#include "GrGpu.h"
#include "GrRenderTarget.h"
+#include "GrResourceProvider.h"
#include "GrTexture.h"
-#include "GrTextureProvider.h"
#include "GrSurfacePriv.h"
#include "Test.h"
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());
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());
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());
#if SK_SUPPORT_GPU
#include "GrContext.h"
-#include "GrTextureProvider.h"
+#include "GrResourceProvider.h"
static GrTexture* create_texture(GrContext* context) {
SkBitmap srcBM = create_bm();
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) {
desc.fHeight = kFullSize;
return GrSurfaceProxy::MakeDeferred(*context->caps(),
- context->textureProvider(),
+ context->resourceProvider(),
desc, SkBudgeted::kYes,
srcBM.getPixels(),
srcBM.rowBytes());
#include "GrFragmentProcessor.h"
#include "GrRenderTargetContext.h"
+#include "GrResourceProvider.h"
#include "GrTexture.h"
-#include "GrTextureProvider.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
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,
#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>
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);
return;
}
- GrTexture* texture = proxy->instantiate(context->textureProvider());
+ GrTexture* texture = proxy->instantiate(context->resourceProvider());
REPORTER_ASSERT(reporter, texture);
if (!texture) {
return;
}
GrSurface* copySurface = dstContext->asTextureProxy()->instantiate(
- context->textureProvider());
+ context->resourceProvider());
REPORTER_ASSERT(reporter, copySurface);
if (!copySurface) {
return;
// 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);
}
}
#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);
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);
#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"
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()));
{
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));
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.
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);
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));
#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;
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) {
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));
// 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;
// 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;
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));
}
{
- sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(texProvider, caps, desc,
+ sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(resourceProvider, caps, desc,
SkBackingFit::kApprox,
SkBudgeted::kYes));
{
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));
#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;
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;
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;
}
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.
#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,
static void check_rendertarget(skiatest::Reporter* reporter,
const GrCaps& caps,
- GrTextureProvider* provider,
+ GrResourceProvider* provider,
GrRenderTargetProxy* rtProxy,
int numSamples,
SkBackingFit fit,
}
static void check_texture(skiatest::Reporter* reporter,
- GrTextureProvider* provider,
+ GrResourceProvider* provider,
GrTextureProxy* texProxy,
SkBackingFit fit,
bool wasWrapped) {
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();
{
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));
}
{
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));
}
}
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;
#if SK_SUPPORT_GPU
#include "GrContext.h"
-#include "GrTextureProvider.h"
+#include "GrResourceProvider.h"
#include "SkGr.h"
#endif
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());
}
#include "GrContext.h"
#include "GrContextPriv.h"
+#include "GrResourceProvider.h"
#include "GrSurfaceContext.h"
#include "GrSurfaceProxy.h"
-#include "GrTextureProvider.h"
#include "SkCanvas.h"
#include "SkSurface.h"
memset(alphaData, 0, X_SIZE * Y_SIZE);
sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(*context->caps(),
- context->textureProvider(),
+ context->resourceProvider(),
desc,
SkBudgeted::kNo,
alphaData, 0));
}
}
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) {
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);
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());
}
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());
}
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());
}
// 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());
}
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());
}
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());
}
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);
}
////////////////////////////////////////////////////////////////////////////////
-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) {
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) {
// 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;
#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"
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);
#if SK_SUPPORT_GPU
#include "GrCaps.h"
#include "GrContext.h"
-#include "GrTextureProvider.h"
+#include "GrResourceProvider.h"
#include "SkCanvas.h"
#include "SkSurface.h"
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;
}
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;
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) {
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) {
desc.fHeight = kFullSize;
sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(*context->caps(),
- context->textureProvider(),
+ context->resourceProvider(),
desc, SkBudgeted::kNo,
bm.getPixels(), 0));
if (!proxy) {
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());
return nullptr;
}
- GrTexture* tex = proxy->instantiate(this->textureProvider());
+ GrTexture* tex = proxy->instantiate(this->resourceProvider());
if (!tex) {
return nullptr;
}