Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Unified Diff: tools/gpu/gl/command_buffer/GLContext_command_buffer.cpp

Issue 1815823002: Move SkGLContext and some GrGLInterface implementations to skgputest module (Closed) Base URL: https://chromium.googlesource.com/skia.git@debugobject
Patch Set: rebase, readd null interface to main lib Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 b14debda57c1c06aaec25fbf60ac1bc0ce6b2726..b878cb4aa9f42b9ff92f3a0e964fdf016b1cd0a7 100644
--- a/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp
+++ b/tools/gpu/gl/command_buffer/GLContext_command_buffer.cpp
@@ -5,10 +5,11 @@
* 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"
@@ -83,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
@@ -125,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,
@@ -161,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) {
@@ -182,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;
@@ -207,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();
@@ -217,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,
@@ -247,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();
@@ -262,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;
}
@@ -289,7 +293,7 @@ void SkCommandBufferGLContext::destroyGLContext() {
}
}
-void SkCommandBufferGLContext::onPlatformMakeCurrent() const {
+void CommandBufferGLContext::onPlatformMakeCurrent() const {
if (!gfFunctionsLoadedSuccessfully) {
return;
}
@@ -298,7 +302,7 @@ void SkCommandBufferGLContext::onPlatformMakeCurrent() const {
}
}
-void SkCommandBufferGLContext::onPlatformSwapBuffers() const {
+void CommandBufferGLContext::onPlatformSwapBuffers() const {
if (!gfFunctionsLoadedSuccessfully) {
return;
}
@@ -307,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();
}
@@ -322,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

Powered by Google App Engine
This is Rietveld 408576698