• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2014 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // OSWindow:
7 //   Operating system window integration base class.
8 
9 #ifndef UTIL_OSWINDOW_H_
10 #define UTIL_OSWINDOW_H_
11 
12 #include <stdint.h>
13 #include <list>
14 #include <string>
15 
16 #include <EGL/egl.h>
17 #include <EGL/eglext.h>
18 
19 #include "util/Event.h"
20 #include "util/util_export.h"
21 
22 class ANGLE_UTIL_EXPORT OSWindow
23 {
24   public:
25     static OSWindow *New();
26     static void Delete(OSWindow **osWindow);
27 
28     virtual bool initialize(const std::string &name, int width, int height)       = 0;
29     virtual void destroy()                                                        = 0;
30 
31     int getX() const;
32     int getY() const;
33     int getWidth() const;
34     int getHeight() const;
35 
36     // Takes a screenshot of the window, returning the result as a mWidth * mHeight * 4
37     // normalized unsigned byte BGRA array. Note that it will be used to test the window
38     // manager's behavior so it needs to take an actual screenshot of the screen and not
39     // just grab the pixels of the window. Returns if it was successful.
40     virtual bool takeScreenshot(uint8_t *pixelData);
41 
42     // Re-initializes the native window. This is used on platforms which do not
43     // have a reusable EGLNativeWindowType in order to recreate it, and is
44     // needed by the test suite because it re-uses the same OSWindow for
45     // multiple EGLSurfaces.
46     virtual void resetNativeWindow() = 0;
47 
48     virtual EGLNativeWindowType getNativeWindow() const   = 0;
49     virtual EGLNativeDisplayType getNativeDisplay() const = 0;
50 
51     virtual void messageLoop() = 0;
52 
53     bool popEvent(Event *event);
54     virtual void pushEvent(Event event);
55 
56     virtual void setMousePosition(int x, int y) = 0;
57     virtual bool setPosition(int x, int y)      = 0;
58     virtual bool resize(int width, int height)  = 0;
59     virtual void setVisible(bool isVisible)     = 0;
60 
61     virtual void signalTestEvent() = 0;
62 
63     // Pops events look for the test event
64     bool didTestEventFire();
65 
66   protected:
67     OSWindow();
68     virtual ~OSWindow();
69     friend ANGLE_UTIL_EXPORT void FreeOSWindow(OSWindow *window);
70 
71     int mX;
72     int mY;
73     int mWidth;
74     int mHeight;
75 
76     std::list<Event> mEvents;
77 };
78 
79 #endif  // UTIL_OSWINDOW_H_
80