aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2016-07-19 09:46:29 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-19 09:46:29 -0700
commitc7b4b28496a94c3fce7f11a18ce04deffbf9cfcb (patch)
tree79f874593ee36589f3d355232cce5625c3bf1bb3 /tools
parent6bdbf4412bd1a6fe26be1042ccf080174b13021f (diff)
Make sk_app::WindowContext directly create a SkSurface without an intermediate GrRenderTarget
Diffstat (limited to 'tools')
-rw-r--r--tools/viewer/sk_app/GLWindowContext.cpp3
-rw-r--r--tools/viewer/sk_app/VulkanWindowContext.cpp3
-rwxr-xr-xtools/viewer/sk_app/WindowContext.cpp8
-rw-r--r--tools/viewer/sk_app/WindowContext.h5
4 files changed, 9 insertions, 10 deletions
diff --git a/tools/viewer/sk_app/GLWindowContext.cpp b/tools/viewer/sk_app/GLWindowContext.cpp
index b960da4824..31ba01c292 100644
--- a/tools/viewer/sk_app/GLWindowContext.cpp
+++ b/tools/viewer/sk_app/GLWindowContext.cpp
@@ -83,9 +83,8 @@ sk_sp<SkSurface> GLWindowContext::getBackbufferSurface() {
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 5087e5d4fd..c969f28d85 100644
--- a/tools/viewer/sk_app/VulkanWindowContext.cpp
+++ b/tools/viewer/sk_app/VulkanWindowContext.cpp
@@ -278,9 +278,8 @@ void VulkanWindowContext::createBuffers(VkFormat format) {
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 ba04e7eace..5d364bc497 100755
--- a/tools/viewer/sk_app/WindowContext.cpp
+++ b/tools/viewer/sk_app/WindowContext.cpp
@@ -25,12 +25,12 @@ sk_sp<SkSurface> WindowContext::createOffscreenSurface(bool forceSRGB) {
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 @@ sk_sp<SkSurface> WindowContext::createSurface(
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 2c526a4bfe..917eb4edf8 100644
--- a/tools/viewer/sk_app/WindowContext.h
+++ b/tools/viewer/sk_app/WindowContext.h
@@ -45,13 +45,14 @@ public:
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 @@ protected:
private:
sk_sp<SkSurface> createSurface(
- sk_sp<GrRenderTarget>, int colorBits, bool offscreen, bool forceSRGB);
+ GrBackendRenderTargetDesc*, int colorBits, bool offscreen, bool forceSRGB);
};
} // namespace sk_app