summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Lantinga <slouken@libsdl.org>2007-09-10 12:20:02 +0000
committerSam Lantinga <slouken@libsdl.org>2007-09-10 12:20:02 +0000
commit4f2f07efffca1e1f3ec0c6033b88aa0436947ba6 (patch)
tree3657936aff5a489d9ca3743f2a56a596f1236b2f /src
parent1e891ee4f28c8536607336b4e00dbc30d843972d (diff)
Split out the SDL_rect and SDL_surface functions into their own headers.
Removed unused count from the dirty rect list.
Diffstat (limited to 'src')
-rw-r--r--src/video/SDL_pixels.c82
-rw-r--r--src/video/SDL_rect.c2
-rw-r--r--src/video/SDL_rect_c.h1
-rw-r--r--src/video/SDL_renderer_gl.c2
4 files changed, 45 insertions, 42 deletions
diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c
index db4a6486f2..1d15f7bcec 100644
--- a/src/video/SDL_pixels.c
+++ b/src/video/SDL_pixels.c
@@ -536,8 +536,7 @@ SDL_FindColor(SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b)
/* Find the opaque pixel value corresponding to an RGB triple */
Uint32
-SDL_MapRGB(const SDL_PixelFormat * const format, const Uint8 r, const Uint8 g,
- const Uint8 b)
+SDL_MapRGB(const SDL_PixelFormat * format, Uint8 r, Uint8 g, Uint8 b)
{
if (format->palette == NULL) {
return (r >> format->Rloss) << format->Rshift
@@ -550,8 +549,8 @@ SDL_MapRGB(const SDL_PixelFormat * const format, const Uint8 r, const Uint8 g,
/* Find the pixel value corresponding to an RGBA quadruple */
Uint32
-SDL_MapRGBA(const SDL_PixelFormat * const format, const Uint8 r,
- const Uint8 g, const Uint8 b, const Uint8 a)
+SDL_MapRGBA(const SDL_PixelFormat * format, Uint8 r, Uint8 g, Uint8 b,
+ Uint8 a)
{
if (format->palette == NULL) {
return (r >> format->Rloss) << format->Rshift
@@ -564,57 +563,64 @@ SDL_MapRGBA(const SDL_PixelFormat * const format, const Uint8 r,
}
void
-SDL_GetRGBA(Uint32 pixel, SDL_PixelFormat * fmt,
- Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a)
+SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat * format, Uint8 * r, Uint8 * g,
+ Uint8 * b)
{
- if (fmt->palette == NULL) {
+ if (format->palette == NULL) {
/*
* This makes sure that the result is mapped to the
* interval [0..255], and the maximum value for each
* component is 255. This is important to make sure
- * that white is indeed reported as (255, 255, 255),
- * and that opaque alpha is 255.
+ * that white is indeed reported as (255, 255, 255).
* This only works for RGB bit fields at least 4 bit
* wide, which is almost always the case.
*/
unsigned v;
- v = (pixel & fmt->Rmask) >> fmt->Rshift;
- *r = (v << fmt->Rloss) + (v >> (8 - (fmt->Rloss << 1)));
- v = (pixel & fmt->Gmask) >> fmt->Gshift;
- *g = (v << fmt->Gloss) + (v >> (8 - (fmt->Gloss << 1)));
- v = (pixel & fmt->Bmask) >> fmt->Bshift;
- *b = (v << fmt->Bloss) + (v >> (8 - (fmt->Bloss << 1)));
- if (fmt->Amask) {
- v = (pixel & fmt->Amask) >> fmt->Ashift;
- *a = (v << fmt->Aloss) + (v >> (8 - (fmt->Aloss << 1)));
- } else {
- *a = SDL_ALPHA_OPAQUE;
- }
+ v = (pixel & format->Rmask) >> format->Rshift;
+ *r = (v << format->Rloss) + (v >> (8 - (format->Rloss << 1)));
+ v = (pixel & format->Gmask) >> format->Gshift;
+ *g = (v << format->Gloss) + (v >> (8 - (format->Gloss << 1)));
+ v = (pixel & format->Bmask) >> format->Bshift;
+ *b = (v << format->Bloss) + (v >> (8 - (format->Bloss << 1)));
} else {
- *r = fmt->palette->colors[pixel].r;
- *g = fmt->palette->colors[pixel].g;
- *b = fmt->palette->colors[pixel].b;
- *a = SDL_ALPHA_OPAQUE;
+ *r = format->palette->colors[pixel].r;
+ *g = format->palette->colors[pixel].g;
+ *b = format->palette->colors[pixel].b;
}
}
void
-SDL_GetRGB(Uint32 pixel, SDL_PixelFormat * fmt, Uint8 * r, Uint8 * g,
- Uint8 * b)
+SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat * format,
+ Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a)
{
- if (fmt->palette == NULL) {
- /* the note for SDL_GetRGBA above applies here too */
+ if (format->palette == NULL) {
+ /*
+ * This makes sure that the result is mapped to the
+ * interval [0..255], and the maximum value for each
+ * component is 255. This is important to make sure
+ * that white is indeed reported as (255, 255, 255),
+ * and that opaque alpha is 255.
+ * This only works for RGB bit fields at least 4 bit
+ * wide, which is almost always the case.
+ */
unsigned v;
- v = (pixel & fmt->Rmask) >> fmt->Rshift;
- *r = (v << fmt->Rloss) + (v >> (8 - (fmt->Rloss << 1)));
- v = (pixel & fmt->Gmask) >> fmt->Gshift;
- *g = (v << fmt->Gloss) + (v >> (8 - (fmt->Gloss << 1)));
- v = (pixel & fmt->Bmask) >> fmt->Bshift;
- *b = (v << fmt->Bloss) + (v >> (8 - (fmt->Bloss << 1)));
+ v = (pixel & format->Rmask) >> format->Rshift;
+ *r = (v << format->Rloss) + (v >> (8 - (format->Rloss << 1)));
+ v = (pixel & format->Gmask) >> format->Gshift;
+ *g = (v << format->Gloss) + (v >> (8 - (format->Gloss << 1)));
+ v = (pixel & format->Bmask) >> format->Bshift;
+ *b = (v << format->Bloss) + (v >> (8 - (format->Bloss << 1)));
+ if (format->Amask) {
+ v = (pixel & format->Amask) >> format->Ashift;
+ *a = (v << format->Aloss) + (v >> (8 - (format->Aloss << 1)));
+ } else {
+ *a = SDL_ALPHA_OPAQUE;
+ }
} else {
- *r = fmt->palette->colors[pixel].r;
- *g = fmt->palette->colors[pixel].g;
- *b = fmt->palette->colors[pixel].b;
+ *r = format->palette->colors[pixel].r;
+ *g = format->palette->colors[pixel].g;
+ *b = format->palette->colors[pixel].b;
+ *a = SDL_ALPHA_OPAQUE;
}
}
diff --git a/src/video/SDL_rect.c b/src/video/SDL_rect.c
index 9265d60e1f..9d37dc87d4 100644
--- a/src/video/SDL_rect.c
+++ b/src/video/SDL_rect.c
@@ -143,7 +143,6 @@ SDL_AddDirtyRect(SDL_DirtyRectList * list, const SDL_Rect * rect)
dirty->rect = *rect;
dirty->next = list->list;
list->list = dirty;
- ++list->count;
}
void
@@ -164,7 +163,6 @@ SDL_ClearDirtyRects(SDL_DirtyRectList * list)
list->free = list->list;
}
list->list = NULL;
- list->count = 0;
}
void
diff --git a/src/video/SDL_rect_c.h b/src/video/SDL_rect_c.h
index 0f4d3bf069..1bde59c3bc 100644
--- a/src/video/SDL_rect_c.h
+++ b/src/video/SDL_rect_c.h
@@ -29,7 +29,6 @@ typedef struct SDL_DirtyRect
typedef struct SDL_DirtyRectList
{
- int count;
SDL_DirtyRect *list;
SDL_DirtyRect *free;
} SDL_DirtyRectList;
diff --git a/src/video/SDL_renderer_gl.c b/src/video/SDL_renderer_gl.c
index 3390b4242c..eabd5ac9ea 100644
--- a/src/video/SDL_renderer_gl.c
+++ b/src/video/SDL_renderer_gl.c
@@ -806,7 +806,7 @@ GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
int minx, miny, maxx, maxy;
GLfloat minu, maxu, minv, maxv;
- if (texturedata->dirty.count > 0) {
+ if (texturedata->dirty.list) {
SDL_DirtyRect *dirty;
void *pixels;
int bpp = SDL_BYTESPERPIXEL(texture->format);