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 | |
Dan Stoza | 8deb4da | 2016-06-01 18:21:44 -0700 | [diff] [blame] | 23 | #include <ui/Gralloc1.h> |
| 24 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 25 | #include <utils/Singleton.h> |
| 26 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 27 | namespace android { |
| 28 | |
| 29 | // --------------------------------------------------------------------------- |
| 30 | |
Chia-I Wu | 9ba189d | 2016-09-22 17:13:08 +0800 | [diff] [blame] | 31 | namespace Gralloc2 { |
| 32 | class Mapper; |
| 33 | } |
| 34 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 35 | class Rect; |
| 36 | |
Mathias Agopian | 3330b20 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 37 | class GraphicBufferMapper : public Singleton<GraphicBufferMapper> |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 38 | { |
| 39 | public: |
Mathias Agopian | 3330b20 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 40 | static inline GraphicBufferMapper& get() { return getInstance(); } |
Mathias Agopian | 0926f50 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 41 | |
| 42 | status_t registerBuffer(buffer_handle_t handle); |
Dan Stoza | 8deb4da | 2016-06-01 18:21:44 -0700 | [diff] [blame] | 43 | status_t registerBuffer(const GraphicBuffer* buffer); |
Mathias Agopian | 0926f50 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 44 | |
| 45 | status_t unregisterBuffer(buffer_handle_t handle); |
Dan Stoza | 303b9a5 | 2014-11-17 12:03:59 -0800 | [diff] [blame] | 46 | |
Mathias Agopian | 0926f50 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 47 | status_t lock(buffer_handle_t handle, |
Dan Stoza | 303b9a5 | 2014-11-17 12:03:59 -0800 | [diff] [blame] | 48 | uint32_t usage, const Rect& bounds, void** vaddr); |
Mathias Agopian | 0926f50 | 2009-05-04 14:17:04 -0700 | [diff] [blame] | 49 | |
Eino-Ville Talvala | c43946b | 2013-05-04 18:07:43 -0700 | [diff] [blame] | 50 | status_t lockYCbCr(buffer_handle_t handle, |
Dan Stoza | 303b9a5 | 2014-11-17 12:03:59 -0800 | [diff] [blame] | 51 | uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr); |
Eino-Ville Talvala | c43946b | 2013-05-04 18:07:43 -0700 | [diff] [blame] | 52 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 53 | status_t unlock(buffer_handle_t handle); |
Francis Hart | 8f39601 | 2014-04-01 15:30:53 +0300 | [diff] [blame] | 54 | |
| 55 | status_t lockAsync(buffer_handle_t handle, |
Dan Stoza | 303b9a5 | 2014-11-17 12:03:59 -0800 | [diff] [blame] | 56 | uint32_t usage, const Rect& bounds, void** vaddr, int fenceFd); |
Francis Hart | 8f39601 | 2014-04-01 15:30:53 +0300 | [diff] [blame] | 57 | |
| 58 | status_t lockAsyncYCbCr(buffer_handle_t handle, |
Dan Stoza | 303b9a5 | 2014-11-17 12:03:59 -0800 | [diff] [blame] | 59 | uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr, |
| 60 | int fenceFd); |
Francis Hart | 8f39601 | 2014-04-01 15:30:53 +0300 | [diff] [blame] | 61 | |
| 62 | status_t unlockAsync(buffer_handle_t handle, int *fenceFd); |
Dan Stoza | 303b9a5 | 2014-11-17 12:03:59 -0800 | [diff] [blame] | 63 | |
Chia-I Wu | 9ba189d | 2016-09-22 17:13:08 +0800 | [diff] [blame] | 64 | const Gralloc2::Mapper& getGrallocMapper() const |
| 65 | { |
| 66 | return *mMapper; |
| 67 | } |
| 68 | |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 69 | private: |
Mathias Agopian | 3330b20 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 70 | friend class Singleton<GraphicBufferMapper>; |
Dan Stoza | 8deb4da | 2016-06-01 18:21:44 -0700 | [diff] [blame] | 71 | |
Mathias Agopian | 3330b20 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 72 | GraphicBufferMapper(); |
Dan Stoza | 8deb4da | 2016-06-01 18:21:44 -0700 | [diff] [blame] | 73 | |
Chia-I Wu | 9ba189d | 2016-09-22 17:13:08 +0800 | [diff] [blame] | 74 | const std::unique_ptr<const Gralloc2::Mapper> mMapper; |
| 75 | |
Dan Stoza | 8deb4da | 2016-06-01 18:21:44 -0700 | [diff] [blame] | 76 | std::unique_ptr<Gralloc1::Loader> mLoader; |
| 77 | std::unique_ptr<Gralloc1::Device> mDevice; |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | // --------------------------------------------------------------------------- |
| 81 | |
| 82 | }; // namespace android |
| 83 | |
| 84 | #endif // ANDROID_UI_BUFFER_MAPPER_H |
| 85 | |