reed@android.com | 671cd65 | 2009-05-22 20:44:12 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2006 The Android Open Source Project |
reed@android.com | 671cd65 | 2009-05-22 20:44:12 +0000 | [diff] [blame] | 3 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
reed@android.com | 671cd65 | 2009-05-22 20:44:12 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #ifndef SkOSWindow_SDL_DEFINED |
| 9 | #define SkOSWindow_SDL_DEFINED |
| 10 | |
| 11 | #include "SDL.h" |
joshualitt | 65d6fbb | 2015-11-04 13:41:02 -0800 | [diff] [blame] | 12 | #include "SDL_opengl.h" |
reed@android.com | 671cd65 | 2009-05-22 20:44:12 +0000 | [diff] [blame] | 13 | #include "SkWindow.h" |
| 14 | |
| 15 | class SkOSWindow : public SkWindow { |
| 16 | public: |
kkinnunen | abc0c82 | 2016-01-14 05:37:51 -0800 | [diff] [blame] | 17 | SkOSWindow(void*); |
reed@android.com | c3a8c5f | 2009-05-26 13:27:48 +0000 | [diff] [blame] | 18 | virtual ~SkOSWindow(); |
reed@android.com | 671cd65 | 2009-05-22 20:44:12 +0000 | [diff] [blame] | 19 | |
joshualitt | 65d6fbb | 2015-11-04 13:41:02 -0800 | [diff] [blame] | 20 | enum SkBackEndTypes { |
kkinnunen | abc0c82 | 2016-01-14 05:37:51 -0800 | [diff] [blame] | 21 | kNone_BackEndType, // TODO: remove this, it's not a real option. |
joshualitt | 65d6fbb | 2015-11-04 13:41:02 -0800 | [diff] [blame] | 22 | kNativeGL_BackEndType, |
| 23 | #if SK_ANGLE |
| 24 | kANGLE_BackEndType, |
| 25 | #endif // SK_ANGLE |
| 26 | #if SK_COMMAND_BUFFER |
| 27 | kCommandBuffer_BackEndType, |
| 28 | #endif // SK_COMMAND_BUFFER |
| 29 | }; |
| 30 | |
| 31 | void detach(); |
| 32 | bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*); |
| 33 | void present(); |
| 34 | bool makeFullscreen(); |
| 35 | void setVsync(bool); |
| 36 | void closeWindow(); |
kkinnunen | abc0c82 | 2016-01-14 05:37:51 -0800 | [diff] [blame] | 37 | static void RunEventLoop(); |
reed@android.com | 671cd65 | 2009-05-22 20:44:12 +0000 | [diff] [blame] | 38 | |
| 39 | protected: |
joshualitt | 65d6fbb | 2015-11-04 13:41:02 -0800 | [diff] [blame] | 40 | void onSetTitle(const char title[]) override; |
reed@android.com | 671cd65 | 2009-05-22 20:44:12 +0000 | [diff] [blame] | 41 | |
| 42 | private: |
kkinnunen | abc0c82 | 2016-01-14 05:37:51 -0800 | [diff] [blame] | 43 | void createWindow(int msaaSampleCount); |
| 44 | void destroyWindow(); |
| 45 | void updateWindowTitle(); |
| 46 | static SkOSWindow* GetInstanceForWindowID(Uint32 windowID); |
| 47 | static bool HasDirtyWindows(); |
| 48 | static void UpdateDirtyWindows(); |
| 49 | static void HandleEvent(const SDL_Event&); |
| 50 | |
joshualitt | 65d6fbb | 2015-11-04 13:41:02 -0800 | [diff] [blame] | 51 | SDL_Window* fWindow; |
| 52 | SDL_GLContext fGLContext; |
kkinnunen | abc0c82 | 2016-01-14 05:37:51 -0800 | [diff] [blame] | 53 | int fWindowMSAASampleCount; |
reed@android.com | 671cd65 | 2009-05-22 20:44:12 +0000 | [diff] [blame] | 54 | typedef SkWindow INHERITED; |
| 55 | }; |
| 56 | |
| 57 | #endif |