aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils
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
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')
-rw-r--r--src/utils/SkEGLContext_none.cpp19
-rw-r--r--src/utils/mac/SkEGLContext_mac.cpp77
-rw-r--r--src/utils/mesa/SkEGLContext_Mesa.cpp137
-rw-r--r--src/utils/unix/SkEGLContext_Unix.cpp275
-rw-r--r--src/utils/win/SkEGLContext_Win.cpp202
5 files changed, 0 insertions, 710 deletions
diff --git a/src/utils/SkEGLContext_none.cpp b/src/utils/SkEGLContext_none.cpp
deleted file mode 100644
index 52ea5efe6d..0000000000
--- a/src/utils/SkEGLContext_none.cpp
+++ /dev/null
@@ -1,19 +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"
-
-SkEGLContext::SkEGLContext()
- : fFBO(0) {
-}
-
-SkEGLContext::~SkEGLContext() {
-}
-
-bool SkEGLContext::init(int width, int height) {
- return false;
-}
diff --git a/src/utils/mac/SkEGLContext_mac.cpp b/src/utils/mac/SkEGLContext_mac.cpp
deleted file mode 100644
index bb96840089..0000000000
--- a/src/utils/mac/SkEGLContext_mac.cpp
+++ /dev/null
@@ -1,77 +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 <AGL/agl.h>
-
-SkEGLContext::SkEGLContext()
- : fFBO(0)
- , context(NULL) {
-}
-
-SkEGLContext::~SkEGLContext() {
- if (this->context) {
- aglDestroyContext(this->context);
- }
-}
-
-bool SkEGLContext::init(int width, int height) {
- GLint major, minor;
- AGLContext ctx;
-
- aglGetVersion(&major, &minor);
- //SkDebugf("---- agl version %d %d\n", major, minor);
-
- const GLint pixelAttrs[] = {
- AGL_RGBA,
- AGL_STENCIL_SIZE, 8,
-/*
- AGL_SAMPLE_BUFFERS_ARB, 1,
- AGL_MULTISAMPLE,
- AGL_SAMPLES_ARB, 2,
-*/
- AGL_ACCELERATED,
- AGL_NONE
- };
- AGLPixelFormat format = aglChoosePixelFormat(NULL, 0, pixelAttrs);
- //AGLPixelFormat format = aglCreatePixelFormat(pixelAttrs);
- //SkDebugf("----- agl format %p\n", format);
- ctx = aglCreateContext(format, NULL);
- //SkDebugf("----- agl context %p\n", ctx);
- aglDestroyPixelFormat(format);
-
-/*
- static const GLint interval = 1;
- aglSetInteger(ctx, AGL_SWAP_INTERVAL, &interval);
-*/
-
- aglSetCurrentContext(ctx);
- this->context = ctx;
-
- // Now create our FBO render target
-
- GLuint cbID;
- GLuint dsID;
- glGenFramebuffersEXT(1, &fFBO);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fFBO);
- glGenRenderbuffersEXT(1, &cbID);
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, cbID);
- glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA, width, height);
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, cbID);
- glGenRenderbuffersEXT(1, &dsID);
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, dsID);
- glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_STENCIL_EXT, width, height);
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, dsID);
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, dsID);
- glViewport(0, 0, width, height);
- glClearStencil(0);
- glClear(GL_STENCIL_BUFFER_BIT);
-
- GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
- return GL_FRAMEBUFFER_COMPLETE_EXT == status;
-}
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;
-}
diff --git a/src/utils/unix/SkEGLContext_Unix.cpp b/src/utils/unix/SkEGLContext_Unix.cpp
deleted file mode 100644
index 40a1b5d366..0000000000
--- a/src/utils/unix/SkEGLContext_Unix.cpp
+++ /dev/null
@@ -1,275 +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/gl.h>
-#include <GL/glext.h>
-#include <GL/glu.h>
-#include <GL/glx.h>
-#include <X11/Xlib.h>
-
-#define SK_GL_GET_PROC(T, F) T F = NULL; \
- F = (T) glXGetProcAddressARB(reinterpret_cast<const GLubyte*>(#F));
-
-static bool ctxErrorOccurred = false;
-static int ctxErrorHandler(Display *dpy, XErrorEvent *ev) {
- ctxErrorOccurred = true;
- return 0;
-}
-
-SkEGLContext::SkEGLContext()
- : fFBO(0)
- , context(NULL)
- , display(NULL)
- , pixmap(0)
- , glxPixmap(0) {
-}
-
-SkEGLContext::~SkEGLContext() {
- if (this->display) {
- glXMakeCurrent(this->display, 0, 0);
-
- if (this->context)
- glXDestroyContext(this->display, this->context);
-
- if (this->glxPixmap)
- glXDestroyGLXPixmap(this->display, this->glxPixmap);
-
- if (this->pixmap)
- XFreePixmap(this->display, this->pixmap);
-
- XCloseDisplay(this->display);
- }
-}
-
-bool SkEGLContext::init(const int width, const int height) {
- Display *display = XOpenDisplay(0);
- this->display = display;
-
- if (!display) {
- SkDebugf("Failed to open X display.\n");
- return false;
- }
-
- // Get a matching FB config
- static int visual_attribs[] = {
- GLX_X_RENDERABLE , True,
- GLX_DRAWABLE_TYPE , GLX_PIXMAP_BIT,
- GLX_RENDER_TYPE , GLX_RGBA_BIT,
- GLX_X_VISUAL_TYPE , GLX_TRUE_COLOR,
- GLX_RED_SIZE , 8,
- GLX_GREEN_SIZE , 8,
- GLX_BLUE_SIZE , 8,
- GLX_ALPHA_SIZE , 8,
- GLX_DEPTH_SIZE , 24,
- GLX_STENCIL_SIZE , 8,
- GLX_DOUBLEBUFFER , True,
- //GLX_SAMPLE_BUFFERS , 1,
- //GLX_SAMPLES , 4,
- None
- };
-
- int glx_major, glx_minor;
-
- // FBConfigs were added in GLX version 1.3.
- if (!glXQueryVersion( display, &glx_major, &glx_minor) ||
- ( (glx_major == 1) && (glx_minor < 3) ) || (glx_major < 1))
- {
- SkDebugf("Invalid GLX version.");
- return false;
- }
-
- //SkDebugf("Getting matching framebuffer configs.\n");
- int fbcount;
- GLXFBConfig *fbc = glXChooseFBConfig(display, DefaultScreen(display),
- visual_attribs, &fbcount);
- if (!fbc) {
- SkDebugf("Failed to retrieve a framebuffer config.\n");
- return false;
- }
- //SkDebugf("Found %d matching FB configs.\n", fbcount);
-
- // Pick the FB config/visual with the most samples per pixel
- //SkDebugf("Getting XVisualInfos.\n");
- int best_fbc = -1, worst_fbc = -1, best_num_samp = -1, worst_num_samp = 999;
-
- int i;
- for (i = 0; i < fbcount; ++i) {
- XVisualInfo *vi = glXGetVisualFromFBConfig(display, fbc[i]);
- if (vi) {
- int samp_buf, samples;
- glXGetFBConfigAttrib(display, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf);
- glXGetFBConfigAttrib(display, fbc[i], GLX_SAMPLES, &samples);
-
- //SkDebugf(" Matching fbconfig %d, visual ID 0x%2x: SAMPLE_BUFFERS = %d,"
- // " SAMPLES = %d\n",
- // i, (unsigned int)vi->visualid, samp_buf, samples);
-
- if (best_fbc < 0 || (samp_buf && samples > best_num_samp))
- best_fbc = i, best_num_samp = samples;
- if (worst_fbc < 0 || !samp_buf || samples < worst_num_samp)
- worst_fbc = i, worst_num_samp = samples;
- }
- XFree(vi);
- }
-
- GLXFBConfig bestFbc = fbc[best_fbc];
-
- // Be sure to free the FBConfig list allocated by glXChooseFBConfig()
- XFree(fbc);
-
- // Get a visual
- XVisualInfo *vi = glXGetVisualFromFBConfig(display, bestFbc);
- //SkDebugf("Chosen visual ID = 0x%x\n", (unsigned int)vi->visualid);
-
- Pixmap pixmap = XCreatePixmap(
- display, RootWindow(display, vi->screen), width, height, vi->depth
- );
-
- this->pixmap = pixmap;
- if (!pixmap) {
- SkDebugf("Failed to create pixmap.\n");
- return false;
- }
-
- GLXPixmap glxPixmap = glXCreateGLXPixmap(display, vi, pixmap);
- this->glxPixmap = glxPixmap;
-
- // Done with the visual info data
- XFree(vi);
-
- // Create the context
- GLXContext ctx = 0;
-
- // Install an X error handler so the application won't exit if GL 3.0
- // context allocation fails.
- //
- // Note this error handler is global.
- // All display connections in all threads of a process use the same
- // error handler, so be sure to guard against other threads issuing
- // X commands while this code is running.
- ctxErrorOccurred = false;
- int (*oldHandler)(Display*, XErrorEvent*) =
- XSetErrorHandler(&ctxErrorHandler);
-
- // Get the default screen's GLX extension list
- const char *glxExts = glXQueryExtensionsString(
- display, DefaultScreen(display)
- );
- // Check for the GLX_ARB_create_context extension string and the function.
- // If either is not present, use GLX 1.3 context creation method.
- if (!gluCheckExtension(
- reinterpret_cast<const GLubyte*>("GLX_ARB_create_context")
- , reinterpret_cast<const GLubyte*>(glxExts)))
- {
- //SkDebugf("GLX_ARB_create_context not found."
- // " Using old-style GLX context.\n");
- ctx = glXCreateNewContext(display, bestFbc, GLX_RGBA_TYPE, 0, True);
-
- } else {
- //SkDebugf("Creating context.\n");
-
- SK_GL_GET_PROC(PFNGLXCREATECONTEXTATTRIBSARBPROC, glXCreateContextAttribsARB)
- int context_attribs[] = {
- GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
- GLX_CONTEXT_MINOR_VERSION_ARB, 0,
- //GLX_CONTEXT_FLAGS_ARB , GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
- None
- };
- ctx = glXCreateContextAttribsARB(
- display, bestFbc, 0, True, context_attribs
- );
-
- // Sync to ensure any errors generated are processed.
- XSync(display, False);
- if (!ctxErrorOccurred && ctx) {
- //SkDebugf( "Created GL 3.0 context.\n" );
- } else {
- // Couldn't create GL 3.0 context.
- // Fall back to old-style 2.x context.
- // When a context version below 3.0 is requested,
- // implementations will return the newest context version compatible
- // with OpenGL versions less than version 3.0.
-
- // GLX_CONTEXT_MAJOR_VERSION_ARB = 1
- context_attribs[1] = 1;
- // GLX_CONTEXT_MINOR_VERSION_ARB = 0
- context_attribs[3] = 0;
-
- ctxErrorOccurred = false;
-
- //SkDebugf("Failed to create GL 3.0 context."
- // " Using old-style GLX context.\n");
- ctx = glXCreateContextAttribsARB(
- display, bestFbc, 0, True, context_attribs
- );
- }
- }
-
- // Sync to ensure any errors generated are processed.
- XSync(display, False);
-
- // Restore the original error handler
- XSetErrorHandler(oldHandler);
-
- if (ctxErrorOccurred || !ctx) {
- SkDebugf("Failed to create an OpenGL context.\n");
- return false;
- }
- this->context = ctx;
-
- // Verify that context is a direct context
- if (!glXIsDirect(display, ctx)) {
- //SkDebugf("Indirect GLX rendering context obtained.\n");
- } else {
- //SkDebugf("Direct GLX rendering context obtained.\n");
- }
-
- //SkDebugf("Making context current.\n");
- if (!glXMakeCurrent(display, glxPixmap, ctx)) {
- SkDebugf("Could not set the context.\n");
- return false;
- }
-
- //Setup the framebuffers
- const GLubyte* glExts = glGetString(GL_EXTENSIONS);
- if (!gluCheckExtension(
- reinterpret_cast<const GLubyte*>("GL_EXT_framebuffer_object")
- , glExts))
- {
- SkDebugf("GL_EXT_framebuffer_object not found.\n");
- return false;
- }
- SK_GL_GET_PROC(PFNGLGENFRAMEBUFFERSEXTPROC, glGenFramebuffersEXT)
- SK_GL_GET_PROC(PFNGLBINDFRAMEBUFFEREXTPROC, glBindFramebufferEXT)
- SK_GL_GET_PROC(PFNGLGENRENDERBUFFERSPROC, glGenRenderbuffersEXT)
- SK_GL_GET_PROC(PFNGLBINDRENDERBUFFERPROC, glBindRenderbufferEXT)
- SK_GL_GET_PROC(PFNGLRENDERBUFFERSTORAGEPROC, glRenderbufferStorageEXT)
- SK_GL_GET_PROC(PFNGLFRAMEBUFFERRENDERBUFFERPROC, glFramebufferRenderbufferEXT)
- SK_GL_GET_PROC(PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC, glCheckFramebufferStatusEXT)
-
- GLuint cbID;
- GLuint dsID;
- glGenFramebuffersEXT(1, &fFBO);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fFBO);
- glGenRenderbuffersEXT(1, &cbID);
- glBindRenderbufferEXT(GL_RENDERBUFFER, cbID);
- glRenderbufferStorageEXT(GL_RENDERBUFFER, GL_RGBA, width, height);
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, cbID);
- glGenRenderbuffersEXT(1, &dsID);
- glBindRenderbufferEXT(GL_RENDERBUFFER, dsID);
- glRenderbufferStorageEXT(GL_RENDERBUFFER, GL_DEPTH_STENCIL, width, height);
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, dsID);
- glViewport(0, 0, width, height);
- glClearStencil(0);
- glClear(GL_STENCIL_BUFFER_BIT);
-
- GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER);
- return GL_FRAMEBUFFER_COMPLETE == status;
-}
diff --git a/src/utils/win/SkEGLContext_Win.cpp b/src/utils/win/SkEGLContext_Win.cpp
deleted file mode 100644
index b82e7d7ff6..0000000000
--- a/src/utils/win/SkEGLContext_Win.cpp
+++ /dev/null
@@ -1,202 +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.
- */
-#define WIN32_LEAN_AND_MEAN 1
-#include <Windows.h>
-#include <GL/GL.h>
-
-#include "SkEGLContext.h"
-#include "SkTypes.h"
-
-#define SK_EGL_DECLARE_PROC(F) SkEGL ## F ## Proc SkEGL ## F = NULL;
-#define SK_EGL_GET_PROC(F) SkEGL ## F = (SkEGL ## F ## Proc) \
- wglGetProcAddress("gl" #F);
-#define SK_EGL_GET_PROC_SUFFIX(F, S) SkEGL ## F = (SkEGL ## F ## Proc) \
- wglGetProcAddress("gl" #F #S);
-
-#define SK_EGL_FRAMEBUFFER 0x8D40
-#define SK_EGL_RENDERBUFFER 0x8D41
-#define SK_EGL_COLOR_ATTACHMENT0 0x8CE0
-#define SK_EGL_DEPTH_STENCIL 0x84F9
-#define SK_EGL_DEPTH_STENCIL_ATTACHMENT 0x821A
-#define SK_EGL_FRAMEBUFFER_COMPLETE 0x8CD5
-
-#define SK_EGL_FUNCTION_TYPE __stdcall
-typedef void (SK_EGL_FUNCTION_TYPE *SkEGLGenFramebuffersProc) (GLsizei n, GLuint *framebuffers);
-typedef void (SK_EGL_FUNCTION_TYPE *SkEGLBindFramebufferProc) (GLenum target, GLuint framebuffer);
-typedef void (SK_EGL_FUNCTION_TYPE *SkEGLGenRenderbuffersProc) (GLsizei n, GLuint *renderbuffers);
-typedef void (SK_EGL_FUNCTION_TYPE *SkEGLBindRenderbufferProc) (GLenum target, GLuint renderbuffer);
-typedef void (SK_EGL_FUNCTION_TYPE *SkEGLRenderbufferStorageProc) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (SK_EGL_FUNCTION_TYPE *SkEGLFramebufferRenderbufferProc) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-typedef GLenum (SK_EGL_FUNCTION_TYPE *SkEGLCheckFramebufferStatusProc) (GLenum target);
-
-SkEGLContext::SkEGLContext()
- : fFBO(0)
- , fWindow(NULL)
- , fDeviceContext(NULL)
- , fGlRenderContext(0) {
-}
-
-SkEGLContext::~SkEGLContext() {
- if (this->fGlRenderContext) {
- wglDeleteContext(this->fGlRenderContext);
- }
- if (this->fWindow && this->fDeviceContext) {
- ReleaseDC(this->fWindow, this->fDeviceContext);
- }
- if (this->fWindow) {
- DestroyWindow(this->fWindow);
- }
-}
-
-bool skEGLCheckExtension(const char* ext,
- const char* extensionString) {
- int extLength = strlen(ext);
-
- while (true) {
- int n = strcspn(extensionString, " ");
- if (n == extLength && 0 == strncmp(ext, extensionString, n)) {
- return true;
- }
- if (0 == extensionString[n]) {
- return false;
- }
- extensionString += n+1;
- }
-
- return false;
-}
-
-bool SkEGLContext::init(const int width, const int height) {
- HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL);
-
- WNDCLASS wc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hbrBackground = NULL;
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.hInstance = hInstance;
- wc.lpfnWndProc = (WNDPROC) DefWindowProc;
- wc.lpszClassName = TEXT("Griffin");
- wc.lpszMenuName = NULL;
- wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
-
- if (!RegisterClass(&wc)) {
- SkDebugf("Could not register window class.\n");
- return false;
- }
-
- if (!(
- this->fWindow = CreateWindow(
- TEXT("Griffin"),
- TEXT("The Invisible Man"),
- WS_OVERLAPPEDWINDOW,
- 10, 10, // x, y
- 200, 200, // width, height
- NULL, NULL, // parent, menu
- hInstance, NULL) // hInstance, param
- ))
- {
- SkDebugf("Could not create window.\n");
- return false;
- }
-
- if (!(this->fDeviceContext = GetDC(this->fWindow))) {
- SkDebugf("Could not get device context.\n");
- return false;
- }
-
- PIXELFORMATDESCRIPTOR pfd;
- ZeroMemory(&pfd, sizeof(pfd));
- pfd.nSize = sizeof(pfd);
- pfd.nVersion = 1;
- pfd.dwFlags = PFD_DRAW_TO_WINDOW |
- PFD_SUPPORT_OPENGL |
- PFD_DOUBLEBUFFER;
- pfd.iPixelType = PFD_TYPE_RGBA;
- pfd.cColorBits = 32;
- pfd.cDepthBits = 24;
- pfd.cStencilBits = 8;
- pfd.iLayerType = PFD_MAIN_PLANE;
-
- int pixelFormat = 0;
- if (!(pixelFormat = ChoosePixelFormat(this->fDeviceContext, &pfd))) {
- SkDebugf("No matching pixel format descriptor.\n");
- return false;
- }
-
- if (!SetPixelFormat(this->fDeviceContext, pixelFormat, &pfd)) {
- SkDebugf("Could not set the pixel format %d.\n", pixelFormat);
- return false;
- }
-
- if (!(this->fGlRenderContext = wglCreateContext(this->fDeviceContext))) {
- SkDebugf("Could not create rendering context.\n");
- return false;
- }
-
- if (!(wglMakeCurrent(this->fDeviceContext, this->fGlRenderContext))) {
- SkDebugf("Could not set the context.\n");
- return false;
- }
-
- //TODO: in the future we need to use this context
- // to test for WGL_ARB_create_context
- // and then create a new window / context.
-
- //Setup the framebuffers
- const char* glExts =
- reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS));
- if (!skEGLCheckExtension(
- "GL_EXT_framebuffer_object"
- , glExts))
- {
- SkDebugf("GL_EXT_framebuffer_object not found.\n");
- return false;
- }
- SK_EGL_DECLARE_PROC(GenFramebuffers)
- SK_EGL_DECLARE_PROC(BindFramebuffer)
- SK_EGL_DECLARE_PROC(GenRenderbuffers)
- SK_EGL_DECLARE_PROC(BindRenderbuffer)
- SK_EGL_DECLARE_PROC(RenderbufferStorage)
- SK_EGL_DECLARE_PROC(FramebufferRenderbuffer)
- SK_EGL_DECLARE_PROC(CheckFramebufferStatus)
-
- SK_EGL_GET_PROC_SUFFIX(GenFramebuffers, EXT)
- SK_EGL_GET_PROC_SUFFIX(BindFramebuffer, EXT)
- SK_EGL_GET_PROC_SUFFIX(GenRenderbuffers, EXT)
- SK_EGL_GET_PROC_SUFFIX(BindRenderbuffer, EXT)
- SK_EGL_GET_PROC_SUFFIX(RenderbufferStorage, EXT)
- SK_EGL_GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT)
- SK_EGL_GET_PROC_SUFFIX(CheckFramebufferStatus, EXT)
-
- GLuint cbID;
- GLuint dsID;
- SkEGLGenFramebuffers(1, &fFBO);
- SkEGLBindFramebuffer(SK_EGL_FRAMEBUFFER, fFBO);
- SkEGLGenRenderbuffers(1, &cbID);
- SkEGLBindRenderbuffer(SK_EGL_RENDERBUFFER, cbID);
- SkEGLRenderbufferStorage(SK_EGL_RENDERBUFFER, GL_RGBA, width, height);
- SkEGLFramebufferRenderbuffer(SK_EGL_FRAMEBUFFER
- , SK_EGL_COLOR_ATTACHMENT0
- , SK_EGL_RENDERBUFFER, cbID);
- SkEGLGenRenderbuffers(1, &dsID);
- SkEGLBindRenderbuffer(SK_EGL_RENDERBUFFER, dsID);
- SkEGLRenderbufferStorage(SK_EGL_RENDERBUFFER, SK_EGL_DEPTH_STENCIL
- , width, height);
- SkEGLFramebufferRenderbuffer(SK_EGL_FRAMEBUFFER
- , SK_EGL_DEPTH_STENCIL_ATTACHMENT
- , SK_EGL_RENDERBUFFER
- , dsID);
- glViewport(0, 0, width, height);
- glClearStencil(0);
- glClear(GL_STENCIL_BUFFER_BIT);
-
- GLenum status = SkEGLCheckFramebufferStatus(SK_EGL_FRAMEBUFFER);
- return SK_EGL_FRAMEBUFFER_COMPLETE == status;
-}