Commit 03f292e2 authored by Sam Lantinga's avatar Sam Lantinga

Fixed clip_rect when drawing points and lines with software renderer.

Lock the minimal rect to minimize texture uploads

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403366
parent 18b9f5b2
......@@ -543,36 +543,41 @@ static int
SW_RenderPoint(SDL_Renderer * renderer, int x, int y)
{
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
SDL_Rect rect;
int status;
if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
SDL_Rect rect;
rect.x = x;
rect.y = y;
rect.w = 1;
rect.h = 1;
rect.x = x;
rect.y = y;
rect.w = 1;
rect.h = 1;
if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
SDL_AddDirtyRect(&data->dirty, &rect);
}
if (data->renderer->LockTexture(data->renderer,
data->texture[data->current_texture],
&data->surface.clip_rect, 1,
&rect, 1,
&data->surface.pixels,
&data->surface.pitch) < 0) {
return -1;
}
data->surface.w = 1;
data->surface.h = 1;
data->surface.clip_rect.w = 1;
data->surface.clip_rect.h = 1;
if (renderer->blendMode == SDL_BLENDMODE_NONE ||
renderer->blendMode == SDL_BLENDMODE_MASK) {
Uint32 color =
SDL_MapRGBA(data->surface.format, renderer->r, renderer->g,
renderer->b, renderer->a);
status = SDL_DrawPoint(&data->surface, x, y, color);
status = SDL_DrawPoint(&data->surface, 0, 0, color);
} else {
status =
SDL_BlendPoint(&data->surface, x, y, renderer->blendMode,
SDL_BlendPoint(&data->surface, 0, 0, renderer->blendMode,
renderer->r, renderer->g, renderer->b,
renderer->a);
}
......@@ -586,36 +591,49 @@ static int
SW_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
{
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
SDL_Rect rect;
int status;
if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
SDL_Rect rect;
if (x1 < x2) {
rect.x = x1;
rect.w = (x2 - x1) + 1;
x2 -= x1;
x1 = 0;
} else {
rect.x = x2;
rect.w = (x1 - x2) + 1;
x1 -= x2;
x2 = 0;
}
if (y1 < y2) {
rect.y = y1;
rect.h = (y2 - y1) + 1;
y2 -= y1;
y1 = 0;
} else {
rect.y = y2;
rect.h = (y1 - y2) + 1;
y1 -= y2;
y2 = 0;
}
if (x1 < x2) {
rect.x = x1;
rect.w = (x2 - x1) + 1;
} else {
rect.x = x2;
rect.w = (x1 - x2) + 1;
}
if (y1 < y2) {
rect.y = y1;
rect.h = (y2 - y1) + 1;
} else {
rect.y = y2;
rect.h = (y1 - y2) + 1;
}
if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
SDL_AddDirtyRect(&data->dirty, &rect);
}
if (data->renderer->LockTexture(data->renderer,
data->texture[data->current_texture],
&data->surface.clip_rect, 1,
&rect, 1,
&data->surface.pixels,
&data->surface.pitch) < 0) {
return -1;
}
data->surface.w = rect.w;
data->surface.h = rect.h;
data->surface.clip_rect.w = rect.w;
data->surface.clip_rect.h = rect.h;
if (renderer->blendMode == SDL_BLENDMODE_NONE ||
renderer->blendMode == SDL_BLENDMODE_MASK) {
Uint32 color =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment