Chia-I Wu | 9ba189d | 2016-09-22 17:13:08 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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_GRALLOC_MAPPER_H |
| 18 | #define ANDROID_UI_GRALLOC_MAPPER_H |
| 19 | |
| 20 | #include <memory> |
| 21 | |
| 22 | #include <android/hardware/graphics/mapper/2.0/IMapper.h> |
| 23 | #include <system/window.h> |
| 24 | |
| 25 | namespace android { |
| 26 | |
| 27 | namespace Gralloc2 { |
| 28 | |
| 29 | using hardware::graphics::allocator::V2_0::Error; |
Chia-I Wu | 9ba189d | 2016-09-22 17:13:08 +0800 | [diff] [blame] | 30 | using hardware::graphics::allocator::V2_0::ProducerUsage; |
| 31 | using hardware::graphics::allocator::V2_0::ConsumerUsage; |
Chia-I Wu | 5901fda | 2016-11-17 10:26:37 +0800 | [diff] [blame] | 32 | using hardware::graphics::common::V1_0::PixelFormat; |
Chia-I Wu | 9ba189d | 2016-09-22 17:13:08 +0800 | [diff] [blame] | 33 | using hardware::graphics::mapper::V2_0::FlexLayout; |
| 34 | using hardware::graphics::mapper::V2_0::BackingStore; |
Chia-I Wu | 9ba189d | 2016-09-22 17:13:08 +0800 | [diff] [blame] | 35 | using hardware::graphics::mapper::V2_0::IMapper; |
| 36 | |
| 37 | // Mapper is a wrapper to IMapper, a client-side graphics buffer mapper. |
| 38 | class Mapper { |
| 39 | public: |
| 40 | Mapper(); |
Chia-I Wu | 9ba189d | 2016-09-22 17:13:08 +0800 | [diff] [blame] | 41 | |
| 42 | // this will be removed and Mapper will be always valid |
| 43 | bool valid() const { return (mMapper != nullptr); } |
| 44 | |
Chia-I Wu | 3166947 | 2016-12-07 14:55:24 +0800 | [diff] [blame] | 45 | Error retain(buffer_handle_t handle) const; |
Chia-I Wu | 9ba189d | 2016-09-22 17:13:08 +0800 | [diff] [blame] | 46 | void release(buffer_handle_t handle) const; |
| 47 | |
Craig Donner | 58a1ef2 | 2017-02-02 12:40:05 -0800 | [diff] [blame] | 48 | Error getDimensions(buffer_handle_t handle, |
| 49 | uint32_t* outWidth, uint32_t* outHeight) const; |
| 50 | Error getFormat(buffer_handle_t handle, int32_t* outFormat) const; |
| 51 | Error getLayerCount(buffer_handle_t handle, uint32_t* outLayerCount) const; |
| 52 | Error getProducerUsage(buffer_handle_t handle, |
| 53 | uint64_t* outProducerUsage) const; |
| 54 | Error getConsumerUsage(buffer_handle_t handle, |
| 55 | uint64_t* outConsumerUsage) const; |
| 56 | Error getBackingStore(buffer_handle_t handle, |
| 57 | uint64_t* outBackingStore) const; |
Chia-I Wu | 3166947 | 2016-12-07 14:55:24 +0800 | [diff] [blame] | 58 | Error getStride(buffer_handle_t handle, uint32_t* outStride) const; |
Chia-I Wu | 9ba189d | 2016-09-22 17:13:08 +0800 | [diff] [blame] | 59 | |
Craig Donner | 58a1ef2 | 2017-02-02 12:40:05 -0800 | [diff] [blame] | 60 | Error lock(buffer_handle_t handle, uint64_t producerUsage, |
| 61 | uint64_t consumerUsage, const IMapper::Rect& accessRegion, |
Chia-I Wu | 3166947 | 2016-12-07 14:55:24 +0800 | [diff] [blame] | 62 | int acquireFence, void** outData) const; |
Craig Donner | 58a1ef2 | 2017-02-02 12:40:05 -0800 | [diff] [blame] | 63 | Error lock(buffer_handle_t handle, uint64_t producerUsage, |
| 64 | uint64_t consumerUsage, const IMapper::Rect& accessRegion, |
Chia-I Wu | 3166947 | 2016-12-07 14:55:24 +0800 | [diff] [blame] | 65 | int acquireFence, FlexLayout* outLayout) const; |
Chia-I Wu | 9ba189d | 2016-09-22 17:13:08 +0800 | [diff] [blame] | 66 | int unlock(buffer_handle_t handle) const; |
| 67 | |
| 68 | private: |
Chia-I Wu | 3166947 | 2016-12-07 14:55:24 +0800 | [diff] [blame] | 69 | sp<IMapper> mMapper; |
Chia-I Wu | 9ba189d | 2016-09-22 17:13:08 +0800 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | } // namespace Gralloc2 |
| 73 | |
| 74 | } // namespace android |
| 75 | |
| 76 | #endif // ANDROID_UI_GRALLOC_MAPPER_H |