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,

View File

@ -189,14 +189,6 @@ dnl See what platform we are building for
dnl ================================================================
AC_CANONICAL_HOST
AC_CHECK_HEADER([OpenGL/gl.h], [platform_quartz=yes], [platform_quartz=no])
AM_CONDITIONAL(OS_QUARTZ, [test "$platform_quartz" = "yes"])
dnl ================================================================
dnl Handle extra configure options
dnl ================================================================
dnl ============================================================
dnl Installed tests
dnl ============================================================
@ -207,7 +199,6 @@ AC_ARG_ENABLE(installed_tests,
[enable_installed_tests=no])
AM_CONDITIONAL(ENABLE_INSTALLED_TESTS, test x$enable_installed_tests = xyes)
dnl ============================================================
dnl Standalone cogl
dnl ============================================================
@ -493,13 +484,6 @@ AC_ARG_ENABLE(
[enable_gdk_pixbuf=no])])]
)
AC_ARG_ENABLE(
[quartz-image],
[AC_HELP_STRING([--enable-quartz-image=@<:@no/yes@:>@], [Enable image loading via quartz @<:@default=no@:>@])],
[],
enable_quartz_image=no
)
AS_IF(
[test "x$enable_gdk_pixbuf" = "xyes"],
[
@ -509,15 +493,6 @@ AS_IF(
COGL_PKG_REQUIRES="$COGL_PKG_REQUIRES gdk-pixbuf-2.0 >= gdk_pixbuf_req_version"
COGL_IMAGE_BACKEND="gdk-pixbuf"
],
[test "x$enable_quartz_image" = "xyes"],
[
EXPERIMENTAL_CONFIG=yes
EXPERIMENTAL_OPTIONS="$EXPERIMENTAL_OPTIONS Quartz Core Graphics,"
AC_DEFINE([USE_QUARTZ], 1,
[Use Core Graphics (Quartz) for loading image data])
COGL_EXTRA_LDFLAGS="$COGL_EXTRA_LDFLAGS -framework ApplicationServices"
COGL_IMAGE_BACKEND="quartz"
],
[
EXPERIMENTAL_CONFIG=yes
EXPERIMENTAL_OPTIONS="$EXPERIMENTAL_OPTIONS fallback image decoding (stb_image),"
@ -684,27 +659,15 @@ AS_IF([test "x$enable_gl" = "xyes"],
cogl_gl_headers="GL/gl.h"
AS_IF([test "x$platform_quartz" = "xyes"],
[
cogl_gl_headers="OpenGL/gl.h"
COGL_EXTRA_LDFLAGS="$COGL_EXTRA_LDFLAGS -framework OpenGL"
dnl The GL API is being directly linked in so there is
dnl no need to dlopen it separately
GL_LIBRARY_DIRECTLY_LINKED=yes
COGL_GL_LIBNAME=""
],
[
PKG_CHECK_EXISTS([gl],
dnl We don't want to use COGL_PKG_REQUIRES here because we don't want to
dnl directly link against libGL
[COGL_PKG_REQUIRES_GL="$COGL_PKG_REQUIRES_GL gl"],
[AC_CHECK_LIB(GL, [glGetString],
,
[AC_MSG_ERROR([Unable to locate required GL library])])
])
COGL_GL_LIBNAME="libGL.so.1"
])
PKG_CHECK_EXISTS([gl],
dnl We don't want to use COGL_PKG_REQUIRES here because we don't want to
dnl directly link against libGL
[COGL_PKG_REQUIRES_GL="$COGL_PKG_REQUIRES_GL gl"],
[AC_CHECK_LIB(GL, [glGetString],
,
[AC_MSG_ERROR([Unable to locate required GL library])])
])
COGL_GL_LIBNAME="libGL.so.1"
AC_DEFINE([HAVE_COGL_GL], [1], [Have GL for rendering])