| Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  * Copyright (C) 2007 The Android Open Source Project | 
 | 3 |  * | 
 | 4 |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
 | 5 |  * you may not use this file except in compliance with the License. | 
 | 6 |  * You may obtain a copy of the License at | 
 | 7 |  * | 
 | 8 |  *      http://www.apache.org/licenses/LICENSE-2.0 | 
 | 9 |  * | 
 | 10 |  * Unless required by applicable law or agreed to in writing, software | 
 | 11 |  * distributed under the License is distributed on an "AS IS" BASIS, | 
 | 12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
 | 13 |  * See the License for the specific language governing permissions and | 
 | 14 |  * limitations under the License. | 
 | 15 |  */ | 
 | 16 |  | 
 | 17 | #ifndef ANDROID_UI_BUFFER_MAPPER_H | 
 | 18 | #define ANDROID_UI_BUFFER_MAPPER_H | 
 | 19 |  | 
 | 20 | #include <stdint.h> | 
 | 21 | #include <sys/types.h> | 
| Mathias Agopian | 8b765b7 | 2009-04-10 20:34:46 -0700 | [diff] [blame] | 22 |  | 
| Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 23 | #include <utils/Singleton.h> | 
 | 24 |  | 
 | 25 | #include <hardware/gralloc.h> | 
 | 26 |  | 
 | 27 |  | 
 | 28 | struct gralloc_module_t; | 
 | 29 |  | 
 | 30 | namespace android { | 
 | 31 |  | 
 | 32 | // --------------------------------------------------------------------------- | 
 | 33 |  | 
 | 34 | class Rect; | 
 | 35 |  | 
| Mathias Agopian | 3330b20 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 36 | class GraphicBufferMapper : public Singleton<GraphicBufferMapper> | 
| Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 37 | { | 
 | 38 | public: | 
| Mathias Agopian | 3330b20 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 39 |     static inline GraphicBufferMapper& get() { return getInstance(); } | 
| Mathias Agopian | 0926f50 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 40 |  | 
 | 41 |     status_t registerBuffer(buffer_handle_t handle); | 
 | 42 |  | 
 | 43 |     status_t unregisterBuffer(buffer_handle_t handle); | 
 | 44 |      | 
 | 45 |     status_t lock(buffer_handle_t handle, | 
 | 46 |             int usage, const Rect& bounds, void** vaddr); | 
 | 47 |  | 
| Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 48 |     status_t unlock(buffer_handle_t handle); | 
 | 49 |      | 
| Mathias Agopian | 8b765b7 | 2009-04-10 20:34:46 -0700 | [diff] [blame] | 50 |     // dumps information about the mapping of this handle | 
 | 51 |     void dump(buffer_handle_t handle); | 
 | 52 |  | 
| Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 53 | private: | 
| Mathias Agopian | 3330b20 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 54 |     friend class Singleton<GraphicBufferMapper>; | 
 | 55 |     GraphicBufferMapper(); | 
| Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 56 |     gralloc_module_t const *mAllocMod; | 
| Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 57 | }; | 
 | 58 |  | 
 | 59 | // --------------------------------------------------------------------------- | 
 | 60 |  | 
 | 61 | }; // namespace android | 
 | 62 |  | 
 | 63 | #endif // ANDROID_UI_BUFFER_MAPPER_H | 
 | 64 |  |