aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/views/sdl/SkOSWindow_SDL.cpp
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@google.com>2015-11-05 10:48:41 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-11-05 10:48:41 -0800
commit5d7a7fe5631d87ca3c18d2f75d8402906616c17b (patch)
tree6a1faf90ee04fd3471f80866c15cedf4c00e0082 /src/views/sdl/SkOSWindow_SDL.cpp
parenta2e69fcdedbd9a7762620e0e9dcdd86596369cff (diff)
Revert of Wire up SDL on Android (patchset #4 id:60001 of https://codereview.chromium.org/1415453009/ )
Reason for revert: breaks appurify Original issue's description: > Wire up SDL on Android > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/a4d3797c3b0f0cac8493c46cb334ca88a5d6ccf6 TBR=bsalomon@google.com,robertphillips@google.com,joshualitt@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1410703009
Diffstat (limited to 'src/views/sdl/SkOSWindow_SDL.cpp')
-rw-r--r--src/views/sdl/SkOSWindow_SDL.cpp92
1 files changed, 18 insertions, 74 deletions
diff --git a/src/views/sdl/SkOSWindow_SDL.cpp b/src/views/sdl/SkOSWindow_SDL.cpp
index 80802a1dd0..8edcd72bff 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 @@ static void handle_error() {
}
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,32 +49,22 @@ void SkOSWindow::detach() {
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) {
handle_error();
@@ -124,7 +77,7 @@ bool SkOSWindow::attach(SkBackEndTypes attachType, int msaaSampleCount, Attachme
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 @@ void SkEvent::SignalQueueTimer(SkMSec delay) {
// 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.