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 bool initialize(const std::string &name, int width, int height); 29 virtual void destroy() = 0; 30 virtual void disableErrorMessageDialog() = 0; 31 32 int getX() const; 33 int getY() const; 34 int getWidth() const; 35 int getHeight() const; 36 37 // Takes a screenshot of the window, returning the result as a mWidth * mHeight * 4 38 // normalized unsigned byte BGRA array. Note that it will be used to test the window 39 // manager's behavior so it needs to take an actual screenshot of the screen and not 40 // just grab the pixels of the window. Returns if it was successful. 41 virtual bool takeScreenshot(uint8_t *pixelData); 42 43 // Re-initializes the native window. This is used on platforms which do not 44 // have a reusable EGLNativeWindowType in order to recreate it, and is 45 // needed by the test suite because it re-uses the same OSWindow for 46 // multiple EGLSurfaces. 47 virtual void resetNativeWindow() = 0; 48 49 virtual EGLNativeWindowType getNativeWindow() const = 0; 50 virtual EGLNativeDisplayType getNativeDisplay() const = 0; 51 52 virtual void messageLoop() = 0; 53 54 bool popEvent(Event *event); 55 virtual void pushEvent(Event event); 56 57 virtual void setMousePosition(int x, int y) = 0; 58 virtual bool setOrientation(int width, int height) = 0; 59 virtual bool setPosition(int x, int y) = 0; 60 virtual bool resize(int width, int height) = 0; 61 virtual void setVisible(bool isVisible) = 0; 62 63 virtual void signalTestEvent() = 0; 64 65 // Pops events look for the test event 66 bool didTestEventFire(); 67 68 // Whether window has been successfully initialized. valid()69 bool valid() const { return mValid; } 70 ignoreSizeEvents()71 void ignoreSizeEvents() { mIgnoreSizeEvents = true; } 72 73 protected: 74 OSWindow(); 75 virtual ~OSWindow(); 76 77 virtual bool initializeImpl(const std::string &name, int width, int height) = 0; 78 79 int mX; 80 int mY; 81 int mWidth; 82 int mHeight; 83 84 std::list<Event> mEvents; 85 86 bool mValid; 87 bool mIgnoreSizeEvents; 88 }; 89 90 namespace angle 91 { 92 // Find a test data file or directory. 93 ANGLE_UTIL_EXPORT bool FindTestDataPath(const char *searchPath, 94 char *dataPathOut, 95 size_t maxDataPathOutLen); 96 } // namespace angle 97 98 #endif // UTIL_OSWINDOW_H_ 99