Index: tools/gpu/gl/GLContext.cpp |
diff --git a/src/gpu/gl/SkGLContext.cpp b/tools/gpu/gl/GLContext.cpp |
similarity index 81% |
rename from src/gpu/gl/SkGLContext.cpp |
rename to tools/gpu/gl/GLContext.cpp |
index 1f9011fbd972a9eed5468df2aa1bf5c2d7dcea5b..ac0e310014462aad5ed45ba6b2d16eb69bcf5c24 100644 |
--- a/src/gpu/gl/SkGLContext.cpp |
+++ b/tools/gpu/gl/GLContext.cpp |
@@ -1,16 +1,18 @@ |
+ |
/* |
* Copyright 2013 Google Inc. |
* |
* Use of this source code is governed by a BSD-style license that can be |
* found in the LICENSE file. |
*/ |
-#include "gl/SkGLContext.h" |
-#include "GrGLUtil.h" |
+#include "GLContext.h" |
+#include "gl/GrGLUtil.h" |
#include "SkGpuFenceSync.h" |
-class SkGLContext::GLFenceSync : public SkGpuFenceSync { |
+namespace sk_gpu_test { |
+class GLContext::GLFenceSync : public SkGpuFenceSync { |
public: |
- static GLFenceSync* CreateIfSupported(const SkGLContext*); |
+ static GLFenceSync* CreateIfSupported(const GLContext*); |
SkPlatformGpuFence SK_WARN_UNUSED_RESULT insertFence() const override; |
bool waitFence(SkPlatformGpuFence fence, bool flush) const override; |
@@ -36,12 +38,12 @@ private: |
typedef SkGpuFenceSync INHERITED; |
}; |
-SkGLContext::SkGLContext() |
+GLContext::GLContext() |
: fCurrentFenceIdx(0) { |
memset(fFrameFences, 0, sizeof(fFrameFences)); |
} |
-SkGLContext::~SkGLContext() { |
+GLContext::~GLContext() { |
// Subclass should call teardown. |
#ifdef SK_DEBUG |
for (size_t i = 0; i < SK_ARRAY_COUNT(fFrameFences); i++) { |
@@ -52,13 +54,13 @@ SkGLContext::~SkGLContext() { |
SkASSERT(nullptr == fFenceSync.get()); |
} |
-void SkGLContext::init(const GrGLInterface* gl, SkGpuFenceSync* fenceSync) { |
+void GLContext::init(const GrGLInterface* gl, SkGpuFenceSync* fenceSync) { |
SkASSERT(!fGL.get()); |
fGL.reset(gl); |
fFenceSync.reset(fenceSync ? fenceSync : GLFenceSync::CreateIfSupported(this)); |
} |
-void SkGLContext::teardown() { |
+void GLContext::teardown() { |
if (fFenceSync) { |
for (size_t i = 0; i < SK_ARRAY_COUNT(fFrameFences); i++) { |
if (fFrameFences[i]) { |
@@ -72,15 +74,15 @@ void SkGLContext::teardown() { |
fGL.reset(nullptr); |
} |
-void SkGLContext::makeCurrent() const { |
+void GLContext::makeCurrent() const { |
this->onPlatformMakeCurrent(); |
} |
-void SkGLContext::swapBuffers() { |
+void GLContext::swapBuffers() { |
this->onPlatformSwapBuffers(); |
} |
-void SkGLContext::waitOnSyncOrSwap() { |
+void GLContext::waitOnSyncOrSwap() { |
if (!fFenceSync) { |
// Fallback on the platform SwapBuffers method for synchronization. This may have no effect. |
this->swapBuffers(); |
@@ -98,7 +100,7 @@ void SkGLContext::waitOnSyncOrSwap() { |
fCurrentFenceIdx = (fCurrentFenceIdx + 1) % SK_ARRAY_COUNT(fFrameFences); |
} |
-void SkGLContext::testAbandon() { |
+void GLContext::testAbandon() { |
if (fGL) { |
fGL->abandon(); |
} |
@@ -107,12 +109,12 @@ void SkGLContext::testAbandon() { |
} |
} |
-SkGLContext::GLFenceSync* SkGLContext::GLFenceSync::CreateIfSupported(const SkGLContext* ctx) { |
+GLContext::GLFenceSync* GLContext::GLFenceSync::CreateIfSupported(const GLContext* ctx) { |
SkAutoTDelete<GLFenceSync> ret(new GLFenceSync); |
if (kGL_GrGLStandard == ctx->gl()->fStandard) { |
const GrGLubyte* versionStr; |
- SK_GL_RET(*ctx, versionStr, GetString(GR_GL_VERSION)); |
+ GR_GL_CALL_RET(ctx->gl(), versionStr, GetString(GR_GL_VERSION)); |
GrGLVersion version = GrGLGetVersionFromString(reinterpret_cast<const char*>(versionStr)); |
if (version < GR_GL_VER(3,2) && !ctx->gl()->hasExtension("GL_ARB_sync")) { |
return nullptr; |
@@ -142,23 +144,23 @@ SkGLContext::GLFenceSync* SkGLContext::GLFenceSync::CreateIfSupported(const SkGL |
return ret.release(); |
} |
-SkPlatformGpuFence SkGLContext::GLFenceSync::insertFence() const { |
+SkPlatformGpuFence GLContext::GLFenceSync::insertFence() const { |
return fGLFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); |
} |
-bool SkGLContext::GLFenceSync::waitFence(SkPlatformGpuFence fence, bool flush) const { |
+bool GLContext::GLFenceSync::waitFence(SkPlatformGpuFence fence, bool flush) const { |
GLsync glsync = static_cast<GLsync>(fence); |
return GL_WAIT_FAILED != fGLClientWaitSync(glsync, flush ? GL_SYNC_FLUSH_COMMANDS_BIT : 0, -1); |
} |
-void SkGLContext::GLFenceSync::deleteFence(SkPlatformGpuFence fence) const { |
+void GLContext::GLFenceSync::deleteFence(SkPlatformGpuFence fence) const { |
GLsync glsync = static_cast<GLsync>(fence); |
fGLDeleteSync(glsync); |
} |
-GrGLint SkGLContext::createTextureRectangle(int width, int height, GrGLenum internalFormat, |
- GrGLenum externalFormat, GrGLenum externalType, |
- GrGLvoid* data) { |
+GrGLint GLContext::createTextureRectangle(int width, int height, GrGLenum internalFormat, |
+ GrGLenum externalFormat, GrGLenum externalType, |
+ GrGLvoid* data) { |
if (!(kGL_GrGLStandard == fGL->fStandard && GrGLGetVersion(fGL) >= GR_GL_VER(3, 1)) && |
!fGL->fExtensions.has("GL_ARB_texture_rectangle")) { |
return 0; |
@@ -176,10 +178,11 @@ GrGLint SkGLContext::createTextureRectangle(int width, int height, GrGLenum inte |
GR_GL_CALL(fGL, TexParameteri(GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_MIN_FILTER, |
GR_GL_NEAREST)); |
GR_GL_CALL(fGL, TexParameteri(GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_WRAP_S, |
- GR_GL_CLAMP_TO_EDGE)); |
+ GR_GL_CLAMP_TO_EDGE)); |
GR_GL_CALL(fGL, TexParameteri(GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_WRAP_T, |
GR_GL_CLAMP_TO_EDGE)); |
GR_GL_CALL(fGL, TexImage2D(GR_GL_TEXTURE_RECTANGLE, 0, internalFormat, width, height, 0, |
externalFormat, externalType, data)); |
return id; |
} |
+} // namespace sk_gpu_test |