Skip to content

Commit

Permalink
Added partial screen updates - they should be just a tiny bit faster,
Browse files Browse the repository at this point in the history
however I did not notice any difference.
  • Loading branch information
pelya committed Nov 17, 2011
1 parent db20fa2 commit a7108e2
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ static int ANDROID_SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 value)
return SDL_SetTextureAlphaMod((struct SDL_Texture *)surface->hwdata, value);
};

static void ANDROID_FlipHWSurfaceInternal()
static void ANDROID_FlipHWSurfaceInternal(int numrects, SDL_Rect *rects)
{
//__android_log_print(ANDROID_LOG_INFO, "libSDL", "ANDROID_FlipHWSurface()");
if( SDL_CurrentVideoSurface->hwdata && SDL_CurrentVideoSurface->pixels && ! ( SDL_CurrentVideoSurface->flags & SDL_HWSURFACE ) )
Expand All @@ -853,7 +853,14 @@ static void ANDROID_FlipHWSurfaceInternal()
rect.y = 0;
rect.w = SDL_CurrentVideoSurface->w;
rect.h = SDL_CurrentVideoSurface->h;
SDL_UpdateTexture((struct SDL_Texture *)SDL_CurrentVideoSurface->hwdata, &rect, SDL_CurrentVideoSurface->pixels, SDL_CurrentVideoSurface->pitch);
if(numrects == 0)
SDL_UpdateTexture((struct SDL_Texture *)SDL_CurrentVideoSurface->hwdata, &rect, SDL_CurrentVideoSurface->pixels, SDL_CurrentVideoSurface->pitch);
else
{
int i = 0;
for(i = 0; i < numrects; i++)
SDL_UpdateTexture((struct SDL_Texture *)SDL_CurrentVideoSurface->hwdata, &rects[i], SDL_CurrentVideoSurface->pixels, SDL_CurrentVideoSurface->pitch);
}
SDL_RenderCopy((struct SDL_Texture *)SDL_CurrentVideoSurface->hwdata, &rect, &rect);
static int MousePointerAlpha = 255;
if(SDL_ANDROID_ShowMouseCursor)
Expand Down Expand Up @@ -928,7 +935,7 @@ static int ANDROID_FlipHWSurface(_THIS, SDL_Surface *surface)
return -1;
}

ANDROID_FlipHWSurfaceInternal();
ANDROID_FlipHWSurfaceInternal(0, NULL);

SDL_ANDROID_CallJavaSwapBuffers();

Expand All @@ -949,7 +956,7 @@ static void ANDROID_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
return;
}

ANDROID_FlipHWSurfaceInternal();
ANDROID_FlipHWSurfaceInternal(numrects, rects);

SDL_ANDROID_CallJavaSwapBuffers();
}
Expand Down Expand Up @@ -1052,6 +1059,8 @@ typedef struct
int height;
int bpp;
Uint32 flags;
int numrects;
SDL_Rect *rects;

int retcode;
SDL_Surface * retcode2;
Expand Down Expand Up @@ -1096,11 +1105,11 @@ void SDL_ANDROID_MultiThreadedVideoLoop()
ANDROID_VideoQuit(videoThread._this);
break;
case CMD_UPDATERECTS:
ANDROID_FlipHWSurfaceInternal();
ANDROID_FlipHWSurfaceInternal(videoThread.numrects, videoThread.rects);
swapBuffersNeeded = 1;
break;
case CMD_FLIP:
ANDROID_FlipHWSurfaceInternal();
ANDROID_FlipHWSurfaceInternal(0, NULL);
swapBuffersNeeded = 1;
break;
}
Expand All @@ -1109,7 +1118,7 @@ void SDL_ANDROID_MultiThreadedVideoLoop()
}
else if( SDL_ANDROID_CompatibilityHacks && ret == SDL_MUTEX_TIMEDOUT && SDL_CurrentVideoSurface )
{
ANDROID_FlipHWSurfaceInternal();
ANDROID_FlipHWSurfaceInternal(0, NULL);
swapBuffersNeeded = 1;
}
SDL_mutexV(videoThread.mutex);
Expand Down Expand Up @@ -1185,6 +1194,8 @@ void ANDROID_UpdateRectsMT(_THIS, int numrects, SDL_Rect *rects)
SDL_CondWaitTimeout(videoThread.cond2, videoThread.mutex, 1000);
videoThread.cmd = CMD_UPDATERECTS;
videoThread._this = this;
videoThread.numrects = numrects;
videoThread.rects = rects;
videoThread.execute = 1;
SDL_CondSignal(videoThread.cond);
while( videoThread.execute )
Expand Down

0 comments on commit a7108e2

Please sign in to comment.