mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 18:11:05 -05:00
Fix ISO C90 compiler warnings in Cogl
Mixing declarations and statements and unused variables.
This commit is contained in:
parent
5c398c18ad
commit
6655bedba7
@ -882,7 +882,7 @@ get_wire_lines (CoglAttribute *attribute,
|
|||||||
CoglIndicesType indices_type;
|
CoglIndicesType indices_type;
|
||||||
int i;
|
int i;
|
||||||
int n_lines;
|
int n_lines;
|
||||||
CoglVertexP3 *out;
|
CoglVertexP3 *out = NULL;
|
||||||
|
|
||||||
vertices = cogl_buffer_map (COGL_BUFFER (vertex_array),
|
vertices = cogl_buffer_map (COGL_BUFFER (vertex_array),
|
||||||
COGL_BUFFER_ACCESS_READ, 0);
|
COGL_BUFFER_ACCESS_READ, 0);
|
||||||
@ -894,7 +894,11 @@ get_wire_lines (CoglAttribute *attribute,
|
|||||||
indices_type = cogl_indices_get_type (_indices);
|
indices_type = cogl_indices_get_type (_indices);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
index_array = NULL;
|
||||||
indices = NULL;
|
indices = NULL;
|
||||||
|
indices_type = COGL_INDICES_TYPE_UNSIGNED_BYTE;
|
||||||
|
}
|
||||||
|
|
||||||
*n_vertices_out = 0;
|
*n_vertices_out = 0;
|
||||||
|
|
||||||
@ -977,10 +981,12 @@ get_wire_lines (CoglAttribute *attribute,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (vertices)
|
if (vertices != NULL)
|
||||||
cogl_buffer_unmap (COGL_BUFFER (vertex_array));
|
cogl_buffer_unmap (COGL_BUFFER (vertex_array));
|
||||||
if (indices)
|
|
||||||
|
if (indices != NULL)
|
||||||
cogl_buffer_unmap (COGL_BUFFER (index_array));
|
cogl_buffer_unmap (COGL_BUFFER (index_array));
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,63 +95,86 @@ CoglBitmap *
|
|||||||
_cogl_bitmap_from_file (const char *filename,
|
_cogl_bitmap_from_file (const char *filename,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
CFURLRef url;
|
||||||
|
CGImageSourceRef image_source;
|
||||||
|
CGImageRef image;
|
||||||
|
int save_errno;
|
||||||
|
CFStringRef type;
|
||||||
|
gsize width, height, rowstride;
|
||||||
|
guint8 *out_data;
|
||||||
|
CGColorSpaceRef color_space;
|
||||||
|
CGContextRef bitmap_context;
|
||||||
|
|
||||||
g_assert (filename != NULL);
|
g_assert (filename != NULL);
|
||||||
g_assert (error == NULL || *error == NULL);
|
g_assert (error == NULL || *error == NULL);
|
||||||
|
|
||||||
CFURLRef url = CFURLCreateFromFileSystemRepresentation (NULL, (guchar*)filename, strlen(filename), false);
|
url = CFURLCreateFromFileSystemRepresentation (NULL,
|
||||||
CGImageSourceRef image_source = CGImageSourceCreateWithURL (url, NULL);
|
(guchar *) filename,
|
||||||
int save_errno = errno;
|
strlen (filename),
|
||||||
|
false);
|
||||||
|
image_source = CGImageSourceCreateWithURL (url, NULL);
|
||||||
|
save_errno = errno;
|
||||||
CFRelease (url);
|
CFRelease (url);
|
||||||
|
|
||||||
if (image_source == NULL)
|
if (image_source == NULL)
|
||||||
{
|
{
|
||||||
/* doesn't exist, not readable, etc. */
|
/* doesn't exist, not readable, etc. */
|
||||||
g_set_error (error, COGL_BITMAP_ERROR, COGL_BITMAP_ERROR_FAILED,
|
g_set_error_literal (error,
|
||||||
"%s", g_strerror (save_errno));
|
COGL_BITMAP_ERROR,
|
||||||
|
COGL_BITMAP_ERROR_FAILED,
|
||||||
|
g_strerror (save_errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unknown images would be cleanly caught as zero width/height below, but try
|
/* Unknown images would be cleanly caught as zero width/height below, but try
|
||||||
* to provide better error message
|
* to provide better error message
|
||||||
*/
|
*/
|
||||||
CFStringRef type = CGImageSourceGetType (image_source);
|
type = CGImageSourceGetType (image_source);
|
||||||
if (type == NULL)
|
if (type == NULL)
|
||||||
{
|
{
|
||||||
CFRelease (image_source);
|
CFRelease (image_source);
|
||||||
g_set_error (error, COGL_BITMAP_ERROR, COGL_BITMAP_ERROR_UNKNOWN_TYPE,
|
g_set_error_literal (error,
|
||||||
|
COGL_BITMAP_ERROR,
|
||||||
|
COGL_BITMAP_ERROR_UNKNOWN_TYPE,
|
||||||
"Unknown image type");
|
"Unknown image type");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CFRelease (type);
|
CFRelease (type);
|
||||||
|
|
||||||
CGImageRef image = CGImageSourceCreateImageAtIndex (image_source, 0, NULL);
|
image = CGImageSourceCreateImageAtIndex (image_source, 0, NULL);
|
||||||
CFRelease (image_source);
|
CFRelease (image_source);
|
||||||
|
|
||||||
gsize width = CGImageGetWidth (image);
|
width = CGImageGetWidth (image);
|
||||||
gsize height = CGImageGetHeight (image);
|
height = CGImageGetHeight (image);
|
||||||
if (width == 0 || height == 0)
|
if (width == 0 || height == 0)
|
||||||
{
|
{
|
||||||
/* incomplete or corrupt */
|
/* incomplete or corrupt */
|
||||||
CFRelease (image);
|
CFRelease (image);
|
||||||
g_set_error (error, COGL_BITMAP_ERROR, COGL_BITMAP_ERROR_CORRUPT_IMAGE,
|
g_set_error_literal (error,
|
||||||
|
COGL_BITMAP_ERROR,
|
||||||
|
COGL_BITMAP_ERROR_CORRUPT_IMAGE,
|
||||||
"Image has zero width or height");
|
"Image has zero width or height");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate buffer big enough to hold pixel data */
|
/* allocate buffer big enough to hold pixel data */
|
||||||
gsize rowstride;
|
|
||||||
rowstride = 4 * width;
|
rowstride = 4 * width;
|
||||||
guint8 *out_data = g_malloc0 (height * rowstride);
|
out_data = g_malloc0 (height * rowstride);
|
||||||
|
|
||||||
/* render to buffer */
|
/* render to buffer */
|
||||||
CGColorSpaceRef color_space = CGColorSpaceCreateWithName (kCGColorSpaceGenericRGB);
|
color_space = CGColorSpaceCreateWithName (kCGColorSpaceGenericRGB);
|
||||||
CGContextRef bitmap_context = CGBitmapContextCreate (out_data,
|
bitmap_context = CGBitmapContextCreate (out_data,
|
||||||
width, height, 8,
|
width, height, 8,
|
||||||
rowstride, color_space,
|
rowstride, color_space,
|
||||||
kCGImageAlphaPremultipliedFirst);
|
kCGImageAlphaPremultipliedFirst);
|
||||||
CGColorSpaceRelease (color_space);
|
CGColorSpaceRelease (color_space);
|
||||||
|
|
||||||
|
{
|
||||||
const CGRect rect = {{0, 0}, {width, height}};
|
const CGRect rect = {{0, 0}, {width, height}};
|
||||||
|
|
||||||
CGContextDrawImage (bitmap_context, rect, image);
|
CGContextDrawImage (bitmap_context, rect, image);
|
||||||
|
}
|
||||||
|
|
||||||
CGImageRelease (image);
|
CGImageRelease (image);
|
||||||
CGContextRelease (bitmap_context);
|
CGContextRelease (bitmap_context);
|
||||||
|
@ -477,8 +477,8 @@ parse_argument (const char *string, /* original user string */
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
const char *p = *ret_p;
|
const char *p = *ret_p;
|
||||||
const char *mark;
|
const char *mark = NULL;
|
||||||
const char *error_string;
|
const char *error_string = NULL;
|
||||||
ParserArgState state = PARSER_ARG_STATE_START;
|
ParserArgState state = PARSER_ARG_STATE_START;
|
||||||
gboolean parsing_factor = FALSE;
|
gboolean parsing_factor = FALSE;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user