aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar djsollen <djsollen@google.com>2014-11-13 11:12:41 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-13 11:12:41 -0800
commite4545210c950f98d9fa20f51bc1be6c5591534bd (patch)
tree0485f434709c8c1ad9ffb43ea5a63e5c013fc71b
parent912c9ec6ee8e28724861f0ac2b746e970895f745 (diff)
Cleanup GrContextFactory and make it's subclasses private
-rw-r--r--gyp/gpu.gypi9
-rw-r--r--gyp/gputest.gyp2
-rw-r--r--gyp/tools.gyp3
-rwxr-xr-xsrc/gpu/GrContextFactory.cpp89
-rw-r--r--src/gpu/GrContextFactory.h (renamed from include/gpu/GrContextFactory.h)80
-rw-r--r--src/gpu/gl/SkNullGLContext.h (renamed from include/gpu/gl/SkNullGLContext.h)2
-rw-r--r--src/gpu/gl/angle/SkANGLEGLContext.cpp2
-rw-r--r--src/gpu/gl/angle/SkANGLEGLContext.h (renamed from include/gpu/gl/SkANGLEGLContext.h)2
-rw-r--r--src/gpu/gl/debug/SkDebugGLContext.cpp2
-rw-r--r--src/gpu/gl/debug/SkDebugGLContext.h (renamed from include/gpu/gl/SkDebugGLContext.h)2
-rw-r--r--src/gpu/gl/mesa/SkMesaGLContext.cpp2
-rw-r--r--src/gpu/gl/mesa/SkMesaGLContext.h (renamed from include/gpu/gl/SkMesaGLContext.h)2
12 files changed, 108 insertions, 89 deletions
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi
index 1bad40a6f7..ac56f4447b 100644
--- a/gyp/gpu.gypi
+++ b/gyp/gpu.gypi
@@ -14,7 +14,6 @@
'<(skia_include_path)/gpu/GrColor.h',
'<(skia_include_path)/gpu/GrConfig.h',
'<(skia_include_path)/gpu/GrContext.h',
- '<(skia_include_path)/gpu/GrContextFactory.h',
'<(skia_include_path)/gpu/GrCoordTransform.h',
'<(skia_include_path)/gpu/GrFontScaler.h',
'<(skia_include_path)/gpu/GrFragmentProcessor.h',
@@ -322,15 +321,15 @@
'<(skia_src_path)/gpu/gl/mesa/GrGLCreateMesaInterface.cpp',
# Sk files
- '<(skia_include_path)/gpu/gl/SkMesaGLContext.h',
'<(skia_src_path)/gpu/gl/mesa/SkMesaGLContext.cpp',
+ '<(skia_src_path)/gpu/gl/mesa/SkMesaGLContext.h',
],
'skgpu_angle_gl_sources': [
'<(skia_src_path)/gpu/gl/angle/GrGLCreateANGLEInterface.cpp',
# Sk files
- '<(skia_include_path)/gpu/gl/SkANGLEGLContext.h',
'<(skia_src_path)/gpu/gl/angle/SkANGLEGLContext.cpp',
+ '<(skia_src_path)/gpu/gl/angle/SkANGLEGLContext.h',
],
'skgpu_debug_gl_sources': [
'<(skia_src_path)/gpu/gl/debug/GrGLCreateDebugInterface.cpp',
@@ -354,15 +353,15 @@
'<(skia_src_path)/gpu/gl/debug/GrVertexArrayObj.h',
# Sk files
- '<(skia_include_path)/gpu/gl/SkDebugGLContext.h',
'<(skia_src_path)/gpu/gl/debug/SkDebugGLContext.cpp',
+ '<(skia_src_path)/gpu/gl/debug/SkDebugGLContext.h',
],
'skgpu_null_gl_sources': [
'<(skia_src_path)/gpu/gl/GrGLCreateNullInterface.cpp',
# Sk files
- '<(skia_include_path)/gpu/gl/SkNullGLContext.h',
'<(skia_src_path)/gpu/gl/SkNullGLContext.cpp',
+ '<(skia_src_path)/gpu/gl/SkNullGLContext.h',
],
},
}
diff --git a/gyp/gputest.gyp b/gyp/gputest.gyp
index da7722db96..5e8cca2ba4 100644
--- a/gyp/gputest.gyp
+++ b/gyp/gputest.gyp
@@ -20,6 +20,8 @@
],
},
'sources': [
+ '<(skia_src_path)/gpu/GrContextFactory.cpp',
+ '<(skia_src_path)/gpu/GrContextFactory.h',
'<(skia_src_path)/gpu/GrTest.cpp',
'<(skia_src_path)/gpu/GrTest.h',
],
diff --git a/gyp/tools.gyp b/gyp/tools.gyp
index dae1cf58c7..c1419dd195 100644
--- a/gyp/tools.gyp
+++ b/gyp/tools.gyp
@@ -473,6 +473,9 @@
'dependencies': [
'gputest.gyp:skgputest',
],
+ 'export_dependent_settings': [
+ 'gputest.gyp:skgputest',
+ ],
},
],
],
diff --git a/src/gpu/GrContextFactory.cpp b/src/gpu/GrContextFactory.cpp
new file mode 100755
index 0000000000..1a3864ac14
--- /dev/null
+++ b/src/gpu/GrContextFactory.cpp
@@ -0,0 +1,89 @@
+
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrContextFactory.h"
+
+#if SK_ANGLE
+ #include "gl/angle/SkANGLEGLContext.h"
+#endif
+#include "gl/debug/SkDebugGLContext.h"
+#if SK_MESA
+ #include "gl/mesa/SkMesaGLContext.h"
+#endif
+#include "gl/SkGLContext.h"
+#include "gl/SkNullGLContext.h"
+
+
+GrContext* GrContextFactory::get(GLContextType type, GrGLStandard forcedGpuAPI) {
+ for (int i = 0; i < fContexts.count(); ++i) {
+ if (forcedGpuAPI != kNone_GrGLStandard &&
+ forcedGpuAPI != fContexts[i].fGLContext->gl()->fStandard)
+ continue;
+
+ if (fContexts[i].fType == type) {
+ fContexts[i].fGLContext->makeCurrent();
+ return fContexts[i].fGrContext;
+ }
+ }
+ SkAutoTUnref<SkGLContext> glCtx;
+ SkAutoTUnref<GrContext> grCtx;
+ switch (type) {
+ case kNVPR_GLContextType: // fallthru
+ case kNative_GLContextType:
+ glCtx.reset(SkCreatePlatformGLContext(forcedGpuAPI));
+ break;
+#ifdef SK_ANGLE
+ case kANGLE_GLContextType:
+ glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI));
+ break;
+#endif
+#ifdef SK_MESA
+ case kMESA_GLContextType:
+ glCtx.reset(SkMesaGLContext::Create(forcedGpuAPI));
+ break;
+#endif
+ case kNull_GLContextType:
+ glCtx.reset(SkNullGLContext::Create(forcedGpuAPI));
+ break;
+ case kDebug_GLContextType:
+ glCtx.reset(SkDebugGLContext::Create(forcedGpuAPI));
+ break;
+ }
+ if (NULL == glCtx.get()) {
+ return NULL;
+ }
+
+ SkASSERT(glCtx->isValid());
+
+ // Ensure NVPR is available for the NVPR type and block it from other types.
+ SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl()));
+ if (kNVPR_GLContextType == type) {
+ if (!glInterface->hasExtension("GL_NV_path_rendering")) {
+ return NULL;
+ }
+ } else {
+ glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface));
+ if (!glInterface) {
+ return NULL;
+ }
+ }
+
+ glCtx->makeCurrent();
+ GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(glInterface.get());
+ grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, &fGlobalOptions));
+ if (!grCtx.get()) {
+ return NULL;
+ }
+ GPUContext& ctx = fContexts.push_back();
+ ctx.fGLContext = glCtx.get();
+ ctx.fGLContext->ref();
+ ctx.fGrContext = grCtx.get();
+ ctx.fGrContext->ref();
+ ctx.fType = type;
+ return ctx.fGrContext;
+}
diff --git a/include/gpu/GrContextFactory.h b/src/gpu/GrContextFactory.h
index 143ca31aad..353e3d9c96 100644
--- a/include/gpu/GrContextFactory.h
+++ b/src/gpu/GrContextFactory.h
@@ -8,17 +8,9 @@
#ifndef GrContextFactory_DEFINED
#define GrContextFactory_DEFINED
-#if SK_ANGLE
- #include "gl/SkANGLEGLContext.h"
-#endif
-#include "gl/SkDebugGLContext.h"
-#if SK_MESA
- #include "gl/SkMesaGLContext.h"
-#endif
-#include "gl/SkGLContext.h"
-#include "gl/SkNullGLContext.h"
-
#include "GrContext.h"
+
+#include "gl/SkGLContext.h"
#include "SkTArray.h"
/**
@@ -119,74 +111,8 @@ public:
/**
* Get a GrContext initialized with a type of GL context. It also makes the GL context current.
*/
- GrContext* get(GLContextType type, GrGLStandard forcedGpuAPI = kNone_GrGLStandard) {
- for (int i = 0; i < fContexts.count(); ++i) {
- if (forcedGpuAPI != kNone_GrGLStandard &&
- forcedGpuAPI != fContexts[i].fGLContext->gl()->fStandard)
- continue;
+ GrContext* get(GLContextType type, GrGLStandard forcedGpuAPI = kNone_GrGLStandard);
- if (fContexts[i].fType == type) {
- fContexts[i].fGLContext->makeCurrent();
- return fContexts[i].fGrContext;
- }
- }
- SkAutoTUnref<SkGLContext> glCtx;
- SkAutoTUnref<GrContext> grCtx;
- switch (type) {
- case kNVPR_GLContextType: // fallthru
- case kNative_GLContextType:
- glCtx.reset(SkCreatePlatformGLContext(forcedGpuAPI));
- break;
-#ifdef SK_ANGLE
- case kANGLE_GLContextType:
- glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI));
- break;
-#endif
-#ifdef SK_MESA
- case kMESA_GLContextType:
- glCtx.reset(SkMesaGLContext::Create(forcedGpuAPI));
- break;
-#endif
- case kNull_GLContextType:
- glCtx.reset(SkNullGLContext::Create(forcedGpuAPI));
- break;
- case kDebug_GLContextType:
- glCtx.reset(SkDebugGLContext::Create(forcedGpuAPI));
- break;
- }
- if (NULL == glCtx.get()) {
- return NULL;
- }
-
- SkASSERT(glCtx->isValid());
-
- // Ensure NVPR is available for the NVPR type and block it from other types.
- SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl()));
- if (kNVPR_GLContextType == type) {
- if (!glInterface->hasExtension("GL_NV_path_rendering")) {
- return NULL;
- }
- } else {
- glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface));
- if (!glInterface) {
- return NULL;
- }
- }
-
- glCtx->makeCurrent();
- GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(glInterface.get());
- grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, &fGlobalOptions));
- if (!grCtx.get()) {
- return NULL;
- }
- GPUContext& ctx = fContexts.push_back();
- ctx.fGLContext = glCtx.get();
- ctx.fGLContext->ref();
- ctx.fGrContext = grCtx.get();
- ctx.fGrContext->ref();
- ctx.fType = type;
- return ctx.fGrContext;
- }
// Returns the GLContext of the given type. If it has not been created yet,
// NULL is returned instead.
diff --git a/include/gpu/gl/SkNullGLContext.h b/src/gpu/gl/SkNullGLContext.h
index 35e94d2ab9..92ac11aeec 100644
--- a/include/gpu/gl/SkNullGLContext.h
+++ b/src/gpu/gl/SkNullGLContext.h
@@ -8,7 +8,7 @@
#ifndef SkNullGLContext_DEFINED
#define SkNullGLContext_DEFINED
-#include "SkGLContext.h"
+#include "gl/SkGLContext.h"
class SK_API SkNullGLContext : public SkGLContext {
public:
diff --git a/src/gpu/gl/angle/SkANGLEGLContext.cpp b/src/gpu/gl/angle/SkANGLEGLContext.cpp
index 232c866423..2cff750fa0 100644
--- a/src/gpu/gl/angle/SkANGLEGLContext.cpp
+++ b/src/gpu/gl/angle/SkANGLEGLContext.cpp
@@ -6,7 +6,7 @@
* found in the LICENSE file.
*/
-#include "gl/SkANGLEGLContext.h"
+#include "gl/angle/SkANGLEGLContext.h"
SkANGLEGLContext::SkANGLEGLContext()
: fContext(EGL_NO_CONTEXT)
diff --git a/include/gpu/gl/SkANGLEGLContext.h b/src/gpu/gl/angle/SkANGLEGLContext.h
index 797e997972..dec3f9f2a7 100644
--- a/include/gpu/gl/SkANGLEGLContext.h
+++ b/src/gpu/gl/angle/SkANGLEGLContext.h
@@ -10,7 +10,7 @@
#if SK_ANGLE
-#include "SkGLContext.h"
+#include "gl/SkGLContext.h"
#include <GLES2/gl2.h>
#include <EGL/egl.h>
diff --git a/src/gpu/gl/debug/SkDebugGLContext.cpp b/src/gpu/gl/debug/SkDebugGLContext.cpp
index c021c7a7a8..ae55104d46 100644
--- a/src/gpu/gl/debug/SkDebugGLContext.cpp
+++ b/src/gpu/gl/debug/SkDebugGLContext.cpp
@@ -6,7 +6,7 @@
* found in the LICENSE file.
*/
-#include "gl/SkDebugGLContext.h"
+#include "gl/debug/SkDebugGLContext.h"
SkDebugGLContext::SkDebugGLContext() {
fGL.reset(GrGLCreateDebugInterface());
diff --git a/include/gpu/gl/SkDebugGLContext.h b/src/gpu/gl/debug/SkDebugGLContext.h
index ad157fa653..7dca67f320 100644
--- a/include/gpu/gl/SkDebugGLContext.h
+++ b/src/gpu/gl/debug/SkDebugGLContext.h
@@ -8,7 +8,7 @@
#ifndef SkDebugGLContext_DEFINED
#define SkDebugGLContext_DEFINED
-#include "SkGLContext.h"
+#include "gl/SkGLContext.h"
class SkDebugGLContext : public SkGLContext {
public:
diff --git a/src/gpu/gl/mesa/SkMesaGLContext.cpp b/src/gpu/gl/mesa/SkMesaGLContext.cpp
index 3c5cc971a2..1fac5fadd6 100644
--- a/src/gpu/gl/mesa/SkMesaGLContext.cpp
+++ b/src/gpu/gl/mesa/SkMesaGLContext.cpp
@@ -8,7 +8,7 @@
#include <GL/osmesa.h>
-#include "gl/SkMesaGLContext.h"
+#include "gl/mesa/SkMesaGLContext.h"
#include "gl/GrGLDefines.h"
static const GrGLint gBOGUS_SIZE = 16;
diff --git a/include/gpu/gl/SkMesaGLContext.h b/src/gpu/gl/mesa/SkMesaGLContext.h
index 70a391df10..0fc5162319 100644
--- a/include/gpu/gl/SkMesaGLContext.h
+++ b/src/gpu/gl/mesa/SkMesaGLContext.h
@@ -8,7 +8,7 @@
#ifndef SkMesaGLContext_DEFINED
#define SkMesaGLContext_DEFINED
-#include "SkGLContext.h"
+#include "gl/SkGLContext.h"
#if SK_MESA