bool AndroidGraphicBuffer::EnsureBufferCreated() { if (!mHandle) { mHandle = malloc(GRAPHIC_BUFFER_SIZE); sGLFunctions.fGraphicBufferCtor(mHandle, mWidth, mHeight, GetAndroidFormat(mFormat), GetAndroidUsage(mUsage)); } return true; }
CGraphicBuffer::CGraphicBuffer(uint32_t width, uint32_t height, uint32_t format, gfxImageUsage usage): m_width(width), m_height(height), m_usage(usage), m_format(format), m_handle(0) { CLog::Log(LOGDEBUG, "CGraphicBuffer::CGraphicBuffer"); if (!m_dll) { // m_dll is static, there can be only one. m_dll = new DllGraphicBuffer; m_dll->Load(); m_dll->EnableDelayedUnload(false); } m_handle = malloc(4096 * 4); if (m_dll) m_dll->GraphicBufferCtor(m_handle, width, height, GetAndroidFormat(format), usage); }
bool AndroidGraphicBuffer::Reallocate(uint32_t aWidth, uint32_t aHeight, gfxImageFormat aFormat) { if (!EnsureInitialized()) return false; mWidth = aWidth; mHeight = aHeight; mFormat = aFormat; // Sometimes GraphicBuffer::reallocate just doesn't work. In those cases we'll just allocate a brand // new buffer. If reallocate fails once, never try it again. if (!gTryRealloc || sGLFunctions.fGraphicBufferReallocate(mHandle, aWidth, aHeight, GetAndroidFormat(aFormat)) != 0) { DestroyBuffer(); EnsureBufferCreated(); gTryRealloc = false; } return true; }