Clean up some GrContext in tests
Change-Id: I58372d0691fe6a348288a6076d78d3455288192a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/303660
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/tests/DefaultPathRendererTest.cpp b/tests/DefaultPathRendererTest.cpp
index 6211b88..f08f56c 100644
--- a/tests/DefaultPathRendererTest.cpp
+++ b/tests/DefaultPathRendererTest.cpp
@@ -74,7 +74,7 @@
// When the bug manifests the GrDefaultPathRenderer/GrMSAAPathRenderer is/was leaving the stencil
// buffer outside of the first content rect in a bad state and the second draw would be incorrect.
-static void run_test(GrContext* ctx, skiatest::Reporter* reporter) {
+static void run_test(GrRecordingContext* rContext, skiatest::Reporter* reporter) {
SkPath invPath = make_path(SkRect::MakeXYWH(0, 0, kBigSize, kBigSize),
kBigSize/2-1, SkPathFillType::kInverseWinding);
SkPath path = make_path(SkRect::MakeXYWH(0, 0, kBigSize, kBigSize),
@@ -84,7 +84,7 @@
{
auto rtc = GrRenderTargetContext::Make(
- ctx, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox,
+ rContext, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox,
{kBigSize/2 + 1, kBigSize/2 + 1});
rtc->clear(SK_PMColor4fBLACK);
@@ -103,7 +103,7 @@
{
auto rtc = GrRenderTargetContext::Make(
- ctx, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {kBigSize, kBigSize});
+ rContext, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {kBigSize, kBigSize});
rtc->clear(SK_PMColor4fBLACK);
diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp
index 1c6811f..ea52cab 100644
--- a/tests/EGLImageTest.cpp
+++ b/tests/EGLImageTest.cpp
@@ -26,13 +26,13 @@
using sk_gpu_test::GLTestContext;
static void cleanup(GLTestContext* glctx0, GrGLuint texID0, GLTestContext* glctx1,
- sk_sp<GrContext> grctx1, GrBackendTexture* backendTex1,
+ sk_sp<GrDirectContext> dContext, GrBackendTexture* backendTex1,
GrEGLImage image1) {
if (glctx1) {
glctx1->makeCurrent();
- if (grctx1) {
+ if (dContext) {
if (backendTex1 && backendTex1->isValid()) {
- grctx1->deleteBackendTexture(*backendTex1);
+ dContext->deleteBackendTexture(*backendTex1);
}
}
if (GR_EGL_NO_IMAGE != image1) {
diff --git a/tests/GrCCPRTest.cpp b/tests/GrCCPRTest.cpp
index f37bef1..c706e8e 100644
--- a/tests/GrCCPRTest.cpp
+++ b/tests/GrCCPRTest.cpp
@@ -12,7 +12,6 @@
#include "include/core/SkRect.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h"
-#include "include/gpu/GrRecordingContext.h"
#include "include/gpu/mock/GrMockTypes.h"
#include "src/core/SkPathPriv.h"
#include "src/gpu/GrClip.h"
@@ -58,11 +57,11 @@
class CCPRPathDrawer {
public:
- CCPRPathDrawer(sk_sp<GrContext> ctx, skiatest::Reporter* reporter, DoStroke doStroke)
- : fCtx(ctx)
- , fCCPR(fCtx->priv().drawingManager()->getCoverageCountingPathRenderer())
+ CCPRPathDrawer(sk_sp<GrDirectContext> dContext, skiatest::Reporter* reporter, DoStroke doStroke)
+ : fDContext(dContext)
+ , fCCPR(fDContext->priv().drawingManager()->getCoverageCountingPathRenderer())
, fRTC(GrRenderTargetContext::Make(
- fCtx.get(), GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact,
+ fDContext.get(), GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact,
{kCanvasSize, kCanvasSize}))
, fDoStroke(DoStroke::kYes == doStroke) {
if (!fCCPR) {
@@ -73,16 +72,16 @@
}
}
- GrContext* ctx() const { return fCtx.get(); }
+ GrDirectContext* dContext() const { return fDContext.get(); }
GrCoverageCountingPathRenderer* ccpr() const { return fCCPR; }
bool valid() const { return fCCPR && fRTC; }
void clear() const { fRTC->clear(SK_PMColor4fTRANSPARENT); }
void destroyGrContext() {
- SkASSERT(fCtx->unique());
+ SkASSERT(fDContext->unique());
fRTC.reset();
fCCPR = nullptr;
- fCtx.reset();
+ fDContext.reset();
}
void drawPath(const SkPath& path, const SkMatrix& matrix = SkMatrix::I()) const {
@@ -106,8 +105,8 @@
}
fCCPR->testingOnly_drawPathDirectly({
- fCtx.get(), std::move(paint), &GrUserStencilSettings::kUnused, fRTC.get(), nullptr,
- &clipBounds, &matrix, &shape, GrAAType::kCoverage, false});
+ fDContext.get(), std::move(paint), &GrUserStencilSettings::kUnused, fRTC.get(),
+ nullptr, &clipBounds, &matrix, &shape, GrAAType::kCoverage, false});
}
void clipFullscreenRect(SkPath clipPath, SkPMColor4f color = { 0, 1, 0, 1 }) {
@@ -123,11 +122,11 @@
void flush() const {
SkASSERT(this->valid());
- fCtx->flushAndSubmit();
+ fDContext->flushAndSubmit();
}
private:
- sk_sp<GrContext> fCtx;
+ sk_sp<GrDirectContext> fDContext;
GrCoverageCountingPathRenderer* fCCPR;
std::unique_ptr<GrRenderTargetContext> fRTC;
const bool fDoStroke;
@@ -234,7 +233,7 @@
mockOptions->fFailTextureAllocations = true;
}
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr) override {
- ((GrRecordingContext*)ccpr.ctx())->priv().incrSuppressWarningMessages();
+ ((GrRecordingContext*)ccpr.dContext())->priv().incrSuppressWarningMessages();
this->CCPR_cleanup::onRun(reporter, ccpr);
}
};
@@ -393,11 +392,11 @@
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr) final {
RecordLastMockAtlasIDs atlasIDRecorder(sk_ref_sp(ccpr.ccpr()));
- ccpr.ctx()->priv().addOnFlushCallbackObject(&atlasIDRecorder);
+ ccpr.dContext()->priv().addOnFlushCallbackObject(&atlasIDRecorder);
this->onRun(reporter, ccpr, atlasIDRecorder);
- ccpr.ctx()->priv().testingOnly_flushAndRemoveOnFlushCallbackObject(&atlasIDRecorder);
+ ccpr.dContext()->priv().testingOnly_flushAndRemoveOnFlushCallbackObject(&atlasIDRecorder);
}
virtual void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr,
@@ -581,7 +580,7 @@
REPORTER_ASSERT(reporter, 0 == atlasIDRecorder.lastRenderedAtlasID());
}
- ccpr.ctx()->performDeferredCleanup(std::chrono::milliseconds(0));
+ ccpr.dContext()->performDeferredCleanup(std::chrono::milliseconds(0));
}
}
};
@@ -862,13 +861,13 @@
class CCPRRenderingTest {
public:
- void run(skiatest::Reporter* reporter, GrContext* ctx, DoStroke doStroke) const {
- if (auto ccpr = ctx->priv().drawingManager()->getCoverageCountingPathRenderer()) {
+ void run(skiatest::Reporter* reporter, GrDirectContext* dContext, DoStroke doStroke) const {
+ if (auto ccpr = dContext->priv().drawingManager()->getCoverageCountingPathRenderer()) {
if (DoStroke::kYes == doStroke &&
GrCCAtlas::CoverageType::kA8_Multisample == ccpr->coverageType()) {
return; // Stroking is not yet supported for multisample.
}
- CCPRPathDrawer drawer(sk_ref_sp(ctx), reporter, doStroke);
+ CCPRPathDrawer drawer(sk_ref_sp(dContext), reporter, doStroke);
if (!drawer.valid()) {
return;
}
diff --git a/tests/OpChainTest.cpp b/tests/OpChainTest.cpp
index 14c2ab8..6aecafc 100644
--- a/tests/OpChainTest.cpp
+++ b/tests/OpChainTest.cpp
@@ -5,12 +5,13 @@
* found in the LICENSE file.
*/
-#include "include/gpu/GrContext.h"
+#include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrMemoryPool.h"
#include "src/gpu/GrOpFlushState.h"
#include "src/gpu/GrOpsTask.h"
#include "src/gpu/GrProxyProvider.h"
+#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/ops/GrOp.h"
#include "tests/Test.h"
@@ -95,7 +96,7 @@
public:
DEFINE_OP_CLASS_ID
- static std::unique_ptr<TestOp> Make(GrContext* context, int value, const Range& range,
+ static std::unique_ptr<TestOp> Make(GrRecordingContext* context, int value, const Range& range,
int result[], const Combinable* combinable) {
GrOpMemoryPool* pool = context->priv().opMemoryPool();
return pool->allocate<TestOp>(value, range, result, combinable);
@@ -170,22 +171,22 @@
* painter's order.
*/
DEF_GPUTEST(OpChainTest, reporter, /*ctxInfo*/) {
- sk_sp<GrDirectContext> context = GrDirectContext::MakeMock(nullptr);
- SkASSERT(context);
+ sk_sp<GrDirectContext> dContext = GrDirectContext::MakeMock(nullptr);
+ SkASSERT(dContext);
+ const GrCaps* caps = dContext->priv().caps();
static constexpr SkISize kDims = {kNumOps + 1, 1};
- const GrBackendFormat format =
- context->priv().caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888,
- GrRenderable::kYes);
+ const GrBackendFormat format = caps->getDefaultBackendFormat(GrColorType::kRGBA_8888,
+ GrRenderable::kYes);
static const GrSurfaceOrigin kOrigin = kTopLeft_GrSurfaceOrigin;
- auto proxy = context->priv().proxyProvider()->createProxy(
+ auto proxy = dContext->priv().proxyProvider()->createProxy(
format, kDims, GrRenderable::kYes, 1, GrMipMapped::kNo, SkBackingFit::kExact,
SkBudgeted::kNo, GrProtected::kNo, GrInternalSurfaceFlags::kNone);
SkASSERT(proxy);
- proxy->instantiate(context->priv().resourceProvider());
+ proxy->instantiate(dContext->priv().resourceProvider());
- GrSwizzle writeSwizzle = context->priv().caps()->getWriteSwizzle(format, GrColorType::kRGBA_8888);
+ GrSwizzle writeSwizzle = caps->getWriteSwizzle(format, GrColorType::kRGBA_8888);
int result[result_width()];
int validResult[result_width()];
@@ -202,7 +203,7 @@
SkRandom random;
bool repeat = false;
Combinable combinable;
- GrDrawingManager* drawingMgr = context->priv().drawingManager();
+ GrDrawingManager* drawingMgr = dContext->priv().drawingManager();
for (int p = 0; p < kNumPermutations; ++p) {
for (int i = 0; i < kNumOps - 2 && !repeat; ++i) {
// The current implementation of nextULessThan() is biased. :(
@@ -214,13 +215,13 @@
for (int c = 0; c < kNumCombinabilitiesPerGrouping; ++c) {
init_combinable(g, &combinable, &random);
GrTokenTracker tracker;
- GrOpFlushState flushState(context->priv().getGpu(),
- context->priv().resourceProvider(),
+ GrOpFlushState flushState(dContext->priv().getGpu(),
+ dContext->priv().resourceProvider(),
&tracker);
GrOpsTask opsTask(drawingMgr,
- context->priv().arenas(),
+ dContext->priv().arenas(),
GrSurfaceProxyView(proxy, kOrigin, writeSwizzle),
- context->priv().auditTrail());
+ dContext->priv().auditTrail());
// This assumes the particular values of kRanges.
std::fill_n(result, result_width(), -1);
std::fill_n(validResult, result_width(), -1);
@@ -232,13 +233,13 @@
int pos = j % kNumOpPositions;
Range range = kRanges[j / kNumOpPositions];
range.fOffset += pos;
- auto op = TestOp::Make(context.get(), value, range, result, &combinable);
+ auto op = TestOp::Make(dContext.get(), value, range, result, &combinable);
op->writeResult(validResult);
opsTask.addOp(drawingMgr, std::move(op),
- GrTextureResolveManager(context->priv().drawingManager()),
- *context->priv().caps());
+ GrTextureResolveManager(dContext->priv().drawingManager()),
+ *caps);
}
- opsTask.makeClosed(*context->priv().caps());
+ opsTask.makeClosed(*caps);
opsTask.prepare(&flushState);
opsTask.execute(&flushState);
opsTask.endFlush(drawingMgr);
diff --git a/tests/PathRendererCacheTests.cpp b/tests/PathRendererCacheTests.cpp
index 626c715..097bee2 100644
--- a/tests/PathRendererCacheTests.cpp
+++ b/tests/PathRendererCacheTests.cpp
@@ -8,8 +8,10 @@
#include "tests/Test.h"
#include "include/core/SkPath.h"
-#include "include/gpu/GrContext.h"
+#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/GrRecordingContext.h"
#include "src/gpu/GrContextPriv.h"
+#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrRenderTargetContext.h"
#include "src/gpu/GrResourceCache.h"
#include "src/gpu/GrSoftwarePathRenderer.h"
@@ -28,7 +30,7 @@
return path;
}
-static void draw_path(GrContext* ctx,
+static void draw_path(GrRecordingContext* rContext,
GrRenderTargetContext* renderTargetContext,
const SkPath& path,
GrPathRenderer* pr,
@@ -46,7 +48,7 @@
}
SkMatrix matrix = SkMatrix::I();
matrix.setScaleX(scaleX);
- GrPathRenderer::DrawPathArgs args{ctx,
+ GrPathRenderer::DrawPathArgs args{rContext,
std::move(paint),
&GrUserStencilSettings::kUnused,
renderTargetContext,
@@ -71,32 +73,32 @@
static void test_path(skiatest::Reporter* reporter,
std::function<SkPath(void)> createPath,
- std::function<GrPathRenderer*(GrContext*)> createPathRenderer,
+ std::function<GrPathRenderer*(GrRecordingContext*)> createPathRenderer,
int expected,
bool checkListeners,
GrAAType aaType = GrAAType::kNone,
GrStyle style = GrStyle(SkStrokeRec::kFill_InitStyle)) {
- sk_sp<GrDirectContext> ctx = GrDirectContext::MakeMock(nullptr);
+ sk_sp<GrDirectContext> dContext = GrDirectContext::MakeMock(nullptr);
// The cache needs to be big enough that nothing gets flushed, or our expectations can be wrong
- ctx->setResourceCacheLimit(8000000);
- GrResourceCache* cache = ctx->priv().getResourceCache();
+ dContext->setResourceCacheLimit(8000000);
+ GrResourceCache* cache = dContext->priv().getResourceCache();
auto rtc = GrRenderTargetContext::Make(
- ctx.get(), GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox, {800, 800}, 1,
+ dContext.get(), GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox, {800, 800}, 1,
GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
if (!rtc) {
return;
}
- sk_sp<GrPathRenderer> pathRenderer(createPathRenderer(ctx.get()));
+ sk_sp<GrPathRenderer> pathRenderer(createPathRenderer(dContext.get()));
SkPath path = createPath();
// Initially, cache only has the render target context
REPORTER_ASSERT(reporter, cache_non_scratch_resources_equals(cache, 0));
// Draw the path, check that new resource count matches expectations
- draw_path(ctx.get(), rtc.get(), path, pathRenderer.get(), aaType, style);
- ctx->flushAndSubmit();
+ draw_path(dContext.get(), rtc.get(), path, pathRenderer.get(), aaType, style);
+ dContext->flushAndSubmit();
REPORTER_ASSERT(reporter, cache_non_scratch_resources_equals(cache, expected));
// Nothing should be purgeable yet
@@ -118,19 +120,19 @@
REPORTER_ASSERT(reporter, SkPathPriv::GenIDChangeListenersCount(path) == 0);
for (int i = 0; i < 20; ++i) {
float scaleX = 1 + ((float)i + 1)/20.f;
- draw_path(ctx.get(), rtc.get(), path, pathRenderer.get(), aaType, style, scaleX);
+ draw_path(dContext.get(), rtc.get(), path, pathRenderer.get(), aaType, style, scaleX);
}
- ctx->flushAndSubmit();
+ dContext->flushAndSubmit();
REPORTER_ASSERT(reporter, SkPathPriv::GenIDChangeListenersCount(path) == 20);
cache->purgeAllUnlocked();
// The listeners don't actually purge until we try to add another one.
- draw_path(ctx.get(), rtc.get(), path, pathRenderer.get(), aaType, style);
+ draw_path(dContext.get(), rtc.get(), path, pathRenderer.get(), aaType, style);
REPORTER_ASSERT(reporter, SkPathPriv::GenIDChangeListenersCount(path) == 1);
}
// Test that deleting the original path invalidates the VBs cached by the tessellating path renderer
DEF_GPUTEST(TriangulatingPathRendererCacheTest, reporter, /* options */) {
- auto createPR = [](GrContext*) {
+ auto createPR = [](GrRecordingContext*) {
return new GrTriangulatingPathRenderer();
};
@@ -152,8 +154,8 @@
// Test that deleting the original path invalidates the textures cached by the SW path renderer
DEF_GPUTEST(SoftwarePathRendererCacheTest, reporter, /* options */) {
- auto createPR = [](GrContext* ctx) {
- return new GrSoftwarePathRenderer(ctx->priv().proxyProvider(), true);
+ auto createPR = [](GrRecordingContext* rContext) {
+ return new GrSoftwarePathRenderer(rContext->priv().proxyProvider(), true);
};
// Software path renderer creates a mask texture and renders with a non-AA rect, but the flush
diff --git a/tests/PremulAlphaRoundTripTest.cpp b/tests/PremulAlphaRoundTripTest.cpp
index c9a7073..9227b33 100644
--- a/tests/PremulAlphaRoundTripTest.cpp
+++ b/tests/PremulAlphaRoundTripTest.cpp
@@ -11,8 +11,6 @@
#include "tests/Test.h"
#include "tools/ToolUtils.h"
-#include "include/gpu/GrContext.h"
-
static uint32_t pack_unpremul_rgba(SkColor c) {
uint32_t packed;
uint8_t* byte = reinterpret_cast<uint8_t*>(&packed);
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index c07c488..71c1b2c 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -337,31 +337,30 @@
class Mock {
public:
Mock(size_t maxBytes) {
- fContext = GrDirectContext::MakeMock(nullptr);
- SkASSERT(fContext);
- fContext->setResourceCacheLimit(maxBytes);
- GrResourceCache* cache = fContext->priv().getResourceCache();
+ fDContext = GrDirectContext::MakeMock(nullptr);
+ SkASSERT(fDContext);
+ fDContext->setResourceCacheLimit(maxBytes);
+ GrResourceCache* cache = fDContext->priv().getResourceCache();
cache->purgeAllUnlocked();
SkASSERT(0 == cache->getResourceCount() && 0 == cache->getResourceBytes());
}
- GrResourceCache* cache() { return fContext->priv().getResourceCache(); }
-
- GrContext* context() { return fContext.get(); }
+ GrResourceCache* cache() { return fDContext->priv().getResourceCache(); }
+ GrGpu* gpu() { return fDContext->priv().getGpu(); }
+ GrDirectContext* dContext() { return fDContext.get(); }
void reset() {
- fContext.reset();
+ fDContext.reset();
}
private:
- sk_sp<GrContext> fContext;
+ sk_sp<GrDirectContext> fDContext;
};
static void test_no_key(skiatest::Reporter* reporter) {
Mock mock(30000);
- GrContext* context = mock.context();
GrResourceCache* cache = mock.cache();
- GrGpu* gpu = context->priv().getGpu();
+ GrGpu* gpu = mock.gpu();
// Create a bunch of resources with no keys
TestResource* a = new TestResource(gpu, SkBudgeted::kYes, 11);
@@ -413,9 +412,8 @@
static void test_purge_unlocked(skiatest::Reporter* reporter) {
Mock mock(30000);
- GrContext* context = mock.context();
GrResourceCache* cache = mock.cache();
- GrGpu* gpu = context->priv().getGpu();
+ GrGpu* gpu = mock.gpu();
// Create two resource w/ a unique key and two w/o but all of which have scratch keys.
TestResource* a = TestResource::CreateScratch(gpu, SkBudgeted::kYes,
@@ -477,9 +475,8 @@
static void test_budgeting(skiatest::Reporter* reporter) {
Mock mock(300);
- GrContext* context = mock.context();
GrResourceCache* cache = mock.cache();
- GrGpu* gpu = context->priv().getGpu();
+ GrGpu* gpu = mock.gpu();
GrUniqueKey uniqueKey;
make_unique_key<0>(&uniqueKey, 0);
@@ -604,9 +601,8 @@
static void test_unbudgeted(skiatest::Reporter* reporter) {
Mock mock(30000);
- GrContext* context = mock.context();
GrResourceCache* cache = mock.cache();
- GrGpu* gpu = context->priv().getGpu();
+ GrGpu* gpu = mock.gpu();
GrUniqueKey uniqueKey;
make_unique_key<0>(&uniqueKey, 0);
@@ -677,9 +673,8 @@
void test_unbudgeted_to_scratch(skiatest::Reporter* reporter);
/*static*/ void test_unbudgeted_to_scratch(skiatest::Reporter* reporter) {
Mock mock(300);
- GrContext* context = mock.context();
GrResourceCache* cache = mock.cache();
- GrGpu* gpu = context->priv().getGpu();
+ GrGpu* gpu = mock.gpu();
TestResource* resource =
TestResource::CreateScratch(gpu, SkBudgeted::kNo, TestResource::kA_SimulatedProperty);
@@ -744,9 +739,8 @@
static void test_duplicate_scratch_key(skiatest::Reporter* reporter) {
Mock mock(30000);
- GrContext* context = mock.context();
GrResourceCache* cache = mock.cache();
- GrGpu* gpu = context->priv().getGpu();
+ GrGpu* gpu = mock.gpu();
// Create two resources that have the same scratch key.
TestResource* a = TestResource::CreateScratch(gpu,
@@ -790,9 +784,8 @@
static void test_remove_scratch_key(skiatest::Reporter* reporter) {
Mock mock(30000);
- GrContext* context = mock.context();
GrResourceCache* cache = mock.cache();
- GrGpu* gpu = context->priv().getGpu();
+ GrGpu* gpu = mock.gpu();
// Create two resources that have the same scratch key.
TestResource* a = TestResource::CreateScratch(gpu, SkBudgeted::kYes,
@@ -849,9 +842,8 @@
static void test_scratch_key_consistency(skiatest::Reporter* reporter) {
Mock mock(30000);
- GrContext* context = mock.context();
GrResourceCache* cache = mock.cache();
- GrGpu* gpu = context->priv().getGpu();
+ GrGpu* gpu = mock.gpu();
// Create two resources that have the same scratch key.
TestResource* a = TestResource::CreateScratch(gpu, SkBudgeted::kYes,
@@ -909,9 +901,8 @@
static void test_duplicate_unique_key(skiatest::Reporter* reporter) {
Mock mock(30000);
- GrContext* context = mock.context();
GrResourceCache* cache = mock.cache();
- GrGpu* gpu = context->priv().getGpu();
+ GrGpu* gpu = mock.gpu();
GrUniqueKey key;
make_unique_key<0>(&key, 0);
@@ -1002,9 +993,9 @@
static void test_purge_invalidated(skiatest::Reporter* reporter) {
Mock mock(30000);
- GrContext* context = mock.context();
+ auto dContext = mock.dContext();
GrResourceCache* cache = mock.cache();
- GrGpu* gpu = context->priv().getGpu();
+ GrGpu* gpu = mock.gpu();
GrUniqueKey key1, key2, key3;
make_unique_key<0>(&key1, 1);
@@ -1032,8 +1023,8 @@
typedef SkMessageBus<GrUniqueKeyInvalidatedMessage> Bus;
// Invalidate two of the three, they should be purged and no longer accessible via their keys.
- Bus::Post(Msg(key1, context->priv().contextID()));
- Bus::Post(Msg(key2, context->priv().contextID()));
+ Bus::Post(Msg(key1, dContext->priv().contextID()));
+ Bus::Post(Msg(key2, dContext->priv().contextID()));
cache->purgeAsNeeded();
// a should be deleted now, but we still have a ref on b.
REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key1));
@@ -1042,7 +1033,7 @@
REPORTER_ASSERT(reporter, cache->hasUniqueKey(key3));
// Invalidate the third.
- Bus::Post(Msg(key3, context->priv().contextID()));
+ Bus::Post(Msg(key3, dContext->priv().contextID()));
cache->purgeAsNeeded();
// we still have a ref on b, c should be recycled as scratch.
REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
@@ -1071,9 +1062,8 @@
static void test_cache_chained_purge(skiatest::Reporter* reporter) {
Mock mock(30000);
- GrContext* context = mock.context();
GrResourceCache* cache = mock.cache();
- GrGpu* gpu = context->priv().getGpu();
+ GrGpu* gpu = mock.gpu();
GrUniqueKey key1, key2;
make_unique_key<0>(&key1, 1);
@@ -1117,9 +1107,8 @@
// Run the test 2*kCount times;
for (int i = 0; i < 2 * kCount; ++i ) {
Mock mock(kBudgetSize);
- GrContext* context = mock.context();
GrResourceCache* cache = mock.cache();
- GrGpu* gpu = context->priv().getGpu();
+ GrGpu* gpu = mock.gpu();
// Pick a random number of resources to add before the timestamp will wrap.
cache->changeTimestamp(UINT32_MAX - random.nextULessThan(kCount + 1));
@@ -1174,9 +1163,9 @@
static void test_time_purge(skiatest::Reporter* reporter) {
Mock mock(1000000);
- GrContext* context = mock.context();
+ auto dContext = mock.dContext();
GrResourceCache* cache = mock.cache();
- GrGpu* gpu = context->priv().getGpu();
+ GrGpu* gpu = mock.gpu();
static constexpr int kCnts[] = {1, 10, 1024};
auto nowish = []() {
@@ -1259,7 +1248,7 @@
// Verify that calling flush() on a GrContext with nothing to do will not trigger resource
// eviction
- context->flushAndSubmit();
+ dContext->flushAndSubmit();
for (int i = 0; i < 10; ++i) {
TestResource* r = new TestResource(gpu);
GrUniqueKey k;
@@ -1268,7 +1257,7 @@
r->unref();
}
REPORTER_ASSERT(reporter, 10 == cache->getResourceCount());
- context->flushAndSubmit();
+ dContext->flushAndSubmit();
REPORTER_ASSERT(reporter, 10 == cache->getResourceCount());
cache->purgeResourcesNotUsedSince(nowish());
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
@@ -1277,9 +1266,9 @@
static void test_partial_purge(skiatest::Reporter* reporter) {
Mock mock(100);
- GrContext* context = mock.context();
+ auto dContext = mock.dContext();
GrResourceCache* cache = mock.cache();
- GrGpu* gpu = context->priv().getGpu();
+ GrGpu* gpu = mock.gpu();
enum TestsCase {
kOnlyScratch_TestCase = 0,
@@ -1332,38 +1321,38 @@
switch(testCase) {
case kOnlyScratch_TestCase: {
- context->purgeUnlockedResources(14, true);
+ dContext->purgeUnlockedResources(14, true);
REPORTER_ASSERT(reporter, 3 == cache->getBudgetedResourceCount());
REPORTER_ASSERT(reporter, 33 == cache->getBudgetedResourceBytes());
break;
}
case kPartialScratch_TestCase: {
- context->purgeUnlockedResources(3, true);
+ dContext->purgeUnlockedResources(3, true);
REPORTER_ASSERT(reporter, 4 == cache->getBudgetedResourceCount());
REPORTER_ASSERT(reporter, 47 == cache->getBudgetedResourceBytes());
break;
}
case kAllScratch_TestCase: {
- context->purgeUnlockedResources(50, true);
+ dContext->purgeUnlockedResources(50, true);
REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceCount());
REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceBytes());
break;
}
case kPartial_TestCase: {
- context->purgeUnlockedResources(13, false);
+ dContext->purgeUnlockedResources(13, false);
REPORTER_ASSERT(reporter, 3 == cache->getBudgetedResourceCount());
REPORTER_ASSERT(reporter, 37 == cache->getBudgetedResourceBytes());
break;
}
case kAll_TestCase: {
- context->purgeUnlockedResources(50, false);
+ dContext->purgeUnlockedResources(50, false);
REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceCount());
REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceBytes());
break;
}
case kNone_TestCase: {
- context->purgeUnlockedResources(0, true);
- context->purgeUnlockedResources(0, false);
+ dContext->purgeUnlockedResources(0, true);
+ dContext->purgeUnlockedResources(0, false);
REPORTER_ASSERT(reporter, 5 == cache->getBudgetedResourceCount());
REPORTER_ASSERT(reporter, 60 == cache->getBudgetedResourceBytes());
REPORTER_ASSERT(reporter, 60 == cache->getPurgeableBytes());
@@ -1372,7 +1361,7 @@
}
// ensure all are purged before the next
- context->priv().testingOnly_purgeAllUnlockedResources();
+ dContext->priv().testingOnly_purgeAllUnlockedResources();
REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceCount());
REPORTER_ASSERT(reporter, 0 == cache->getPurgeableBytes());
@@ -1395,11 +1384,11 @@
static void test_abandoned(skiatest::Reporter* reporter) {
Mock mock(300);
- GrContext* context = mock.context();
- GrGpu* gpu = context->priv().getGpu();
+ auto dContext = mock.dContext();
+ GrGpu* gpu = mock.gpu();
sk_sp<GrGpuResource> resource(new TestResource(gpu));
- context->abandonContext();
+ dContext->abandonContext();
REPORTER_ASSERT(reporter, resource->wasDestroyed());
@@ -1429,9 +1418,8 @@
static constexpr int kNumResources = kLastTagIdx * (kLastTagIdx + 1) / 2;
Mock mock(kNumResources * TestResource::kDefaultSize);
- GrContext* context = mock.context();
GrResourceCache* cache = mock.cache();
- GrGpu* gpu = context->priv().getGpu();
+ GrGpu* gpu = mock.gpu();
// tag strings are expected to be long lived
std::vector<SkString> tagStrings;
@@ -1466,9 +1454,9 @@
static void test_free_texture_messages(skiatest::Reporter* reporter) {
Mock mock(30000);
- GrContext* context = mock.context();
+ auto dContext = mock.dContext();
GrResourceCache* cache = mock.cache();
- GrGpu* gpu = context->priv().getGpu();
+ GrGpu* gpu = mock.gpu();
GrBackendTexture backends[3];
GrTexture* wrapped[3];
@@ -1480,8 +1468,8 @@
};
for (int i = 0; i < 3; ++i) {
- backends[i] = context->createBackendTexture(16, 16, SkColorType::kRGBA_8888_SkColorType,
- GrMipMapped::kNo, GrRenderable::kNo);
+ backends[i] = dContext->createBackendTexture(16, 16, SkColorType::kRGBA_8888_SkColorType,
+ GrMipMapped::kNo, GrRenderable::kNo);
wrapped[i] = gpu->wrapBackendTexture(backends[i],
GrWrapOwnership::kBorrow_GrWrapOwnership,
(i < 2) ? GrWrapCacheable::kYes : GrWrapCacheable::kNo,
@@ -1513,14 +1501,14 @@
REPORTER_ASSERT(reporter, 0 == (freed[0] + freed[1] + freed[2]));
// Send message to free the first resource
- GrTextureFreedMessage msg1{wrapped[0], context->priv().contextID()};
+ GrTextureFreedMessage msg1{wrapped[0], dContext->priv().contextID()};
SkMessageBus<GrTextureFreedMessage>::Post(msg1);
cache->purgeAsNeeded();
REPORTER_ASSERT(reporter, 1 == (freed[0] + freed[1] + freed[2]));
REPORTER_ASSERT(reporter, 1 == freed[0]);
- GrTextureFreedMessage msg2{wrapped[2], context->priv().contextID()};
+ GrTextureFreedMessage msg2{wrapped[2], dContext->priv().contextID()};
SkMessageBus<GrTextureFreedMessage>::Post(msg2);
cache->purgeAsNeeded();
diff --git a/tests/SRGBReadWritePixelsTest.cpp b/tests/SRGBReadWritePixelsTest.cpp
index 1844870..62b1aa8 100644
--- a/tests/SRGBReadWritePixelsTest.cpp
+++ b/tests/SRGBReadWritePixelsTest.cpp
@@ -7,7 +7,6 @@
#include "include/core/SkCanvas.h"
#include "include/core/SkSurface.h"
-#include "include/gpu/GrContext.h"
#include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrContextPriv.h"
@@ -189,10 +188,10 @@
}
static std::unique_ptr<GrSurfaceContext> make_surface_context(Encoding contextEncoding,
- GrContext* context,
+ GrRecordingContext* rContext,
skiatest::Reporter* reporter) {
auto surfaceContext = GrRenderTargetContext::Make(
- context, GrColorType::kRGBA_8888, encoding_as_color_space(contextEncoding),
+ rContext, GrColorType::kRGBA_8888, encoding_as_color_space(contextEncoding),
SkBackingFit::kExact, {kW, kH}, 1, GrMipMapped::kNo, GrProtected::kNo,
kBottomLeft_GrSurfaceOrigin, SkBudgeted::kNo);
if (!surfaceContext) {
@@ -202,9 +201,9 @@
}
static void test_write_read(Encoding contextEncoding, Encoding writeEncoding, Encoding readEncoding,
- float error, CheckFn check, GrContext* context,
+ float error, CheckFn check, GrRecordingContext* rContext,
skiatest::Reporter* reporter) {
- auto surfaceContext = make_surface_context(contextEncoding, context, reporter);
+ auto surfaceContext = make_surface_context(contextEncoding, rContext, reporter);
if (!surfaceContext) {
return;
}
diff --git a/tests/TestTest.cpp b/tests/TestTest.cpp
index 13d6ef4..a68c60d 100644
--- a/tests/TestTest.cpp
+++ b/tests/TestTest.cpp
@@ -7,7 +7,7 @@
#include "tests/Test.h"
-#include "include/gpu/GrContext.h"
+#include "include/gpu/GrDirectContext.h"
#include "tools/gpu/gl/GLTestContext.h"
// This is an example of a normal test.
diff --git a/tests/TextBlobCacheTest.cpp b/tests/TextBlobCacheTest.cpp
index 6e72d9e..66d7162 100644
--- a/tests/TextBlobCacheTest.cpp
+++ b/tests/TextBlobCacheTest.cpp
@@ -19,6 +19,7 @@
#include "include/core/SkTypeface.h"
#include "include/gpu/GrDirectContext.h"
#include "src/core/SkGlyphRun.h"
+#include "src/gpu/GrContextPriv.h"
#include "tools/fonts/RandomScalerContext.h"
#ifdef SK_BUILD_FOR_WIN
@@ -27,8 +28,6 @@
#include "tests/Test.h"
-#include "include/gpu/GrContext.h"
-#include "src/gpu/GrContextPriv.h"
#include "src/gpu/text/GrAtlasManager.h"
#include "src/gpu/text/GrTextBlobCache.h"
@@ -48,8 +47,8 @@
static const int kWidth = 1024;
static const int kHeight = 768;
-static void setup_always_evict_atlas(GrContext* context) {
- context->priv().getAtlasManager()->setAtlasDimensionsToMinimum_ForTesting();
+static void setup_always_evict_atlas(GrDirectContext* dContext) {
+ dContext->priv().getAtlasManager()->setAtlasDimensionsToMinimum_ForTesting();
}
class GrTextBlobTestingPeer {
@@ -62,7 +61,7 @@
};
// This test hammers the GPU textblobcache and font atlas
-static void text_blob_cache_inner(skiatest::Reporter* reporter, GrContext* context,
+static void text_blob_cache_inner(skiatest::Reporter* reporter, GrDirectContext* dContext,
int maxTotalText, int maxGlyphID, int maxFamilies, bool normal,
bool stressTest) {
// setup surface
@@ -71,13 +70,13 @@
// configure our context for maximum stressing of cache and atlas
if (stressTest) {
- setup_always_evict_atlas(context);
- GrTextBlobTestingPeer::SetBudget(context->priv().getTextBlobCache(), 0);
+ setup_always_evict_atlas(dContext);
+ GrTextBlobTestingPeer::SetBudget(dContext->priv().getTextBlobCache(), 0);
}
SkImageInfo info = SkImageInfo::Make(kWidth, kHeight, kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
- auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info, 0, &props));
+ auto surface(SkSurface::MakeRenderTarget(dContext, SkBudgeted::kNo, info, 0, &props));
REPORTER_ASSERT(reporter, surface);
if (!surface) {
return;
@@ -159,14 +158,14 @@
draw(canvasNoLCD, 2, blobs);
// test draw after free
- context->freeGpuResources();
+ dContext->freeGpuResources();
draw(canvas, 1, blobs);
- context->freeGpuResources();
+ dContext->freeGpuResources();
draw(canvasNoLCD, 1, blobs);
// test draw after abandon
- context->abandonContext();
+ dContext->abandonContext();
draw(canvas, 1, blobs);
}
@@ -275,10 +274,10 @@
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TextBlobIntegerOverflowTest, reporter, ctxInfo) {
- auto grContext = ctxInfo.grContext();
+ auto dContext = ctxInfo.directContext();
const SkImageInfo info =
SkImageInfo::Make(kScreenDim, kScreenDim, kN32_SkColorType, kPremul_SkAlphaType);
- auto surface = SkSurface::MakeRenderTarget(grContext, SkBudgeted::kNo, info);
+ auto surface = SkSurface::MakeRenderTarget(dContext, SkBudgeted::kNo, info);
auto blob = make_large_blob();
int y = 40;
diff --git a/tests/VkYcbcrSamplerTest.cpp b/tests/VkYcbcrSamplerTest.cpp
index c526086..cf732b1 100644
--- a/tests/VkYcbcrSamplerTest.cpp
+++ b/tests/VkYcbcrSamplerTest.cpp
@@ -12,7 +12,7 @@
#include "include/core/SkCanvas.h"
#include "include/core/SkImage.h"
#include "include/core/SkSurface.h"
-#include "include/gpu/GrContext.h"
+#include "include/gpu/GrDirectContext.h"
#include "tests/Test.h"
#include "tools/gpu/vk/VkTestHelper.h"
#include "tools/gpu/vk/VkYcbcrSamplerHelper.h"
diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp
index b661763..792d4d2 100644
--- a/tests/skia_test.cpp
+++ b/tests/skia_test.cpp
@@ -8,7 +8,6 @@
#include <atomic>
#include "include/core/SkGraphics.h"
#include "include/core/SkTime.h"
-#include "include/gpu/GrContext.h"
#include "include/private/SkTArray.h"
#include "include/private/SkTemplates.h"
#include "src/core/SkOSFile.h"