From 2259bd42cf7cede7c1196d10f1a5a68180c94a32 Mon Sep 17 00:00:00 2001 From: Jim Van Verth Date: Fri, 1 Sep 2017 14:49:09 -0400 Subject: More iOS Fixes for SkiaSDLExample. Fixes up resolution and sets up ES context properly. Change-Id: I660098905f0d3643b0c7392808833ab564dbd447 Reviewed-on: https://skia-review.googlesource.com/42122 Reviewed-by: Ethan Nicholas Commit-Queue: Jim Van Verth --- example/SkiaSDLExample.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'example') diff --git a/example/SkiaSDLExample.cpp b/example/SkiaSDLExample.cpp index 65254117fa..3878cc7f95 100644 --- a/example/SkiaSDLExample.cpp +++ b/example/SkiaSDLExample.cpp @@ -113,8 +113,8 @@ int main(int argc, char** argv) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); SDL_GLContext glContext = nullptr; -#if defined(SK_BUILD_FOR_ANDROID) - // For Android we need to set up for OpenGL ES and we make the window hi res & full screen +#if defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_IOS) + // For Android/iOS we need to set up for OpenGL ES and we make the window hi res & full screen SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); windowFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS | SDL_WINDOW_FULLSCREEN_DESKTOP | @@ -180,7 +180,10 @@ int main(int argc, char** argv) { return success; } - glViewport(0, 0, dm.w, dm.h); + int dw, dh; + SDL_GL_GetDrawableSize(window, &dw, &dh); + + glViewport(0, 0, dw, dh); glClearColor(1, 1, 1, 1); glClearStencil(0); glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); @@ -198,7 +201,7 @@ int main(int argc, char** argv) { GR_GL_GetIntegerv(interface.get(), GR_GL_FRAMEBUFFER_BINDING, &buffer); GrGLFramebufferInfo info; info.fFBOID = (GrGLuint) buffer; - GrBackendRenderTarget target(dm.w, dm.h, kMsaaSampleCount, kStencilBits, + GrBackendRenderTarget target(dw, dh, kMsaaSampleCount, kStencilBits, kSkia8888_GrPixelConfig, info); // setup SkSurface @@ -212,6 +215,7 @@ int main(int argc, char** argv) { nullptr, &props)); SkCanvas* canvas = surface->getCanvas(); + canvas->scale((float)dw/dm.w, (float)dh/dm.h); ApplicationState state; -- cgit v1.2.3