aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/SkGpuBlurUtils.cpp14
-rw-r--r--src/core/SkImageFilter.cpp6
-rw-r--r--src/core/SkSpecialSurface.cpp5
-rw-r--r--src/effects/SkAlphaThresholdFilter.cpp6
-rw-r--r--src/effects/SkArithmeticImageFilter.cpp3
-rw-r--r--src/effects/SkDisplacementMapEffect.cpp2
-rw-r--r--src/effects/SkLightingImageFilter.cpp4
-rw-r--r--src/effects/SkMorphologyImageFilter.cpp10
-rw-r--r--src/effects/SkXfermodeImageFilter.cpp3
-rw-r--r--src/gpu/GrAHardwareBufferImageGenerator.cpp3
-rw-r--r--src/gpu/GrBackendTextureImageGenerator.cpp3
-rw-r--r--src/gpu/GrBlurUtils.cpp7
-rw-r--r--src/gpu/GrClipStackClip.cpp12
-rw-r--r--src/gpu/GrContext.cpp34
-rw-r--r--src/gpu/GrContextPriv.h78
-rw-r--r--src/gpu/GrDrawingManager.cpp22
-rw-r--r--src/gpu/GrTextureProducer.cpp3
-rw-r--r--src/gpu/GrTracing.h2
-rw-r--r--src/gpu/GrYUVProvider.cpp3
-rw-r--r--src/gpu/SkGpuDevice.cpp8
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.h4
-rw-r--r--src/gpu/effects/GrRRectBlurEffect.h3
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.cpp13
-rw-r--r--src/gpu/text/GrAtlasTextContext.cpp8
-rw-r--r--src/image/SkImage.cpp2
-rw-r--r--src/image/SkImage_Gpu.cpp15
26 files changed, 188 insertions, 85 deletions
diff --git a/src/core/SkGpuBlurUtils.cpp b/src/core/SkGpuBlurUtils.cpp
index 755e8daf70..b42bb04782 100644
--- a/src/core/SkGpuBlurUtils.cpp
+++ b/src/core/SkGpuBlurUtils.cpp
@@ -250,8 +250,8 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
// We shouldn't be scaling because this is a small size blur
SkASSERT((1 == scaleFactorX) && (1 == scaleFactorY));
- dstRenderTargetContext = context->makeDeferredRenderTargetContext(fit, width, height,
- config, colorSpace);
+ dstRenderTargetContext = context->contextPriv().makeDeferredRenderTargetContext(
+ fit, width, height, config, colorSpace);
if (!dstRenderTargetContext) {
return nullptr;
}
@@ -272,7 +272,7 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
SkIRect dstRect(srcRect);
shrink_irect_by_2(&dstRect, i < scaleFactorX, i < scaleFactorY);
- dstRenderTargetContext = context->makeDeferredRenderTargetContext(
+ dstRenderTargetContext = context->contextPriv().makeDeferredRenderTargetContext(
fit,
SkTMin(dstRect.fRight, width),
SkTMin(dstRect.fBottom, height),
@@ -327,7 +327,8 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
}
SkASSERT(srcRect.width() <= width && srcRect.height() <= height);
- dstRenderTargetContext = context->makeDeferredRenderTargetContext(fit, srcRect.width(),
+ dstRenderTargetContext = context->contextPriv().makeDeferredRenderTargetContext(
+ fit, srcRect.width(),
srcRect.height(),
config, colorSpace);
if (!dstRenderTargetContext) {
@@ -362,7 +363,8 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
}
SkASSERT(srcRect.width() <= width && srcRect.height() <= height);
- dstRenderTargetContext = context->makeDeferredRenderTargetContext(fit, srcRect.width(),
+ dstRenderTargetContext = context->contextPriv().makeDeferredRenderTargetContext(
+ fit, srcRect.width(),
srcRect.height(),
config, colorSpace);
if (!dstRenderTargetContext) {
@@ -394,7 +396,7 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
SkIRect dstRect(srcRect);
scale_irect(&dstRect, scaleFactorX, scaleFactorY);
- dstRenderTargetContext = context->makeDeferredRenderTargetContext(
+ dstRenderTargetContext = context->contextPriv().makeDeferredRenderTargetContext(
fit, SkTMin(dstRect.width(), width),
SkTMin(dstRect.height(), height),
config, colorSpace);
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index b2220a7651..ae3b53a69e 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -302,8 +302,10 @@ sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context,
sk_sp<SkColorSpace> colorSpace = sk_ref_sp(outputProperties.colorSpace());
GrPixelConfig config = GrRenderableConfigForColorSpace(colorSpace.get());
- sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext(
- SkBackingFit::kApprox, bounds.width(), bounds.height(), config, std::move(colorSpace)));
+ sk_sp<GrRenderTargetContext> renderTargetContext(
+ context->contextPriv().makeDeferredRenderTargetContext(
+ SkBackingFit::kApprox, bounds.width(), bounds.height(),
+ config, std::move(colorSpace)));
if (!renderTargetContext) {
return nullptr;
}
diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp
index ef78a3e0ad..19a149fe45 100644
--- a/src/core/SkSpecialSurface.cpp
+++ b/src/core/SkSpecialSurface.cpp
@@ -171,8 +171,9 @@ sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrContext* context,
return nullptr;
}
- sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext(
- SkBackingFit::kApprox, width, height, config, std::move(colorSpace)));
+ sk_sp<GrRenderTargetContext> renderTargetContext(
+ context->contextPriv().makeDeferredRenderTargetContext(
+ SkBackingFit::kApprox, width, height, config, std::move(colorSpace)));
if (!renderTargetContext) {
return nullptr;
}
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
index a9052f856a..f2759610be 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -106,8 +106,10 @@ sk_sp<GrTextureProxy> SkAlphaThresholdFilterImpl::createMaskTexture(GrContext* c
const SkMatrix& inMatrix,
const SkIRect& bounds) const {
- sk_sp<GrRenderTargetContext> rtContext(context->makeDeferredRenderTargetContextWithFallback(
- SkBackingFit::kApprox, bounds.width(), bounds.height(), kAlpha_8_GrPixelConfig, nullptr));
+ sk_sp<GrRenderTargetContext> rtContext(
+ context->contextPriv().makeDeferredRenderTargetContextWithFallback(
+ SkBackingFit::kApprox, bounds.width(), bounds.height(), kAlpha_8_GrPixelConfig,
+ nullptr));
if (!rtContext) {
return nullptr;
}
diff --git a/src/effects/SkArithmeticImageFilter.cpp b/src/effects/SkArithmeticImageFilter.cpp
index d78550aba7..4bb3c0bd58 100644
--- a/src/effects/SkArithmeticImageFilter.cpp
+++ b/src/effects/SkArithmeticImageFilter.cpp
@@ -345,7 +345,8 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU(
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
- sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> renderTargetContext(
+ context->contextPriv().makeDeferredRenderTargetContext(
SkBackingFit::kApprox, bounds.width(), bounds.height(),
GrRenderableConfigForColorSpace(outputProperties.colorSpace()),
sk_ref_sp(outputProperties.colorSpace())));
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index ce7fe34ea4..bb51b883a3 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -306,7 +306,7 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffect::onFilterImage(SkSpecialImage* sou
matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colorBounds.y()));
sk_sp<GrRenderTargetContext> renderTargetContext(
- context->makeDeferredRenderTargetContext(SkBackingFit::kApprox,
+ context->contextPriv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
bounds.width(), bounds.height(),
GrRenderableConfigForColorSpace(colorSpace),
sk_ref_sp(colorSpace)));
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 98b0a13245..7a1c535606 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -466,7 +466,9 @@ sk_sp<SkSpecialImage> SkLightingImageFilterInternal::filterImageGPU(
sk_sp<GrTextureProxy> inputProxy(input->asTextureProxyRef(context));
SkASSERT(inputProxy);
- sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext(
+
+ sk_sp<GrRenderTargetContext> renderTargetContext(
+ context->contextPriv().makeDeferredRenderTargetContext(
SkBackingFit::kApprox, offsetBounds.width(), offsetBounds.height(),
GrRenderableConfigForColorSpace(outputProperties.colorSpace()),
sk_ref_sp(outputProperties.colorSpace())));
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 67a681db21..f5da7acf01 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -497,8 +497,9 @@ static sk_sp<SkSpecialImage> apply_morphology(
SkASSERT(radius.width() > 0 || radius.height() > 0);
if (radius.fWidth > 0) {
- sk_sp<GrRenderTargetContext> dstRTContext(context->makeDeferredRenderTargetContext(
- SkBackingFit::kApprox, rect.width(), rect.height(), config, colorSpace));
+ sk_sp<GrRenderTargetContext> dstRTContext(
+ context->contextPriv().makeDeferredRenderTargetContext(
+ SkBackingFit::kApprox, rect.width(), rect.height(), config, colorSpace));
if (!dstRTContext) {
return nullptr;
}
@@ -515,8 +516,9 @@ static sk_sp<SkSpecialImage> apply_morphology(
srcRect = dstRect;
}
if (radius.fHeight > 0) {
- sk_sp<GrRenderTargetContext> dstRTContext(context->makeDeferredRenderTargetContext(
- SkBackingFit::kApprox, rect.width(), rect.height(), config, colorSpace));
+ sk_sp<GrRenderTargetContext> dstRTContext(
+ context->contextPriv().makeDeferredRenderTargetContext(
+ SkBackingFit::kApprox, rect.width(), rect.height(), config, colorSpace));
if (!dstRTContext) {
return nullptr;
}
diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp
index 42fb249254..f1f83965db 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -333,7 +333,8 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilter_Base::filterImageGPU(
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
- sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> renderTargetContext(
+ context->contextPriv().makeDeferredRenderTargetContext(
SkBackingFit::kApprox, bounds.width(), bounds.height(),
GrRenderableConfigForColorSpace(outputProperties.colorSpace()),
sk_ref_sp(outputProperties.colorSpace())));
diff --git a/src/gpu/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp
index 085d27ac10..be6a8d099a 100644
--- a/src/gpu/GrAHardwareBufferImageGenerator.cpp
+++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp
@@ -147,7 +147,8 @@ sk_sp<GrTextureProxy> GrAHardwareBufferImageGenerator::onGenerateTexture(
#endif
sk_sp<GrTextureProxy> GrAHardwareBufferImageGenerator::makeProxy(GrContext* context) {
- if (context->abandoned() || kOpenGL_GrBackend != context->contextPriv().getBackend()) {
+ if (context->contextPriv().abandoned() ||
+ kOpenGL_GrBackend != context->contextPriv().getBackend()) {
// Check if GrContext is not abandoned and the backend is GL.
return nullptr;
}
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index aafa3a25fd..73f19b0199 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -189,7 +189,8 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
colorSpace = SkColorSpace::MakeSRGB();
}
- sk_sp<GrRenderTargetContext> rtContext(context->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> rtContext(
+ context->contextPriv().makeDeferredRenderTargetContext(
SkBackingFit::kExact, info.width(), info.height(), proxy->config(),
std::move(colorSpace), 1, mipMapped, proxy->origin(), nullptr, SkBudgeted::kYes));
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index fb8977e541..0bddd5c594 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -110,9 +110,10 @@ static sk_sp<GrTextureProxy> create_mask_GPU(GrContext* context,
sampleCnt = 1;
}
- sk_sp<GrRenderTargetContext> rtContext(context->makeDeferredRenderTargetContextWithFallback(
- SkBackingFit::kApprox, maskRect.width(), maskRect.height(), kAlpha_8_GrPixelConfig, nullptr,
- sampleCnt));
+ sk_sp<GrRenderTargetContext> rtContext(
+ context->contextPriv().makeDeferredRenderTargetContextWithFallback(
+ SkBackingFit::kApprox, maskRect.width(), maskRect.height(), kAlpha_8_GrPixelConfig,
+ nullptr, sampleCnt));
if (!rtContext) {
return nullptr;
}
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index 179573e321..28bf34b573 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -337,12 +337,12 @@ sk_sp<GrTextureProxy> GrClipStackClip::createAlphaClipMask(GrContext* context,
return proxy;
}
- sk_sp<GrRenderTargetContext> rtc(context->makeDeferredRenderTargetContextWithFallback(
- SkBackingFit::kApprox,
- reducedClip.width(),
- reducedClip.height(),
- kAlpha_8_GrPixelConfig,
- nullptr));
+ sk_sp<GrRenderTargetContext> rtc(
+ context->contextPriv().makeDeferredRenderTargetContextWithFallback(SkBackingFit::kApprox,
+ reducedClip.width(),
+ reducedClip.height(),
+ kAlpha_8_GrPixelConfig,
+ nullptr));
if (!rtc) {
return nullptr;
}
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 627f20a9cb..d29a173e4a 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -961,7 +961,8 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceContext* src, int left, int top,
colorSpace = SkColorSpace::MakeSRGB();
}
sk_sp<GrRenderTargetContext> tempRTC =
- fContext->makeDeferredRenderTargetContext(tempDrawInfo.fTempSurfaceFit,
+ fContext->contextPriv().makeDeferredRenderTargetContext(
+ tempDrawInfo.fTempSurfaceFit,
tempDrawInfo.fTempSurfaceDesc.fWidth,
tempDrawInfo.fTempSurfaceDesc.fHeight,
tempDrawInfo.fTempSurfaceDesc.fConfig,
@@ -1334,7 +1335,7 @@ static inline GrPixelConfig GrPixelConfigFallback(GrPixelConfig config) {
}
}
-sk_sp<GrRenderTargetContext> GrContext::makeDeferredRenderTargetContextWithFallback(
+sk_sp<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContextWithFallback(
SkBackingFit fit,
int width, int height,
GrPixelConfig config,
@@ -1345,7 +1346,7 @@ sk_sp<GrRenderTargetContext> GrContext::makeDeferredRenderTargetContextWithFallb
const SkSurfaceProps* surfaceProps,
SkBudgeted budgeted) {
SkASSERT(sampleCnt > 0);
- if (0 == this->caps()->getRenderTargetSampleCount(sampleCnt, config)) {
+ if (0 == fContext->caps()->getRenderTargetSampleCount(sampleCnt, config)) {
config = GrPixelConfigFallback(config);
}
@@ -1354,7 +1355,7 @@ sk_sp<GrRenderTargetContext> GrContext::makeDeferredRenderTargetContextWithFallb
budgeted);
}
-sk_sp<GrRenderTargetContext> GrContext::makeDeferredRenderTargetContext(
+sk_sp<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContext(
SkBackingFit fit,
int width, int height,
GrPixelConfig config,
@@ -1378,18 +1379,18 @@ sk_sp<GrRenderTargetContext> GrContext::makeDeferredRenderTargetContext(
sk_sp<GrTextureProxy> rtp;
if (GrMipMapped::kNo == mipMapped) {
- rtp = fProxyProvider->createProxy(desc, origin, fit, budgeted);
+ rtp = fContext->fProxyProvider->createProxy(desc, origin, fit, budgeted);
} else {
- rtp = fProxyProvider->createMipMapProxy(desc, origin, budgeted);
+ rtp = fContext->fProxyProvider->createMipMapProxy(desc, origin, budgeted);
}
if (!rtp) {
return nullptr;
}
sk_sp<GrRenderTargetContext> renderTargetContext(
- fDrawingManager->makeRenderTargetContext(std::move(rtp),
- std::move(colorSpace),
- surfaceProps));
+ fContext->fDrawingManager->makeRenderTargetContext(std::move(rtp),
+ std::move(colorSpace),
+ surfaceProps));
if (!renderTargetContext) {
return nullptr;
}
@@ -1399,9 +1400,9 @@ sk_sp<GrRenderTargetContext> GrContext::makeDeferredRenderTargetContext(
return renderTargetContext;
}
-bool GrContext::abandoned() const {
- ASSERT_SINGLE_OWNER
- return fDrawingManager->wasAbandoned();
+bool GrContextPriv::abandoned() const {
+ ASSERT_SINGLE_OWNER_PRIV
+ return fContext->fDrawingManager->wasAbandoned();
}
std::unique_ptr<GrFragmentProcessor> GrContext::createPMToUPMEffect(
@@ -1470,7 +1471,6 @@ void GrContext::setResourceCacheLimits(int maxResources, size_t maxResourceBytes
}
//////////////////////////////////////////////////////////////////////////////
-
void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const {
ASSERT_SINGLE_OWNER
fResourceCache->dumpMemoryStatistics(traceMemoryDump);
@@ -1478,7 +1478,7 @@ void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const {
//////////////////////////////////////////////////////////////////////////////
-SkString GrContext::dump() const {
+SkString GrContextPriv::dump() const {
SkDynamicMemoryWStream stream;
SkJSONWriter writer(&stream, SkJSONWriter::Mode::kPretty);
writer.beginObject();
@@ -1493,13 +1493,13 @@ SkString GrContext::dump() const {
GR_STATIC_ASSERT(1 == kOpenGL_GrBackend);
GR_STATIC_ASSERT(2 == kVulkan_GrBackend);
GR_STATIC_ASSERT(3 == kMock_GrBackend);
- writer.appendString("backend", kBackendStr[fBackend]);
+ writer.appendString("backend", kBackendStr[fContext->fBackend]);
writer.appendName("caps");
- fCaps->dumpJSON(&writer);
+ fContext->fCaps->dumpJSON(&writer);
writer.appendName("gpu");
- fGpu->dumpJSON(&writer);
+ fContext->fGpu->dumpJSON(&writer);
// Flush JSON to the memory stream
writer.endObject();
diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h
index 0db572cecb..ebfe51a3a5 100644
--- a/src/gpu/GrContextPriv.h
+++ b/src/gpu/GrContextPriv.h
@@ -204,6 +204,84 @@ public:
void moveOpListsToDDL(SkDeferredDisplayList*);
void copyOpListsFromDDL(const SkDeferredDisplayList*, GrRenderTargetProxy* newDest);
+ /**
+ * Purge all the unlocked resources from the cache.
+ * This entry point is mainly meant for timing texture uploads
+ * and is not defined in normal builds of Skia.
+ */
+ void purgeAllUnlockedResources_ForTesting();
+
+
+ /*
+ * Create a new render target context backed by a deferred-style
+ * GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for
+ * renderTargetContexts created via this entry point.
+ */
+ sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext(
+ SkBackingFit fit,
+ int width, int height,
+ GrPixelConfig config,
+ sk_sp<SkColorSpace> colorSpace,
+ int sampleCnt = 1,
+ GrMipMapped = GrMipMapped::kNo,
+ GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
+ const SkSurfaceProps* surfaceProps = nullptr,
+ SkBudgeted = SkBudgeted::kYes);
+ /*
+ * This method will attempt to create a renderTargetContext that has, at least, the number of
+ * channels and precision per channel as requested in 'config' (e.g., A8 and 888 can be
+ * converted to 8888). It may also swizzle the channels (e.g., BGRA -> RGBA).
+ * SRGB-ness will be preserved.
+ */
+ sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
+ SkBackingFit fit,
+ int width, int height,
+ GrPixelConfig config,
+ sk_sp<SkColorSpace> colorSpace,
+ int sampleCnt = 1,
+ GrMipMapped = GrMipMapped::kNo,
+ GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
+ const SkSurfaceProps* surfaceProps = nullptr,
+ SkBudgeted budgeted = SkBudgeted::kYes);
+
+ bool abandoned() const;
+
+ /** Reset GPU stats */
+ void resetGpuStats() const ;
+
+ /** Prints cache stats to the string if GR_CACHE_STATS == 1. */
+ void dumpCacheStats(SkString*) const;
+ void dumpCacheStatsKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values) const;
+ void printCacheStats() const;
+
+ /** Prints GPU stats to the string if GR_GPU_STATS == 1. */
+ void dumpGpuStats(SkString*) const;
+ void dumpGpuStatsKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values) const;
+ void printGpuStats() const;
+
+ /** Returns a string with detailed information about the context & GPU, in JSON format. */
+ SkString dump() const;
+
+ /** Specify the TextBlob cache limit. If the current cache exceeds this limit it will purge.
+ this is for testing only */
+ void setTextBlobCacheLimit_ForTesting(size_t bytes);
+
+ /** Specify the sizes of the GrAtlasTextContext atlases. The configs pointer below should be
+ to an array of 3 entries */
+ void setTextContextAtlasSizes_ForTesting(const GrDrawOpAtlasConfig* configs);
+
+ /** Get pointer to atlas texture for given mask format. Note that this wraps an
+ actively mutating texture in an SkImage. This could yield unexpected results
+ if it gets cached or used more generally. */
+ sk_sp<SkImage> getFontAtlasImage_ForTesting(GrMaskFormat format, unsigned int index = 0);
+
+ GrAuditTrail* getAuditTrail() { return &fContext->fAuditTrail; }
+
+ GrContextOptions::PersistentCache* getPersistentCache() { return fContext->fPersistentCache; }
+
+ /** This is only useful for debug purposes */
+ SkDEBUGCODE(GrSingleOwner* debugSingleOwner() const { return &fContext->fSingleOwner; } )
+
private:
explicit GrContextPriv(GrContext* context) : fContext(context) {}
GrContextPriv(const GrContextPriv&); // unimpl
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index de6722f998..62db98edd4 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -386,9 +386,10 @@ sk_sp<GrRenderTargetOpList> GrDrawingManager::newRTOpList(GrRenderTargetProxy* r
auto resourceProvider = fContext->contextPriv().resourceProvider();
- sk_sp<GrRenderTargetOpList> opList(new GrRenderTargetOpList(rtp,
- resourceProvider,
- fContext->getAuditTrail()));
+ sk_sp<GrRenderTargetOpList> opList(new GrRenderTargetOpList(
+ rtp,
+ resourceProvider,
+ fContext->contextPriv().getAuditTrail()));
SkASSERT(rtp->getLastOpList() == opList.get());
if (managedOpList) {
@@ -410,7 +411,7 @@ sk_sp<GrTextureOpList> GrDrawingManager::newTextureOpList(GrTextureProxy* textur
sk_sp<GrTextureOpList> opList(new GrTextureOpList(fContext->contextPriv().resourceProvider(),
textureProxy,
- fContext->getAuditTrail()));
+ fContext->contextPriv().getAuditTrail()));
SkASSERT(textureProxy->getLastOpList() == opList.get());
@@ -482,11 +483,12 @@ sk_sp<GrRenderTargetContext> GrDrawingManager::makeRenderTargetContext(
sk_sp<GrRenderTargetProxy> rtp(sk_ref_sp(sProxy->asRenderTargetProxy()));
- return sk_sp<GrRenderTargetContext>(new GrRenderTargetContext(fContext, this, std::move(rtp),
- std::move(colorSpace),
- surfaceProps,
- fContext->getAuditTrail(),
- fSingleOwner, managedOpList));
+ return sk_sp<GrRenderTargetContext>(new GrRenderTargetContext(
+ fContext, this, std::move(rtp),
+ std::move(colorSpace),
+ surfaceProps,
+ fContext->contextPriv().getAuditTrail(),
+ fSingleOwner, managedOpList));
}
sk_sp<GrTextureContext> GrDrawingManager::makeTextureContext(sk_sp<GrSurfaceProxy> sProxy,
@@ -509,6 +511,6 @@ sk_sp<GrTextureContext> GrDrawingManager::makeTextureContext(sk_sp<GrSurfaceProx
return sk_sp<GrTextureContext>(new GrTextureContext(fContext, this, std::move(textureProxy),
std::move(colorSpace),
- fContext->getAuditTrail(),
+ fContext->contextPriv().getAuditTrail(),
fSingleOwner));
}
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp
index f1c8c8dbd0..feee9dd3c7 100644
--- a/src/gpu/GrTextureProducer.cpp
+++ b/src/gpu/GrTextureProducer.cpp
@@ -28,7 +28,8 @@ sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrContext* context,
if (GrPixelConfigIsSRGB(inputProxy->config())) {
colorSpace = SkColorSpace::MakeSRGB();
}
- sk_sp<GrRenderTargetContext> copyRTC = context->makeDeferredRenderTargetContextWithFallback(
+ sk_sp<GrRenderTargetContext> copyRTC =
+ context->contextPriv().makeDeferredRenderTargetContextWithFallback(
SkBackingFit::kExact, dstRect.width(), dstRect.height(), inputProxy->config(),
std::move(colorSpace), 1, mipMapped, inputProxy->origin());
if (!copyRTC) {
diff --git a/src/gpu/GrTracing.h b/src/gpu/GrTracing.h
index d4a49fd8cc..6a8ded7bbe 100644
--- a/src/gpu/GrTracing.h
+++ b/src/gpu/GrTracing.h
@@ -16,7 +16,7 @@ class GrContext;
* Context level GrTracing macros, classname and op are const char*, context is GrContext
*/
#define GR_CREATE_TRACE_MARKER_CONTEXT(classname, op, context) \
- GR_AUDIT_TRAIL_AUTO_FRAME(context->getAuditTrail(), classname "::" op); \
+ GR_AUDIT_TRAIL_AUTO_FRAME(context->contextPriv().getAuditTrail(), classname "::" op); \
TRACE_EVENT0("skia.gpu", classname "::" op);
#endif
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index 01d46f69e4..bd66dba62d 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -116,7 +116,8 @@ sk_sp<GrTextureProxy> GrYUVProvider::refAsTextureProxy(GrContext* ctx, const GrS
colorSpace = SkColorSpace::MakeSRGB();
}
// TODO: investigate preallocating mip maps here
- sk_sp<GrRenderTargetContext> renderTargetContext(ctx->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> renderTargetContext(
+ ctx->contextPriv().makeDeferredRenderTargetContext(
SkBackingFit::kExact, desc.fWidth, desc.fHeight, desc.fConfig, std::move(colorSpace),
desc.fSampleCnt, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin));
if (!renderTargetContext) {
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 2722292506..e7ba14e1d9 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -54,7 +54,7 @@
#if SK_SUPPORT_GPU
#define ASSERT_SINGLE_OWNER \
- SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fContext->debugSingleOwner());)
+SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fContext->contextPriv().debugSingleOwner());)
///////////////////////////////////////////////////////////////////////////////
@@ -164,7 +164,7 @@ sk_sp<GrRenderTargetContext> SkGpuDevice::MakeRenderTargetContext(
}
// This method is used to create SkGpuDevice's for SkSurface_Gpus. In this case
// they need to be exact.
- return context->makeDeferredRenderTargetContext(
+ return context->contextPriv().makeDeferredRenderTargetContext(
SkBackingFit::kExact,
origInfo.width(), origInfo.height(),
config, origInfo.refColorSpace(), sampleCount,
@@ -1048,7 +1048,7 @@ void SkGpuDevice::drawSprite(const SkBitmap& bitmap,
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawSprite", fContext.get());
- if (fContext->abandoned()) {
+ if (fContext->contextPriv().abandoned()) {
return;
}
@@ -1720,7 +1720,7 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
config = kRGBA_8888_GrPixelConfig;
}
- sk_sp<GrRenderTargetContext> rtc(fContext->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> rtc(fContext->contextPriv().makeDeferredRenderTargetContext(
fit, cinfo.fInfo.width(), cinfo.fInfo.height(), config,
fRenderTargetContext->colorSpaceInfo().refColorSpace(),
fRenderTargetContext->numStencilSamples(), GrMipMapped::kNo,
diff --git a/src/gpu/effects/GrConfigConversionEffect.h b/src/gpu/effects/GrConfigConversionEffect.h
index 40bbc97832..0b5a205e1c 100644
--- a/src/gpu/effects/GrConfigConversionEffect.h
+++ b/src/gpu/effects/GrConfigConversionEffect.h
@@ -46,9 +46,9 @@ public:
const SkImageInfo ii =
SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- sk_sp<GrRenderTargetContext> readRTC(context->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> readRTC(context->contextPriv().makeDeferredRenderTargetContext(
SkBackingFit::kExact, kSize, kSize, kConfig, nullptr));
- sk_sp<GrRenderTargetContext> tempRTC(context->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> tempRTC(context->contextPriv().makeDeferredRenderTargetContext(
SkBackingFit::kExact, kSize, kSize, kConfig, nullptr));
if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) {
return false;
diff --git a/src/gpu/effects/GrRRectBlurEffect.h b/src/gpu/effects/GrRRectBlurEffect.h
index 7ba02c7dd0..0e63a92c9e 100644
--- a/src/gpu/effects/GrRRectBlurEffect.h
+++ b/src/gpu/effects/GrRRectBlurEffect.h
@@ -52,7 +52,8 @@ public:
proxyProvider->findOrCreateProxyByUniqueKey(key, kBottomLeft_GrSurfaceOrigin));
if (!mask) {
// TODO: this could be approx but the texture coords will need to be updated
- sk_sp<GrRenderTargetContext> rtc(context->makeDeferredRenderTargetContextWithFallback(
+ sk_sp<GrRenderTargetContext> rtc(
+ context->contextPriv().makeDeferredRenderTargetContextWithFallback(
SkBackingFit::kExact, size.fWidth, size.fHeight, kAlpha_8_GrPixelConfig,
nullptr));
if (!rtc) {
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index ed6386b7f3..7ca7506687 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -46,9 +46,10 @@ GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrPipeline& pipeline,
// uniforms, varyings, textures, etc
GrGLProgramBuilder builder(gpu, pipeline, primProc, desc);
- if (gpu->getContext()->getPersistentCache() && gpu->glCaps().programBinarySupport()) {
+ auto persistentCache = gpu->getContext()->contextPriv().getPersistentCache();
+ if (persistentCache && gpu->glCaps().programBinarySupport()) {
sk_sp<SkData> key = SkData::MakeWithoutCopy(desc->asKey(), desc->keyLength());
- builder.fCached = gpu->getContext()->getPersistentCache()->load(*key);
+ builder.fCached = persistentCache->load(*key);
// the eventual end goal is to completely skip emitAndInstallProcs on a cache hit, but it's
// doing necessary setup in addition to generating the SkSL code. Currently we are only able
// to skip the SkSL->GLSL step on a cache hit.
@@ -141,7 +142,7 @@ GrGLProgram* GrGLProgramBuilder::finalize() {
}
if (this->gpu()->glCaps().programBinarySupport() &&
- this->gpu()->getContext()->getPersistentCache()) {
+ this->gpu()->getContext()->contextPriv().getPersistentCache()) {
GL_CALL(ProgramParameteri(programID, GR_GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GR_GL_TRUE));
}
@@ -267,7 +268,7 @@ GrGLProgram* GrGLProgramBuilder::finalize() {
this->resolveProgramResourceLocations(programID);
this->cleanupShaders(shadersToDelete);
- if (!cached && this->gpu()->getContext()->getPersistentCache() &&
+ if (!cached && this->gpu()->getContext()->contextPriv().getPersistentCache() &&
fGpu->glCaps().programBinarySupport()) {
GrGLsizei length = 0;
GL_CALL(GetProgramiv(programID, GL_PROGRAM_BINARY_LENGTH, &length));
@@ -285,8 +286,8 @@ GrGLProgram* GrGLProgramBuilder::finalize() {
memcpy(data.get() + offset, &binaryFormat, sizeof(binaryFormat));
offset += sizeof(binaryFormat);
memcpy(data.get() + offset, binary.get(), length);
- this->gpu()->getContext()->getPersistentCache()->store(*key,
- *SkData::MakeWithoutCopy(data.get(), dataLength));
+ this->gpu()->getContext()->contextPriv().getPersistentCache()->store(
+ *key, *SkData::MakeWithoutCopy(data.get(), dataLength));
}
}
return this->createProgram(programID);
diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp
index 4a10e101e2..6ebd02cc15 100644
--- a/src/gpu/text/GrAtlasTextContext.cpp
+++ b/src/gpu/text/GrAtlasTextContext.cpp
@@ -103,7 +103,7 @@ void GrAtlasTextContext::drawTextBlob(GrContext* context, GrTextUtils::Target* t
const SkTextBlob* blob, SkScalar x, SkScalar y,
SkDrawFilter* drawFilter, const SkIRect& clipBounds) {
// If we have been abandoned, then don't draw
- if (context->abandoned()) {
+ if (context->contextPriv().abandoned()) {
return;
}
@@ -317,7 +317,7 @@ void GrAtlasTextContext::drawText(GrContext* context, GrTextUtils::Target* targe
const SkMatrix& viewMatrix, const SkSurfaceProps& props,
const char text[], size_t byteLength, SkScalar x, SkScalar y,
const SkIRect& regionClipBounds) {
- if (context->abandoned()) {
+ if (context->contextPriv().abandoned()) {
return;
}
@@ -344,7 +344,7 @@ void GrAtlasTextContext::drawPosText(GrContext* context, GrTextUtils::Target* ta
int scalarsPerPosition, const SkPoint& offset,
const SkIRect& regionClipBounds) {
GrTextUtils::Paint paint(&skPaint, &target->colorSpaceInfo());
- if (context->abandoned()) {
+ if (context->contextPriv().abandoned()) {
return;
}
@@ -939,7 +939,7 @@ GR_DRAW_OP_TEST_DEFINE(GrAtlasTextOp) {
}
// Setup dummy SkPaint / GrPaint / GrRenderTargetContext
- sk_sp<GrRenderTargetContext> rtc(context->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> rtc(context->contextPriv().makeDeferredRenderTargetContext(
SkBackingFit::kApprox, 1024, 1024, kRGBA_8888_GrPixelConfig, nullptr));
SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 2337a36882..7b90d6e7ed 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -164,7 +164,7 @@ GrBackendObject SkImage::getTextureHandle(bool flushPendingGrContextIO,
}
bool SkImage::isValid(GrContext* context) const {
- if (context && context->abandoned()) {
+ if (context && context->contextPriv().abandoned()) {
return false;
}
return as_IB(this)->onIsValid(context);
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 1ce53c6c7f..0ba3f03d37 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -441,9 +441,10 @@ static sk_sp<SkImage> make_from_yuv_textures_copy(GrContext* ctx, SkYUVColorSpac
const int height = yuvSizes[0].fHeight;
// Needs to be a render target in order to draw to it for the yuv->rgb conversion.
- sk_sp<GrRenderTargetContext> renderTargetContext(ctx->makeDeferredRenderTargetContext(
- SkBackingFit::kExact, width, height, kRGBA_8888_GrPixelConfig,
- std::move(imageColorSpace), 1, GrMipMapped::kNo, origin));
+ sk_sp<GrRenderTargetContext> renderTargetContext(
+ ctx->contextPriv().makeDeferredRenderTargetContext(
+ SkBackingFit::kExact, width, height, kRGBA_8888_GrPixelConfig,
+ std::move(imageColorSpace), 1, GrMipMapped::kNo, origin));
if (!renderTargetContext) {
return nullptr;
}
@@ -766,8 +767,10 @@ sk_sp<SkImage> SkImage_Gpu::onMakeColorSpace(sk_sp<SkColorSpace> target, SkColor
return sk_ref_sp(const_cast<SkImage_Gpu*>(this));
}
- sk_sp<GrRenderTargetContext> renderTargetContext(fContext->makeDeferredRenderTargetContext(
- SkBackingFit::kExact, this->width(), this->height(), kRGBA_8888_GrPixelConfig, nullptr));
+ sk_sp<GrRenderTargetContext> renderTargetContext(
+ fContext->contextPriv().makeDeferredRenderTargetContext(
+ SkBackingFit::kExact, this->width(), this->height(),
+ kRGBA_8888_GrPixelConfig, nullptr));
if (!renderTargetContext) {
return nullptr;
}
@@ -794,7 +797,7 @@ sk_sp<SkImage> SkImage_Gpu::onMakeColorSpace(sk_sp<SkColorSpace> target, SkColor
bool SkImage_Gpu::onIsValid(GrContext* context) const {
// The base class has already checked that context isn't abandoned (if it's not nullptr)
- if (fContext->abandoned()) {
+ if (fContext->contextPriv().abandoned()) {
return false;
}