/*static*/ PGrallocBufferParent* GrallocBufferActor::Create(const gfxIntSize& aSize, const uint32_t& aFormat, const uint32_t& aUsage, MaybeMagicGrallocBufferHandle* aOutHandle) { PROFILER_LABEL("GrallocBufferActor", "Create"); GrallocBufferActor* actor = new GrallocBufferActor(); *aOutHandle = null_t(); uint32_t format = aFormat; uint32_t usage = aUsage; if (format == 0 || usage == 0) { printf_stderr("GrallocBufferActor::Create -- format and usage must be non-zero"); return actor; } sp<GraphicBuffer> buffer(new GraphicBuffer(aSize.width, aSize.height, format, usage)); if (buffer->initCheck() != OK) return actor; size_t bpp = BytesPerPixelForPixelFormat(format); actor->mAllocBytes = aSize.width * aSize.height * bpp; sCurrentAlloc += actor->mAllocBytes; actor->mGraphicBuffer = buffer; *aOutHandle = MagicGrallocBufferHandle(buffer); return actor; }
/*static*/ PGrallocBufferParent* GrallocBufferActor::Create(const gfxIntSize& aSize, const gfxContentType& aContent, MaybeMagicGrallocBufferHandle* aOutHandle) { SAMPLE_LABEL("GrallocBufferActor", "Create"); GrallocBufferActor* actor = new GrallocBufferActor(); *aOutHandle = null_t(); android::PixelFormat format = PixelFormatForContentType(aContent); sp<GraphicBuffer> buffer( new GraphicBuffer(aSize.width, aSize.height, format, GraphicBuffer::USAGE_SW_READ_OFTEN | GraphicBuffer::USAGE_SW_WRITE_OFTEN | GraphicBuffer::USAGE_HW_TEXTURE)); if (buffer->initCheck() != OK) return actor; size_t bpp = gfxASurface::BytePerPixelFromFormat( gfxPlatform::GetPlatform()->OptimalFormatForContent(aContent)); actor->mAllocBytes = aSize.width * aSize.height * bpp; sCurrentAlloc += actor->mAllocBytes; actor->mGraphicBuffer = buffer; *aOutHandle = MagicGrallocBufferHandle(buffer); return actor; }
/*static*/ PGrallocBufferParent* GrallocBufferActor::Create(const gfxIntSize& aSize, const uint32_t& aFormat, const uint32_t& aUsage, MaybeMagicGrallocBufferHandle* aOutHandle) { GrallocBufferActor* actor = new GrallocBufferActor(); *aOutHandle = null_t(); sp<GraphicBuffer> buffer( new GraphicBuffer(aSize.width, aSize.height, aFormat, aUsage)); if (buffer->initCheck() != OK) return actor; actor->mGraphicBuffer = buffer; *aOutHandle = MagicGrallocBufferHandle(buffer); return actor; }
/*static*/ PGrallocBufferParent* GrallocBufferActor::Create(const gfxIntSize& aSize, const gfxContentType& aContent, MaybeMagicGrallocBufferHandle* aOutHandle) { SAMPLE_LABEL("GrallocBufferActor", "Create"); GrallocBufferActor* actor = new GrallocBufferActor(); *aOutHandle = null_t(); android::PixelFormat format = PixelFormatForContentType(aContent); sp<GraphicBuffer> buffer( new GraphicBuffer(aSize.width, aSize.height, format, GraphicBuffer::USAGE_SW_READ_OFTEN | GraphicBuffer::USAGE_SW_WRITE_OFTEN | GraphicBuffer::USAGE_HW_TEXTURE)); if (buffer->initCheck() != OK) return actor; actor->mGraphicBuffer = buffer; *aOutHandle = MagicGrallocBufferHandle(buffer); return actor; }