• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <gui/Flags.h>
18 #include <gui/IGraphicBufferProducer.h>
19 #include <gui/Surface.h>
20 #include <gui/view/Surface.h>
21 
22 namespace android {
23 namespace flagtools {
surfaceToSurfaceType(const sp<Surface> & surface)24 sp<SurfaceType> surfaceToSurfaceType(const sp<Surface>& surface) {
25 #if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
26     return surface;
27 #else
28     return surface->getIGraphicBufferProducer();
29 #endif
30 }
31 
surfaceToParcelableSurfaceType(const sp<Surface> & surface)32 ParcelableSurfaceType surfaceToParcelableSurfaceType(const sp<Surface>& surface) {
33 #if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
34     return view::Surface::fromSurface(surface);
35 #else
36     return surface->getIGraphicBufferProducer();
37 #endif
38 }
39 
surfaceTypeToIGBP(const sp<SurfaceType> & surface)40 sp<IGraphicBufferProducer> surfaceTypeToIGBP(const sp<SurfaceType>& surface) {
41 #if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
42     return surface->getIGraphicBufferProducer();
43 #else
44     return surface;
45 #endif
46 }
47 
isSurfaceTypeValid(const sp<SurfaceType> & surface)48 bool isSurfaceTypeValid(const sp<SurfaceType>& surface) {
49 #if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
50     return Surface::isValid(surface);
51 #else
52     return surface != nullptr;
53 #endif
54 }
55 
toParcelableSurfaceType(const view::Surface & surface)56 ParcelableSurfaceType toParcelableSurfaceType(const view::Surface& surface) {
57 #if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
58     return surface;
59 #else
60     return surface.graphicBufferProducer;
61 #endif
62 }
63 
convertSurfaceTypeToParcelable(sp<SurfaceType> surface)64 ParcelableSurfaceType convertSurfaceTypeToParcelable(sp<SurfaceType> surface) {
65 #if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
66     return view::Surface::fromSurface(surface);
67 #else
68     return surface;
69 #endif
70 }
71 
convertParcelableSurfaceTypeToSurface(const ParcelableSurfaceType & surface)72 sp<SurfaceType> convertParcelableSurfaceTypeToSurface(const ParcelableSurfaceType& surface) {
73 #if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
74     return surface.toSurface();
75 #else
76     return surface;
77 #endif
78 }
79 
80 } // namespace flagtools
81 } // namespace android