aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/mesa
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-10-13 13:33:08 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-10-13 13:33:08 +0000
commite295313f019d36be5303673dd0c58c751e516fdb (patch)
tree6b897489326972a4231112894a1a7c6b23e7edcb /src/utils/mesa
parent1ba7137fc0dcace0c1be1367fe977202c63746ba (diff)
move utils/SkEGLContext to gpu/SkGLContext, some gpu.gyp cleanup, set eol style LF on all gpu files
Review URL: http://codereview.appspot.com/5242056/ git-svn-id: http://skia.googlecode.com/svn/trunk@2474 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/utils/mesa')
-rw-r--r--src/utils/mesa/SkEGLContext_Mesa.cpp137
1 files changed, 0 insertions, 137 deletions
diff --git a/src/utils/mesa/SkEGLContext_Mesa.cpp b/src/utils/mesa/SkEGLContext_Mesa.cpp
deleted file mode 100644
index 1174dedbcc..0000000000
--- a/src/utils/mesa/SkEGLContext_Mesa.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include "SkEGLContext.h"
-#include "SkTypes.h"
-
-#include "GL/osmesa.h"
-#include "GL/glu.h"
-
-#define SK_GL_DECL_PROC(T, F) T F ## _func = NULL;
-#define SK_GL_GET_PROC(T, F) F ## _func = (T)OSMesaGetProcAddress(#F);
-#define SK_GL_GET_EXT_PROC(T, F) F ## _func = (T)OSMesaGetProcAddress(#F "EXT");
-
-SkEGLContext::SkEGLContext()
- : fFBO(0)
- , context(NULL)
- , image(NULL) {
-}
-
-SkEGLContext::~SkEGLContext() {
- if (this->image)
- free(this->image);
-
- if (this->context)
- OSMesaDestroyContext(this->context);
-}
-
-#if SK_B32_SHIFT < SK_G32_SHIFT &&\
- SK_G32_SHIFT < SK_R32_SHIFT &&\
- SK_R32_SHIFT < SK_A32_SHIFT
- #define SK_OSMESA_COLOR_ORDER OSMESA_BGRA
-#elif SK_R32_SHIFT < SK_G32_SHIFT &&\
- SK_G32_SHIFT < SK_B32_SHIFT &&\
- SK_B32_SHIFT < SK_A32_SHIFT
- #define SK_OSMESA_COLOR_ORDER OSMESA_RGBA
-#elif SK_A32_SHIFT < SK_R32_SHIFT && \
- SK_R32_SHIFT < SK_G32_SHIFT && \
- SK_G32_SHIFT < SK_B32_SHIFT
- #define SK_OSMESA_COLOR_ORDER OSMESA_ARGB
-#else
- //Color order (rgba) SK_R32_SHIFT SK_G32_SHIFT SK_B32_SHIFT SK_A32_SHIFT
- #define SK_OSMESA_COLOR_ORDER OSMESA_RGBA
-#endif
-
-bool SkEGLContext::init(const int width, const int height) {
- /* Create an RGBA-mode context */
-#if OSMESA_MAJOR_VERSION * 100 + OSMESA_MINOR_VERSION >= 305
- /* specify Z, stencil, accum sizes */
- OSMesaContext ctx = OSMesaCreateContextExt(SK_OSMESA_COLOR_ORDER, 16, 0, 0, NULL);
-#else
- OSMesaContext ctx = OSMesaCreateContext(SK_OSMESA_COLOR_ORDER, NULL);
-#endif
- if (!ctx) {
- SkDebugf("OSMesaCreateContext failed!\n");
- return false;
- }
- this->context = ctx;
-
- // Allocate the image buffer
- GLfloat *buffer = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- if (!buffer) {
- SkDebugf("Alloc image buffer failed!\n");
- return false;
- }
- this->image = buffer;
-
- // Bind the buffer to the context and make it current
- if (!OSMesaMakeCurrent(ctx, buffer, GL_FLOAT, width, height)) {
- SkDebugf("OSMesaMakeCurrent failed!\n");
- return false;
- }
-
- //Setup the framebuffers
- SK_GL_DECL_PROC(PFNGLGENFRAMEBUFFERSEXTPROC, glGenFramebuffers)
- SK_GL_DECL_PROC(PFNGLBINDFRAMEBUFFEREXTPROC, glBindFramebuffer)
- SK_GL_DECL_PROC(PFNGLGENRENDERBUFFERSPROC, glGenRenderbuffers)
- SK_GL_DECL_PROC(PFNGLBINDRENDERBUFFERPROC, glBindRenderbuffer)
- SK_GL_DECL_PROC(PFNGLRENDERBUFFERSTORAGEPROC, glRenderbufferStorage)
- SK_GL_DECL_PROC(PFNGLFRAMEBUFFERRENDERBUFFERPROC, glFramebufferRenderbuffer)
- SK_GL_DECL_PROC(PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC, glCheckFramebufferStatus)
-
- const GLubyte* glExts = glGetString(GL_EXTENSIONS);
- if (gluCheckExtension(
- reinterpret_cast<const GLubyte*>("GL_ARB_framebuffer_object")
- , glExts))
- {
- SK_GL_GET_PROC(PFNGLGENFRAMEBUFFERSEXTPROC, glGenFramebuffers)
- SK_GL_GET_PROC(PFNGLBINDFRAMEBUFFEREXTPROC, glBindFramebuffer)
- SK_GL_GET_PROC(PFNGLGENRENDERBUFFERSPROC, glGenRenderbuffers)
- SK_GL_GET_PROC(PFNGLBINDRENDERBUFFERPROC, glBindRenderbuffer)
- SK_GL_GET_PROC(PFNGLRENDERBUFFERSTORAGEPROC, glRenderbufferStorage)
- SK_GL_GET_PROC(PFNGLFRAMEBUFFERRENDERBUFFERPROC, glFramebufferRenderbuffer)
- SK_GL_GET_PROC(PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC, glCheckFramebufferStatus)
-
- //osmesa on mac currently only supports EXT
- } else if (gluCheckExtension(
- reinterpret_cast<const GLubyte*>("GL_EXT_framebuffer_object")
- , glExts))
- {
- SK_GL_GET_EXT_PROC(PFNGLGENFRAMEBUFFERSEXTPROC, glGenFramebuffers)
- SK_GL_GET_EXT_PROC(PFNGLBINDFRAMEBUFFEREXTPROC, glBindFramebuffer)
- SK_GL_GET_EXT_PROC(PFNGLGENRENDERBUFFERSPROC, glGenRenderbuffers)
- SK_GL_GET_EXT_PROC(PFNGLBINDRENDERBUFFERPROC, glBindRenderbuffer)
- SK_GL_GET_EXT_PROC(PFNGLRENDERBUFFERSTORAGEPROC, glRenderbufferStorage)
- SK_GL_GET_EXT_PROC(PFNGLFRAMEBUFFERRENDERBUFFERPROC, glFramebufferRenderbuffer)
- SK_GL_GET_EXT_PROC(PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC, glCheckFramebufferStatus)
- } else {
- SkDebugf("GL_ARB_framebuffer_object not found.\n");
- return false;
- }
-
- GLuint cbID;
- GLuint dsID;
- glGenFramebuffers_func(1, &fFBO);
- glBindFramebuffer_func(GL_FRAMEBUFFER, fFBO);
-
- glGenRenderbuffers_func(1, &cbID);
- glBindRenderbuffer_func(GL_RENDERBUFFER, cbID);
- glRenderbufferStorage_func(GL_RENDERBUFFER, OSMESA_RGBA, width, height);
- glFramebufferRenderbuffer_func(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, cbID);
-
- glGenRenderbuffers_func(1, &dsID);
- glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, dsID);
- glRenderbufferStorage_func(GL_RENDERBUFFER, GL_STENCIL_INDEX8, width, height);
- glFramebufferRenderbuffer_func(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, dsID);
-
- glViewport(0, 0, width, height);
- glClearStencil(0);
- glClear(GL_STENCIL_BUFFER_BIT);
-
- GLenum status = glCheckFramebufferStatus_func(GL_FRAMEBUFFER);
- return GL_FRAMEBUFFER_COMPLETE == status;
-}