blob: c40ec2e301fe066980bbcdaba849de6aaf74cc95 [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:
reed@android.comc3a8c5f2009-05-26 13:27:48 +000017 SkOSWindow(void* screen);
18 virtual ~SkOSWindow();
reed@android.com671cd652009-05-22 20:44:12 +000019
joshualitt474a9ea2015-11-05 11:49:35 -080020 static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay) {
21 SkFAIL("not implemented\n");
22 return false;
joshualitt65d6fbb2015-11-04 13:41:02 -080023 }
reed@android.com671cd652009-05-22 20:44:12 +000024
joshualitt65d6fbb2015-11-04 13:41:02 -080025 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.com671cd652009-05-22 20:44:12 +000048
49protected:
joshualitt65d6fbb2015-11-04 13:41:02 -080050 void onSetTitle(const char title[]) override;
joshualitt474a9ea2015-11-05 11:49:35 -080051 void onHandleInval(const SkIRect&) override;
52 void onPDFSaved(const char title[], const char desc[], const char path[]) override;
reed@android.com671cd652009-05-22 20:44:12 +000053
54private:
joshualitt65d6fbb2015-11-04 13:41:02 -080055 void handleEvents();
56 bool fQuit;
joshualitt474a9ea2015-11-05 11:49:35 -080057 uint32_t fWindowFlags;
joshualitt65d6fbb2015-11-04 13:41:02 -080058 SDL_Window* fWindow;
59 SDL_GLContext fGLContext;
reed@android.com671cd652009-05-22 20:44:12 +000060
61 typedef SkWindow INHERITED;
62};
63
64#endif