blob: 5a23b6844ae6df12f64a44a1cdc2b16f1bdadb7c [file] [log] [blame]
Chia-I Wu9ba189d2016-09-22 17:13:08 +08001/*
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
25namespace android {
26
27namespace Gralloc2 {
28
29using hardware::graphics::allocator::V2_0::Error;
Chia-I Wu9ba189d2016-09-22 17:13:08 +080030using hardware::graphics::allocator::V2_0::ProducerUsage;
31using hardware::graphics::allocator::V2_0::ConsumerUsage;
Chia-I Wu5901fda2016-11-17 10:26:37 +080032using hardware::graphics::common::V1_0::PixelFormat;
Chia-I Wu9ba189d2016-09-22 17:13:08 +080033using hardware::graphics::mapper::V2_0::FlexLayout;
34using hardware::graphics::mapper::V2_0::BackingStore;
Chia-I Wu9ba189d2016-09-22 17:13:08 +080035using hardware::graphics::mapper::V2_0::IMapper;
36
37// Mapper is a wrapper to IMapper, a client-side graphics buffer mapper.
38class Mapper {
39public:
40 Mapper();
Chia-I Wu9ba189d2016-09-22 17:13:08 +080041
42 // this will be removed and Mapper will be always valid
43 bool valid() const { return (mMapper != nullptr); }
44
Chia-I Wu31669472016-12-07 14:55:24 +080045 Error retain(buffer_handle_t handle) const;
Chia-I Wu9ba189d2016-09-22 17:13:08 +080046 void release(buffer_handle_t handle) const;
47
Craig Donner58a1ef22017-02-02 12:40:05 -080048 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 Wu31669472016-12-07 14:55:24 +080058 Error getStride(buffer_handle_t handle, uint32_t* outStride) const;
Chia-I Wu9ba189d2016-09-22 17:13:08 +080059
Craig Donner58a1ef22017-02-02 12:40:05 -080060 Error lock(buffer_handle_t handle, uint64_t producerUsage,
61 uint64_t consumerUsage, const IMapper::Rect& accessRegion,
Chia-I Wu31669472016-12-07 14:55:24 +080062 int acquireFence, void** outData) const;
Craig Donner58a1ef22017-02-02 12:40:05 -080063 Error lock(buffer_handle_t handle, uint64_t producerUsage,
64 uint64_t consumerUsage, const IMapper::Rect& accessRegion,
Chia-I Wu31669472016-12-07 14:55:24 +080065 int acquireFence, FlexLayout* outLayout) const;
Chia-I Wu9ba189d2016-09-22 17:13:08 +080066 int unlock(buffer_handle_t handle) const;
67
68private:
Chia-I Wu31669472016-12-07 14:55:24 +080069 sp<IMapper> mMapper;
Chia-I Wu9ba189d2016-09-22 17:13:08 +080070};
71
72} // namespace Gralloc2
73
74} // namespace android
75
76#endif // ANDROID_UI_GRALLOC_MAPPER_H