bool Layer::resize(const uint32_t width, const uint32_t height) {
    uint32_t desiredWidth = computeIdealWidth(width);
    uint32_t desiredHeight = computeIdealWidth(height);

    if (desiredWidth <= getWidth() && desiredHeight <= getHeight()) {
        return true;
    }

    ATRACE_NAME("resizeLayer");

    const uint32_t maxTextureSize = caches.maxTextureSize;
    if (desiredWidth > maxTextureSize || desiredHeight > maxTextureSize) {
        ALOGW("Layer exceeds max. dimensions supported by the GPU (%dx%d, max=%dx%d)",
                desiredWidth, desiredHeight, maxTextureSize, maxTextureSize);
        return false;
    }

    uint32_t oldWidth = getWidth();
    uint32_t oldHeight = getHeight();

    setSize(desiredWidth, desiredHeight);

    if (fbo) {
        caches.textureState().activateTexture(0);
        bindTexture();
        allocateTexture();

        if (glGetError() != GL_NO_ERROR) {
            setSize(oldWidth, oldHeight);
            return false;
        }
    }

    if (stencil) {
        stencil->bind();
        stencil->resize(desiredWidth, desiredHeight);

        if (glGetError() != GL_NO_ERROR) {
            setSize(oldWidth, oldHeight);
            return false;
        }
    }

    return true;
}
Beispiel #2
0
bool VideoLayerChromium::allocateTexturesIfNeeded(GraphicsContext3D* context, VideoFrameChromium* frame, unsigned textureFormat)
{
    ASSERT(context);
    ASSERT(frame);

    for (unsigned plane = 0; plane < frame->planes(); plane++) {
        IntSize planeTextureSize = frame->requiredTextureSize(plane);

        // If the renderer cannot handle this large of a texture, return false.
        // FIXME: Remove this test when tiled layers are implemented.
        if (!layerRenderer()->checkTextureSize(planeTextureSize))
            return false;

        if (!m_textures[plane])
            m_textures[plane] = layerRenderer()->createLayerTexture();

        if (!planeTextureSize.isZero() && planeTextureSize != m_textureSizes[plane]) {
            allocateTexture(context, m_textures[plane], planeTextureSize, textureFormat);
            m_textureSizes[plane] = planeTextureSize;
            m_frameSizes[plane] = IntSize(frame->width(), frame->height());
        }
    }
    return true;
}
Beispiel #3
0
//--------------------------------------------------------------------------------
void ofxCvImage::allocate( int w, int h ) {
	if (bAllocated == true){
		ofLogVerbose("ofxCvImage") << "allocate(): reallocating";
		clear();
	}
	
	if( w == 0 || h == 0 ){
		ofLogError("ofxCvImage") << "allocate(): width and height are zero";
		return;
	}

	cvImage = cvCreateImage( cvSize(w,h), ipldepth, iplchannels );
	cvImageTemp	= cvCreateImage( cvSize(w,h), ipldepth, iplchannels );

	width = w;
	height = h;
	bAllocated = true;

    if( bUseTexture ) {
    	allocatePixels(w,h);
        allocateTexture();
        bTextureDirty = true;
    }
}
    //-----------------------------------------------------------------------
    void PagingLandScapeTextureManager::WorldDimensionChange()
    {
        const uint newWidth = mOptions->world_width; 
        const uint newHeight = mOptions->world_height;    

        if (newWidth != mWidth || newHeight != mHeight)
        {
            uint i,k;
            if (newWidth < mWidth )
            {
                for (i = newWidth; i <  mWidth; ++i)
	            {
                    PagingLandScapeTextureRow  *li = &mTexture[ i ];
                    for (k = 0; k < mHeight; k++ )
		            {
                        delete ((*li)[ k ]);
		            }            
                    li->clear();
	            }
                mTexture.reserve (newWidth);
                mTexture.resize (newWidth);


                if (newHeight < mHeight )
                { 
                    // clear pages
                    for (i = 0; i < newWidth; i++ )
	                {
                        PagingLandScapeTextureRow  *li = &mTexture[ i ];
                        for (k = newHeight; k < mHeight; ++k)
	                    {
                            delete (*li)[ k ];
	                    }
                        li->reserve(newHeight);
                        li->resize(newHeight);
                    }
                }
                else if (newHeight > mHeight )
                {
                    // add pages
                    for (i = 0; i < newWidth; i++ )
	                {
                        PagingLandScapeTextureRow  *li = &mTexture[ i ];
                        li->reserve(newHeight);
                        li->resize(newHeight);
	                    for (k = mHeight; k < newHeight; k++ )
		                {
			                (*li)[ k ] = allocateTexture ();
		                }
	                }
                }
            }
            else if (newWidth > mWidth )
            {
                mTexture.reserve (newWidth);
                mTexture.resize (newWidth);

                if (newHeight < mHeight )
                { 
                    // clear pages
                    for (i = 0; i < mWidth; i++ )
	                {
                        PagingLandScapeTextureRow  *li = &mTexture[ i ];
                        for (k = newHeight; k < mHeight; ++k)
	                    {
                            delete (*li)[ k ];
	                    }
                        li->reserve(newHeight);
                        li->resize(newHeight);
                    }
                }
                else if (newHeight > mHeight )
                {
                    // add pages
                    for (i = 0; i < mWidth; i++ )
	                {
                        PagingLandScapeTextureRow  *li = &mTexture[ i ];
                        li->reserve(newHeight);
                        li->resize(newHeight);
	                    for (k = mHeight; k < newHeight; k++ )
		                {
			                (*li)[ k ] = allocateTexture ();
		                }
	                }
                }

                // add pages
	            for (i = mWidth; i < newWidth; i++ )
	            {
                    mTexture[ i ].reserve (newHeight);
                    mTexture[ i ].resize (newHeight);
	            }
                for (i = mWidth; i < newWidth; i++ )
	            {
                    PagingLandScapeTextureRow  *li = &mTexture[ i ];
                    li->reserve(newHeight);
                    li->resize(newHeight);
	                for (k = 0; k < newHeight; k++ )
		            {
                        (*li)[ k ] = allocateTexture ();
		            }
	            }
            }
            else if (newHeight < mHeight )
            { 
                for (i = 0; i < newWidth; i++ )
	            {
                    PagingLandScapeTextureRow  *li = &mTexture[ i ];
                    for (k = newHeight; k < mHeight; ++k)
	                {
                        delete (*li)[ k ];
	                }
                    li->reserve(newHeight);
                    li->resize(newHeight);
                }
            }
            else if (newHeight > mHeight )
            {
                for (i = 0; i < newWidth; i++ )
	            {
                    PagingLandScapeTextureRow  *li = &mTexture[ i ];
                    li->reserve(newHeight);
                    li->resize(newHeight);
	                for (k = mHeight; k < newHeight; ++k )
		            {    
                        (*li)[ k ] = allocateTexture ();
		            }
	            }
            }
            mWidth = newWidth; 
            mHeight = newHeight;    
//            for (i = 0; i < newWidth; i++ )
//            {
//                PagingLandScapeTextureRow  *li = &mTexture[ i ];
//                for (k = 0; k < newHeight; k++ )
//                {		
//                    PagingLandScapeTexture *p = (*li)[ k ];
//                    
//                }
//            }
        }
    }