blob: f533dfb71b675de1aa4df05504be8461aad73280 [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
Chia-I Wu31669472016-12-07 14:55:24 +080048 Error getStride(buffer_handle_t handle, uint32_t* outStride) const;
Chia-I Wu9ba189d2016-09-22 17:13:08 +080049
50 Error lock(buffer_handle_t handle,
51 uint64_t producerUsageMask,
52 uint64_t consumerUsageMask,
Chia-I Wu31669472016-12-07 14:55:24 +080053 const IMapper::Rect& accessRegion,
54 int acquireFence, void** outData) const;
Chia-I Wu9ba189d2016-09-22 17:13:08 +080055 Error lock(buffer_handle_t handle,
56 uint64_t producerUsageMask,
57 uint64_t consumerUsageMask,
Chia-I Wu31669472016-12-07 14:55:24 +080058 const IMapper::Rect& accessRegion,
59 int acquireFence, FlexLayout* outLayout) const;
Chia-I Wu9ba189d2016-09-22 17:13:08 +080060 int unlock(buffer_handle_t handle) const;
61
62private:
Chia-I Wu31669472016-12-07 14:55:24 +080063 sp<IMapper> mMapper;
Chia-I Wu9ba189d2016-09-22 17:13:08 +080064};
65
66} // namespace Gralloc2
67
68} // namespace android
69
70#endif // ANDROID_UI_GRALLOC_MAPPER_H