quartz: drop support

This commit is contained in:
Rui Matos
2016-04-10 18:55:22 +02:00
parent fb75df852c
commit 0da00392e6
2 changed files with 10 additions and 182 deletions

View File

@@ -40,143 +40,8 @@
#include <string.h>
#ifdef USE_QUARTZ
#include <ApplicationServices/ApplicationServices.h>
#elif defined(USE_GDKPIXBUF)
#if defined(USE_GDKPIXBUF)
#include <gdk-pixbuf/gdk-pixbuf.h>
#endif
#ifdef USE_QUARTZ
CoglBool
_cogl_bitmap_get_size_from_file (const char *filename,
int *width,
int *height)
{
if (width)
*width = 0;
if (height)
*height = 0;
return TRUE;
}
/* the error does not contain the filename as the caller already has it */
CoglBitmap *
_cogl_bitmap_from_file (CoglContext *ctx,
const char *filename,
CoglError **error)
{
CFURLRef url;
CGImageSourceRef image_source;
CGImageRef image;
int save_errno;
CFStringRef type;
size_t width, height, rowstride;
uint8_t *out_data;
CGColorSpaceRef color_space;
CGContextRef bitmap_context;
CoglBitmap *bmp;
url = CFURLCreateFromFileSystemRepresentation (NULL,
(guchar *) filename,
strlen (filename),
false);
image_source = CGImageSourceCreateWithURL (url, NULL);
save_errno = errno;
CFRelease (url);
if (image_source == NULL)
{
/* doesn't exist, not readable, etc. */
_cogl_set_error_literal (error,
COGL_BITMAP_ERROR,
COGL_BITMAP_ERROR_FAILED,
g_strerror (save_errno));
return NULL;
}
/* Unknown images would be cleanly caught as zero width/height below, but try
* to provide better error message
*/
type = CGImageSourceGetType (image_source);
if (type == NULL)
{
CFRelease (image_source);
_cogl_set_error_literal (error,
COGL_BITMAP_ERROR,
COGL_BITMAP_ERROR_UNKNOWN_TYPE,
"Unknown image type");
return NULL;
}
CFRelease (type);
image = CGImageSourceCreateImageAtIndex (image_source, 0, NULL);
CFRelease (image_source);
width = CGImageGetWidth (image);
height = CGImageGetHeight (image);
if (width == 0 || height == 0)
{
/* incomplete or corrupt */
CFRelease (image);
_cogl_set_error_literal (error,
COGL_BITMAP_ERROR,
COGL_BITMAP_ERROR_CORRUPT_IMAGE,
"Image has zero width or height");
return NULL;
}
/* allocate buffer big enough to hold pixel data */
bmp = _cogl_bitmap_new_with_malloc_buffer (ctx,
width, height,
COGL_PIXEL_FORMAT_ARGB_8888,
error);
if (bmp == NULL)
{
CFRelease (image);
return NULL;
}
rowstride = cogl_bitmap_get_rowstride (bmp);
out_data = _cogl_bitmap_map (bmp,
COGL_BUFFER_ACCESS_WRITE,
COGL_BUFFER_MAP_HINT_DISCARD,
error);
if (out_data == NULL)
{
cogl_object_unref (bmp);
CFRelease (image);
return NULL;
}
/* render to buffer */
color_space = CGColorSpaceCreateWithName (kCGColorSpaceGenericRGB);
bitmap_context = CGBitmapContextCreate (out_data,
width, height, 8,
rowstride, color_space,
kCGImageAlphaPremultipliedFirst);
CGColorSpaceRelease (color_space);
CGContextSetBlendMode (bitmap_context, kCGBlendModeCopy);
{
const CGRect rect = {{0, 0}, {width, height}};
CGContextDrawImage (bitmap_context, rect, image);
}
CGImageRelease (image);
CGContextRelease (bitmap_context);
_cogl_bitmap_unmap (bmp);
/* store bitmap info */
return bmp;
}
#elif defined(USE_GDKPIXBUF)
CoglBool
_cogl_bitmap_get_size_from_file (const char *filename,