1076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian/* 2076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian * Copyright (C) 2007 The Android Open Source Project 3076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian * 4076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian * Licensed under the Apache License, Version 2.0 (the "License"); 5076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian * you may not use this file except in compliance with the License. 6076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian * You may obtain a copy of the License at 7076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian * 8076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian * http://www.apache.org/licenses/LICENSE-2.0 9076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian * 10076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian * Unless required by applicable law or agreed to in writing, software 11076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian * distributed under the License is distributed on an "AS IS" BASIS, 12076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian * See the License for the specific language governing permissions and 14076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian * limitations under the License. 15076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian */ 16076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian 17076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian#ifndef ANDROID_UI_BUFFER_MAPPER_H 18076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian#define ANDROID_UI_BUFFER_MAPPER_H 19076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian 20076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian#include <stdint.h> 21076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian#include <sys/types.h> 228b765b7f5ea7f56963ea0e3141d043d20944dbccMathias Agopian 23076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian#include <utils/Singleton.h> 24076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian 25076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian#include <hardware/gralloc.h> 26076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian 27076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian 28076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopianstruct gralloc_module_t; 29076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian 30076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopiannamespace android { 31076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian 32076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian// --------------------------------------------------------------------------- 33076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian 34076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopianclass Rect; 35076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian 363330b203039dea366d4981db1408a460134b2d2cMathias Agopianclass GraphicBufferMapper : public Singleton<GraphicBufferMapper> 37076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian{ 38076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopianpublic: 393330b203039dea366d4981db1408a460134b2d2cMathias Agopian static inline GraphicBufferMapper& get() { return getInstance(); } 400926f50664c739eaee60341f8e8c694dc9a4f3ebMathias Agopian 410926f50664c739eaee60341f8e8c694dc9a4f3ebMathias Agopian status_t registerBuffer(buffer_handle_t handle); 420926f50664c739eaee60341f8e8c694dc9a4f3ebMathias Agopian 430926f50664c739eaee60341f8e8c694dc9a4f3ebMathias Agopian status_t unregisterBuffer(buffer_handle_t handle); 44303b9a51239d36d237a7d40c67b5085cdb3c1059Dan Stoza 450926f50664c739eaee60341f8e8c694dc9a4f3ebMathias Agopian status_t lock(buffer_handle_t handle, 46303b9a51239d36d237a7d40c67b5085cdb3c1059Dan Stoza uint32_t usage, const Rect& bounds, void** vaddr); 470926f50664c739eaee60341f8e8c694dc9a4f3ebMathias Agopian 48c43946b931de5dafd28f49963f9af78e05390b26Eino-Ville Talvala status_t lockYCbCr(buffer_handle_t handle, 49303b9a51239d36d237a7d40c67b5085cdb3c1059Dan Stoza uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr); 50c43946b931de5dafd28f49963f9af78e05390b26Eino-Ville Talvala 51076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian status_t unlock(buffer_handle_t handle); 528f3960179c56767e5077be8337792bd4e244b7d7Francis Hart 538f3960179c56767e5077be8337792bd4e244b7d7Francis Hart status_t lockAsync(buffer_handle_t handle, 54303b9a51239d36d237a7d40c67b5085cdb3c1059Dan Stoza uint32_t usage, const Rect& bounds, void** vaddr, int fenceFd); 558f3960179c56767e5077be8337792bd4e244b7d7Francis Hart 568f3960179c56767e5077be8337792bd4e244b7d7Francis Hart status_t lockAsyncYCbCr(buffer_handle_t handle, 57303b9a51239d36d237a7d40c67b5085cdb3c1059Dan Stoza uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr, 58303b9a51239d36d237a7d40c67b5085cdb3c1059Dan Stoza int fenceFd); 598f3960179c56767e5077be8337792bd4e244b7d7Francis Hart 608f3960179c56767e5077be8337792bd4e244b7d7Francis Hart status_t unlockAsync(buffer_handle_t handle, int *fenceFd); 61303b9a51239d36d237a7d40c67b5085cdb3c1059Dan Stoza 628b765b7f5ea7f56963ea0e3141d043d20944dbccMathias Agopian // dumps information about the mapping of this handle 638b765b7f5ea7f56963ea0e3141d043d20944dbccMathias Agopian void dump(buffer_handle_t handle); 648b765b7f5ea7f56963ea0e3141d043d20944dbccMathias Agopian 65076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopianprivate: 663330b203039dea366d4981db1408a460134b2d2cMathias Agopian friend class Singleton<GraphicBufferMapper>; 673330b203039dea366d4981db1408a460134b2d2cMathias Agopian GraphicBufferMapper(); 68076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian gralloc_module_t const *mAllocMod; 69076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian}; 70076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian 71076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian// --------------------------------------------------------------------------- 72076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian 73076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian}; // namespace android 74076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian 75076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian#endif // ANDROID_UI_BUFFER_MAPPER_H 76076b1cc3a9b90aa5b381a1ed268ca0b548444c9bMathias Agopian 77