xref: /aosp_15_r20/frameworks/native/include/gui/Flags.h (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
1 /*
2  * Copyright 2024 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 #pragma once
18 
19 #include <com_android_graphics_libgui_flags.h>
20 #include <utils/StrongPointer.h>
21 
22 namespace android {
23 
24 class IGraphicBufferProducer;
25 class Surface;
26 namespace view {
27 class Surface;
28 }
29 
30 #define WB_CAMERA3_AND_PROCESSORS_WITH_DEPENDENCIES                  \
31     (COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CAMERA3_AND_PROCESSORS) && \
32      COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ) &&  \
33      COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS))
34 
35 #define WB_LIBCAMERASERVICE_WITH_DEPENDENCIES       \
36     (WB_CAMERA3_AND_PROCESSORS_WITH_DEPENDENCIES && \
37      COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_LIBCAMERASERVICE))
38 
39 #if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
40 typedef android::Surface SurfaceType;
41 typedef android::view::Surface ParcelableSurfaceType;
42 #else
43 typedef android::IGraphicBufferProducer SurfaceType;
44 typedef android::sp<android::IGraphicBufferProducer> ParcelableSurfaceType;
45 #endif
46 
47 namespace flagtools {
48 sp<SurfaceType> surfaceToSurfaceType(const sp<Surface>& surface);
49 ParcelableSurfaceType toParcelableSurfaceType(const view::Surface& surface);
50 sp<IGraphicBufferProducer> surfaceTypeToIGBP(const sp<SurfaceType>& surface);
51 bool isSurfaceTypeValid(const sp<SurfaceType>& surface);
52 ParcelableSurfaceType convertSurfaceTypeToParcelable(sp<SurfaceType> surface);
53 sp<SurfaceType> convertParcelableSurfaceTypeToSurface(const ParcelableSurfaceType& surface);
54 } // namespace flagtools
55 
56 } // namespace android
57