Reland "Reland "Have a GrBackendFormat be stored on gpu proxies.""
This is a reland of 2f9a5ea639925f38785f4d3a0af237822007cfd6
Original change's description:
> Reland "Have a GrBackendFormat be stored on gpu proxies."
>
> This reverts commit 919c9e77c3492af766ff5982acda76ee49da3168.
>
> Reason for revert: Flutter change has landed and fixed memory issue.
>
> Original change's description:
> > Revert "Have a GrBackendFormat be stored on gpu proxies."
> >
> > This reverts commit 51b1c12bbc2fa3f8d4faa29ad19c6f3cb34837ce.
> >
> > Reason for revert: reverting till flutter gets to 1.1 to fix build issues.
> >
> > Original change's description:
> > > Have a GrBackendFormat be stored on gpu proxies.
> > >
> > > Bug: skia:
> > > Change-Id: Iaf1fb24ab29a61d44e5fa59a5e0867ed02dcda90
> > > Reviewed-on: https://skia-review.googlesource.com/c/168021
> > > Reviewed-by: Brian Osman <brianosman@google.com>
> > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> >
> > TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com
> >
> > Change-Id: I574fdc084ef5994596c51fb0d60423b5dc01b885
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: chromium:903701 chromium:903756
> > Reviewed-on: https://skia-review.googlesource.com/c/169835
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com
>
> Change-Id: Ifd9b6b8e194af9fb9258fa626644e76e6ecf090d
> Bug: chromium:903701 chromium:903756
> Reviewed-on: https://skia-review.googlesource.com/c/170104
> Commit-Queue: Greg Daniel <egdaniel@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
Bug: chromium:903701 chromium:903756
Change-Id: Id1360067d8e928b0a4e1848dae8bc1e7f1994403
Reviewed-on: https://skia-review.googlesource.com/c/171660
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp
index d9271fc..c4809f5 100644
--- a/tests/ClearTest.cpp
+++ b/tests/ClearTest.cpp
@@ -56,8 +56,10 @@
}
sk_sp<GrRenderTargetContext> newRTC(GrContext* context, int w, int h) {
+ const GrBackendFormat format =
+ context->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
return context->contextPriv().makeDeferredRenderTargetContext(
- SkBackingFit::kExact, w, h,
+ format, SkBackingFit::kExact, w, h,
kRGBA_8888_GrPixelConfig, nullptr);
}
diff --git a/tests/DefaultPathRendererTest.cpp b/tests/DefaultPathRendererTest.cpp
index f78c283..688ecee 100644
--- a/tests/DefaultPathRendererTest.cpp
+++ b/tests/DefaultPathRendererTest.cpp
@@ -79,8 +79,11 @@
GrStyle style(SkStrokeRec::kFill_InitStyle);
+ GrBackendFormat format =
+ ctx->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
{
auto rtc = ctx->contextPriv().makeDeferredRenderTargetContext(
+ format,
SkBackingFit::kApprox,
kBigSize/2+1, kBigSize/2+1,
kRGBA_8888_GrPixelConfig, nullptr);
@@ -101,8 +104,9 @@
{
auto rtc = ctx->contextPriv().makeDeferredRenderTargetContext(
- SkBackingFit::kExact, kBigSize, kBigSize,
- kRGBA_8888_GrPixelConfig, nullptr);
+ format, SkBackingFit::kExact, kBigSize,
+ kBigSize, kRGBA_8888_GrPixelConfig,
+ nullptr);
rtc->clear(nullptr, { 0, 0, 0, 1 }, GrRenderTargetContext::CanClearFullscreen::kYes);
diff --git a/tests/DetermineDomainModeTest.cpp b/tests/DetermineDomainModeTest.cpp
index c40a957..907e535 100644
--- a/tests/DetermineDomainModeTest.cpp
+++ b/tests/DetermineDomainModeTest.cpp
@@ -118,10 +118,11 @@
};
-static sk_sp<GrTextureProxy> create_proxy(GrProxyProvider* proxyProvider,
+static sk_sp<GrTextureProxy> create_proxy(GrContext* ctx,
bool isPowerOfTwo,
bool isExact,
RectInfo* rect) {
+ GrProxyProvider* proxyProvider = ctx->contextPriv().proxyProvider();
int size = isPowerOfTwo ? 128 : 100;
SkBackingFit fit = isExact ? SkBackingFit::kExact : SkBackingFit::kApprox;
@@ -130,6 +131,9 @@
desc.fHeight = size;
desc.fConfig = kRGBA_8888_GrPixelConfig;
+ GrBackendFormat format =
+ ctx->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+
static const char* name = "proxy";
// Proxies are always hard on the left and top but can be bad on the right and bottom
@@ -140,7 +144,8 @@
(isPowerOfTwo || isExact) ? RectInfo::kHard : RectInfo::kBad,
name);
- return proxyProvider->createProxy(desc, kTopLeft_GrSurfaceOrigin, fit, SkBudgeted::kYes);
+ return proxyProvider->createProxy(format, desc, kTopLeft_GrSurfaceOrigin, fit,
+ SkBudgeted::kYes);
}
static RectInfo::EdgeType compute_inset_edgetype(RectInfo::EdgeType previous,
@@ -313,7 +318,7 @@
insetAmount, halfFilterWidth, 0, name);
}
-static void proxy_test(skiatest::Reporter* reporter, GrProxyProvider* proxyProvider) {
+static void proxy_test(skiatest::Reporter* reporter, GrContext* context) {
GrTextureProducer_TestAccess::DomainMode actualMode, expectedMode;
SkRect actualDomainRect;
@@ -332,7 +337,7 @@
for (auto isExact : { true, false }) {
RectInfo outermost;
- sk_sp<GrTextureProxy> proxy = create_proxy(proxyProvider, isPowerOfTwoSized,
+ sk_sp<GrTextureProxy> proxy = create_proxy(context, isPowerOfTwoSized,
isExact, &outermost);
SkASSERT(outermost.isHardOrBadAllAround());
@@ -386,5 +391,5 @@
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DetermineDomainModeTest, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
- proxy_test(reporter, context->contextPriv().proxyProvider());
+ proxy_test(reporter, context);
}
diff --git a/tests/DrawOpAtlasTest.cpp b/tests/DrawOpAtlasTest.cpp
index 251403d..10bc51d 100644
--- a/tests/DrawOpAtlasTest.cpp
+++ b/tests/DrawOpAtlasTest.cpp
@@ -135,8 +135,12 @@
GrOnFlushResourceProvider onFlushResourceProvider(drawingManager);
TestingUploadTarget uploadTarget;
+ GrBackendFormat format =
+ context->contextPriv().caps()->getBackendFormatFromColorType(kAlpha_8_SkColorType);
+
std::unique_ptr<GrDrawOpAtlas> atlas = GrDrawOpAtlas::Make(
proxyProvider,
+ format,
kAlpha_8_GrPixelConfig,
kAtlasSize, kAtlasSize,
kNumPlots, kNumPlots,
@@ -184,7 +188,11 @@
auto textContext = drawingManager->getTextContext();
auto opMemoryPool = context->contextPriv().opMemoryPool();
- auto rtc = context->contextPriv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
+ GrBackendFormat format =
+ context->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+
+ auto rtc = context->contextPriv().makeDeferredRenderTargetContext(format,
+ SkBackingFit::kApprox,
32, 32,
kRGBA_8888_GrPixelConfig,
nullptr);
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 654dce0..c2dd572 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -154,8 +154,11 @@
// Above could be 0 if msaa isn't supported.
sampleCnt = SkTMax(1, sampleCnt);
+ const GrBackendFormat format = caps->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+
sk_sp<GrRenderTargetContext> renderTargetContext(
- context->contextPriv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
+ context->contextPriv().makeDeferredRenderTargetContext(format,
+ SkBackingFit::kExact,
kRenderTargetWidth,
kRenderTargetHeight,
kRGBA_8888_GrPixelConfig,
@@ -265,7 +268,9 @@
dummyDesc.fWidth = 34;
dummyDesc.fHeight = 18;
dummyDesc.fConfig = kRGBA_8888_GrPixelConfig;
- proxies[0] = proxyProvider->createProxy(dummyDesc, kBottomLeft_GrSurfaceOrigin,
+ const GrBackendFormat format =
+ context->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+ proxies[0] = proxyProvider->createProxy(format, dummyDesc, kBottomLeft_GrSurfaceOrigin,
GrMipMapped::kYes, SkBackingFit::kExact,
SkBudgeted::kNo, GrInternalSurfaceFlags::kNone);
}
@@ -275,7 +280,9 @@
dummyDesc.fWidth = 16;
dummyDesc.fHeight = 22;
dummyDesc.fConfig = kAlpha_8_GrPixelConfig;
- proxies[1] = proxyProvider->createProxy(dummyDesc, kTopLeft_GrSurfaceOrigin,
+ const GrBackendFormat format =
+ context->contextPriv().caps()->getBackendFormatFromColorType(kAlpha_8_SkColorType);
+ proxies[1] = proxyProvider->createProxy(format, dummyDesc, kTopLeft_GrSurfaceOrigin,
GrMipMapped::kYes, SkBackingFit::kExact,
SkBudgeted::kNo, GrInternalSurfaceFlags::kNone);
}
@@ -308,9 +315,12 @@
// Flush everything, test passes if flush is successful(ie, no asserts are hit, no crashes)
drawingManager->flush(nullptr);
+ const GrBackendFormat format =
+ context->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
// Validate that GrFPs work correctly without an input.
sk_sp<GrRenderTargetContext> renderTargetContext(
- context->contextPriv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
+ context->contextPriv().makeDeferredRenderTargetContext(format,
+ SkBackingFit::kExact,
kRenderTargetWidth,
kRenderTargetHeight,
kRGBA_8888_GrPixelConfig,
diff --git a/tests/GrCCPRTest.cpp b/tests/GrCCPRTest.cpp
index 946fde6..a400985 100644
--- a/tests/GrCCPRTest.cpp
+++ b/tests/GrCCPRTest.cpp
@@ -60,9 +60,9 @@
: fCtx(ctx)
, fCCPR(fCtx->contextPriv().drawingManager()->getCoverageCountingPathRenderer())
, fRTC(fCtx->contextPriv().makeDeferredRenderTargetContext(
- SkBackingFit::kExact, kCanvasSize,
- kCanvasSize, kRGBA_8888_GrPixelConfig,
- nullptr))
+ ctx->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType),
+ SkBackingFit::kExact, kCanvasSize, kCanvasSize, kRGBA_8888_GrPixelConfig,
+ nullptr))
, fDoStroke(doStroke) {
if (!fCCPR) {
ERRORF(reporter, "ccpr not enabled in GrContext for ccpr tests");
diff --git a/tests/GrMeshTest.cpp b/tests/GrMeshTest.cpp
index fdaa259..6762ddc 100644
--- a/tests/GrMeshTest.cpp
+++ b/tests/GrMeshTest.cpp
@@ -83,9 +83,12 @@
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrMeshTest, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
+ const GrBackendFormat format =
+ context->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+
sk_sp<GrRenderTargetContext> rtc(context->contextPriv().makeDeferredRenderTargetContext(
- SkBackingFit::kExact, kImageWidth, kImageHeight,
- kRGBA_8888_GrPixelConfig, nullptr));
+ format, SkBackingFit::kExact, kImageWidth,
+ kImageHeight, kRGBA_8888_GrPixelConfig, nullptr));
if (!rtc) {
ERRORF(reporter, "could not create render target context.");
return;
diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp
index 85d7091..bd57141 100644
--- a/tests/GrPipelineDynamicStateTest.cpp
+++ b/tests/GrPipelineDynamicStateTest.cpp
@@ -161,9 +161,12 @@
GrContext* context = ctxInfo.grContext();
GrResourceProvider* rp = context->contextPriv().resourceProvider();
+ const GrBackendFormat format =
+ context->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+
sk_sp<GrRenderTargetContext> rtc(context->contextPriv().makeDeferredRenderTargetContext(
- SkBackingFit::kExact, kScreenSize, kScreenSize,
- kRGBA_8888_GrPixelConfig, nullptr));
+ format, SkBackingFit::kExact, kScreenSize,
+ kScreenSize, kRGBA_8888_GrPixelConfig, nullptr));
if (!rtc) {
ERRORF(reporter, "could not create render target context.");
return;
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index bdec795..d3cc2f4 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -112,8 +112,13 @@
REPORTER_ASSERT(reporter, SkToBool(tex) == ict,
"config:%d, tex:%d, isConfigTexturable:%d", config, SkToBool(tex), ict);
+ GrSRGBEncoded srgbEncoded = GrSRGBEncoded::kNo;
+ GrColorType colorType = GrPixelConfigToColorTypeAndEncoding(config, &srgbEncoded);
+ const GrBackendFormat format =
+ caps->getBackendFormatFromGrColorType(colorType, srgbEncoded);
+
sk_sp<GrTextureProxy> proxy =
- proxyProvider->createMipMapProxy(desc, origin, SkBudgeted::kNo);
+ proxyProvider->createMipMapProxy(format, desc, origin, SkBudgeted::kNo);
REPORTER_ASSERT(reporter, SkToBool(proxy.get()) ==
(caps->isConfigTexturable(desc.fConfig) &&
caps->mipMapSupport()));
@@ -146,16 +151,17 @@
std::unique_ptr<uint32_t[]> data(new uint32_t[kSize * kSize]);
GrContext* context = context_info.grContext();
+ const GrCaps* caps = context->contextPriv().caps();
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
for (int c = 0; c <= kLast_GrPixelConfig; ++c) {
desc.fConfig = static_cast<GrPixelConfig>(c);
- if (!context->contextPriv().caps()->isConfigTexturable(desc.fConfig)) {
+ if (!caps->isConfigTexturable(desc.fConfig)) {
continue;
}
desc.fFlags = kPerformInitialClear_GrSurfaceFlag;
for (bool rt : {false, true}) {
- if (rt && !context->contextPriv().caps()->isConfigRenderable(desc.fConfig)) {
+ if (rt && !caps->isConfigRenderable(desc.fConfig)) {
continue;
}
desc.fFlags |= rt ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags;
@@ -193,10 +199,16 @@
}
context->contextPriv().purgeAllUnlockedResources_ForTesting();
+ GrSRGBEncoded srgbEncoded = GrSRGBEncoded::kNo;
+ GrColorType colorType = GrPixelConfigToColorTypeAndEncoding(desc.fConfig,
+ &srgbEncoded);
+ const GrBackendFormat format =
+ caps->getBackendFormatFromGrColorType(colorType, srgbEncoded);
+
// Try creating the texture as a deferred proxy.
for (int i = 0; i < 2; ++i) {
auto surfCtx = context->contextPriv().makeDeferredSurfaceContext(
- desc, origin, GrMipMapped::kNo, fit, SkBudgeted::kYes);
+ format, desc, origin, GrMipMapped::kNo, fit, SkBudgeted::kYes);
if (!surfCtx) {
continue;
}
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index 16653e2..82cf29d 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -377,7 +377,9 @@
static sk_sp<SkSpecialSurface> create_empty_special_surface(GrContext* context, int widthHeight) {
if (context) {
- return SkSpecialSurface::MakeRenderTarget(context,
+ GrBackendFormat format =
+ context->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+ return SkSpecialSurface::MakeRenderTarget(context, format,
widthHeight, widthHeight,
kRGBA_8888_GrPixelConfig, nullptr);
} else {
diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp
index 2d48aa7..8b106f0 100644
--- a/tests/LazyProxyTest.cpp
+++ b/tests/LazyProxyTest.cpp
@@ -61,7 +61,7 @@
bool nullTexture) {
GrOpMemoryPool* pool = context->contextPriv().opMemoryPool();
- return pool->allocate<Op>(proxyProvider, test, nullTexture);
+ return pool->allocate<Op>(context, proxyProvider, test, nullTexture);
}
void visitProxies(const VisitProxyFunc& func, VisitorType) const override {
@@ -76,8 +76,10 @@
private:
friend class GrOpMemoryPool; // for ctor
- Op(GrProxyProvider* proxyProvider, LazyProxyTest* test, bool nullTexture)
+ Op(GrContext* ctx, GrProxyProvider* proxyProvider, LazyProxyTest* test, bool nullTexture)
: GrDrawOp(ClassID()), fTest(test) {
+ const GrBackendFormat format =
+ ctx->contextPriv().caps()->getBackendFormatFromColorType(kRGB_565_SkColorType);
fProxy = GrProxyProvider::MakeFullyLazyProxy(
[this, nullTexture](GrResourceProvider* rp) {
if (!rp) {
@@ -97,7 +99,7 @@
return texture;
}
},
- GrProxyProvider::Renderable::kNo, kTopLeft_GrSurfaceOrigin,
+ format, GrProxyProvider::Renderable::kNo, kTopLeft_GrSurfaceOrigin,
kRGB_565_GrPixelConfig, *proxyProvider->caps());
this->setBounds(SkRectPriv::MakeLargest(), GrOp::HasAABloat::kNo,
@@ -117,11 +119,16 @@
class ClipFP : public GrFragmentProcessor {
public:
- ClipFP(GrProxyProvider* proxyProvider, LazyProxyTest* test, GrTextureProxy* atlas)
+ ClipFP(GrContext* ctx, GrProxyProvider* proxyProvider, LazyProxyTest* test,
+ GrTextureProxy* atlas)
: GrFragmentProcessor(kTestFP_ClassID, kNone_OptimizationFlags)
+ , fContext(ctx)
, fProxyProvider(proxyProvider)
, fTest(test)
, fAtlas(atlas) {
+ const GrBackendFormat format =
+ ctx->contextPriv().caps()->getBackendFormatFromGrColorType(GrColorType::kAlpha_F16,
+ GrSRGBEncoded::kNo);
fLazyProxy = GrProxyProvider::MakeFullyLazyProxy(
[this](GrResourceProvider* rp) {
if (!rp) {
@@ -132,6 +139,7 @@
fAtlas->instantiate(rp);
return sk_ref_sp(fAtlas->peekTexture());
},
+ format,
GrProxyProvider::Renderable::kYes,
kBottomLeft_GrSurfaceOrigin,
kAlpha_half_GrPixelConfig, *proxyProvider->caps());
@@ -143,13 +151,14 @@
private:
const char* name() const override { return "LazyProxyTest::ClipFP"; }
std::unique_ptr<GrFragmentProcessor> clone() const override {
- return skstd::make_unique<ClipFP>(fProxyProvider, fTest, fAtlas);
+ return skstd::make_unique<ClipFP>(fContext, fProxyProvider, fTest, fAtlas);
}
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { return nullptr; }
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
bool onIsEqual(const GrFragmentProcessor&) const override { return false; }
const TextureSampler& onTextureSampler(int) const override { return fAccess; }
+ GrContext* const fContext;
GrProxyProvider* const fProxyProvider;
LazyProxyTest* const fTest;
GrTextureProxy* const fAtlas;
@@ -168,7 +177,7 @@
bool apply(GrContext* context, GrRenderTargetContext*, bool, bool, GrAppliedClip* out,
SkRect* bounds) const override {
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
- out->addCoverageFP(skstd::make_unique<ClipFP>(proxyProvider, fTest, fAtlas));
+ out->addCoverageFP(skstd::make_unique<ClipFP>(context, proxyProvider, fTest, fAtlas));
return true;
}
bool quickContains(const SkRect&) const final { return false; }
@@ -200,12 +209,17 @@
for (bool nullTexture : {false, true}) {
LazyProxyTest test(reporter);
ctx->contextPriv().addOnFlushCallbackObject(&test);
+ GrBackendFormat format =
+ ctx->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
sk_sp<GrRenderTargetContext> rtc = ctx->contextPriv().makeDeferredRenderTargetContext(
- SkBackingFit::kExact, 100, 100,
+ format, SkBackingFit::kExact, 100, 100,
kRGBA_8888_GrPixelConfig, nullptr);
REPORTER_ASSERT(reporter, rtc);
+ format =
+ ctx->contextPriv().caps()->getBackendFormatFromGrColorType(GrColorType::kAlpha_F16,
+ GrSRGBEncoded::kNo);
sk_sp<GrRenderTargetContext> mockAtlas = ctx->contextPriv().makeDeferredRenderTargetContext(
- SkBackingFit::kExact, 10, 10,
+ format, SkBackingFit::kExact, 10, 10,
kAlpha_half_GrPixelConfig, nullptr);
REPORTER_ASSERT(reporter, mockAtlas);
rtc->priv().testingOnly_addDrawOp(LazyProxyTest::Clip(&test, mockAtlas->asTextureProxy()),
@@ -226,6 +240,9 @@
desc.fHeight = kSize;
desc.fConfig = kRGBA_8888_GrPixelConfig;
+ GrBackendFormat format =
+ ctx->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+
using LazyInstantiationType = GrSurfaceProxy::LazyInstantiationType;
for (bool doInstantiate : {true, false}) {
for (auto lazyType : {LazyInstantiationType::kSingleUse,
@@ -242,7 +259,7 @@
*testCountPtr = 1;
return sk_sp<GrTexture>();
},
- desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, GrTextureType::k2D,
+ format, desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo,
GrInternalSurfaceFlags::kNone, SkBackingFit::kExact, SkBudgeted::kNo, lazyType);
REPORTER_ASSERT(reporter, proxy.get());
@@ -277,7 +294,7 @@
bool shouldFailInstantiation) {
GrOpMemoryPool* pool = context->contextPriv().opMemoryPool();
- return pool->allocate<LazyFailedInstantiationTestOp>(proxyProvider,
+ return pool->allocate<LazyFailedInstantiationTestOp>(context, proxyProvider,
testExecuteValue,
shouldFailInstantiation);
}
@@ -289,14 +306,16 @@
private:
friend class GrOpMemoryPool; // for ctor
- LazyFailedInstantiationTestOp(GrProxyProvider* proxyProvider, int* testExecuteValue,
- bool shouldFailInstantiation)
+ LazyFailedInstantiationTestOp(GrContext* ctx, GrProxyProvider* proxyProvider,
+ int* testExecuteValue, bool shouldFailInstantiation)
: INHERITED(ClassID())
, fTestExecuteValue(testExecuteValue) {
GrSurfaceDesc desc;
desc.fWidth = kSize;
desc.fHeight = kSize;
desc.fConfig = kRGBA_8888_GrPixelConfig;
+ GrBackendFormat format =
+ ctx->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
fLazyProxy = proxyProvider->createLazyProxy(
[testExecuteValue, shouldFailInstantiation, desc](GrResourceProvider* rp) {
@@ -309,7 +328,7 @@
}
return rp->createTexture(desc, SkBudgeted::kNo);
},
- desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, GrTextureType::k2D,
+ format, desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo,
SkBackingFit::kExact, SkBudgeted::kNo);
SkASSERT(fLazyProxy.get());
@@ -341,9 +360,11 @@
sk_sp<GrContext> ctx = GrContext::MakeMock(&mockOptions, GrContextOptions());
GrResourceProvider* resourceProvider = ctx->contextPriv().resourceProvider();
GrProxyProvider* proxyProvider = ctx->contextPriv().proxyProvider();
+ GrBackendFormat format =
+ ctx->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
for (bool failInstantiation : {false, true}) {
sk_sp<GrRenderTargetContext> rtc = ctx->contextPriv().makeDeferredRenderTargetContext(
- SkBackingFit::kExact, 100, 100,
+ format, SkBackingFit::kExact, 100, 100,
kRGBA_8888_GrPixelConfig, nullptr);
REPORTER_ASSERT(reporter, rtc);
@@ -417,10 +438,13 @@
GrProxyProvider* proxyProvider = ctx->contextPriv().proxyProvider();
GrGpu* gpu = ctx->contextPriv().getGpu();
+ GrBackendFormat format =
+ ctx->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+
using LazyType = GrSurfaceProxy::LazyInstantiationType;
for (auto lazyType : {LazyType::kSingleUse, LazyType::kMultipleUse, LazyType::kUninstantiate}) {
sk_sp<GrRenderTargetContext> rtc = ctx->contextPriv().makeDeferredRenderTargetContext(
- SkBackingFit::kExact, 100, 100,
+ format, SkBackingFit::kExact, 100, 100,
kRGBA_8888_GrPixelConfig, nullptr);
REPORTER_ASSERT(reporter, rtc);
@@ -453,7 +477,7 @@
texture->setRelease(UninstantiateReleaseProc, releasePtr);
return texture;
},
- desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, GrTextureType::k2D,
+ format, desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo,
GrInternalSurfaceFlags::kNone, SkBackingFit::kExact, SkBudgeted::kNo, lazyType);
REPORTER_ASSERT(reporter, lazyProxy.get());
diff --git a/tests/OnFlushCallbackTest.cpp b/tests/OnFlushCallbackTest.cpp
index ac9805e..805be6a 100644
--- a/tests/OnFlushCallbackTest.cpp
+++ b/tests/OnFlushCallbackTest.cpp
@@ -292,11 +292,13 @@
// Get the fully lazy proxy that is backing the atlas. Its actual width isn't
// known until flush time.
- sk_sp<GrTextureProxy> getAtlasProxy(GrProxyProvider* proxyProvider) {
+ sk_sp<GrTextureProxy> getAtlasProxy(GrProxyProvider* proxyProvider, const GrCaps* caps) {
if (fAtlasProxy) {
return fAtlasProxy;
}
+ const GrBackendFormat format = caps->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+
fAtlasProxy = GrProxyProvider::MakeFullyLazyProxy(
[](GrResourceProvider* resourceProvider) {
if (!resourceProvider) {
@@ -314,6 +316,7 @@
return resourceProvider->createTexture(desc, SkBudgeted::kYes,
GrResourceProvider::Flags::kNoPendingIO);
},
+ format,
GrProxyProvider::Renderable::kYes,
kBottomLeft_GrSurfaceOrigin,
kRGBA_8888_GrPixelConfig,
@@ -426,7 +429,11 @@
// This creates an off-screen rendertarget whose ops which eventually pull from the atlas.
static sk_sp<GrTextureProxy> make_upstream_image(GrContext* context, AtlasObject* object, int start,
sk_sp<GrTextureProxy> atlasProxy) {
+ const GrBackendFormat format =
+ context->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+
sk_sp<GrRenderTargetContext> rtc(context->contextPriv().makeDeferredRenderTargetContext(
+ format,
SkBackingFit::kApprox,
3*kDrawnTileSize,
kDrawnTileSize,
@@ -537,13 +544,18 @@
sk_sp<GrTextureProxy> proxies[kNumProxies];
for (int i = 0; i < kNumProxies; ++i) {
proxies[i] = make_upstream_image(context, &object, i*3,
- object.getAtlasProxy(proxyProvider));
+ object.getAtlasProxy(proxyProvider,
+ context->contextPriv().caps()));
}
static const int kFinalWidth = 6*kDrawnTileSize;
static const int kFinalHeight = kDrawnTileSize;
+ const GrBackendFormat format =
+ context->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+
sk_sp<GrRenderTargetContext> rtc(context->contextPriv().makeDeferredRenderTargetContext(
+ format,
SkBackingFit::kApprox,
kFinalWidth,
kFinalHeight,
diff --git a/tests/OpChainTest.cpp b/tests/OpChainTest.cpp
index eefbaea..dde0c7a 100644
--- a/tests/OpChainTest.cpp
+++ b/tests/OpChainTest.cpp
@@ -168,9 +168,12 @@
desc.fHeight = 1;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
+ const GrBackendFormat format =
+ context->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+
auto proxy = context->contextPriv().proxyProvider()->createProxy(
- desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, SkBackingFit::kExact, SkBudgeted::kNo,
- GrInternalSurfaceFlags::kNone);
+ format, desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, SkBackingFit::kExact,
+ SkBudgeted::kNo, GrInternalSurfaceFlags::kNone);
SkASSERT(proxy);
proxy->instantiate(context->contextPriv().resourceProvider());
int result[result_width()];
diff --git a/tests/PathRendererCacheTests.cpp b/tests/PathRendererCacheTests.cpp
index 32e5b7df..ae81b69 100644
--- a/tests/PathRendererCacheTests.cpp
+++ b/tests/PathRendererCacheTests.cpp
@@ -79,9 +79,12 @@
ctx->setResourceCacheLimits(100, 8000000);
GrResourceCache* cache = ctx->contextPriv().getResourceCache();
+ const GrBackendFormat format =
+ ctx->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+
sk_sp<GrRenderTargetContext> rtc(ctx->contextPriv().makeDeferredRenderTargetContext(
- SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig, nullptr, 1, GrMipMapped::kNo,
- kTopLeft_GrSurfaceOrigin));
+ format, SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig, nullptr, 1,
+ GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin));
if (!rtc) {
return;
}
diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp
index dea8d5c..268927e 100644
--- a/tests/PrimitiveProcessorTest.cpp
+++ b/tests/PrimitiveProcessorTest.cpp
@@ -121,8 +121,11 @@
GrGpu* gpu = context->contextPriv().getGpu();
#endif
+ const GrBackendFormat format =
+ context->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+
sk_sp<GrRenderTargetContext> renderTargetContext(
- context->contextPriv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
+ context->contextPriv().makeDeferredRenderTargetContext(format, SkBackingFit::kApprox,
1, 1, kRGBA_8888_GrPixelConfig,
nullptr));
if (!renderTargetContext) {
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index e76099c..e4aab42 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -162,21 +162,28 @@
desc.fHeight = 10;
desc.fConfig = kRGBA_8888_GrPixelConfig;
+ const GrBackendFormat format =
+ context->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+
for (bool makeClone : {false, true}) {
for (int parentCnt = 0; parentCnt < 2; parentCnt++) {
sk_sp<GrRenderTargetContext> renderTargetContext(
context->contextPriv().makeDeferredRenderTargetContext(
- SkBackingFit::kApprox, 1, 1,
+ format, SkBackingFit::kApprox, 1, 1,
kRGBA_8888_GrPixelConfig, nullptr));
{
sk_sp<GrTextureProxy> proxy1 = proxyProvider->createProxy(
- desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kExact, SkBudgeted::kYes);
+ format, desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kExact,
+ SkBudgeted::kYes);
sk_sp<GrTextureProxy> proxy2 = proxyProvider->createProxy(
- desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kExact, SkBudgeted::kYes);
+ format, desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kExact,
+ SkBudgeted::kYes);
sk_sp<GrTextureProxy> proxy3 = proxyProvider->createProxy(
- desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kExact, SkBudgeted::kYes);
+ format, desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kExact,
+ SkBudgeted::kYes);
sk_sp<GrTextureProxy> proxy4 = proxyProvider->createProxy(
- desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kExact, SkBudgeted::kYes);
+ format, desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kExact,
+ SkBudgeted::kYes);
{
SkTArray<sk_sp<GrTextureProxy>> proxies;
SkTArray<sk_sp<GrBuffer>> buffers;
@@ -429,10 +436,14 @@
// use --processorSeed <seed> (without --randomProcessorTest) to reproduce.
SkRandom random(seed);
+ const GrBackendFormat format =
+ context->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+
// Make the destination context for the test.
static constexpr int kRenderSize = 256;
sk_sp<GrRenderTargetContext> rtc = context->contextPriv().makeDeferredRenderTargetContext(
- SkBackingFit::kExact, kRenderSize, kRenderSize, kRGBA_8888_GrPixelConfig, nullptr);
+ format, SkBackingFit::kExact, kRenderSize, kRenderSize, kRGBA_8888_GrPixelConfig,
+ nullptr);
sk_sp<GrTextureProxy> proxies[2];
if (!init_test_textures(proxyProvider, &random, proxies)) {
@@ -662,10 +673,14 @@
SkRandom random;
+ const GrBackendFormat format =
+ context->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+
// Make the destination context for the test.
static constexpr int kRenderSize = 1024;
sk_sp<GrRenderTargetContext> rtc = context->contextPriv().makeDeferredRenderTargetContext(
- SkBackingFit::kExact, kRenderSize, kRenderSize, kRGBA_8888_GrPixelConfig, nullptr);
+ format, SkBackingFit::kExact, kRenderSize, kRenderSize, kRGBA_8888_GrPixelConfig,
+ nullptr);
sk_sp<GrTextureProxy> proxies[2];
if (!init_test_textures(proxyProvider, &random, proxies)) {
diff --git a/tests/ProxyConversionTest.cpp b/tests/ProxyConversionTest.cpp
index e316da7..8913f9a 100644
--- a/tests/ProxyConversionTest.cpp
+++ b/tests/ProxyConversionTest.cpp
@@ -137,9 +137,12 @@
desc.fHeight = 64;
desc.fConfig = kRGBA_8888_GrPixelConfig;
+ const GrBackendFormat format =
+ ctxInfo.grContext()->contextPriv().caps()->getBackendFormatFromColorType(
+ kRGBA_8888_SkColorType);
{
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
- desc, kBottomLeft_GrSurfaceOrigin, SkBackingFit::kApprox, SkBudgeted::kYes);
+ format, desc, kBottomLeft_GrSurfaceOrigin, SkBackingFit::kApprox, SkBudgeted::kYes);
// Both RenderTarget and Texture
GrRenderTargetProxy* rtProxy = proxy->asRenderTargetProxy();
@@ -152,7 +155,7 @@
{
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
- desc, kBottomLeft_GrSurfaceOrigin, SkBackingFit::kApprox, SkBudgeted::kYes);
+ format, desc, kBottomLeft_GrSurfaceOrigin, SkBackingFit::kApprox, SkBudgeted::kYes);
// Both RenderTarget and Texture - but via GrTextureProxy
GrTextureProxy* tProxy = proxy->asTextureProxy();
@@ -167,7 +170,7 @@
desc.fFlags = kNone_GrSurfaceFlags; // force no-RT
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
- desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kApprox, SkBudgeted::kYes);
+ format, desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kApprox, SkBudgeted::kYes);
// Texture-only
GrTextureProxy* tProxy = proxy->asTextureProxy();
REPORTER_ASSERT(reporter, tProxy);
diff --git a/tests/ProxyRefTest.cpp b/tests/ProxyRefTest.cpp
index 288085f..5f3ce4f 100644
--- a/tests/ProxyRefTest.cpp
+++ b/tests/ProxyRefTest.cpp
@@ -61,18 +61,20 @@
SkASSERT(proxy->getPendingWriteCnt_TestOnly() == expectedNumWrites);
}
-static sk_sp<GrTextureProxy> make_deferred(GrProxyProvider* proxyProvider) {
+static sk_sp<GrTextureProxy> make_deferred(GrProxyProvider* proxyProvider, const GrCaps* caps) {
GrSurfaceDesc desc;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fWidth = kWidthHeight;
desc.fHeight = kWidthHeight;
desc.fConfig = kRGBA_8888_GrPixelConfig;
- return proxyProvider->createProxy(desc, kBottomLeft_GrSurfaceOrigin, SkBackingFit::kApprox,
- SkBudgeted::kYes, GrInternalSurfaceFlags::kNoPendingIO);
+ const GrBackendFormat format = caps->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+ return proxyProvider->createProxy(format, desc, kBottomLeft_GrSurfaceOrigin,
+ SkBackingFit::kApprox, SkBudgeted::kYes,
+ GrInternalSurfaceFlags::kNoPendingIO);
}
-static sk_sp<GrTextureProxy> make_wrapped(GrProxyProvider* proxyProvider) {
+static sk_sp<GrTextureProxy> make_wrapped(GrProxyProvider* proxyProvider, const GrCaps* caps) {
GrSurfaceDesc desc;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fWidth = kWidthHeight;
@@ -86,11 +88,12 @@
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider();
GrResourceProvider* resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider();
+ const GrCaps* caps = ctxInfo.grContext()->contextPriv().caps();
for (auto make : { make_deferred, make_wrapped }) {
// A single write
{
- sk_sp<GrTextureProxy> proxy((*make)(proxyProvider));
+ sk_sp<GrTextureProxy> proxy((*make)(proxyProvider, caps));
if (proxy.get()) {
GrPendingIOResource<GrSurfaceProxy, kWrite_GrIOType> fWrite(proxy.get());
@@ -110,7 +113,7 @@
// A single read
{
- sk_sp<GrTextureProxy> proxy((*make)(proxyProvider));
+ sk_sp<GrTextureProxy> proxy((*make)(proxyProvider, caps));
if (proxy.get()) {
GrPendingIOResource<GrSurfaceProxy, kRead_GrIOType> fRead(proxy.get());
@@ -130,7 +133,7 @@
// A single read/write pair
{
- sk_sp<GrTextureProxy> proxy((*make)(proxyProvider));
+ sk_sp<GrTextureProxy> proxy((*make)(proxyProvider, caps));
if (proxy.get()) {
GrPendingIOResource<GrSurfaceProxy, kRW_GrIOType> fRW(proxy.get());
@@ -150,7 +153,7 @@
// Multiple normal refs
{
- sk_sp<GrTextureProxy> proxy((*make)(proxyProvider));
+ sk_sp<GrTextureProxy> proxy((*make)(proxyProvider, caps));
if (proxy.get()) {
proxy->ref();
proxy->ref();
@@ -174,7 +177,7 @@
// Continue using (reffing) proxy after instantiation
{
- sk_sp<GrTextureProxy> proxy((*make)(proxyProvider));
+ sk_sp<GrTextureProxy> proxy((*make)(proxyProvider, caps));
if (proxy.get()) {
proxy->ref();
diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp
index 8988ed5..9a5a0d1 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -124,6 +124,12 @@
desc.fConfig = config;
desc.fSampleCnt = numSamples;
+ GrSRGBEncoded srgbEncoded;
+ GrColorType colorType =
+ GrPixelConfigToColorTypeAndEncoding(config, &srgbEncoded);
+ const GrBackendFormat format =
+ caps.getBackendFormatFromGrColorType(colorType, srgbEncoded);
+
{
sk_sp<GrTexture> tex;
if (SkBackingFit::kApprox == fit) {
@@ -134,7 +140,8 @@
}
sk_sp<GrTextureProxy> proxy =
- proxyProvider->createProxy(desc, origin, fit, budgeted);
+ proxyProvider->createProxy(format, desc, origin, fit,
+ budgeted);
REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy));
if (proxy) {
REPORTER_ASSERT(reporter, proxy->asRenderTargetProxy());
@@ -168,7 +175,8 @@
}
sk_sp<GrTextureProxy> proxy(
- proxyProvider->createProxy(desc, origin, fit, budgeted));
+ proxyProvider->createProxy(format, desc, origin, fit,
+ budgeted));
REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy));
if (proxy) {
// This forces the proxy to compute and cache its
@@ -346,8 +354,12 @@
desc.fConfig = kRGBA_8888_GrPixelConfig;
desc.fSampleCnt = 1;
+ const GrBackendFormat format =
+ ctxInfo.grContext()->contextPriv().caps()->getBackendFormatFromColorType(
+ kRGBA_8888_SkColorType);
+
sk_sp<GrTextureProxy> proxy = provider->createProxy(
- desc, kBottomLeft_GrSurfaceOrigin, fit, SkBudgeted::kNo);
+ format, desc, kBottomLeft_GrSurfaceOrigin, fit, SkBudgeted::kNo);
REPORTER_ASSERT(reporter, !proxy);
}
}
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index ac81e6d..21a9e19 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -23,7 +23,10 @@
// skbug.com/5932
static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrContext* context,
sk_sp<GrTextureProxy> rectProxy, uint32_t expectedPixelValues[]) {
+ GrBackendFormat format = rectProxy->backendFormat().makeTexture2D();
+ SkASSERT(format.isValid());
sk_sp<GrRenderTargetContext> rtContext(context->contextPriv().makeDeferredRenderTargetContext(
+ format,
SkBackingFit::kExact, rectProxy->width(),
rectProxy->height(), rectProxy->config(),
nullptr));
diff --git a/tests/ResourceAllocatorTest.cpp b/tests/ResourceAllocatorTest.cpp
index e839d04..e5ace1a 100644
--- a/tests/ResourceAllocatorTest.cpp
+++ b/tests/ResourceAllocatorTest.cpp
@@ -31,7 +31,8 @@
// TODO: do we care about mipmapping
};
-static GrSurfaceProxy* make_deferred(GrProxyProvider* proxyProvider, const ProxyParams& p) {
+static GrSurfaceProxy* make_deferred(GrProxyProvider* proxyProvider, const GrCaps* caps,
+ const ProxyParams& p) {
GrColorType grCT = SkColorTypeToGrColorType(p.fColorType);
GrPixelConfig config = GrColorTypeToPixelConfig(grCT, GrSRGBEncoded::kNo);
@@ -42,7 +43,9 @@
desc.fConfig = config;
desc.fSampleCnt = p.fSampleCnt;
- auto tmp = proxyProvider->createProxy(desc, p.fOrigin, p.fFit, SkBudgeted::kNo);
+ const GrBackendFormat format = caps->getBackendFormatFromColorType(p.fColorType);
+
+ auto tmp = proxyProvider->createProxy(format, desc, p.fOrigin, p.fFit, SkBudgeted::kNo);
if (!tmp) {
return nullptr;
}
@@ -134,6 +137,7 @@
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceAllocatorTest, reporter, ctxInfo) {
+ const GrCaps* caps = ctxInfo.grContext()->contextPriv().caps();
GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider();
GrResourceProvider* resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider();
@@ -173,8 +177,8 @@
};
for (auto test : gOverlappingTests) {
- GrSurfaceProxy* p1 = make_deferred(proxyProvider, test.fP1);
- GrSurfaceProxy* p2 = make_deferred(proxyProvider, test.fP2);
+ GrSurfaceProxy* p1 = make_deferred(proxyProvider, caps, test.fP1);
+ GrSurfaceProxy* p2 = make_deferred(proxyProvider, caps, test.fP2);
overlap_test(reporter, resourceProvider, p1, p2, test.fExpectation);
p1->completedRead();
p2->completedRead();
@@ -215,8 +219,8 @@
};
for (auto test : gNonOverlappingTests) {
- GrSurfaceProxy* p1 = make_deferred(proxyProvider, test.fP1);
- GrSurfaceProxy* p2 = make_deferred(proxyProvider, test.fP2);
+ GrSurfaceProxy* p1 = make_deferred(proxyProvider, caps, test.fP1);
+ GrSurfaceProxy* p2 = make_deferred(proxyProvider, caps, test.fP2);
if (!p1 || !p2) {
continue; // creation can fail (i.e., for msaa4 on iOS)
@@ -236,7 +240,7 @@
GrBackendTexture backEndTex;
GrSurfaceProxy* p1 = make_backend(ctxInfo.grContext(), t[0].fP1, &backEndTex);
- GrSurfaceProxy* p2 = make_deferred(proxyProvider, t[0].fP2);
+ GrSurfaceProxy* p2 = make_deferred(proxyProvider, caps, t[0].fP2);
non_overlap_test(reporter, resourceProvider, p1, p2, t[0].fExpectation);
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index fa09db3..11c8e67 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -1580,6 +1580,7 @@
}
static sk_sp<GrTextureProxy> make_mipmap_proxy(GrProxyProvider* proxyProvider,
+ const GrCaps* caps,
GrSurfaceDescFlags descFlags,
int width, int height,
int sampleCnt) {
@@ -1590,10 +1591,11 @@
desc.fConfig = kRGBA_8888_GrPixelConfig;
desc.fSampleCnt = sampleCnt;
+ const GrBackendFormat format = caps->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
auto origin = (descFlags & kRenderTarget_GrSurfaceFlag) ? kBottomLeft_GrSurfaceOrigin
: kTopLeft_GrSurfaceOrigin;
- return proxyProvider->createMipMapProxy(desc, origin, SkBudgeted::kYes);
+ return proxyProvider->createMipMapProxy(format, desc, origin, SkBudgeted::kYes);
}
// Exercise GrSurface::gpuMemorySize for different combos of MSAA, RT-only,
@@ -1632,18 +1634,20 @@
// Mipmapped versions
- if (context->contextPriv().caps()->mipMapSupport()) {
+ const GrCaps* caps = context->contextPriv().caps();
+ if (caps->mipMapSupport()) {
sk_sp<GrTextureProxy> proxy;
- proxy = make_mipmap_proxy(proxyProvider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 1);
+ proxy = make_mipmap_proxy(proxyProvider, caps, kRenderTarget_GrSurfaceFlag, kSize, kSize,
+ 1);
size_t size = proxy->gpuMemorySize();
REPORTER_ASSERT(reporter, kSize*kSize*4+(kSize*kSize*4)/3 == size);
size_t sampleCount = (size_t)context->contextPriv().caps()->getRenderTargetSampleCount(
4, kRGBA_8888_GrPixelConfig);
if (sampleCount >= 4) {
- proxy = make_mipmap_proxy(proxyProvider, kRenderTarget_GrSurfaceFlag, kSize, kSize,
- sampleCount);
+ proxy = make_mipmap_proxy(proxyProvider, caps, kRenderTarget_GrSurfaceFlag, kSize,
+ kSize, sampleCount);
size = proxy->gpuMemorySize();
REPORTER_ASSERT(reporter,
kSize*kSize*4+(kSize*kSize*4)/3 == size || // msaa4 failed
@@ -1651,7 +1655,7 @@
kSize*kSize*4*(sampleCount+1)+(kSize*kSize*4)/3 == size); // explicit resolve buffer
}
- proxy = make_mipmap_proxy(proxyProvider, kNone_GrSurfaceFlags, kSize, kSize, 1);
+ proxy = make_mipmap_proxy(proxyProvider, caps, kNone_GrSurfaceFlags, kSize, kSize, 1);
size = proxy->gpuMemorySize();
REPORTER_ASSERT(reporter, kSize*kSize*4+(kSize*kSize*4)/3 == size);
}
diff --git a/tests/SRGBReadWritePixelsTest.cpp b/tests/SRGBReadWritePixelsTest.cpp
index 0bb7694..201a831 100644
--- a/tests/SRGBReadWritePixelsTest.cpp
+++ b/tests/SRGBReadWritePixelsTest.cpp
@@ -202,8 +202,13 @@
desc.fHeight = kH;
desc.fConfig = encoding_as_pixel_config(contextEncoding);
+ GrSRGBEncoded srgbEncoded = GrSRGBEncoded::kNo;
+ GrColorType colorType = GrPixelConfigToColorTypeAndEncoding(desc.fConfig, &srgbEncoded);
+ const GrBackendFormat format =
+ context->contextPriv().caps()->getBackendFormatFromGrColorType(colorType, srgbEncoded);
+
auto surfaceContext = context->contextPriv().makeDeferredSurfaceContext(
- desc, kBottomLeft_GrSurfaceOrigin, GrMipMapped::kNo, SkBackingFit::kExact,
+ format, desc, kBottomLeft_GrSurfaceOrigin, GrMipMapped::kNo, SkBackingFit::kExact,
SkBudgeted::kNo, encoding_as_color_space(contextEncoding));
if (!surfaceContext) {
ERRORF(reporter, "Could not create %s surface context.", encoding_as_str(contextEncoding));
diff --git a/tests/SpecialSurfaceTest.cpp b/tests/SpecialSurfaceTest.cpp
index 7b3896b..a59c8ee 100644
--- a/tests/SpecialSurfaceTest.cpp
+++ b/tests/SpecialSurfaceTest.cpp
@@ -79,10 +79,16 @@
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialSurface_Gpu1, reporter, ctxInfo) {
for (auto config : { kRGBA_8888_GrPixelConfig, kRGBA_1010102_GrPixelConfig }) {
- if (!ctxInfo.grContext()->contextPriv().caps()->isConfigRenderable(config)) {
+ const GrCaps* caps = ctxInfo.grContext()->contextPriv().caps();
+ if (!caps->isConfigRenderable(config)) {
continue;
}
+ GrSRGBEncoded srgbEncoded = GrSRGBEncoded::kNo;
+ GrColorType colorType = GrPixelConfigToColorTypeAndEncoding(config, &srgbEncoded);
+ const GrBackendFormat format =
+ caps->getBackendFormatFromGrColorType(colorType, srgbEncoded);
sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeRenderTarget(ctxInfo.grContext(),
+ format,
kSmallerSize, kSmallerSize,
config, nullptr));
test_surface(surf, reporter, 0);
diff --git a/tests/TessellatingPathRendererTests.cpp b/tests/TessellatingPathRendererTests.cpp
index 6b1f29f..db8665d 100644
--- a/tests/TessellatingPathRendererTests.cpp
+++ b/tests/TessellatingPathRendererTests.cpp
@@ -675,9 +675,11 @@
DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) {
GrContext* ctx = ctxInfo.grContext();
+ const GrBackendFormat format =
+ ctx->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
sk_sp<GrRenderTargetContext> rtc(ctx->contextPriv().makeDeferredRenderTargetContext(
- SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig, nullptr, 1, GrMipMapped::kNo,
- kTopLeft_GrSurfaceOrigin));
+ format, SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig, nullptr, 1,
+ GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin));
if (!rtc) {
return;
}
diff --git a/tests/TextureProxyTest.cpp b/tests/TextureProxyTest.cpp
index 3348631..03ded09 100644
--- a/tests/TextureProxyTest.cpp
+++ b/tests/TextureProxyTest.cpp
@@ -38,29 +38,34 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// Basic test
-static sk_sp<GrTextureProxy> deferred_tex(skiatest::Reporter* reporter,
+static sk_sp<GrTextureProxy> deferred_tex(skiatest::Reporter* reporter, GrContext* ctx,
GrProxyProvider* proxyProvider, SkBackingFit fit) {
const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
+ GrBackendFormat format =
+ ctx->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
sk_sp<GrTextureProxy> proxy =
- proxyProvider->createProxy(desc, kBottomLeft_GrSurfaceOrigin, fit, SkBudgeted::kYes);
+ proxyProvider->createProxy(format, desc, kBottomLeft_GrSurfaceOrigin, fit,
+ SkBudgeted::kYes);
// Only budgeted & wrapped external proxies get to carry uniqueKeys
REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
return proxy;
}
-static sk_sp<GrTextureProxy> deferred_texRT(skiatest::Reporter* reporter,
+static sk_sp<GrTextureProxy> deferred_texRT(skiatest::Reporter* reporter, GrContext* ctx,
GrProxyProvider* proxyProvider, SkBackingFit fit) {
const GrSurfaceDesc desc = make_desc(kRenderTarget_GrSurfaceFlag);
+ GrBackendFormat format =
+ ctx->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
sk_sp<GrTextureProxy> proxy =
- proxyProvider->createProxy(desc, kBottomLeft_GrSurfaceOrigin, fit, SkBudgeted::kYes);
+ proxyProvider->createProxy(format, desc, kBottomLeft_GrSurfaceOrigin, fit, SkBudgeted::kYes);
// Only budgeted & wrapped external proxies get to carry uniqueKeys
REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
return proxy;
}
-static sk_sp<GrTextureProxy> wrapped(skiatest::Reporter* reporter,
+static sk_sp<GrTextureProxy> wrapped(skiatest::Reporter* reporter, GrContext* ctx,
GrProxyProvider* proxyProvider, SkBackingFit fit) {
const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
@@ -71,7 +76,7 @@
return proxy;
}
-static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter,
+static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter, GrContext* ctx,
GrProxyProvider* proxyProvider, SkBackingFit fit) {
static GrUniqueKey::Domain d = GrUniqueKey::GenerateDomain();
static int kUniqueKeyData = 0;
@@ -237,7 +242,8 @@
builder.finish();
// Create proxy, assign unique key
- sk_sp<GrTextureProxy> proxy = deferred_tex(reporter, proxyProvider, SkBackingFit::kExact);
+ sk_sp<GrTextureProxy> proxy = deferred_tex(reporter, context, proxyProvider,
+ SkBackingFit::kExact);
SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get()));
// Send an invalidation message, which will be sitting in the cache's inbox
@@ -274,7 +280,7 @@
for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
for (auto create : { deferred_tex, deferred_texRT, wrapped, wrapped_with_key }) {
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
- basic_test(context, reporter, create(reporter, proxyProvider, fit));
+ basic_test(context, reporter, create(reporter, context, proxyProvider, fit));
}
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
diff --git a/tests/TraceMemoryDumpTest.cpp b/tests/TraceMemoryDumpTest.cpp
index df72f79..32eab62 100644
--- a/tests/TraceMemoryDumpTest.cpp
+++ b/tests/TraceMemoryDumpTest.cpp
@@ -150,7 +150,7 @@
iddesc.fMSColorRenderbufferID = 22;
iddesc.fIsMixedSampled = false;
- sk_sp<GrGLRenderTarget> rt = GrGLRenderTarget::MakeWrapped(gpu, sd, iddesc, 0);
+ sk_sp<GrGLRenderTarget> rt = GrGLRenderTarget::MakeWrapped(gpu, sd, GR_GL_RGBA8, iddesc, 0);
ValidateMemoryDumps(reporter, context, rt->gpuMemorySize(), true /* isOwned */);
}
@@ -172,7 +172,7 @@
iddesc.fMSColorRenderbufferID = 22;
iddesc.fIsMixedSampled = false;
- sk_sp<GrGLRenderTarget> rt = GrGLRenderTarget::MakeWrapped(gpu, sd, iddesc, 0);
+ sk_sp<GrGLRenderTarget> rt = GrGLRenderTarget::MakeWrapped(gpu, sd, GR_GL_RGBA8, iddesc, 0);
ValidateMemoryDumps(reporter, context, rt->gpuMemorySize(), false /* isOwned */);
}
diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp
index 007f16b..9ba16c9 100644
--- a/tests/WritePixelsTest.cpp
+++ b/tests/WritePixelsTest.cpp
@@ -529,8 +529,11 @@
desc.fHeight = 64;
desc.fConfig = kRGBA_8888_GrPixelConfig;
+ const GrBackendFormat format =
+ context->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
+
sk_sp<GrTextureProxy> temp = proxyProvider->createProxy(
- desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kApprox, SkBudgeted::kYes);
+ format, desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kApprox, SkBudgeted::kYes);
temp->instantiate(context->contextPriv().resourceProvider());
}