aboutsummaryrefslogtreecommitdiffhomepage
path: root/example
diff options
context:
space:
mode:
authorGravatar Jim Van Verth <jvanverth@google.com>2017-09-01 14:49:09 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-05 20:34:55 +0000
commit2259bd42cf7cede7c1196d10f1a5a68180c94a32 (patch)
tree646898191f4e854c12d890f81982243069e2a7ae /example
parent6f98bc648b1bb4928bf7011ee1d92eacc0db23bb (diff)
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 <ethannicholas@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'example')
-rw-r--r--example/SkiaSDLExample.cpp12
1 files changed, 8 insertions, 4 deletions
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;