• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (c) 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 
7 #ifndef SAMPLE_UTIL_WINDOW_H
8 #define SAMPLE_UTIL_WINDOW_H
9 
10 #include <list>
11 #include <stdint.h>
12 #include <string>
13 
14 #include <EGL/egl.h>
15 #include <EGL/eglext.h>
16 
17 #include "Event.h"
18 
19 class OSWindow
20 {
21   public:
22     OSWindow();
23     virtual ~OSWindow();
24 
25     virtual bool initialize(const std::string &name, size_t width, size_t height) = 0;
26     virtual void destroy() = 0;
27 
28     int getX() const;
29     int getY() const;
30     int getWidth() const;
31     int getHeight() const;
32 
33     // Takes a screenshot of the window, returning the result as a mWidth * mHeight * 4
34     // normalized unsigned byte BGRA array. Note that it will be used to test the window
35     // manager's behavior so it needs to take an actual screenshot of the screen and not
36     // just grab the pixels of the window. Returns if it was successful.
37     virtual bool takeScreenshot(uint8_t *pixelData);
38 
39     virtual EGLNativeWindowType getNativeWindow() const = 0;
40     virtual EGLNativeDisplayType getNativeDisplay() const = 0;
41 
42     virtual void* getFramebufferNativeWindow() const = 0;
43 
getDevicePixelRatio()44     virtual float getDevicePixelRatio() const {
45         return 1.0f;
46     }
47 
48     virtual void messageLoop() = 0;
49 
50     bool popEvent(Event *event);
51     virtual void pushEvent(Event event);
52 
53     virtual void setMousePosition(int x, int y) = 0;
54     virtual bool setPosition(int x, int y) = 0;
55     virtual bool resize(int width, int height) = 0;
56     virtual void setVisible(bool isVisible) = 0;
57 
58     virtual void signalTestEvent() = 0;
59 
60     // Pops events look for the test event
61     bool didTestEventFire();
62 
63   protected:
64     int mX;
65     int mY;
66     int mWidth;
67     int mHeight;
68 
69     std::list<Event> mEvents;
70 };
71 
72 OSWindow *CreateOSWindow();
73 
74 #endif // SAMPLE_UTIL_WINDOW_H
75