surfaceflinger: add image abstraction to RenderEngine
Similar to Surface, Image manages the creation and destruction of an
EGLImageKHR.
Test: builds
Change-Id: I2ca98e99013f0a4028f0ea5036f37b20fd67d956
diff --git a/services/surfaceflinger/RenderEngine/RenderEngine.cpp b/services/surfaceflinger/RenderEngine/RenderEngine.cpp
index d5471ad..f1415c9 100644
--- a/services/surfaceflinger/RenderEngine/RenderEngine.cpp
+++ b/services/surfaceflinger/RenderEngine/RenderEngine.cpp
@@ -20,6 +20,7 @@
#include "GLES20RenderEngine.h"
#include "GLExtensions.h"
+#include "Image.h"
#include "Mesh.h"
#include "RenderEngine.h"
@@ -152,6 +153,10 @@
return mEGLConfig;
}
+bool RenderEngine::supportsImageCrop() const {
+ return GLExtensions::getInstance().hasImageCrop();
+}
+
bool RenderEngine::setCurrentSurface(const RE::Surface& surface) {
bool success = true;
EGLSurface eglSurface = surface.getEGLSurface();
@@ -324,6 +329,15 @@
glDeleteTextures(count, names);
}
+void RenderEngine::bindExternalTextureImage(uint32_t texName, const RE::Image& image) {
+ const GLenum target = GL_TEXTURE_EXTERNAL_OES;
+
+ glBindTexture(target, texName);
+ if (image.getEGLImage() != EGL_NO_IMAGE_KHR) {
+ glEGLImageTargetTexture2DOES(target, static_cast<GLeglImageOES>(image.getEGLImage()));
+ }
+}
+
void RenderEngine::readPixels(size_t l, size_t b, size_t w, size_t h, uint32_t* pixels) {
glReadPixels(l, b, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
}