Reland "Migrate GrSurfaceContext readPixels to take direct context"
This reverts commit cf0d08e149cfea45b2bc70ec22181315d33ddb3f.
Reason for revert: fix codegen
Original change's description:
> Revert "Migrate GrSurfaceContext readPixels to take direct context"
>
> This reverts commit d169e1915cba8caaddabb22b3672c7cefa91bfa2.
>
> Reason for revert: broke chrome via code generator
>
> Original change's description:
> > Migrate GrSurfaceContext readPixels to take direct context
> >
> > After this lands we'll proceed up the stack and add the direct
> > context requirement to the public API and SkImage.
> >
> > Bug: skia:104662
> > Change-Id: I4b2d779a7fcd65eec68e631757821ac8e136ddba
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309044
> > Commit-Queue: Adlai Holler <adlai@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
>
> TBR=robertphillips@google.com,adlai@google.com
>
> Change-Id: I6126f2dca4bc902c903512ac486e22841cc472e5
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:104662
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309281
> Reviewed-by: Adlai Holler <adlai@google.com>
> Commit-Queue: Adlai Holler <adlai@google.com>
TBR=robertphillips@google.com,adlai@google.com
Bug: skia:104662
Change-Id: If899edab54d031a3619a4bbab90d13738679c037
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309319
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Adlai Holler <adlai@google.com>
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index fc9bb63..198ff85 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -200,13 +200,13 @@
if (!sk_gpu_test::GrContextFactory::IsRenderingContext(contextType)) {
continue;
}
- auto context = factory.get(contextType);
- if (!context) {
+ auto dContext = factory.get(contextType);
+ if (!dContext) {
continue;
}
- GrProxyProvider* proxyProvider = context->priv().proxyProvider();
- const GrCaps* caps = context->priv().caps();
+ GrProxyProvider* proxyProvider = dContext->priv().proxyProvider();
+ const GrCaps* caps = dContext->priv().caps();
const std::vector<GrCaps::TestFormatColorTypeCombination>& combos =
caps->getTestingCombinations();
@@ -265,13 +265,14 @@
combo.fColorType);
GrSurfaceProxyView view(std::move(proxy), kTopLeft_GrSurfaceOrigin,
swizzle);
- auto texCtx = GrSurfaceContext::Make(context, std::move(view),
+ auto texCtx = GrSurfaceContext::Make(dContext, std::move(view),
combo.fColorType,
kPremul_SkAlphaType, nullptr);
readback.erase(kClearColor);
- if (texCtx->readPixels(readback.info(), readback.writable_addr(),
- readback.rowBytes(), {0, 0})) {
+ if (texCtx->readPixels(
+ dContext, readback.info(), readback.writable_addr(),
+ readback.rowBytes(), {0, 0})) {
for (int i = 0; i < kSize * kSize; ++i) {
if (!checkColor(combo, readback.addr32()[i])) {
break;
@@ -280,7 +281,7 @@
}
}
- context->priv().testingOnly_purgeAllUnlockedResources();
+ dContext->priv().testingOnly_purgeAllUnlockedResources();
}
// Try creating the texture as a deferred proxy.
@@ -288,12 +289,12 @@
std::unique_ptr<GrSurfaceContext> surfCtx;
if (renderable == GrRenderable::kYes) {
surfCtx = GrRenderTargetContext::Make(
- context, combo.fColorType, nullptr, fit,
+ dContext, combo.fColorType, nullptr, fit,
{desc.fWidth, desc.fHeight}, 1, GrMipmapped::kNo,
GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
} else {
surfCtx = GrSurfaceContext::Make(
- context, {desc.fWidth, desc.fHeight}, combo.fFormat,
+ dContext, {desc.fWidth, desc.fHeight}, combo.fFormat,
GrRenderable::kNo, 1, GrMipmapped::kNo, GrProtected::kNo,
kTopLeft_GrSurfaceOrigin, combo.fColorType,
kUnknown_SkAlphaType, nullptr, fit, SkBudgeted::kYes);
@@ -303,7 +304,7 @@
}
readback.erase(kClearColor);
- if (surfCtx->readPixels(readback.info(), readback.writable_addr(),
+ if (surfCtx->readPixels(dContext, readback.info(), readback.writable_addr(),
readback.rowBytes(), {0, 0})) {
for (int i = 0; i < kSize * kSize; ++i) {
if (!checkColor(combo, readback.addr32()[i])) {
@@ -311,7 +312,7 @@
}
}
}
- context->priv().testingOnly_purgeAllUnlockedResources();
+ dContext->priv().testingOnly_purgeAllUnlockedResources();
}
}
}
@@ -349,30 +350,30 @@
return (0xFFU << 24) | (x << 16) | (y << 8) | uint8_t((x * y) & 0xFF);
});
- auto context = context_info.directContext();
- GrProxyProvider* proxyProvider = context->priv().proxyProvider();
+ auto dContext = context_info.directContext();
+ GrProxyProvider* proxyProvider = dContext->priv().proxyProvider();
// We test both kRW in addition to kRead mostly to ensure that the calls are structured such
// that they'd succeed if the texture wasn't kRead. We want to be sure we're failing with
// kRead for the right reason.
for (auto ioType : {kRead_GrIOType, kRW_GrIOType}) {
- auto backendTex = context->createBackendTexture(&srcPixmap, 1,
- GrRenderable::kYes, GrProtected::kNo);
+ auto backendTex = dContext->createBackendTexture(&srcPixmap, 1,
+ GrRenderable::kYes, GrProtected::kNo);
auto proxy = proxyProvider->wrapBackendTexture(
backendTex, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, ioType);
- GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(proxy->backendFormat(),
- GrColorType::kRGBA_8888);
+ GrSwizzle swizzle = dContext->priv().caps()->getReadSwizzle(proxy->backendFormat(),
+ GrColorType::kRGBA_8888);
GrSurfaceProxyView view(proxy, kTopLeft_GrSurfaceOrigin, swizzle);
- auto surfContext = GrSurfaceContext::Make(context, std::move(view), GrColorType::kRGBA_8888,
+ auto surfContext = GrSurfaceContext::Make(dContext, std::move(view), GrColorType::kRGBA_8888,
kPremul_SkAlphaType, nullptr);
// Read pixels should work with a read-only texture.
{
SkAutoPixmapStorage read;
read.alloc(srcPixmap.info());
- auto readResult = surfContext->readPixels(srcPixmap.info(), read.writable_addr(),
- 0, { 0, 0 });
+ auto readResult = surfContext->readPixels(dContext, srcPixmap.info(),
+ read.writable_addr(), 0, { 0, 0 });
REPORTER_ASSERT(reporter, readResult);
if (readResult) {
comparePixels(srcPixmap, read, reporter);
@@ -383,11 +384,12 @@
SkAutoPixmapStorage write;
write.alloc(srcPixmap.info());
fillPixels(&write, [&srcPixmap](int x, int y) { return ~*srcPixmap.addr32(); });
- auto writeResult = surfContext->writePixels(srcPixmap.info(), write.addr(), 0, {0, 0});
+ auto writeResult = surfContext->writePixels(dContext, srcPixmap.info(), write.addr(),
+ 0, {0, 0});
REPORTER_ASSERT(reporter, writeResult == (ioType == kRW_GrIOType));
// Try the low level write.
- context->flushAndSubmit();
- auto gpuWriteResult = context->priv().getGpu()->writePixels(
+ dContext->flushAndSubmit();
+ auto gpuWriteResult = dContext->priv().getGpu()->writePixels(
proxy->peekTexture(), 0, 0, kSize, kSize, GrColorType::kRGBA_8888,
GrColorType::kRGBA_8888, write.addr32(),
kSize * GrColorTypeBytesPerPixel(GrColorType::kRGBA_8888));
@@ -397,7 +399,7 @@
copySrcBitmap.installPixels(write);
copySrcBitmap.setImmutable();
- GrBitmapTextureMaker maker(context, copySrcBitmap,
+ GrBitmapTextureMaker maker(dContext, copySrcBitmap,
GrImageTexGenPolicy::kNew_Uncached_Budgeted);
auto copySrc = maker.view(GrMipmapped::kNo);
@@ -405,28 +407,28 @@
auto copyResult = surfContext->testCopy(copySrc.proxy());
REPORTER_ASSERT(reporter, copyResult == (ioType == kRW_GrIOType));
// Try the low level copy.
- context->flushAndSubmit();
- auto gpuCopyResult = context->priv().getGpu()->copySurface(
+ dContext->flushAndSubmit();
+ auto gpuCopyResult = dContext->priv().getGpu()->copySurface(
proxy->peekSurface(), copySrc.proxy()->peekSurface(), SkIRect::MakeWH(kSize, kSize),
{0, 0});
REPORTER_ASSERT(reporter, gpuCopyResult == (ioType == kRW_GrIOType));
// Mip regen should not work with a read only texture.
- if (context->priv().caps()->mipmapSupport()) {
- DeleteBackendTexture(context, backendTex);
- backendTex = context->createBackendTexture(
+ if (dContext->priv().caps()->mipmapSupport()) {
+ DeleteBackendTexture(dContext, backendTex);
+ backendTex = dContext->createBackendTexture(
kSize, kSize, kRGBA_8888_SkColorType,
SkColors::kTransparent, GrMipmapped::kYes, GrRenderable::kYes,
GrProtected::kNo);
proxy = proxyProvider->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership,
GrWrapCacheable::kNo, ioType);
- context->flushAndSubmit();
+ dContext->flushAndSubmit();
proxy->peekTexture()->markMipmapsDirty(); // avoids assert in GrGpu.
auto regenResult =
- context->priv().getGpu()->regenerateMipMapLevels(proxy->peekTexture());
+ dContext->priv().getGpu()->regenerateMipMapLevels(proxy->peekTexture());
REPORTER_ASSERT(reporter, regenResult == (ioType == kRW_GrIOType));
}
- DeleteBackendTexture(context, backendTex);
+ DeleteBackendTexture(dContext, backendTex);
}
}