blob: e08108add45c4d21cb1ec869fa1e5fa4eb27c5dc [file] [log] [blame]
reed@android.com671cd652009-05-22 20:44:12 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * Copyright 2006 The Android Open Source Project
reed@android.com671cd652009-05-22 20:44:12 +00003 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00004 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
reed@android.com671cd652009-05-22 20:44:12 +00006 */
7
8#ifndef SkOSWindow_SDL_DEFINED
9#define SkOSWindow_SDL_DEFINED
10
11#include "SDL.h"
joshualitt65d6fbb2015-11-04 13:41:02 -080012#include "SDL_opengl.h"
reed@android.com671cd652009-05-22 20:44:12 +000013#include "SkWindow.h"
14
15class SkOSWindow : public SkWindow {
16public:
kkinnunenabc0c822016-01-14 05:37:51 -080017 SkOSWindow(void*);
reed@android.comc3a8c5f2009-05-26 13:27:48 +000018 virtual ~SkOSWindow();
reed@android.com671cd652009-05-22 20:44:12 +000019
joshualitt65d6fbb2015-11-04 13:41:02 -080020 enum SkBackEndTypes {
kkinnunenabc0c822016-01-14 05:37:51 -080021 kNone_BackEndType, // TODO: remove this, it's not a real option.
joshualitt65d6fbb2015-11-04 13:41:02 -080022 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();
kkinnunenabc0c822016-01-14 05:37:51 -080037 static void RunEventLoop();
reed@android.com671cd652009-05-22 20:44:12 +000038
39protected:
joshualitt65d6fbb2015-11-04 13:41:02 -080040 void onSetTitle(const char title[]) override;
reed@android.com671cd652009-05-22 20:44:12 +000041
42private:
kkinnunenabc0c822016-01-14 05:37:51 -080043 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
joshualitt65d6fbb2015-11-04 13:41:02 -080051 SDL_Window* fWindow;
52 SDL_GLContext fGLContext;
kkinnunenabc0c822016-01-14 05:37:51 -080053 int fWindowMSAASampleCount;
reed@android.com671cd652009-05-22 20:44:12 +000054 typedef SkWindow INHERITED;
55};
56
57#endif