2007-10-12 Tomas Frydrych <tf@o-hand.com>

Portability fixes:

	* clutter/clutter-private.h:
	Bracket #include "unistd.h" with #ifdef HAVE_UNISTD_H

	* clutter/clutter-fixed.c:
	Use "", not <> for inclusion of local files.

	(clutter_sqrtx): forward declare local variables.

	* clutter/clutter-debug.h:
	Added non-gcc (c99) implementation of variadic debug macros for
	when not compiling with gcc.

	* clutter/pango/pangoclutter-render.c:
	Fixed some strange uses of CLUTTER_NOTE() + stripped trailing
	whitespace.
This commit is contained in:
Tomas Frydrych 2007-10-12 09:39:41 +00:00
parent abd6832dd9
commit 174bd04b49
5 changed files with 116 additions and 65 deletions

View File

@ -1,3 +1,23 @@
2007-10-12 Tomas Frydrych <tf@o-hand.com>
Portability fixes:
* clutter/clutter-private.h:
Bracket #include "unistd.h" with #ifdef HAVE_UNISTD_H
* clutter/clutter-fixed.c:
Use "", not <> for inclusion of local files.
(clutter_sqrtx): forward declare local variables.
* clutter/clutter-debug.h:
Added non-gcc (c99) implementation of variadic debug macros for
when not compiling with gcc.
* clutter/pango/pangoclutter-render.c:
Fixed some strange uses of CLUTTER_NOTE() + stripped trailing
whitespace.
2007-10-12 Tomas Frydrych <tf@o-hand.com> 2007-10-12 Tomas Frydrych <tf@o-hand.com>
* clutter/clutter-actor.c: * clutter/clutter-actor.c:
@ -42,7 +62,7 @@
Fixedup config.h inclusion (must always be bracketed with #ifdef Fixedup config.h inclusion (must always be bracketed with #ifdef
HAVE_CONFIG_H). HAVE_CONFIG_H).
2007-10-11 Tomas Frydrych <tf@o-hand.com> 2007-10-11 Tomas Frydrych <tf@o-hand.com>
* clutter/clutter-entry.c: * clutter/clutter-entry.c:

View File

@ -23,11 +23,42 @@ typedef enum {
#ifdef CLUTTER_ENABLE_DEBUG #ifdef CLUTTER_ENABLE_DEBUG
#ifdef __GNUC_
#define CLUTTER_NOTE(type,x,a...) G_STMT_START { \ #define CLUTTER_NOTE(type,x,a...) G_STMT_START { \
if (clutter_debug_flags & CLUTTER_DEBUG_##type) \ if (clutter_debug_flags & CLUTTER_DEBUG_##type) \
{ g_message ("[" #type "] " G_STRLOC ": " x, ##a); } \ { g_message ("[" #type "] " G_STRLOC ": " x, ##a); } \
} G_STMT_END } G_STMT_END
#define CLUTTER_TIMESTAMP(type,x,a...) G_STMT_START { \
if (clutter_debug_flags & CLUTTER_DEBUG_##type) \
{ g_message ("[" #type "]" " %li:" G_STRLOC ": " \
x, clutter_get_timestamp(), ##a); } \
} G_STMT_END
#else
/* Try the C99 version; unfortunately, this does not allow us to pass
* empty arguments to the macro, which means we have to
* do an intemediate printf.
*/
#define CLUTTER_NOTE(type,...) G_STMT_START { \
if (clutter_debug_flags & CLUTTER_DEBUG_##type) \
{ \
gchar * _fmt = g_strdup_printf (__VA_ARGS__); \
g_message ("[" #type "] " G_STRLOC ": %s",_fmt); \
g_free (_fmt); \
} \
} G_STMT_END
#define CLUTTER_TIMESTAMP(type,...) G_STMT_START { \
if (clutter_debug_flags & CLUTTER_DEBUG_##type) \
{ \
gchar * _fmt = g_strdup_printf (__VA_ARGS__); \
g_message ("[" #type "]" " %li:" G_STRLOC ": %s", \
clutter_get_timestamp(), _fmt); \
g_free (_fmt); \
} \
} G_STMT_END
#endif
#define CLUTTER_MARK() CLUTTER_NOTE(MISC, "== mark ==") #define CLUTTER_MARK() CLUTTER_NOTE(MISC, "== mark ==")
#define CLUTTER_DBG(x) { a } #define CLUTTER_DBG(x) { a }
@ -38,19 +69,14 @@ typedef enum {
g_warning (G_STRLOC ": GL Error %x", _err); \ g_warning (G_STRLOC ": GL Error %x", _err); \
} } G_STMT_END } } G_STMT_END
#define CLUTTER_TIMESTAMP(type,x,a...) G_STMT_START { \
if (clutter_debug_flags & CLUTTER_DEBUG_##type) \
{ g_message ("[" #type "]" " %li:" G_STRLOC ": " \
x, clutter_get_timestamp(), ##a); } \
} G_STMT_END
#else /* !CLUTTER_ENABLE_DEBUG */ #else /* !CLUTTER_ENABLE_DEBUG */
#define CLUTTER_NOTE(type,x,a...) #define CLUTTER_NOTE(type,...)
#define CLUTTER_MARK() #define CLUTTER_MARK()
#define CLUTTER_DBG(x) #define CLUTTER_DBG(x)
#define CLUTTER_GLERR() #define CLUTTER_GLERR()
#define CLUTTER_TIMESTAMP(type,x,a...) #define CLUTTER_TIMESTAMP(type,...)
#endif /* CLUTTER_ENABLE_DEBUG */ #endif /* CLUTTER_ENABLE_DEBUG */

View File

@ -27,8 +27,8 @@
#include "config.h" #include "config.h"
#endif #endif
#include <clutter-fixed.h> #include "clutter-fixed.h"
#include <clutter-private.h> #include "clutter-private.h"
/** /**
* SECTION:clutter-fixed * SECTION:clutter-fixed
@ -517,6 +517,7 @@ clutter_sqrtx (ClutterFixed x)
unsigned int mask = 0x40000000; unsigned int mask = 0x40000000;
unsigned fract = x & 0x0000ffff; unsigned fract = x & 0x0000ffff;
unsigned int d1, d2; unsigned int d1, d2;
ClutterFixed v1, v2;
if (x <= 0) if (x <= 0)
return 0; return 0;
@ -579,8 +580,8 @@ clutter_sqrtx (ClutterFixed x)
} }
/* Do a weighted average of the two nearest values */ /* Do a weighted average of the two nearest values */
ClutterFixed v1 = sqrt_tbl[t]; v1 = sqrt_tbl[t];
ClutterFixed v2 = sqrt_tbl[t+1]; v2 = sqrt_tbl[t+1];
/* /*
* 12 is fairly arbitrary -- we want integer that is not too big to cost * 12 is fairly arbitrary -- we want integer that is not too big to cost

View File

@ -29,7 +29,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif
#include <math.h> #include <math.h>
#include <glib.h> #include <glib.h>

View File

@ -34,7 +34,7 @@
#include "cogl.h" #include "cogl.h"
/* /*
* Texture cache support code * Texture cache support code
*/ */
@ -106,8 +106,8 @@ tc_get (tc_area *area, int width, int height)
/* create a new texture if necessary */ /* create a new texture if necessary */
if (!match) if (!match)
{ {
CLUTTER_NOTE (PANGO, g_message ("creating new texture %i x %i\n", CLUTTER_NOTE (PANGO, "creating new texture %i x %i",
TC_WIDTH, TC_HEIGHT)); TC_WIDTH, TC_HEIGHT);
match = g_slice_new (tc_texture); match = g_slice_new (tc_texture);
match->next = first_texture; match->next = first_texture;
@ -124,12 +124,12 @@ tc_get (tc_area *area, int width, int height)
*/ */
cogl_texture_set_filters (CGL_TEXTURE_2D, CGL_LINEAR, CGL_NEAREST); cogl_texture_set_filters (CGL_TEXTURE_2D, CGL_LINEAR, CGL_NEAREST);
cogl_texture_image_2d (CGL_TEXTURE_2D, cogl_texture_image_2d (CGL_TEXTURE_2D,
CGL_ALPHA, CGL_ALPHA,
TC_WIDTH, TC_WIDTH,
TC_HEIGHT, TC_HEIGHT,
CGL_ALPHA, CGL_ALPHA,
CGL_UNSIGNED_BYTE, CGL_UNSIGNED_BYTE,
NULL); NULL);
} }
@ -236,11 +236,11 @@ render_box (Glyph *glyph, int width, int height, int top)
memset (glyph->bitmap, 0, glyph->stride * height); memset (glyph->bitmap, 0, glyph->stride * height);
for (i = width; i--; ) for (i = width; i--; )
glyph->bitmap [i] glyph->bitmap [i]
= glyph->bitmap [i + (height - 1) * glyph->stride] = 0xff; = glyph->bitmap [i + (height - 1) * glyph->stride] = 0xff;
for (i = height; i--; ) for (i = height; i--; )
glyph->bitmap [i * glyph->stride] glyph->bitmap [i * glyph->stride]
= glyph->bitmap [i * glyph->stride + (width - 1)] = 0xff; = glyph->bitmap [i * glyph->stride + (width - 1)] = 0xff;
} }
@ -270,7 +270,7 @@ font_render_glyph (Glyph *glyph, PangoFont *font, int glyph_index)
} }
face = pango_clutter_font_get_face (font); face = pango_clutter_font_get_face (font);
if (face) if (face)
{ {
PangoClutterFont *glfont = (PangoClutterFont *)font; PangoClutterFont *glfont = (PangoClutterFont *)font;
@ -287,16 +287,16 @@ font_render_glyph (Glyph *glyph, PangoFont *font, int glyph_index)
} }
else else
generic_box: generic_box:
render_box (glyph, PANGO_UNKNOWN_GLYPH_WIDTH, render_box (glyph, PANGO_UNKNOWN_GLYPH_WIDTH,
PANGO_UNKNOWN_GLYPH_HEIGHT, PANGO_UNKNOWN_GLYPH_HEIGHT); PANGO_UNKNOWN_GLYPH_HEIGHT, PANGO_UNKNOWN_GLYPH_HEIGHT);
} }
typedef struct glyph_info typedef struct glyph_info
{ {
tc_area tex; tc_area tex;
int left, top; int left, top;
int generation; int generation;
} }
glyph_info; glyph_info;
static void static void
@ -307,10 +307,10 @@ free_glyph_info (glyph_info *g)
} }
static void static void
draw_glyph (PangoRenderer *renderer_, draw_glyph (PangoRenderer *renderer_,
PangoFont *font, PangoFont *font,
PangoGlyph glyph, PangoGlyph glyph,
double x, double x,
double y) double y)
{ {
PangoClutterRenderer *renderer = PANGO_CLUTTER_RENDERER (renderer_); PangoClutterRenderer *renderer = PANGO_CLUTTER_RENDERER (renderer_);
@ -320,7 +320,7 @@ draw_glyph (PangoRenderer *renderer_,
if (glyph & PANGO_GLYPH_UNKNOWN_FLAG) if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
{ {
glyph = pango_clutter_get_unknown_glyph (font); glyph = pango_clutter_get_unknown_glyph (font);
if (glyph == PANGO_GLYPH_EMPTY) if (glyph == PANGO_GLYPH_EMPTY)
glyph = PANGO_GLYPH_UNKNOWN_FLAG; glyph = PANGO_GLYPH_UNKNOWN_FLAG;
} }
@ -338,7 +338,7 @@ draw_glyph (PangoRenderer *renderer_,
{ {
g = g_slice_new (glyph_info); g = g_slice_new (glyph_info);
_pango_clutter_font_set_glyph_cache_destroy _pango_clutter_font_set_glyph_cache_destroy
(font, (GDestroyNotify)free_glyph_info); (font, (GDestroyNotify)free_glyph_info);
_pango_clutter_font_set_cache_glyph_data (font, glyph, g); _pango_clutter_font_set_cache_glyph_data (font, glyph, g);
} }
@ -348,27 +348,27 @@ draw_glyph (PangoRenderer *renderer_,
g->left = bm.left; g->left = bm.left;
g->top = bm.top; g->top = bm.top;
CLUTTER_NOTE (PANGO, g_message ("cache fail; subimage2d %i\n", glyph)); CLUTTER_NOTE (PANGO, "cache fail; subimage2d %i", glyph);
cogl_texture_bind (CGL_TEXTURE_2D, g->tex.name); cogl_texture_bind (CGL_TEXTURE_2D, g->tex.name);
cogl_texture_set_alignment (CGL_TEXTURE_2D, 1, bm.stride); cogl_texture_set_alignment (CGL_TEXTURE_2D, 1, bm.stride);
cogl_texture_sub_image_2d (CGL_TEXTURE_2D, cogl_texture_sub_image_2d (CGL_TEXTURE_2D,
g->tex.x, g->tex.x,
g->tex.y, g->tex.y,
bm.width, bm.width,
bm.height, bm.height,
CGL_ALPHA, CGL_ALPHA,
CGL_UNSIGNED_BYTE, CGL_UNSIGNED_BYTE,
bm.bitmap); bm.bitmap);
glTexParameteri (CGL_TEXTURE_2D, GL_GENERATE_MIPMAP, FALSE); glTexParameteri (CGL_TEXTURE_2D, GL_GENERATE_MIPMAP, FALSE);
renderer->curtex = g->tex.name; renderer->curtex = g->tex.name;
} }
else CLUTTER_NOTE (PANGO, g_message ("cache succsess %i\n", glyph)); else CLUTTER_NOTE (PANGO, "cache succsess %i\n", glyph);
x += g->left; x += g->left;
y -= g->top; y -= g->top;
@ -384,13 +384,13 @@ draw_glyph (PangoRenderer *renderer_,
renderer->curtex = g->tex.name; renderer->curtex = g->tex.name;
} }
cogl_texture_quad (x, cogl_texture_quad (x,
x + g->tex.w, x + g->tex.w,
y, y,
y + g->tex.h, y + g->tex.h,
CLUTTER_FLOAT_TO_FIXED (box.x1), CLUTTER_FLOAT_TO_FIXED (box.x1),
CLUTTER_FLOAT_TO_FIXED (box.y1), CLUTTER_FLOAT_TO_FIXED (box.y1),
CLUTTER_FLOAT_TO_FIXED (box.x2), CLUTTER_FLOAT_TO_FIXED (box.x2),
CLUTTER_FLOAT_TO_FIXED (box.y2)); CLUTTER_FLOAT_TO_FIXED (box.y2));
} }
@ -426,9 +426,9 @@ draw_trapezoid (PangoRenderer *renderer_,
cogl_enable (CGL_ENABLE_TEXTURE_2D|CGL_ENABLE_BLEND); cogl_enable (CGL_ENABLE_TEXTURE_2D|CGL_ENABLE_BLEND);
} }
void void
pango_clutter_render_layout_subpixel (PangoLayout *layout, pango_clutter_render_layout_subpixel (PangoLayout *layout,
int x, int x,
int y, int y,
ClutterColor *color, ClutterColor *color,
int flags) int flags)
@ -439,30 +439,30 @@ pango_clutter_render_layout_subpixel (PangoLayout *layout,
context = pango_layout_get_context (layout); context = pango_layout_get_context (layout);
fontmap = pango_context_get_font_map (context); fontmap = pango_context_get_font_map (context);
renderer = _pango_clutter_font_map_get_renderer renderer = _pango_clutter_font_map_get_renderer
(PANGO_CLUTTER_FONT_MAP (fontmap)); (PANGO_CLUTTER_FONT_MAP (fontmap));
memcpy (&(PANGO_CLUTTER_RENDERER (renderer)->color), memcpy (&(PANGO_CLUTTER_RENDERER (renderer)->color),
color, sizeof(ClutterColor)); color, sizeof(ClutterColor));
pango_renderer_draw_layout (renderer, layout, x, y); pango_renderer_draw_layout (renderer, layout, x, y);
} }
void void
pango_clutter_render_layout (PangoLayout *layout, pango_clutter_render_layout (PangoLayout *layout,
int x, int x,
int y, int y,
ClutterColor *color, ClutterColor *color,
int flags) int flags)
{ {
pango_clutter_render_layout_subpixel (layout, pango_clutter_render_layout_subpixel (layout,
x * PANGO_SCALE, x * PANGO_SCALE,
y * PANGO_SCALE, y * PANGO_SCALE,
color, color,
flags); flags);
} }
void void
pango_clutter_render_layout_line (PangoLayoutLine *line, pango_clutter_render_layout_line (PangoLayoutLine *line,
int x, int x,
int y, int y,
@ -474,16 +474,16 @@ pango_clutter_render_layout_line (PangoLayoutLine *line,
context = pango_layout_get_context (line->layout); context = pango_layout_get_context (line->layout);
fontmap = pango_context_get_font_map (context); fontmap = pango_context_get_font_map (context);
renderer = _pango_clutter_font_map_get_renderer renderer = _pango_clutter_font_map_get_renderer
(PANGO_CLUTTER_FONT_MAP (fontmap)); (PANGO_CLUTTER_FONT_MAP (fontmap));
memcpy (&(PANGO_CLUTTER_RENDERER (renderer)->color), memcpy (&(PANGO_CLUTTER_RENDERER (renderer)->color),
color, sizeof(ClutterColor)); color, sizeof(ClutterColor));
pango_renderer_draw_layout_line (renderer, line, x, y); pango_renderer_draw_layout_line (renderer, line, x, y);
} }
void void
pango_clutter_render_clear_caches (void) pango_clutter_render_clear_caches (void)
{ {
tc_clear(); tc_clear();
@ -509,17 +509,17 @@ prepare_run (PangoRenderer *renderer, PangoLayoutRun *run)
for (l = run->item->analysis.extra_attrs; l; l = l->next) for (l = run->item->analysis.extra_attrs; l; l = l->next)
{ {
PangoAttribute *attr = l->data; PangoAttribute *attr = l->data;
switch (attr->klass->type) switch (attr->klass->type)
{ {
case PANGO_ATTR_UNDERLINE: case PANGO_ATTR_UNDERLINE:
renderer->underline = ((PangoAttrInt *)attr)->value; renderer->underline = ((PangoAttrInt *)attr)->value;
break; break;
case PANGO_ATTR_STRIKETHROUGH: case PANGO_ATTR_STRIKETHROUGH:
renderer->strikethrough = ((PangoAttrInt *)attr)->value; renderer->strikethrough = ((PangoAttrInt *)attr)->value;
break; break;
case PANGO_ATTR_FOREGROUND: case PANGO_ATTR_FOREGROUND:
fg = &((PangoAttrColor *)attr)->color; fg = &((PangoAttrColor *)attr)->color;
break; break;
@ -534,7 +534,7 @@ prepare_run (PangoRenderer *renderer, PangoLayoutRun *run)
col.green = (fg->green * 255) / 65535; col.green = (fg->green * 255) / 65535;
col.blue = (fg->blue * 255) / 65535; col.blue = (fg->blue * 255) / 65535;
} }
else else
{ {
col.red = glrenderer->color.red; col.red = glrenderer->color.red;
col.green = glrenderer->color.green; col.green = glrenderer->color.green;
@ -548,8 +548,8 @@ prepare_run (PangoRenderer *renderer, PangoLayoutRun *run)
col.red ^= 0xffU; col.red ^= 0xffU;
col.green ^= 0xffU; col.green ^= 0xffU;
col.blue ^= 0xffU; col.blue ^= 0xffU;
} }
cogl_color(&col); cogl_color(&col);
} }