aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2016-03-30 08:35:09 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-30 08:35:09 -0700
commitfe3456cb006110d045b26ff3f8681b893a757b58 (patch)
tree8d07fbc43230b807d0cf7174c79d5757c397b07f /include/gpu
parentb4a7f144b41dbe8341d26abb71d87b13d072a5cf (diff)
Move SkGLContext and some GrGLInterface implementations to skgputest module
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1815823002 CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Ubuntu-GCC-x86_64-Release-CMake-Trybot,Build-Mac-Clang-x86_64-Release-CMake-Trybot Review URL: https://codereview.chromium.org/1815823002
Diffstat (limited to 'include/gpu')
-rw-r--r--include/gpu/gl/GrGLInterface.h31
-rw-r--r--include/gpu/gl/SkGLContext.h145
-rw-r--r--include/gpu/gl/SkNullGLContext.h26
-rw-r--r--include/gpu/gl/angle/SkANGLEGLContext.h61
-rw-r--r--include/gpu/gl/command_buffer/SkCommandBufferGLContext.h63
5 files changed, 5 insertions, 321 deletions
diff --git a/include/gpu/gl/GrGLInterface.h b/include/gpu/gl/GrGLInterface.h
index cbf9b1a59f..4ba516617f 100644
--- a/include/gpu/gl/GrGLInterface.h
+++ b/include/gpu/gl/GrGLInterface.h
@@ -43,39 +43,18 @@ const GrGLInterface* GrGLDefaultInterface();
*/
SK_API const GrGLInterface* GrGLCreateNativeInterface();
-#if SK_MESA
-/**
- * Creates a GrGLInterface for an OSMesa context.
- */
-SK_API const GrGLInterface* GrGLCreateMesaInterface();
-#endif
-
-#if SK_ANGLE
-/**
- * Creates a GrGLInterface for an ANGLE context.
- */
-SK_API const GrGLInterface* GrGLCreateANGLEInterface();
-#endif
-
-#if SK_COMMAND_BUFFER
-/**
- * Creates a GrGLInterface for a Command Buffer context.
- */
-SK_API const GrGLInterface* GrGLCreateCommandBufferInterface();
+#if GR_GL_PER_GL_FUNC_CALLBACK
+typedef void (*GrGLInterfaceCallbackProc)(const GrGLInterface*);
+typedef intptr_t GrGLInterfaceCallbackData;
#endif
/**
* Creates a null GrGLInterface that doesn't draw anything. Used for measuring
- * CPU overhead.
+ * CPU overhead. TODO: We would like to move this to tools/gpu/gl/null but currently
+ * Chromium is using it in its unit tests.
*/
const SK_API GrGLInterface* GrGLCreateNullInterface();
-/**
- * Creates a debugging GrGLInterface that doesn't draw anything. Used for
- * finding memory leaks and invalid memory accesses.
- */
-const GrGLInterface* GrGLCreateDebugInterface();
-
/** Function that returns a new interface identical to "interface" but without support for
GL_NV_path_rendering. */
const GrGLInterface* GrGLInterfaceRemoveNVPR(const GrGLInterface*);
diff --git a/include/gpu/gl/SkGLContext.h b/include/gpu/gl/SkGLContext.h
deleted file mode 100644
index fe41a606ef..0000000000
--- a/include/gpu/gl/SkGLContext.h
+++ /dev/null
@@ -1,145 +0,0 @@
-
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#ifndef SkGLContext_DEFINED
-#define SkGLContext_DEFINED
-
-#include "GrGLInterface.h"
-#include "../private/SkGpuFenceSync.h"
-
-/**
- * Create an offscreen opengl context with an RGBA8 / 8bit stencil FBO.
- * Provides a GrGLInterface struct of function pointers for the context.
- * This class is intended for Skia's testing needs and not for general
- * use.
- */
-class SK_API SkGLContext : public SkNoncopyable {
-public:
- virtual ~SkGLContext();
-
- bool isValid() const { return NULL != gl(); }
-
- const GrGLInterface* gl() const { return fGL.get(); }
-
- bool fenceSyncSupport() const { return fFenceSync != nullptr; }
-
- bool getMaxGpuFrameLag(int* maxFrameLag) const {
- if (!fFenceSync) {
- return false;
- }
- *maxFrameLag = kMaxFrameLag;
- return true;
- }
-
- void makeCurrent() const;
-
- /** Used for testing EGLImage integration. Take a GL_TEXTURE_2D and wraps it in an EGL Image */
- virtual GrEGLImage texture2DToEGLImage(GrGLuint /*texID*/) const { return 0; }
- virtual void destroyEGLImage(GrEGLImage) const {}
-
- /** Used for testing GL_TEXTURE_RECTANGLE integration. */
- GrGLint createTextureRectangle(int width, int height, GrGLenum internalFormat,
- GrGLenum externalFormat, GrGLenum externalType,
- GrGLvoid* data);
-
- /**
- * Used for testing EGLImage integration. Takes a EGLImage and wraps it in a
- * GL_TEXTURE_EXTERNAL_OES.
- */
- virtual GrGLuint eglImageToExternalTexture(GrEGLImage) const { return 0; }
-
- void swapBuffers();
-
- /**
- * The only purpose of this function it to provide a means of scheduling
- * work on the GPU (since all of the subclasses create primary buffers for
- * testing that are small and not meant to be rendered to the screen).
- *
- * If the platform supports fence sync (OpenGL 3.2+ or EGL_KHR_fence_sync),
- * this will not swap any buffers, but rather emulate triple buffer
- * synchronization using fences.
- *
- * Otherwise it will call the platform SwapBuffers method. This may or may
- * not perform some sort of synchronization, depending on whether the
- * drawing surface provided by the platform is double buffered.
- */
- void waitOnSyncOrSwap();
-
- /**
- * This notifies the context that we are deliberately testing abandoning
- * the context. It is useful for debugging contexts that would otherwise
- * test that GPU resources are properly deleted. It also allows a debugging
- * context to test that further GL calls are not made by Skia GPU code.
- */
- void testAbandon();
-
- /**
- * Creates a new GL context of the same type and makes the returned context current
- * (if not null).
- */
- virtual SkGLContext* createNew() const { return nullptr; }
-
- class GLFenceSync; // SkGpuFenceSync implementation that uses the OpenGL functionality.
-
- /*
- * returns the fencesync object owned by this SkGLContext
- */
- SkGpuFenceSync* fenceSync() { return fFenceSync.get(); }
-
-protected:
- SkGLContext();
-
- /*
- * Methods that sublcasses must call from their constructors and destructors.
- */
- void init(const GrGLInterface*, SkGpuFenceSync* = NULL);
- void teardown();
-
- /*
- * Operations that have a platform-dependent implementation.
- */
- virtual void onPlatformMakeCurrent() const = 0;
- virtual void onPlatformSwapBuffers() const = 0;
- virtual GrGLFuncPtr onPlatformGetProcAddress(const char*) const = 0;
-
-private:
- enum { kMaxFrameLag = 3 };
-
- SkAutoTDelete<SkGpuFenceSync> fFenceSync;
- SkPlatformGpuFence fFrameFences[kMaxFrameLag - 1];
- int fCurrentFenceIdx;
-
- /** Subclass provides the gl interface object if construction was
- * successful. */
- SkAutoTUnref<const GrGLInterface> fGL;
-
- friend class GLFenceSync; // For onPlatformGetProcAddress.
-};
-
-/** Creates platform-dependent GL context object. The shareContext parameter is in an optional
- * context with which to share display lists. This should be a pointer to an SkGLContext created
- * with SkCreatePlatformGLContext. NULL indicates that no sharing is to take place. Returns a valid
- * gl context object or NULL if such can not be created.
- * Note: If Skia embedder needs a custom GL context that sets up the GL interface, this function
- * should be implemented by the embedder. Otherwise, the default implementation for the platform
- * should be compiled in the library.
- */
-SK_API SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI,
- SkGLContext* shareContext = nullptr);
-
-/**
- * Helper macros for using the GL context through the GrGLInterface. Example:
- * SK_GL(glCtx, GenTextures(1, &texID));
- */
-#define SK_GL(ctx, X) (ctx).gl()->fFunctions.f ## X; \
- SkASSERT(0 == (ctx).gl()->fFunctions.fGetError())
-#define SK_GL_RET(ctx, RET, X) (RET) = (ctx).gl()->fFunctions.f ## X; \
- SkASSERT(0 == (ctx).gl()->fFunctions.fGetError())
-#define SK_GL_NOERRCHECK(ctx, X) (ctx).gl()->fFunctions.f ## X
-#define SK_GL_RET_NOERRCHECK(ctx, RET, X) (RET) = (ctx).gl()->fFunctions.f ## X
-
-#endif
diff --git a/include/gpu/gl/SkNullGLContext.h b/include/gpu/gl/SkNullGLContext.h
deleted file mode 100644
index 5a2a73fd8f..0000000000
--- a/include/gpu/gl/SkNullGLContext.h
+++ /dev/null
@@ -1,26 +0,0 @@
-
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#ifndef SkNullGLContext_DEFINED
-#define SkNullGLContext_DEFINED
-
-#include "gl/SkGLContext.h"
-
-class SK_API SkNullGLContext : public SkGLContext {
-public:
- ~SkNullGLContext() override;
- static SkNullGLContext* Create();
-
-private:
- SkNullGLContext();
-
- void onPlatformMakeCurrent() const override {};
- void onPlatformSwapBuffers() const override {}
- GrGLFuncPtr onPlatformGetProcAddress(const char*) const override { return nullptr; }
-};
-
-#endif
diff --git a/include/gpu/gl/angle/SkANGLEGLContext.h b/include/gpu/gl/angle/SkANGLEGLContext.h
deleted file mode 100644
index ea5e877ca2..0000000000
--- a/include/gpu/gl/angle/SkANGLEGLContext.h
+++ /dev/null
@@ -1,61 +0,0 @@
-
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#ifndef SkANGLEGLContext_DEFINED
-#define SkANGLEGLContext_DEFINED
-
-#if SK_ANGLE
-
-#include "gl/SkGLContext.h"
-
-class SkANGLEGLContext : public SkGLContext {
-public:
- ~SkANGLEGLContext() override;
-#ifdef SK_BUILD_FOR_WIN
- static SkANGLEGLContext* CreateDirectX() {
- SkANGLEGLContext* ctx = new SkANGLEGLContext(false);
- if (!ctx->isValid()) {
- delete ctx;
- return NULL;
- }
- return ctx;
- }
-#endif
- static SkANGLEGLContext* CreateOpenGL() {
- SkANGLEGLContext* ctx = new SkANGLEGLContext(true);
- if (!ctx->isValid()) {
- delete ctx;
- return NULL;
- }
- return ctx;
- }
-
- GrEGLImage texture2DToEGLImage(GrGLuint texID) const override;
- void destroyEGLImage(GrEGLImage) const override;
- GrGLuint eglImageToExternalTexture(GrEGLImage) const override;
- SkGLContext* createNew() const override;
-
- // The param is an EGLNativeDisplayType and the return is an EGLDispay.
- static void* GetD3DEGLDisplay(void* nativeDisplay, bool useGLBackend);
-
-private:
- SkANGLEGLContext(bool preferGLBackend);
- void destroyGLContext();
-
- void onPlatformMakeCurrent() const override;
- void onPlatformSwapBuffers() const override;
- GrGLFuncPtr onPlatformGetProcAddress(const char* name) const override;
-
- void* fContext;
- void* fDisplay;
- void* fSurface;
- bool fIsGLBackend;
-};
-
-#endif
-
-#endif
diff --git a/include/gpu/gl/command_buffer/SkCommandBufferGLContext.h b/include/gpu/gl/command_buffer/SkCommandBufferGLContext.h
deleted file mode 100644
index 47f3fd967a..0000000000
--- a/include/gpu/gl/command_buffer/SkCommandBufferGLContext.h
+++ /dev/null
@@ -1,63 +0,0 @@
-
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#ifndef SKCOMMANDBUFFERGLCONTEXT_DEFINED
-#define SKCOMMANDBUFFERGLCONTEXT_DEFINED
-
-#if SK_COMMAND_BUFFER
-
-#include "gl/SkGLContext.h"
-
-class SkCommandBufferGLContext : public SkGLContext {
-public:
- ~SkCommandBufferGLContext() override;
-
- static SkCommandBufferGLContext* Create() {
- SkCommandBufferGLContext* ctx = new SkCommandBufferGLContext;
- if (!ctx->isValid()) {
- delete ctx;
- return nullptr;
- }
- return ctx;
- }
-
- static SkCommandBufferGLContext* Create(void* nativeWindow, int msaaSampleCount) {
- SkCommandBufferGLContext* ctx = new SkCommandBufferGLContext(nativeWindow,
- msaaSampleCount);
- if (!ctx->isValid()) {
- delete ctx;
- return nullptr;
- }
- return ctx;
- }
-
- void presentCommandBuffer();
-
- bool makeCurrent();
- int getStencilBits();
- int getSampleCount();
-
-private:
- SkCommandBufferGLContext();
- SkCommandBufferGLContext(void* nativeWindow, int msaaSampleCount);
- void initializeGLContext(void* nativeWindow, const int* configAttribs,
- const int* surfaceAttribs);
- void destroyGLContext();
-
- void onPlatformMakeCurrent() const override;
- void onPlatformSwapBuffers() const override;
- GrGLFuncPtr onPlatformGetProcAddress(const char* name) const override;
-
- void* fContext;
- void* fDisplay;
- void* fSurface;
- void* fConfig;
-};
-
-#endif // SK_COMMAND_BUFFER
-
-#endif