aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
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 /include
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 'include')
-rw-r--r--include/gpu/GrContextFactory.h10
-rw-r--r--include/gpu/gl/SkANGLEGLContext.h15
-rw-r--r--include/gpu/gl/SkDebugGLContext.h4
-rw-r--r--include/gpu/gl/SkGLContextHelper.h (renamed from include/gpu/gl/SkGLContext.h)20
-rw-r--r--include/gpu/gl/SkMesaGLContext.h17
-rw-r--r--include/gpu/gl/SkNativeGLContext.h111
-rw-r--r--include/gpu/gl/SkNullGLContext.h4
7 files changed, 154 insertions, 27 deletions
diff --git a/include/gpu/GrContextFactory.h b/include/gpu/GrContextFactory.h
index eff1f5834c..d78120ccb0 100644
--- a/include/gpu/GrContextFactory.h
+++ b/include/gpu/GrContextFactory.h
@@ -15,7 +15,7 @@
#if SK_MESA
#include "gl/SkMesaGLContext.h"
#endif
-#include "gl/SkGLContext.h"
+#include "gl/SkNativeGLContext.h"
#include "gl/SkNullGLContext.h"
#include "GrContext.h"
@@ -130,12 +130,12 @@ public:
return fContexts[i].fGrContext;
}
}
- SkAutoTUnref<SkGLContext> glCtx;
+ SkAutoTUnref<SkGLContextHelper> glCtx;
SkAutoTUnref<GrContext> grCtx;
switch (type) {
case kNVPR_GLContextType: // fallthru
case kNative_GLContextType:
- glCtx.reset(SkCreatePlatformGLContext());
+ glCtx.reset(SkNEW(SkNativeGLContext));
break;
#ifdef SK_ANGLE
case kANGLE_GLContextType:
@@ -192,7 +192,7 @@ public:
// Returns the GLContext of the given type. If it has not been created yet,
// NULL is returned instead.
- SkGLContext* getGLContext(GLContextType type) {
+ SkGLContextHelper* getGLContext(GLContextType type) {
for (int i = 0; i < fContexts.count(); ++i) {
if (fContexts[i].fType == type) {
return fContexts[i].fGLContext;
@@ -207,7 +207,7 @@ public:
private:
struct GPUContext {
GLContextType fType;
- SkGLContext* fGLContext;
+ SkGLContextHelper* fGLContext;
GrContext* fGrContext;
};
SkTArray<GPUContext, true> fContexts;
diff --git a/include/gpu/gl/SkANGLEGLContext.h b/include/gpu/gl/SkANGLEGLContext.h
index 18cdbdb213..c5f62ff3ce 100644
--- a/include/gpu/gl/SkANGLEGLContext.h
+++ b/include/gpu/gl/SkANGLEGLContext.h
@@ -10,12 +10,12 @@
#if SK_ANGLE
-#include "SkGLContext.h"
+#include "SkGLContextHelper.h"
#include <GLES2/gl2.h>
#include <EGL/egl.h>
-class SkANGLEGLContext : public SkGLContext {
+class SkANGLEGLContext : public SkGLContextHelper {
public:
SkANGLEGLContext();
@@ -24,6 +24,17 @@ public:
virtual void makeCurrent() const SK_OVERRIDE;
virtual void swapBuffers() const SK_OVERRIDE;
+ class AutoContextRestore {
+ public:
+ AutoContextRestore();
+ ~AutoContextRestore();
+
+ private:
+ EGLContext fOldEGLContext;
+ EGLDisplay fOldDisplay;
+ EGLSurface fOldSurface;
+ };
+
protected:
virtual const GrGLInterface* createGLContext(
GrGLStandard forcedGpuAPI) SK_OVERRIDE;
diff --git a/include/gpu/gl/SkDebugGLContext.h b/include/gpu/gl/SkDebugGLContext.h
index 792666332e..7db9579617 100644
--- a/include/gpu/gl/SkDebugGLContext.h
+++ b/include/gpu/gl/SkDebugGLContext.h
@@ -8,9 +8,9 @@
#ifndef SkDebugGLContext_DEFINED
#define SkDebugGLContext_DEFINED
-#include "SkGLContext.h"
+#include "SkGLContextHelper.h"
-class SkDebugGLContext : public SkGLContext {
+class SkDebugGLContext : public SkGLContextHelper {
public:
SkDebugGLContext() {}
diff --git a/include/gpu/gl/SkGLContext.h b/include/gpu/gl/SkGLContextHelper.h
index 83c9146c9b..c4d9bdf997 100644
--- a/include/gpu/gl/SkGLContext.h
+++ b/include/gpu/gl/SkGLContextHelper.h
@@ -5,8 +5,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#ifndef SkGLContext_DEFINED
-#define SkGLContext_DEFINED
+#ifndef SkGLContextHelper_DEFINED
+#define SkGLContextHelper_DEFINED
#include "GrGLInterface.h"
@@ -15,12 +15,12 @@
* Provides a GrGLInterface struct of function pointers for the context.
*/
-class SK_API SkGLContext : public SkRefCnt {
+class SK_API SkGLContextHelper : public SkRefCnt {
public:
- SK_DECLARE_INST_COUNT(SkGLContext)
+ SK_DECLARE_INST_COUNT(SkGLContextHelper)
- SkGLContext();
- virtual ~SkGLContext();
+ SkGLContextHelper();
+ virtual ~SkGLContextHelper();
/**
* Initializes the context and makes it current.
@@ -81,14 +81,6 @@ private:
typedef SkRefCnt INHERITED;
};
-/** Creates platform-dependent GL context object
- * Note: If Skia embedder needs a custom GL context that sets up the GL
- * interface, this function should be implemented by the embedder.
- * Otherwise, the default implementation for the platform should be compiled in
- * the library.
- */
-SK_API SkGLContext* SkCreatePlatformGLContext();
-
/**
* Helper macros for using the GL context through the GrGLInterface. Example:
* SK_GL(glCtx, GenTextures(1, &texID));
diff --git a/include/gpu/gl/SkMesaGLContext.h b/include/gpu/gl/SkMesaGLContext.h
index ef0017180c..28349ddd88 100644
--- a/include/gpu/gl/SkMesaGLContext.h
+++ b/include/gpu/gl/SkMesaGLContext.h
@@ -8,11 +8,11 @@
#ifndef SkMesaGLContext_DEFINED
#define SkMesaGLContext_DEFINED
-#include "SkGLContext.h"
+#include "SkGLContextHelper.h"
#if SK_MESA
-class SkMesaGLContext : public SkGLContext {
+class SkMesaGLContext : public SkGLContextHelper {
private:
typedef intptr_t Context;
@@ -24,6 +24,19 @@ public:
virtual void makeCurrent() const SK_OVERRIDE;
virtual void swapBuffers() const SK_OVERRIDE;
+ class AutoContextRestore {
+ public:
+ AutoContextRestore();
+ ~AutoContextRestore();
+
+ private:
+ Context fOldContext;
+ GrGLint fOldWidth;
+ GrGLint fOldHeight;
+ GrGLint fOldFormat;
+ void* fOldImage;
+ };
+
protected:
virtual const GrGLInterface* createGLContext(GrGLStandard forcedGpuAPI) SK_OVERRIDE;
virtual void destroyGLContext() SK_OVERRIDE;
diff --git a/include/gpu/gl/SkNativeGLContext.h b/include/gpu/gl/SkNativeGLContext.h
new file mode 100644
index 0000000000..93b5b4183a
--- /dev/null
+++ b/include/gpu/gl/SkNativeGLContext.h
@@ -0,0 +1,111 @@
+
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef SkNativeGLContext_DEFINED
+#define SkNativeGLContext_DEFINED
+
+#include "SkGLContextHelper.h"
+
+/* This struct is taken from a mesa demo. Please update as required */
+static const struct { int major, minor; } gl_versions[] = {
+ {1, 0},
+ {1, 1},
+ {1, 2},
+ {1, 3},
+ {1, 4},
+ {1, 5},
+ {2, 0},
+ {2, 1},
+ {3, 0},
+ {3, 1},
+ {3, 2},
+ {3, 3},
+ {4, 0},
+ {4, 1},
+ {4, 2},
+ {4, 3},
+ {4, 4},
+ {0, 0} /* end of list */
+};
+#define NUM_GL_VERSIONS SK_ARRAY_COUNT(gl_versions)
+
+#if defined(SK_BUILD_FOR_MAC)
+ #include <OpenGL/OpenGL.h>
+#elif SK_EGL
+ #include <GLES2/gl2.h>
+ #include <EGL/egl.h>
+#elif defined(SK_BUILD_FOR_UNIX)
+ #include <X11/Xlib.h>
+ #include <GL/glx.h>
+#elif defined(SK_BUILD_FOR_WIN32)
+ #include <windows.h>
+ #include <GL/GL.h>
+ #include "SkWGL.h"
+#endif
+
+class SkNativeGLContext : public SkGLContextHelper {
+public:
+ SkNativeGLContext();
+
+ virtual ~SkNativeGLContext();
+
+ virtual void makeCurrent() const SK_OVERRIDE;
+ virtual void swapBuffers() const SK_OVERRIDE;
+
+ class AutoContextRestore {
+ public:
+ AutoContextRestore();
+ ~AutoContextRestore();
+
+ private:
+ #if defined(SK_BUILD_FOR_MAC)
+ CGLContextObj fOldCGLContext;
+ #elif SK_EGL
+ EGLContext fOldEGLContext;
+ EGLDisplay fOldDisplay;
+ EGLSurface fOldSurface;
+ #elif defined(SK_BUILD_FOR_UNIX)
+ GLXContext fOldGLXContext;
+ Display* fOldDisplay;
+ GLXDrawable fOldDrawable;
+ #elif defined(SK_BUILD_FOR_WIN32)
+ HDC fOldHDC;
+ HGLRC fOldHGLRC;
+
+ #elif defined(SK_BUILD_FOR_IOS)
+ void* fEAGLContext;
+ #endif
+ };
+
+protected:
+ virtual const GrGLInterface* createGLContext(GrGLStandard forcedGpuAPI) SK_OVERRIDE;
+ virtual void destroyGLContext() SK_OVERRIDE;
+
+private:
+#if defined(SK_BUILD_FOR_MAC)
+ CGLContextObj fContext;
+#elif SK_EGL
+ EGLContext fContext;
+ EGLDisplay fDisplay;
+ EGLSurface fSurface;
+#elif defined(SK_BUILD_FOR_UNIX)
+ GLXContext fContext;
+ Display* fDisplay;
+ Pixmap fPixmap;
+ GLXPixmap fGlxPixmap;
+#elif defined(SK_BUILD_FOR_WIN32)
+ HWND fWindow;
+ HDC fDeviceContext;
+ HGLRC fGlRenderContext;
+ static ATOM gWC;
+ SkWGLPbufferContext* fPbufferContext;
+#elif defined(SK_BUILD_FOR_IOS)
+ void* fEAGLContext;
+#endif
+};
+
+#endif
diff --git a/include/gpu/gl/SkNullGLContext.h b/include/gpu/gl/SkNullGLContext.h
index 16621fc696..6c2a1d7e59 100644
--- a/include/gpu/gl/SkNullGLContext.h
+++ b/include/gpu/gl/SkNullGLContext.h
@@ -8,9 +8,9 @@
#ifndef SkNullGLContext_DEFINED
#define SkNullGLContext_DEFINED
-#include "SkGLContext.h"
+#include "SkGLContextHelper.h"
-class SK_API SkNullGLContext : public SkGLContext {
+class SK_API SkNullGLContext : public SkGLContextHelper {
public:
SkNullGLContext() {};