From bc0a701e472880e874466985ce52c07760eb9f8a Mon Sep 17 00:00:00 2001 From: pelya Date: Fri, 10 May 2013 23:45:04 +0300 Subject: [PATCH] Fixed 4:3 aspect ratio, magnifying glass is buggy in this mode (I hope noone will use these two options together) --- project/java/Video.java | 11 ++- .../ballfield/AndroidAppSettings.cfg | 2 +- .../jni/application/ballfield/ballfield.cpp | 2 +- .../src/video/android/SDL_androidvideo-1.2.c | 6 +- .../video/android/SDL_androidvideo-1.3-stub.c | 12 +-- .../src/video/android/SDL_androidvideo.c | 77 +++++++++---------- .../src/video/android/SDL_androidvideo.h | 3 +- .../video/android/SDL_touchscreenkeyboard.c | 33 ++------ .../jni/sdl-1.2/src/video/android/SDL_video.c | 42 +++++----- 9 files changed, 93 insertions(+), 95 deletions(-) diff --git a/project/java/Video.java b/project/java/Video.java index 600515056..01abb2004 100644 --- a/project/java/Video.java +++ b/project/java/Video.java @@ -389,7 +389,14 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer } public void onSurfaceChanged(GL10 gl, int w, int h) { - Log.i("SDL", "libSDL: DemoRenderer.onSurfaceChanged(): paused " + mPaused + " mFirstTimeStart " + mFirstTimeStart ); + Log.i("SDL", "libSDL: DemoRenderer.onSurfaceChanged(): paused " + mPaused + " mFirstTimeStart " + mFirstTimeStart + " w " + w + " h " + h); + if( w < h && Globals.HorizontalOrientation ) + { + // Sometimes when Android awakes from lockscreen, portrait orientation is kept + int x = w; + w = h; + h = x; + } mWidth = w; mHeight = h; mGl = gl; @@ -569,6 +576,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer } public void DrawLogo(GL10 gl) { + /* // TODO: this not quite works, as it seems BitmapDrawable bmp = null; try @@ -619,6 +627,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer gl.glDeleteTextures(1, mTextureNameWorkspace, 0); gl.glFlush(); + */ } diff --git a/project/jni/application/ballfield/AndroidAppSettings.cfg b/project/jni/application/ballfield/AndroidAppSettings.cfg index bee8d6ecb..c482983c0 100644 --- a/project/jni/application/ballfield/AndroidAppSettings.cfg +++ b/project/jni/application/ballfield/AndroidAppSettings.cfg @@ -12,7 +12,7 @@ NeedStencilBuffer=n NeedGles2=n SwVideoMode=y SdlVideoResize=y -SdlVideoResizeKeepAspect=n +SdlVideoResizeKeepAspect=y CompatibilityHacks=n CompatibilityHacksStaticInit=n CompatibilityHacksTextInputEmulatesHwKeyboard=n diff --git a/project/jni/application/ballfield/ballfield.cpp b/project/jni/application/ballfield/ballfield.cpp index 807783daf..7259519c9 100644 --- a/project/jni/application/ballfield/ballfield.cpp +++ b/project/jni/application/ballfield/ballfield.cpp @@ -25,7 +25,7 @@ Definitions... ----------------------------------------------------------*/ -#define SCREEN_W 800 +#define SCREEN_W 640 #define SCREEN_H 480 diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c index e8b2c8f02..2f7ec792e 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c @@ -382,7 +382,7 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current, SDL_RendererInfo SDL_VideoRendererInfo; SDL_SelectVideoDisplay(0); - SDL_VideoWindow = SDL_CreateWindow("", 0, 0, width, height, SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS | SDL_WINDOW_OPENGL); + SDL_VideoWindow = SDL_CreateWindow("", (SDL_ANDROID_sRealWindowWidth-SDL_ANDROID_sWindowWidth)/2, 0, width, height, SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS | SDL_WINDOW_OPENGL); SDL_memset(&mode, 0, sizeof(mode)); mode.format = PixelFormatEnum; @@ -422,7 +422,7 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current, DEBUGOUT("ANDROID_SetVideoMode() HwSurfaceCount %d HwSurfaceList %p", HwSurfaceCount, HwSurfaceList); } glViewport(0, 0, SDL_ANDROID_sRealWindowWidth, SDL_ANDROID_sRealWindowHeight); - glOrthof(0.0, (GLfloat) SDL_ANDROID_sWindowWidth, (GLfloat) SDL_ANDROID_sWindowHeight, 0.0, 0.0, 1.0); + glOrthof(0, SDL_ANDROID_sRealWindowWidth, SDL_ANDROID_sWindowHeight, 0, 0, 1); } /* Allocate the new pixel format for the screen */ @@ -1134,7 +1134,7 @@ void SDL_ANDROID_VideoContextRecreated() SDL_SelectRenderer(SDL_VideoWindow); // Re-apply glOrtho() and blend modes // Re-apply our custom 4:3 screen aspect ratio glViewport(0, 0, SDL_ANDROID_sRealWindowWidth, SDL_ANDROID_sRealWindowHeight); - glOrthof(0.0, (GLfloat) SDL_ANDROID_sWindowWidth, (GLfloat) SDL_ANDROID_sWindowHeight, 0.0, 0.0, 1.0); + glOrthof(0, SDL_ANDROID_sRealWindowWidth, SDL_ANDROID_sWindowHeight, 0, 0, 1); for( i = 0; i < HwSurfaceCount; i++ ) { // Allocate HW texture diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.3-stub.c b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.3-stub.c index cc535f68a..dc39713c8 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.3-stub.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.3-stub.c @@ -85,8 +85,8 @@ int ANDROID_VideoInit(_THIS) SDL_VideoDisplay display; SDL_DisplayMode mode; - mode.w = SDL_ANDROID_sWindowWidth; - mode.h = SDL_ANDROID_sWindowHeight; + mode.w = SDL_ANDROID_sRealWindowWidth; + mode.h = SDL_ANDROID_sRealWindowHeight; mode.refresh_rate = 0; mode.format = SDL_PIXELFORMAT_RGB565; mode.driverdata = NULL; @@ -103,8 +103,8 @@ int ANDROID_VideoInit(_THIS) void ANDROID_GetDisplayModes(_THIS, SDL_VideoDisplay * display) { SDL_DisplayMode mode; - mode.w = SDL_ANDROID_sWindowWidth; - mode.h = SDL_ANDROID_sWindowHeight; + mode.w = SDL_ANDROID_sRealWindowWidth; + mode.h = SDL_ANDROID_sRealWindowHeight; mode.refresh_rate = 0; mode.format = SDL_PIXELFORMAT_RGB565; mode.driverdata = NULL; @@ -113,8 +113,8 @@ void ANDROID_GetDisplayModes(_THIS, SDL_VideoDisplay * display) int ANDROID_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect) { - rect->w = SDL_ANDROID_sWindowWidth; - rect->h = SDL_ANDROID_sWindowHeight; + rect->w = SDL_ANDROID_sRealWindowWidth; + rect->h = SDL_ANDROID_sRealWindowHeight; return 1; }; diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo.c b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo.c index 22e0bf35d..16b7400f6 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo.c @@ -54,7 +54,8 @@ int SDL_ANDROID_sWindowHeight = 0; int SDL_ANDROID_sRealWindowWidth = 0; int SDL_ANDROID_sRealWindowHeight = 0; -SDL_Rect SDL_ANDROID_ForceClearScreenRect = { 0, 0, 0, 0 }; +SDL_Rect SDL_ANDROID_ForceClearScreenRect[2] = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 } }; +int SDL_ANDROID_ForceClearScreenRectAmount = 0; // Extremely wicked JNI environment to call Java functions from C code static JNIEnv* JavaEnv = NULL; @@ -102,29 +103,35 @@ static SDL_ANDROID_ApplicationPutToBackgroundCallback_t openALRestoredCallback = int SDL_ANDROID_CallJavaSwapBuffers() { + if( !glContextLost ) { - SDL_ANDROID_drawTouchscreenKeyboard(); - } - - // Clear part of screen not used by SDL - on Android the screen contains garbage after each frame - if( SDL_ANDROID_ForceClearScreenRect.w != 0 && SDL_ANDROID_ForceClearScreenRect.h != 0 ) - { - glPushMatrix(); - glLoadIdentity(); - glOrthof( 0.0f, SDL_ANDROID_sRealWindowWidth, SDL_ANDROID_sRealWindowHeight, 0.0f, 0.0f, 1.0f ); - glColor4f(0.0f, 0.0f, 0.0f, 1.0f); - glEnableClientState(GL_VERTEX_ARRAY); - - GLshort vertices[] = { SDL_ANDROID_ForceClearScreenRect.x, SDL_ANDROID_ForceClearScreenRect.y, - SDL_ANDROID_ForceClearScreenRect.x + SDL_ANDROID_ForceClearScreenRect.w, SDL_ANDROID_ForceClearScreenRect.y, - SDL_ANDROID_ForceClearScreenRect.x + SDL_ANDROID_ForceClearScreenRect.w, SDL_ANDROID_ForceClearScreenRect.y + SDL_ANDROID_ForceClearScreenRect.h, - SDL_ANDROID_ForceClearScreenRect.x, SDL_ANDROID_ForceClearScreenRect.y + SDL_ANDROID_ForceClearScreenRect.h }; - glVertexPointer(2, GL_SHORT, 0, vertices); - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + // Clear part of screen not used by SDL - on Android the screen contains garbage after each frame + if( SDL_ANDROID_ForceClearScreenRectAmount > 0 ) + { + int i; - glDisableClientState(GL_VERTEX_ARRAY); - glPopMatrix(); + glPushMatrix(); + glLoadIdentity(); + glOrthof( 0.0f, SDL_ANDROID_sRealWindowWidth, SDL_ANDROID_sRealWindowHeight, 0.0f, 0.0f, 1.0f ); + glColor4f(0.0f, 0.0f, 0.0f, 1.0f); + glEnableClientState(GL_VERTEX_ARRAY); + + for( i = 0; i < SDL_ANDROID_ForceClearScreenRectAmount; i++ ) + { + GLshort vertices[] = { SDL_ANDROID_ForceClearScreenRect[i].x, SDL_ANDROID_ForceClearScreenRect[i].y, + SDL_ANDROID_ForceClearScreenRect[i].x + SDL_ANDROID_ForceClearScreenRect[i].w, SDL_ANDROID_ForceClearScreenRect[i].y, + SDL_ANDROID_ForceClearScreenRect[i].x + SDL_ANDROID_ForceClearScreenRect[i].w, SDL_ANDROID_ForceClearScreenRect[i].y + SDL_ANDROID_ForceClearScreenRect[i].h, + SDL_ANDROID_ForceClearScreenRect[i].x, SDL_ANDROID_ForceClearScreenRect[i].y + SDL_ANDROID_ForceClearScreenRect[i].h }; + glVertexPointer(2, GL_SHORT, 0, vertices); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + } + + glDisableClientState(GL_VERTEX_ARRAY); + glPopMatrix(); + } + + SDL_ANDROID_drawTouchscreenKeyboard(); } if( ! (*JavaEnv)->CallIntMethod( JavaEnv, JavaRenderer, JavaSwapBuffers ) ) @@ -167,30 +174,22 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeResize) ( JNIEnv* env, jobject thiz, jint // TODO: tweak that parameters when app calls SetVideoMode(), not here - app may request something else than 640x480, it's okay for most apps though SDL_ANDROID_sWindowWidth = (SDL_ANDROID_sFakeWindowWidth*h)/SDL_ANDROID_sFakeWindowHeight; SDL_ANDROID_sWindowHeight = h; - SDL_ANDROID_ForceClearScreenRect.x = SDL_ANDROID_sWindowWidth; - SDL_ANDROID_ForceClearScreenRect.y = 0; - SDL_ANDROID_ForceClearScreenRect.w = w - SDL_ANDROID_sWindowWidth; - SDL_ANDROID_ForceClearScreenRect.h = h; - - if(SDL_ANDROID_sWindowWidth >= w) - { - SDL_ANDROID_sWindowWidth = w; - SDL_ANDROID_sWindowHeight = (SDL_ANDROID_sFakeWindowHeight*w)/SDL_ANDROID_sFakeWindowWidth; - SDL_ANDROID_ForceClearScreenRect.x = 0; - SDL_ANDROID_ForceClearScreenRect.y = SDL_ANDROID_sWindowHeight; - SDL_ANDROID_ForceClearScreenRect.w = w; - SDL_ANDROID_ForceClearScreenRect.h = SDL_ANDROID_sWindowHeight - h; // OpenGL vertical coord is inverted - } + SDL_ANDROID_ForceClearScreenRect[0].x = 0; + SDL_ANDROID_ForceClearScreenRect[0].y = 0; + SDL_ANDROID_ForceClearScreenRect[0].w = (SDL_ANDROID_sRealWindowWidth - SDL_ANDROID_sWindowWidth) / 2; + SDL_ANDROID_ForceClearScreenRect[0].h = h; + SDL_ANDROID_ForceClearScreenRect[1].x = SDL_ANDROID_sRealWindowWidth - SDL_ANDROID_ForceClearScreenRect[0].w; + SDL_ANDROID_ForceClearScreenRect[1].y = 0; + SDL_ANDROID_ForceClearScreenRect[1].w = SDL_ANDROID_ForceClearScreenRect[0].w; + SDL_ANDROID_ForceClearScreenRect[1].h = h; + SDL_ANDROID_ForceClearScreenRectAmount = 2; } else #endif { - SDL_ANDROID_ForceClearScreenRect.w = 0; - SDL_ANDROID_ForceClearScreenRect.h = 0; - SDL_ANDROID_ForceClearScreenRect.x = 0; - SDL_ANDROID_ForceClearScreenRect.y = 0; SDL_ANDROID_sWindowWidth = w; SDL_ANDROID_sWindowHeight = h; + SDL_ANDROID_ForceClearScreenRectAmount = 0; } __android_log_print(ANDROID_LOG_INFO, "libSDL", "Physical screen resolution is %dx%d, virtual screen %dx%d", w, h, SDL_ANDROID_sWindowWidth, SDL_ANDROID_sWindowHeight ); SDL_ANDROID_TouchscreenCalibrationWidth = SDL_ANDROID_sWindowWidth; diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo.h b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo.h index ae56d7e4c..42c7e2c98 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo.h +++ b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo.h @@ -51,7 +51,8 @@ extern int SDL_ANDROID_BITSPERPIXEL; extern void SDL_ANDROID_TextInputInit(char * buffer, int len); extern int SDL_ANDROID_TextInputFinished; extern SDL_Surface *SDL_CurrentVideoSurface; -extern SDL_Rect SDL_ANDROID_ForceClearScreenRect; +extern SDL_Rect SDL_ANDROID_ForceClearScreenRect[]; +extern int SDL_ANDROID_ForceClearScreenRectAmount; extern int SDL_ANDROID_ShowScreenUnderFinger; extern SDL_Rect SDL_ANDROID_ShowScreenUnderFingerRect, SDL_ANDROID_ShowScreenUnderFingerRectSrc; extern int SDL_ANDROID_CallJavaSwapBuffers(); diff --git a/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c b/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c index 6f9ead6c3..8b5b39b92 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c @@ -208,7 +208,7 @@ static inline void drawCharTexFlip(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * cropRect[3] = -cropRect[3]; } glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, cropRect); - glDrawTexiOES(dest->x, SDL_ANDROID_sWindowHeight - dest->y - dest->h, 0, dest->w, dest->h); + glDrawTexiOES(dest->x, SDL_ANDROID_sRealWindowHeight - dest->y - dest->h, 0, dest->w, dest->h); } static inline void drawCharTex(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * dest, float r, float g, float b, float a) @@ -719,26 +719,16 @@ JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thi } // Arrows to the lower-left part of screen - arrows.w = SDL_ANDROID_sWindowWidth / (size + 2) * 2 / 3; + arrows.w = SDL_ANDROID_sRealWindowWidth / (size + 2) * 2 / 3; arrows.h = arrows.w; // Move to the screen edge arrows.x = 0; - arrows.y = SDL_ANDROID_sWindowHeight - arrows.h; + arrows.y = SDL_ANDROID_sRealWindowHeight - arrows.h; arrowsExtended.w = arrows.w * 2; arrowsExtended.h = arrows.h * 2; arrowsExtended.x = arrows.x + arrows.w / 2 - arrowsExtended.w / 2; arrowsExtended.y = arrows.y + arrows.h / 2 - arrowsExtended.h / 2; - /* - // This will leave some unused space near the edge - arrows.x = SDL_ANDROID_sWindowWidth / 4; - arrows.y = SDL_ANDROID_sWindowHeight - SDL_ANDROID_sWindowWidth / 4; - arrows.x -= arrows.w/2; - arrows.y -= arrows.h/2; - // Move arrows from the center of the screen - arrows.x -= size * SDL_ANDROID_sWindowWidth / 32; - arrows.y += size * SDL_ANDROID_sWindowWidth / 32; - */ // Buttons to the lower-right in 2 rows for(i = 0; i < 3; i++) @@ -746,23 +736,16 @@ JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thi { // Custom button ordering int iii = ii + i*2; - buttons[iii].w = SDL_ANDROID_sWindowWidth / (size + 2) / 3; + buttons[iii].w = SDL_ANDROID_sRealWindowWidth / (size + 2) / 3; buttons[iii].h = buttons[iii].w; // Move to the screen edge - buttons[iii].x = SDL_ANDROID_sWindowWidth - buttons[iii].w * (ii + 1); - buttons[iii].y = SDL_ANDROID_sWindowHeight - buttons[iii].h * (i + 1); - /* - // This will leave some unused space near the edge and between buttons - buttons[iii].x = SDL_ANDROID_sWindowWidth - SDL_ANDROID_sWindowWidth / 12 - (SDL_ANDROID_sWindowWidth * ii / 6); - buttons[iii].y = SDL_ANDROID_sWindowHeight - SDL_ANDROID_sWindowHeight / 8 - (SDL_ANDROID_sWindowHeight * i / 4); - buttons[iii].x -= buttons[iii].w/2; - buttons[iii].y -= buttons[iii].h/2; - */ + buttons[iii].x = SDL_ANDROID_sRealWindowWidth - buttons[iii].w * (ii + 1); + buttons[iii].y = SDL_ANDROID_sRealWindowHeight - buttons[iii].h * (i + 1); } buttons[6].x = 0; buttons[6].y = 0; - buttons[6].w = SDL_ANDROID_sWindowHeight/10; - buttons[6].h = SDL_ANDROID_sWindowHeight/10; + buttons[6].w = SDL_ANDROID_sRealWindowHeight/10; + buttons[6].h = SDL_ANDROID_sRealWindowHeight/10; for( i = 0; i < sizeof(pointerInButtonRect)/sizeof(pointerInButtonRect[0]); i++ ) { diff --git a/project/jni/sdl-1.2/src/video/android/SDL_video.c b/project/jni/sdl-1.2/src/video/android/SDL_video.c index d17943d5a..430a29bd9 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_video.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_video.c @@ -2441,18 +2441,18 @@ SDL_RenderClear() #if SDL_VIDEO_RENDER_RESIZE static inline void -SDL_RESIZE_resizePoints(int realW, int fakeW, int realH, int fakeH, +SDL_RESIZE_resizePoints(int realW, int fakeW, int realH, int fakeH, int offsetX, int offsetY, const SDL_Point * src, SDL_Point * dest, int count ) { int i; for( i = 0; i < count; i++ ) { - dest[i].x = src[i].x * realW / fakeW; - dest[i].y = src[i].y * realH / fakeH; + dest[i].x = src[i].x * realW / fakeW + offsetX; + dest[i].y = src[i].y * realH / fakeH + offsetY; } } static inline void -SDL_RESIZE_resizeRects(int realW, int fakeW, int realH, int fakeH, +SDL_RESIZE_resizeRects(int realW, int fakeW, int realH, int fakeH, int offsetX, int offsetY, const SDL_Rect ** src, SDL_Rect * dest, int count ) { int i; @@ -2463,6 +2463,8 @@ SDL_RESIZE_resizeRects(int realW, int fakeW, int realH, int fakeH, dest[i].y = src[i]->y * realH / fakeH; dest[i].w = (src[i]->w + src[i]->x) * realW / fakeW - dest[i].x; dest[i].h = (src[i]->h + src[i]->y) * realH / fakeH - dest[i].y; + dest[i].x += offsetX; + dest[i].y += offsetY; } } @@ -2505,8 +2507,8 @@ SDL_RenderDrawPoints(const SDL_Point * points, int count) } #if SDL_VIDEO_RENDER_RESIZE - realW = renderer->window->display->desktop_mode.w; - realH = renderer->window->display->desktop_mode.h; + realW = renderer->window->display->desktop_mode.w - renderer->window->x; + realH = renderer->window->display->desktop_mode.h - renderer->window->y; fakeW = renderer->window->w; fakeH = renderer->window->h; //if( fakeW > realW || fakeH > realH ) @@ -2516,7 +2518,7 @@ SDL_RenderDrawPoints(const SDL_Point * points, int count) SDL_OutOfMemory(); return -1; } - SDL_RESIZE_resizePoints( realW, fakeW, realH, fakeH, points, resized, count ); + SDL_RESIZE_resizePoints( realW, fakeW, realH, fakeH, renderer->window->x, renderer->window->y, points, resized, count ); ret = renderer->RenderDrawPoints(renderer, resized, count); SDL_stack_free(resized); return ret; @@ -2564,8 +2566,8 @@ SDL_RenderDrawLines(const SDL_Point * points, int count) } #if SDL_VIDEO_RENDER_RESIZE - realW = renderer->window->display->desktop_mode.w; - realH = renderer->window->display->desktop_mode.h; + realW = renderer->window->display->desktop_mode.w - renderer->window->x; + realH = renderer->window->display->desktop_mode.h - renderer->window->y; fakeW = renderer->window->w; fakeH = renderer->window->h; //if( fakeW > realW || fakeH > realH ) @@ -2575,7 +2577,7 @@ SDL_RenderDrawLines(const SDL_Point * points, int count) SDL_OutOfMemory(); return -1; } - SDL_RESIZE_resizePoints( realW, fakeW, realH, fakeH, points, resized, count ); + SDL_RESIZE_resizePoints( realW, fakeW, realH, fakeH, renderer->window->x, renderer->window->y, points, resized, count ); ret = renderer->RenderDrawLines(renderer, resized, count); SDL_stack_free(resized); return ret; @@ -2633,8 +2635,8 @@ SDL_RenderDrawRects(const SDL_Rect ** rects, int count) } #if SDL_VIDEO_RENDER_RESIZE - realW = renderer->window->display->desktop_mode.w; - realH = renderer->window->display->desktop_mode.h; + realW = renderer->window->display->desktop_mode.w - renderer->window->x; + realH = renderer->window->display->desktop_mode.h - renderer->window->y; fakeW = renderer->window->w; fakeH = renderer->window->h; //if( fakeW > realW || fakeH > realH ) @@ -2654,7 +2656,7 @@ SDL_RenderDrawRects(const SDL_Rect ** rects, int count) for( i = 0; i < count; i++ ) { resizedPtrs[i] = &(resized[i]); } - SDL_RESIZE_resizeRects( realW, fakeW, realH, fakeH, rects, resized, count ); + SDL_RESIZE_resizeRects( realW, fakeW, realH, fakeH, renderer->window->x, renderer->window->y, rects, resized, count ); ret = renderer->RenderDrawRects(renderer, resizedPtrs, count); SDL_stack_free(resizedPtrs); SDL_stack_free(resized); @@ -2713,8 +2715,8 @@ SDL_RenderFillRects(const SDL_Rect ** rects, int count) } #if SDL_VIDEO_RENDER_RESIZE - realW = renderer->window->display->desktop_mode.w; - realH = renderer->window->display->desktop_mode.h; + realW = renderer->window->display->desktop_mode.w - renderer->window->x; + realH = renderer->window->display->desktop_mode.h - renderer->window->y; fakeW = renderer->window->w; fakeH = renderer->window->h; //if( fakeW > realW || fakeH > realH ) @@ -2734,7 +2736,7 @@ SDL_RenderFillRects(const SDL_Rect ** rects, int count) for( i = 0; i < count; i++ ) { resizedPtrs[i] = &(resized[i]); } - SDL_RESIZE_resizeRects( realW, fakeW, realH, fakeH, rects, resized, count ); + SDL_RESIZE_resizeRects( realW, fakeW, realH, fakeH, renderer->window->x, renderer->window->y, rects, resized, count ); ret = renderer->RenderFillRects(renderer, resizedPtrs, count); SDL_stack_free(resizedPtrs); SDL_stack_free(resized); @@ -2810,8 +2812,8 @@ SDL_RenderCopy(SDL_Texture * texture, const SDL_Rect * srcrect, } #if SDL_VIDEO_RENDER_RESIZE - realW = window->display->desktop_mode.w; - realH = window->display->desktop_mode.h; + realW = window->display->desktop_mode.w - renderer->window->x; + realH = window->display->desktop_mode.h - renderer->window->y; fakeW = window->w; fakeH = window->h; //if( fakeW > realW || fakeH > realH ) @@ -2824,6 +2826,10 @@ SDL_RenderCopy(SDL_Texture * texture, const SDL_Rect * srcrect, real_dstrect.y = real_dstrect.y * realH / fakeH; real_dstrect.w -= real_dstrect.x; real_dstrect.h -= real_dstrect.y; + real_dstrect.x += renderer->window->x; + real_dstrect.y += renderer->window->y; + real_dstrect.w -= renderer->window->x; + real_dstrect.h -= renderer->window->y; //__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_RenderCopy dest %d:%d+%d+%d desktop_mode %d:%d", (int)real_dstrect.x, (int)real_dstrect.y, (int)real_dstrect.w, (int)real_dstrect.h, (int)realW, (int)realH); } #endif