• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "Gralloc.h"
21 
22 namespace gfxstream {
23 
24 // Abstraction around libnativewindow to support testing.
25 class ANativeWindowHelper {
26   public:
~ANativeWindowHelper()27     virtual ~ANativeWindowHelper() {}
28 
29     virtual bool isValid(EGLNativeWindowType window) = 0;
30     virtual bool isValid(EGLClientBuffer buffer) = 0;
31 
32     virtual void acquire(EGLNativeWindowType window) = 0;
33     virtual void release(EGLNativeWindowType window)= 0;
34 
35     virtual void acquire(EGLClientBuffer buffer) = 0;
36     virtual void release(EGLClientBuffer buffer) = 0;
37 
38     virtual int getConsumerUsage(EGLNativeWindowType window, int* usage) = 0;
39     virtual void setUsage(EGLNativeWindowType window, int usage) = 0;
40 
41     virtual int getWidth(EGLNativeWindowType window) = 0;
42     virtual int getHeight(EGLNativeWindowType window) = 0;
43 
44     virtual int getWidth(EGLClientBuffer buffer) = 0;
45     virtual int getHeight(EGLClientBuffer buffer) = 0;
46     virtual int getFormat(EGLClientBuffer buffer, Gralloc* helper) = 0;
47     virtual int getHostHandle(EGLClientBuffer buffer, Gralloc* helper) = 0;
48 
49     virtual void setSwapInterval(EGLNativeWindowType window, int interval) = 0;
50 
51     virtual int queueBuffer(EGLNativeWindowType window, EGLClientBuffer buffer, int fence) = 0;
52     virtual int dequeueBuffer(EGLNativeWindowType window, EGLClientBuffer* buffer, int* fence) = 0;
53     virtual int cancelBuffer(EGLNativeWindowType window, EGLClientBuffer buffer) = 0;
54 };
55 
56 }  // namespace gfxstream
57