RenderEngine.cpp revision 19733a32799f792125913e746e8644d16f8dc223
1875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian/* 2875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * Copyright 2013 The Android Open Source Project 3875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * 4875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * Licensed under the Apache License, Version 2.0 (the "License"); 5875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * you may not use this file except in compliance with the License. 6875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * You may obtain a copy of the License at 7875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * 8875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * http://www.apache.org/licenses/LICENSE-2.0 9875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * 10875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * Unless required by applicable law or agreed to in writing, software 11875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * distributed under the License is distributed on an "AS IS" BASIS, 12875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * See the License for the specific language governing permissions and 14875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian * limitations under the License. 15875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian */ 16875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 17875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian#include <cutils/log.h> 183f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian#include <ui/Rect.h> 193f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian#include <ui/Region.h> 20875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 21875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian#include "RenderEngine.h" 22875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian#include "GLES10RenderEngine.h" 23875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian#include "GLES11RenderEngine.h" 243f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian#include "GLES20RenderEngine.h" 25875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian#include "GLExtensions.h" 263f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian#include "Mesh.h" 27875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 28875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian// --------------------------------------------------------------------------- 29875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopiannamespace android { 30875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian// --------------------------------------------------------------------------- 31875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 32875d8e1323536e16dcfc90c9674d7ad32116a69aMathias AgopianRenderEngine* RenderEngine::create(EGLDisplay display, EGLConfig config) { 33875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian // Also create our EGLContext 34875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian EGLint contextAttributes[] = { 353f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian EGL_CONTEXT_CLIENT_VERSION, 2, // MUST be first 36875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian#ifdef EGL_IMG_context_priority 37875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian#ifdef HAS_CONTEXT_PRIORITY 38875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian#warning "using EGL_IMG_context_priority" 39875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, 40875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian#endif 41875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian#endif 42875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian EGL_NONE, EGL_NONE 43875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian }; 44875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 45458197de008be8fe561286b09f4edddb2f5c540aMathias Agopian EGLContext ctxt = eglCreateContext(display, config, NULL, contextAttributes); 46875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian if (ctxt == EGL_NO_CONTEXT) { 47875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian // maybe ES 2.x is not supported 48875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian ALOGW("can't create an ES 2.x context, trying 1.x"); 49875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian ctxt = eglCreateContext(display, config, NULL, contextAttributes + 2); 50875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian } 51875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 52875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian // if can't create a GL context, we can only abort. 53875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian LOG_ALWAYS_FATAL_IF(ctxt==EGL_NO_CONTEXT, "EGLContext creation failed"); 54875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 55875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 56875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian // now figure out what version of GL did we actually get 57875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian // NOTE: a dummy surface is not needed if KHR_create_context is supported 58875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 59875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian EGLint attribs[] = { EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE, EGL_NONE }; 60875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian EGLSurface dummy = eglCreatePbufferSurface(display, config, attribs); 61875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian LOG_ALWAYS_FATAL_IF(dummy==EGL_NO_SURFACE, "can't create dummy pbuffer"); 62875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian EGLBoolean success = eglMakeCurrent(display, dummy, dummy, ctxt); 63875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian LOG_ALWAYS_FATAL_IF(!success, "can't make dummy pbuffer current"); 64875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 65875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian GLExtensions& extensions(GLExtensions::getInstance()); 66875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian extensions.initWithGLStrings( 67875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian glGetString(GL_VENDOR), 68875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian glGetString(GL_RENDERER), 69875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian glGetString(GL_VERSION), 70875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian glGetString(GL_EXTENSIONS)); 71875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 72875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian GlesVersion version = parseGlesVersion( extensions.getVersion() ); 73875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 74875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian // initialize the renderer while GL is current 75875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 76875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian RenderEngine* engine = NULL; 77875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian switch (version) { 78875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian case GLES_VERSION_1_0: 79875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian engine = new GLES10RenderEngine(); 80875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian break; 81875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian case GLES_VERSION_1_1: 82875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian engine = new GLES11RenderEngine(); 83875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian break; 84875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian case GLES_VERSION_2_0: 85875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian case GLES_VERSION_3_0: 863f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian engine = new GLES20RenderEngine(); 87875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian break; 88875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian } 89875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian engine->setEGLContext(ctxt); 90875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 91875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian ALOGI("OpenGL ES informations:"); 92875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian ALOGI("vendor : %s", extensions.getVendor()); 93875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian ALOGI("renderer : %s", extensions.getRenderer()); 94875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian ALOGI("version : %s", extensions.getVersion()); 95875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian ALOGI("extensions: %s", extensions.getExtension()); 96875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian ALOGI("GL_MAX_TEXTURE_SIZE = %d", engine->getMaxTextureSize()); 97875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian ALOGI("GL_MAX_VIEWPORT_DIMS = %d", engine->getMaxViewportDims()); 98875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 99875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); 100875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian eglDestroySurface(display, dummy); 101875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 102875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian return engine; 103875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian} 104875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 105875d8e1323536e16dcfc90c9674d7ad32116a69aMathias AgopianRenderEngine::RenderEngine() : mEGLContext(EGL_NO_CONTEXT) { 106875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian} 107875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 108875d8e1323536e16dcfc90c9674d7ad32116a69aMathias AgopianRenderEngine::~RenderEngine() { 109875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian} 110875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 111875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopianvoid RenderEngine::setEGLContext(EGLContext ctxt) { 112875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian mEGLContext = ctxt; 113875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian} 114875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 115875d8e1323536e16dcfc90c9674d7ad32116a69aMathias AgopianEGLContext RenderEngine::getEGLContext() const { 116875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian return mEGLContext; 117875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian} 118875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 119875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopianvoid RenderEngine::checkErrors() const { 120875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian do { 121875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian // there could be more than one error flag 122875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian GLenum error = glGetError(); 123875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian if (error == GL_NO_ERROR) 124875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian break; 125875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian ALOGE("GL error 0x%04x", int(error)); 126875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian } while (true); 127875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian} 128875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 129875d8e1323536e16dcfc90c9674d7ad32116a69aMathias AgopianRenderEngine::GlesVersion RenderEngine::parseGlesVersion(const char* str) { 130875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian int major, minor; 131875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian if (sscanf(str, "OpenGL ES-CM %d.%d", &major, &minor) != 2) { 132875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian if (sscanf(str, "OpenGL ES %d.%d", &major, &minor) != 2) { 133875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian ALOGW("Unable to parse GL_VERSION string: \"%s\"", str); 134875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian return GLES_VERSION_1_0; 135875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian } 136875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian } 137875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 138875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian if (major == 1 && minor == 0) return GLES_VERSION_1_0; 139875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian if (major == 1 && minor >= 1) return GLES_VERSION_1_1; 140875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian if (major == 2 && minor >= 0) return GLES_VERSION_2_0; 141875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian if (major == 3 && minor >= 0) return GLES_VERSION_3_0; 142875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 143875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian ALOGW("Unrecognized OpenGL ES version: %d.%d", major, minor); 144875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian return GLES_VERSION_1_0; 145875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian} 146875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian 1473f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopianvoid RenderEngine::fillRegionWithColor(const Region& region, uint32_t height, 1483f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian float red, float green, float blue, float alpha) { 1493f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian size_t c; 1503f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian Rect const* r = region.getArray(&c); 1513f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian Mesh mesh(Mesh::TRIANGLES, c*6, 2); 1525cdc8994a0ecd751a6350b16a1bef8b6b0d09b11Mathias Agopian Mesh::VertexArray position(mesh.getPositionArray()); 1533f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian for (size_t i=0 ; i<c ; i++, r++) { 1545cdc8994a0ecd751a6350b16a1bef8b6b0d09b11Mathias Agopian position[i*6 + 0].x = r->left; 1555cdc8994a0ecd751a6350b16a1bef8b6b0d09b11Mathias Agopian position[i*6 + 0].y = height - r->top; 1565cdc8994a0ecd751a6350b16a1bef8b6b0d09b11Mathias Agopian position[i*6 + 1].x = r->left; 1575cdc8994a0ecd751a6350b16a1bef8b6b0d09b11Mathias Agopian position[i*6 + 1].y = height - r->bottom; 1585cdc8994a0ecd751a6350b16a1bef8b6b0d09b11Mathias Agopian position[i*6 + 2].x = r->right; 1595cdc8994a0ecd751a6350b16a1bef8b6b0d09b11Mathias Agopian position[i*6 + 2].y = height - r->bottom; 1605cdc8994a0ecd751a6350b16a1bef8b6b0d09b11Mathias Agopian position[i*6 + 3].x = r->left; 1615cdc8994a0ecd751a6350b16a1bef8b6b0d09b11Mathias Agopian position[i*6 + 3].y = height - r->top; 1625cdc8994a0ecd751a6350b16a1bef8b6b0d09b11Mathias Agopian position[i*6 + 4].x = r->right; 1635cdc8994a0ecd751a6350b16a1bef8b6b0d09b11Mathias Agopian position[i*6 + 4].y = height - r->bottom; 1645cdc8994a0ecd751a6350b16a1bef8b6b0d09b11Mathias Agopian position[i*6 + 5].x = r->right; 1655cdc8994a0ecd751a6350b16a1bef8b6b0d09b11Mathias Agopian position[i*6 + 5].y = height - r->top; 1663f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian } 16719733a32799f792125913e746e8644d16f8dc223Mathias Agopian setupFillWithColor(red, green, blue, alpha); 16819733a32799f792125913e746e8644d16f8dc223Mathias Agopian drawMesh(mesh); 1693f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian} 1703f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian 1713f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopianvoid RenderEngine::clearWithColor(float red, float green, float blue, float alpha) { 1723f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian glClearColor(red, green, blue, alpha); 1733f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian glClear(GL_COLOR_BUFFER_BIT); 1743f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian} 1753f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian 1763f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopianvoid RenderEngine::setScissor( 1773f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian uint32_t left, uint32_t bottom, uint32_t right, uint32_t top) { 1783f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian glScissor(left, bottom, right, top); 1793f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian glEnable(GL_SCISSOR_TEST); 1803f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian} 1813f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian 1823f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopianvoid RenderEngine::disableScissor() { 1833f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian glDisable(GL_SCISSOR_TEST); 1843f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian} 1853f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian 1863f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopianvoid RenderEngine::genTextures(size_t count, uint32_t* names) { 1873f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian glGenTextures(count, names); 1883f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian} 1893f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian 1903f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopianvoid RenderEngine::deleteTextures(size_t count, uint32_t const* names) { 1913f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian glDeleteTextures(count, names); 1923f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian} 1933f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian 194458197de008be8fe561286b09f4edddb2f5c540aMathias Agopianvoid RenderEngine::dump(String8& result) { 195458197de008be8fe561286b09f4edddb2f5c540aMathias Agopian const GLExtensions& extensions(GLExtensions::getInstance()); 196458197de008be8fe561286b09f4edddb2f5c540aMathias Agopian result.appendFormat("GLES: %s, %s, %s\n", 197458197de008be8fe561286b09f4edddb2f5c540aMathias Agopian extensions.getVendor(), 198458197de008be8fe561286b09f4edddb2f5c540aMathias Agopian extensions.getRenderer(), 199458197de008be8fe561286b09f4edddb2f5c540aMathias Agopian extensions.getVersion()); 200458197de008be8fe561286b09f4edddb2f5c540aMathias Agopian result.appendFormat("%s\n", extensions.getExtension()); 201458197de008be8fe561286b09f4edddb2f5c540aMathias Agopian} 202458197de008be8fe561286b09f4edddb2f5c540aMathias Agopian 2033f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian// --------------------------------------------------------------------------- 2043f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian 2053f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias AgopianRenderEngine::BindImageAsFramebuffer::BindImageAsFramebuffer( 2063f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian RenderEngine& engine, EGLImageKHR image) : mEngine(engine) 2073f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian{ 208458197de008be8fe561286b09f4edddb2f5c540aMathias Agopian mEngine.bindImageAsFramebuffer(image, &mTexName, &mFbName, &mStatus); 209458197de008be8fe561286b09f4edddb2f5c540aMathias Agopian 2103f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian ALOGE_IF(mStatus != GL_FRAMEBUFFER_COMPLETE_OES, 2113f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian "glCheckFramebufferStatusOES error %d", mStatus); 2123f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian} 2133f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian 2143f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias AgopianRenderEngine::BindImageAsFramebuffer::~BindImageAsFramebuffer() { 2153f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian // back to main framebuffer 216458197de008be8fe561286b09f4edddb2f5c540aMathias Agopian mEngine.unbindFramebuffer(mTexName, mFbName); 2173f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian} 2183f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian 2193f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopianstatus_t RenderEngine::BindImageAsFramebuffer::getStatus() const { 2203f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian return mStatus == GL_FRAMEBUFFER_COMPLETE_OES ? NO_ERROR : BAD_VALUE; 2213f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian} 2223f84483382be2d528918cc1a6fbc6a7d68e0b181Mathias Agopian 223875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian// --------------------------------------------------------------------------- 224875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian}; // namespace android 225875d8e1323536e16dcfc90c9674d7ad32116a69aMathias Agopian// --------------------------------------------------------------------------- 226