aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/viewer/sk_app/GLWindowContext.cpp
diff options
context:
space:
mode:
authorGravatar jvanverth <jvanverth@google.com>2016-05-18 07:01:16 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-18 07:01:16 -0700
commit2884e9c0bd2cc9634a4b932d4142840c67227a78 (patch)
treec8c04ea788dc277d59d022008533944a4716f986 /tools/viewer/sk_app/GLWindowContext.cpp
parent3949971e8d29345ee89461aec1ef25734ffc03f5 (diff)
Revert of Add OpenGL context to Viewer. (patchset #7 id:120001 of https://codereview.chromium.org/1978573003/ )
Reason for revert: sk_app/WindowContext.cpp is missing. Need to add file and resubmit. Original issue's description: > Add OpenGL context to Viewer. > > BUG=skia: > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1978573003 > > Committed: https://skia.googlesource.com/skia/+/56a11e4d6f3d436a3c2497c9c9e71a117d78a93f TBR=brianosman@google.com,bsalomon@google.com,djsollen@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review-Url: https://codereview.chromium.org/1990893002
Diffstat (limited to 'tools/viewer/sk_app/GLWindowContext.cpp')
-rw-r--r--tools/viewer/sk_app/GLWindowContext.cpp112
1 files changed, 0 insertions, 112 deletions
diff --git a/tools/viewer/sk_app/GLWindowContext.cpp b/tools/viewer/sk_app/GLWindowContext.cpp
deleted file mode 100644
index a491321a2a..0000000000
--- a/tools/viewer/sk_app/GLWindowContext.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "GrContext.h"
-#include "SkSurface.h"
-#include "GLWindowContext.h"
-
-#include "gl/GrGLDefines.h"
-
-#include "gl/GrGLUtil.h"
-#include "GrRenderTarget.h"
-#include "GrContext.h"
-
-#include "SkCanvas.h"
-#include "SkImage_Base.h"
-
-namespace sk_app {
-
-GLWindowContext::GLWindowContext(void* platformData, const DisplayParams& params)
- : WindowContext()
- , fBackendContext(nullptr)
- , fRenderTarget(nullptr)
- , fSurface(nullptr) {
-}
-
-void GLWindowContext::initializeContext(void* platformData, const DisplayParams& params) {
-
- this->onInitializeContext(platformData, params);
-
- fDisplayParams = params;
-
- SkAutoTUnref<const GrGLInterface> glInterface;
- glInterface.reset(GrGLCreateNativeInterface());
- fBackendContext.reset(GrGLInterfaceRemoveNVPR(glInterface.get()));
-
- SkASSERT(nullptr == fContext);
- fContext = GrContext::Create(kOpenGL_GrBackend, (GrBackendContext)fBackendContext.get());
-
- // We may not have real sRGB support (ANGLE, in particular), so check for
- // that, and fall back to L32:
- //
- // ... and, if we're using a 10-bit/channel FB0, it doesn't do sRGB conversion on write,
- // so pretend that it's non-sRGB 8888:
- fPixelConfig = fContext->caps()->srgbSupport() &&
- SkColorAndProfileAreGammaCorrect(fDisplayParams.fColorType,
- fDisplayParams.fProfileType) &&
- (fColorBits != 30) ? kSkiaGamma8888_GrPixelConfig : kSkia8888_GrPixelConfig;
-}
-
-void GLWindowContext::destroyContext() {
- fSurface.reset(nullptr);
- fRenderTarget.reset(nullptr);
-
- if (fContext) {
- // in case we have outstanding refs to this guy (lua?)
- fContext->abandonContext();
- fContext->unref();
- fContext = nullptr;
- }
-
- fBackendContext.reset(nullptr);
-
- this->onDestroyContext();
-}
-
-sk_sp<SkSurface> GLWindowContext::getBackbufferSurface() {
- if (nullptr == fSurface) {
- fActualColorBits = SkTMax(fColorBits, 24);
-
- if (fContext) {
- GrBackendRenderTargetDesc desc;
- desc.fWidth = this->fWidth;
- desc.fHeight = this->fHeight;
- desc.fConfig = fPixelConfig;
- desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
- desc.fSampleCnt = fSampleCount;
- desc.fStencilBits = fStencilBits;
- 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);
- }
- }
-
- return fSurface;
-}
-
-void GLWindowContext::swapBuffers() {
- this->presentRenderSurface(fSurface, fRenderTarget, fActualColorBits);
- this->onSwapBuffers();
-}
-
-void GLWindowContext::resize(uint32_t w, uint32_t h) {
- this->destroyContext();
-
- this->initializeContext(nullptr, fDisplayParams);
-}
-
-void GLWindowContext::setDisplayParams(const DisplayParams& params) {
- this->destroyContext();
-
- this->initializeContext(nullptr, params);
-}
-
-} //namespace sk_app