aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/viewer
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2017-07-25 10:05:01 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-25 14:33:03 +0000
commit02611d9afdd887ee443825ac88377f2eea093380 (patch)
tree3e35b4e4fde4b6f387f7bdb345b049c1ab76e182 /tools/viewer
parent10b6ad13f996d2f522bc057d17acea58e43a7f0b (diff)
Add Make[backend] calls for creating GrContexts
Docs-Preview: https://skia.org/?cl=26369 Bug: skia: Change-Id: I460ee63e466f85b05918479f068a2e5ca2d70550 Reviewed-on: https://skia-review.googlesource.com/26369 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tools/viewer')
-rw-r--r--tools/viewer/sk_app/GLWindowContext.cpp10
-rw-r--r--tools/viewer/sk_app/VulkanWindowContext.cpp7
-rw-r--r--tools/viewer/sk_app/WindowContext.h6
3 files changed, 10 insertions, 13 deletions
diff --git a/tools/viewer/sk_app/GLWindowContext.cpp b/tools/viewer/sk_app/GLWindowContext.cpp
index 2f0d5dc74b..682fcbfa48 100644
--- a/tools/viewer/sk_app/GLWindowContext.cpp
+++ b/tools/viewer/sk_app/GLWindowContext.cpp
@@ -31,11 +31,10 @@ GLWindowContext::GLWindowContext(const DisplayParams& params)
void GLWindowContext::initializeContext() {
this->onInitializeContext();
- SkASSERT(nullptr == fContext);
+ SkASSERT(!fContext);
fBackendContext.reset(GrGLCreateNativeInterface());
- fContext = GrContext::Create(kOpenGL_GrBackend, (GrBackendContext)fBackendContext.get(),
- fDisplayParams.fGrContextOptions);
+ fContext = GrContext::MakeGL(fBackendContext.get(), fDisplayParams.fGrContextOptions);
if (!fContext && fDisplayParams.fMSAASampleCount) {
fDisplayParams.fMSAASampleCount /= 2;
this->initializeContext();
@@ -58,8 +57,7 @@ void GLWindowContext::destroyContext() {
if (fContext) {
// in case we have outstanding refs to this guy (lua?)
fContext->abandonContext();
- fContext->unref();
- fContext = nullptr;
+ fContext.reset();
}
fBackendContext.reset(nullptr);
@@ -83,7 +81,7 @@ sk_sp<SkSurface> GLWindowContext::getBackbufferSurface() {
fPixelConfig,
fbInfo);
- fSurface = SkSurface::MakeFromBackendRenderTarget(fContext, backendRT,
+ fSurface = SkSurface::MakeFromBackendRenderTarget(fContext.get(), backendRT,
kBottomLeft_GrSurfaceOrigin,
fDisplayParams.fColorSpace,
&fSurfaceProps);
diff --git a/tools/viewer/sk_app/VulkanWindowContext.cpp b/tools/viewer/sk_app/VulkanWindowContext.cpp
index 261206c221..a9124d5e41 100644
--- a/tools/viewer/sk_app/VulkanWindowContext.cpp
+++ b/tools/viewer/sk_app/VulkanWindowContext.cpp
@@ -67,8 +67,7 @@ void VulkanWindowContext::initializeContext() {
GET_DEV_PROC(AcquireNextImageKHR);
GET_DEV_PROC(QueuePresentKHR);
- fContext = GrContext::Create(kVulkan_GrBackend, (GrBackendContext) fBackendContext.get(),
- fDisplayParams.fGrContextOptions);
+ fContext = GrContext::MakeVulkan(fBackendContext.get(), fDisplayParams.fGrContextOptions);
fSurface = fCreateVkSurfaceFn(instance);
if (VK_NULL_HANDLE == fSurface) {
@@ -280,7 +279,7 @@ void VulkanWindowContext::createBuffers(VkFormat format) {
GrBackendTexture backendTex(fWidth, fHeight, info);
- fSurfaces[i] = SkSurface::MakeFromBackendTextureAsRenderTarget(fContext, backendTex,
+ fSurfaces[i] = SkSurface::MakeFromBackendTextureAsRenderTarget(fContext.get(), backendTex,
kTopLeft_GrSurfaceOrigin,
fSampleCount,
fDisplayParams.fColorSpace,
@@ -412,7 +411,7 @@ void VulkanWindowContext::destroyContext() {
fSurface = VK_NULL_HANDLE;
}
- fContext->unref();
+ fContext.reset();
fBackendContext.reset(nullptr);
}
diff --git a/tools/viewer/sk_app/WindowContext.h b/tools/viewer/sk_app/WindowContext.h
index fbd2756b67..cd4c357e20 100644
--- a/tools/viewer/sk_app/WindowContext.h
+++ b/tools/viewer/sk_app/WindowContext.h
@@ -8,11 +8,11 @@
#define WindowContext_DEFINED
#include "DisplayParams.h"
+#include "GrContext.h"
#include "GrTypes.h"
#include "SkRefCnt.h"
#include "SkSurfaceProps.h"
-class GrContext;
class SkSurface;
class GrRenderTarget;
@@ -46,7 +46,7 @@ public:
}
virtual GrBackendContext getBackendContext() = 0;
- GrContext* getGrContext() const { return fContext; }
+ GrContext* getGrContext() const { return fContext.get(); }
int width() const { return fWidth; }
int height() const { return fHeight; }
@@ -56,7 +56,7 @@ public:
protected:
virtual bool isGpuContext() { return true; }
- GrContext* fContext;
+ sk_sp<GrContext> fContext;
int fWidth;
int fHeight;