Пример #1
0
EJCanvasContext::~EJCanvasContext()
{
	fontCache->release();
	
	// Release all fonts and clip paths from the stack
	for( int i = 0; i < stateIndex + 1; i++ ) {
		stateStack[i].font->release();
		//stateStack[i].clipPath->release();
	}

#ifdef _WINDOWS
	if( viewFrameBuffer ) { glDeleteFramebuffers( 1, &viewFrameBuffer); }
	if( viewRenderBuffer ) { glDeleteRenderbuffers(1, &viewRenderBuffer); }
	if( msaaFrameBuffer ) {	glDeleteFramebuffers( 1, &msaaFrameBuffer); }
	if( msaaRenderBuffer ) { glDeleteRenderbuffers(1, &msaaRenderBuffer); }
	if( stencilBuffer ) { glDeleteRenderbuffers(1, &stencilBuffer); }
#else
	if( viewFrameBuffer ) { glDeleteFramebuffersOES( 1, &viewFrameBuffer); }
	if( viewRenderBuffer ) { glDeleteRenderbuffersOES(1, &viewRenderBuffer); }
	if( msaaFrameBuffer ) {	glDeleteFramebuffersOES( 1, &msaaFrameBuffer); }
	if( msaaRenderBuffer ) { glDeleteRenderbuffersOES(1, &msaaRenderBuffer); }
	if( stencilBuffer ) { glDeleteRenderbuffersOES(1, &stencilBuffer); }
#endif
	
	path->release();

}
Пример #2
0
void DestroySurfaceGLES(EAGLSurfaceDesc* surface)
{
	if( surface->systemRenderbuffer )
	{
		GLES_CHK( glBindRenderbufferOES(GL_RENDERBUFFER_OES, surface->systemRenderbuffer) );
		DeallocateRenderBufferStorageFromEAGLLayer();

		GLES_CHK( glBindRenderbufferOES(GL_RENDERBUFFER_OES, 0) );
		GLES_CHK( glDeleteRenderbuffersOES(1, &surface->systemRenderbuffer) );

		surface->systemRenderbuffer = 0;
	}

	if( surface->systemFramebuffer )
	{
		GLES_CHK( glDeleteFramebuffersOES(1, &surface->systemFramebuffer) );
		surface->systemFramebuffer = 0;
	}

	DestroyRenderingSurfaceGLES(surface);

	if(surface->depthbuffer)
	{
		GLES_CHK( glDeleteRenderbuffersOES(1, &surface->depthbuffer) );
		surface->depthbuffer = 0;
	}
}
void DestroySurfaceMultisampleBuffersGLES(EAGLSurfaceDesc* surface)
{
	if(surface->depthbuffer)
	{
		GLES_CHK( glDeleteRenderbuffersOES(1, &surface->depthbuffer) );
	}
	surface->depthbuffer = 0;

	if(surface->msaaDepthbuffer)
	{
		GLES_CHK( glDeleteRenderbuffersOES(1, &surface->msaaDepthbuffer) );
	}
	surface->msaaDepthbuffer = 0;

	if(surface->msaaRenderbuffer)
	{
		GLES_CHK( glDeleteRenderbuffersOES(1, &surface->msaaRenderbuffer) );
	}
	surface->msaaRenderbuffer = 0;

	if (surface->msaaFramebuffer)
	{
		GLES_CHK( glDeleteFramebuffersOES(1, &surface->msaaFramebuffer) );
	}
	surface->msaaFramebuffer = 0;
}
Пример #4
0
void DestroyRenderingSurfaceGLES(EAGLSurfaceDesc* surface)
{
	if( (surface->msaaFramebuffer || surface->targetFramebuffer) && surface->depthbuffer )
	{
		GLES_CHK( glDeleteRenderbuffersOES(1, &surface->depthbuffer) );
		surface->depthbuffer = 0;
	}

	if(surface->targetRT)
	{
		GLES_CHK( glDeleteTextures(1, &surface->targetRT) );
		surface->targetRT = 0;
	}

	if(surface->targetFramebuffer)
	{
		GLES_CHK( glDeleteFramebuffersOES(1, &surface->targetFramebuffer) );
		surface->targetFramebuffer = 0;
	}

	if(surface->msaaRenderbuffer)
	{
		GLES_CHK( glDeleteRenderbuffersOES(1, &surface->msaaRenderbuffer) );
		surface->msaaRenderbuffer = 0;
	}

	if(surface->msaaFramebuffer)
	{
		GLES_CHK( glDeleteFramebuffersOES(1, &surface->msaaFramebuffer) );
		surface->msaaFramebuffer = 0;
	}
}
Пример #5
0
    /** Try a certain FBO format, and return the status. Also sets mDepthRB and mStencilRB.
        @returns true    if this combo is supported
                 false   if this combo is not supported
    */
    GLuint GLESFBOManager::_tryFormat(GLenum depthFormat, GLenum stencilFormat)
    {
        GLuint status, depthRB = 0, stencilRB = 0;

        if(depthFormat != GL_NONE)
        {
            /// Generate depth renderbuffer
            glGenRenderbuffersOES(1, &depthRB);

            /// Bind it to FBO
            glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRB);
            
            /// Allocate storage for depth buffer
            glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthFormat,
                                PROBE_SIZE, PROBE_SIZE);
            
            /// Attach depth
            glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES,
                                    GL_RENDERBUFFER_OES, depthRB);
        }

        // Stencil buffers aren't available on iPhone
        if(stencilFormat != GL_NONE)
        {
            /// Generate stencil renderbuffer
            glGenRenderbuffersOES(1, &stencilRB);
            
            /// Bind it to FBO
            glBindRenderbufferOES(GL_RENDERBUFFER_OES, stencilRB);

            /// Allocate storage for stencil buffer
            glRenderbufferStorageOES(GL_RENDERBUFFER_OES, stencilFormat,
                                PROBE_SIZE, PROBE_SIZE); 

            /// Attach stencil
            glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES,
                            GL_RENDERBUFFER_OES, stencilRB);
        }

        status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);

        /// If status is negative, clean up
        // Detach and destroy
        glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, 0);

        glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES, GL_RENDERBUFFER_OES, 0);

        if (depthRB)
            glDeleteRenderbuffersOES(1, &depthRB);

        if (stencilRB)
            glDeleteRenderbuffersOES(1, &stencilRB);
        
        return status == GL_FRAMEBUFFER_COMPLETE_OES;
    }
Пример #6
0
void Screen::DestroyHardwareSurfaces()
{
	glDeleteFramebuffersOES(1, &frameBuffer);
	frameBuffer = 0;
	glDeleteRenderbuffersOES(1, &renderBuffer);
	renderBuffer = 0;

#if SEED_ENABLE_DEPTH_TEST
	if (depthRenderbuffer)
	{
		glDeleteRenderbuffersOES(1, &depthRenderbuffer);
		depthRenderbuffer = 0;
	}
#endif // SEED_ENABLE_DEPTH_TEST
}
 inline void VL_glDeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers)
 {
   if (glDeleteRenderbuffersOES)
     glDeleteRenderbuffersOES(n, renderbuffers);
   else
     VL_TRAP();
 }
void CreateSurfaceGLES(EAGLSurfaceDesc* surface)
{
	GLuint oldRenderbuffer;
	GLES_CHK( glGetIntegerv(GL_RENDERBUFFER_BINDING_OES, (GLint *) &oldRenderbuffer) );

	DestroySurfaceGLES(surface);

	InitEAGLLayer(surface->eaglLayer, surface->use32bitColor);

	GLES_CHK( glGenRenderbuffersOES(1, &surface->renderbuffer) );
	GLES_CHK( glBindRenderbufferOES(GL_RENDERBUFFER_OES, surface->renderbuffer) );

	if( !AllocateRenderBufferStorageFromEAGLLayer(surface->eaglLayer) )
	{
		GLES_CHK( glDeleteRenderbuffersOES(1, &surface->renderbuffer) );
		GLES_CHK( glBindRenderbufferOES(GL_RENDERBUFFER_BINDING_OES, oldRenderbuffer) );

		printf_console("FAILED allocating render buffer storage from gles context\n");
		return;
	}

	GLES_CHK( glGenFramebuffersOES(1, &surface->framebuffer) );

	UNITY_DBG_LOG ("glBindFramebufferOES(GL_FRAMEBUFFER_OES, %d) :: AppCtrl\n", surface->framebuffer);
	GLES_CHK( glBindFramebufferOES(GL_FRAMEBUFFER_OES, surface->framebuffer) );

	gDefaultFBO = surface->framebuffer;

	UNITY_DBG_LOG ("glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, %d) :: AppCtrl\n", surface->renderbuffer);
	GLES_CHK( glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, surface->renderbuffer) );

	CreateSurfaceMultisampleBuffersGLES(surface);
}
Пример #9
0
    /** Try a certain packed depth/stencil format, and return the status.
        @returns true    if this combo is supported
                 false   if this combo is not supported
    */
    bool GLESFBOManager::_tryPackedFormat(GLenum packedFormat)
    {
        GLuint packedRB;

        /// Generate renderbuffer
        glGenRenderbuffersOES(1, &packedRB);

        /// Bind it to FBO
        glBindRenderbufferOES(GL_RENDERBUFFER_OES, packedRB);

        /// Allocate storage for buffer
        glRenderbufferStorageOES(GL_RENDERBUFFER_OES, packedFormat, PROBE_SIZE, PROBE_SIZE);

        /// Attach depth
        glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES,
            GL_RENDERBUFFER_OES, packedRB);

        /// Attach stencil
        glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES,
            GL_RENDERBUFFER_OES, packedRB);

        GLuint status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);

        /// Detach and destroy
        glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, 0);
        glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES, GL_RENDERBUFFER_OES, 0);
        glDeleteRenderbuffersOES(1, &packedRB);

        return status == GL_FRAMEBUFFER_COMPLETE_OES;
    }
void GLES11RenderEngine::unbindFramebuffer(uint32_t texName, uint32_t fbName,
        bool useReadPixels) {
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
    glDeleteFramebuffersOES(1, &fbName);
    if (!useReadPixels)
        glDeleteTextures(1, &texName);
    else
        glDeleteRenderbuffersOES(1, &texName);
}
Пример #11
0
	OpenGLRTTexture::~OpenGLRTTexture()
	{
		if (mFBOID != 0)
		{
			glDeleteFramebuffersOES(1, &mFBOID);
			mFBOID = 0;
		}
		if (mRBOID != 0)
		{
			glDeleteRenderbuffersOES(1, &mRBOID);
			mRBOID = 0;
		}
	}
Пример #12
0
static bool
try_as_render_buffer(EGLImageKHR img)
{
	GLuint rbo;
	bool res;

	glGenRenderbuffersOES(1, &rbo);
	glBindRenderbufferOES(GL_RENDERBUFFER_OES, rbo);
	glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER_OES, img);
	res = piglit_check_gl_error(GL_NO_ERROR);
	glDeleteRenderbuffersOES(1, &rbo);

	return res;
}
 void GLESStateCacheManagerImp::deleteGLBuffer(GLenum target, GLuint buffer, GLenum attach, bool force)
 {
     // Buffer name 0 is reserved and we should never try to delete it
     if(buffer == 0)
         return;
     
     if(target == GL_FRAMEBUFFER_OES)
         glDeleteFramebuffersOES(1, &buffer);
     else if(target == GL_RENDERBUFFER_OES)
         glDeleteRenderbuffersOES(1, &buffer);
     else
         glDeleteBuffers(1, &buffer);
     
     GL_CHECK_ERROR
 }
Пример #14
0
void destroyFBO(FBO *fbo) {
    if (fbo==NULL) {
        logError(TAG, "Cannot destroy Default FBO");
        return;
    }
    GLuint drbId = fbo->mDepthRenderBuffer;
    GLuint fboId = fbo->mFBO;
    // switch to default FBO
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
    // delete texture
    destroyTexture(fbo->mTexturePtrId);
    // delete depth buffer
    glDeleteRenderbuffersOES(1, &drbId);
    // delete framebuffer
    glDeleteFramebuffersOES(1, &fboId);
}
Пример #15
0
int releaseFrameBuffer(AndroidContext *rc)
{
	LOG( ANDROID_LOG_DEBUG, TAG, "Android Delete FrameBuffer");

	glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);

	if ( rc->framebuff >= 0 )
	{
		glDeleteFramebuffersOES(1, &(rc->framebuff));
		rc->framebuff = -1;
	}
	if ( rc->depthbuff >= 0 )
	{
		glDeleteRenderbuffersOES(1, &(rc->depthbuff));
		rc->depthbuff = -1;
	}
}
Пример #16
0
GL11Renderer::~GL11Renderer()
{
    if( m_snowTextureId )
	{
		glDeleteTextures( 1, &m_snowTextureId );
		m_snowTextureId = 0;
	}

	if( m_vertexBufferId )
	{
		glDeleteBuffers( 1, &m_vertexBufferId );
		m_vertexBufferId = 0;
	}
    
    if( m_colorBufferId )
	{
		glDeleteBuffers( 1, &m_colorBufferId );
		m_colorBufferId = 0;
	}
    
    if( m_pointSizeBufferId )
	{
		glDeleteBuffers( 1, &m_pointSizeBufferId );
		m_pointSizeBufferId = 0;
	}
	
    if( m_framebuffer )
	{
		glDeleteFramebuffersOES( 1, &m_framebuffer );
		m_framebuffer = 0;
	}
    
    if( m_depthRenderbuffer )
    {
        glDeleteFramebuffersOES( 1, &m_depthRenderbuffer );
        m_depthRenderbuffer = 0;
    }
    
	if( m_colorRenderbuffer )
	{
		glDeleteRenderbuffersOES( 1, &m_colorRenderbuffer );
		m_colorRenderbuffer = 0;
	}
}
void DestroySurfaceGLES(EAGLSurfaceDesc* surface)
{
	if( surface->renderbuffer )
	{
		GLES_CHK( glBindRenderbufferOES(GL_RENDERBUFFER_OES, surface->renderbuffer) );
		DeallocateRenderBufferStorageFromEAGLLayer();

		GLES_CHK( glBindRenderbufferOES(GL_RENDERBUFFER_OES, 0) );
		GLES_CHK( glDeleteRenderbuffersOES(1, &surface->renderbuffer) );

		surface->renderbuffer = 0;
	}

	if( surface->framebuffer )
	{
		GLES_CHK( glDeleteFramebuffersOES(1, &surface->framebuffer) );
		surface->framebuffer = 0;
	}

	DestroySurfaceMultisampleBuffersGLES(surface);
}
GL_API void GL_APIENTRY glGenRenderbuffersOES (GLsizei n, GLuint* renderbuffers)
{
	if(n <= 0)
		return;

	int name;
	GLsizei i = n;
	GLuint *cur = renderbuffers;
	FGLContext *ctx = getContext();

	do {
		name = fglRenderbufferObjects.get(ctx);
		if(name < 0) {
			glDeleteRenderbuffersOES (n - i, renderbuffers);
			setError(GL_OUT_OF_MEMORY);
			return;
		}
		fglRenderbufferObjects[name] = NULL;
		*cur = name;
		cur++;
	} while (--i);
}
Пример #19
0
sgTexture::~sgTexture()
{
	if(fbo != -1)
	{
		if(sgRenderer::oglversion > 1)
		{
			glDeleteFramebuffers(1, &fbo);
			glDeleteRenderbuffers(1, &fbo_depth);
		}else
		{
#if defined __IOS__
			glDeleteFramebuffersOES(1, &fbo);
			glDeleteRenderbuffersOES(1, &fbo_depth);
#endif
		}
	}

	if(texid != -1)
		glDeleteTextures(1, &texid);

	if(texdata != NULL)
		delete[] texdata;
}
Пример #20
0
RenderES1::~RenderES1()
{
    glDeleteFramebuffersOES(1, &_frame_buffer);
    glDeleteRenderbuffersOES(1, &_render_buffer);
}
 //----------------------------------------------------------------------------- 
 GLESRenderBuffer::~GLESRenderBuffer()
 {
     // Generate renderbuffer
     glDeleteRenderbuffersOES(1, &mRenderbufferID);
     GL_CHECK_ERROR;
 }
void glDeleteRenderbuffersOESLogged(GLsizei n, const GLuint* renderbuffers) {
	printf("glDeleteRenderbuffersOES(%i, %p)\n", n, renderbuffers);
	glDeleteRenderbuffersOES(n, renderbuffers);
}
Пример #23
0
		virtual void deleteFBO(GLuint framebuffer, GLuint depthbuffer, GLuint img)
		{
			glDeleteTextures(1, &img);
			glDeleteRenderbuffersOES(1, &depthbuffer);
			glDeleteFramebuffersOES(1, &framebuffer);
		}
Пример #24
0
status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy,
        sp<IMemoryHeap>* heap,
        uint32_t* w, uint32_t* h, PixelFormat* f,
        uint32_t sw, uint32_t sh)
{
   LOGI("captureScreenImplLocked");
    status_t result = PERMISSION_DENIED;

    // only one display supported for now
    if (UNLIKELY(uint32_t(dpy) >= DISPLAY_COUNT))
        return BAD_VALUE;

    if (!GLExtensions::getInstance().haveFramebufferObject())
        return INVALID_OPERATION;

    // get screen geometry
    const DisplayHardware& hw(graphicPlane(dpy).displayHardware());
    const uint32_t hw_w = hw.getWidth();
    const uint32_t hw_h = hw.getHeight();

    if ((sw > hw_w) || (sh > hw_h))
        return BAD_VALUE;

    sw = (!sw) ? hw_w : sw;
    sh = (!sh) ? hw_h : sh;
    const size_t size = sw * sh * 4;

    // make sure to clear all GL error flags
    while ( glGetError() != GL_NO_ERROR ) ;

    // create a FBO
    GLuint name, tname;
    glGenRenderbuffersOES(1, &tname);
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, tname);
    glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_RGBA8_OES, sw, sh);
    glGenFramebuffersOES(1, &name);
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, name);
    glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES,
            GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, tname);

    GLenum status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
    if (status == GL_FRAMEBUFFER_COMPLETE_OES) {

        // invert everything, b/c glReadPixel() below will invert the FB
        glViewport(0, 0, sw, sh);
        glScissor(0, 0, sw, sh);
        glMatrixMode(GL_PROJECTION);
        glPushMatrix();
        glLoadIdentity();
        glOrthof(0, hw_w, 0, hw_h, 0, 1);
        glMatrixMode(GL_MODELVIEW);

        // redraw the screen entirely...
        glClearColor(0,0,0,1);
        glClear(GL_COLOR_BUFFER_BIT);

        const Vector< sp<LayerBase> >& layers(mVisibleLayersSortedByZ);
        const size_t count = layers.size();
        for (size_t i=0 ; i<count ; ++i) {
            const sp<LayerBase>& layer(layers[i]);
            layer->drawForSreenShot();
        }

        // XXX: this is needed on tegra
        glScissor(0, 0, sw, sh);

        // check for errors and return screen capture
        if (glGetError() != GL_NO_ERROR) {
            // error while rendering
            result = INVALID_OPERATION;
        } else {
            // allocate shared memory large enough to hold the
            // screen capture
            sp<MemoryHeapBase> base(
                    new MemoryHeapBase(size, 0, "screen-capture") );
            void* const ptr = base->getBase();
            if (ptr) {
                // capture the screen with glReadPixels()
                glReadPixels(0, 0, sw, sh, GL_RGBA, GL_UNSIGNED_BYTE, ptr);
                if (glGetError() == GL_NO_ERROR) {
                    *heap = base;
                    *w = sw;
                    *h = sh;
                    *f = PIXEL_FORMAT_RGBA_8888;
                    result = NO_ERROR;
                }
            } else {
                result = NO_MEMORY;
            }
        }
        glEnable(GL_SCISSOR_TEST);
        glViewport(0, 0, hw_w, hw_h);
        glMatrixMode(GL_PROJECTION);
        glPopMatrix();
        glMatrixMode(GL_MODELVIEW);


    } else {
        result = BAD_VALUE;
    }

    // release FBO resources
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
    glDeleteRenderbuffersOES(1, &tname);
    glDeleteFramebuffersOES(1, &name);

    hw.compositionComplete();

    return result;
}