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: |
reed@android.com | c3a8c5f | 2009-05-26 13:27:48 +0000 | [diff] [blame] | 17 | SkOSWindow(void* screen); |
| 18 | virtual ~SkOSWindow(); |
reed@android.com | 671cd65 | 2009-05-22 20:44:12 +0000 | [diff] [blame] | 19 | |
joshualitt | 474a9ea | 2015-11-05 11:49:35 -0800 | [diff] [blame] | 20 | static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay) { |
| 21 | SkFAIL("not implemented\n"); |
| 22 | return false; |
joshualitt | 65d6fbb | 2015-11-04 13:41:02 -0800 | [diff] [blame] | 23 | } |
reed@android.com | 671cd65 | 2009-05-22 20:44:12 +0000 | [diff] [blame] | 24 | |
joshualitt | 65d6fbb | 2015-11-04 13:41:02 -0800 | [diff] [blame] | 25 | enum SkBackEndTypes { |
| 26 | kNone_BackEndType, |
| 27 | kNativeGL_BackEndType, |
| 28 | #if SK_ANGLE |
| 29 | kANGLE_BackEndType, |
| 30 | #endif // SK_ANGLE |
| 31 | #if SK_COMMAND_BUFFER |
| 32 | kCommandBuffer_BackEndType, |
| 33 | #endif // SK_COMMAND_BUFFER |
| 34 | }; |
| 35 | |
| 36 | void detach(); |
| 37 | bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*); |
| 38 | void present(); |
| 39 | bool makeFullscreen(); |
| 40 | void setVsync(bool); |
| 41 | void closeWindow(); |
| 42 | void loop() { |
| 43 | while (!fQuit) { |
| 44 | this->handleEvents(); |
| 45 | this->update(nullptr); |
| 46 | } |
| 47 | } |
reed@android.com | 671cd65 | 2009-05-22 20:44:12 +0000 | [diff] [blame] | 48 | |
| 49 | protected: |
joshualitt | 65d6fbb | 2015-11-04 13:41:02 -0800 | [diff] [blame] | 50 | void onSetTitle(const char title[]) override; |
joshualitt | 474a9ea | 2015-11-05 11:49:35 -0800 | [diff] [blame] | 51 | void onHandleInval(const SkIRect&) override; |
| 52 | void onPDFSaved(const char title[], const char desc[], const char path[]) override; |
reed@android.com | 671cd65 | 2009-05-22 20:44:12 +0000 | [diff] [blame] | 53 | |
| 54 | private: |
joshualitt | 65d6fbb | 2015-11-04 13:41:02 -0800 | [diff] [blame] | 55 | void handleEvents(); |
| 56 | bool fQuit; |
joshualitt | 474a9ea | 2015-11-05 11:49:35 -0800 | [diff] [blame] | 57 | uint32_t fWindowFlags; |
joshualitt | 65d6fbb | 2015-11-04 13:41:02 -0800 | [diff] [blame] | 58 | SDL_Window* fWindow; |
| 59 | SDL_GLContext fGLContext; |
reed@android.com | 671cd65 | 2009-05-22 20:44:12 +0000 | [diff] [blame] | 60 | |
| 61 | typedef SkWindow INHERITED; |
| 62 | }; |
| 63 | |
| 64 | #endif |