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

Unified Diff: src/gpu/gl/egl/SkCreatePlatformGLContext_egl.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/egl/GrGLCreateNativeInterface_egl.cpp ('k') | src/gpu/glsl/GrGLSL.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp
diff --git a/src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp b/src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp
index d1335d355f56a7e535641e9cf660e738ad60a880..591cae349c0f8925b4697ad5f30f352890d125cc 100644
--- a/src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp
+++ b/src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp
@@ -13,6 +13,9 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
+#include "gl/GrGLDefines.h"
+#include "gl/GrGLUtil.h"
+
namespace {
// TODO: Share this class with ANGLE if/when it gets support for EGL_KHR_fence_sync.
@@ -37,6 +40,11 @@ public:
EGLGLContext(GrGLStandard forcedGpuAPI);
~EGLGLContext() override;
+ GrEGLImage texture2DToEGLImage(GrGLuint texID) const override;
+ void destroyEGLImage(GrEGLImage) const override;
+ GrGLuint eglImageToExternalTexture(GrEGLImage) const override;
+ SkGLContext* createNew() const override;
+
private:
void destroyGLContext();
@@ -200,6 +208,57 @@ void EGLGLContext::destroyGLContext() {
}
}
+GrEGLImage EGLGLContext::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_NONE };
+ GrEGLClientBuffer clientBuffer = reinterpret_cast<GrEGLClientBuffer>(texID);
+ GR_GL_CALL_RET(this->gl(), img,
+ EGLCreateImage(fDisplay, fContext, GR_EGL_GL_TEXTURE_2D, clientBuffer, attribs));
+ return img;
+}
+
+void EGLGLContext::destroyEGLImage(GrEGLImage image) const {
+ GR_GL_CALL(this->gl(), EGLDestroyImage(fDisplay, image));
+}
+
+GrGLuint EGLGLContext::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;
+ glGenTextures(1, &texID);
+ if (!texID) {
+ return 0;
+ }
+ glBindTexture(GR_GL_TEXTURE_EXTERNAL, texID);
+ if (glGetError() != GR_GL_NO_ERROR) {
+ glDeleteTextures(1, &texID);
+ return 0;
+ }
+ glEGLImageTargetTexture2D(GR_GL_TEXTURE_EXTERNAL, image);
+ if (glGetError() != GR_GL_NO_ERROR) {
+ glDeleteTextures(1, &texID);
+ return 0;
+ }
+ return texID;
+}
+
+SkGLContext* EGLGLContext::createNew() const {
+ SkGLContext* ctx = SkCreatePlatformGLContext(this->gl()->fStandard);
+ if (ctx) {
+ ctx->makeCurrent();
+ }
+ return ctx;
+}
void EGLGLContext::onPlatformMakeCurrent() const {
if (!eglMakeCurrent(fDisplay, fSurface, fSurface, fContext)) {
« no previous file with comments | « src/gpu/gl/egl/GrGLCreateNativeInterface_egl.cpp ('k') | src/gpu/glsl/GrGLSL.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698