aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/SkSpecialImage.cpp4
-rw-r--r--src/effects/GrCircleBlurFragmentProcessor.cpp16
-rw-r--r--src/effects/GrCircleBlurFragmentProcessor.h2
-rw-r--r--src/effects/SkBlurMaskFilter.cpp33
-rw-r--r--src/effects/SkPerlinNoiseShader.cpp4
-rw-r--r--src/effects/SkTableColorFilter.cpp14
-rw-r--r--src/effects/gradients/SkGradientShader.cpp4
-rw-r--r--src/gpu/GrContext.cpp6
-rw-r--r--src/gpu/GrRenderTargetContext.h2
-rw-r--r--src/gpu/GrResourceProvider.cpp3
-rw-r--r--src/gpu/GrResourceProvider.h13
-rw-r--r--src/gpu/GrSoftwarePathRenderer.cpp6
-rw-r--r--src/gpu/GrSurfaceProxy.cpp24
-rw-r--r--src/gpu/SkGpuDevice.cpp22
-rw-r--r--src/gpu/SkGr.cpp21
-rw-r--r--src/gpu/SkGr.h8
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.cpp3
-rw-r--r--src/gpu/effects/GrTextureStripAtlas.cpp2
-rw-r--r--src/gpu/text/GrStencilAndCoverTextContext.cpp26
-rw-r--r--src/gpu/text/GrStencilAndCoverTextContext.h2
-rw-r--r--src/gpu/text/GrTextUtils.cpp1
21 files changed, 118 insertions, 98 deletions
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index 331ee66fb6..411b0ea289 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -105,7 +105,7 @@ sk_sp<SkSpecialImage> SkSpecialImage::makeTextureImage(GrContext* context) {
// TODO: this is a tight copy of 'bmp' but it doesn't have to be (given SkSpecialImage's
// semantics). Since this is cached though we would have to bake the fit into the cache key.
- sk_sp<GrTextureProxy> proxy = GrMakeCachedBitmapProxy(context, bmp);
+ sk_sp<GrTextureProxy> proxy = GrMakeCachedBitmapProxy(context->resourceProvider(), bmp);
if (!proxy) {
return nullptr;
}
@@ -249,7 +249,7 @@ public:
#if SK_SUPPORT_GPU
sk_sp<GrTextureProxy> onAsTextureProxyRef(GrContext* context) const override {
if (context) {
- return GrMakeCachedBitmapProxy(context, fBitmap);
+ return GrMakeCachedBitmapProxy(context->resourceProvider(), fBitmap);
}
return nullptr;
diff --git a/src/effects/GrCircleBlurFragmentProcessor.cpp b/src/effects/GrCircleBlurFragmentProcessor.cpp
index 301eb27148..4b9ab26644 100644
--- a/src/effects/GrCircleBlurFragmentProcessor.cpp
+++ b/src/effects/GrCircleBlurFragmentProcessor.cpp
@@ -260,7 +260,7 @@ static uint8_t* create_half_plane_profile(int profileWidth) {
return profile;
}
-static sk_sp<GrTextureProxy> create_profile_texture(GrContext* context,
+static sk_sp<GrTextureProxy> create_profile_texture(GrResourceProvider* resourceProvider,
const SkRect& circle,
float sigma,
float* solidRadius, float* textureRadius) {
@@ -299,7 +299,7 @@ static sk_sp<GrTextureProxy> create_profile_texture(GrContext* context,
builder[0] = sigmaToCircleRRatioFixed;
builder.finish();
- sk_sp<GrTextureProxy> blurProfile = context->resourceProvider()->findProxyByUniqueKey(key);
+ sk_sp<GrTextureProxy> blurProfile = resourceProvider->findProxyByUniqueKey(key);
if (!blurProfile) {
static constexpr int kProfileTextureWidth = 512;
GrSurfaceDesc texDesc;
@@ -317,13 +317,13 @@ static sk_sp<GrTextureProxy> create_profile_texture(GrContext* context,
kProfileTextureWidth));
}
- blurProfile = GrSurfaceProxy::MakeDeferred(*context->caps(), context->resourceProvider(),
+ blurProfile = GrSurfaceProxy::MakeDeferred(resourceProvider,
texDesc, SkBudgeted::kYes, profile.get(), 0);
if (!blurProfile) {
return nullptr;
}
- context->resourceProvider()->assignUniqueKeyToProxy(key, blurProfile.get());
+ resourceProvider->assignUniqueKeyToProxy(key, blurProfile.get());
}
return blurProfile;
@@ -331,16 +331,16 @@ static sk_sp<GrTextureProxy> create_profile_texture(GrContext* context,
//////////////////////////////////////////////////////////////////////////////
-sk_sp<GrFragmentProcessor> GrCircleBlurFragmentProcessor::Make(GrContext* context,
+sk_sp<GrFragmentProcessor> GrCircleBlurFragmentProcessor::Make(GrResourceProvider* resourceProvider,
const SkRect& circle, float sigma) {
float solidRadius;
float textureRadius;
- sk_sp<GrTextureProxy> profile(create_profile_texture(context, circle, sigma,
+ sk_sp<GrTextureProxy> profile(create_profile_texture(resourceProvider, circle, sigma,
&solidRadius, &textureRadius));
if (!profile) {
return nullptr;
}
- return sk_sp<GrFragmentProcessor>(new GrCircleBlurFragmentProcessor(context->resourceProvider(),
+ return sk_sp<GrFragmentProcessor>(new GrCircleBlurFragmentProcessor(resourceProvider,
circle,
textureRadius, solidRadius,
std::move(profile)));
@@ -355,7 +355,7 @@ sk_sp<GrFragmentProcessor> GrCircleBlurFragmentProcessor::TestCreate(GrProcessor
SkScalar wh = d->fRandom->nextRangeScalar(100.f, 1000.f);
SkScalar sigma = d->fRandom->nextRangeF(1.f,10.f);
SkRect circle = SkRect::MakeWH(wh, wh);
- return GrCircleBlurFragmentProcessor::Make(d->context(), circle, sigma);
+ return GrCircleBlurFragmentProcessor::Make(d->context()->resourceProvider(), circle, sigma);
}
#endif
diff --git a/src/effects/GrCircleBlurFragmentProcessor.h b/src/effects/GrCircleBlurFragmentProcessor.h
index 68d88cf2e0..c6cf3ba923 100644
--- a/src/effects/GrCircleBlurFragmentProcessor.h
+++ b/src/effects/GrCircleBlurFragmentProcessor.h
@@ -34,7 +34,7 @@ public:
return str;
}
- static sk_sp<GrFragmentProcessor> Make(GrContext*, 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.
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 24e56f37ff..2bf6b90b8a 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -772,7 +772,8 @@ public:
const char* name() const override { return "RectBlur"; }
- static sk_sp<GrFragmentProcessor> Make(GrContext* context, const SkRect& rect, float sigma) {
+ static sk_sp<GrFragmentProcessor> Make(GrResourceProvider* resourceProvider,
+ const SkRect& rect, float sigma) {
int doubleProfileSize = SkScalarCeilToInt(12*sigma);
if (doubleProfileSize >= rect.width() || doubleProfileSize >= rect.height()) {
@@ -781,7 +782,7 @@ public:
return nullptr;
}
- sk_sp<GrTextureProxy> blurProfile(CreateBlurProfileTexture(context, sigma));
+ sk_sp<GrTextureProxy> blurProfile(CreateBlurProfileTexture(resourceProvider, sigma));
if (!blurProfile) {
return nullptr;
}
@@ -805,7 +806,7 @@ public:
precision = kDefault_GrSLPrecision;
}
- return sk_sp<GrFragmentProcessor>(new GrRectBlurEffect(context->resourceProvider(),
+ return sk_sp<GrFragmentProcessor>(new GrRectBlurEffect(resourceProvider,
rect, sigma,
std::move(blurProfile), precision));
}
@@ -824,7 +825,7 @@ private:
bool onIsEqual(const GrFragmentProcessor&) const override;
- static sk_sp<GrTextureProxy> CreateBlurProfileTexture(GrContext*, float sigma);
+ static sk_sp<GrTextureProxy> CreateBlurProfileTexture(GrResourceProvider*, float sigma);
SkRect fRect;
float fSigma;
@@ -942,7 +943,9 @@ void GrGLRectBlurEffect::onSetData(const GrGLSLProgramDataManager& pdman,
pdman.set1f(fProfileSizeUniform, SkScalarCeilToScalar(6*rbe.getSigma()));
}
-sk_sp<GrTextureProxy> GrRectBlurEffect::CreateBlurProfileTexture(GrContext* context, float sigma) {
+sk_sp<GrTextureProxy> GrRectBlurEffect::CreateBlurProfileTexture(
+ GrResourceProvider* resourceProvider,
+ float sigma) {
GrSurfaceDesc texDesc;
unsigned int profileSize = SkScalarCeilToInt(6*sigma);
@@ -958,17 +961,17 @@ sk_sp<GrTextureProxy> GrRectBlurEffect::CreateBlurProfileTexture(GrContext* cont
builder[0] = profileSize;
builder.finish();
- sk_sp<GrTextureProxy> blurProfile(context->resourceProvider()->findProxyByUniqueKey(key));
+ sk_sp<GrTextureProxy> blurProfile(resourceProvider->findProxyByUniqueKey(key));
if (!blurProfile) {
std::unique_ptr<uint8_t[]> profile(SkBlurMask::ComputeBlurProfile(sigma));
- blurProfile = GrSurfaceProxy::MakeDeferred(*context->caps(), context->resourceProvider(),
+ blurProfile = GrSurfaceProxy::MakeDeferred(resourceProvider,
texDesc, SkBudgeted::kYes, profile.get(), 0);
if (!blurProfile) {
return nullptr;
}
- context->resourceProvider()->assignUniqueKeyToProxy(key, blurProfile.get());
+ resourceProvider->assignUniqueKeyToProxy(key, blurProfile.get());
}
return blurProfile;
@@ -1008,7 +1011,8 @@ sk_sp<GrFragmentProcessor> GrRectBlurEffect::TestCreate(GrProcessorTestData* d)
float sigma = d->fRandom->nextRangeF(3,8);
float width = d->fRandom->nextRangeF(200,300);
float height = d->fRandom->nextRangeF(200,300);
- return GrRectBlurEffect::Make(d->context(), SkRect::MakeWH(width, height), sigma);
+ return GrRectBlurEffect::Make(d->context()->resourceProvider(),
+ SkRect::MakeWH(width, height), sigma);
}
#endif
@@ -1032,6 +1036,7 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context,
SkScalar xformedSigma = this->computeXformedSigma(viewMatrix);
+ GrResourceProvider* resourceProvider = renderTargetContext->resourceProvider();
sk_sp<GrFragmentProcessor> fp;
SkRect rect;
@@ -1039,9 +1044,9 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context,
SkScalar pad = 3.0f * xformedSigma;
rect.outset(pad, pad);
- fp = GrRectBlurEffect::Make(context, rect, xformedSigma);
+ fp = GrRectBlurEffect::Make(resourceProvider, rect, xformedSigma);
} else if (path.isOval(&rect) && SkScalarNearlyEqual(rect.width(), rect.height())) {
- fp = GrCircleBlurFragmentProcessor::Make(context, rect, xformedSigma);
+ fp = GrCircleBlurFragmentProcessor::Make(resourceProvider, rect, xformedSigma);
// expand the rect for the coverage geometry
int pad = SkScalarCeilToInt(6*xformedSigma)/2;
@@ -1354,6 +1359,7 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
return false;
}
+ GrResourceProvider* resourceProvider = renderTargetContext->resourceProvider();
SkScalar xformedSigma = this->computeXformedSigma(viewMatrix);
if (devRRect.isRect() || devRRect.isCircle()) {
@@ -1366,9 +1372,10 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
SkScalar pad = 3.0f * xformedSigma;
const SkRect dstCoverageRect = devRRect.rect().makeOutset(pad, pad);
- fp = GrRectBlurEffect::Make(context, dstCoverageRect, xformedSigma);
+ fp = GrRectBlurEffect::Make(resourceProvider, dstCoverageRect, xformedSigma);
} else {
- fp = GrCircleBlurFragmentProcessor::Make(context, devRRect.rect(), xformedSigma);
+ fp = GrCircleBlurFragmentProcessor::Make(resourceProvider,
+ devRRect.rect(), xformedSigma);
}
if (!fp) {
diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp
index 73e10184e3..aa85d1bf6b 100644
--- a/src/effects/SkPerlinNoiseShader.cpp
+++ b/src/effects/SkPerlinNoiseShader.cpp
@@ -915,9 +915,9 @@ sk_sp<GrFragmentProcessor> SkPerlinNoiseShader::asFragmentProcessor(const AsFPAr
SkPerlinNoiseShader::PaintingData* paintingData =
new PaintingData(fTileSize, fSeed, fBaseFrequencyX, fBaseFrequencyY, matrix);
sk_sp<GrTextureProxy> permutationsProxy(GrMakeCachedBitmapProxy(
- args.fContext,
+ args.fContext->resourceProvider(),
paintingData->getPermutationsBitmap()));
- sk_sp<GrTextureProxy> noiseProxy(GrMakeCachedBitmapProxy(args.fContext,
+ sk_sp<GrTextureProxy> noiseProxy(GrMakeCachedBitmapProxy(args.fContext->resourceProvider(),
paintingData->getNoiseBitmap()));
SkMatrix m = *args.fViewMatrix;
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index 099846d2b3..393543b4bb 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -388,7 +388,7 @@ private:
bool onIsEqual(const GrFragmentProcessor&) const override;
- ColorTableEffect(GrContext* context, sk_sp<GrTextureProxy> proxy,
+ ColorTableEffect(GrResourceProvider* , sk_sp<GrTextureProxy> proxy,
GrTextureStripAtlas* atlas, int row, unsigned flags);
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
@@ -490,6 +490,8 @@ sk_sp<GrFragmentProcessor> ColorTableEffect::Make(GrContext* context, const SkBi
desc.fWidth = bitmap.width();
desc.fHeight = 128;
desc.fRowHeight = bitmap.height();
+
+ // TODO: this seems a bit heavy handed (passing a GrContext as part of the desc)
desc.fContext = context;
desc.fConfig = SkImageInfo2GrPixelConfig(bitmap.info(), *context->caps());
GrTextureStripAtlas* atlas = GrTextureStripAtlas::GetAtlas(desc);
@@ -498,7 +500,7 @@ sk_sp<GrFragmentProcessor> ColorTableEffect::Make(GrContext* context, const SkBi
if (-1 == row) {
atlas = nullptr;
- proxy = GrMakeCachedBitmapProxy(context, bitmap);
+ proxy = GrMakeCachedBitmapProxy(context->resourceProvider(), bitmap);
} else {
proxy = atlas->asTextureProxyRef();
}
@@ -507,14 +509,16 @@ sk_sp<GrFragmentProcessor> ColorTableEffect::Make(GrContext* context, const SkBi
return nullptr;
}
- return sk_sp<GrFragmentProcessor>(new ColorTableEffect(context, std::move(proxy),
+ return sk_sp<GrFragmentProcessor>(new ColorTableEffect(context->resourceProvider(),
+ std::move(proxy),
atlas, row, flags));
}
-ColorTableEffect::ColorTableEffect(GrContext* context, sk_sp<GrTextureProxy> proxy,
+ColorTableEffect::ColorTableEffect(GrResourceProvider* resourceProvider,
+ sk_sp<GrTextureProxy> proxy,
GrTextureStripAtlas* atlas, int row, unsigned flags)
: INHERITED(kNone_OptimizationFlags) // Not bothering with table-specific optimizations.
- , fTextureSampler(context->resourceProvider(), std::move(proxy))
+ , fTextureSampler(resourceProvider, std::move(proxy))
, fAtlas(atlas)
, fRow(row) {
this->initClassID<ColorTableEffect>();
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index afb4f8b95a..9d7108f6d0 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -1710,7 +1710,9 @@ GrGradientEffect::GrGradientEffect(const CreateArgs& args, bool isOpaque)
// Only the x-tileMode is unknown. However, given all the other knowns we know
// that GrMakeCachedBitmapProxy is sufficient (i.e., it won't need to be
// extracted to a subset or mipmapped).
- sk_sp<GrTextureProxy> proxy = GrMakeCachedBitmapProxy(args.fContext, bitmap);
+ sk_sp<GrTextureProxy> proxy = GrMakeCachedBitmapProxy(
+ args.fContext->resourceProvider(),
+ bitmap);
if (!proxy) {
return;
}
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 01f131020d..f260130d69 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -296,7 +296,6 @@ bool GrContext::writeSurfacePixels(GrSurface* surface, SkColorSpace* dstColorSpa
sk_sp<GrTextureProxy> tempProxy;
if (GrGpu::kNoDraw_DrawPreference != drawPreference) {
tempProxy = GrSurfaceProxy::MakeDeferred(this->resourceProvider(),
- *this->caps(),
tempDrawInfo.fTempSurfaceDesc,
SkBackingFit::kApprox,
SkBudgeted::kYes);
@@ -622,8 +621,7 @@ sk_sp<GrSurfaceContext> GrContextPriv::makeDeferredSurfaceContext(const GrSurfac
SkBudgeted isDstBudgeted) {
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(fContext->resourceProvider(),
- *fContext->caps(), dstDesc,
- fit, isDstBudgeted);
+ dstDesc, fit, isDstBudgeted);
if (!proxy) {
return nullptr;
}
@@ -820,7 +818,7 @@ sk_sp<GrRenderTargetContext> GrContext::makeDeferredRenderTargetContext(
desc.fSampleCnt = sampleCnt;
sk_sp<GrTextureProxy> rtp = GrSurfaceProxy::MakeDeferred(this->resourceProvider(),
- *this->caps(), desc, fit, budgeted);
+ desc, fit, budgeted);
if (!rtp) {
return nullptr;
}
diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h
index dc4944abf9..72ce259be9 100644
--- a/src/gpu/GrRenderTargetContext.h
+++ b/src/gpu/GrRenderTargetContext.h
@@ -53,6 +53,8 @@ class SK_API GrRenderTargetContext : public GrSurfaceContext {
public:
~GrRenderTargetContext() override;
+ GrResourceProvider* resourceProvider() { return fContext->resourceProvider(); }
+
// We use SkPaint rather than GrPaint here for two reasons:
// * The SkPaint carries extra text settings. If these were extracted to a lighter object
// we could use GrPaint except that
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index 43e82975c7..1a04951283 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -9,6 +9,7 @@
#include "GrBuffer.h"
#include "GrCaps.h"
+#include "GrContext.h"
#include "GrGpu.h"
#include "GrPathRendering.h"
#include "GrRenderTarget.h"
@@ -36,6 +37,8 @@ GrResourceProvider::GrResourceProvider(GrGpu* gpu, GrResourceCache* cache, GrSin
, fSingleOwner(owner)
#endif
{
+ fCaps = sk_ref_sp(fGpu->caps());
+
GR_DEFINE_STATIC_UNIQUE_KEY(gQuadIndexBufferKey);
fQuadIndexBufferKey = gQuadIndexBufferKey;
}
diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h
index 2d5b0981fb..948979805c 100644
--- a/src/gpu/GrResourceProvider.h
+++ b/src/gpu/GrResourceProvider.h
@@ -243,14 +243,16 @@ public:
void releaseOwnershipOfSemaphore(sk_sp<GrSemaphore>);
void abandon() {
- fCache = NULL;
- fGpu = NULL;
+ fCache = nullptr;
+ fGpu = nullptr;
}
// 'Proxy' is about to be used as a texture src. This query can be used to determine if
// it is going to need a texture domain.
static bool IsFunctionallyExact(GrTextureProxy* proxy);
+ const GrCaps* caps() const { return fCaps.get(); }
+
private:
GrTexture* internalCreateApproxTexture(const GrSurfaceDesc& desc, uint32_t scratchTextureFlags);
@@ -275,9 +277,10 @@ private:
const GrBuffer* createQuadIndexBuffer();
- GrResourceCache* fCache;
- GrGpu* fGpu;
- GrUniqueKey fQuadIndexBufferKey;
+ GrResourceCache* fCache;
+ GrGpu* fGpu;
+ sk_sp<const GrCaps> fCaps;
+ GrUniqueKey fQuadIndexBufferKey;
// In debug builds we guard against improper thread handling
SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;)
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index 88314eacf2..22b2f3c506 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -12,7 +12,6 @@
#include "GrPipelineBuilder.h"
#include "GrResourceProvider.h"
#include "GrSWMaskHelper.h"
-#include "GrSurfaceContextPriv.h"
#include "ops/GrRectOpFactory.h"
////////////////////////////////////////////////////////////////////////////////
@@ -208,11 +207,10 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
if (useCache) {
proxy = fResourceProvider->findProxyByUniqueKey(maskKey);
}
- GrContext* context = args.fRenderTargetContext->surfPriv().getContext();
if (!proxy) {
SkBackingFit fit = useCache ? SkBackingFit::kExact : SkBackingFit::kApprox;
GrAA aa = GrAAType::kCoverage == args.fAAType ? GrAA::kYes : GrAA::kNo;
- proxy = GrSWMaskHelper::DrawShapeMaskToTexture(context, *args.fShape,
+ proxy = GrSWMaskHelper::DrawShapeMaskToTexture(args.fContext, *args.fShape,
*boundsForMask, aa,
fit, args.fViewMatrix);
if (!proxy) {
@@ -228,7 +226,7 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
unclippedDevShapeBounds);
}
GrSWMaskHelper::DrawToTargetWithShapeMask(
- context, std::move(proxy), args.fRenderTargetContext, std::move(args.fPaint),
+ args.fContext, std::move(proxy), args.fRenderTargetContext, std::move(args.fPaint),
*args.fUserStencilSettings, *args.fClip, *args.fViewMatrix,
SkIPoint{boundsForMask->fLeft, boundsForMask->fTop}, *boundsForMask);
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index 279eec2161..a5cb057be4 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -148,13 +148,15 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrTexture> tex) {
#include "GrResourceProvider.h"
sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(GrResourceProvider* resourceProvider,
- const GrCaps& caps,
const GrSurfaceDesc& desc,
SkBackingFit fit,
SkBudgeted budgeted,
uint32_t flags) {
SkASSERT(0 == flags || GrResourceProvider::kNoPendingIO_Flag == flags);
+ const GrCaps* caps = resourceProvider->caps();
+
+ // TODO: move this logic into GrResourceProvider!
// TODO: share this testing code with check_texture_creation_params
if (GrPixelConfigIsCompressed(desc.fConfig)) {
if (SkBackingFit::kApprox == fit || kBottomLeft_GrSurfaceOrigin == desc.fOrigin) {
@@ -163,17 +165,17 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(GrResourceProvider* resourceP
return nullptr;
}
- if (!caps.npotTextureTileSupport() && (!SkIsPow2(desc.fWidth) || !SkIsPow2(desc.fHeight))) {
+ if (!caps->npotTextureTileSupport() && (!SkIsPow2(desc.fWidth) || !SkIsPow2(desc.fHeight))) {
return nullptr;
}
}
- if (!caps.isConfigTexturable(desc.fConfig)) {
+ if (!caps->isConfigTexturable(desc.fConfig)) {
return nullptr;
}
bool willBeRT = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag);
- if (willBeRT && !caps.isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
+ if (willBeRT && !caps->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
return nullptr;
}
@@ -184,9 +186,9 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(GrResourceProvider* resourceP
int maxSize;
if (willBeRT) {
- maxSize = caps.maxRenderTargetSize();
+ maxSize = caps->maxRenderTargetSize();
} else {
- maxSize = caps.maxTextureSize();
+ maxSize = caps->maxTextureSize();
}
if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
@@ -194,20 +196,19 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(GrResourceProvider* resourceP
}
GrSurfaceDesc copyDesc = desc;
- copyDesc.fSampleCnt = SkTMin(desc.fSampleCnt, caps.maxSampleCount());
+ copyDesc.fSampleCnt = SkTMin(desc.fSampleCnt, caps->maxSampleCount());
if (willBeRT) {
// We know anything we instantiate later from this deferred path will be
// both texturable and renderable
- return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(caps, copyDesc, fit,
+ return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(*caps, copyDesc, fit,
budgeted, flags));
}
return sk_sp<GrTextureProxy>(new GrTextureProxy(copyDesc, fit, budgeted, nullptr, 0, flags));
}
-sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(const GrCaps& caps,
- GrResourceProvider* resourceProvider,
+sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(GrResourceProvider* resourceProvider,
const GrSurfaceDesc& desc,
SkBudgeted budgeted,
const void* srcData,
@@ -218,8 +219,7 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(const GrCaps& caps,
return GrSurfaceProxy::MakeWrapped(std::move(tex));
}
- return GrSurfaceProxy::MakeDeferred(resourceProvider, caps, desc, SkBackingFit::kExact,
- budgeted);
+ return GrSurfaceProxy::MakeDeferred(resourceProvider, desc, SkBackingFit::kExact, budgeted);
}
sk_sp<GrSurfaceProxy> GrSurfaceProxy::MakeWrappedBackend(GrContext* context,
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 55be407de4..5a98b08220 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -14,7 +14,6 @@
#include "GrImageTextureMaker.h"
#include "GrRenderTargetContextPriv.h"
#include "GrStyle.h"
-#include "GrSurfaceContextPriv.h"
#include "GrTextureAdjuster.h"
#include "GrTextureProxy.h"
#include "GrTracing.h"
@@ -459,7 +458,7 @@ void SkGpuDevice::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
// we used to test finalIRect for quickReject, but that seems unlikely
// given that the original shape was not rejected...
- if (mf->directFilterRRectMaskGPU(fContext.get(), fRenderTargetContext.get(),
+ if (mf->directFilterRRectMaskGPU(this->context(), fRenderTargetContext.get(),
std::move(grPaint), this->clip(), this->ctm(),
style.strokeRec(), rrect, devRRect)) {
return;
@@ -1272,7 +1271,7 @@ void SkGpuDevice::drawBitmapRect(const SkBitmap& bitmap,
sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkBitmap& bitmap) {
// TODO: this makes a tight copy of 'bitmap' but it doesn't have to be (given SkSpecialImage's
// semantics). Since this is cached we would have to bake the fit into the cache key though.
- sk_sp<GrTextureProxy> proxy = GrMakeCachedBitmapProxy(fContext.get(), bitmap);
+ sk_sp<GrTextureProxy> proxy = GrMakeCachedBitmapProxy(fContext->resourceProvider(), bitmap);
if (!proxy) {
return nullptr;
}
@@ -1547,10 +1546,10 @@ void SkGpuDevice::drawBitmapLattice(const SkBitmap& bitmap,
this->drawProducerLattice(&maker, lattice, dst, paint);
}
-bool init_vertices_paint(const SkPaint& skPaint, const SkMatrix& matrix, SkBlendMode bmode,
- bool hasTexs, bool hasColors, GrRenderTargetContext* rtc,
- GrPaint* grPaint) {
- GrContext* context = rtc->surfPriv().getContext();
+static bool init_vertices_paint(GrContext* context, GrRenderTargetContext* rtc,
+ const SkPaint& skPaint,
+ const SkMatrix& matrix, SkBlendMode bmode,
+ bool hasTexs, bool hasColors, GrPaint* grPaint) {
if (hasTexs && skPaint.getShader()) {
if (hasColors) {
// When there are texs and colors the shader and colors are combined using bmode.
@@ -1643,8 +1642,9 @@ void SkGpuDevice::drawVertices(SkCanvas::VertexMode vmode,
GrPrimitiveType primType = SkVertexModeToGrPrimitiveType(vmode);
GrPaint grPaint;
- if (!init_vertices_paint(paint, this->ctm(), bmode, SkToBool(texs), SkToBool(colors),
- fRenderTargetContext.get(), &grPaint)) {
+ if (!init_vertices_paint(fContext.get(), fRenderTargetContext.get(),
+ paint, this->ctm(), bmode, SkToBool(texs),
+ SkToBool(colors), &grPaint)) {
return;
}
fRenderTargetContext->drawVertices(this->clip(),
@@ -1676,8 +1676,8 @@ void SkGpuDevice::drawVerticesObject(sk_sp<SkVertices> vertices,
nullptr, nullptr, mode, vertices->indices(), vertices->indexCount(),
paint);
}
- if (!init_vertices_paint(paint, this->ctm(), mode, hasTexs, hasColors,
- fRenderTargetContext.get(), &grPaint)) {
+ if (!init_vertices_paint(fContext.get(), fRenderTargetContext.get(), paint, this->ctm(),
+ mode, hasTexs, hasColors, &grPaint)) {
return;
}
fRenderTargetContext->drawVertices(this->clip(), std::move(grPaint), this->ctm(),
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index c9c9b0e662..b030469967 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -106,7 +106,8 @@ GrTexture* GrUploadBitmapToTexture(GrContext* ctx, const SkBitmap& bitmap) {
}
-sk_sp<GrTextureProxy> GrUploadBitmapToTextureProxy(GrContext* ctx, const SkBitmap& bitmap) {
+sk_sp<GrTextureProxy> GrUploadBitmapToTextureProxy(GrResourceProvider* resourceProvider,
+ const SkBitmap& bitmap) {
SkAutoLockPixels alp(bitmap);
if (!bitmap.readyToDraw()) {
return nullptr;
@@ -115,7 +116,7 @@ sk_sp<GrTextureProxy> GrUploadBitmapToTextureProxy(GrContext* ctx, const SkBitma
if (!bitmap.peekPixels(&pixmap)) {
return nullptr;
}
- return GrUploadPixmapToTextureProxy(ctx, pixmap, SkBudgeted::kYes);
+ return GrUploadPixmapToTextureProxy(resourceProvider, pixmap, SkBudgeted::kYes);
}
static const SkPixmap* compute_desc(const GrCaps& caps, const SkPixmap& pixmap,
@@ -190,7 +191,7 @@ GrTexture* GrUploadPixmapToTexture(GrContext* ctx, const SkPixmap& pixmap, SkBud
return nullptr;
}
-sk_sp<GrTextureProxy> GrUploadPixmapToTextureProxy(GrContext* ctx,
+sk_sp<GrTextureProxy> GrUploadPixmapToTextureProxy(GrResourceProvider* resourceProvider,
const SkPixmap& pixmap,
SkBudgeted budgeted) {
if (!SkImageInfoIsValid(pixmap.info())) {
@@ -201,8 +202,9 @@ sk_sp<GrTextureProxy> GrUploadPixmapToTextureProxy(GrContext* ctx,
SkPixmap tmpPixmap;
GrSurfaceDesc desc;
- if (const SkPixmap* pmap = compute_desc(*ctx->caps(), pixmap, &desc, &tmpBitmap, &tmpPixmap)) {
- return GrSurfaceProxy::MakeDeferred(*ctx->caps(), ctx->resourceProvider(), desc,
+ if (const SkPixmap* pmap = compute_desc(*resourceProvider->caps(), pixmap, &desc,
+ &tmpBitmap, &tmpPixmap)) {
+ return GrSurfaceProxy::MakeDeferred(resourceProvider, desc,
budgeted, pmap->addr(), pmap->rowBytes());
}
@@ -312,7 +314,8 @@ GrTexture* GrRefCachedBitmapTexture(GrContext* ctx, const SkBitmap& bitmap,
nullptr, scaleAdjust);
}
-sk_sp<GrTextureProxy> GrMakeCachedBitmapProxy(GrContext* context, const SkBitmap& bitmap) {
+sk_sp<GrTextureProxy> GrMakeCachedBitmapProxy(GrResourceProvider* resourceProvider,
+ const SkBitmap& bitmap) {
GrUniqueKey originalKey;
if (!bitmap.isVolatile()) {
@@ -324,12 +327,12 @@ sk_sp<GrTextureProxy> GrMakeCachedBitmapProxy(GrContext* context, const SkBitmap
sk_sp<GrTextureProxy> proxy;
if (originalKey.isValid()) {
- proxy = context->resourceProvider()->findProxyByUniqueKey(originalKey);
+ proxy = resourceProvider->findProxyByUniqueKey(originalKey);
}
if (!proxy) {
- proxy = GrUploadBitmapToTextureProxy(context, bitmap);
+ proxy = GrUploadBitmapToTextureProxy(resourceProvider, bitmap);
if (proxy && originalKey.isValid()) {
- context->resourceProvider()->assignUniqueKeyToProxy(originalKey, proxy.get());
+ resourceProvider->assignUniqueKeyToProxy(originalKey, proxy.get());
// MDB TODO (caching): this has to play nice with the GrSurfaceProxy's caching
GrInstallBitmapUniqueKeyInvalidator(originalKey, bitmap.pixelRef());
}
diff --git a/src/gpu/SkGr.h b/src/gpu/SkGr.h
index f0bc390b0c..e1874a6799 100644
--- a/src/gpu/SkGr.h
+++ b/src/gpu/SkGr.h
@@ -27,6 +27,7 @@ class GrContext;
class GrRenderTargetContext;
class GrFragmentProcessor;
class GrPaint;
+class GrResourceProvider;
class GrTexture;
class GrTextureProxy;
class GrUniqueKey;
@@ -213,7 +214,7 @@ GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&,
*/
GrTexture* GrUploadBitmapToTexture(GrContext*, const SkBitmap&);
-sk_sp<GrTextureProxy> GrUploadBitmapToTextureProxy(GrContext*, const SkBitmap&);
+sk_sp<GrTextureProxy> GrUploadBitmapToTextureProxy(GrResourceProvider*, const SkBitmap&);
GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext*, const SkBitmap&,
SkColorSpace* dstColorSpace);
@@ -223,7 +224,8 @@ GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext*, const SkBitmap&,
*/
GrTexture* GrUploadPixmapToTexture(GrContext*, const SkPixmap&, SkBudgeted);
-sk_sp<GrTextureProxy> GrUploadPixmapToTextureProxy(GrContext*, const SkPixmap&, SkBudgeted);
+sk_sp<GrTextureProxy> GrUploadPixmapToTextureProxy(GrResourceProvider*,
+ const SkPixmap&, SkBudgeted);
/**
* Creates a new texture populated with the mipmap levels.
@@ -245,7 +247,7 @@ sk_sp<GrTexture> GrMakeCachedBitmapTexture(GrContext*, const SkBitmap&,
// if (!texture) {
// return nullptr;
// }
-sk_sp<GrTextureProxy> GrMakeCachedBitmapProxy(GrContext* context, const SkBitmap& bitmap);
+sk_sp<GrTextureProxy> GrMakeCachedBitmapProxy(GrResourceProvider*, const SkBitmap& bitmap);
/**
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index 7bdcaf5ca0..6275adb3c1 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -219,8 +219,7 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
desc.fHeight = kSize;
desc.fConfig = kConfig;
- sk_sp<GrTextureProxy> dataProxy = GrSurfaceProxy::MakeDeferred(*context->caps(),
- context->resourceProvider(),
+ sk_sp<GrTextureProxy> dataProxy = GrSurfaceProxy::MakeDeferred(context->resourceProvider(),
desc, SkBudgeted::kYes, data, 0);
if (!dataProxy) {
return;
diff --git a/src/gpu/effects/GrTextureStripAtlas.cpp b/src/gpu/effects/GrTextureStripAtlas.cpp
index 2bf5a721e6..0f6ca58204 100644
--- a/src/gpu/effects/GrTextureStripAtlas.cpp
+++ b/src/gpu/effects/GrTextureStripAtlas.cpp
@@ -210,7 +210,7 @@ void GrTextureStripAtlas::lockTexture() {
sk_sp<GrTextureProxy> proxy = fDesc.fContext->resourceProvider()->findProxyByUniqueKey(key);
if (!proxy) {
proxy = GrSurfaceProxy::MakeDeferred(fDesc.fContext->resourceProvider(),
- *fDesc.fContext->caps(), texDesc, SkBackingFit::kExact,
+ texDesc, SkBackingFit::kExact,
SkBudgeted::kYes,
GrResourceProvider::kNoPendingIO_Flag);
if (!proxy) {
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp
index afa54d5c43..acd426787b 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp
@@ -13,7 +13,6 @@
#include "GrPipelineBuilder.h"
#include "GrRenderTargetContext.h"
#include "GrResourceProvider.h"
-#include "GrSurfaceContextPriv.h"
#include "GrTextUtils.h"
#include "SkAutoKern.h"
#include "SkDraw.h"
@@ -528,22 +527,23 @@ void GrStencilAndCoverTextContext::TextRun::setPosText(const char text[], size_t
fFallbackTextBlob = fallback.makeIfNeeded(&fFallbackGlyphCount);
}
-GrPathRange* GrStencilAndCoverTextContext::TextRun::createGlyphs(GrContext* ctx) const {
+GrPathRange* GrStencilAndCoverTextContext::TextRun::createGlyphs(
+ GrResourceProvider* resourceProvider) const {
GrPathRange* glyphs = static_cast<GrPathRange*>(
- ctx->resourceProvider()->findAndRefResourceByUniqueKey(fGlyphPathsKey));
+ resourceProvider->findAndRefResourceByUniqueKey(fGlyphPathsKey));
if (nullptr == glyphs) {
if (fUsingRawGlyphPaths) {
SkScalerContextEffects noeffects;
- glyphs = ctx->resourceProvider()->createGlyphs(fFont.getTypeface(), noeffects,
- nullptr, fStyle);
+ glyphs = resourceProvider->createGlyphs(fFont.getTypeface(), noeffects,
+ nullptr, fStyle);
} else {
SkGlyphCache* cache = this->getGlyphCache();
- glyphs = ctx->resourceProvider()->createGlyphs(cache->getScalerContext()->getTypeface(),
- cache->getScalerContext()->getEffects(),
- &cache->getDescriptor(),
- fStyle);
+ glyphs = resourceProvider->createGlyphs(cache->getScalerContext()->getTypeface(),
+ cache->getScalerContext()->getEffects(),
+ &cache->getDescriptor(),
+ fStyle);
}
- ctx->resourceProvider()->assignUniqueKeyToResource(fGlyphPathsKey, glyphs);
+ resourceProvider->assignUniqueKeyToResource(fGlyphPathsKey, glyphs);
}
return glyphs;
}
@@ -585,7 +585,7 @@ void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx,
0xffff>()
);
- sk_sp<GrPathRange> glyphs(this->createGlyphs(ctx));
+ sk_sp<GrPathRange> glyphs(this->createGlyphs(ctx->resourceProvider()));
if (fLastDrawnGlyphsID != glyphs->uniqueID()) {
// Either this is the first draw or the glyphs object was purged since last draw.
glyphs->loadPathsIfNeeded(fInstanceData->indices(), fInstanceData->count());
@@ -593,9 +593,7 @@ void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx,
}
GrPaint grPaint;
- GrContext* context = renderTargetContext->surfPriv().getContext();
- if (!SkPaintToGrPaint(context, renderTargetContext, originalSkPaint, viewMatrix,
- &grPaint)) {
+ if (!SkPaintToGrPaint(ctx, renderTargetContext, originalSkPaint, viewMatrix, &grPaint)) {
return;
}
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.h b/src/gpu/text/GrStencilAndCoverTextContext.h
index a99c264fb7..f06442b1be 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.h
+++ b/src/gpu/text/GrStencilAndCoverTextContext.h
@@ -89,7 +89,7 @@ private:
typedef GrDrawPathRangeOp::InstanceData InstanceData;
SkGlyphCache* getGlyphCache() const;
- GrPathRange* createGlyphs(GrContext*) const;
+ GrPathRange* createGlyphs(GrResourceProvider*) const;
void appendGlyph(const SkGlyph&, const SkPoint&, FallbackBlobBuilder*);
GrStyle fStyle;
diff --git a/src/gpu/text/GrTextUtils.cpp b/src/gpu/text/GrTextUtils.cpp
index 4c74dbe76a..31d0291b67 100644
--- a/src/gpu/text/GrTextUtils.cpp
+++ b/src/gpu/text/GrTextUtils.cpp
@@ -41,6 +41,7 @@ static const int kLargeDFFontLimit = 2 * kLargeDFFontSize;
bool GrTextUtils::Paint::toGrPaint(GrMaskFormat maskFormat, GrRenderTargetContext* rtc,
const SkMatrix& viewMatrix, GrPaint* grPaint) const {
+ // TODO: this is the last use of GrSurfaceContextPriv
GrContext* context = rtc->surfPriv().getContext();
if (kARGB_GrMaskFormat == maskFormat) {
return SkPaintToGrPaintWithPrimitiveColor(context, rtc, this->skPaint(), grPaint);