Author: titmuss
Date: Fri Nov 14 03:21:45 2008
New Revision: 3371
URL: http://svn.slimdevices.com?rev=3371&root=Jive&view=rev
Log:
Bug: N/A
Description:
Refactoring to make the jive_surface structure private.
Modified:
7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive.h
7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_font.c
7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_framework.c
7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_surface.c
7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_tile.c
Modified: 7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive.h
URL:
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive.h?rev=3371&root=Jive&r1=3370&r2=3371&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive.h (original)
+++ 7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive.h Fri Nov 14 03:21:45 2008
@@ -183,13 +183,6 @@
Uint8 layer;
};
-struct jive_surface {
- Uint32 refcount;
-
- SDL_Surface *sdl;
- Sint16 offset_x, offset_y;
-};
-
struct jive_scroll_event {
int rel;
};
@@ -294,9 +287,11 @@
JiveSurface *jive_surface_set_video_mode(Uint16 w, Uint16 h, Uint16 bpp, bool
fullscreen);
JiveSurface *jive_surface_newRGB(Uint16 w, Uint16 h);
JiveSurface *jive_surface_newRGBA(Uint16 w, Uint16 h);
+JiveSurface *jive_surface_new_SDLSurface(SDL_Surface *sdl_surface);
JiveSurface *jive_surface_ref(JiveSurface *srf);
JiveSurface *jive_surface_load_image(const char *path);
JiveSurface *jive_surface_load_image_data(const char *data, size_t len);
+int jive_surface_set_wm_icon(JiveSurface *srf);
int jive_surface_save_bmp(JiveSurface *srf, const char *file);
int jive_surface_cmp(JiveSurface *a, JiveSurface *b, Uint32 key);
void jive_surface_set_offset(JiveSurface *src, Sint16 x, Sint16 y);
Modified: 7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_font.c
URL:
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_font.c?rev=3371&root=Jive&r1=3370&r2=3371&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_font.c (original)
+++ 7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_font.c Fri Nov 14
03:21:45 2008
@@ -250,17 +250,9 @@
}
JiveSurface *jive_font_draw_text(JiveFont *font, Uint32 color, const char
*str) {
- JiveSurface *srf;
-
- assert(font && font->magic == JIVE_FONT_MAGIC);
-
- srf = calloc(sizeof(JiveSurface), 1);
- srf->refcount = 1;
- if (str) {
- srf->sdl = font->draw(font, color, str);
- }
-
- return srf;
+ assert(font && font->magic == JIVE_FONT_MAGIC);
+
+ return jive_surface_new_SDLSurface(str ? font->draw(font, color, str) :
NULL);
}
JiveSurface *jive_font_ndraw_text(JiveFont *font, Uint32 color, const char
*str, size_t len) {
Modified: 7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_framework.c
URL:
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_framework.c?rev=3371&root=Jive&r1=3370&r2=3371&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_framework.c (original)
+++ 7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_framework.c Fri Nov 14
03:21:45 2008
@@ -162,12 +162,10 @@
exit(-1);
}
- /* load the icon */
- icon = jive_surface_load_image("jive/app.png");
- if (icon->sdl)
- SDL_WM_SetIcon(icon->sdl, NULL);
- else
- fprintf(stderr, "SDL_WM_SetIcon(jive/jiveapp.png): %s\n",
SDL_GetError());
+ /* load the icon */
+ icon = jive_surface_load_image("jive/app.png");
+ jive_surface_set_wm_icon(icon);
+ jive_surface_free(icon);
// SDL_ShowCursor (SDL_DISABLE);
SDL_EnableKeyRepeat (100, 100);
Modified: 7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_surface.c
URL:
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_surface.c?rev=3371&root=Jive&r1=3370&r2=3371&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_surface.c (original)
+++ 7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_surface.c Fri Nov 14
03:21:45 2008
@@ -7,6 +7,14 @@
#include "common.h"
#include "jive.h"
+
+
+struct jive_surface {
+ Uint32 refcount;
+
+ SDL_Surface *sdl;
+ Sint16 offset_x, offset_y;
+};
JiveSurface *jive_surface_set_video_mode(Uint16 w, Uint16 h, Uint16 bpp, bool
fullscreen) {
@@ -89,6 +97,17 @@
}
+JiveSurface *jive_surface_new_SDLSurface(SDL_Surface *sdl_surface) {
+ JiveSurface *srf;
+
+ srf = calloc(sizeof(JiveSurface), 1);
+ srf->refcount = 1;
+ srf->sdl = sdl_surface;
+
+ return srf;
+}
+
+
JiveSurface *jive_surface_ref(JiveSurface *srf) {
if (srf) {
srf->refcount++;
@@ -161,6 +180,13 @@
return jive_surface_display_format(srf);
}
+
+
+int jive_surface_set_wm_icon(JiveSurface *srf) {
+ SDL_WM_SetIcon(srf->sdl, NULL);
+ return 1;
+}
+
int jive_surface_save_bmp(JiveSurface *srf, const char *file) {
return SDL_SaveBMP(srf->sdl, file);
@@ -307,6 +333,14 @@
}
+/* this function must only be used for blitting tiles */
+void jive_surface_get_tile_blit(JiveSurface *srf, SDL_Surface **sdl, Sint16
*x, Sint16 *y) {
+ *sdl = srf->sdl;
+ *x = srf->offset_x;
+ *y = srf->offset_y;
+}
+
+
void jive_surface_blit(JiveSurface *src, JiveSurface *dst, Uint16 dx, Uint16
dy) {
#ifdef JIVE_PROFILE_BLIT
Uint32 t0 = SDL_GetTicks(), t1;
Modified: 7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_tile.c
URL:
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_tile.c?rev=3371&root=Jive&r1=3370&r2=3371&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_tile.c (original)
+++ 7.3/trunk/squeezeplay/src/squeezeplay/src/ui/jive_tile.c Fri Nov 14
03:21:45 2008
@@ -7,6 +7,9 @@
#include "common.h"
#include "jive.h"
+
+
+void jive_surface_get_tile_blit(JiveSurface *srf, SDL_Surface **sdl, Sint16
*x, Sint16 *y);
struct jive_tile {
@@ -264,70 +267,74 @@
static void _blit_tile(JiveTile *tile, JiveSurface *dst, Uint16 dx, Uint16 dy,
Uint16 dw, Uint16 dh) {
int ox=0, oy=0, ow=0, oh=0;
+ Sint16 dst_offset_x, dst_offset_y;
+ SDL_Surface *dst_srf;
if (tile->is_bg) {
jive_surface_boxColor(dst, dx, dy, dx + dw - 1, dy + dh - 1,
tile->bg);
return;
}
- dx += dst->offset_x;
- dy += dst->offset_y;
+ jive_surface_get_tile_blit(dst, &dst_srf, &dst_offset_x, &dst_offset_y);
+
+ dx += dst_offset_x;
+ dy += dst_offset_y;
/* top left */
if (tile->srf[1]) {
ox = MIN(tile->w[0], dw);
oy = MIN(tile->h[0], dh);
- blit_area(tile->srf[1], dst->sdl, dx, dy, ox, oy);
+ blit_area(tile->srf[1], dst_srf, dx, dy, ox, oy);
}
/* top right */
if (tile->srf[3]) {
ow = MIN(tile->w[1], dw);
oy = MIN(tile->h[0], dh);
- blit_area(tile->srf[3], dst->sdl, dx + dw - ow, dy, ow, oy);
+ blit_area(tile->srf[3], dst_srf, dx + dw - ow, dy, ow, oy);
}
/* bottom right */
if (tile->srf[5]) {
ow = MIN(tile->w[1], dw);
oh = MIN(tile->h[1], dh);
- blit_area(tile->srf[5], dst->sdl, dx + dw - ow, dy + dh - oh,
ow, oh);
+ blit_area(tile->srf[5], dst_srf, dx + dw - ow, dy + dh - oh,
ow, oh);
}
/* bottom left */
if (tile->srf[7]) {
ox = MIN(tile->w[0], dw);
oh = MIN(tile->h[1], dh);
- blit_area(tile->srf[7], dst->sdl, dx, dy + dh - oh, ox, oh);
+ blit_area(tile->srf[7], dst_srf, dx, dy + dh - oh, ox, oh);
}
/* top */
if (tile->srf[2]) {
oy = MIN(tile->h[0], dh);
- blit_area(tile->srf[2], dst->sdl, dx + ox, dy, dw - ox - ow,
oy);
+ blit_area(tile->srf[2], dst_srf, dx + ox, dy, dw - ox - ow, oy);
}
/* right */
if (tile->srf[4]) {
ow = MIN(tile->w[1], dw);
- blit_area(tile->srf[4], dst->sdl, dx + dw - ow, dy + oy, ow, dh
- oy - oh);
+ blit_area(tile->srf[4], dst_srf, dx + dw - ow, dy + oy, ow, dh
- oy - oh);
}
/* bottom */
if (tile->srf[6]) {
oh = MIN(tile->h[1], dh);
- blit_area(tile->srf[6], dst->sdl, dx + ox, dy + dh - oh, dw -
ox - ow, oh);
+ blit_area(tile->srf[6], dst_srf, dx + ox, dy + dh - oh, dw - ox
- ow, oh);
}
/* left */
if (tile->srf[8]) {
ox = MIN(tile->w[0], dw);
- blit_area(tile->srf[8], dst->sdl, dx, dy + oy, ox, dh - oy -
oh);
+ blit_area(tile->srf[8], dst_srf, dx, dy + oy, ox, dh - oy - oh);
}
/* center */
if (tile->srf[0]) {
- blit_area(tile->srf[0], dst->sdl, dx + ox, dy + oy, dw - ox -
ow, dh - oy - oh);
+ blit_area(tile->srf[0], dst_srf, dx + ox, dy + oy, dw - ox -
ow, dh - oy - oh);
}
}
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins