• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2018 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 express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 #pragma once
15 
16 #include "AndroidBufferQueue.h"
17 
18 #include <system/window.h>
19 
20 namespace aemu {
21 
22 class AndroidWindow : public ANativeWindow {
23 public:
24     AndroidWindow(int width, int height);
25 
26     ~AndroidWindow() = default;
27 
getSelf(ANativeWindow * window)28     static AndroidWindow* getSelf(ANativeWindow* window) {
29         return (AndroidWindow*)(window);
30     }
31 
getSelfConst(const ANativeWindow * window)32     static const AndroidWindow* getSelfConst(const ANativeWindow* window) {
33         return (const AndroidWindow*)(window);
34     }
35 
36     void setProducer(AndroidBufferQueue* fromProducer,
37                      AndroidBufferQueue* toProducer);
38     int dequeueBuffer(ANativeWindowBuffer** buffer, int* fenceFd);
39     int queueBuffer(ANativeWindowBuffer* buffer, int fenceFd);
40     int cancelBuffer(ANativeWindowBuffer* buffer, int fenceFd);
41 
42     int query(int what, int* value) const;
43     int perform(int operation, va_list args);
44 
45     AndroidBufferQueue* fromProducer = nullptr;
46     AndroidBufferQueue* toProducer = nullptr;
47 
48     int swapInterval = 1;
49     int width = 256;
50     int height = 256;
51 };
52 
53 } // namespace aemu
54 
55 extern "C" {
56 
57 ANativeWindow* create_host_anativewindow(int width, int height);
58 void destroy_host_anativewindow(ANativeWindow* window);
59 
60 } // extern "C"