aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/SkGLContext.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-10-08 04:45:09 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-08 04:45:10 -0700
commit10805961ce424868e8315e00f6dbeeaa62d466ac (patch)
tree87fbeec3c52176c1794c25ae639adb38c6bcfa60 /src/gpu/gl/SkGLContext.cpp
parenta5ee45ce9daba663c28ba5f6634af93702aecd96 (diff)
Revert of Make the Sk GL context class an abstract base class (patchset #4 id:60001 of https://codereview.chromium.org/630843002/)
Reason for revert: nanobech failing on Android Original issue's description: > Make the Sk GL context class an abstract base class > > Make the Sk GL context class, SkGLNativeContext, an abstract base class. Before, > it depended on ifdefs to implement the platform dependent polymorphism. Move > the logic to subclasses of the various platform implementations. > > This a step to enable Skia embedders to compile dm and bench_pictures. The > concrete goal is to support running these test apps with Chromium command buffer. > > With this change, Chromium can implement its own version of SkGLNativeContext > that uses command buffer, and host the implementation in its own repository. > > Implements the above by renaming the SkGLContextHelper to SkGLContext and > removing the unneeded SkGLNativeContext. Also removes > SkGLNativeContext::AutoRestoreContext functionality, it appeared to be unused: > no use in Skia code, and no tests. > > BUG=skia:2992 > > Committed: https://skia.googlesource.com/skia/+/a90ed4e83897b45d6331ee4c54e1edd4054de9a8 TBR=kkinnunen@nvidia.com NOTREECHECKS=true NOTRY=true BUG=skia:2992 Review URL: https://codereview.chromium.org/639793002
Diffstat (limited to 'src/gpu/gl/SkGLContext.cpp')
-rw-r--r--src/gpu/gl/SkGLContext.cpp142
1 files changed, 0 insertions, 142 deletions
diff --git a/src/gpu/gl/SkGLContext.cpp b/src/gpu/gl/SkGLContext.cpp
deleted file mode 100644
index 92f65cd924..0000000000
--- a/src/gpu/gl/SkGLContext.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include "gl/SkGLContext.h"
-#include "GrGLUtil.h"
-
-SkGLContext::SkGLContext()
- : fFBO(0)
- , fColorBufferID(0)
- , fDepthStencilBufferID(0)
- , fGL(NULL) {
-}
-
-SkGLContext::~SkGLContext() {
-
- if (fGL) {
- // TODO: determine why DeleteFramebuffers is generating a GL error in tests
- SK_GL_NOERRCHECK(*this, DeleteFramebuffers(1, &fFBO));
- SK_GL_NOERRCHECK(*this, DeleteRenderbuffers(1, &fColorBufferID));
- SK_GL_NOERRCHECK(*this, DeleteRenderbuffers(1, &fDepthStencilBufferID));
- }
-
- SkSafeUnref(fGL);
-}
-
-bool SkGLContext::init(GrGLStandard forcedGpuAPI, int width,
- int height) {
- if (fGL) {
- fGL->unref();
- this->destroyGLContext();
- }
-
- fGL = this->createGLContext(forcedGpuAPI);
- if (fGL) {
- const GrGLubyte* temp;
-
- if (!fGL->validate()) {
- fGL = NULL;
- this->destroyGLContext();
- return false;
- }
-
- SK_GL_RET(*this, temp, GetString(GR_GL_VERSION));
- const char* versionStr = reinterpret_cast<const char*>(temp);
- GrGLVersion version = GrGLGetVersionFromString(versionStr);
-
- // clear any existing GL erorrs
- GrGLenum error;
- do {
- SK_GL_RET(*this, error, GetError());
- } while (GR_GL_NO_ERROR != error);
-
- SK_GL(*this, GenFramebuffers(1, &fFBO));
- SK_GL(*this, BindFramebuffer(GR_GL_FRAMEBUFFER, fFBO));
- SK_GL(*this, GenRenderbuffers(1, &fColorBufferID));
- SK_GL(*this, BindRenderbuffer(GR_GL_RENDERBUFFER, fColorBufferID));
- if (kGLES_GrGLStandard == this->gl()->fStandard) {
- SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER,
- GR_GL_RGBA8,
- width, height));
- } else {
- SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER,
- GR_GL_RGBA,
- width, height));
- }
- SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
- GR_GL_COLOR_ATTACHMENT0,
- GR_GL_RENDERBUFFER,
- fColorBufferID));
- SK_GL(*this, GenRenderbuffers(1, &fDepthStencilBufferID));
- SK_GL(*this, BindRenderbuffer(GR_GL_RENDERBUFFER, fDepthStencilBufferID));
-
- // Some drivers that support packed depth stencil will only succeed
- // in binding a packed format an FBO. However, we can't rely on packed
- // depth stencil being available.
- bool supportsPackedDepthStencil;
- if (kGLES_GrGLStandard == this->gl()->fStandard) {
- supportsPackedDepthStencil = version >= GR_GL_VER(3,0) ||
- this->hasExtension("GL_OES_packed_depth_stencil");
- } else {
- supportsPackedDepthStencil = version >= GR_GL_VER(3,0) ||
- this->hasExtension("GL_EXT_packed_depth_stencil") ||
- this->hasExtension("GL_ARB_framebuffer_object");
- }
-
- if (supportsPackedDepthStencil) {
- // ES2 requires sized internal formats for RenderbufferStorage
- // On Desktop we let the driver decide.
- GrGLenum format = kGLES_GrGLStandard == this->gl()->fStandard ?
- GR_GL_DEPTH24_STENCIL8 :
- GR_GL_DEPTH_STENCIL;
- SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER,
- format,
- width, height));
- SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
- GR_GL_DEPTH_ATTACHMENT,
- GR_GL_RENDERBUFFER,
- fDepthStencilBufferID));
- } else {
- GrGLenum format = kGLES_GrGLStandard == this->gl()->fStandard ? GR_GL_STENCIL_INDEX8 :
- GR_GL_STENCIL_INDEX;
- SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER,
- format,
- width, height));
- }
- SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
- GR_GL_STENCIL_ATTACHMENT,
- GR_GL_RENDERBUFFER,
- fDepthStencilBufferID));
- SK_GL(*this, Viewport(0, 0, width, height));
- SK_GL(*this, ClearStencil(0));
- SK_GL(*this, Clear(GR_GL_STENCIL_BUFFER_BIT));
-
- SK_GL_RET(*this, error, GetError());
- GrGLenum status;
- SK_GL_RET(*this, status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
-
- if (GR_GL_FRAMEBUFFER_COMPLETE != status ||
- GR_GL_NO_ERROR != error) {
- fFBO = 0;
- fColorBufferID = 0;
- fDepthStencilBufferID = 0;
- fGL->unref();
- fGL = NULL;
- this->destroyGLContext();
- return false;
- } else {
- return true;
- }
- }
- return false;
-}
-
-void SkGLContext::testAbandon() {
- if (fGL) {
- fGL->abandon();
- }
-}