1 #ifndef _TCUANDROIDWINDOW_HPP
2 #define _TCUANDROIDWINDOW_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program Tester Core
5 * ----------------------------------------
7 * Copyright 2014 The Android Open Source Project
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * \brief Android window.
24 *//*--------------------------------------------------------------------*/
26 #include "tcuDefs.hpp"
27 #include "tcuVector.hpp"
28 #include "deSemaphore.hpp"
29 #include "deMutex.hpp"
33 #include <android/native_window.h>
40 // \note Window is thread-safe, WindowRegistry is not
49 STATE_PENDING_DESTROY,
50 STATE_READY_FOR_DESTROY,
51 STATE_ACQUIRED_FOR_DESTROY,
56 Window (ANativeWindow* window);
59 bool tryAcquire (void);
62 void markForDestroy (void);
63 bool isPendingDestroy (void) const;
64 bool tryAcquireForDestroy(bool onlyMarked);
66 ANativeWindow* getNativeWindow (void) { return m_window; }
68 void setBuffersGeometry (int width, int height, int32_t format);
70 IVec2 getSize (void) const;
73 Window (const Window& other);
74 Window& operator= (const Window& other);
76 ANativeWindow* m_window;
77 mutable de::Mutex m_stateLock;
84 WindowRegistry (void);
85 ~WindowRegistry (void);
87 void addWindow (ANativeWindow* window);
88 void destroyWindow (ANativeWindow* window);
90 Window* tryAcquireWindow (void);
92 void garbageCollect (void);
95 std::vector<Window*> m_windows;
101 #endif // _TCUANDROIDWINDOW_HPP