Make sk_app::WindowContext directly create a SkSurface without an intermediate GrRenderTarget
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2165703002
Review-Url: https://codereview.chromium.org/2165703002
diff --git a/tools/viewer/sk_app/GLWindowContext.cpp b/tools/viewer/sk_app/GLWindowContext.cpp
index b960da4..31ba01c 100644
--- a/tools/viewer/sk_app/GLWindowContext.cpp
+++ b/tools/viewer/sk_app/GLWindowContext.cpp
@@ -83,9 +83,8 @@
GrGLint buffer;
GR_GL_CALL(fBackendContext, GetIntegerv(GR_GL_FRAMEBUFFER_BINDING, &buffer));
desc.fRenderTargetHandle = buffer;
- fRenderTarget.reset(fContext->textureProvider()->wrapBackendRenderTarget(desc));
- fSurface = this->createRenderSurface(fRenderTarget, fActualColorBits);
+ fSurface = this->createRenderSurface(desc, fActualColorBits);
}
}
diff --git a/tools/viewer/sk_app/VulkanWindowContext.cpp b/tools/viewer/sk_app/VulkanWindowContext.cpp
index 5087e5d..c969f28 100644
--- a/tools/viewer/sk_app/VulkanWindowContext.cpp
+++ b/tools/viewer/sk_app/VulkanWindowContext.cpp
@@ -278,9 +278,8 @@
desc.fSampleCnt = 0;
desc.fStencilBits = 0;
desc.fRenderTargetHandle = (GrBackendObject) &info;
- fRenderTargets[i].reset(fContext->textureProvider()->wrapBackendRenderTarget(desc));
- fSurfaces[i] = this->createRenderSurface(fRenderTargets[i], 24);
+ fSurfaces[i] = this->createRenderSurface(desc, 24);
}
// create the command pool for the command buffers
diff --git a/tools/viewer/sk_app/WindowContext.cpp b/tools/viewer/sk_app/WindowContext.cpp
index ba04e7e..5d364bc 100755
--- a/tools/viewer/sk_app/WindowContext.cpp
+++ b/tools/viewer/sk_app/WindowContext.cpp
@@ -25,12 +25,12 @@
return createSurface(nullptr, 0, true, forceSRGB);
}
-sk_sp<SkSurface> WindowContext::createRenderSurface(sk_sp<GrRenderTarget> rt, int colorBits) {
- return createSurface(rt, colorBits, false, false);
+sk_sp<SkSurface> WindowContext::createRenderSurface(GrBackendRenderTargetDesc desc, int colorBits) {
+ return createSurface(&desc, colorBits, false, false);
}
sk_sp<SkSurface> WindowContext::createSurface(
- sk_sp<GrRenderTarget> rt, int colorBits, bool offscreen, bool forceSRGB) {
+ GrBackendRenderTargetDesc* rtDesc, int colorBits, bool offscreen, bool forceSRGB) {
auto flags = (fSurfaceProps.flags() & ~SkSurfaceProps::kGammaCorrect_Flag) |
(GrPixelConfigIsSRGB(fPixelConfig) || forceSRGB ?
SkSurfaceProps::kGammaCorrect_Flag : 0);
@@ -57,7 +57,7 @@
return SkSurface::MakeRaster(info, &props);
}
} else {
- return SkSurface::MakeRenderTargetDirect(rt.get(), &props);
+ return SkSurface::MakeFromBackendRenderTarget(fContext, *rtDesc, &props);
}
}
diff --git a/tools/viewer/sk_app/WindowContext.h b/tools/viewer/sk_app/WindowContext.h
index 2c526a4..917eb4e 100644
--- a/tools/viewer/sk_app/WindowContext.h
+++ b/tools/viewer/sk_app/WindowContext.h
@@ -45,13 +45,14 @@
GrContext* getGrContext() const { return fContext; }
sk_sp<SkSurface> createOffscreenSurface(bool sRGB);
- sk_sp<SkSurface> createRenderSurface(sk_sp<GrRenderTarget>, int colorBits);
void presentRenderSurface(sk_sp<SkSurface> renderSurface, sk_sp<GrRenderTarget> rt,
int colorBits);
protected:
virtual bool isGpuContext() { return true; }
+ sk_sp<SkSurface> createRenderSurface(GrBackendRenderTargetDesc, int colorBits);
+
GrContext* fContext;
int fWidth;
@@ -62,7 +63,7 @@
private:
sk_sp<SkSurface> createSurface(
- sk_sp<GrRenderTarget>, int colorBits, bool offscreen, bool forceSRGB);
+ GrBackendRenderTargetDesc*, int colorBits, bool offscreen, bool forceSRGB);
};
} // namespace sk_app