コード例 #1
0
static WSEGLError allocateBackBuffers(struct wl_egl_display *egldisplay, NativeWindowType nativeWindow)
{
    int index;
    
    if (nativeWindow->numFlipBuffers)
    {
        long stride = 0;
        
        unsigned long flipId = 0;
        unsigned long numBuffers;
        PVR2DERROR ret = PVR2DCreateFlipChain(egldisplay->context, 0,
                                 //PVR2D_CREATE_FLIPCHAIN_SHARED |
                                 //PVR2D_CREATE_FLIPCHAIN_QUERY,
                                 nativeWindow->numFlipBuffers,
                                 nativeWindow->width,
                                 nativeWindow->height,
                                 wsegl2pvr2dformat(nativeWindow->format),
                                 &stride, &flipId, &(nativeWindow->flipChain));
        assert(ret == PVR2D_OK); 
        PVR2DGetFlipChainBuffers(egldisplay->context,
                                     nativeWindow->flipChain,
                                     &numBuffers,
                                     nativeWindow->flipBuffers);
        for (index = 0; index < numBuffers; ++index)
        {
             nativeWindow->backBuffers[index] = nativeWindow->flipBuffers[index];
        }
    }
    else {
	    for (index = 0; index < WAYLANDWSEGL_MAX_BACK_BUFFERS; ++index)
	    {
		if (PVR2DMemAlloc(egldisplay->context,
			      nativeWindow->strideBytes * nativeWindow->height,
	 		      128, 0,
			      &(nativeWindow->backBuffers[index])) != PVR2D_OK)
	        {
		       assert(0);
					       
		       while (--index >= 0)
				PVR2DMemFree(egldisplay->context, nativeWindow->backBuffers[index]);
			       
	               memset(nativeWindow->backBuffers, 0, sizeof(nativeWindow->backBuffers));
		       
		       nativeWindow->backBuffersValid = 0;
   		       
			       
		       return WSEGL_OUT_OF_MEMORY;
	        }
	    }
    }
    nativeWindow->backBuffersValid = 1;
    nativeWindow->currentBackBuffer = 0;
    return WSEGL_SUCCESS;
}
コード例 #2
0
int pvrQwsAllocBuffers(PvrQwsDrawable *drawable)
{
    int index;
    int numBuffers = PVRQWS_MAX_BACK_BUFFERS;
    if (drawable->type == PvrQwsPixmap)
        numBuffers = 1;
    if (drawable->backBuffers[0]) {
        if (drawable->backBuffersValid)
            return 1;
        if (!drawable->usingFlipBuffers) {
            for (index = 0; index < numBuffers; ++index)
                PVR2DMemFree(pvrQwsDisplay.context, drawable->backBuffers[index]);
        }
    }
    drawable->stridePixels = (drawable->rect.width + 31) & ~31;
    drawable->strideBytes =
        drawable->stridePixels *
        pvrQwsDisplay.screens[drawable->screen].bytesPerPixel;
    drawable->usingFlipBuffers =
        (pvrQwsDisplay.numFlipBuffers > 0 && drawable->isFullScreen);
    if (drawable->usingFlipBuffers) {
        if (numBuffers > (int)(pvrQwsDisplay.numFlipBuffers))
            numBuffers = pvrQwsDisplay.numFlipBuffers;
        for (index = 0; index < numBuffers; ++index)
            drawable->backBuffers[index] = pvrQwsDisplay.flipBuffers[index];
    } else {
        for (index = 0; index < numBuffers; ++index) {
            if (PVR2DMemAlloc(pvrQwsDisplay.context,
                              drawable->strideBytes * drawable->rect.height,
                              128, 0,
                              &(drawable->backBuffers[index])) != PVR2D_OK) {
                while (--index >= 0)
                    PVR2DMemFree(pvrQwsDisplay.context, drawable->backBuffers[index]);
                memset(drawable->backBuffers, 0, sizeof(drawable->backBuffers));
                drawable->backBuffersValid = 0;
                return 0;
            }
        }
    }
    for (index = numBuffers; index < PVRQWS_MAX_BACK_BUFFERS; ++index) {
        drawable->backBuffers[index] = drawable->backBuffers[0];
    }
    drawable->backBuffersValid = 1;
    drawable->currentBackBuffer = 0;
    return 1;
}