1 // Copyright 2023 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expresso or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <EGL/egl.h>
18 #include <EGL/eglext.h>
19 
20 #include "gfxstream/guest/ANativeWindow.h"
21 
22 namespace gfxstream {
23 
24 class ANativeWindowHelperAndroid : public ANativeWindowHelper {
25    public:
26     ANativeWindowHelperAndroid() = default;
27 
28     bool isValid(EGLNativeWindowType window);
29     bool isValid(EGLClientBuffer buffer);
30 
31     void acquire(EGLNativeWindowType window);
32     void release(EGLNativeWindowType window);
33 
34     void acquire(EGLClientBuffer buffer);
35     void release(EGLClientBuffer buffer);
36 
37     int getConsumerUsage(EGLNativeWindowType window, int* usage);
38     void setUsage(EGLNativeWindowType window, int usage);
39 
40     int getWidth(EGLNativeWindowType window);
41     int getHeight(EGLNativeWindowType window);
42 
43     int getWidth(EGLClientBuffer buffer);
44     int getHeight(EGLClientBuffer buffer);
45 
46     int getFormat(EGLClientBuffer buffer, Gralloc* helper);
47 
48     void setSwapInterval(EGLNativeWindowType window, int interval);
49 
50     int queueBuffer(EGLNativeWindowType window, EGLClientBuffer buffer, int fence);
51     int dequeueBuffer(EGLNativeWindowType window, EGLClientBuffer* buffer, int* fence);
52     int cancelBuffer(EGLNativeWindowType window, EGLClientBuffer buffer);
53 
54     int getHostHandle(EGLClientBuffer buffer, Gralloc* helper);
55 };
56 
57 }  // namespace gfxstream