| Index: tools/gpu/gl/GLContext.cpp
|
| diff --git a/src/gpu/gl/SkGLContext.cpp b/tools/gpu/gl/GLContext.cpp
|
| similarity index 82%
|
| rename from src/gpu/gl/SkGLContext.cpp
|
| rename to tools/gpu/gl/GLContext.cpp
|
| index ebe50328279b17c9e9d70ef7a498084ed6b858aa..ac0e310014462aad5ed45ba6b2d16eb69bcf5c24 100644
|
| --- a/src/gpu/gl/SkGLContext.cpp
|
| +++ b/tools/gpu/gl/GLContext.cpp
|
| @@ -5,13 +5,14 @@
|
| * 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;
|
| @@ -37,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++) {
|
| @@ -53,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]) {
|
| @@ -73,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();
|
| @@ -99,7 +100,7 @@ void SkGLContext::waitOnSyncOrSwap() {
|
| fCurrentFenceIdx = (fCurrentFenceIdx + 1) % SK_ARRAY_COUNT(fFrameFences);
|
| }
|
|
|
| -void SkGLContext::testAbandon() {
|
| +void GLContext::testAbandon() {
|
| if (fGL) {
|
| fGL->abandon();
|
| }
|
| @@ -108,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;
|
| @@ -143,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;
|
| @@ -184,3 +185,4 @@ GrGLint SkGLContext::createTextureRectangle(int width, int height, GrGLenum inte
|
| externalFormat, externalType, data));
|
| return id;
|
| }
|
| +} // namespace sk_gpu_test
|
|
|