Declare interface types as void and remove cast macros

This declares the interface types CoglFramebuffer, CoglBuffer,
CoglTexture, CoglMetaTexture and CoglPrimitiveTexture as void when
including the public cogl.h header so that users don't have to use lots
of C type casts between instance types and interface types.

This also removes all of the COGL_XYZ() type cast macros since they do
nothing more than compile time type casting but it's less readable if
you haven't seen that coding pattern before.

Unlike with gobject based apis that use per-type macros for casting and
performing runtime type checking we instead prefer to do our runtime
type checking internally within the front-end public apis when objects
are passed into Cogl. This greatly reduces the verbosity for users of
the api and may help reduce the chance of excessive runtime type
checking that can sometimes be a problem.

(cherry picked from commit 248a76f5eac7e5ae4fb45208577f9a55360812a7)

Since we can't break the 1.x api this version of the patch actually
defines compatible NOP macros within deprecated/cogl-type-casts.h
This commit is contained in:
Robert Bragg 2013-10-09 13:31:12 +01:00
parent d24f632d91
commit 6436cd073d
62 changed files with 340 additions and 156 deletions

View File

@ -31,17 +31,20 @@
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include <gst/gstvalue.h>
#include <gst/video/video.h>
#include <gst/riff/riff-ids.h>
#include <cogl/cogl.h>
#include <string.h>
/* We just need the public Cogl api for cogl-gst but we first need to
* undef COGL_COMPILATION to avoid getting an error that normally
* checks cogl.h isn't used internally. */
#undef COGL_COMPILATION
#include <cogl/cogl.h>
#include "cogl-gst-video-sink.h"
#define COGL_GST_DEFAULT_PRIORITY G_PRIORITY_HIGH_IDLE
@ -198,7 +201,7 @@ cogl_gst_video_sink_attach_frame (CoglGstVideoSink *sink,
for (i = 0; i < G_N_ELEMENTS (priv->frame); i++)
if (priv->frame[i] != NULL)
cogl_pipeline_set_layer_texture (pln, i + priv->custom_start,
COGL_TEXTURE (priv->frame[i]));
priv->frame[i]);
}
static CoglBool
@ -486,9 +489,9 @@ video_texture_new_from_data (CoglContext *ctx,
is_pot (cogl_bitmap_get_height (bitmap))) ||
cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC))
{
tex = COGL_TEXTURE (cogl_texture_2d_new_from_bitmap (bitmap,
internal_format,
&internal_error));
tex = cogl_texture_2d_new_from_bitmap (bitmap,
internal_format,
&internal_error);
if (!tex)
{
cogl_error_free (internal_error);
@ -506,7 +509,7 @@ video_texture_new_from_data (CoglContext *ctx,
-1, /* no maximum waste */
internal_format,
error);
tex = COGL_TEXTURE (tex_2ds);
tex = tex_2ds;
}
cogl_object_unref (bitmap);

View File

@ -35,6 +35,16 @@
#define __COGL_GST_VIDEO_SINK_H__
#include <glib-object.h>
#include <gst/base/gstbasesink.h>
/* We just need the public Cogl api for cogl-gst but we first need to
* undef COGL_COMPILATION to avoid getting an error that normally
* checks cogl.h isn't used internally. */
#ifdef COGL_COMPILATION
#undef COGL_COMPILATION
#endif
#include <cogl/cogl.h>
#include <cogl/cogl.h>
/**

View File

@ -26,7 +26,6 @@
#endif
#include <glib.h>
#include <cogl/cogl.h>
#include <string.h>
#include "cogl-pango-display-list.h"

View File

@ -25,7 +25,6 @@
#define __COGL_PANGO_DISPLAY_LIST_H__
#include <glib.h>
#include <cogl/cogl.h>
#include "cogl-pango-pipeline-cache.h"
COGL_BEGIN_DECLS

View File

@ -25,9 +25,10 @@
#define __COGL_PANGO_GLYPH_CACHE_H__
#include <glib.h>
#include <cogl/cogl.h>
#include <pango/pango-font.h>
#include "cogl/cogl-texture.h"
COGL_BEGIN_DECLS
typedef struct _CoglPangoGlyphCache CoglPangoGlyphCache;

View File

@ -30,7 +30,6 @@
#endif
#include <glib.h>
#include <cogl/cogl.h>
#include "cogl-pango-pipeline-cache.h"
#include "cogl/cogl-context-private.h"

View File

@ -29,7 +29,8 @@
#define __COGL_PANGO_PIPELINE_CACHE_H__
#include <glib.h>
#include <cogl/cogl.h>
#include "cogl/cogl-context-private.h"
COGL_BEGIN_DECLS

View File

@ -32,7 +32,20 @@
#include <glib-object.h>
#include <pango/pango.h>
#include <pango/pangocairo.h>
/* XXX: Currently this header may be included both as an internal
* header (within the cogl-pango implementation) and as a public
* header.
*
* Since <cogl/cogl.h> should not be included for internal use we
* determine the current context and switch between including cogl.h
* or specific internal cogl headers here...
*/
#ifndef COGL_COMPILATION
#include <cogl/cogl.h>
#else
#include "cogl/cogl-context.h"
#endif
COGL_BEGIN_DECLS

View File

@ -35,8 +35,6 @@ COGL_BEGIN_DECLS
typedef struct _CoglPath CoglPath;
#define COGL_PATH(obj) ((CoglPath *)(obj))
/**
* CoglPathFillRule:
* @COGL_PATH_FILL_RULE_NON_ZERO: Each time the line crosses an edge of

View File

@ -26,9 +26,7 @@
* Robert Bragg <robert@linux.intel.com>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "cogl-util.h"
#include "cogl-object.h"

View File

@ -30,7 +30,11 @@
#define __COGL2_PATH_FUNCTIONS_H__
#include <cogl/cogl-types.h>
#ifdef COGL_COMPILATION
#include "cogl-context.h"
#else
#include <cogl/cogl.h>
#endif
COGL_BEGIN_DECLS

View File

@ -74,6 +74,7 @@ cogl_deprecated_h = \
$(srcdir)/deprecated/cogl-vertex-buffer.h \
$(srcdir)/deprecated/cogl-shader.h \
$(srcdir)/deprecated/cogl-clutter.h \
$(srcdir)/deprecated/cogl-type-casts.h \
$(NULL)
# public 1.x api headers

View File

@ -59,9 +59,15 @@ COGL_BEGIN_DECLS
* without blocking other Cogl operations.
*/
#define COGL_BUFFER(buffer) ((CoglBuffer *)(buffer))
#ifdef __COGL_H_INSIDE__
/* For the public C api we typedef interface types as void to avoid needing
* lots of casting in code and instead we will rely on runtime type checking
* for these objects. */
typedef void CoglBuffer;
#else
typedef struct _CoglBuffer CoglBuffer;
#define COGL_BUFFER(buffer) ((CoglBuffer *)(buffer))
#endif
#define COGL_BUFFER_ERROR (_cogl_buffer_error_domain ())

View File

@ -35,7 +35,15 @@
/* We forward declare the CoglFramebuffer type here to avoid some circular
* dependency issues with the following headers.
*/
#ifdef __COGL_H_INSIDE__
/* For the public C api we typedef interface types as void to avoid needing
* lots of casting in code and instead we will rely on runtime type checking
* for these objects. */
typedef void CoglFramebuffer;
#else
typedef struct _CoglFramebuffer CoglFramebuffer;
#define COGL_FRAMEBUFFER(X) ((CoglFramebuffer *)(X))
#endif
#include <cogl/cogl-pipeline.h>
#include <cogl/cogl-indices.h>
@ -88,8 +96,6 @@ COGL_BEGIN_DECLS
#ifdef COGL_ENABLE_EXPERIMENTAL_API
#define COGL_FRAMEBUFFER(X) ((CoglFramebuffer *)(X))
/**
* cogl_framebuffer_allocate:
* @framebuffer: A #CoglFramebuffer

View File

@ -29,7 +29,16 @@
#ifndef __COGL_GLES2_H__
#define __COGL_GLES2_H__
/* NB: cogl-gles2.h is a top-level header that can be included directly
* but we want to be careful not to define __COGL_H_INSIDE__ when this
* is included internally while building Cogl itself since
* __COGL_H_INSIDE__ is used in headers to guard public vs private
* api definitions
*/
#ifndef COGL_COMPILATION
#define __COGL_H_INSIDE__
#endif
#include <cogl/cogl-defines.h>
#include <cogl/cogl-context.h>
#include <cogl/cogl-framebuffer.h>

View File

@ -86,8 +86,15 @@ COGL_BEGIN_DECLS
* meta-textures.</note>
*/
#ifdef __COGL_H_INSIDE__
/* For the public C api we typedef interface types as void to avoid needing
* lots of casting in code and instead we will rely on runtime type checking
* for these objects. */
typedef void CoglMetaTexture;
#else
typedef struct _CoglMetaTexture CoglMetaTexture;
#define COGL_META_TEXTURE(X) ((CoglMetaTexture *)X)
#endif
/**
* CoglMetaTextureCallback:

View File

@ -57,8 +57,15 @@ COGL_BEGIN_DECLS
* primitive textures.</note>
*/
#ifdef __COGL_H_INSIDE__
/* For the public C api we typedef interface types as void to avoid needing
* lots of casting in code and instead we will rely on runtime type checking
* for these objects. */
typedef void CoglPrimitiveTexture;
#else
typedef struct _CoglPrimitiveTexture CoglPrimitiveTexture;
#define COGL_PRIMITIVE_TEXTURE(X) ((CoglPrimitiveTexture *)X)
#endif
/**
* cogl_is_primitive_texture:

View File

@ -31,7 +31,15 @@
/* We forward declare the CoglTexture type here to avoid some circular
* dependency issues with the following headers.
*/
#ifdef __COGL_H_INSIDE__
/* For the public C api we typedef interface types as void to avoid needing
* lots of casting in code and instead we will rely on runtime type checking
* for these objects. */
typedef void CoglTexture;
#else
typedef struct _CoglTexture CoglTexture;
#define COGL_TEXTURE(X) ((CoglTexture *)X)
#endif
#include <cogl/cogl-types.h>
#include <cogl/cogl-macros.h>
@ -52,8 +60,6 @@ COGL_BEGIN_DECLS
* loading and manipulating textures.
*/
#define COGL_TEXTURE(X) ((CoglTexture *)X)
#define COGL_TEXTURE_MAX_WASTE 127
/**

View File

@ -24,7 +24,16 @@
#ifndef __COGL_WAYLAND_CLIENT_H
#define __COGL_WAYLAND_CLIENT_H
/* NB: this is a top-level header that can be included directly but we
* want to be careful not to define __COGL_H_INSIDE__ when this is
* included internally while building Cogl itself since
* __COGL_H_INSIDE__ is used in headers to guard public vs private api
* definitions
*/
#ifndef COGL_COMPILATION
#define __COGL_H_INSIDE__
#endif
#include <cogl/cogl-wayland-renderer.h>
#endif /* __COGL_WAYLAND_CLIENT_H */

View File

@ -26,7 +26,16 @@
#include <wayland-server.h>
/* NB: this is a top-level header that can be included directly but we
* want to be careful not to define __COGL_H_INSIDE__ when this is
* included internally while building Cogl itself since
* __COGL_H_INSIDE__ is used in headers to guard public vs private api
* definitions
*/
#ifndef COGL_COMPILATION
#define __COGL_H_INSIDE__
#endif
#include <cogl/cogl-context.h>
#include <cogl/cogl-texture-2d.h>

View File

@ -30,7 +30,15 @@
#include <X11/Xlib.h>
/* NB: this is a top-level header that can be included directly but we
* want to be careful not to define __COGL_H_INSIDE__ when this is
* included internally while building Cogl itself since
* __COGL_H_INSIDE__ is used in headers to guard public vs private api
* definitions
*/
#ifndef COGL_COMPILATION
#define __COGL_H_INSIDE__
#endif
#include <cogl/cogl-renderer.h>
COGL_BEGIN_DECLS

View File

@ -26,8 +26,16 @@
#include <X11/Xlib.h>
/* NB: this is a top-level header that can be included directly but we
* want to be careful not to define __COGL_H_INSIDE__ when this is
* included internally while building Cogl itself since
* __COGL_H_INSIDE__ is used in headers to guard public vs private api
* definitions
*/
#ifndef COGL_COMPILATION
#define __COGL_XLIB_H_INSIDE__
#define __COGL_H_INSIDE__
#endif
#include <cogl/cogl-types.h>
#include <cogl/deprecated/cogl-clutter-xlib.h>

View File

@ -25,6 +25,10 @@
#ifndef __COGL_H__
#define __COGL_H__
#ifdef COGL_COMPILATION
#error "<cogl/cogl.h> shouldn't be included internally"
#endif
#define __COGL_H_INSIDE__
#ifdef COGL_ENABLE_EXPERIMENTAL_2_0_API
@ -72,6 +76,11 @@
#include <cogl/deprecated/cogl-shader.h>
#endif
/* It would be good to move these casts up into 1.x only api if we can
* update Clutter, Mutter and GnomeShell to avoid redundant casts when
* they enable the experimental api... */
#include <cogl/deprecated/cogl-type-casts.h>
/*
* 2.0 api that's compatible with the 1.x api...
*/

View File

@ -0,0 +1,47 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2013 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*
*
*/
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
#error "Only <cogl/cogl.h> can be included directly."
#endif
#ifndef __COGL_TYPE_CASTS_H__
#define __COGL_TYPE_CASTS_H__
/* The various interface types in Cogl used to be more strongly typed
* which required lots type casting by developers. We provided
* macros for performing these casts following a widely used Gnome
* coding style. Since we now consistently typedef these interfaces
* as void for the public C api and use runtime type checking to
* catch programming errors the casts have become redundant and
* so these macros are only kept for compatibility...
*/
#define COGL_FRAMEBUFFER(X) (X)
#define COGL_BUFFER(X) (X)
#define COGL_TEXTURE(X) (X)
#define COGL_META_TEXTURE(X) (X)
#define COGL_PRIMITIVE_TEXTURE(X) (X)
#endif /* __COGL_TYPE_CASTS_H__ */

View File

@ -108,6 +108,7 @@
#include "cogl-primitive-private.h"
#include "cogl-journal-private.h"
#include "cogl1-context.h"
#include "cogl-vertex-buffer.h"
#define PAD_FOR_ALIGNMENT(VAR, TYPE_SIZE) \
(VAR = TYPE_SIZE + ((VAR - 1) & ~(TYPE_SIZE - 1)))

View File

@ -24,7 +24,15 @@
#ifndef __COGL_TEXTURE_PIXMAP_X11_H
#define __COGL_TEXTURE_PIXMAP_X11_H
/* NB: this is a top-level header that can be included directly but we
* want to be careful not to define __COGL_H_INSIDE__ when this is
* included internally while building Cogl itself since
* __COGL_H_INSIDE__ is used in headers to guard public vs private api
* definitions
*/
#ifndef COGL_COMPILATION
#define __COGL_H_INSIDE__
#endif
#include <cogl/cogl-context.h>

View File

@ -257,7 +257,7 @@ main (int argc,
cogl_onscreen_add_resize_callback (onscreen, _resize_callback, &data, NULL);
cogl_onscreen_show (onscreen);
data.fb = COGL_FRAMEBUFFER (onscreen);
data.fb = onscreen;
cogl_framebuffer_orthographic (data.fb, 0, 0, 640, 480, -1, 100);
data.border_pipeline = cogl_pipeline_new (ctx);

View File

@ -160,7 +160,7 @@ main (int argc, char **argv)
}
onscreen = cogl_onscreen_new (ctx, 640, 480);
fb = COGL_FRAMEBUFFER (onscreen);
fb = onscreen;
data.fb = fb;
data.framebuffer_width = cogl_framebuffer_get_width (fb);
data.framebuffer_height = cogl_framebuffer_get_height (fb);
@ -220,11 +220,11 @@ main (int argc, char **argv)
/* Load a jpeg crate texture from a file */
printf ("crate.jpg (CC by-nc-nd http://bit.ly/9kP45T) ShadowRunner27 http://bit.ly/m1YXLh\n");
data.texture = COGL_TEXTURE (
data.texture =
cogl_texture_2d_new_from_file (ctx,
COGL_EXAMPLES_DATA "crate.jpg",
COGL_PIXEL_FORMAT_ANY,
&error));
&error);
if (!data.texture)
g_error ("Failed to load texture: %s", error->message);

View File

@ -87,7 +87,7 @@ main (int argc, char **argv)
onscreen = cogl_onscreen_new (data.ctx, 640, 480);
cogl_onscreen_show (onscreen);
data.fb = COGL_FRAMEBUFFER (onscreen);
data.fb = onscreen;
/* Prepare onscreen primitive */
data.triangle = cogl_primitive_new_p2c4 (data.ctx,
@ -95,11 +95,11 @@ main (int argc, char **argv)
3, triangle_vertices);
data.pipeline = cogl_pipeline_new (data.ctx);
data.offscreen_texture = COGL_TEXTURE (
data.offscreen_texture =
cogl_texture_2d_new_with_size (data.ctx,
OFFSCREEN_WIDTH,
OFFSCREEN_HEIGHT,
COGL_PIXEL_FORMAT_ANY));
COGL_PIXEL_FORMAT_ANY);
data.offscreen = cogl_offscreen_new_with_texture (data.offscreen_texture);
data.gles2_ctx = cogl_gles2_context_new (data.ctx, &error);

View File

@ -779,7 +779,7 @@ main (int argc, char **argv)
onscreen = cogl_onscreen_new (data.ctx, 300, 300);
cogl_onscreen_show (onscreen);
data.fb = COGL_FRAMEBUFFER (onscreen);
data.fb = onscreen;
data.gles2_ctx = cogl_gles2_context_new (data.ctx, &error);
if (!data.gles2_ctx)

View File

@ -27,7 +27,7 @@ paint_cb (void *user_data)
cogl_primitive_draw (data->triangle,
data->fb,
data->pipeline);
cogl_onscreen_swap_buffers (COGL_ONSCREEN (data->fb));
cogl_onscreen_swap_buffers (data->fb);
return G_SOURCE_REMOVE;
}
@ -94,7 +94,7 @@ main (int argc, char **argv)
onscreen = cogl_onscreen_new (data.ctx, 640, 480);
cogl_onscreen_show (onscreen);
data.fb = COGL_FRAMEBUFFER (onscreen);
data.fb = onscreen;
cogl_onscreen_set_resizable (onscreen, TRUE);
@ -107,11 +107,11 @@ main (int argc, char **argv)
g_source_attach (cogl_source, NULL);
cogl_onscreen_add_frame_callback (COGL_ONSCREEN (data.fb),
cogl_onscreen_add_frame_callback (data.fb,
frame_event_cb,
&data,
NULL); /* destroy notify */
cogl_onscreen_add_dirty_callback (COGL_ONSCREEN (data.fb),
cogl_onscreen_add_dirty_callback (data.fb,
dirty_cb,
&data,
NULL); /* destroy notify */

View File

@ -41,7 +41,7 @@ main (int argc, char **argv)
}
onscreen = cogl_onscreen_new (ctx, 640, 480);
fb = COGL_FRAMEBUFFER (onscreen);
fb = onscreen;
cogl_framebuffer_set_samples_per_pixel (fb, 4);
@ -62,11 +62,11 @@ main (int argc, char **argv)
cogl_onscreen_show (onscreen);
tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
320, 480,
COGL_PIXEL_FORMAT_ANY));
tex = cogl_texture_2d_new_with_size (ctx,
320, 480,
COGL_PIXEL_FORMAT_ANY);
offscreen = cogl_offscreen_new_with_texture (tex);
offscreen_fb = COGL_FRAMEBUFFER (offscreen);
offscreen_fb = offscreen;
cogl_framebuffer_set_samples_per_pixel (offscreen_fb, 4);
if (!cogl_framebuffer_allocate (offscreen_fb, &error))
{

View File

@ -89,7 +89,7 @@ generate_round_texture (CoglContext *context)
g_free (data);
return COGL_TEXTURE (tex);
return tex;
}
static void
@ -183,7 +183,7 @@ paint (Data *data)
g_timer_reset (data->last_spark_time);
}
cogl_buffer_set_data (COGL_BUFFER (data->attribute_buffer),
cogl_buffer_set_data (data->attribute_buffer,
0, /* offset */
data->sparks,
sizeof (data->sparks));
@ -194,7 +194,7 @@ paint (Data *data)
data->fb,
data->pipeline);
cogl_onscreen_swap_buffers (COGL_ONSCREEN (data->fb));
cogl_onscreen_swap_buffers (data->fb);
}
static void
@ -206,7 +206,7 @@ create_primitive (Data *data)
data->attribute_buffer =
cogl_attribute_buffer_new_with_size (data->context,
sizeof (data->sparks));
cogl_buffer_set_update_hint (COGL_BUFFER (data->attribute_buffer),
cogl_buffer_set_update_hint (data->attribute_buffer,
COGL_BUFFER_UPDATE_HINT_DYNAMIC);
attributes[0] = cogl_attribute_new (data->attribute_buffer,
@ -288,7 +288,7 @@ main (int argc, char *argv[])
onscreen = cogl_onscreen_new (data.context, 800, 600);
cogl_onscreen_show (onscreen);
data.fb = COGL_FRAMEBUFFER (onscreen);
data.fb = onscreen;
cogl_source = cogl_glib_source_new (data.context, G_PRIORITY_DEFAULT);

View File

@ -59,9 +59,9 @@ handle_event (Data *data, SDL_Event *event)
case SDL_MOUSEMOTION:
{
int width =
cogl_framebuffer_get_width (COGL_FRAMEBUFFER (data->fb));
cogl_framebuffer_get_width (data->fb);
int height =
cogl_framebuffer_get_height (COGL_FRAMEBUFFER (data->fb));
cogl_framebuffer_get_height (data->fb);
data->center_x = event->motion.x * 2.0f / width - 1.0f;
data->center_y = event->motion.y * 2.0f / height - 1.0f;
@ -110,7 +110,7 @@ main (int argc, char **argv)
}
onscreen = cogl_onscreen_new (ctx, 800, 600);
data.fb = COGL_FRAMEBUFFER (onscreen);
data.fb = onscreen;
cogl_onscreen_add_frame_callback (onscreen,
frame_cb,

View File

@ -157,7 +157,7 @@ main (int argc, char **argv)
XMapWindow (xdpy, xwin);
fb = COGL_FRAMEBUFFER (onscreen);
fb = onscreen;
cogl_onscreen_set_resizable (onscreen, TRUE);
cogl_onscreen_add_resize_callback (onscreen, resize_handler, onscreen, NULL);

View File

@ -189,12 +189,12 @@ main (int argc, char **argv)
return 1;
}
fb = COGL_FRAMEBUFFER (onscreen);
cogl_push_framebuffer (fb);
fb = onscreen;
for (;;)
{
unsigned long pixel;
CoglPipeline *pipeline;
while (XPending (xdpy))
{
@ -221,8 +221,10 @@ main (int argc, char **argv)
XFlush (xdpy);
cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
cogl_set_source_texture (COGL_TEXTURE (tfp));
cogl_rectangle (-0.8, 0.8, 0.8, -0.8);
pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_layer_texture (pipeline, 0, tfp);
cogl_framebuffer_draw_rectangle (fb, pipeline, -0.8, 0.8, 0.8, -0.8);
cogl_object_unref (pipeline);
cogl_onscreen_swap_buffers (onscreen);
}

View File

@ -385,11 +385,9 @@ paint_cb (void *user_data)
for (l = compositor->outputs; l; l = l->next)
{
CoglandOutput *output = l->data;
CoglFramebuffer *fb = COGL_FRAMEBUFFER (output->onscreen);
CoglFramebuffer *fb = output->onscreen;
GList *l2;
cogl_push_framebuffer (fb);
cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
cogl_primitive_draw (compositor->triangle,
@ -402,13 +400,14 @@ paint_cb (void *user_data)
if (surface->texture)
{
CoglTexture2D *texture = surface->texture;
cogl_set_source_texture (COGL_TEXTURE (texture));
cogl_rectangle (-1, 1, 1, -1);
CoglPipeline *pipeline =
cogl_pipeline_new (compositor->cogl_context);
cogl_pipeline_set_layer_texture (pipeline, 0, texture);
cogl_framebuffer_draw_rectangle (fb, pipeline, -1, 1, 1, -1);
cogl_object_unref (pipeline);
}
}
cogl_onscreen_swap_buffers (COGL_ONSCREEN (fb));
cogl_pop_framebuffer ();
}
while (!wl_list_empty (&compositor->frame_callbacks))
@ -473,7 +472,7 @@ surface_damaged (CoglandSurface *surface,
format = COGL_PIXEL_FORMAT_ARGB_8888;
}
cogl_texture_set_region (COGL_TEXTURE (surface->texture),
cogl_texture_set_region (surface->texture,
x, y, /* src_x/y */
x, y, /* dst_x/y */
width, height, /* dst_width/height */
@ -634,7 +633,7 @@ cogland_surface_commit (struct wl_client *client,
!region_is_empty (&surface->pending.damage))
{
CoglandRegion *region = &surface->pending.damage;
CoglTexture *texture = COGL_TEXTURE (surface->texture);
CoglTexture *texture = surface->texture;
if (region->x2 > cogl_texture_get_width (texture))
region->x2 = cogl_texture_get_width (texture);
@ -885,7 +884,7 @@ cogland_compositor_create_output (CoglandCompositor *compositor,
width_mm, height_mm);
/* Eventually there will be an implicit allocate on first use so this
* will become optional... */
fb = COGL_FRAMEBUFFER (output->onscreen);
fb = output->onscreen;
if (!cogl_framebuffer_allocate (fb, &error))
g_error ("Failed to allocate framebuffer: %s\n", error->message);
@ -895,7 +894,8 @@ cogland_compositor_create_output (CoglandCompositor *compositor,
NULL /* destroy */);
cogl_onscreen_show (output->onscreen);
cogl_framebuffer_set_viewport (fb, -x, -y,
cogl_framebuffer_set_viewport (fb,
-x, -y,
compositor->virtual_width,
compositor->virtual_height);

View File

@ -1,6 +1,13 @@
#ifndef _TEST_UTILS_H_
#define _TEST_UTILS_H_
/* NB: This header is for private and public api testing and so
* we need consider that if we are testing the public api we should
* just include <cogl/cogl.h> but since that will only provide
* opaque typedefs we need to include the specific internal headers
* for testing private apis...
*/
#ifdef COGL_COMPILATION
#include <cogl/cogl-context.h>
#include <cogl/cogl-onscreen.h>
#include <cogl/cogl-offscreen.h>
@ -9,6 +16,10 @@
#include <cogl/cogl-texture-2d-sliced.h>
#include <cogl/cogl-meta-texture.h>
#include <cogl/cogl-atlas-texture.h>
#else
#include <cogl/cogl.h>
#endif
#include <glib.h>
/* We don't really care about functions that are defined without a

View File

@ -137,8 +137,7 @@ endif
AM_CPPFLAGS += \
-DCOGL_ENABLE_EXPERIMENTAL_API \
-DCOGL_DISABLE_DEPRECATED \
-DTESTS_DATADIR=\""$(top_srcdir)/tests/data"\" \
-DCOGL_COMPILATION
-DTESTS_DATADIR=\""$(top_srcdir)/tests/data"\"
test_conformance_CFLAGS = -g3 -O0 $(COGL_DEP_CFLAGS) $(COGL_EXTRA_CFLAGS)
test_conformance_LDADD = \

View File

@ -24,7 +24,7 @@ create_texture (CoglContext *context)
void
test_alpha_test (void)
{
CoglTexture *tex = COGL_TEXTURE (create_texture (test_ctx));
CoglTexture *tex = create_texture (test_ctx);
CoglPipeline *pipeline = cogl_pipeline_new (test_ctx);
int fb_width = cogl_framebuffer_get_width (test_fb);
int fb_height = cogl_framebuffer_get_height (test_fb);

View File

@ -39,10 +39,10 @@ create_pipeline (CoglTexture **tex_out,
cogl_pipeline_set_layer_texture (pipeline,
0, /* layer */
COGL_TEXTURE (tex));
tex);
*pipeline_out = pipeline;
*tex_out = COGL_TEXTURE (tex);
*tex_out = tex;
}
void

View File

@ -298,7 +298,7 @@ test_backface_culling (void)
TEST_UTILS_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_ANY); /* internal
format */
state.offscreen = COGL_FRAMEBUFFER (cogl_offscreen_new_with_texture (tex));
state.offscreen = cogl_offscreen_new_with_texture (tex);
state.offscreen_tex = tex;
paint (&state);

View File

@ -27,18 +27,18 @@ test_color_hsl (void)
memset(&color, 0, sizeof (CoglColor));
cogl_color_init_from_hsl(&color, hue, saturation, luminance);
g_assert_cmpint (color.red, ==, 108);
g_assert_cmpint (color.green, ==, 198);
g_assert_cmpint (color.blue, ==, 78);
g_assert_cmpint (color.alpha, ==, 255);
g_assert_cmpint (cogl_color_get_red_byte (&color), ==, 108);
g_assert_cmpint (cogl_color_get_green_byte (&color), ==, 198);
g_assert_cmpint (cogl_color_get_blue_byte (&color), ==, 78);
g_assert_cmpint (cogl_color_get_alpha_byte (&color), ==, 255);
memset(&color, 0, sizeof (CoglColor));
cogl_color_init_from_hsl(&color, hue, 0, luminance);
cogl_assert_float(color.red / 255.0f, luminance);
cogl_assert_float(color.green / 255.0f, luminance);
cogl_assert_float(color.blue / 255.0f, luminance);
cogl_assert_float(color.alpha / 255.0f, 1.0f);
cogl_assert_float (cogl_color_get_red_float (&color), luminance);
cogl_assert_float (cogl_color_get_green_float (&color), luminance);
cogl_assert_float (cogl_color_get_blue_float (&color), luminance);
cogl_assert_float (cogl_color_get_alpha_float (&color), 1.0f);
if (cogl_test_verbose ())
g_print ("OK\n");

View File

@ -86,8 +86,7 @@ test_color_mask (void)
COGL_PIXEL_FORMAT_RGB_888);
state.fbo[i] = COGL_FRAMEBUFFER (
cogl_offscreen_new_with_texture (state.tex[i]));
state.fbo[i] = cogl_offscreen_new_with_texture (state.tex[i]);
/* Clear the texture color bits */
cogl_framebuffer_clear4f (state.fbo[i],

View File

@ -51,7 +51,7 @@ create_texture (void)
texture_num++;
return COGL_TEXTURE (tex_2d);
return tex_2d;
}
void

View File

@ -6,7 +6,6 @@
#include "test-utils.h"
#include "config.h"
#include <cogl/cogl-util.h>
/* I'm writing this on the train after having dinner at a churrascuria. */
#define MAGIC_CHUNK_O_DATA ((void *) 0xdeadbeef)

View File

@ -10,15 +10,15 @@ test_framebuffer_get_bits (void)
16, 16, /* width/height */
COGL_PIXEL_FORMAT_A_8);
CoglOffscreen *offscreen_a =
cogl_offscreen_new_with_texture (COGL_TEXTURE (tex_a));
CoglFramebuffer *fb_a = COGL_FRAMEBUFFER (offscreen_a);
cogl_offscreen_new_with_texture (tex_a);
CoglFramebuffer *fb_a = offscreen_a;
CoglTexture2D *tex_rgba =
cogl_texture_2d_new_with_size (test_ctx,
16, 16, /* width/height */
COGL_PIXEL_FORMAT_RGBA_8888);
CoglOffscreen *offscreen_rgba =
cogl_offscreen_new_with_texture (COGL_TEXTURE (tex_rgba));
CoglFramebuffer *fb_rgba = COGL_FRAMEBUFFER (offscreen_rgba);
cogl_offscreen_new_with_texture (tex_rgba);
CoglFramebuffer *fb_rgba = offscreen_rgba;
cogl_framebuffer_allocate (fb_a, NULL);
cogl_framebuffer_allocate (fb_rgba, NULL);

View File

@ -23,11 +23,11 @@ test_push_pop_single_context (void)
const CoglGLES2Vtable *gles2;
CoglError *error = NULL;
offscreen_texture = COGL_TEXTURE (
offscreen_texture =
cogl_texture_2d_new_with_size (test_ctx,
cogl_framebuffer_get_width (test_fb),
cogl_framebuffer_get_height (test_fb),
COGL_PIXEL_FORMAT_ANY));
COGL_PIXEL_FORMAT_ANY);
offscreen = cogl_offscreen_new_with_texture (offscreen_texture);
pipeline = cogl_pipeline_new (test_ctx);
@ -67,8 +67,8 @@ test_push_pop_single_context (void)
if (!cogl_push_gles2_context (test_ctx,
gles2_ctx,
COGL_FRAMEBUFFER (offscreen),
COGL_FRAMEBUFFER (offscreen),
offscreen,
offscreen,
&error))
{
g_error ("Failed to push gles2 context: %s\n", error->message);
@ -94,8 +94,8 @@ test_push_pop_single_context (void)
*/
if (!cogl_push_gles2_context (test_ctx,
gles2_ctx,
COGL_FRAMEBUFFER (offscreen),
COGL_FRAMEBUFFER (offscreen),
offscreen,
offscreen,
&error))
{
g_error ("Failed to push gles2 context: %s\n", error->message);
@ -147,11 +147,11 @@ create_gles2_context (CoglTexture **offscreen_texture,
{
CoglError *error = NULL;
*offscreen_texture = COGL_TEXTURE (
*offscreen_texture =
cogl_texture_2d_new_with_size (test_ctx,
cogl_framebuffer_get_width (test_fb),
cogl_framebuffer_get_height (test_fb),
COGL_PIXEL_FORMAT_ANY));
COGL_PIXEL_FORMAT_ANY);
*offscreen = cogl_offscreen_new_with_texture (*offscreen_texture);
*pipeline = cogl_pipeline_new (test_ctx);
@ -195,8 +195,8 @@ test_push_pop_multi_context (void)
if (!cogl_push_gles2_context (test_ctx,
gles2_ctx0,
COGL_FRAMEBUFFER (offscreen0),
COGL_FRAMEBUFFER (offscreen0),
offscreen0,
offscreen0,
&error))
{
g_error ("Failed to push gles2 context 0: %s\n", error->message);
@ -207,8 +207,8 @@ test_push_pop_multi_context (void)
if (!cogl_push_gles2_context (test_ctx,
gles2_ctx1,
COGL_FRAMEBUFFER (offscreen1),
COGL_FRAMEBUFFER (offscreen1),
offscreen1,
offscreen1,
&error))
{
g_error ("Failed to push gles2 context 1: %s\n", error->message);
@ -290,8 +290,8 @@ test_gles2_read_pixels (void)
if (!cogl_push_gles2_context (test_ctx,
gles2_ctx,
COGL_FRAMEBUFFER (offscreen),
COGL_FRAMEBUFFER (offscreen),
offscreen,
offscreen,
&error))
{
g_error ("Failed to push gles2 context: %s\n", error->message);
@ -328,7 +328,7 @@ test_gles2_read_pixels (void)
/* Bind different read and write buffers */
if (!cogl_push_gles2_context (test_ctx,
gles2_ctx,
COGL_FRAMEBUFFER (offscreen),
offscreen,
test_fb,
&error))
{
@ -349,7 +349,7 @@ test_gles2_read_pixels (void)
if (!cogl_push_gles2_context (test_ctx,
gles2_ctx,
test_fb,
COGL_FRAMEBUFFER (offscreen),
offscreen,
&error))
{
g_error ("Failed to push gles2 context: %s\n", error->message);
@ -682,8 +682,8 @@ test_gles2_context_fbo (void)
if (!cogl_push_gles2_context (test_ctx,
gles2_ctx,
COGL_FRAMEBUFFER (offscreen),
COGL_FRAMEBUFFER (offscreen),
offscreen,
offscreen,
&error))
g_error ("Failed to push gles2 context: %s\n", error->message);
@ -817,8 +817,8 @@ test_gles2_context_copy_tex_image (void)
if (!cogl_push_gles2_context (test_ctx,
gles2_ctx,
COGL_FRAMEBUFFER (offscreen),
COGL_FRAMEBUFFER (offscreen),
offscreen,
offscreen,
&error))
g_error ("Failed to push gles2 context: %s\n", error->message);

View File

@ -44,7 +44,7 @@ test_map_buffer_range (void)
pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (tex));
cogl_pipeline_set_layer_texture (pipeline, 0, tex);
cogl_pipeline_set_layer_filters (pipeline,
0, /* layer */
COGL_PIPELINE_FILTER_NEAREST,
@ -62,7 +62,7 @@ test_map_buffer_range (void)
/* Replace the texture coordinates of the third vertex with the
* coordinates for a green texel */
data = cogl_buffer_map_range (COGL_BUFFER (buffer),
data = cogl_buffer_map_range (buffer,
sizeof (vertex_data[0]) * 2,
sizeof (vertex_data[0]),
COGL_BUFFER_ACCESS_WRITE,
@ -75,7 +75,7 @@ test_map_buffer_range (void)
data->s = 1.0f;
data->t = 0.0f;
cogl_buffer_unmap (COGL_BUFFER (buffer));
cogl_buffer_unmap (buffer);
pos_attribute =
cogl_attribute_new (buffer,

View File

@ -48,7 +48,7 @@ test_paint (TestState *state)
state->fb_width,
state->fb_height,
COGL_PIXEL_FORMAT_RGBA_8888_PRE);
tex = COGL_TEXTURE (tex_2d);
tex = tex_2d;
offscreen = cogl_offscreen_new_with_texture (tex);
@ -66,7 +66,7 @@ test_paint (TestState *state)
cogl_translate (0.5, 0.5, 0);
cogl_scale (-0.5, 0.5, 1);
cogl_push_framebuffer (COGL_FRAMEBUFFER (offscreen));
cogl_push_framebuffer (offscreen);
/* Cogl should release the last reference when we call cogl_pop_framebuffer()
*/
@ -129,11 +129,11 @@ test_flush (TestState *state)
tex_2d = cogl_texture_2d_new_with_size (test_ctx,
16, 16, /* width/height */
COGL_PIXEL_FORMAT_RGBA_8888_PRE);
tex = COGL_TEXTURE (tex_2d);
tex = tex_2d;
offscreen = cogl_offscreen_new_with_texture (tex);
cogl_push_framebuffer (COGL_FRAMEBUFFER (offscreen));
cogl_push_framebuffer (offscreen);
cogl_color_init_from_4ub (&clear_color, 0, 0, 0, 255);
cogl_clear (&clear_color, COGL_BUFFER_BIT_COLOR);
@ -143,7 +143,7 @@ test_flush (TestState *state)
if (i == 0)
/* First time check using read pixels on the offscreen */
test_utils_check_region (COGL_FRAMEBUFFER (offscreen),
test_utils_check_region (offscreen,
1, 1, 15, 15, 0xff0000ff);
else if (i == 1)
{

View File

@ -37,7 +37,7 @@ create_texture (void)
GINT_TO_POINTER (1),
free_texture_cb);
return COGL_TEXTURE (tex_2d);
return tex_2d;
}
void

View File

@ -24,8 +24,8 @@ test_pipeline_shader_state (void)
tex = cogl_texture_2d_new_with_size (test_ctx,
128, 128, COGL_PIXEL_FORMAT_ANY);
offscreen = cogl_offscreen_new_with_texture (COGL_TEXTURE (tex));
fb = COGL_FRAMEBUFFER (offscreen);
offscreen = cogl_offscreen_new_with_texture (tex);
fb = offscreen;
cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
cogl_object_unref (offscreen);
@ -35,7 +35,7 @@ test_pipeline_shader_state (void)
/* Setup a template pipeline... */
base_pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_layer_texture (base_pipeline, 1, COGL_TEXTURE (tex));
cogl_pipeline_set_layer_texture (base_pipeline, 1, tex);
cogl_pipeline_set_color4f (base_pipeline, 1, 0, 0, 1);
@ -69,7 +69,7 @@ test_pipeline_shader_state (void)
* cached vertex shader gets invalidated.
*/
cogl_pipeline_set_layer_texture (base_pipeline, 0, COGL_TEXTURE (tex));
cogl_pipeline_set_layer_texture (base_pipeline, 0, tex);
/* Now we derive another pipeline from base_pipeline to verify that

View File

@ -39,7 +39,7 @@ create_bitmap (void)
BITMAP_SIZE,
BITMAP_SIZE,
COGL_PIXEL_FORMAT_RGBA_8888);
buffer = COGL_BUFFER (cogl_bitmap_get_buffer (bitmap));
buffer = cogl_bitmap_get_buffer (bitmap);
g_assert (cogl_is_pixel_buffer (buffer));
g_assert (cogl_is_buffer (buffer));
@ -56,7 +56,7 @@ static CoglBitmap *
create_and_fill_bitmap (void)
{
CoglBitmap *bitmap = create_bitmap ();
CoglBuffer *buffer = COGL_BUFFER (cogl_bitmap_get_buffer (bitmap));
CoglBuffer *buffer = cogl_bitmap_get_buffer (bitmap);
uint8_t *map;
unsigned int stride;
@ -69,7 +69,7 @@ create_and_fill_bitmap (void)
generate_bitmap_data (map, stride);
cogl_buffer_unmap (COGL_BUFFER (buffer));
cogl_buffer_unmap (buffer);
return bitmap;
}
@ -85,7 +85,7 @@ create_texture_from_bitmap (CoglBitmap *bitmap)
g_assert (texture != NULL);
return COGL_TEXTURE (texture);
return texture;
}
static CoglPipeline *
@ -168,7 +168,7 @@ void
test_pixel_buffer_set_data (void)
{
CoglBitmap *bitmap = create_bitmap ();
CoglBuffer *buffer = COGL_BUFFER (cogl_bitmap_get_buffer (bitmap));
CoglBuffer *buffer = cogl_bitmap_get_buffer (bitmap);
CoglPipeline *pipeline;
CoglTexture *texture;
uint8_t *data;
@ -228,7 +228,7 @@ create_white_texture (void)
g_free (data);
return COGL_TEXTURE (texture);
return texture;
}
void

View File

@ -59,7 +59,7 @@ do_test (CoglBool check_orientation,
g_assert (error == NULL);
pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (tex_2d));
cogl_pipeline_set_layer_texture (pipeline, 0, tex_2d);
cogl_pipeline_set_layer_filters (pipeline,
0, /* layer_index */

View File

@ -57,7 +57,7 @@ make_texture (uint32_t color,
g_free (tex_data);
return COGL_TEXTURE (tex_2d);
return tex_2d;
}
static void
@ -97,7 +97,7 @@ check_texture (CoglPipeline *pipeline,
cogl_pop_framebuffer ();
/* New API */
cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (tex));
cogl_pipeline_set_layer_texture (pipeline, 0, tex);
cogl_framebuffer_draw_rectangle (test_fb, pipeline,
x * QUAD_WIDTH,
y * QUAD_WIDTH,

View File

@ -17,7 +17,7 @@ test_read_byte (CoglTexture2D *tex_2d,
{
uint8_t received_byte;
cogl_texture_get_data (COGL_TEXTURE (tex_2d),
cogl_texture_get_data (tex_2d,
format,
1, /* rowstride */
&received_byte);
@ -38,7 +38,7 @@ test_read_short (CoglTexture2D *tex_2d,
char *expected_value_str;
int bits_sum = 0;
cogl_texture_get_data (COGL_TEXTURE (tex_2d),
cogl_texture_get_data (tex_2d,
format,
2, /* rowstride */
(uint8_t *) &received_value);
@ -71,7 +71,7 @@ test_read_888 (CoglTexture2D *tex_2d,
{
uint8_t pixel[4];
cogl_texture_get_data (COGL_TEXTURE (tex_2d),
cogl_texture_get_data (tex_2d,
format,
4, /* rowstride */
pixel);
@ -88,7 +88,7 @@ test_read_8888 (CoglTexture2D *tex_2d,
char *received_value_str;
char *expected_value_str;
cogl_texture_get_data (COGL_TEXTURE (tex_2d),
cogl_texture_get_data (tex_2d,
format,
4, /* rowstride */
(uint8_t *) &received_pixel);
@ -115,7 +115,7 @@ test_read_int (CoglTexture2D *tex_2d,
char *expected_value_str;
int bits_sum = 0;
cogl_texture_get_data (COGL_TEXTURE (tex_2d),
cogl_texture_get_data (tex_2d,
format,
4, /* rowstride */
(uint8_t *) &received_value);

View File

@ -105,14 +105,14 @@ paint (TestState *state)
/* Create a sub texture of the bottom right quarter of the texture */
sub_texture = cogl_sub_texture_new (test_ctx,
COGL_TEXTURE (state->tex),
state->tex,
DIVISION_WIDTH,
DIVISION_HEIGHT,
DIVISION_WIDTH,
DIVISION_HEIGHT);
/* Paint it */
cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (sub_texture));
cogl_pipeline_set_layer_texture (pipeline, 0, sub_texture);
cogl_object_unref (sub_texture);
cogl_framebuffer_draw_rectangle (test_fb, pipeline,
0.0f, 0.0f, DIVISION_WIDTH, DIVISION_HEIGHT);
@ -122,11 +122,11 @@ paint (TestState *state)
documented to be undefined so it doesn't technically have to work
but it will with the current implementation */
sub_texture = cogl_sub_texture_new (test_ctx,
COGL_TEXTURE (state->tex),
state->tex,
0, 0,
SOURCE_SIZE,
DIVISION_HEIGHT);
cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (sub_texture));
cogl_pipeline_set_layer_texture (pipeline, 0, sub_texture);
cogl_object_unref (sub_texture);
cogl_framebuffer_draw_textured_rectangle (test_fb, pipeline,
0.0f,
@ -139,14 +139,14 @@ paint (TestState *state)
/* Create a sub texture of a sub texture */
full_texture = create_test_texture (state);
sub_texture = cogl_sub_texture_new (test_ctx,
COGL_TEXTURE (full_texture),
full_texture,
20, 10, 30, 20);
cogl_object_unref (full_texture);
sub_sub_texture = cogl_sub_texture_new (test_ctx,
COGL_TEXTURE (sub_texture),
sub_texture,
20, 10, 10, 10);
cogl_object_unref (sub_texture);
cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (sub_sub_texture));
cogl_pipeline_set_layer_texture (pipeline, 0, sub_sub_texture);
cogl_object_unref (sub_sub_texture);
cogl_framebuffer_draw_rectangle (test_fb, pipeline,
0.0f, SOURCE_SIZE * 2.0f,
@ -231,15 +231,15 @@ validate_result (TestState *state)
/* Try reading back the texture data */
sub_texture = cogl_sub_texture_new (test_ctx,
COGL_TEXTURE (state->tex),
state->tex,
SOURCE_SIZE / 4,
SOURCE_SIZE / 4,
SOURCE_SIZE / 2,
SOURCE_SIZE / 2);
tex_width = cogl_texture_get_width (COGL_TEXTURE (sub_texture));
tex_height = cogl_texture_get_height (COGL_TEXTURE (sub_texture));
tex_width = cogl_texture_get_width (sub_texture);
tex_height = cogl_texture_get_height (sub_texture);
p = texture_data = g_malloc (tex_width * tex_height * 4);
cogl_texture_get_data (COGL_TEXTURE (sub_texture),
cogl_texture_get_data (sub_texture,
COGL_PIXEL_FORMAT_RGBA_8888,
tex_width * 4,
texture_data);
@ -262,11 +262,11 @@ validate_result (TestState *state)
test_tex = create_test_texture (state);
/* Create a sub texture the views the center half of the texture */
sub_texture = cogl_sub_texture_new (test_ctx,
COGL_TEXTURE (test_tex),
test_tex,
64, 64, 128, 128);
/* Update the center half of the sub texture */
texture_data = create_update_data ();
cogl_texture_set_region (COGL_TEXTURE (sub_texture),
cogl_texture_set_region (sub_texture,
0, 0, 32, 32, 64, 64, 256, 256,
COGL_PIXEL_FORMAT_RGBA_8888_PRE, 256 * 4,
texture_data);
@ -274,7 +274,7 @@ validate_result (TestState *state)
cogl_object_unref (sub_texture);
/* Get the texture data */
p = texture_data = g_malloc (256 * 256 * 4);
cogl_texture_get_data (COGL_TEXTURE (test_tex),
cogl_texture_get_data (test_tex,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
256 * 4, texture_data);

View File

@ -73,7 +73,7 @@ create_texture_3d (CoglContext *context)
static void
draw_frame (TestState *state)
{
CoglTexture *tex = COGL_TEXTURE (create_texture_3d (test_ctx));
CoglTexture *tex = create_texture_3d (test_ctx);
CoglPipeline *pipeline = cogl_pipeline_new (test_ctx);
typedef struct { float x, y, s, t, r; } Vert;
CoglPrimitive *primitive;
@ -221,7 +221,7 @@ test_multi_texture (TestState *state)
4, /* rowstride */
tex_data,
NULL);
cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (tex_2d));
cogl_pipeline_set_layer_texture (pipeline, 0, tex_2d);
tex_data[0] = 0x00;
tex_data[1] = 0xff;
@ -235,7 +235,7 @@ test_multi_texture (TestState *state)
4, /* image_stride */
tex_data,
NULL);
cogl_pipeline_set_layer_texture (pipeline, 1, COGL_TEXTURE (tex_3d));
cogl_pipeline_set_layer_texture (pipeline, 1, tex_3d);
cogl_pipeline_set_layer_combine (pipeline, 0,
"RGBA = REPLACE(PREVIOUS)",

View File

@ -26,7 +26,7 @@ test_texture_no_allocate (void)
/* Try to create an atlas texture that is too big so it will
* internally be freed without allocating */
texture = COGL_TEXTURE (
texture =
cogl_atlas_texture_new_from_data (test_ctx,
BIG_TEX_WIDTH,
BIG_TEX_HEIGHT,
@ -37,7 +37,7 @@ test_texture_no_allocate (void)
/* rowstride */
BIG_TEX_WIDTH * 4,
tex_data,
&error));
&error);
g_free (tex_data);
@ -50,12 +50,12 @@ test_texture_no_allocate (void)
cogl_object_unref (texture);
/* Try to create a sliced texture without allocating it */
texture = COGL_TEXTURE (
texture =
cogl_texture_2d_sliced_new_with_size (test_ctx,
BIG_TEX_WIDTH,
BIG_TEX_HEIGHT,
COGL_TEXTURE_MAX_WASTE,
COGL_PIXEL_FORMAT_RGBA_8888_PRE));
COGL_PIXEL_FORMAT_RGBA_8888_PRE);
cogl_object_unref (texture);
/* 2D texture */

View File

@ -6,7 +6,15 @@
#include "test-utils.h"
#include "config.h"
/* So we can use _COGL_STATIC_ASSERT we include the internal
* cogl-util.h header. Since internal headers explicitly guard against
* applications including them directly instead of including
* <cogl/cogl.h> we define __COGL_H_INSIDE__ here to subvert those
* guards in this case... */
#define __COGL_H_INSIDE__
#include <cogl/cogl-util.h>
#undef __COGL_H_INSIDE__
_COGL_STATIC_ASSERT (COGL_VERSION_ENCODE (COGL_VERSION_MAJOR,
COGL_VERSION_MINOR,

View File

@ -40,7 +40,7 @@ create_base_pipeline (void)
cogl_pipeline_set_layer_texture (pipeline,
0, /* layer */
COGL_TEXTURE (tex));
tex);
cogl_object_unref (tex);

View File

@ -153,7 +153,7 @@ main (int argc, char **argv)
cogl_onscreen_set_swap_throttled (onscreen, FALSE);
cogl_onscreen_show (onscreen);
data.fb = COGL_FRAMEBUFFER (onscreen);
data.fb = onscreen;
cogl_framebuffer_orthographic (data.fb,
0, 0,
FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT,