Update more tests to use the GrDirectContext/GrRecordingContext pair

Change-Id: I66011fef006398a95c9f54af97c5c1092b8b7415
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305497
Reviewed-by: Adlai Holler <adlai@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2020-07-23 09:41:57 -04:00 committed by Skia Commit-Bot
parent 36e0849af6
commit 58adb34cda
11 changed files with 92 additions and 83 deletions

View File

@ -225,11 +225,11 @@ public:
int id() const { return fID; }
static std::unique_ptr<AtlasedRectOp> Make(GrContext* context,
static std::unique_ptr<AtlasedRectOp> Make(GrRecordingContext* rContext,
GrPaint&& paint,
const SkRect& r,
int id) {
GrDrawOp* op = Helper::FactoryHelper<AtlasedRectOp>(context, std::move(paint),
GrDrawOp* op = Helper::FactoryHelper<AtlasedRectOp>(rContext, std::move(paint),
r, id).release();
return std::unique_ptr<AtlasedRectOp>(static_cast<AtlasedRectOp*>(op));
}
@ -462,11 +462,13 @@ private:
};
// This creates an off-screen rendertarget whose ops which eventually pull from the atlas.
static GrSurfaceProxyView make_upstream_image(GrContext* context, AtlasObject* object, int start,
static GrSurfaceProxyView make_upstream_image(GrRecordingContext* rContext,
AtlasObject* object,
int start,
GrSurfaceProxyView atlasView,
SkAlphaType atlasAlphaType) {
auto rtc = GrRenderTargetContext::Make(
context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox,
rContext, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox,
{3 * kDrawnTileSize, kDrawnTileSize});
rtc->clear({ 1, 0, 0, 1 });
@ -478,7 +480,7 @@ static GrSurfaceProxyView make_upstream_image(GrContext* context, AtlasObject* o
GrPaint paint;
paint.setColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
std::unique_ptr<AtlasedRectOp> op(AtlasedRectOp::Make(context,
std::unique_ptr<AtlasedRectOp> op(AtlasedRectOp::Make(rContext,
std::move(paint), r, start + i));
AtlasedRectOp* sparePtr = op.get();
@ -506,7 +508,7 @@ static void save_bm(const SkBitmap& bm, const char name[]) {
SkASSERT(result);
}
sk_sp<GrTextureProxy> pre_create_atlas(GrContext* context) {
sk_sp<GrTextureProxy> pre_create_atlas(GrRecordingContext* rContext) {
SkBitmap bm;
bm.allocN32Pixels(18, 2, true);
bm.erase(SK_ColorRED, SkIRect::MakeXYWH(0, 0, 2, 2));
@ -525,8 +527,8 @@ sk_sp<GrTextureProxy> pre_create_atlas(GrContext* context) {
desc.fFlags |= kRenderTarget_GrSurfaceFlag;
sk_sp<GrSurfaceProxy> tmp = GrSurfaceProxy::MakeDeferred(*context->caps(),
context->textureProvider(),
sk_sp<GrSurfaceProxy> tmp = GrSurfaceProxy::MakeDeferred(*rContext->caps(),
rContext->textureProvider(),
dm.dimensions(), SkBudgeted::kYes,
bm.getPixels(), bm.rowBytes());

View File

@ -241,7 +241,7 @@ static void make_path_crbugskia2820(SkPath* path, skiatest::Reporter* reporter)
path->close();
}
static void test_path_crbugskia2820(skiatest::Reporter* reporter) {//GrContext* context) {
static void test_path_crbugskia2820(skiatest::Reporter* reporter) {
SkPath path;
make_path_crbugskia2820(&path, reporter);

View File

@ -35,7 +35,7 @@ static bool surface_is_expected_color(SkSurface* surf, const SkImageInfo& ii, Sk
return true;
}
static void basic_test(skiatest::Reporter* reporter, GrContext* context) {
static void basic_test(skiatest::Reporter* reporter, GrRecordingContext* rContext) {
const SkImageInfo ii = SkImageInfo::Make(64, 64, kN32_SkColorType, kPremul_SkAlphaType);
SkBitmap bm;
@ -47,7 +47,7 @@ static void basic_test(skiatest::Reporter* reporter, GrContext* context) {
// We start off with the raster image being all red.
sk_sp<SkImage> img = SkMakeImageFromRasterBitmap(bm, kNever_SkCopyPixelsMode);
sk_sp<SkSurface> gpuSurface = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, ii);
sk_sp<SkSurface> gpuSurface = SkSurface::MakeRenderTarget(rContext, SkBudgeted::kYes, ii);
SkCanvas* canvas = gpuSurface->getCanvas();
// w/o pinning - the gpu draw always reflects the current state of the underlying bitmap
@ -63,7 +63,7 @@ static void basic_test(skiatest::Reporter* reporter, GrContext* context) {
// w/ pinning - the gpu draw is stuck at the pinned state
{
SkImage_pinAsTexture(img.get(), context); // pin at blue
SkImage_pinAsTexture(img.get(), rContext); // pin at blue
canvas->drawImage(img, 0, 0);
REPORTER_ASSERT(reporter, surface_is_expected_color(gpuSurface.get(), ii, SK_ColorGREEN));
@ -73,7 +73,7 @@ static void basic_test(skiatest::Reporter* reporter, GrContext* context) {
canvas->drawImage(img, 0, 0);
REPORTER_ASSERT(reporter, surface_is_expected_color(gpuSurface.get(), ii, SK_ColorGREEN));
SkImage_unpinAsTexture(img.get(), context);
SkImage_unpinAsTexture(img.get(), rContext);
}
// once unpinned local changes will be picked up

View File

@ -34,8 +34,8 @@ public:
const char* name() const override { return "Dummy Op"; }
static std::unique_ptr<GrDrawOp> Make(GrContext* context, int numAttribs) {
GrOpMemoryPool* pool = context->priv().opMemoryPool();
static std::unique_ptr<GrDrawOp> Make(GrRecordingContext* rContext, int numAttribs) {
GrOpMemoryPool* pool = rContext->priv().opMemoryPool();
return pool->allocate<Op>(numAttribs);
}

View File

@ -30,9 +30,9 @@ namespace {
class TestOp : public GrMeshDrawOp {
public:
DEFINE_OP_CLASS_ID
static std::unique_ptr<GrDrawOp> Make(GrContext* context,
static std::unique_ptr<GrDrawOp> Make(GrRecordingContext* rContext,
std::unique_ptr<GrFragmentProcessor> fp) {
GrOpMemoryPool* pool = context->priv().opMemoryPool();
GrOpMemoryPool* pool = rContext->priv().opMemoryPool();
return pool->allocate<TestOp>(std::move(fp));
}
@ -226,22 +226,24 @@ static GrColor input_texel_color(int i, int j, SkScalar delta) {
return color4f.premul().toBytes_RGBA();
}
void test_draw_op(GrContext* context, GrRenderTargetContext* rtc,
void test_draw_op(GrRecordingContext* rContext,
GrRenderTargetContext* rtc,
std::unique_ptr<GrFragmentProcessor> fp) {
GrPaint paint;
paint.setColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
auto op = GrFillRectOp::MakeNonAARect(context, std::move(paint), SkMatrix::I(),
auto op = GrFillRectOp::MakeNonAARect(rContext, std::move(paint), SkMatrix::I(),
SkRect::MakeWH(rtc->width(), rtc->height()));
rtc->priv().testingOnly_addDrawOp(std::move(op));
}
// The output buffer must be the same size as the render-target context.
void render_fp(GrContext* context, GrRenderTargetContext* rtc,
void render_fp(GrRecordingContext* rContext,
GrRenderTargetContext* rtc,
std::unique_ptr<GrFragmentProcessor> fp,
GrColor* outBuffer) {
test_draw_op(context, rtc, std::move(fp));
test_draw_op(rContext, rtc, std::move(fp));
std::fill_n(outBuffer, rtc->width() * rtc->height(), 0);
rtc->readPixels(SkImageInfo::Make(rtc->width(), rtc->height(), kRGBA_8888_SkColorType,
kPremul_SkAlphaType),
@ -397,11 +399,11 @@ bool log_pixels(GrColor* pixels, int widthHeight, SkString* dst) {
return BipmapToBase64DataURI(bmp, dst);
}
bool log_texture_view(GrContext* context, GrSurfaceProxyView src, SkString* dst) {
bool log_texture_view(GrRecordingContext* rContext, GrSurfaceProxyView src, SkString* dst) {
SkImageInfo ii = SkImageInfo::Make(src.proxy()->dimensions(), kRGBA_8888_SkColorType,
kLogAlphaType);
auto sContext = GrSurfaceContext::Make(context, std::move(src), GrColorType::kRGBA_8888,
auto sContext = GrSurfaceContext::Make(rContext, std::move(src), GrColorType::kRGBA_8888,
kLogAlphaType, nullptr);
SkBitmap bm;
SkAssertResult(bm.tryAllocPixels(ii));

View File

@ -145,9 +145,10 @@ private:
static const int kRenderTargetHeight = 1;
static const int kRenderTargetWidth = 1;
static std::unique_ptr<GrRenderTargetContext> random_render_target_context(GrContext* context,
SkRandom* random,
const GrCaps* caps) {
static std::unique_ptr<GrRenderTargetContext> random_render_target_context(
GrRecordingContext* rContext,
SkRandom* random,
const GrCaps* caps) {
GrSurfaceOrigin origin = random->nextBool() ? kTopLeft_GrSurfaceOrigin
: kBottomLeft_GrSurfaceOrigin;
@ -159,7 +160,7 @@ static std::unique_ptr<GrRenderTargetContext> random_render_target_context(GrCon
sampleCnt = std::max(1, sampleCnt);
return GrRenderTargetContext::Make(
context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact,
rContext, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact,
{kRenderTargetWidth, kRenderTargetHeight}, sampleCnt, GrMipmapped::kNo,
GrProtected::kNo, origin);
}

View File

@ -239,16 +239,16 @@ DEF_GPUTEST(PromiseImageTextureShutdown, reporter, ctxInfo) {
const int kHeight = 10;
// Different ways of killing contexts.
using DeathFn = std::function<void(sk_gpu_test::GrContextFactory*, GrContext*)>;
DeathFn destroy = [](sk_gpu_test::GrContextFactory* factory, GrContext* context) {
using DeathFn = std::function<void(sk_gpu_test::GrContextFactory*, GrDirectContext*)>;
DeathFn destroy = [](sk_gpu_test::GrContextFactory* factory, GrDirectContext*) {
factory->destroyContexts();
};
DeathFn abandon = [](sk_gpu_test::GrContextFactory* factory, GrContext* context) {
context->abandonContext();
DeathFn abandon = [](sk_gpu_test::GrContextFactory* factory, GrDirectContext* dContext) {
dContext->abandonContext();
};
DeathFn releaseResourcesAndAbandon = [](sk_gpu_test::GrContextFactory* factory,
GrContext* context) {
context->releaseResourcesAndAbandonContext();
GrDirectContext* dContext) {
dContext->releaseResourcesAndAbandonContext();
};
for (int type = 0; type < sk_gpu_test::GrContextFactory::kContextTypeCnt; ++type) {
@ -272,7 +272,8 @@ DEF_GPUTEST(PromiseImageTextureShutdown, reporter, ctxInfo) {
GrBackendTexture backendTex;
CreateBackendTexture(ctx, &backendTex, kWidth, kHeight, kAlpha_8_SkColorType,
SkColors::kTransparent, GrMipmapped::kNo, GrRenderable::kNo, GrProtected::kNo);
SkColors::kTransparent, GrMipmapped::kNo, GrRenderable::kNo,
GrProtected::kNo);
REPORTER_ASSERT(reporter, backendTex.isValid());
SkImageInfo info = SkImageInfo::Make(kWidth, kHeight, kRGBA_8888_SkColorType,
@ -307,21 +308,21 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageTextureFullCache, reporter, ctxIn
const int kWidth = 10;
const int kHeight = 10;
auto ctx = ctxInfo.directContext();
auto dContext = ctxInfo.directContext();
GrBackendTexture backendTex = ctx->createBackendTexture(
GrBackendTexture backendTex = dContext->createBackendTexture(
kWidth, kHeight, kAlpha_8_SkColorType,
SkColors::kTransparent, GrMipmapped::kNo, GrRenderable::kNo, GrProtected::kNo);
REPORTER_ASSERT(reporter, backendTex.isValid());
SkImageInfo info =
SkImageInfo::Make(kWidth, kHeight, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info);
sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(dContext, SkBudgeted::kNo, info);
SkCanvas* canvas = surface->getCanvas();
PromiseTextureChecker promiseChecker(backendTex, reporter, false);
sk_sp<SkImage> image(SkImage_Gpu::MakePromiseTexture(
ctx, backendTex.getBackendFormat(), kWidth, kHeight, GrMipmapped::kNo,
dContext, backendTex.getBackendFormat(), kWidth, kHeight, GrMipmapped::kNo,
kTopLeft_GrSurfaceOrigin, kAlpha_8_SkColorType, kPremul_SkAlphaType, nullptr,
PromiseTextureChecker::Fulfill, PromiseTextureChecker::Release,
PromiseTextureChecker::Done, &promiseChecker,
@ -331,12 +332,12 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageTextureFullCache, reporter, ctxIn
// Make the cache full. This tests that we don't preemptively purge cached textures for
// fulfillment due to cache pressure.
static constexpr int kMaxBytes = 1;
ctx->setResourceCacheLimit(kMaxBytes);
dContext->setResourceCacheLimit(kMaxBytes);
SkTArray<sk_sp<GrTexture>> textures;
for (int i = 0; i < 5; ++i) {
auto format = ctx->priv().caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kNo);
textures.emplace_back(ctx->priv().resourceProvider()->createTexture(
auto format = dContext->priv().caps()->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kNo);
textures.emplace_back(dContext->priv().resourceProvider()->createTexture(
{100, 100}, format, GrRenderable::kNo, 1, GrMipmapped::kNo, SkBudgeted::kYes,
GrProtected::kNo));
REPORTER_ASSERT(reporter, textures[i]);
@ -344,7 +345,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageTextureFullCache, reporter, ctxIn
size_t bytesUsed;
ctx->getResourceCacheUsage(nullptr, &bytesUsed);
dContext->getResourceCacheUsage(nullptr, &bytesUsed);
REPORTER_ASSERT(reporter, bytesUsed > kMaxBytes);
// Relying on the asserts in the promiseImageChecker to ensure that fulfills and releases are
@ -363,10 +364,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageTextureFullCache, reporter, ctxIn
surface->flushAndSubmit();
// Must call these to ensure that all callbacks are performed before the checker is destroyed.
image.reset();
ctx->flushAndSubmit();
ctx->priv().getGpu()->testingOnly_flushGpuAndSync();
dContext->flushAndSubmit();
dContext->priv().getGpu()->testingOnly_flushGpuAndSync();
ctx->deleteBackendTexture(backendTex);
dContext->deleteBackendTexture(backendTex);
}
// Test case where promise image fulfill returns nullptr.
@ -374,17 +375,17 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageNullFulfill, reporter, ctxInfo) {
const int kWidth = 10;
const int kHeight = 10;
auto ctx = ctxInfo.directContext();
auto dContext = ctxInfo.directContext();
// Do all this just to get a valid backend format for the image.
GrBackendTexture backendTex;
CreateBackendTexture(ctx, &backendTex, kWidth, kHeight, kRGBA_8888_SkColorType,
CreateBackendTexture(dContext, &backendTex, kWidth, kHeight, kRGBA_8888_SkColorType,
SkColors::kTransparent, GrMipmapped::kNo, GrRenderable::kYes,
GrProtected::kNo);
REPORTER_ASSERT(reporter, backendTex.isValid());
GrBackendFormat backendFormat = backendTex.getBackendFormat();
REPORTER_ASSERT(reporter, backendFormat.isValid());
ctx->deleteBackendTexture(backendTex);
dContext->deleteBackendTexture(backendTex);
struct Counts {
int fFulfillCount = 0;
@ -403,12 +404,12 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageNullFulfill, reporter, ctxInfo) {
};
GrSurfaceOrigin texOrigin = kTopLeft_GrSurfaceOrigin;
sk_sp<SkImage> refImg(SkImage_Gpu::MakePromiseTexture(
ctx, backendFormat, kWidth, kHeight, GrMipmapped::kNo, texOrigin,
dContext, backendFormat, kWidth, kHeight, GrMipmapped::kNo, texOrigin,
kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr, fulfill, release, done, &counts,
SkDeferredDisplayListRecorder::PromiseImageApiVersion::kNew));
SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight);
sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info);
sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(dContext, SkBudgeted::kNo, info);
SkCanvas* canvas = surface->getCanvas();
// Draw the image a few different ways.
canvas->drawImage(refImg, 0, 0);

View File

@ -55,16 +55,16 @@ private:
size_t fDumpedObjectsSize = 0;
};
void ValidateMemoryDumps(skiatest::Reporter* reporter, GrContext* context, size_t size,
void ValidateMemoryDumps(skiatest::Reporter* reporter, GrDirectContext* dContext, size_t size,
bool isOwned) {
// Note than one entry in the dumped objects is expected for the text blob cache.
TestSkTraceMemoryDump dump_with_wrapped(true /* shouldDumpWrappedObjects */);
context->dumpMemoryStatistics(&dump_with_wrapped);
dContext->dumpMemoryStatistics(&dump_with_wrapped);
REPORTER_ASSERT(reporter, 2 == dump_with_wrapped.numDumpedObjects());
REPORTER_ASSERT(reporter, size == dump_with_wrapped.dumpedObjectsSize());
TestSkTraceMemoryDump dump_no_wrapped(false /* shouldDumpWrappedObjects */);
context->dumpMemoryStatistics(&dump_no_wrapped);
dContext->dumpMemoryStatistics(&dump_no_wrapped);
if (isOwned) {
REPORTER_ASSERT(reporter, 2 == dump_no_wrapped.numDumpedObjects());
REPORTER_ASSERT(reporter, size == dump_no_wrapped.dumpedObjectsSize());
@ -76,18 +76,18 @@ void ValidateMemoryDumps(skiatest::Reporter* reporter, GrContext* context, size_
#ifdef SK_GL
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkTraceMemoryDump_ownedGLBuffer, reporter, ctxInfo) {
auto context = ctxInfo.directContext();
GrGLGpu* gpu = static_cast<GrGLGpu*>(context->priv().getGpu());
auto dContext = ctxInfo.directContext();
GrGLGpu* gpu = static_cast<GrGLGpu*>(dContext->priv().getGpu());
const size_t kMemorySize = 1024;
sk_sp<GrGLBuffer> buffer =
GrGLBuffer::Make(gpu, kMemorySize, GrGpuBufferType::kVertex, kDynamic_GrAccessPattern);
ValidateMemoryDumps(reporter, context, kMemorySize, true /* isOwned */);
ValidateMemoryDumps(reporter, dContext, kMemorySize, true /* isOwned */);
}
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkTraceMemoryDump_ownedGLTexture, reporter, ctxInfo) {
auto context = ctxInfo.directContext();
GrGLGpu* gpu = static_cast<GrGLGpu*>(context->priv().getGpu());
auto dContext = ctxInfo.directContext();
GrGLGpu* gpu = static_cast<GrGLGpu*>(dContext->priv().getGpu());
GrGLTexture::Desc desc;
desc.fTarget = GR_GL_TEXTURE_2D;
@ -99,12 +99,12 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkTraceMemoryDump_ownedGLTexture, reporter
auto texture =
sk_make_sp<GrGLTexture>(gpu, SkBudgeted::kNo, desc, GrMipmapStatus::kNotAllocated);
ValidateMemoryDumps(reporter, context, texture->gpuMemorySize(), true /* isOwned */);
ValidateMemoryDumps(reporter, dContext, texture->gpuMemorySize(), true /* isOwned */);
}
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkTraceMemoryDump_unownedGLTexture, reporter, ctxInfo) {
auto context = ctxInfo.directContext();
GrGLGpu* gpu = static_cast<GrGLGpu*>(context->priv().getGpu());
auto dContext = ctxInfo.directContext();
GrGLGpu* gpu = static_cast<GrGLGpu*>(dContext->priv().getGpu());
GrGLTexture::Desc desc;
desc.fTarget = GR_GL_TEXTURE_2D;
@ -119,12 +119,12 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkTraceMemoryDump_unownedGLTexture, report
GrGLTexture::MakeWrapped(gpu, GrMipmapStatus::kNotAllocated, desc, std::move(params),
GrWrapCacheable::kNo, kRead_GrIOType);
ValidateMemoryDumps(reporter, context, texture->gpuMemorySize(), false /* isOwned */);
ValidateMemoryDumps(reporter, dContext, texture->gpuMemorySize(), false /* isOwned */);
}
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkTraceMemoryDump_ownedGLRenderTarget, reporter, ctxInfo) {
auto context = ctxInfo.directContext();
GrGLGpu* gpu = static_cast<GrGLGpu*>(context->priv().getGpu());
auto dContext = ctxInfo.directContext();
GrGLGpu* gpu = static_cast<GrGLGpu*>(dContext->priv().getGpu());
static constexpr auto kSize = SkISize::Make(64, 64);
@ -137,12 +137,12 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkTraceMemoryDump_ownedGLRenderTarget, rep
sk_sp<GrGLRenderTarget> rt =
GrGLRenderTarget::MakeWrapped(gpu, kSize, GrGLFormat::kRGBA8, 1, rtIDs, 0);
ValidateMemoryDumps(reporter, context, rt->gpuMemorySize(), true /* isOwned */);
ValidateMemoryDumps(reporter, dContext, rt->gpuMemorySize(), true /* isOwned */);
}
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkTraceMemoryDump_unownedGLRenderTarget, reporter, ctxInfo) {
auto context = ctxInfo.directContext();
GrGLGpu* gpu = static_cast<GrGLGpu*>(context->priv().getGpu());
auto dContext = ctxInfo.directContext();
GrGLGpu* gpu = static_cast<GrGLGpu*>(dContext->priv().getGpu());
static constexpr auto kSize = SkISize::Make(64, 64);
@ -155,6 +155,6 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkTraceMemoryDump_unownedGLRenderTarget, r
sk_sp<GrGLRenderTarget> rt =
GrGLRenderTarget::MakeWrapped(gpu, kSize, GrGLFormat::kRGBA8, 1, rtIDs, 0);
ValidateMemoryDumps(reporter, context, rt->gpuMemorySize(), false /* isOwned */);
ValidateMemoryDumps(reporter, dContext, rt->gpuMemorySize(), false /* isOwned */);
}
#endif // SK_GL

View File

@ -94,21 +94,23 @@ bool read_pixels_from_texture(GrTexture* texture, GrColorType colorType, char* d
return gpu->readPixels(texture, 0, 0, w, h, colorType, supportedRead.fColorType, dst, rowBytes);
}
void basic_transfer_to_test(skiatest::Reporter* reporter, GrContext* context, GrColorType colorType,
void basic_transfer_to_test(skiatest::Reporter* reporter,
GrDirectContext* dContext,
GrColorType colorType,
GrRenderable renderable) {
if (GrCaps::kNone_MapFlags == context->priv().caps()->mapBufferFlags()) {
if (GrCaps::kNone_MapFlags == dContext->priv().caps()->mapBufferFlags()) {
return;
}
auto* caps = context->priv().caps();
auto* caps = dContext->priv().caps();
auto backendFormat = caps->getDefaultBackendFormat(colorType, renderable);
if (!backendFormat.isValid()) {
return;
}
auto resourceProvider = context->priv().resourceProvider();
GrGpu* gpu = context->priv().getGpu();
auto resourceProvider = dContext->priv().resourceProvider();
GrGpu* gpu = dContext->priv().getGpu();
static constexpr SkISize kTexDims = {16, 16};
int srcBufferWidth = caps->writePixelsRowBytesSupport() ? 20 : 16;

View File

@ -687,7 +687,8 @@ static SkPath create_path_46() {
return path;
}
static std::unique_ptr<GrFragmentProcessor> create_linear_gradient_processor(GrContext* ctx) {
static std::unique_ptr<GrFragmentProcessor> create_linear_gradient_processor(
GrRecordingContext* rContext) {
SkPoint pts[2] = { {0, 0}, {1, 1} };
SkColor colors[2] = { SK_ColorGREEN, SK_ColorBLUE };
@ -695,11 +696,11 @@ static std::unique_ptr<GrFragmentProcessor> create_linear_gradient_processor(GrC
pts, colors, nullptr, SK_ARRAY_COUNT(colors), SkTileMode::kClamp);
GrColorInfo colorInfo(GrColorType::kRGBA_8888, kPremul_SkAlphaType, nullptr);
SkSimpleMatrixProvider matrixProvider(SkMatrix::I());
GrFPArgs args(ctx, matrixProvider, SkFilterQuality::kLow_SkFilterQuality, &colorInfo);
GrFPArgs args(rContext, matrixProvider, SkFilterQuality::kLow_SkFilterQuality, &colorInfo);
return as_SB(shader)->asFragmentProcessor(args);
}
static void test_path(GrContext* ctx,
static void test_path(GrRecordingContext* rContext,
GrRenderTargetContext* renderTargetContext,
const SkPath& path,
const SkMatrix& matrix = SkMatrix::I(),
@ -718,7 +719,7 @@ static void test_path(GrContext* ctx,
renderTargetContext->height());
GrStyle style(SkStrokeRec::kFill_InitStyle);
GrStyledShape shape(path, style);
GrPathRenderer::DrawPathArgs args{ctx,
GrPathRenderer::DrawPathArgs args{rContext,
std::move(paint),
&GrUserStencilSettings::kUnused,
renderTargetContext,

View File

@ -129,14 +129,14 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkImageLayoutTest, reporter, ctxInfo) {
#if 0
// Test to make sure we transition from the EXTERNAL queue even when no layout transition is needed.
DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkTransitionExternalQueueTest, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
GrGpu* gpu = context->priv().getGpu();
auto dContext = ctxInfo.directContext();
GrGpu* gpu = dContext->priv().getGpu();
GrVkGpu* vkGpu = static_cast<GrVkGpu*>(gpu);
if (!vkGpu->vkCaps().supportsExternalMemory()) {
return;
}
GrBackendTexture backendTex = context->createBackendTexture(
GrBackendTexture backendTex = dContext->createBackendTexture(
1, 1, kRGBA_8888_SkColorType,
SkColors::kTransparent, GrMipmapped::kNo, GrRenderable::kNo);
sk_sp<SkImage> image;
@ -151,7 +151,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkTransitionExternalQueueTest, reporter, ctxInfo)
GrBackendTexture vkExtTex(1, 1, vkInfo);
REPORTER_ASSERT(reporter, vkExtTex.isValid());
image = SkImage::MakeFromTexture(context, vkExtTex, kTopLeft_GrSurfaceOrigin,
image = SkImage::MakeFromTexture(dContext, vkExtTex, kTopLeft_GrSurfaceOrigin,
kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr, nullptr,
nullptr);
@ -176,7 +176,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkTransitionExternalQueueTest, reporter, ctxInfo)
image.reset();
gpu->testingOnly_flushGpuAndSync();
context->deleteBackendTexture(backendTex);
dContext->deleteBackendTexture(backendTex);
}
#endif