Initial version of external_oes texture support and unit test
Committed: https://skia.googlesource.com/skia/+/27a048700778d4cebfc23301d1780649791b0e03
Review URL: https://codereview.chromium.org/1451683002
diff --git a/include/gpu/gl/GrGLFunctions.h b/include/gpu/gl/GrGLFunctions.h
index a8a721e..1086186 100644
--- a/include/gpu/gl/GrGLFunctions.h
+++ b/include/gpu/gl/GrGLFunctions.h
@@ -69,6 +69,7 @@
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDrawBufferProc)(GrGLenum mode);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDrawBuffersProc)(GrGLsizei n, const GrGLenum* bufs);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLDrawElementsProc)(GrGLenum mode, GrGLsizei count, GrGLenum type, const GrGLvoid* indices);
+typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLEGLImageTargetTexture2DProc)(GrGLenum target, GrGLeglImage image);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLEnableProc)(GrGLenum cap);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLEnableVertexAttribArrayProc)(GrGLuint index);
typedef GrGLvoid (GR_GL_FUNCTION_TYPE* GrGLEndQueryProc)(GrGLenum target);
@@ -352,8 +353,8 @@
/** EGL functions */
typedef const char* (GR_GL_FUNCTION_TYPE* GrEGLQueryStringProc)(GrEGLDisplay dpy, GrEGLint name);
typedef GrEGLDisplay (GR_GL_FUNCTION_TYPE* GrEGLGetCurrentDisplayProc)();
-typedef GrEGLImageKHR (GR_GL_FUNCTION_TYPE* GrEGLCreateImageProc)(GrEGLDisplay dpy, GrEGLContext ctx, GrEGLenum target, GrEGLClientBuffer buffer, const GrEGLint *attrib_list);
-typedef GrEGLBoolean (GR_GL_FUNCTION_TYPE* GrEGLDestroyImageProc)(GrEGLDisplay dpy, GrEGLImageKHR image);
+typedef GrEGLImage (GR_GL_FUNCTION_TYPE* GrEGLCreateImageProc)(GrEGLDisplay dpy, GrEGLContext ctx, GrEGLenum target, GrEGLClientBuffer buffer, const GrEGLint *attrib_list);
+typedef GrEGLBoolean (GR_GL_FUNCTION_TYPE* GrEGLDestroyImageProc)(GrEGLDisplay dpy, GrEGLImage image);
} // extern "C"
#endif
diff --git a/include/gpu/gl/GrGLInterface.h b/include/gpu/gl/GrGLInterface.h
index ec27ace..31429a8 100644
--- a/include/gpu/gl/GrGLInterface.h
+++ b/include/gpu/gl/GrGLInterface.h
@@ -498,8 +498,8 @@
GLPtr<GrGLObjectLabelProc> fObjectLabel;
/* EGL functions */
- GLPtr<GrEGLCreateImageProc> fCreateImage;
- GLPtr<GrEGLDestroyImageProc> fDestroyImage;
+ GLPtr<GrEGLCreateImageProc> fEGLCreateImage;
+ GLPtr<GrEGLDestroyImageProc> fEGLDestroyImage;
} fFunctions;
// Per-GL func callback
diff --git a/include/gpu/gl/GrGLTypes.h b/include/gpu/gl/GrGLTypes.h
index 275eba5..248ce88 100644
--- a/include/gpu/gl/GrGLTypes.h
+++ b/include/gpu/gl/GrGLTypes.h
@@ -57,12 +57,12 @@
typedef signed long int GrGLintptr;
typedef signed long int GrGLsizeiptr;
#endif
-
+typedef void* GrGLeglImage;
/**
* EGL types.
*/
-typedef void* GrEGLImageKHR;
+typedef void* GrEGLImage;
typedef void* GrEGLDisplay;
typedef void* GrEGLContext;
typedef void* GrEGLClientBuffer;
diff --git a/include/gpu/gl/SkGLContext.h b/include/gpu/gl/SkGLContext.h
index 75cfcfe..3420a47 100644
--- a/include/gpu/gl/SkGLContext.h
+++ b/include/gpu/gl/SkGLContext.h
@@ -14,8 +14,9 @@
/**
* 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 SkRefCnt {
public:
~SkGLContext() override;
@@ -36,6 +37,16 @@
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 EGLImage integration. Takes a EGLImage and wraps it in a
+ * GL_TEXTURE_EXTERNAL_OES.
+ */
+ virtual GrGLuint eglImageToExternalTexture(GrEGLImage) const { return 0; }
+
/**
* 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
@@ -59,6 +70,12 @@
*/
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.
protected:
diff --git a/include/gpu/gl/angle/SkANGLEGLContext.h b/include/gpu/gl/angle/SkANGLEGLContext.h
index 8d5f830..7858fff 100644
--- a/include/gpu/gl/angle/SkANGLEGLContext.h
+++ b/include/gpu/gl/angle/SkANGLEGLContext.h
@@ -27,6 +27,10 @@
}
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);
@@ -42,6 +46,7 @@
void* fContext;
void* fDisplay;
void* fSurface;
+ bool fIsGLBackend;
};
#endif