• 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 <system/window.h>
17 
18 #include <cstdarg>
19 
20 #include "AndroidBufferQueue.h"
21 
22 namespace aemu {
23 
24 class AndroidWindow : public ANativeWindow {
25 public:
26     AndroidWindow(int width, int height);
27 
28     ~AndroidWindow() = default;
29 
getSelf(ANativeWindow * window)30     static AndroidWindow* getSelf(ANativeWindow* window) {
31         return (AndroidWindow*)(window);
32     }
33 
getSelfConst(const ANativeWindow * window)34     static const AndroidWindow* getSelfConst(const ANativeWindow* window) {
35         return (const AndroidWindow*)(window);
36     }
37 
38     void setProducer(AndroidBufferQueue* fromProducer,
39                      AndroidBufferQueue* toProducer);
40     int dequeueBuffer(ANativeWindowBuffer** buffer, int* fenceFd);
41     int queueBuffer(ANativeWindowBuffer* buffer, int fenceFd);
42     int cancelBuffer(ANativeWindowBuffer* buffer, int fenceFd);
43 
44     int query(int what, int* value) const;
45     int perform(int operation, va_list args);
46 
47     AndroidBufferQueue* fromProducer = nullptr;
48     AndroidBufferQueue* toProducer = nullptr;
49 
50     int swapInterval = 1;
51     int width = 256;
52     int height = 256;
53 };
54 
55 } // namespace aemu
56 
57 extern "C" {
58 
59 ANativeWindow* create_host_anativewindow(int width, int height);
60 void destroy_host_anativewindow(ANativeWindow* window);
61 
62 } // extern "C"