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

Unified Diff: src/gpu/gl/angle/SkANGLEGLContext.cpp

Issue 1451683002: Initial version of external_oes texture support and unit test (Closed) Base URL: https://skia.googlesource.com/skia.git@target
Patch Set: again Created 5 years, 1 month 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
« no previous file with comments | « src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp ('k') | src/gpu/gl/builders/GrGLProgramBuilder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/angle/SkANGLEGLContext.cpp
diff --git a/src/gpu/gl/angle/SkANGLEGLContext.cpp b/src/gpu/gl/angle/SkANGLEGLContext.cpp
index 64a3bdec74381365db58936fe4d43db3a424bc16..54ef02d492468864f82ee60e89eba16120dabbe9 100644
--- a/src/gpu/gl/angle/SkANGLEGLContext.cpp
+++ b/src/gpu/gl/angle/SkANGLEGLContext.cpp
@@ -11,6 +11,9 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
+#include "gl/GrGLDefines.h"
+#include "gl/GrGLUtil.h"
+
#define EGL_PLATFORM_ANGLE_ANGLE 0x3202
#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203
#define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3207
@@ -34,8 +37,7 @@ void* SkANGLEGLContext::GetD3DEGLDisplay(void* nativeDisplay, bool useGLBackend)
EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE,
EGL_NONE
};
- display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,
- nativeDisplay, attribs);
+ display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, nativeDisplay, attribs);
} else {
// Try for an ANGLE D3D11 context, fall back to D3D9, and finally GL.
EGLint attribs[3][3] = {
@@ -56,8 +58,7 @@ void* SkANGLEGLContext::GetD3DEGLDisplay(void* nativeDisplay, bool useGLBackend)
}
};
for (int i = 0; i < 3 && display == EGL_NO_DISPLAY; ++i) {
- display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,
- nativeDisplay, attribs[i]);
+ display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,nativeDisplay, attribs[i]);
}
}
return display;
@@ -79,6 +80,7 @@ SkANGLEGLContext::SkANGLEGLContext(bool useGLBackend)
EGL_NONE
};
+ fIsGLBackend = useGLBackend;
fDisplay = GetD3DEGLDisplay(EGL_DEFAULT_DISPLAY, useGLBackend);
if (EGL_NO_DISPLAY == fDisplay) {
SkDebugf("Could not create EGL display!");
@@ -129,6 +131,62 @@ SkANGLEGLContext::~SkANGLEGLContext() {
this->destroyGLContext();
}
+GrEGLImage SkANGLEGLContext::texture2DToEGLImage(GrGLuint texID) const {
+ if (!this->gl()->hasExtension("EGL_KHR_gl_texture_2D_image")) {
+ return GR_EGL_NO_IMAGE;
+ }
+ GrEGLImage img;
+ GrEGLint attribs[] = { GR_EGL_GL_TEXTURE_LEVEL, 0,
+ GR_EGL_IMAGE_PRESERVED, GR_EGL_TRUE,
+ GR_EGL_NONE };
+ // 64 bit cast is to shut Visual C++ up about casting 32 bit value to a pointer.
+ GrEGLClientBuffer clientBuffer = reinterpret_cast<GrEGLClientBuffer>((uint64_t)texID);
+ GR_GL_CALL_RET(this->gl(), img,
+ EGLCreateImage(fDisplay, fContext, GR_EGL_GL_TEXTURE_2D, clientBuffer,
+ attribs));
+ return img;
+}
+
+void SkANGLEGLContext::destroyEGLImage(GrEGLImage image) const {
+ GR_GL_CALL(this->gl(), EGLDestroyImage(fDisplay, image));
+}
+
+GrGLuint SkANGLEGLContext::eglImageToExternalTexture(GrEGLImage image) const {
+ GrGLClearErr(this->gl());
+ if (!this->gl()->hasExtension("GL_OES_EGL_image_external")) {
+ return 0;
+ }
+ GrGLEGLImageTargetTexture2DProc glEGLImageTargetTexture2D =
+ (GrGLEGLImageTargetTexture2DProc)eglGetProcAddress("glEGLImageTargetTexture2DOES");
+ if (!glEGLImageTargetTexture2D) {
+ return 0;
+ }
+ GrGLuint texID;
+ GR_GL_CALL(this->gl(), GenTextures(1, &texID));
+ if (!texID) {
+ return 0;
+ }
+ GR_GL_CALL(this->gl(), BindTexture(GR_GL_TEXTURE_EXTERNAL, texID));
+ if (GR_GL_GET_ERROR(this->gl()) != GR_GL_NO_ERROR) {
+ GR_GL_CALL(this->gl(), DeleteTextures(1, &texID));
+ return 0;
+ }
+ glEGLImageTargetTexture2D(GR_GL_TEXTURE_EXTERNAL, image);
+ if (GR_GL_GET_ERROR(this->gl()) != GR_GL_NO_ERROR) {
+ GR_GL_CALL(this->gl(), DeleteTextures(1, &texID));
+ return 0;
+ }
+ return texID;
+}
+
+SkGLContext* SkANGLEGLContext::createNew() const {
+ SkGLContext* ctx = SkANGLEGLContext::Create(this->gl()->fStandard, fIsGLBackend);
+ if (ctx) {
+ ctx->makeCurrent();
+ }
+ return ctx;
+}
+
void SkANGLEGLContext::destroyGLContext() {
if (fDisplay) {
eglMakeCurrent(fDisplay, 0, 0, 0);
« no previous file with comments | « src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp ('k') | src/gpu/gl/builders/GrGLProgramBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698