Skip to content

Commit

Permalink
Fixed offset bug in hardware accelerated fills and blits
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Aug 20, 2002
1 parent 816e467 commit 36bb48e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
21 changes: 21 additions & 0 deletions src/video/SDL_surface.c
Expand Up @@ -399,6 +399,8 @@ int SDL_LowerBlit (SDL_Surface *src, SDL_Rect *srcrect,
SDL_Surface *dst, SDL_Rect *dstrect)
{
SDL_blit do_blit;
SDL_Rect hw_srcrect;
SDL_Rect hw_dstrect;

/* Check to make sure the blit mapping is valid */
if ( (src->map->dst != dst) ||
Expand All @@ -410,6 +412,18 @@ int SDL_LowerBlit (SDL_Surface *src, SDL_Rect *srcrect,

/* Figure out which blitter to use */
if ( (src->flags & SDL_HWACCEL) == SDL_HWACCEL ) {
if ( src == SDL_VideoSurface ) {
hw_srcrect = *dstrect;
hw_srcrect.x += current_video->offset_x;
hw_srcrect.y += current_video->offset_y;
srcrect = &hw_srcrect;
}
if ( dst == SDL_VideoSurface ) {
hw_dstrect = *dstrect;
hw_dstrect.x += current_video->offset_x;
hw_dstrect.y += current_video->offset_y;
dstrect = &hw_dstrect;
}
do_blit = src->map->hw_blit;
} else {
do_blit = src->map->sw_blit;
Expand Down Expand Up @@ -533,6 +547,13 @@ int SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
/* Check for hardware acceleration */
if ( ((dst->flags & SDL_HWSURFACE) == SDL_HWSURFACE) &&
video->info.blit_fill ) {
SDL_Rect hw_rect;
if ( dst == SDL_VideoSurface ) {
hw_rect = *dstrect;
hw_rect.x += current_video->offset_x;
hw_rect.y += current_video->offset_y;
dstrect = &hw_rect;
}
return(video->FillHWRect(this, dst, dstrect, color));
}

Expand Down
4 changes: 0 additions & 4 deletions src/video/dga/SDL_dgavideo.c
Expand Up @@ -793,10 +793,6 @@ static __inline__ void DGA_dst_to_xy(_THIS, SDL_Surface *dst, int *x, int *y)
{
*x = (long)((Uint8 *)dst->pixels - memory_base)%memory_pitch;
*y = (long)((Uint8 *)dst->pixels - memory_base)/memory_pitch;
if ( dst == this->screen ) {
*x += this->offset_x;
*y += this->offset_y;
}
}

static int DGA_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
Expand Down

0 comments on commit 36bb48e

Please sign in to comment.