Update more tests to use the GrDirectContext/GrRecordingContext pair
This should be the last batch of tests. All the remaining uses of
GrContext should be resolved when SkImage no longer requires a context.
Change-Id: I47eeb3b74c28f483c20d9bec4daecbdb6d2cb982
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305541
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp
index 22c152b..ad47501 100644
--- a/tests/EGLImageTest.cpp
+++ b/tests/EGLImageTest.cpp
@@ -83,7 +83,7 @@
///////////////////////////////// CONTEXT 1 ///////////////////////////////////
- // Use GL Context 1 to create a texture unknown to GrContext.
+ // Use GL Context 1 to create a texture unknown to the GrDirectContext.
context1->flushAndSubmit();
static const int kSize = 100;
@@ -135,7 +135,7 @@
GR_GL_CALL(glCtx1->gl(), TexSubImage2D(texInfo.fTarget, 0, 0, 0, kSize, kSize,
GR_GL_RGBA, GR_GL_UNSIGNED_BYTE, pixels.get()));
GR_GL_CALL(glCtx1->gl(), Finish());
- // We've been making direct GL calls in GL context 1, let GrContext 1 know its internal
+ // We've been making direct GL calls in GL context 1, let GrDirectContext 1 know its internal
// state is invalid.
context1->resetContext();
diff --git a/tests/GrCCPRTest.cpp b/tests/GrCCPRTest.cpp
index c706e8e..16ba73c 100644
--- a/tests/GrCCPRTest.cpp
+++ b/tests/GrCCPRTest.cpp
@@ -65,7 +65,7 @@
{kCanvasSize, kCanvasSize}))
, fDoStroke(DoStroke::kYes == doStroke) {
if (!fCCPR) {
- ERRORF(reporter, "ccpr not enabled in GrContext for ccpr tests");
+ ERRORF(reporter, "ccpr not enabled in GrDirectContext for ccpr tests");
}
if (!fRTC) {
ERRORF(reporter, "failed to create GrRenderTargetContext for ccpr tests");
@@ -550,7 +550,7 @@
};
DEF_CCPR_TEST(CCPR_cache_mostlyVisible)
-// Ensures GrContext::performDeferredCleanup works.
+// Ensures GrDirectContext::performDeferredCleanup works.
class CCPR_cache_deferredCleanup : public CCPRCacheTest {
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr,
const RecordLastMockAtlasIDs& atlasIDRecorder) override {
diff --git a/tests/GrContextFactoryTest.cpp b/tests/GrContextFactoryTest.cpp
index 94950e8..32fa734 100644
--- a/tests/GrContextFactoryTest.cpp
+++ b/tests/GrContextFactoryTest.cpp
@@ -105,7 +105,8 @@
#ifdef SK_ENABLE_DUMP_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(GrContextDump, reporter, ctxInfo) {
- // Ensure that GrContext::dump doesn't assert (which is possible, if the JSON code is wrong)
+ // Ensure that GrDirectContext::dump doesn't assert (which is possible, if the JSON code
+ // is wrong)
SkString result = ctxInfo.directContext()->dump();
REPORTER_ASSERT(reporter, !result.isEmpty());
}
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index 923b17e..92957aa 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -385,7 +385,7 @@
// Create a texture image.
[dContext] { return create_gpu_image(dContext, true, SkBudgeted::kYes); },
[dContext] { return create_gpu_image(dContext, false, SkBudgeted::kNo); },
- // Create a texture image in a another GrContext.
+ // Create a texture image in a another context.
[otherContextInfo] {
auto restore = otherContextInfo.testContext()->makeCurrentAndAutoRestore();
auto otherContextImage = create_gpu_image(otherContextInfo.directContext());
@@ -408,7 +408,7 @@
auto texImage = image->makeTextureImage(dContext, mipMapped, budgeted);
if (!texImage) {
GrContext* imageContext = as_IB(image)->context();
- // We expect to fail if image comes from a different GrContext
+ // We expect to fail if image comes from a different context
if (!image->isTextureBacked() || imageContext == dContext) {
ERRORF(reporter, "makeTextureImage failed.");
}
@@ -597,7 +597,7 @@
// This shouldn't crash.
rsurf->getCanvas()->drawImage(img, 0, 0);
- // Give up all other refs on GrContext.
+ // Give up all other refs on the context.
factory.reset(nullptr);
REPORTER_ASSERT(reporter, !img->isValid(rsurf->getCanvas()->getGrContext()));
// This shouldn't crash.
@@ -965,7 +965,7 @@
// Case #6: Verify that only one context can be using the image at a time
{
- // Suppress warnings about trying to use a texture on two GrContexts.
+ // Suppress warnings about trying to use a texture in two contexts.
GrRecordingContextPriv::AutoSuppressWarningMessages aswm(otherCtx);
testContext->makeCurrent();
@@ -1074,7 +1074,7 @@
{ create_data_image, true, false },
{ create_picture_image, true, false },
{ [context] { return create_gpu_image(context); }, true, true },
- // Create a texture image in a another GrContext.
+ // Create a texture image in a another context.
{ [otherContextInfo] {
auto restore = otherContextInfo.testContext()->makeCurrentAndAutoRestore();
sk_sp<SkImage> otherContextImage = create_gpu_image(otherContextInfo.directContext());
@@ -1454,7 +1454,7 @@
i2 = make_yuva_image(dContext);
// On some systems where preferVRAMUseOverFlushes is false (ANGLE on Windows) the above may
// actually flush in order to make textures for the YUV planes. TODO: Remove this when we
- // make the YUVA planes from backend textures rather than pixmaps that GrContext must upload.
+ // make the YUVA planes from backend textures rather than pixmaps that the context must upload.
// Calling numSubmits rebases the flush count from here.
numSubmits();
as_IB(i2.get())->view(dContext);
diff --git a/tests/PinnedImageTest.cpp b/tests/PinnedImageTest.cpp
index 82adb5f..07068e6 100644
--- a/tests/PinnedImageTest.cpp
+++ b/tests/PinnedImageTest.cpp
@@ -99,26 +99,26 @@
{
sk_sp<SkImage> img;
- GrDirectContext* context = nullptr;
+ GrDirectContext* dContext = nullptr;
{
GrContextFactory testFactory;
ContextInfo info = testFactory.getContextInfo(ctxType);
- context = info.directContext();
- if (!context) {
+ dContext = info.directContext();
+ if (!dContext) {
continue;
}
img = SkMakeImageFromRasterBitmap(bm, kNever_SkCopyPixelsMode);
- if (!SkImage_pinAsTexture(img.get(), context)) {
+ if (!SkImage_pinAsTexture(img.get(), dContext)) {
continue;
}
}
- // The GrContext used to pin the image is gone at this point!
+ // The context used to pin the image is gone at this point!
// "context" isn't technically used in this call but it can't be null!
// We don't really want to support this use case but it currently happens.
- SkImage_unpinAsTexture(img.get(), context);
+ SkImage_unpinAsTexture(img.get(), dContext);
}
}
}
diff --git a/tests/ProxyRefTest.cpp b/tests/ProxyRefTest.cpp
index 3a460f0..e590f76 100644
--- a/tests/ProxyRefTest.cpp
+++ b/tests/ProxyRefTest.cpp
@@ -12,6 +12,7 @@
#include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrProxyProvider.h"
+#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrRenderTargetProxy.h"
#include "src/gpu/GrResourceProvider.h"
#include "src/gpu/GrSurfaceProxy.h"
@@ -21,9 +22,9 @@
static const int kWidthHeight = 128;
-static sk_sp<GrTextureProxy> make_deferred(GrContext* context) {
- GrProxyProvider* proxyProvider = context->priv().proxyProvider();
- const GrCaps* caps = context->priv().caps();
+static sk_sp<GrTextureProxy> make_deferred(GrRecordingContext* rContext) {
+ GrProxyProvider* proxyProvider = rContext->priv().proxyProvider();
+ const GrCaps* caps = rContext->priv().caps();
const GrBackendFormat format = caps->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kYes);
@@ -32,8 +33,8 @@
GrProtected::kNo);
}
-static sk_sp<GrTextureProxy> make_wrapped(GrContext* context) {
- GrProxyProvider* proxyProvider = context->priv().proxyProvider();
+static sk_sp<GrTextureProxy> make_wrapped(GrRecordingContext* rContext) {
+ GrProxyProvider* proxyProvider = rContext->priv().proxyProvider();
return proxyProvider->testingOnly_createInstantiatedProxy(
{kWidthHeight, kWidthHeight}, GrColorType::kRGBA_8888, GrRenderable::kYes, 1,
@@ -41,13 +42,13 @@
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
- auto direct = ctxInfo.directContext();
- GrResourceProvider* resourceProvider = direct->priv().resourceProvider();
+ auto dContext = ctxInfo.directContext();
+ GrResourceProvider* resourceProvider = dContext->priv().resourceProvider();
for (auto make : { make_deferred, make_wrapped }) {
// An extra ref
{
- sk_sp<GrTextureProxy> proxy((*make)(direct));
+ sk_sp<GrTextureProxy> proxy((*make)(dContext));
if (proxy) {
sk_sp<GrTextureProxy> extraRef(proxy);
@@ -64,7 +65,7 @@
// Multiple normal refs
{
- sk_sp<GrTextureProxy> proxy((*make)(direct));
+ sk_sp<GrTextureProxy> proxy((*make)(dContext));
if (proxy.get()) {
proxy->ref();
proxy->ref();
@@ -85,7 +86,7 @@
// Continue using (reffing) proxy after instantiation
{
- sk_sp<GrTextureProxy> proxy((*make)(direct));
+ sk_sp<GrTextureProxy> proxy((*make)(dContext));
if (proxy) {
sk_sp<GrTextureProxy> firstExtraRef(proxy);
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index b75747b..60f1e1e 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -1147,8 +1147,8 @@
sk_gpu_test::GrContextFactory::ContextTypeName(type), yuv);
continue;
}
- // For vulkan we need to release all refs to the GrContext before trying to destroy
- // the test context. The surface here is holding a ref.
+ // For vulkan we need to release all refs to the GrDirectContext before trying to
+ // destroy the test context. The surface here is holding a ref.
surf.reset();
// The real test is that we don't crash, get Vulkan validation errors, etc, during
diff --git a/tests/RenderTargetContextTest.cpp b/tests/RenderTargetContextTest.cpp
index c44eadc..0268a89 100644
--- a/tests/RenderTargetContextTest.cpp
+++ b/tests/RenderTargetContextTest.cpp
@@ -17,9 +17,9 @@
static const int kSize = 64;
-static std::unique_ptr<GrRenderTargetContext> get_rtc(GrContext* ctx) {
+static std::unique_ptr<GrRenderTargetContext> get_rtc(GrRecordingContext* rContext) {
return GrRenderTargetContext::Make(
- ctx, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {kSize, kSize});
+ rContext, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {kSize, kSize});
}
static void check_instantiation_status(skiatest::Reporter* reporter,
@@ -34,26 +34,26 @@
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RenderTargetContextTest, reporter, ctxInfo) {
- auto ctx = ctxInfo.directContext();
+ auto dContext = ctxInfo.directContext();
// Calling instantiate on a GrRenderTargetContext's textureProxy also instantiates the
// GrRenderTargetContext
{
- auto rtCtx = get_rtc(ctx);
+ auto rtCtx = get_rtc(dContext);
check_instantiation_status(reporter, rtCtx.get(), false);
GrTextureProxy* tProxy = rtCtx->asTextureProxy();
REPORTER_ASSERT(reporter, tProxy);
- REPORTER_ASSERT(reporter, tProxy->instantiate(ctx->priv().resourceProvider()));
+ REPORTER_ASSERT(reporter, tProxy->instantiate(dContext->priv().resourceProvider()));
check_instantiation_status(reporter, rtCtx.get(), true);
}
// readPixels switches a deferred rtCtx to wrapped
{
- auto rtCtx = get_rtc(ctx);
+ auto rtCtx = get_rtc(dContext);
check_instantiation_status(reporter, rtCtx.get(), false);
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index 8714bb2..878139a 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -13,6 +13,7 @@
#include "src/gpu/GrGpuResourceCacheAccess.h"
#include "src/gpu/GrGpuResourcePriv.h"
#include "src/gpu/GrProxyProvider.h"
+#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrRenderTargetPriv.h"
#include "src/gpu/GrResourceCache.h"
#include "src/gpu/GrResourceProvider.h"
@@ -1246,7 +1247,7 @@
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
- // Verify that calling flush() on a GrContext with nothing to do will not trigger resource
+ // Verify that calling flush() on a context with nothing to do will not trigger resource
// eviction
dContext->flushAndSubmit();
for (int i = 0; i < 10; ++i) {
@@ -1600,12 +1601,12 @@
SkBudgeted::kYes, GrProtected::kNo);
}
-static sk_sp<GrTextureProxy> make_mipmap_proxy(GrContext* context,
+static sk_sp<GrTextureProxy> make_mipmap_proxy(GrRecordingContext* rContext,
GrRenderable renderable,
SkISize dims,
int sampleCnt) {
- GrProxyProvider* proxyProvider = context->priv().proxyProvider();
- const GrCaps* caps = context->priv().caps();
+ GrProxyProvider* proxyProvider = rContext->priv().proxyProvider();
+ const GrCaps* caps = rContext->priv().caps();
const GrBackendFormat format = caps->getDefaultBackendFormat(GrColorType::kRGBA_8888,
diff --git a/tests/SkRemoteGlyphCacheTest.cpp b/tests/SkRemoteGlyphCacheTest.cpp
index f5ed12f..2cd3d04 100644
--- a/tests/SkRemoteGlyphCacheTest.cpp
+++ b/tests/SkRemoteGlyphCacheTest.cpp
@@ -158,21 +158,21 @@
}
}
-sk_sp<SkSurface> MakeSurface(int width, int height, GrContext* context) {
+sk_sp<SkSurface> MakeSurface(int width, int height, GrRecordingContext* rContext) {
const SkImageInfo info =
SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType);
- return SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info);
+ return SkSurface::MakeRenderTarget(rContext, SkBudgeted::kNo, info);
}
-const SkSurfaceProps FindSurfaceProps(GrContext* context) {
- auto surface = MakeSurface(1, 1, context);
+const SkSurfaceProps FindSurfaceProps(GrRecordingContext* rContext) {
+ auto surface = MakeSurface(1, 1, rContext);
return surface->props();
}
SkBitmap RasterBlob(sk_sp<SkTextBlob> blob, int width, int height, const SkPaint& paint,
- GrContext* context, const SkMatrix* matrix = nullptr,
+ GrRecordingContext* rContext, const SkMatrix* matrix = nullptr,
SkScalar x = 0) {
- auto surface = MakeSurface(width, height, context);
+ auto surface = MakeSurface(width, height, rContext);
if (matrix) surface->getCanvas()->concat(*matrix);
surface->getCanvas()->drawTextBlob(blob.get(), x, height/2, paint);
SkBitmap bitmap;
@@ -199,7 +199,7 @@
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_StrikeSerialization, reporter, ctxInfo) {
- auto direct = ctxInfo.directContext();
+ auto dContext = ctxInfo.directContext();
sk_sp<DiscardableManager> discardableManager = sk_make_sp<DiscardableManager>();
SkStrikeServer server(discardableManager.get());
SkStrikeClient client(discardableManager, false);
@@ -211,9 +211,9 @@
int glyphCount = 10;
auto serverBlob = buildTextBlob(serverTf, glyphCount);
- auto props = FindSurfaceProps(direct);
+ auto props = FindSurfaceProps(dContext);
SkTextBlobCacheDiffCanvas cache_diff_canvas(10, 10, props, &server,
- direct->supportsDistanceFieldText());
+ dContext->supportsDistanceFieldText());
#ifdef SK_CAPTURE_DRAW_TEXT_BLOB
{
SkDynamicMemoryWStream wStream;
@@ -237,8 +237,8 @@
client.readStrikeData(serverStrikeData.data(), serverStrikeData.size()));
auto clientBlob = buildTextBlob(clientTf, glyphCount);
- SkBitmap expected = RasterBlob(serverBlob, 10, 10, paint, direct);
- SkBitmap actual = RasterBlob(clientBlob, 10, 10, paint, direct);
+ SkBitmap expected = RasterBlob(serverBlob, 10, 10, paint, dContext);
+ SkBitmap actual = RasterBlob(clientBlob, 10, 10, paint, dContext);
compare_blobs(expected, actual, reporter);
REPORTER_ASSERT(reporter, !discardableManager->hasCacheMiss());
diff --git a/tests/SkRuntimeEffectTest.cpp b/tests/SkRuntimeEffectTest.cpp
index e39c16c..5271a20 100644
--- a/tests/SkRuntimeEffectTest.cpp
+++ b/tests/SkRuntimeEffectTest.cpp
@@ -152,10 +152,11 @@
return bmp.makeShader();
}
-static void test_RuntimeEffect_Shaders(skiatest::Reporter* r, GrContext* context) {
+static void test_RuntimeEffect_Shaders(skiatest::Reporter* r, GrRecordingContext* rContext) {
SkImageInfo info = SkImageInfo::Make(2, 2, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- sk_sp<SkSurface> surface = context ? SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info)
- : SkSurface::MakeRaster(info);
+ sk_sp<SkSurface> surface = rContext
+ ? SkSurface::MakeRenderTarget(rContext, SkBudgeted::kNo, info)
+ : SkSurface::MakeRaster(info);
REPORTER_ASSERT(r, surface);
TestEffect effect(r, surface);
diff --git a/tests/Skbug6653.cpp b/tests/Skbug6653.cpp
index 383d7d4..2aae1db 100644
--- a/tests/Skbug6653.cpp
+++ b/tests/Skbug6653.cpp
@@ -22,13 +22,15 @@
return bmp;
}
-static sk_sp<SkSurface> make_surface(GrContext* context) {
+static sk_sp<SkSurface> make_surface(GrRecordingContext* rContext) {
SkImageInfo info = SkImageInfo::Make(50, 50, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- return SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info, 4,
+ return SkSurface::MakeRenderTarget(rContext, SkBudgeted::kNo, info, 4,
kBottomLeft_GrSurfaceOrigin, nullptr);
}
-static void test_bug_6653(GrContext* ctx, skiatest::Reporter* reporter, const char* label) {
+static void test_bug_6653(GrDirectContext* dContext,
+ skiatest::Reporter* reporter,
+ const char* label) {
SkRect rect = SkRect::MakeWH(50, 50);
SkPaint paint;
@@ -42,31 +44,31 @@
static const int kNumIterations = 50;
for (int i = 0; i < kNumIterations; ++i) {
- auto s0 = make_surface(ctx);
+ auto s0 = make_surface(dContext);
if (!s0) {
// MSAA may not be supported
return;
}
- auto s1 = make_surface(ctx);
+ auto s1 = make_surface(dContext);
s1->getCanvas()->clear(SK_ColorBLACK);
s1->getCanvas()->drawOval(rect, paint);
SkBitmap b1 = read_pixels(s1, SK_ColorBLACK);
s1 = nullptr;
// The bug requires that all three of the following surfaces are cleared to the same color
- auto s2 = make_surface(ctx);
+ auto s2 = make_surface(dContext);
s2->getCanvas()->clear(SK_ColorBLUE);
SkBitmap b2 = read_pixels(s2, SK_ColorBLACK);
s2 = nullptr;
- auto s3 = make_surface(ctx);
+ auto s3 = make_surface(dContext);
s3->getCanvas()->clear(SK_ColorBLUE);
SkBitmap b3 = read_pixels(s3, SK_ColorBLACK);
s0->getCanvas()->drawBitmap(b3, 0, 0);
s3 = nullptr;
- auto s4 = make_surface(ctx);
+ auto s4 = make_surface(dContext);
s4->getCanvas()->clear(SK_ColorBLUE);
s4->getCanvas()->drawOval(rect, paint);
diff --git a/tests/SpecialImageTest.cpp b/tests/SpecialImageTest.cpp
index be0fcfb..2276746 100644
--- a/tests/SpecialImageTest.cpp
+++ b/tests/SpecialImageTest.cpp
@@ -57,7 +57,7 @@
// Basic test of the SkSpecialImage public API (e.g., peekTexture, peekPixels & draw)
static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* reporter,
- GrContext* context, bool isGPUBacked) {
+ GrRecordingContext* rContext, bool isGPUBacked) {
const SkIRect subset = img->subset();
REPORTER_ASSERT(reporter, kPad == subset.left());
REPORTER_ASSERT(reporter, kPad == subset.top());
@@ -70,8 +70,8 @@
//--------------
// Test view - as long as there is a context this should succeed
- if (context) {
- GrSurfaceProxyView view = img->view(context);
+ if (rContext) {
+ GrSurfaceProxyView view = img->view(rContext);
REPORTER_ASSERT(reporter, view.asTextureProxy());
}
diff --git a/tests/TextureProxyTest.cpp b/tests/TextureProxyTest.cpp
index dac069c..4d6554c 100644
--- a/tests/TextureProxyTest.cpp
+++ b/tests/TextureProxyTest.cpp
@@ -13,6 +13,7 @@
#include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrProxyProvider.h"
+#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrResourceCache.h"
#include "src/gpu/GrResourceProvider.h"
#include "src/gpu/GrTexture.h"
@@ -35,9 +36,11 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// Basic test
-static sk_sp<GrTextureProxy> deferred_tex(skiatest::Reporter* reporter, GrContext* ctx,
- GrProxyProvider* proxyProvider, SkBackingFit fit) {
- const GrCaps* caps = ctx->priv().caps();
+static sk_sp<GrTextureProxy> deferred_tex(skiatest::Reporter* reporter,
+ GrRecordingContext* rContext,
+ GrProxyProvider* proxyProvider,
+ SkBackingFit fit) {
+ const GrCaps* caps = rContext->priv().caps();
GrBackendFormat format = caps->getDefaultBackendFormat(kColorType, GrRenderable::kNo);
@@ -49,9 +52,11 @@
return proxy;
}
-static sk_sp<GrTextureProxy> deferred_texRT(skiatest::Reporter* reporter, GrContext* ctx,
- GrProxyProvider* proxyProvider, SkBackingFit fit) {
- const GrCaps* caps = ctx->priv().caps();
+static sk_sp<GrTextureProxy> deferred_texRT(skiatest::Reporter* reporter,
+ GrRecordingContext* rContext,
+ GrProxyProvider* proxyProvider,
+ SkBackingFit fit) {
+ const GrCaps* caps = rContext->priv().caps();
GrBackendFormat format = caps->getDefaultBackendFormat(kColorType, GrRenderable::kYes);
@@ -63,7 +68,7 @@
return proxy;
}
-static sk_sp<GrTextureProxy> wrapped(skiatest::Reporter* reporter, GrContext* ctx,
+static sk_sp<GrTextureProxy> wrapped(skiatest::Reporter* reporter, GrRecordingContext*,
GrProxyProvider* proxyProvider, SkBackingFit fit) {
sk_sp<GrTextureProxy> proxy = proxyProvider->testingOnly_createInstantiatedProxy(
kSize, kColorType, GrRenderable::kNo, 1, fit, SkBudgeted::kYes, GrProtected::kNo);
@@ -72,7 +77,7 @@
return proxy;
}
-static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter, GrContext* ctx,
+static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter, GrRecordingContext*,
GrProxyProvider* proxyProvider, SkBackingFit fit) {
static GrUniqueKey::Domain d = GrUniqueKey::GenerateDomain();
static int kUniqueKeyData = 0;
@@ -91,10 +96,11 @@
return proxy;
}
-static sk_sp<GrTextureProxy> create_wrapped_backend(GrContext* context, SkBackingFit fit,
+static sk_sp<GrTextureProxy> create_wrapped_backend(GrDirectContext* dContext,
+ SkBackingFit fit,
sk_sp<GrTexture>* backingSurface) {
- GrProxyProvider* proxyProvider = context->priv().proxyProvider();
- GrResourceProvider* resourceProvider = context->priv().resourceProvider();
+ GrProxyProvider* proxyProvider = dContext->priv().proxyProvider();
+ GrResourceProvider* resourceProvider = dContext->priv().resourceProvider();
GrBackendFormat format =
proxyProvider->caps()->getDefaultBackendFormat(kColorType, GrRenderable::kYes);
@@ -115,14 +121,14 @@
// This tests the basic capabilities of the uniquely keyed texture proxies. Does assigning
// and looking them up work, etc.
-static void basic_test(GrContext* context,
+static void basic_test(GrDirectContext* dContext,
skiatest::Reporter* reporter,
sk_sp<GrTextureProxy> proxy) {
static int id = 1;
- GrResourceProvider* resourceProvider = context->priv().resourceProvider();
- GrProxyProvider* proxyProvider = context->priv().proxyProvider();
- GrResourceCache* cache = context->priv().getResourceCache();
+ GrResourceProvider* resourceProvider = dContext->priv().resourceProvider();
+ GrProxyProvider* proxyProvider = dContext->priv().proxyProvider();
+ GrResourceCache* cache = dContext->priv().getResourceCache();
int startCacheCount = cache->getResourceCount();
@@ -197,7 +203,7 @@
if (expectResourceToOutliveProxy) {
proxy.reset();
- GrUniqueKeyInvalidatedMessage msg(texKey, context->priv().contextID());
+ GrUniqueKeyInvalidatedMessage msg(texKey, dContext->priv().contextID());
SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(msg);
cache->purgeAsNeeded();
expectedCacheCount--;
@@ -211,10 +217,10 @@
// Invalidation test
// Test if invalidating unique ids operates as expected for texture proxies.
-static void invalidation_test(GrDirectContext* direct, skiatest::Reporter* reporter) {
+static void invalidation_test(GrDirectContext* dContext, skiatest::Reporter* reporter) {
- GrProxyProvider* proxyProvider = direct->priv().proxyProvider();
- GrResourceCache* cache = direct->priv().getResourceCache();
+ GrProxyProvider* proxyProvider = dContext->priv().proxyProvider();
+ GrResourceCache* cache = dContext->priv().getResourceCache();
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
sk_sp<SkImage> rasterImg;
@@ -233,20 +239,21 @@
// Some of our backends use buffers to do uploads that will live in our resource cache. So we
// need to account for those extra resources here.
int bufferResources = 0;
- if (direct->backend() == GrBackendApi::kDawn || direct->backend() == GrBackendApi::kVulkan ||
- direct->backend() == GrBackendApi::kDirect3D) {
+ if (dContext->backend() == GrBackendApi::kDawn ||
+ dContext->backend() == GrBackendApi::kVulkan ||
+ dContext->backend() == GrBackendApi::kDirect3D) {
bufferResources = 1;
}
- sk_sp<SkImage> textureImg = rasterImg->makeTextureImage(direct);
+ sk_sp<SkImage> textureImg = rasterImg->makeTextureImage(dContext);
REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
REPORTER_ASSERT(reporter, 1 + bufferResources == cache->getResourceCount());
rasterImg = nullptr; // this invalidates the uniqueKey
// this forces the cache to respond to the inval msg
- size_t maxBytes = direct->getResourceCacheLimit();
- direct->setResourceCacheLimit(maxBytes-1);
+ size_t maxBytes = dContext->getResourceCacheLimit();
+ dContext->setResourceCacheLimit(maxBytes-1);
REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
REPORTER_ASSERT(reporter, 1 + bufferResources == cache->getResourceCount());
@@ -255,29 +262,30 @@
// For backends that use buffers to upload lets make sure that work has been submit and done
// before we try to purge all resources.
- direct->submit(true);
+ dContext->submit(true);
#ifdef SK_DAWN
// The forced cpu sync in dawn doesn't actually mean the async map will finish thus we may
// still have a ref on the GrGpuBuffer and it will not get purged by the call below. We dig
// deep into the dawn gpu to make sure we wait for the async map to finish.
- if (direct->backend() == GrBackendApi::kDawn) {
- GrDawnGpu* gpu = static_cast<GrDawnGpu*>(direct->priv().getGpu());
+ if (dContext->backend() == GrBackendApi::kDawn) {
+ GrDawnGpu* gpu = static_cast<GrDawnGpu*>(dContext->priv().getGpu());
gpu->waitOnAllBusyStagingBuffers();
}
#endif
- direct->priv().testingOnly_purgeAllUnlockedResources();
+ dContext->priv().testingOnly_purgeAllUnlockedResources();
REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
}
// Test if invalidating unique ids prior to instantiating operates as expected
-static void invalidation_and_instantiation_test(GrContext* context, skiatest::Reporter* reporter) {
- GrProxyProvider* proxyProvider = context->priv().proxyProvider();
- GrResourceProvider* resourceProvider = context->priv().resourceProvider();
- GrResourceCache* cache = context->priv().getResourceCache();
+static void invalidation_and_instantiation_test(GrDirectContext* dContext,
+ skiatest::Reporter* reporter) {
+ GrProxyProvider* proxyProvider = dContext->priv().proxyProvider();
+ GrResourceProvider* resourceProvider = dContext->priv().resourceProvider();
+ GrResourceCache* cache = dContext->priv().getResourceCache();
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
static GrUniqueKey::Domain d = GrUniqueKey::GenerateDomain();
@@ -287,13 +295,13 @@
builder.finish();
// Create proxy, assign unique key
- sk_sp<GrTextureProxy> proxy = deferred_tex(reporter, context, proxyProvider,
+ sk_sp<GrTextureProxy> proxy = deferred_tex(reporter, dContext, proxyProvider,
SkBackingFit::kExact);
SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
// Send an invalidation message, which will be sitting in the cache's inbox
SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(
- GrUniqueKeyInvalidatedMessage(key, context->priv().contextID()));
+ GrUniqueKeyInvalidatedMessage(key, dContext->priv().contextID()));
REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
@@ -308,7 +316,7 @@
REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
proxy = nullptr;
- context->priv().testingOnly_purgeAllUnlockedResources();
+ dContext->priv().testingOnly_purgeAllUnlockedResources();
REPORTER_ASSERT(reporter, 0 == proxyProvider->numUniqueKeyProxies_TestOnly());
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
diff --git a/tests/VkDrawableTest.cpp b/tests/VkDrawableTest.cpp
index b1214fc..38378dc 100644
--- a/tests/VkDrawableTest.cpp
+++ b/tests/VkDrawableTest.cpp
@@ -94,9 +94,9 @@
const SkImageInfo&, const GrVkDrawableInfo&);
typedef void (*SubmitProc)(TestDrawable*);
- // Exercises the exporting of a secondary command buffer from one GrContext and then importing
- // it into a second GrContext. We then draw to the secondary command buffer from the second
- // GrContext.
+ // Exercises the exporting of a secondary command buffer from one context and then importing
+ // it into a second context. We then draw to the secondary command buffer from the second
+ // context.
class DrawHandlerImport : public GpuDrawHandler {
public:
DrawHandlerImport(TestDrawable* td, DrawProc drawProc, SubmitProc submitProc,
@@ -132,7 +132,7 @@
};
// Helper function to test drawing to a secondary command buffer that we imported into the
- // GrContext using a GrVkSecondaryCBDrawContext.
+ // context using a GrVkSecondaryCBDrawContext.
static void ImportDraw(TestDrawable* td, const SkMatrix& matrix, const SkIRect& clipBounds,
const SkImageInfo& bufferInfo, const GrVkDrawableInfo& info) {
td->fDrawContext = GrVkSecondaryCBDrawContext::Make(td->fDContext, bufferInfo,
@@ -164,7 +164,7 @@
}
// Helper function to test waiting for the imported secondary command buffer to be submitted on
- // its original context and then cleaning up the GrVkSecondaryCBDrawContext from this GrContext.
+ // its original context and then cleaning up the GrVkSecondaryCBDrawContext from this context.
static void ImportSubmitted(TestDrawable* td) {
// Typical use case here would be to create a fence that we submit to the gpu and then wait
// on before releasing the GrVkSecondaryCBDrawContext resources. To simulate that for this
@@ -173,10 +173,10 @@
td->fDContext->priv().getGpu()->testingOnly_flushGpuAndSync();
td->fDrawContext->releaseResources();
- // We release the GrContext here manually to test that we waited long enough before
+ // We release the context here manually to test that we waited long enough before
// releasing the GrVkSecondaryCBDrawContext. This simulates when a client is able to delete
- // the GrContext it used to imported the secondary command buffer. If we had released the
- // GrContext's resources earlier (before waiting on the gpu above), we would get vulkan
+ // the context it used to imported the secondary command buffer. If we had released the
+ // context's resources earlier (before waiting on the gpu above), we would get vulkan
// validation layer errors saying we freed some vulkan objects while they were still in use
// on the GPU.
td->fDContext->releaseResourcesAndAbandonContext();
diff --git a/tests/VkHardwareBufferTest.cpp b/tests/VkHardwareBufferTest.cpp
index a17f67a..95017dd 100644
--- a/tests/VkHardwareBufferTest.cpp
+++ b/tests/VkHardwareBufferTest.cpp
@@ -831,7 +831,7 @@
GrSemaphoresSubmitted submitted = fDirectContext->flush(info);
fDirectContext->submit();
if (GrSemaphoresSubmitted::kNo == submitted) {
- ERRORF(reporter, "Failing call to flush on GrContext");
+ ERRORF(reporter, "Failing call to flush on GrDirectContext");
return false;
}
SkASSERT(semaphore.isInitialized());
diff --git a/tests/VkYcbcrSamplerTest.cpp b/tests/VkYcbcrSamplerTest.cpp
index 6dc7507..cb14e8d 100644
--- a/tests/VkYcbcrSamplerTest.cpp
+++ b/tests/VkYcbcrSamplerTest.cpp
@@ -133,7 +133,7 @@
GrMipmapped::kNo, GrRenderable::kNo, GrProtected::kNo);
if (texture.isValid()) {
ERRORF(reporter,
- "GrContext::createBackendTexture() didn't fail as expected for Ycbcr format.");
+ "GrDirectContext::createBackendTexture() didn't fail as expected for Ycbcr format.");
}
}