Index: src/views/sdl/SkOSWindow_SDL.cpp |
diff --git a/src/views/sdl/SkOSWindow_SDL.cpp b/src/views/sdl/SkOSWindow_SDL.cpp |
index 80802a1dd09f8d3f6084397f12f19fbfd41e28b4..8edcd72bff3447887860a4d6980fa5de9b2e35b8 100644 |
--- a/src/views/sdl/SkOSWindow_SDL.cpp |
+++ b/src/views/sdl/SkOSWindow_SDL.cpp |
@@ -7,11 +7,7 @@ |
#include "SkOSWindow_SDL.h" |
#include "SkCanvas.h" |
-#if defined(SK_BUILD_FOR_ANDROID) |
-#include <GLES/gl.h> |
-#else |
#include <GL/gl.h> |
-#endif |
const int SCREEN_WIDTH = 640; |
const int SCREEN_HEIGHT = 480; |
@@ -23,50 +19,17 @@ |
} |
SkOSWindow::SkOSWindow(void* screen) : fQuit(false) , fGLContext(nullptr) { |
-#if defined(SK_BUILD_FOR_ANDROID) |
- // TODO we should try and get a 3.0 context first |
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); |
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); |
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); |
- fWindowFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | |
- SDL_WINDOW_BORDERLESS | SDL_WINDOW_FULLSCREEN_DESKTOP | |
- SDL_WINDOW_ALLOW_HIGHDPI; |
-#else |
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); |
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); |
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); |
- SDL_StartTextInput(); |
- |
- fWindowFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE; |
-#endif |
- SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); |
- SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); |
- SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); |
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); |
- SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); |
- SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); |
- |
- SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); |
- |
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) != 0) { |
- handle_error(); |
- return; |
- } |
- |
- SDL_DisplayMode dm; |
- if (SDL_GetDesktopDisplayMode(0, &dm) != 0) { |
- handle_error(); |
- return; |
- } |
- |
- fWindow = SDL_CreateWindow("SDL Window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, |
- dm.w, dm.h, fWindowFlags); |
- |
+ //Create window |
+ SDL_Init(SDL_INIT_VIDEO|SDL_INIT_GAMECONTROLLER|SDL_INIT_EVENTS); |
+ fWindow = SDL_CreateWindow("SDL Window", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, |
+ SCREEN_WIDTH, SCREEN_HEIGHT, |
+ SDL_WINDOW_OPENGL|SDL_WINDOW_SHOWN ); |
if (!fWindow) { |
handle_error(); |
return; |
} |
- this->resize(SkIntToScalar(dm.w), SkIntToScalar(dm.h)); |
+ SDL_StartTextInput(); |
+ this->resize(SCREEN_WIDTH, SCREEN_HEIGHT); |
} |
SkOSWindow::~SkOSWindow() { |
@@ -86,31 +49,21 @@ |
SDL_GL_DeleteContext(fGLContext); |
fGLContext = nullptr; |
} |
- |
-#if defined(SK_BUILD_FOR_ANDROID) |
- if (fWindow) { |
- // Destroy window |
- // Not totally sure why, but we have to do this or swapbuffers will hang |
- SDL_DestroyWindow(fWindow); |
- fWindow = nullptr; |
- } |
-#endif |
-} |
- |
-bool SkOSWindow::attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo* info) { |
- if (!fWindow) { |
- fWindow = SDL_CreateWindow("SDL Window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, |
- SCREEN_WIDTH, SCREEN_HEIGHT, |
- fWindowFlags); |
- } |
+} |
+ |
+bool SkOSWindow::attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*) { |
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); |
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); |
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); |
+ |
+ SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); |
+ SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); |
+ SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); |
if (msaaSampleCount > 0) { |
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); |
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, msaaSampleCount); |
} |
- |
- info->fSampleCount = msaaSampleCount; |
- info->fStencilBits = 8; |
fGLContext = SDL_GL_CreateContext(fWindow); |
if (!fGLContext) { |
@@ -124,7 +77,7 @@ |
return false; |
} |
- glViewport(0, 0, SkScalarFloorToInt(this->width()), SkScalarFloorToInt(this->height())); |
+ glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); |
glClearColor(1, 1, 1, 1); |
glClearStencil(0); |
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
@@ -256,23 +209,14 @@ |
// just need to record the delay time. We handle waking up for it in |
} |
-void SkOSWindow::onHandleInval(const SkIRect& rect) { |
-} |
- |
-void SkOSWindow::onPDFSaved(const char title[], const char desc[], const char path[]) { |
-} |
- |
////////////////////////////////////////////////////////////////////////////////////////////// |
+ |
#include "SkApplication.h" |
#include "SkEvent.h" |
#include "SkWindow.h" |
-#if defined(SK_BUILD_FOR_ANDROID) |
-int SDL_main(int argc, char** argv) { |
-#else |
-int main(int argc, char** argv) { |
-#endif |
+int main(int argc, char** argv){ |
SkOSWindow* window = create_sk_window(nullptr, argc, argv); |
// drain any events that occurred before |window| was assigned. |