• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 <nativebase/nativebase.h>
20 #include <system/graphics.h>
21 
22 #define ANDROID_NATIVE_WINDOW_MAGIC ANDROID_NATIVE_MAKE_CONSTANT('_', 'w', 'n', 'd')
23 
24 enum {
25     NATIVE_WINDOW_WIDTH = 0,
26     NATIVE_WINDOW_HEIGHT = 1,
27 };
28 
29 struct ANativeWindow {
ANativeWindowANativeWindow30     ANativeWindow() : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0) {
31         common.magic = ANDROID_NATIVE_BUFFER_MAGIC;
32         common.version = sizeof(ANativeWindowBuffer);
33         memset(common.reserved, 0, sizeof(common.reserved));
34     }
35 
36     android_native_base_t common;
37 
38     const uint32_t flags;
39     const int minSwapInterval;
40     const int maxSwapInterval;
41     const float xdpi;
42     const float ydpi;
43     intptr_t oem[4];
44 
45     int (*setSwapInterval)(ANativeWindow*, int);
46     int (*dequeueBuffer_DEPRECATED)(ANativeWindow*, ANativeWindowBuffer**);
47     int (*lockBuffer_DEPRECATED)(ANativeWindow*, ANativeWindowBuffer*);
48     int (*queueBuffer_DEPRECATED)(ANativeWindow*, ANativeWindowBuffer*);
49     int (*query)(const ANativeWindow*, int, int*);
50     int (*perform)(ANativeWindow*, int, ...);
51     int (*cancelBuffer_DEPRECATED)(ANativeWindow*, ANativeWindowBuffer*);
52     int (*dequeueBuffer)(ANativeWindow*, ANativeWindowBuffer**, int*);
53     int (*queueBuffer)(ANativeWindow*, ANativeWindowBuffer*, int);
54     int (*cancelBuffer)(ANativeWindow*, ANativeWindowBuffer*, int);
55 };
56 
native_window_set_usage(ANativeWindow *,uint64_t)57 static inline int native_window_set_usage(ANativeWindow*, uint64_t) {
58     // No-op
59     return 0;
60 }
61 
native_window_dequeue_buffer_and_wait(ANativeWindow * anw,ANativeWindowBuffer ** anwb)62 static inline int native_window_dequeue_buffer_and_wait(ANativeWindow* anw,
63                                                         ANativeWindowBuffer** anwb) {
64     return anw->dequeueBuffer_DEPRECATED(anw, anwb);
65 }
66