aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-03-06 08:20:37 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-06 14:23:45 +0000
commit0c4b7b1f2f1dd37204d401a6993119e5431942a6 (patch)
treeaf37ee06f3a29a0aeeba00f8bbcf67fbfd0bbea4
parent2f8622029d265e79eb11df8eb06a29ff3faa7ac0 (diff)
Move internal calls from GrContext to GrContextPriv
A mechanical bulk move just to get these out of the public API. TBR=bsalomon@google.com Change-Id: I813efbd54a09dd448275697c0e50947753a5cfd3 Reviewed-on: https://skia-review.googlesource.com/112262 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
-rw-r--r--bench/ImageCacheBudgetBench.cpp5
-rw-r--r--bench/SKPBench.cpp6
-rw-r--r--bench/nanobench.cpp5
-rw-r--r--dm/DMSrcSink.cpp10
-rw-r--r--gm/fontcache.cpp3
-rw-r--r--gm/windowrectangles.cpp3
-rw-r--r--include/gpu/GrContext.h86
-rw-r--r--samplecode/SampleAnimatedText.cpp5
-rw-r--r--samplecode/SampleChineseFling.cpp13
-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
-rw-r--r--tests/ClearTest.cpp5
-rw-r--r--tests/DefaultPathRendererTest.cpp6
-rw-r--r--tests/GLProgramsTest.cpp30
-rw-r--r--tests/GrCCPRTest.cpp3
-rw-r--r--tests/GrContextFactoryTest.cpp2
-rw-r--r--tests/GrMeshTest.cpp4
-rw-r--r--tests/GrPipelineDynamicStateTest.cpp4
-rw-r--r--tests/GrSurfaceTest.cpp4
-rw-r--r--tests/LazyProxyTest.cpp14
-rw-r--r--tests/OnFlushCallbackTest.cpp4
-rw-r--r--tests/PathRendererCacheTests.cpp2
-rw-r--r--tests/PrimitiveProcessorTest.cpp12
-rw-r--r--tests/ProcessorTest.cpp7
-rw-r--r--tests/RectangleTextureTest.cpp4
-rw-r--r--tests/ResourceCacheTest.cpp2
-rw-r--r--tests/SRGBMipMapTest.cpp12
-rw-r--r--tests/TessellatingPathRendererTests.cpp2
-rw-r--r--tests/TextBlobCacheTest.cpp3
-rw-r--r--tests/TextureProxyTest.cpp4
-rw-r--r--tools/debugger/SkDebugCanvas.cpp2
-rw-r--r--tools/gpu/GrTest.cpp48
56 files changed, 317 insertions, 266 deletions
diff --git a/bench/ImageCacheBudgetBench.cpp b/bench/ImageCacheBudgetBench.cpp
index 12e579060e..a6ee430c61 100644
--- a/bench/ImageCacheBudgetBench.cpp
+++ b/bench/ImageCacheBudgetBench.cpp
@@ -14,6 +14,7 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
+#include "GrContextPriv.h"
/** These benchmarks were designed to measure changes to GrResourceCache's replacement policy */
@@ -46,7 +47,7 @@ void set_cache_budget(SkCanvas* canvas, int approxImagesInBudget) {
GrContext* context = canvas->getGrContext();
SkASSERT(context);
context->flush();
- context->purgeAllUnlockedResources();
+ context->contextPriv().purgeAllUnlockedResources_ForTesting();
sk_sp<SkImage> image;
make_images(&image, 1);
draw_image(canvas, image.get());
@@ -55,7 +56,7 @@ void set_cache_budget(SkCanvas* canvas, int approxImagesInBudget) {
context->getResourceCacheUsage(&baselineCount, nullptr);
baselineCount -= 1; // for the image's textures.
context->setResourceCacheLimits(baselineCount + approxImagesInBudget, 1 << 30);
- context->purgeAllUnlockedResources();
+ context->contextPriv().purgeAllUnlockedResources_ForTesting();
}
//////////////////////////////////////////////////////////////////////////////
diff --git a/bench/SKPBench.cpp b/bench/SKPBench.cpp
index 4fbb1bba29..1391b40cf6 100644
--- a/bench/SKPBench.cpp
+++ b/bench/SKPBench.cpp
@@ -163,13 +163,13 @@ void SKPBench::drawPicture() {
static void draw_pic_for_stats(SkCanvas* canvas, GrContext* context, const SkPicture* picture,
SkTArray<SkString>* keys, SkTArray<double>* values,
const char* tag) {
- context->resetGpuStats();
+ context->contextPriv().resetGpuStats();
canvas->drawPicture(picture);
canvas->flush();
int offset = keys->count();
- context->dumpGpuStatsKeyValuePairs(keys, values);
- context->dumpCacheStatsKeyValuePairs(keys, values);
+ context->contextPriv().dumpGpuStatsKeyValuePairs(keys, values);
+ context->contextPriv().dumpCacheStatsKeyValuePairs(keys, values);
// append tag, but only to new tags
for (int i = offset; i < keys->count(); i++, offset++) {
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index f7f0bff82b..2246fbb07d 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -60,6 +60,7 @@ extern bool gSkForceRasterPipelineBlitter;
#if SK_SUPPORT_GPU
#include "gl/GrGLDefines.h"
#include "GrCaps.h"
+ #include "GrContextPriv.h"
#include "GrContextFactory.h"
#include "gl/GrGLUtil.h"
#include "SkGr.h"
@@ -230,8 +231,8 @@ struct GPUTarget : public Target {
}
void dumpStats() override {
- this->contextInfo.grContext()->printCacheStats();
- this->contextInfo.grContext()->printGpuStats();
+ this->contextInfo.grContext()->contextPriv().printCacheStats();
+ this->contextInfo.grContext()->contextPriv().printGpuStats();
}
};
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 149138d832..b84563701c 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -71,6 +71,10 @@
#include "SkXMLWriter.h"
#endif
+#if SK_SUPPORT_GPU
+#include "GrContextPriv.h"
+#endif
+
DEFINE_bool(multiPage, false, "For document-type backends, render the source"
" into multiple pages");
DEFINE_bool(RAW_threading, true, "Allow RAW decodes to run on multiple threads?");
@@ -1655,8 +1659,10 @@ Error GPUSink::onDraw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log,
}
canvas->flush();
if (FLAGS_gpuStats) {
- canvas->getGrContext()->dumpCacheStats(log);
- canvas->getGrContext()->dumpGpuStats(log);
+#if SK_SUPPORT_GPU
+ canvas->getGrContext()->contextPriv().dumpCacheStats(log);
+ canvas->getGrContext()->contextPriv().dumpGpuStats(log);
+#endif
}
if (info.colorType() == kRGB_565_SkColorType || info.colorType() == kARGB_4444_SkColorType) {
// We don't currently support readbacks into these formats on the GPU backend. Convert to
diff --git a/gm/fontcache.cpp b/gm/fontcache.cpp
index f7a1313fb9..6c99700d93 100644
--- a/gm/fontcache.cpp
+++ b/gm/fontcache.cpp
@@ -13,6 +13,7 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
+#include "GrContextPriv.h"
#include "GrContextOptions.h"
#include "SkCanvas.h"
#include "SkGraphics.h"
@@ -74,7 +75,7 @@ protected:
static const bool kShowAtlas = false;
if (kShowAtlas) {
if (auto ctx = canvas->getGrContext()) {
- auto img = ctx->getFontAtlasImage_ForTesting(kA8_GrMaskFormat);
+ auto img = ctx->contextPriv().getFontAtlasImage_ForTesting(kA8_GrMaskFormat);
canvas->drawImage(img, 0, 0);
}
}
diff --git a/gm/windowrectangles.cpp b/gm/windowrectangles.cpp
index 08fee7b811..931a154df4 100644
--- a/gm/windowrectangles.cpp
+++ b/gm/windowrectangles.cpp
@@ -199,7 +199,8 @@ void WindowRectanglesMaskGM::visualizeAlphaMask(GrContext* ctx, GrRenderTargetCo
const int padRight = (kDeviceRect.right() - kCoverRect.right()) / 2;
const int padBottom = (kDeviceRect.bottom() - kCoverRect.bottom()) / 2;
sk_sp<GrRenderTargetContext> maskRTC(
- ctx->makeDeferredRenderTargetContextWithFallback(SkBackingFit::kExact,
+ ctx->contextPriv().makeDeferredRenderTargetContextWithFallback(
+ SkBackingFit::kExact,
kCoverRect.width() + padRight,
kCoverRect.height() + padBottom,
kAlpha_8_GrPixelConfig, nullptr));
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 6578638183..bbd43df694 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -187,13 +187,6 @@ public:
virtual void freeGpuResources();
/**
- * 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();
-
- /**
* Purge GPU resources that haven't been used in the past 'msNotUsed' milliseconds or are
* otherwise marked for deletion, regardless of whether the context is under budget.
*/
@@ -239,38 +232,6 @@ public:
*/
int maxSurfaceSampleCountForColorType(SkColorType) const;
- /*
- * 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);
-
///////////////////////////////////////////////////////////////////////////
// Misc.
@@ -308,53 +269,14 @@ public:
*/
uint32_t uniqueID() { return fUniqueID; }
- ///////////////////////////////////////////////////////////////////////////
- // Functions intended for internal use only.
- 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);
-
- /** Enumerates all cached GPU resources and dumps their memory to traceMemoryDump. */
- void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const;
-
- /** 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 &fAuditTrail; }
-
- GrContextOptions::PersistentCache* getPersistentCache() { return fPersistentCache; }
-
- /** This is only useful for debug purposes */
- SkDEBUGCODE(GrSingleOwner* debugSingleOwner() const { return &fSingleOwner; } )
-
// Provides access to functions that aren't part of the public API.
GrContextPriv contextPriv();
const GrContextPriv contextPriv() const;
+ /** Enumerates all cached GPU resources and dumps their memory to traceMemoryDump. */
+ // Chrome is using this!
+ void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const;
+
protected:
GrContext(GrBackend, int32_t id = SK_InvalidGenID);
diff --git a/samplecode/SampleAnimatedText.cpp b/samplecode/SampleAnimatedText.cpp
index f93cecaf8f..71f3b87d47 100644
--- a/samplecode/SampleAnimatedText.cpp
+++ b/samplecode/SampleAnimatedText.cpp
@@ -19,6 +19,7 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
+#include "GrContextPriv.h"
#endif
SkRandom gRand;
@@ -103,8 +104,8 @@ protected:
#if SK_SUPPORT_GPU
GrContext* grContext = canvas->getGrContext();
if (grContext) {
- sk_sp<SkImage> image =
- grContext->getFontAtlasImage_ForTesting(GrMaskFormat::kA8_GrMaskFormat);
+ sk_sp<SkImage> image = grContext->contextPriv().getFontAtlasImage_ForTesting(
+ GrMaskFormat::kA8_GrMaskFormat);
canvas->drawImageRect(image,
SkRect::MakeXYWH(512.0f, 10.0f, 512.0f, 512.0f), &paint);
}
diff --git a/samplecode/SampleChineseFling.cpp b/samplecode/SampleChineseFling.cpp
index 76222e91a0..05e0218bce 100644
--- a/samplecode/SampleChineseFling.cpp
+++ b/samplecode/SampleChineseFling.cpp
@@ -17,6 +17,7 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
+#include "GrContextPriv.h"
#endif
static void make_paint(SkPaint* paint, sk_sp<SkTypeface> typeface) {
@@ -173,16 +174,20 @@ protected:
GrContext* grContext = canvas->getGrContext();
if (grContext) {
sk_sp<SkImage> image =
- grContext->getFontAtlasImage_ForTesting(GrMaskFormat::kA8_GrMaskFormat, 0);
+ grContext->contextPriv().getFontAtlasImage_ForTesting(
+ GrMaskFormat::kA8_GrMaskFormat, 0);
canvas->drawImageRect(image,
SkRect::MakeXYWH(10.0f, 10.0f, 512.0f, 512.0), &paint);
- image = grContext->getFontAtlasImage_ForTesting(GrMaskFormat::kA8_GrMaskFormat, 1);
+ image = grContext->contextPriv().getFontAtlasImage_ForTesting(
+ GrMaskFormat::kA8_GrMaskFormat, 1);
canvas->drawImageRect(image,
SkRect::MakeXYWH(522.0f, 10.0f, 512.f, 512.0f), &paint);
- image = grContext->getFontAtlasImage_ForTesting(GrMaskFormat::kA8_GrMaskFormat, 2);
+ image = grContext->contextPriv().getFontAtlasImage_ForTesting(
+ GrMaskFormat::kA8_GrMaskFormat, 2);
canvas->drawImageRect(image,
SkRect::MakeXYWH(10.0f, 522.0f, 512.0f, 512.0f), &paint);
- image = grContext->getFontAtlasImage_ForTesting(GrMaskFormat::kA8_GrMaskFormat, 3);
+ image = grContext->contextPriv().getFontAtlasImage_ForTesting(
+ GrMaskFormat::kA8_GrMaskFormat, 3);
canvas->drawImageRect(image,
SkRect::MakeXYWH(522.0f, 522.0f, 512.0f, 512.0f), &paint);
}
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;
}
diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp
index 7424c5a3b5..429b9e1d5d 100644
--- a/tests/ClearTest.cpp
+++ b/tests/ClearTest.cpp
@@ -42,8 +42,9 @@ static bool check_rect(GrRenderTargetContext* rtc, const SkIRect& rect, uint32_t
}
sk_sp<GrRenderTargetContext> newRTC(GrContext* context, int w, int h) {
- return context->makeDeferredRenderTargetContext(SkBackingFit::kExact, w, h,
- kRGBA_8888_GrPixelConfig, nullptr);
+ return context->contextPriv().makeDeferredRenderTargetContext(
+ SkBackingFit::kExact, w, h,
+ kRGBA_8888_GrPixelConfig, nullptr);
}
static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
diff --git a/tests/DefaultPathRendererTest.cpp b/tests/DefaultPathRendererTest.cpp
index 176461106f..155d6a7b43 100644
--- a/tests/DefaultPathRendererTest.cpp
+++ b/tests/DefaultPathRendererTest.cpp
@@ -68,7 +68,8 @@ static void run_test(GrContext* ctx, skiatest::Reporter* reporter) {
GrStyle style(SkStrokeRec::kFill_InitStyle);
{
- auto rtc = ctx->makeDeferredRenderTargetContext(SkBackingFit::kApprox,
+ auto rtc = ctx->contextPriv().makeDeferredRenderTargetContext(
+ SkBackingFit::kApprox,
kBigSize/2+1, kBigSize/2+1,
kRGBA_8888_GrPixelConfig, nullptr);
@@ -88,7 +89,8 @@ static void run_test(GrContext* ctx, skiatest::Reporter* reporter) {
}
{
- auto rtc = ctx->makeDeferredRenderTargetContext(SkBackingFit::kExact, kBigSize, kBigSize,
+ auto rtc = ctx->contextPriv().makeDeferredRenderTargetContext(
+ SkBackingFit::kExact, kBigSize, kBigSize,
kRGBA_8888_GrPixelConfig, nullptr);
rtc->clear(nullptr, GrColorPackRGBA(0x0, 0x0, 0x0, 0xFF),
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 1384e3885b..e3639fbce6 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -155,15 +155,15 @@ static sk_sp<GrRenderTargetContext> random_render_target_context(GrContext* cont
// Above could be 0 if msaa isn't supported.
sampleCnt = SkTMax(1, sampleCnt);
- sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext(
- SkBackingFit::kExact,
- kRenderTargetWidth,
- kRenderTargetHeight,
- kRGBA_8888_GrPixelConfig,
- nullptr,
- sampleCnt,
- GrMipMapped::kNo,
- origin));
+ sk_sp<GrRenderTargetContext> renderTargetContext(
+ context->contextPriv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
+ kRenderTargetWidth,
+ kRenderTargetHeight,
+ kRGBA_8888_GrPixelConfig,
+ nullptr,
+ sampleCnt,
+ GrMipMapped::kNo,
+ origin));
return renderTargetContext;
}
@@ -318,12 +318,12 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma
drawingManager->flush(nullptr);
// Validate that GrFPs work correctly without an input.
- sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext(
- SkBackingFit::kExact,
- kRenderTargetWidth,
- kRenderTargetHeight,
- kRGBA_8888_GrPixelConfig,
- nullptr));
+ sk_sp<GrRenderTargetContext> renderTargetContext(
+ context->contextPriv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
+ kRenderTargetWidth,
+ kRenderTargetHeight,
+ kRGBA_8888_GrPixelConfig,
+ nullptr));
if (!renderTargetContext) {
SkDebugf("Could not allocate a renderTargetContext");
return false;
diff --git a/tests/GrCCPRTest.cpp b/tests/GrCCPRTest.cpp
index cba94b4bf5..2a51c1b176 100644
--- a/tests/GrCCPRTest.cpp
+++ b/tests/GrCCPRTest.cpp
@@ -59,7 +59,8 @@ public:
CCPRPathDrawer(GrContext* ctx, skiatest::Reporter* reporter)
: fCtx(ctx)
, fCCPR(fCtx->contextPriv().drawingManager()->getCoverageCountingPathRenderer())
- , fRTC(fCtx->makeDeferredRenderTargetContext(SkBackingFit::kExact, kCanvasSize,
+ , fRTC(fCtx->contextPriv().makeDeferredRenderTargetContext(
+ SkBackingFit::kExact, kCanvasSize,
kCanvasSize, kRGBA_8888_GrPixelConfig,
nullptr)) {
if (!fCCPR) {
diff --git a/tests/GrContextFactoryTest.cpp b/tests/GrContextFactoryTest.cpp
index 29f68366c3..bebfd4d530 100644
--- a/tests/GrContextFactoryTest.cpp
+++ b/tests/GrContextFactoryTest.cpp
@@ -166,7 +166,7 @@ DEF_GPUTEST(GrContextFactory_executorAndTaskGroup, reporter, options) {
DEF_GPUTEST_FOR_ALL_CONTEXTS(GrContextDump, reporter, ctxInfo) {
// Ensure that GrContext::dump doesn't assert (which is possible, if the JSON code is wrong)
- SkString result = ctxInfo.grContext()->dump();
+ SkString result = ctxInfo.grContext()->contextPriv().dump();
REPORTER_ASSERT(reporter, !result.isEmpty());
}
diff --git a/tests/GrMeshTest.cpp b/tests/GrMeshTest.cpp
index acac61b95f..80788ddc07 100644
--- a/tests/GrMeshTest.cpp
+++ b/tests/GrMeshTest.cpp
@@ -82,8 +82,8 @@ static void run_test(const char* testName, skiatest::Reporter*, const sk_sp<GrRe
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrMeshTest, reporter, ctxInfo) {
GrContext* const context = ctxInfo.grContext();
- sk_sp<GrRenderTargetContext> rtc(
- context->makeDeferredRenderTargetContext(SkBackingFit::kExact, kImageWidth, kImageHeight,
+ sk_sp<GrRenderTargetContext> rtc(context->contextPriv().makeDeferredRenderTargetContext(
+ SkBackingFit::kExact, kImageWidth, kImageHeight,
kRGBA_8888_GrPixelConfig, nullptr));
if (!rtc) {
ERRORF(reporter, "could not create render target context.");
diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp
index f715684ef9..7db0d9457d 100644
--- a/tests/GrPipelineDynamicStateTest.cpp
+++ b/tests/GrPipelineDynamicStateTest.cpp
@@ -148,8 +148,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrPipelineDynamicStateTest, reporter, ctxInfo
GrContext* const context = ctxInfo.grContext();
GrResourceProvider* rp = context->contextPriv().resourceProvider();
- sk_sp<GrRenderTargetContext> rtc(
- context->makeDeferredRenderTargetContext(SkBackingFit::kExact, kScreenSize, kScreenSize,
+ sk_sp<GrRenderTargetContext> rtc(context->contextPriv().makeDeferredRenderTargetContext(
+ SkBackingFit::kExact, kScreenSize, kScreenSize,
kRGBA_8888_GrPixelConfig, nullptr));
if (!rtc) {
ERRORF(reporter, "could not create render target context.");
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index daef511bb6..18c0275cba 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -197,7 +197,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(InitialTextureClear, reporter, context_info)
texCtx->writePixels(info, data.get(), 0, 0, 0);
}
}
- context->purgeAllUnlockedResources();
+ context->contextPriv().purgeAllUnlockedResources_ForTesting();
// Try creating the texture as a deferred proxy.
for (int i = 0; i < 2; ++i) {
@@ -224,7 +224,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(InitialTextureClear, reporter, context_info)
surfCtx->writePixels(info, data.get(), 0, 0, 0);
}
}
- context->purgeAllUnlockedResources();
+ context->contextPriv().purgeAllUnlockedResources_ForTesting();
}
}
}
diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp
index da83dcbbbc..9253678dbb 100644
--- a/tests/LazyProxyTest.cpp
+++ b/tests/LazyProxyTest.cpp
@@ -187,12 +187,12 @@ DEF_GPUTEST(LazyProxyTest, reporter, /* options */) {
for (bool nullTexture : {false, true}) {
LazyProxyTest test(reporter);
ctx->contextPriv().addOnFlushCallbackObject(&test);
- sk_sp<GrRenderTargetContext> rtc =
- ctx->makeDeferredRenderTargetContext(SkBackingFit::kExact, 100, 100,
- kRGBA_8888_GrPixelConfig, nullptr);
+ sk_sp<GrRenderTargetContext> rtc = ctx->contextPriv().makeDeferredRenderTargetContext(
+ SkBackingFit::kExact, 100, 100,
+ kRGBA_8888_GrPixelConfig, nullptr);
REPORTER_ASSERT(reporter, rtc);
- sk_sp<GrRenderTargetContext> mockAtlas =
- ctx->makeDeferredRenderTargetContext(SkBackingFit::kExact, 10, 10,
+ sk_sp<GrRenderTargetContext> mockAtlas = ctx->contextPriv().makeDeferredRenderTargetContext(
+ SkBackingFit::kExact, 10, 10,
kAlpha_half_GrPixelConfig, nullptr);
REPORTER_ASSERT(reporter, mockAtlas);
rtc->priv().testingOnly_addDrawOp(LazyProxyTest::Clip(&test, mockAtlas->asTextureProxy()),
@@ -316,8 +316,8 @@ DEF_GPUTEST(LazyProxyFailedInstantiationTest, reporter, /* options */) {
GrResourceProvider* resourceProvider = ctx->contextPriv().resourceProvider();
GrProxyProvider* proxyProvider = ctx->contextPriv().proxyProvider();
for (bool failInstantiation : {false, true}) {
- sk_sp<GrRenderTargetContext> rtc =
- ctx->makeDeferredRenderTargetContext(SkBackingFit::kExact, 100, 100,
+ sk_sp<GrRenderTargetContext> rtc = ctx->contextPriv().makeDeferredRenderTargetContext(
+ SkBackingFit::kExact, 100, 100,
kRGBA_8888_GrPixelConfig, nullptr);
REPORTER_ASSERT(reporter, rtc);
diff --git a/tests/OnFlushCallbackTest.cpp b/tests/OnFlushCallbackTest.cpp
index 5cd3bcd480..73ac5f191e 100644
--- a/tests/OnFlushCallbackTest.cpp
+++ b/tests/OnFlushCallbackTest.cpp
@@ -421,7 +421,7 @@ private:
// This creates an off-screen rendertarget whose ops which eventually pull from the atlas.
static sk_sp<GrTextureProxy> make_upstream_image(GrContext* context, AtlasObject* object, int start,
sk_sp<GrTextureProxy> atlasProxy) {
- sk_sp<GrRenderTargetContext> rtc(context->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> rtc(context->contextPriv().makeDeferredRenderTargetContext(
SkBackingFit::kApprox,
3*kDrawnTileSize,
kDrawnTileSize,
@@ -535,7 +535,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(OnFlushCallbackTest, reporter, ctxInfo) {
static const int kFinalWidth = 6*kDrawnTileSize;
static const int kFinalHeight = kDrawnTileSize;
- sk_sp<GrRenderTargetContext> rtc(context->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> rtc(context->contextPriv().makeDeferredRenderTargetContext(
SkBackingFit::kApprox,
kFinalWidth,
kFinalHeight,
diff --git a/tests/PathRendererCacheTests.cpp b/tests/PathRendererCacheTests.cpp
index 19197b0d5f..f8c95b34a4 100644
--- a/tests/PathRendererCacheTests.cpp
+++ b/tests/PathRendererCacheTests.cpp
@@ -79,7 +79,7 @@ static void test_path(skiatest::Reporter* reporter,
ctx->setResourceCacheLimits(100, 8000000);
GrResourceCache* cache = ctx->contextPriv().getResourceCache();
- sk_sp<GrRenderTargetContext> rtc(ctx->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> rtc(ctx->contextPriv().makeDeferredRenderTargetContext(
SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig, nullptr, 1, GrMipMapped::kNo,
kTopLeft_GrSurfaceOrigin));
if (!rtc) {
diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp
index 089d6ce1bf..b5f508bb7a 100644
--- a/tests/PrimitiveProcessorTest.cpp
+++ b/tests/PrimitiveProcessorTest.cpp
@@ -115,10 +115,10 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
GrGpu* gpu = context->contextPriv().getGpu();
#endif
- sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext(
- SkBackingFit::kApprox,
- 1, 1, kRGBA_8888_GrPixelConfig,
- nullptr));
+ sk_sp<GrRenderTargetContext> renderTargetContext(
+ context->contextPriv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
+ 1, 1, kRGBA_8888_GrPixelConfig,
+ nullptr));
if (!renderTargetContext) {
ERRORF(reporter, "Could not create render target context.");
return;
@@ -129,7 +129,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
return;
}
context->flush();
- context->resetGpuStats();
+ context->contextPriv().resetGpuStats();
#if GR_GPU_STATS
REPORTER_ASSERT(reporter, gpu->stats()->numDraws() == 0);
REPORTER_ASSERT(reporter, gpu->stats()->numFailedDraws() == 0);
@@ -145,7 +145,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, gpu->stats()->numDraws() == 1);
REPORTER_ASSERT(reporter, gpu->stats()->numFailedDraws() == 0);
#endif
- context->resetGpuStats();
+ context->contextPriv().resetGpuStats();
renderTargetContext->priv().testingOnly_addDrawOp(Op::Make(attribCnt + 1));
context->flush();
#if GR_GPU_STATS
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index aea5208368..2694bca005 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -168,7 +168,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) {
for (bool makeClone : {false, true}) {
for (int parentCnt = 0; parentCnt < 2; parentCnt++) {
sk_sp<GrRenderTargetContext> renderTargetContext(
- context->makeDeferredRenderTargetContext(SkBackingFit::kApprox, 1, 1,
+ context->contextPriv().makeDeferredRenderTargetContext(
+ SkBackingFit::kApprox, 1, 1,
kRGBA_8888_GrPixelConfig, nullptr));
{
bool texelBufferSupport = context->caps()->shaderCaps()->texelBufferSupport();
@@ -365,7 +366,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor
// Make the destination context for the test.
static constexpr int kRenderSize = 256;
- sk_sp<GrRenderTargetContext> rtc = context->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> rtc = context->contextPriv().makeDeferredRenderTargetContext(
SkBackingFit::kExact, kRenderSize, kRenderSize, kRGBA_8888_GrPixelConfig, nullptr);
sk_sp<GrTextureProxy> proxies[2];
@@ -497,7 +498,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorCloneTest, reporter, ctxInfo) {
// Make the destination context for the test.
static constexpr int kRenderSize = 1024;
- sk_sp<GrRenderTargetContext> rtc = context->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> rtc = context->contextPriv().makeDeferredRenderTargetContext(
SkBackingFit::kExact, kRenderSize, kRenderSize, kRGBA_8888_GrPixelConfig, nullptr);
sk_sp<GrTextureProxy> proxies[2];
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index 8994f56127..08cedd0be3 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -22,8 +22,8 @@
// skbug.com/5932
static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrContext* context,
sk_sp<GrTextureProxy> rectProxy, uint32_t expectedPixelValues[]) {
- sk_sp<GrRenderTargetContext> rtContext(
- context->makeDeferredRenderTargetContext(SkBackingFit::kExact, rectProxy->width(),
+ sk_sp<GrRenderTargetContext> rtContext(context->contextPriv().makeDeferredRenderTargetContext(
+ SkBackingFit::kExact, rectProxy->width(),
rectProxy->height(), rectProxy->config(),
nullptr));
for (auto filter : {GrSamplerState::Filter::kNearest,
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index 55f4f856d2..2ceb567688 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -1465,7 +1465,7 @@ static void test_partial_purge(skiatest::Reporter* reporter) {
};
// ensure all are purged before the next
- context->purgeAllUnlockedResources();
+ context->contextPriv().purgeAllUnlockedResources_ForTesting();
REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceCount());
REPORTER_ASSERT(reporter, 0 == cache->getPurgeableBytes());
diff --git a/tests/SRGBMipMapTest.cpp b/tests/SRGBMipMapTest.cpp
index 466aad2dcc..91294dedb7 100644
--- a/tests/SRGBMipMapTest.cpp
+++ b/tests/SRGBMipMapTest.cpp
@@ -136,10 +136,14 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SRGBMipMaps, reporter, ctxInfo) {
// Create two render target contexts (L32 and S32)
sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::MakeSRGB();
- sk_sp<GrRenderTargetContext> l32RenderTargetContext = context->makeDeferredRenderTargetContext(
- SkBackingFit::kExact, rtS, rtS, kRGBA_8888_GrPixelConfig, nullptr);
- sk_sp<GrRenderTargetContext> s32RenderTargetContext = context->makeDeferredRenderTargetContext(
- SkBackingFit::kExact, rtS, rtS, kSRGBA_8888_GrPixelConfig, std::move(srgbColorSpace));
+ sk_sp<GrRenderTargetContext> l32RenderTargetContext =
+ context->contextPriv().makeDeferredRenderTargetContext(
+ SkBackingFit::kExact, rtS, rtS,
+ kRGBA_8888_GrPixelConfig, nullptr);
+ sk_sp<GrRenderTargetContext> s32RenderTargetContext =
+ context->contextPriv().makeDeferredRenderTargetContext(
+ SkBackingFit::kExact, rtS, rtS,
+ kSRGBA_8888_GrPixelConfig, std::move(srgbColorSpace));
SkRect rect = SkRect::MakeWH(SkIntToScalar(rtS), SkIntToScalar(rtS));
GrNoClip noClip;
diff --git a/tests/TessellatingPathRendererTests.cpp b/tests/TessellatingPathRendererTests.cpp
index f6304f5b18..451391762d 100644
--- a/tests/TessellatingPathRendererTests.cpp
+++ b/tests/TessellatingPathRendererTests.cpp
@@ -485,7 +485,7 @@ static void test_path(GrContext* ctx,
DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) {
GrContext* ctx = ctxInfo.grContext();
- sk_sp<GrRenderTargetContext> rtc(ctx->makeDeferredRenderTargetContext(
+ sk_sp<GrRenderTargetContext> rtc(ctx->contextPriv().makeDeferredRenderTargetContext(
SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig, nullptr, 1, GrMipMapped::kNo,
kTopLeft_GrSurfaceOrigin));
if (!rtc) {
diff --git a/tests/TextBlobCacheTest.cpp b/tests/TextBlobCacheTest.cpp
index bd74301117..4d606c9550 100644
--- a/tests/TextBlobCacheTest.cpp
+++ b/tests/TextBlobCacheTest.cpp
@@ -25,6 +25,7 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
+#include "GrContextPriv.h"
#include "GrTest.h"
static void draw(SkCanvas* canvas, int redraw, const SkTArray<sk_sp<SkTextBlob>>& blobs) {
@@ -54,7 +55,7 @@ static void text_blob_cache_inner(skiatest::Reporter* reporter, GrContext* conte
// configure our context for maximum stressing of cache and atlas
if (stressTest) {
GrTest::SetupAlwaysEvictAtlas(context);
- context->setTextBlobCacheLimit_ForTesting(0);
+ context->contextPriv().setTextBlobCacheLimit_ForTesting(0);
}
SkImageInfo info = SkImageInfo::Make(kWidth, kHeight, kN32_SkColorType, kPremul_SkAlphaType);
diff --git a/tests/TextureProxyTest.cpp b/tests/TextureProxyTest.cpp
index 8d0df6f6d7..0c93977a74 100644
--- a/tests/TextureProxyTest.cpp
+++ b/tests/TextureProxyTest.cpp
@@ -232,7 +232,7 @@ static void invalidation_test(GrContext* context, skiatest::Reporter* reporter)
REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
textureImg = nullptr;
- context->purgeAllUnlockedResources();
+ context->contextPriv().purgeAllUnlockedResources_ForTesting();
REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
@@ -271,7 +271,7 @@ static void invalidation_and_instantiation_test(GrContext* context, skiatest::Re
REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
proxy = nullptr;
- context->purgeAllUnlockedResources();
+ context->contextPriv().purgeAllUnlockedResources_ForTesting();
REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
diff --git a/tools/debugger/SkDebugCanvas.cpp b/tools/debugger/SkDebugCanvas.cpp
index 0bfd85f7f9..d2dddb8d15 100644
--- a/tools/debugger/SkDebugCanvas.cpp
+++ b/tools/debugger/SkDebugCanvas.cpp
@@ -363,7 +363,7 @@ GrAuditTrail* SkDebugCanvas::getAuditTrail(SkCanvas* canvas) {
#if SK_SUPPORT_GPU
GrContext* ctx = canvas->getGrContext();
if (ctx) {
- at = ctx->getAuditTrail();
+ at = ctx->contextPriv().getAuditTrail();
}
#endif
return at;
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp
index 241bbc2f60..3e9f73a6cb 100644
--- a/tools/gpu/GrTest.cpp
+++ b/tools/gpu/GrTest.cpp
@@ -51,7 +51,7 @@ void SetupAlwaysEvictAtlas(GrContext* context) {
configs[kARGB_GrMaskFormat].fPlotWidth = dim;
configs[kARGB_GrMaskFormat].fPlotHeight = dim;
- context->setTextContextAtlasSizes_ForTesting(configs);
+ context->contextPriv().setTextContextAtlasSizes_ForTesting(configs);
}
GrBackendTexture CreateBackendTexture(GrBackend backend, int width, int height,
@@ -89,12 +89,12 @@ bool GrRenderTargetContext::isWrapped_ForTesting() const {
return fRenderTargetProxy->isWrapped_ForTesting();
}
-void GrContext::setTextBlobCacheLimit_ForTesting(size_t bytes) {
- fTextBlobCache->setBudget(bytes);
+void GrContextPriv::setTextBlobCacheLimit_ForTesting(size_t bytes) {
+ fContext->fTextBlobCache->setBudget(bytes);
}
-void GrContext::setTextContextAtlasSizes_ForTesting(const GrDrawOpAtlasConfig* configs) {
- GrAtlasManager* atlasManager = this->contextPriv().getFullAtlasManager();
+void GrContextPriv::setTextContextAtlasSizes_ForTesting(const GrDrawOpAtlasConfig* configs) {
+ GrAtlasManager* atlasManager = this->getFullAtlasManager();
if (atlasManager) {
atlasManager->setAtlasSizes_ForTesting(configs);
}
@@ -102,56 +102,56 @@ void GrContext::setTextContextAtlasSizes_ForTesting(const GrDrawOpAtlasConfig* c
///////////////////////////////////////////////////////////////////////////////
-void GrContext::purgeAllUnlockedResources() {
- fResourceCache->purgeAllUnlocked();
+void GrContextPriv::purgeAllUnlockedResources_ForTesting() {
+ fContext->fResourceCache->purgeAllUnlocked();
}
-void GrContext::resetGpuStats() const {
+void GrContextPriv::resetGpuStats() const {
#if GR_GPU_STATS
- fGpu->stats()->reset();
+ fContext->fGpu->stats()->reset();
#endif
}
-void GrContext::dumpCacheStats(SkString* out) const {
+void GrContextPriv::dumpCacheStats(SkString* out) const {
#if GR_CACHE_STATS
- fResourceCache->dumpStats(out);
+ fContext->fResourceCache->dumpStats(out);
#endif
}
-void GrContext::dumpCacheStatsKeyValuePairs(SkTArray<SkString>* keys,
- SkTArray<double>* values) const {
+void GrContextPriv::dumpCacheStatsKeyValuePairs(SkTArray<SkString>* keys,
+ SkTArray<double>* values) const {
#if GR_CACHE_STATS
- fResourceCache->dumpStatsKeyValuePairs(keys, values);
+ fContext->fResourceCache->dumpStatsKeyValuePairs(keys, values);
#endif
}
-void GrContext::printCacheStats() const {
+void GrContextPriv::printCacheStats() const {
SkString out;
this->dumpCacheStats(&out);
SkDebugf("%s", out.c_str());
}
-void GrContext::dumpGpuStats(SkString* out) const {
+void GrContextPriv::dumpGpuStats(SkString* out) const {
#if GR_GPU_STATS
- return fGpu->stats()->dump(out);
+ return fContext->fGpu->stats()->dump(out);
#endif
}
-void GrContext::dumpGpuStatsKeyValuePairs(SkTArray<SkString>* keys,
- SkTArray<double>* values) const {
+void GrContextPriv::dumpGpuStatsKeyValuePairs(SkTArray<SkString>* keys,
+ SkTArray<double>* values) const {
#if GR_GPU_STATS
- return fGpu->stats()->dumpKeyValuePairs(keys, values);
+ return fContext->fGpu->stats()->dumpKeyValuePairs(keys, values);
#endif
}
-void GrContext::printGpuStats() const {
+void GrContextPriv::printGpuStats() const {
SkString out;
this->dumpGpuStats(&out);
SkDebugf("%s", out.c_str());
}
-sk_sp<SkImage> GrContext::getFontAtlasImage_ForTesting(GrMaskFormat format, unsigned int index) {
- auto restrictedAtlasManager = this->contextPriv().getRestrictedAtlasManager();
+sk_sp<SkImage> GrContextPriv::getFontAtlasImage_ForTesting(GrMaskFormat format, unsigned int index) {
+ auto restrictedAtlasManager = this->getRestrictedAtlasManager();
unsigned int numProxies;
const sk_sp<GrTextureProxy>* proxies = restrictedAtlasManager->getProxies(format, &numProxies);
@@ -160,7 +160,7 @@ sk_sp<SkImage> GrContext::getFontAtlasImage_ForTesting(GrMaskFormat format, unsi
}
SkASSERT(proxies[index]->priv().isExact());
- sk_sp<SkImage> image(new SkImage_Gpu(this, kNeedNewImageUniqueID, kPremul_SkAlphaType,
+ sk_sp<SkImage> image(new SkImage_Gpu(fContext, kNeedNewImageUniqueID, kPremul_SkAlphaType,
proxies[index], nullptr, SkBudgeted::kNo));
return image;
}