1f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian/* 2f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian ** 3f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian ** Copyright 2012 The Android Open Source Project 4f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian ** 5f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian ** Licensed under the Apache License Version 2.0(the "License"); 6f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian ** you may not use this file except in compliance with the License. 7f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian ** You may obtain a copy of the License at 8f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian ** 9f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian ** http://www.apache.org/licenses/LICENSE-2.0 10f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian ** 11f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian ** Unless required by applicable law or agreed to in writing software 12f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian ** distributed under the License is distributed on an "AS IS" BASIS 13f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied. 14f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian ** See the License for the specific language governing permissions and 15f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian ** limitations under the License. 16f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian */ 17f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian 18f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian#include <cutils/log.h> 19f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian 20f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian#include <ui/GraphicBuffer.h> 21f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian 22f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian#include "DisplayHardware/GraphicBufferAlloc.h" 23f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian 24f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian// ---------------------------------------------------------------------------- 25f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopiannamespace android { 26f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian// ---------------------------------------------------------------------------- 27f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian 28f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias AgopianGraphicBufferAlloc::GraphicBufferAlloc() { 29f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian} 30f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian 31f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias AgopianGraphicBufferAlloc::~GraphicBufferAlloc() { 32f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian} 33f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian 34f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopiansp<GraphicBuffer> GraphicBufferAlloc::createGraphicBuffer(uint32_t w, uint32_t h, 35f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian PixelFormat format, uint32_t usage, status_t* error) { 36f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian sp<GraphicBuffer> graphicBuffer(new GraphicBuffer(w, h, format, usage)); 37f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian status_t err = graphicBuffer->initCheck(); 38f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian *error = err; 39f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian if (err != 0 || graphicBuffer->handle == 0) { 40f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian if (err == NO_MEMORY) { 41f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian GraphicBuffer::dumpAllocationsToSystemLog(); 42f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian } 43f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian ALOGE("GraphicBufferAlloc::createGraphicBuffer(w=%d, h=%d) " 44f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian "failed (%s), handle=%p", 45f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian w, h, strerror(-err), graphicBuffer->handle); 46f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian return 0; 47f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian } 48f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian return graphicBuffer; 49f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian} 50f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian 51f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian// ---------------------------------------------------------------------------- 52f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian}; // namespace android 53f33e4b6f13bc3ee2d2a4e1abd1ada171c70d3492Mathias Agopian// ---------------------------------------------------------------------------- 54