Index: tools/gpu/gl/command_buffer/GLContext_command_buffer.cpp |
diff --git a/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp b/tools/gpu/gl/command_buffer/GLContext_command_buffer.cpp |
similarity index 86% |
rename from src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp |
rename to tools/gpu/gl/command_buffer/GLContext_command_buffer.cpp |
index 516c155fcc984d8f9132c9979fab6cbe3ab4e271..b878cb4aa9f42b9ff92f3a0e964fdf016b1cd0a7 100644 |
--- a/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp |
+++ b/tools/gpu/gl/command_buffer/GLContext_command_buffer.cpp |
@@ -1,13 +1,15 @@ |
+ |
/* |
* Copyright 2015 Google Inc. |
* |
* Use of this source code is governed by a BSD-style license that can be |
* found in the LICENSE file. |
*/ |
+ |
#include "SkOnce.h" |
#include "gl/GrGLInterface.h" |
#include "gl/GrGLAssembleInterface.h" |
-#include "gl/command_buffer/SkCommandBufferGLContext.h" |
+#include "gl/command_buffer/GLContext_command_buffer.h" |
#include "../ports/SkOSEnvironment.h" |
#include "../ports/SkOSLibrary.h" |
@@ -82,6 +84,7 @@ static GetProcAddressProc gfGetProcAddress = nullptr; |
static void* gLibrary = nullptr; |
static bool gfFunctionsLoadedSuccessfully = false; |
+namespace { |
static void load_command_buffer_functions() { |
if (!gLibrary) { |
#if defined _WIN32 |
@@ -124,22 +127,24 @@ static GrGLFuncPtr command_buffer_get_gl_proc(void* ctx, const char name[]) { |
} |
SK_DECLARE_STATIC_ONCE(loadCommandBufferOnce); |
-void LoadCommandBufferOnce() { |
+static void load_command_buffer_once() { |
SkOnce(&loadCommandBufferOnce, load_command_buffer_functions); |
} |
-const GrGLInterface* GrGLCreateCommandBufferInterface() { |
- LoadCommandBufferOnce(); |
+static const GrGLInterface* create_command_buffer_interface() { |
+ load_command_buffer_once(); |
if (!gfFunctionsLoadedSuccessfully) { |
return nullptr; |
} |
return GrGLAssembleGLESInterface(gLibrary, command_buffer_get_gl_proc); |
} |
-SkCommandBufferGLContext::SkCommandBufferGLContext() |
- : fContext(EGL_NO_CONTEXT) |
- , fDisplay(EGL_NO_DISPLAY) |
- , fSurface(EGL_NO_SURFACE) { |
+} // anonymous namespace |
+ |
+namespace sk_gpu_test { |
+ |
+CommandBufferGLContext::CommandBufferGLContext() |
+ : fContext(EGL_NO_CONTEXT), fDisplay(EGL_NO_DISPLAY), fSurface(EGL_NO_SURFACE) { |
static const EGLint configAttribs[] = { |
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, |
@@ -160,18 +165,18 @@ SkCommandBufferGLContext::SkCommandBufferGLContext() |
initializeGLContext(nullptr, configAttribs, surfaceAttribs); |
} |
-SkCommandBufferGLContext::SkCommandBufferGLContext(void* nativeWindow, int msaaSampleCount) { |
- static const EGLint surfaceAttribs[] = { EGL_NONE }; |
+CommandBufferGLContext::CommandBufferGLContext(void *nativeWindow, int msaaSampleCount) { |
+ static const EGLint surfaceAttribs[] = {EGL_NONE}; |
EGLint configAttribs[] = { |
- EGL_RED_SIZE, 8, |
- EGL_GREEN_SIZE, 8, |
- EGL_BLUE_SIZE, 8, |
- EGL_ALPHA_SIZE, 8, |
- EGL_DEPTH_SIZE, 8, |
- EGL_STENCIL_SIZE, 8, |
+ EGL_RED_SIZE, 8, |
+ EGL_GREEN_SIZE, 8, |
+ EGL_BLUE_SIZE, 8, |
+ EGL_ALPHA_SIZE, 8, |
+ EGL_DEPTH_SIZE, 8, |
+ EGL_STENCIL_SIZE, 8, |
EGL_SAMPLE_BUFFERS, 1, |
- EGL_SAMPLES, msaaSampleCount, |
+ EGL_SAMPLES, msaaSampleCount, |
EGL_NONE |
}; |
if (msaaSampleCount == 0) { |
@@ -181,9 +186,9 @@ SkCommandBufferGLContext::SkCommandBufferGLContext(void* nativeWindow, int msaaS |
initializeGLContext(nativeWindow, configAttribs, surfaceAttribs); |
} |
-void SkCommandBufferGLContext::initializeGLContext(void* nativeWindow, const int* configAttribs, |
- const int* surfaceAttribs) { |
- LoadCommandBufferOnce(); |
+void CommandBufferGLContext::initializeGLContext(void *nativeWindow, const int *configAttribs, |
+ const int *surfaceAttribs) { |
+ load_command_buffer_once(); |
if (!gfFunctionsLoadedSuccessfully) { |
SkDebugf("Command Buffer: Could not load EGL functions.\n"); |
return; |
@@ -206,7 +211,7 @@ void SkCommandBufferGLContext::initializeGLContext(void* nativeWindow, const int |
} |
EGLint numConfigs; |
- if (!gfChooseConfig(fDisplay, configAttribs, static_cast<EGLConfig*>(&fConfig), 1, |
+ if (!gfChooseConfig(fDisplay, configAttribs, static_cast<EGLConfig *>(&fConfig), 1, |
&numConfigs) || numConfigs != 1) { |
SkDebugf("Command Buffer: Could not choose EGL config.\n"); |
this->destroyGLContext(); |
@@ -216,7 +221,7 @@ void SkCommandBufferGLContext::initializeGLContext(void* nativeWindow, const int |
if (nativeWindow) { |
fSurface = gfCreateWindowSurface(fDisplay, |
static_cast<EGLConfig>(fConfig), |
- (EGLNativeWindowType)nativeWindow, |
+ (EGLNativeWindowType) nativeWindow, |
surfaceAttribs); |
} else { |
fSurface = gfCreatePbufferSurface(fDisplay, |
@@ -246,7 +251,7 @@ void SkCommandBufferGLContext::initializeGLContext(void* nativeWindow, const int |
return; |
} |
- SkAutoTUnref<const GrGLInterface> gl(GrGLCreateCommandBufferInterface()); |
+ SkAutoTUnref<const GrGLInterface> gl(create_command_buffer_interface()); |
if (nullptr == gl.get()) { |
SkDebugf("Command Buffer: Could not create CommandBuffer GL interface.\n"); |
this->destroyGLContext(); |
@@ -261,12 +266,12 @@ void SkCommandBufferGLContext::initializeGLContext(void* nativeWindow, const int |
this->init(gl.release()); |
} |
-SkCommandBufferGLContext::~SkCommandBufferGLContext() { |
+CommandBufferGLContext::~CommandBufferGLContext() { |
this->teardown(); |
this->destroyGLContext(); |
} |
-void SkCommandBufferGLContext::destroyGLContext() { |
+void CommandBufferGLContext::destroyGLContext() { |
if (!gfFunctionsLoadedSuccessfully) { |
return; |
} |
@@ -288,7 +293,7 @@ void SkCommandBufferGLContext::destroyGLContext() { |
} |
} |
-void SkCommandBufferGLContext::onPlatformMakeCurrent() const { |
+void CommandBufferGLContext::onPlatformMakeCurrent() const { |
if (!gfFunctionsLoadedSuccessfully) { |
return; |
} |
@@ -297,7 +302,7 @@ void SkCommandBufferGLContext::onPlatformMakeCurrent() const { |
} |
} |
-void SkCommandBufferGLContext::onPlatformSwapBuffers() const { |
+void CommandBufferGLContext::onPlatformSwapBuffers() const { |
if (!gfFunctionsLoadedSuccessfully) { |
return; |
} |
@@ -306,14 +311,14 @@ void SkCommandBufferGLContext::onPlatformSwapBuffers() const { |
} |
} |
-GrGLFuncPtr SkCommandBufferGLContext::onPlatformGetProcAddress(const char* name) const { |
+GrGLFuncPtr CommandBufferGLContext::onPlatformGetProcAddress(const char *name) const { |
if (!gfFunctionsLoadedSuccessfully) { |
return nullptr; |
} |
return gfGetProcAddress(name); |
} |
-void SkCommandBufferGLContext::presentCommandBuffer() { |
+void CommandBufferGLContext::presentCommandBuffer() { |
if (this->gl()) { |
this->gl()->fFunctions.fFlush(); |
} |
@@ -321,18 +326,20 @@ void SkCommandBufferGLContext::presentCommandBuffer() { |
this->onPlatformSwapBuffers(); |
} |
-bool SkCommandBufferGLContext::makeCurrent() { |
+bool CommandBufferGLContext::makeCurrent() { |
return gfMakeCurrent(fDisplay, fSurface, fSurface, fContext) != EGL_FALSE; |
} |
-int SkCommandBufferGLContext::getStencilBits() { |
+int CommandBufferGLContext::getStencilBits() { |
EGLint result = 0; |
gfGetConfigAttrib(fDisplay, static_cast<EGLConfig>(fConfig), EGL_STENCIL_SIZE, &result); |
return result; |
} |
-int SkCommandBufferGLContext::getSampleCount() { |
+int CommandBufferGLContext::getSampleCount() { |
EGLint result = 0; |
gfGetConfigAttrib(fDisplay, static_cast<EGLConfig>(fConfig), EGL_SAMPLES, &result); |
return result; |
} |
+ |
+} // namespace sk_gpu_test |