Reland "Revert "Use ManagedBackendTexture in place of TestUtils backend texture helpers.""
This reverts commit 21f8b5109951b16ff327f39072d7b5b141ac5c09.
Reason for revert: D3D traced resource assert from unit test
Original change's description:
> Revert "Revert "Use ManagedBackendTexture in place of TestUtils backend texture helpers.""
>
> This reverts commit f625e4ce4504facbf0cfa210f8d9770b8431cdd9.
>
> Change-Id: Id73c53ec7ab8d4a5951712dc150d86e6349addbf
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/325658
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
TBR=egdaniel@google.com,bsalomon@google.com
# Not skipping CQ checks because this is a reland.
Change-Id: I407f1d522d5c4f28d070cc2ce87af7faffca11fd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/325860
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/tools/gpu/BackendSurfaceFactory.cpp b/tools/gpu/BackendSurfaceFactory.cpp
index 2c24760..32a6500 100644
--- a/tools/gpu/BackendSurfaceFactory.cpp
+++ b/tools/gpu/BackendSurfaceFactory.cpp
@@ -15,38 +15,7 @@
namespace sk_gpu_test {
-sk_sp<SkSurface> MakeBackendTextureSurface(GrDirectContext* dContext,
- const SkImageInfo& ii,
- GrSurfaceOrigin origin,
- int sampleCnt,
- GrMipmapped mipMapped,
- GrProtected isProtected,
- const SkSurfaceProps* props) {
- if (ii.alphaType() == kUnpremul_SkAlphaType) {
- return nullptr;
- }
- auto mbet = ManagedBackendTexture::MakeWithoutData(dContext,
- ii.width(),
- ii.height(),
- ii.colorType(),
- mipMapped,
- GrRenderable::kYes,
- isProtected);
- if (!mbet) {
- return nullptr;
- }
- return SkSurface::MakeFromBackendTexture(dContext,
- mbet->texture(),
- origin,
- sampleCnt,
- ii.colorType(),
- ii.refColorSpace(),
- props,
- ManagedBackendTexture::ReleaseProc,
- mbet->releaseContext());
-}
-
-sk_sp<SkSurface> MakeBackendTextureSurface(GrDirectContext* dContext,
+sk_sp<SkSurface> MakeBackendTextureSurface(GrDirectContext* context,
SkISize dimensions,
GrSurfaceOrigin origin,
int sampleCnt,
@@ -55,29 +24,45 @@
GrMipmapped mipMapped,
GrProtected isProtected,
const SkSurfaceProps* props) {
- auto ii = SkImageInfo::Make(dimensions, colorType, kPremul_SkAlphaType, std::move(colorSpace));
- return MakeBackendTextureSurface(
- dContext, ii, origin, sampleCnt, mipMapped, isProtected, props);
-}
-sk_sp<SkSurface> MakeBackendRenderTargetSurface(GrDirectContext* dContext,
- const SkImageInfo& ii,
- GrSurfaceOrigin origin,
- int sampleCnt,
- GrProtected isProtected,
- const SkSurfaceProps* props) {
- if (ii.alphaType() == kUnpremul_SkAlphaType) {
+ auto mbet = ManagedBackendTexture::MakeWithoutData(context,
+ dimensions.fWidth,
+ dimensions.fHeight,
+ colorType,
+ mipMapped,
+ GrRenderable::kYes,
+ isProtected);
+ if (!mbet) {
return nullptr;
}
- auto ct = SkColorTypeToGrColorType(ii.colorType());
+ return SkSurface::MakeFromBackendTexture(context,
+ mbet->texture(),
+ origin,
+ sampleCnt,
+ colorType,
+ std::move(colorSpace),
+ props,
+ ManagedBackendTexture::ReleaseProc,
+ mbet->releaseContext());
+}
+
+sk_sp<SkSurface> MakeBackendRenderTargetSurface(GrDirectContext* context,
+ SkISize dimensions,
+ GrSurfaceOrigin origin,
+ int sampleCnt,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ GrProtected isProtected,
+ const SkSurfaceProps* props) {
+ auto ct = SkColorTypeToGrColorType(colorType);
struct ReleaseContext {
GrDirectContext* fContext;
GrBackendRenderTarget fRenderTarget;
};
- auto bert = dContext->priv().getGpu()->createTestingOnlyBackendRenderTarget(
- ii.dimensions(), ct, sampleCnt, isProtected);
- auto rc = new ReleaseContext{dContext, bert};
+ auto bert = context->priv().getGpu()->createTestingOnlyBackendRenderTarget(
+ dimensions, ct, sampleCnt, isProtected);
+ auto rc = new ReleaseContext{context, bert};
SkASSERT(!bert.isValid() || bert.sampleCnt() >= sampleCnt);
auto proc = [](void* c) {
@@ -89,19 +74,7 @@
};
return SkSurface::MakeFromBackendRenderTarget(
- dContext, bert, origin, ii.colorType(), ii.refColorSpace(), props, proc, rc);
-}
-
-sk_sp<SkSurface> MakeBackendRenderTargetSurface(GrDirectContext* dContext,
- SkISize dimensions,
- GrSurfaceOrigin origin,
- int sampleCnt,
- SkColorType colorType,
- sk_sp<SkColorSpace> colorSpace,
- GrProtected isProtected,
- const SkSurfaceProps* props) {
- auto ii = SkImageInfo::Make(dimensions, colorType, kPremul_SkAlphaType, std::move(colorSpace));
- return MakeBackendRenderTargetSurface(dContext, ii, origin, sampleCnt, isProtected, props);
+ context, bert, origin, colorType, std::move(colorSpace), props, proc, rc);
}
} // namespace sk_gpu_test