Add factories to GrSurfaceContext and clean up creation flow.
This CL updates all callers that ending up in GrDrawingManager::makeSurfaceContext
to use the new factory or directly call ctors.
A follow on change will get the rest of the calls which go to
GrDrawingManager::makeRenderTargetContext
Change-Id: I662da654a1ec8b8972c50fe9ce45a9185d4c3dc1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/260901
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index ef5dc3c..060a97a 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -308,14 +308,24 @@
return nullptr;
}
auto colorType = GrPixelConfigToColorType(src->config());
+ auto format = src->backendFormat().makeTexture2D();
+ SkASSERT(format.isValid());
+ auto config = context->priv().caps()->getConfigFromBackendFormat(format, colorType);
+ if (config == kUnknown_GrPixelConfig) {
+ return nullptr;
+ }
+ GrSurfaceDesc desc;
+ desc.fWidth = width;
+ desc.fHeight = height;
+ desc.fConfig = config;
+
+ GrSurfaceOrigin origin = src->origin();
if (src->backendFormat().textureType() != GrTextureType::kExternal) {
- auto dstContext = context->priv().makeDeferredSurfaceContext(
- fit, width, height, colorType, kUnknown_SkAlphaType, nullptr, mipMapped,
- src->origin(), budgeted, isProtected);
- if (!dstContext) {
- return nullptr;
- }
- if (dstContext->copy(src, srcRect, dstPoint)) {
+ auto dstContext = GrSurfaceContext::Make(context, {width, height}, format,
+ GrRenderable::kNo, 1, mipMapped, isProtected,
+ origin, colorType, kUnknown_SkAlphaType, nullptr,
+ fit, budgeted);
+ if (dstContext && dstContext->copy(src, srcRect, dstPoint)) {
return dstContext->asTextureProxyRef();
}
}