1
0
Fork 0

Merge commit 'origin/master' into 1.0-integration

Conflicts:
	clutter/clutter-texture.c
	clutter/cogl/gl/cogl-fbo.c
This commit is contained in:
Emmanuele Bassi 2009-05-20 16:49:22 +01:00
commit f8f54989be
110 changed files with 3161 additions and 1782 deletions

9
.gitignore vendored
View file

@ -23,8 +23,8 @@ clutter/stamp-*
/clutter/cogl/*.pc
/clutter/cogl/gles/cogl-fixed-vertex-shader.[ch]
/clutter/cogl/gles/cogl-fixed-fragment-shader.[ch]
/clutter/*.gir
/clutter/*.typelib
*.gir
*.typelib
/clutter/json/*.gir
cogl-defines.h
config.*
@ -43,6 +43,7 @@ doc/reference/clutter/clutter.interfaces
doc/reference/clutter/clutter.prerequisites
doc/reference/clutter/clutter.signals
doc/reference/clutter/*.stamp
doc/reference/clutter/*.bak
doc/reference/cogl/cogl-*.txt
!/doc/reference/cogl/cogl-sections.txt
doc/reference/cogl/html
@ -55,6 +56,7 @@ doc/reference/cogl/cogl.interfaces
doc/reference/cogl/cogl.prerequisites
doc/reference/cogl/cogl.signals
doc/reference/cogl/*.stamp
doc/reference/cogl/*.bak
doltcompile
doltlibtool
gtk-doc.make
@ -128,6 +130,7 @@ stamp-h1
/tests/interactive/redhand_alpha.png
/tests/interactive/test-script.json
/tests/interactive/test-clutter-cairo-flowers
/tests/conform/stamp-test-conformance
/tests/conform/test-anchors
/tests/conform/test-conformance
/tests/conform/test-conformance-results.xml
@ -187,6 +190,7 @@ stamp-h1
/tests/conform/test-vertex-buffer-mutability
/tests/conform/test-list-model-iterate
/tests/conform/test-list-model-populate
/tests/conform/test-list-model-filter
/tests/conform/test-npot-texture
/tests/conform/redhand.png
/tests/conform/test-map-recursive
@ -194,6 +198,7 @@ stamp-h1
/tests/conform/test-shown-not-parented
/tests/micro-bench/test-glyph-perf
/tests/micro-bench/test-text
/tests/micro-bench/test-picking
/tests/tools/disable-npots.sh
/clutter/x11/clutter-x11-enum-types.[ch]
/clutter/x11/stamp-clutter-x11-enum-types.h

31
README
View file

@ -295,8 +295,9 @@ Release Notes for Clutter 1.0
* cogl_clip_set* and cogl_clip_unset have been renamed to cogl_clip_push and
cogl_clip_pop respectively so they self document their stacking semantics.
* cogl_paint_init was renamed to cogl_clear and no longer disables lighting
and fogging.
* cogl_paint_init was renamed to cogl_clear and no longer disables lighting and
fogging. cogl_clear also now takes a mask of the auxiliary buffers you want
to clear so you can avoid redundant clears of buffers you aren't using.
* cogl_fog_set was renamed to cogl_set_fog and it now takes a mode argument
giving control over the fogging blend factor equation, so that the
@ -306,6 +307,32 @@ Release Notes for Clutter 1.0
* cogl_get_*_matrix were changed to use the CoglMatrix type instead of
GLfloat m[16] arrays.
* cogl_offscreen_blit_region, cogl_offscreen_blit were removed since they were
only implemnted for GL, not GLES, and it was assumed no one was using them.
* cogl_offscreen_new_multisample was removed since it only ever returned
COGL_INVALID_HANDLE so it wasn't usefull.
* The COGL_MASK_BUFFER type was removed, since there should be nicer ways of
exposing color mask if anyone wants it later. It was assumed that no one was
using this currently.
* COGLenum, COGLint and COGLuint which were simply typedefs for GL{enum,int,uint}
have been removed from the API and replaced with specialised enum typedefs,
int and unsigned int. These were causing problems for generating bindings and
also considered poor style.
* The cogl texture filter defines CGL_NEAREST and CGL_LINEAR etc are now
replaced by a namespaced typedef 'CoglTextureFilter' so they should be
replaced with COGL_TEXTURE_FILTER_NEAREST and COGL_TEXTURE_FILTER_LINEAR etc.
* The shader type defines CGL_VERTEX_SHADER and CGL_FRAGMENT_SHADER are handled
by a CoglShaderType typedef and should be replaced with
COGL_SHADER_TYPE_VERTEX and COGL_SHADER_TYPE_FRAGMENT.
* cogl_shader_get_parameteriv has been replaced by cogl_shader_get_type and
cogl_shader_is_compiled. More getters can be added later if desired.
Release Notes for Clutter 0.8
-------------------------------

View file

@ -207,16 +207,16 @@ source_h_priv = \
libclutter_@CLUTTER_FLAVOUR@_@CLUTTER_API_VERSION@_la_LIBADD = \
$(CLUTTER_LIBS) \
$(top_builddir)/clutter/cogl/libclutter-cogl.la \
$(top_builddir)/clutter/pango/libcoglpango.la \
$(top_builddir)/clutter/$(CLUTTER_FLAVOUR)/libclutter-$(CLUTTER_FLAVOUR).la \
$(top_builddir)/clutter/cogl/$(CLUTTER_COGL)/libclutter-cogl.la \
$(clutter_json_libadd) \
$(backendextralib)
libclutter_@CLUTTER_FLAVOUR@_@CLUTTER_API_VERSION@_la_DEPENDENCIES = \
$(top_builddir)/clutter/cogl/libclutter-cogl.la \
$(top_builddir)/clutter/pango/libcoglpango.la \
$(top_builddir)/clutter/$(CLUTTER_FLAVOUR)/libclutter-$(CLUTTER_FLAVOUR).la \
$(top_builddir)/clutter/cogl/$(CLUTTER_COGL)/libclutter-cogl.la \
$(clutter_json_dep) \
$(backendextralib)
@ -247,8 +247,8 @@ json_gir_include_path=--add-include-path=json
endif
# We can't reference the list of COGL header files, since they are in a
# subdir Makefile.am, so just extract them from cogl.h instead. The doc comments
# for COGL are in the headers, so we don't need the source files.
# subdir Makefile.am, so just extract them from cogl.h instead. The doc
# comments for COGL are in the headers, so we don't need the source files.
Clutter-@CLUTTER_API_VERSION@.gir: $(INTROSPECTION_SCANNER) libclutter-@CLUTTER_FLAVOUR@-@CLUTTER_API_VERSION@.la
headers=`sed -n "s/#include <cogl\/\([^>]*\)>/\1/p" < $(top_srcdir)/clutter/cogl/cogl.h` ; \
cogl_headers="" ; \
@ -276,11 +276,20 @@ Clutter-@CLUTTER_API_VERSION@.gir: $(INTROSPECTION_SCANNER) libclutter-@CLUTTER_
BUILT_GIRSOURCES += Clutter-@CLUTTER_API_VERSION@.gir
# We build Cogl.gir in the cogl/ subdir, but it needs to reference the shared
# library that it's built into, so we delay compiling the gir into typelib
# until after we've built the shared library. To create the final Cogl.gir
# that we compile and install, we transfer the shared-library="" line from
# Clutter.gir to Cogl.gir
Cogl-@CLUTTER_API_VERSION@.gir: Clutter-@CLUTTER_API_VERSION@.gir cogl/Cogl-@CLUTTER_API_VERSION@.gir
shlib=`sed -n 's/.*shared-library="\([^"]*\)".*/\1/p' < Clutter-@CLUTTER_API_VERSION@.gir` ; \
sed "s/shared-library=\"clutter-cogl\"/shared-library=\"$$shlib\"/"< cogl/Cogl-@CLUTTER_API_VERSION@.gir > $@
BUILT_GIRSOURCES += Cogl-@CLUTTER_API_VERSION@.gir
if LOCAL_JSON_GLIB
# We build ClutterJson.gir in the json/ subdir, but it needs to reference the shared library
# that it's built into, so we delay compiling the gir into typelib until after we've built
# the shared library. To create the final ClutterJson.gir that we compiler and install, we
# transfer the shared-library="" line from Clutter.gir to ClutterJson.gir
# If we are building it, ClutterJson gets the same handling as described
# for Cogl above
ClutterJson-@CLUTTER_API_VERSION@.gir: Clutter-@CLUTTER_API_VERSION@.gir json/ClutterJson-@CLUTTER_API_VERSION@.gir
shlib=`sed -n 's/.*shared-library="\([^"]*\)".*/\1/p' < Clutter-@CLUTTER_API_VERSION@.gir` ; \
sed "s/shared-library=\"clutter-json\"/shared-library=\"$$shlib\"/"< json/ClutterJson-@CLUTTER_API_VERSION@.gir > $@
@ -288,12 +297,13 @@ ClutterJson-@CLUTTER_API_VERSION@.gir: Clutter-@CLUTTER_API_VERSION@.gir json/Cl
BUILT_GIRSOURCES += ClutterJson-@CLUTTER_API_VERSION@.gir
endif
# INTROSPECTION_GIRDIR/INTROSPECTION_TYPELIBDIR aren't the right place to install
# thing - we need to install inside our prefix.
# INTROSPECTION_GIRDIR/INTROSPECTION_TYPELIBDIR aren't the right place to
# install anything - we need to install inside our prefix.
girdir = $(datadir)/gir-1.0
gir_DATA = $(BUILT_GIRSOURCES)
typelibsdir = $(libdir)/girepository-1.0/
typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib)
%.typelib: %.gir $(INTROSPECTION_COMPILER)

View file

@ -54,6 +54,12 @@
* cairo_destroy (cr);
* ]|
*
* Although a new #cairo_t is created each time you call
* clutter_cairo_texture_create() or
* clutter_cairo_texture_create_region(), it uses the same
* #cairo_surface_t each time. You can call
* clutter_cairo_texture_clear() to erase the contents between calls.
*
* <warning><para>Note that you should never use the code above inside the
* #ClutterActor::paint or #ClutterActor::pick virtual functions or
* signal handlers because it will lead to performance
@ -760,3 +766,28 @@ clutter_cairo_texture_get_surface_size (ClutterCairoTexture *self,
if (height)
*height = self->priv->height;
}
/**
* clutter_cairo_texture_clear:
* @self: a #ClutterCairoTexture
*
* Clears @self's internal drawing surface, so that the next upload
* will replace the previous contents of the #ClutterCairoTexture
* rather than adding to it.
*
* Since: 1.0
*/
void
clutter_cairo_texture_clear (ClutterCairoTexture *self)
{
ClutterCairoTexturePrivate *priv;
g_return_if_fail (CLUTTER_IS_CAIRO_TEXTURE (self));
priv = self->priv;
if (!priv->cr_surface_data)
return;
memset (priv->cr_surface_data, 0, priv->height * priv->rowstride);
}

View file

@ -98,8 +98,10 @@ void clutter_cairo_texture_get_surface_size (ClutterCairoTexture *self,
guint *width,
guint *height);
void clutter_cairo_set_source_color (cairo_t *cr,
const ClutterColor *color);
void clutter_cairo_texture_clear (ClutterCairoTexture *self);
void clutter_cairo_set_source_color (cairo_t *cr,
const ClutterColor *color);
G_END_DECLS

View file

@ -95,6 +95,7 @@ clutter_event_get_state (ClutterEvent *event)
case CLUTTER_KEY_RELEASE:
return event->key.modifier_state;
case CLUTTER_BUTTON_PRESS:
case CLUTTER_BUTTON_RELEASE:
return event->button.modifier_state;
case CLUTTER_MOTION:
return event->motion.modifier_state;

View file

@ -81,6 +81,8 @@ typedef struct _ClutterModelIterClass ClutterListModelIterClass;
struct _ClutterListModelPrivate
{
GSequence *sequence;
ClutterModelIter *temp_iter;
};
struct _ClutterListModelIter
@ -214,27 +216,22 @@ clutter_list_model_iter_is_first (ClutterModelIter *iter)
ClutterModelIter *temp_iter;
GSequence *sequence;
GSequenceIter *begin, *end;
guint row;
iter_default = CLUTTER_LIST_MODEL_ITER (iter);
g_assert (iter_default->seq_iter != NULL);
model = clutter_model_iter_get_model (iter);
row = clutter_model_iter_get_row (iter);
sequence = CLUTTER_LIST_MODEL (model)->priv->sequence;
begin = g_sequence_get_begin_iter (sequence);
end = iter_default->seq_iter;
temp_iter = g_object_new (CLUTTER_TYPE_LIST_MODEL_ITER,
"model", model,
NULL);
temp_iter = CLUTTER_LIST_MODEL (model)->priv->temp_iter;
while (!g_sequence_iter_is_begin (begin))
{
CLUTTER_LIST_MODEL_ITER (temp_iter)->seq_iter = begin;
g_object_set (G_OBJECT (temp_iter), "row", row, NULL);
if (clutter_model_filter_iter (model, temp_iter))
{
@ -243,11 +240,8 @@ clutter_list_model_iter_is_first (ClutterModelIter *iter)
}
begin = g_sequence_iter_next (begin);
row += 1;
}
g_object_unref (temp_iter);
/* This is because the 'begin_iter' is always *before* the last valid
* iter, otherwise we'd have endless loops
*/
@ -264,7 +258,6 @@ clutter_list_model_iter_is_last (ClutterModelIter *iter)
ClutterModel *model;
GSequence *sequence;
GSequenceIter *begin, *end;
guint row;
iter_default = CLUTTER_LIST_MODEL_ITER (iter);
g_assert (iter_default->seq_iter != NULL);
@ -273,7 +266,6 @@ clutter_list_model_iter_is_last (ClutterModelIter *iter)
return TRUE;
model = clutter_model_iter_get_model (iter);
row = clutter_model_iter_get_row (iter);
sequence = CLUTTER_LIST_MODEL (model)->priv->sequence;
@ -281,14 +273,11 @@ clutter_list_model_iter_is_last (ClutterModelIter *iter)
begin = g_sequence_iter_prev (begin);
end = iter_default->seq_iter;
temp_iter = g_object_new (CLUTTER_TYPE_LIST_MODEL_ITER,
"model", model,
NULL);
temp_iter = CLUTTER_LIST_MODEL (model)->priv->temp_iter;
while (!g_sequence_iter_is_begin (begin))
{
CLUTTER_LIST_MODEL_ITER (temp_iter)->seq_iter = begin;
g_object_set (G_OBJECT (temp_iter), "row", row, NULL);
if (clutter_model_filter_iter (model, temp_iter))
{
@ -297,11 +286,8 @@ clutter_list_model_iter_is_last (ClutterModelIter *iter)
}
begin = g_sequence_iter_prev (begin);
row += 1;
}
g_object_unref (temp_iter);
/* This is because the 'end_iter' is always *after* the last valid iter.
* Otherwise we'd have endless loops
*/
@ -323,37 +309,31 @@ clutter_list_model_iter_next (ClutterModelIter *iter)
g_assert (iter_default->seq_iter != NULL);
model = clutter_model_iter_get_model (iter);
row = clutter_model_iter_get_row (iter) + 1;
row = clutter_model_iter_get_row (iter);
filter_next = g_sequence_iter_next (iter_default->seq_iter);
g_assert (filter_next != NULL);
temp_iter = g_object_new (CLUTTER_TYPE_LIST_MODEL_ITER,
"model", model,
NULL);
temp_iter = CLUTTER_LIST_MODEL (model)->priv->temp_iter;
while (!g_sequence_iter_is_end (filter_next))
{
CLUTTER_LIST_MODEL_ITER (temp_iter)->seq_iter = filter_next;
g_object_set (G_OBJECT (temp_iter), "row", row, NULL);
if (clutter_model_filter_iter (model, temp_iter))
break;
{
row += 1;
break;
}
filter_next = g_sequence_iter_next (filter_next);
row += 1;
}
g_object_unref (temp_iter);
/* We do this because the 'end_iter' is always *after* the last valid iter.
* Otherwise loops will go on forever
*/
if (filter_next == iter_default->seq_iter)
filter_next = g_sequence_iter_next (filter_next);
if (g_sequence_iter_is_end (filter_next))
row += 1;
/* update the iterator and return it */
g_object_set (G_OBJECT (iter_default), "model", model, "row", row, NULL);
clutter_model_iter_set_row (CLUTTER_MODEL_ITER (iter_default), row);
iter_default->seq_iter = filter_next;
return CLUTTER_MODEL_ITER (iter_default);
@ -372,37 +352,31 @@ clutter_list_model_iter_prev (ClutterModelIter *iter)
g_assert (iter_default->seq_iter != NULL);
model = clutter_model_iter_get_model (iter);
row = clutter_model_iter_get_row (iter) - 1;
row = clutter_model_iter_get_row (iter);
filter_prev = g_sequence_iter_prev (iter_default->seq_iter);
g_assert (filter_prev != NULL);
temp_iter = g_object_new (CLUTTER_TYPE_LIST_MODEL_ITER,
"model", model,
NULL);
temp_iter = CLUTTER_LIST_MODEL (model)->priv->temp_iter;
while (!g_sequence_iter_is_begin (filter_prev))
{
CLUTTER_LIST_MODEL_ITER (temp_iter)->seq_iter = filter_prev;
g_object_set (G_OBJECT (temp_iter), "row", row, NULL);
if (clutter_model_filter_iter (model, temp_iter))
break;
{
row -= 1;
break;
}
filter_prev = g_sequence_iter_prev (filter_prev);
row -= 1;
}
g_object_unref (temp_iter);
/* We do this because the 'end_iter' is always *after* the last valid iter.
* Otherwise loops will go on forever
*/
if (filter_prev == iter_default->seq_iter)
filter_prev = g_sequence_iter_prev (filter_prev);
if (g_sequence_iter_is_begin (filter_prev))
row -= 1;
/* update the iterator and return it */
g_object_set (G_OBJECT (iter_default), "model", model, "row", row, NULL);
clutter_model_iter_set_row (CLUTTER_MODEL_ITER (iter_default), row);
iter_default->seq_iter = filter_prev;
return CLUTTER_MODEL_ITER (iter_default);
@ -466,16 +440,73 @@ clutter_list_model_get_iter_at_row (ClutterModel *model,
{
ClutterListModel *model_default = CLUTTER_LIST_MODEL (model);
GSequence *sequence = model_default->priv->sequence;
gint seq_length = g_sequence_get_length (sequence);
ClutterListModelIter *retval;
if (row >= g_sequence_get_length (sequence))
if (row >= seq_length)
return NULL;
retval = g_object_new (CLUTTER_TYPE_LIST_MODEL_ITER,
"model", model,
"row", row,
NULL);
retval->seq_iter = g_sequence_get_iter_at_pos (sequence, row);
/* short-circuit in case we don't have a filter in place */
if (!clutter_model_get_filter_set (model))
{
retval->seq_iter = g_sequence_get_iter_at_pos (sequence, row);
return CLUTTER_MODEL_ITER (retval);
}
if (row == 0)
{
GSequenceIter *filter_next;
gboolean row_found = FALSE;
filter_next = g_sequence_get_begin_iter (sequence);
g_assert (filter_next != NULL);
while (!g_sequence_iter_is_end (filter_next))
{
retval->seq_iter = filter_next;
if (clutter_model_filter_iter (model, CLUTTER_MODEL_ITER (retval)))
{
/* We've found a row that is valid under the filter */
row_found = TRUE;
break;
}
filter_next = g_sequence_iter_next (filter_next);
}
/* Everything has been filtered -> there is no first row */
if (!row_found)
{
g_object_unref (retval);
return NULL;
}
}
else
{
GSequenceIter *filter_prev;
filter_prev = g_sequence_get_end_iter (sequence);
g_assert (filter_prev != NULL);
filter_prev = g_sequence_iter_prev (filter_prev);
while (!g_sequence_iter_is_begin (filter_prev))
{
retval->seq_iter = filter_prev;
if (clutter_model_filter_iter (model, CLUTTER_MODEL_ITER (retval)))
break;
filter_prev = g_sequence_iter_prev (filter_prev);
}
}
return CLUTTER_MODEL_ITER (retval);
}
@ -507,7 +538,7 @@ clutter_list_model_insert_row (ClutterModel *model,
if (index_ < 0)
{
seq_iter = g_sequence_append (sequence, array);
pos = g_sequence_get_length (sequence);
pos = g_sequence_get_length (sequence) - 1;
}
else if (index_ == 0)
{
@ -574,14 +605,6 @@ clutter_list_model_remove_row (ClutterModel *model,
}
}
static guint
clutter_list_model_get_n_rows (ClutterModel *model)
{
ClutterListModel *model_default = CLUTTER_LIST_MODEL (model);
return g_sequence_get_length (model_default->priv->sequence);
}
typedef struct
{
ClutterModel *model;
@ -658,6 +681,20 @@ clutter_list_model_finalize (GObject *gobject)
G_OBJECT_CLASS (clutter_list_model_parent_class)->finalize (gobject);
}
static void
clutter_list_model_dispose (GObject *gobject)
{
ClutterListModel *model = CLUTTER_LIST_MODEL (gobject);
if (model->priv->temp_iter)
{
g_object_unref (model->priv->temp_iter);
model->priv->temp_iter = NULL;
}
G_OBJECT_CLASS (clutter_list_model_parent_class)->dispose (gobject);
}
static void
clutter_list_model_class_init (ClutterListModelClass *klass)
{
@ -667,8 +704,8 @@ clutter_list_model_class_init (ClutterListModelClass *klass)
g_type_class_add_private (klass, sizeof (ClutterListModelPrivate));
gobject_class->finalize = clutter_list_model_finalize;
gobject_class->dispose = clutter_list_model_dispose;
model_class->get_n_rows = clutter_list_model_get_n_rows;
model_class->get_iter_at_row = clutter_list_model_get_iter_at_row;
model_class->insert_row = clutter_list_model_insert_row;
model_class->remove_row = clutter_list_model_remove_row;
@ -683,6 +720,10 @@ clutter_list_model_init (ClutterListModel *model)
model->priv = CLUTTER_LIST_MODEL_GET_PRIVATE (model);
model->priv->sequence = g_sequence_new (NULL);
model->priv->temp_iter = g_object_new (CLUTTER_TYPE_LIST_MODEL_ITER,
"model",
model,
NULL);
}
/**

View file

@ -373,13 +373,17 @@ _clutter_do_pick (ClutterStage *stage,
/* needed for when a context switch happens */
_clutter_stage_maybe_setup_viewport (stage);
cogl_clip_push_window_rect (x, y, 1, 1);
cogl_color_set_from_4ub (&white, 255, 255, 255, 255);
cogl_disable_fog ();
cogl_clear (&white);
cogl_clear (&white,
COGL_BUFFER_BIT_COLOR |
COGL_BUFFER_BIT_DEPTH);
/* Disable dithering (if any) when doing the painting in pick mode */
dither_was_on = glIsEnabled (GL_DITHER);
glDisable (GL_DITHER);
if (dither_was_on)
glDisable (GL_DITHER);
/* Render the entire scence in pick mode - just single colored silhouette's
* are drawn offscreen (as we never swap buffers)
@ -387,15 +391,11 @@ _clutter_do_pick (ClutterStage *stage,
context->pick_mode = mode;
clutter_actor_paint (CLUTTER_ACTOR (stage));
context->pick_mode = CLUTTER_PICK_NONE;
cogl_clip_pop ();
/* Calls should work under both GL and GLES, note GLES needs RGBA */
glGetIntegerv(GL_VIEWPORT, viewport);
/* Below to be safe, particularly on GL ES. an EGL wait call or full
* could be nicer.
*/
glFinish();
/* Read the color of the screen co-ords pixel */
glReadPixels (x, viewport[3] - y -1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);

View file

@ -19,6 +19,9 @@ void clutter_model_set_column_name (ClutterModel *model,
gint column,
const gchar *name);
void clutter_model_iter_set_row (ClutterModelIter *iter,
guint row);
G_END_DECLS
#endif /* __CLUTTER_MODEL_PRIVATE_H__ */

View file

@ -133,9 +133,15 @@
#include "clutter-private.h"
#include "clutter-debug.h"
G_DEFINE_ABSTRACT_TYPE (ClutterModel, clutter_model, G_TYPE_OBJECT);
enum
{
PROP_0,
PROP_FILTER_SET
};
enum
{
ROW_ADDED,
@ -202,28 +208,6 @@ clutter_model_real_get_n_columns (ClutterModel *model)
return model->priv->n_columns;
}
static guint
clutter_model_real_get_n_rows (ClutterModel *model)
{
ClutterModelIter *iter;
guint n_rows = 0;
iter = clutter_model_get_first_iter (model);
if (!iter)
return 0;
while (!clutter_model_iter_is_last (iter))
{
n_rows += 1;
clutter_model_iter_next (iter);
}
g_object_unref (iter);
return n_rows;
}
static void
clutter_model_finalize (GObject *object)
{
@ -249,11 +233,33 @@ clutter_model_finalize (GObject *object)
G_OBJECT_CLASS (clutter_model_parent_class)->finalize (object);
}
static void
clutter_model_get_property (GObject *gobject,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
ClutterModelPrivate *priv = CLUTTER_MODEL (gobject)->priv;
switch (prop_id)
{
case PROP_FILTER_SET:
g_value_set_boolean (value, priv->filter_func != NULL);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
}
}
static void
clutter_model_class_init (ClutterModelClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GParamSpec *pspec;
gobject_class->get_property = clutter_model_get_property;
gobject_class->finalize = clutter_model_finalize;
g_type_class_add_private (gobject_class, sizeof (ClutterModelPrivate));
@ -261,7 +267,23 @@ clutter_model_class_init (ClutterModelClass *klass)
klass->get_column_name = clutter_model_real_get_column_name;
klass->get_column_type = clutter_model_real_get_column_type;
klass->get_n_columns = clutter_model_real_get_n_columns;
klass->get_n_rows = clutter_model_real_get_n_rows;
/**
* ClutterModel:filter-set:
*
* Whether the #ClutterModel has a filter set
*
* This property is set to %TRUE if a filter function has been
* set using clutter_model_set_filter()
*
* Since: 1.0
*/
pspec = g_param_spec_boolean ("filter-set",
"Filter Set",
"Whether the model has a filter",
FALSE,
CLUTTER_PARAM_READABLE);
g_object_class_install_property (gobject_class, PROP_FILTER_SET, pspec);
/**
* ClutterModel::row-added:
@ -419,6 +441,8 @@ clutter_model_check_type (GType gtype)
return FALSE;
}
/**
* clutter_model_resort:
* @model: a #ClutterModel
@ -474,7 +498,7 @@ clutter_model_filter_row (ClutterModel *model,
return TRUE;
iter = clutter_model_get_iter_at_row (model, row);
if (!iter)
if (iter == NULL)
return FALSE;
res = priv->filter_func (model, iter, priv->filter_data);
@ -1117,6 +1141,10 @@ clutter_model_get_column_type (ClutterModel *model,
*
* Retrieves a #ClutterModelIter representing the row at the given index.
*
* If a filter function has been set using clutter_model_set_filter()
* then the @model implementation will return the first non filtered
* row.
*
* Return value: (transfer full): A new #ClutterModelIter, or %NULL if @row was
* out of bounds. When done using the iterator object, call g_object_unref()
* to deallocate its resources
@ -1143,49 +1171,65 @@ clutter_model_get_iter_at_row (ClutterModel *model,
* clutter_model_get_first_iter:
* @model: a #ClutterModel
*
* Retrieves a #ClutterModelIter representing the first row in @model.
* Retrieves a #ClutterModelIter representing the first non-filtered
* row in @model.
*
* Return value: (transfer full): A new #ClutterModelIter. Call g_object_unref() when
* done using it
* Return value: (transfer full): A new #ClutterModelIter.
* Call g_object_unref() when done using it
*
* Since: 0.6
*/
ClutterModelIter *
clutter_model_get_first_iter (ClutterModel *model)
{
ClutterModelIter *retval;
g_return_val_if_fail (CLUTTER_IS_MODEL (model), NULL);
return clutter_model_get_iter_at_row (model, 0);
retval = clutter_model_get_iter_at_row (model, 0);
if (retval != NULL)
{
g_assert (clutter_model_filter_iter (model, retval) != FALSE);
g_assert (clutter_model_iter_get_row (retval) == 0);
}
return retval;
}
/**
* clutter_model_get_last_iter:
* @model: a #ClutterModel
*
* Retrieves a #ClutterModelIter representing the last row in @model.
* Retrieves a #ClutterModelIter representing the last non-filtered
* row in @model.
*
* Return value: (transfer full): A new #ClutterModelIter. Call g_object_unref() when
* done using it
* Return value: (transfer full): A new #ClutterModelIter.
* Call g_object_unref() when done using it
*
* Since: 0.6
*/
ClutterModelIter *
clutter_model_get_last_iter (ClutterModel *model)
{
ClutterModelIter *retval;
guint length;
g_return_val_if_fail (CLUTTER_IS_MODEL (model), NULL);
length = clutter_model_get_n_rows (model);
retval = clutter_model_get_iter_at_row (model, length - 1);
if (retval != NULL)
g_assert (clutter_model_filter_iter (model, retval) != FALSE);
return clutter_model_get_iter_at_row (model, length - 1);
return retval;
}
/**
* clutter_model_get_n_rows:
* @model: a #ClutterModel
*
* Retrieves the number of rows inside @model.
* Retrieves the number of rows inside @model, eventually taking
* into account any filtering function set using clutter_model_set_filter().
*
* Return value: The length of the @model. If there is a filter set, then
* the length of the filtered @model is returned.
@ -1195,9 +1239,35 @@ clutter_model_get_last_iter (ClutterModel *model)
guint
clutter_model_get_n_rows (ClutterModel *model)
{
ClutterModelClass *klass;
guint row_count;
g_return_val_if_fail (CLUTTER_IS_MODEL (model), 0);
return CLUTTER_MODEL_GET_CLASS (model)->get_n_rows (model);
klass = CLUTTER_MODEL_GET_CLASS (model);
if (klass->get_n_rows)
row_count = klass->get_n_rows (model);
else
{
ClutterModelIter *iter;
iter = clutter_model_get_first_iter (model);
if (iter == NULL)
return 0;
row_count = 0;
while (!clutter_model_iter_is_last (iter))
{
if (clutter_model_filter_iter (model, iter))
row_count += 1;
iter = clutter_model_iter_next (iter);
}
g_object_unref (iter);
}
return row_count;
}
@ -1313,6 +1383,9 @@ clutter_model_set_sort (ClutterModel *model,
ClutterModelPrivate *priv;
g_return_if_fail (CLUTTER_IS_MODEL (model));
g_return_if_fail ((func != NULL && column >= 0) ||
(func == NULL && column == -1));
priv = model->priv;
if (priv->sort_notify)
@ -1356,6 +1429,26 @@ clutter_model_set_filter (ClutterModel *model,
priv->filter_notify = notify;
g_signal_emit (model, model_signals[FILTER_CHANGED], 0);
g_object_notify (G_OBJECT (model), "filter-set");
}
/**
* clutter_model_get_filter_set:
* @model: a #ClutterModel
*
* Returns whether the @model has a filter in place, set
* using clutter_model_set_filter()
*
* Return value: %TRUE if a filter is set
*
* Since: 1.0
*/
gboolean
clutter_model_get_filter_set (ClutterModel *model)
{
g_return_val_if_fail (CLUTTER_IS_MODEL (model), FALSE);
return model->priv->filter_func != NULL;
}
/*
@ -1418,6 +1511,14 @@ clutter_model_iter_real_get_row (ClutterModelIter *iter)
return iter->priv->row;
}
/* private function */
void
clutter_model_iter_set_row (ClutterModelIter *iter,
guint row)
{
iter->priv->row = row;
}
static void
clutter_model_iter_get_value_unimplemented (ClutterModelIter *iter,
guint column,
@ -1539,7 +1640,8 @@ clutter_model_iter_set_property (GObject *object,
static void
clutter_model_iter_class_init (ClutterModelIterClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GParamSpec *pspec;
gobject_class->get_property = clutter_model_iter_get_property;
gobject_class->set_property = clutter_model_iter_set_property;
@ -1563,28 +1665,26 @@ clutter_model_iter_class_init (ClutterModelIterClass *klass)
*
* Since: 0.6
*/
g_object_class_install_property (gobject_class,
ITER_PROP_MODEL,
g_param_spec_object ("model",
"Model",
"The model to which the iterator belongs to",
CLUTTER_TYPE_MODEL,
CLUTTER_PARAM_READWRITE));
pspec = g_param_spec_object ("model",
"Model",
"The model to which the iterator belongs to",
CLUTTER_TYPE_MODEL,
CLUTTER_PARAM_READWRITE);
g_object_class_install_property (gobject_class, ITER_PROP_MODEL, pspec);
/**
/**
* ClutterModelIter:row:
*
* The row number to which this iter points to.
*
* Since: 0.6
*/
g_object_class_install_property (gobject_class,
ITER_PROP_ROW,
g_param_spec_uint ("row",
"Row",
"The row to which the iterator points to",
0, G_MAXUINT, 0,
CLUTTER_PARAM_READWRITE));
pspec = g_param_spec_uint ("row",
"Row",
"The row to which the iterator points to",
0, G_MAXUINT, 0,
CLUTTER_PARAM_READWRITE);
g_object_class_install_property (gobject_class, ITER_PROP_ROW, pspec);
g_type_class_add_private (gobject_class, sizeof (ClutterModelIterPrivate));
}

View file

@ -129,7 +129,7 @@ struct _ClutterModel
* @get_iter_at_row: virtual function for returning an iterator for the
* given row
* @get_n_rows: virtual function for returning the number of rows
* of the model, not considering any filter function if present
* of the model
* @get_n_columns: virtual function for retuning the number of columns
* of the model
* @resort: virtual function for sorting the model using the passed
@ -177,11 +177,15 @@ struct _ClutterModelClass
void (* filter_changed) (ClutterModel *model);
/*< private >*/
/* padding for future */
/* padding for future expansion */
void (*_clutter_model_1) (void);
void (*_clutter_model_2) (void);
void (*_clutter_model_3) (void);
void (*_clutter_model_4) (void);
void (*_clutter_model_5) (void);
void (*_clutter_model_6) (void);
void (*_clutter_model_7) (void);
void (*_clutter_model_8) (void);
};
GType clutter_model_get_type (void) G_GNUC_CONST;
@ -248,6 +252,7 @@ void clutter_model_set_filter (ClutterModel *model,
ClutterModelFilterFunc func,
gpointer user_data,
GDestroyNotify notify);
gboolean clutter_model_get_filter_set (ClutterModel *model);
void clutter_model_resort (ClutterModel *model);
gboolean clutter_model_filter_row (ClutterModel *model,
@ -333,11 +338,15 @@ struct _ClutterModelIterClass
ClutterModelIter *(* copy) (ClutterModelIter *iter);
/*< private >*/
/* padding for future */
/* padding for future expansion */
void (*_clutter_model_iter_1) (void);
void (*_clutter_model_iter_2) (void);
void (*_clutter_model_iter_3) (void);
void (*_clutter_model_iter_4) (void);
void (*_clutter_model_iter_5) (void);
void (*_clutter_model_iter_6) (void);
void (*_clutter_model_iter_7) (void);
void (*_clutter_model_iter_8) (void);
};
GType clutter_model_iter_get_type (void) G_GNUC_CONST;

View file

@ -88,7 +88,7 @@ struct _ClutterShaderFloat
struct _ClutterShaderInt
{
gint size;
COGLint value[4];
int value[4];
};
struct _ClutterShaderMatrix
@ -223,7 +223,7 @@ clutter_value_collect_shader_int (GValue *value,
guint collect_flags)
{
gint int_count = collect_values[0].v_int;
const COGLint *ints = collect_values[1].v_pointer;
const int *ints = collect_values[1].v_pointer;
if (!ints)
return g_strdup_printf ("value location for '%s' passed as NULL",
@ -242,7 +242,7 @@ clutter_value_lcopy_shader_int (const GValue *value,
guint collect_flags)
{
gint *int_count = collect_values[0].v_pointer;
COGLint **ints = collect_values[1].v_pointer;
int **ints = collect_values[1].v_pointer;
ClutterShaderInt *shader_int = value->data[0].v_pointer;
if (!int_count || !ints)
@ -250,7 +250,7 @@ clutter_value_lcopy_shader_int (const GValue *value,
G_VALUE_TYPE_NAME (value));
*int_count = shader_int->size;
*ints = g_memdup (shader_int->value, shader_int->size * sizeof (COGLint));
*ints = g_memdup (shader_int->value, shader_int->size * sizeof (int));
return NULL;
}
@ -514,7 +514,7 @@ clutter_value_get_shader_float (const GValue *value,
*
* Since: 0.8
*/
G_CONST_RETURN COGLint *
G_CONST_RETURN int *
clutter_value_get_shader_int (const GValue *value,
gsize *length)
{

View file

@ -86,7 +86,7 @@ void clutter_value_set_shader_matrix (GValue *value,
const gfloat *matrix);
G_CONST_RETURN gfloat * clutter_value_get_shader_float (const GValue *value,
gsize *length);
G_CONST_RETURN COGLint *clutter_value_get_shader_int (const GValue *value,
G_CONST_RETURN gint * clutter_value_get_shader_int (const GValue *value,
gsize *length);
G_CONST_RETURN gfloat * clutter_value_get_shader_matrix (const GValue *value,
gsize *length);

View file

@ -427,20 +427,19 @@ clutter_shader_glsl_bind (ClutterShader *self,
GError **error)
{
ClutterShaderPrivate *priv = self->priv;
GLint is_compiled = CGL_FALSE;
CoglHandle shader = COGL_INVALID_HANDLE;
switch (shader_type)
{
case CLUTTER_VERTEX_SHADER:
shader = cogl_create_shader (CGL_VERTEX_SHADER);
shader = cogl_create_shader (COGL_SHADER_TYPE_VERTEX);
cogl_shader_source (shader, priv->vertex_source);
priv->vertex_shader = shader;
break;
case CLUTTER_FRAGMENT_SHADER:
shader = cogl_create_shader (CGL_FRAGMENT_SHADER);
shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT);
cogl_shader_source (shader, priv->fragment_source);
priv->fragment_shader = shader;
@ -450,11 +449,7 @@ clutter_shader_glsl_bind (ClutterShader *self,
g_assert (shader != COGL_INVALID_HANDLE);
cogl_shader_compile (shader);
cogl_shader_get_parameteriv (shader,
CGL_OBJECT_COMPILE_STATUS,
&is_compiled);
if (is_compiled != CGL_TRUE)
if (!cogl_shader_is_compiled (shader))
{
gchar error_buf[512];
@ -739,7 +734,7 @@ clutter_shader_set_uniform (ClutterShader *shader,
}
else if (CLUTTER_VALUE_HOLDS_SHADER_INT (value))
{
const COGLint *ints;
const int *ints;
ints = clutter_value_get_shader_int (value, &size);
cogl_program_uniform_int (location, size, 1, ints);
@ -759,7 +754,7 @@ clutter_shader_set_uniform (ClutterShader *shader,
}
else if (G_VALUE_HOLDS_INT (value))
{
COGLint int_val = g_value_get_int (value);
int int_val = g_value_get_int (value);
cogl_program_uniform_int (location, 1, 1, &int_val);
}

View file

@ -233,7 +233,9 @@ clutter_stage_paint (ClutterActor *self)
priv->color.green,
priv->color.blue,
priv->color.alpha);
cogl_clear (&stage_color);
cogl_clear (&stage_color,
COGL_BUFFER_BIT_COLOR |
COGL_BUFFER_BIT_DEPTH);
if (priv->use_fog)
{

View file

@ -284,6 +284,7 @@ clutter_text_create_layout_no_cache (ClutterText *text,
pango_layout_set_alignment (layout, priv->alignment);
pango_layout_set_single_paragraph_mode (layout, priv->single_line_mode);
pango_layout_set_justify (layout, priv->justify);
pango_layout_set_wrap (layout, priv->wrap_mode);
/* Cases, assuming ellipsize != NONE on actor:
*
@ -309,11 +310,14 @@ clutter_text_create_layout_no_cache (ClutterText *text,
}
}
/* we do not limit the layout width on editable, single-line
* text actors, since those can scroll the layout
/* We do not limit the layout width on editable, single-line text
* actors, since those can scroll the layout. For non-editable
* actors we only want to set the width if wrapping or ellipsizing
* is enabled.
*/
if (allocation_width > 0 &&
!(priv->editable && priv->single_line_mode))
(priv->editable ? !priv->single_line_mode
: (priv->ellipsize != PANGO_ELLIPSIZE_NONE || priv->wrap)))
{
gint width;
@ -459,6 +463,10 @@ clutter_text_coords_to_position (ClutterText *text,
gint px, py;
gint trailing;
/* Take any offset due to scrolling into account */
if (text->priv->single_line_mode)
x += text->priv->text_x * -1;
px = x * PANGO_SCALE;
py = y * PANGO_SCALE;
@ -528,7 +536,13 @@ clutter_text_position_to_coords (ClutterText *self,
&rect, NULL);
if (x)
*x = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.x);
{
*x = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.x);
/* Take any offset due to scrolling into account */
if (priv->single_line_mode)
*x += priv->text_x;
}
if (y)
*y = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.y);
@ -970,6 +984,12 @@ cursor_paint (ClutterText *self)
range_x = ranges[i * 2]
/ PANGO_SCALE;
/* Account for any scrolling in single line mode */
if (priv->single_line_mode)
range_x += priv->text_x;
range_width = (ranges[i * 2 + 1] - ranges[i * 2])
/ PANGO_SCALE;
@ -1375,34 +1395,38 @@ clutter_text_paint (ClutterActor *self)
if (priv->position == -1)
{
text_x = actor_width - text_width;
priv->cursor_pos.x += text_x + TEXT_PADDING;
}
else if (priv->position == 0)
{
text_x = 0;
text_x = TEXT_PADDING;
}
else
{
if (text_x <= 0)
if (cursor_x < 0)
{
gint diff = -1 * text_x;
if (cursor_x < diff)
text_x += diff - cursor_x;
else if (cursor_x > (diff + actor_width))
text_x -= cursor_x - (diff - actor_width);
text_x = text_x - cursor_x - TEXT_PADDING;
}
else if (cursor_x > actor_width)
{
text_x = text_x + (actor_width - cursor_x) - TEXT_PADDING;
}
}
/* Update the absolute cursor position as it may have moved due to
* scrolling */
priv->text_x = text_x;
clutter_text_ensure_cursor_position (text);
}
else
{
text_x = 0;
priv->cursor_pos.x += text_x + TEXT_PADDING;
text_x = TEXT_PADDING;
}
}
else
text_x = 0;
priv->text_x = text_x;
cursor_paint (text);
real_opacity = clutter_actor_get_paint_opacity (self)
@ -1421,7 +1445,6 @@ clutter_text_paint (ClutterActor *self)
if (clip_set)
cogl_clip_pop ();
priv->text_x = text_x;
}
static void
@ -1460,7 +1483,12 @@ clutter_text_get_preferred_width (ClutterActor *self,
}
if (natural_width_p)
*natural_width_p = layout_width;
{
if (priv->editable && priv->single_line_mode)
*natural_width_p = layout_width + TEXT_PADDING * 2;
else
*natural_width_p = layout_width;
}
}
static void
@ -1469,7 +1497,7 @@ clutter_text_get_preferred_height (ClutterActor *self,
gfloat *min_height_p,
gfloat *natural_height_p)
{
ClutterText *text = CLUTTER_TEXT (self);
ClutterTextPrivate *priv = CLUTTER_TEXT (self)->priv;
if (for_width == 0)
{
@ -1486,7 +1514,8 @@ clutter_text_get_preferred_height (ClutterActor *self,
gint logical_height;
gfloat layout_height;
layout = clutter_text_create_layout (text, for_width, -1);
layout = clutter_text_create_layout (CLUTTER_TEXT (self),
for_width, -1);
pango_layout_get_extents (layout, NULL, &logical_rect);
@ -1495,13 +1524,26 @@ clutter_text_get_preferred_height (ClutterActor *self,
* the height accordingly
*/
logical_height = logical_rect.y + logical_rect.height;
layout_height = CLUTTER_UNITS_FROM_PANGO_UNIT (logical_height);
if (min_height_p)
{
if (text->priv->ellipsize)
*min_height_p = 1;
/* if we wrap and ellipsize then the minimum height is
* going to be at least the size of the first line
*/
if (priv->ellipsize && priv->wrap)
{
PangoLayoutLine *line;
ClutterUnit line_height;
line = pango_layout_get_line_readonly (layout, 0);
pango_layout_line_get_extents (line, NULL, &logical_rect);
logical_height = logical_rect.y + logical_rect.height;
line_height = CLUTTER_UNITS_FROM_PANGO_UNIT (logical_height);
*min_height_p = line_height;
}
else
*min_height_p = layout_height;
}
@ -1772,17 +1814,17 @@ clutter_text_real_del_prev (ClutterText *self,
{
if (pos == -1)
{
clutter_text_set_cursor_position (self, len - 1);
clutter_text_set_selection_bound (self, len - 1);
clutter_text_delete_text (self, len - 1, len);
clutter_text_set_cursor_position (self, -1);
clutter_text_set_selection_bound (self, -1);
}
else
{
clutter_text_delete_text (self, pos - 1, pos);
clutter_text_set_cursor_position (self, pos - 1);
clutter_text_set_selection_bound (self, pos - 1);
clutter_text_delete_text (self, pos - 1, pos);
}
}
@ -2880,7 +2922,8 @@ clutter_text_get_selection (ClutterText *self)
if (end_index == start_index)
return g_strdup ("");
if (end_index < start_index)
if ((end_index != -1 && end_index < start_index) ||
start_index == -1)
{
gint temp = start_index;
start_index = end_index;
@ -3147,6 +3190,8 @@ clutter_text_set_text_internal (ClutterText *self,
{
ClutterTextPrivate *priv = self->priv;
g_object_freeze_notify (G_OBJECT (self));
if (priv->max_length > 0)
{
gint len = g_utf8_strlen (text, -1);
@ -3182,8 +3227,16 @@ clutter_text_set_text_internal (ClutterText *self,
priv->n_chars = g_utf8_strlen (text, -1);
}
if (priv->n_bytes == 0)
{
clutter_text_set_cursor_position (self, -1);
clutter_text_set_selection_bound (self, -1);
}
g_signal_emit (self, text_signals[TEXT_CHANGED], 0);
g_object_notify (G_OBJECT (self), "text");
g_object_thaw_notify (G_OBJECT (self));
}
static inline void

View file

@ -82,7 +82,6 @@ struct _ClutterTexturePrivate
gint max_tile_waste;
ClutterTextureQuality filter_quality;
CoglHandle material;
CoglHandle fbo_texture;
gboolean no_slice;
ClutterActor *fbo_source;
@ -128,7 +127,7 @@ struct _ClutterTextureAsyncData
guint load_idle;
gchar *load_filename;
CoglBitmap *load_bitmap;
CoglHandle load_bitmap;
GError *load_error;
};
@ -188,18 +187,18 @@ clutter_texture_quality_to_filters (ClutterTextureQuality quality,
switch (quality)
{
case CLUTTER_TEXTURE_QUALITY_LOW:
min_filter = CGL_NEAREST;
mag_filter = CGL_NEAREST;
min_filter = COGL_TEXTURE_FILTER_NEAREST;
mag_filter = COGL_TEXTURE_FILTER_NEAREST;
break;
case CLUTTER_TEXTURE_QUALITY_MEDIUM:
min_filter = CGL_LINEAR;
mag_filter = CGL_LINEAR;
min_filter = COGL_TEXTURE_FILTER_LINEAR;
mag_filter = COGL_TEXTURE_FILTER_LINEAR;
break;
case CLUTTER_TEXTURE_QUALITY_HIGH:
min_filter = CGL_LINEAR_MIPMAP_LINEAR;
mag_filter = CGL_LINEAR;
min_filter = COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR;
mag_filter = COGL_TEXTURE_FILTER_LINEAR;
break;
}
@ -289,31 +288,34 @@ clutter_texture_realize (ClutterActor *actor)
CoglTextureFlags flags = COGL_TEXTURE_NONE;
gint min_filter, mag_filter;
gint max_waste = -1;
CoglHandle tex;
/* Handle FBO's */
if (priv->fbo_texture != COGL_INVALID_HANDLE)
cogl_handle_unref (priv->fbo_texture);
if (!priv->no_slice)
max_waste = priv->max_tile_waste;
if (priv->filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH)
flags |= COGL_TEXTURE_AUTO_MIPMAP;
priv->fbo_texture =
cogl_texture_new_with_size (priv->width,
priv->height,
max_waste, flags,
COGL_PIXEL_FORMAT_RGBA_8888);
tex = cogl_texture_new_with_size (priv->width,
priv->height,
max_waste, flags,
COGL_PIXEL_FORMAT_RGBA_8888);
cogl_material_set_layer (priv->material, 0, tex);
clutter_texture_quality_to_filters (priv->filter_quality,
&min_filter,
&mag_filter);
cogl_texture_set_filters (priv->fbo_texture, min_filter, mag_filter);
cogl_texture_set_filters (tex, min_filter, mag_filter);
priv->fbo_handle = cogl_offscreen_new_to_texture (priv->fbo_texture);
priv->fbo_handle = cogl_offscreen_new_to_texture (tex);
/* The material now has a reference to the texture so it will
stick around */
cogl_handle_unref (tex);
if (priv->fbo_handle == COGL_INVALID_HANDLE)
{
@ -544,7 +546,7 @@ clutter_texture_paint (ClutterActor *self)
clutter_shader_set_is_enabled (shader, FALSE);
/* Redirect drawing to the fbo */
cogl_draw_buffer (COGL_OFFSCREEN_BUFFER, priv->fbo_handle);
cogl_set_draw_buffer (COGL_OFFSCREEN_BUFFER, priv->fbo_handle);
if ((stage = clutter_actor_get_stage (self)))
{
@ -575,7 +577,9 @@ clutter_texture_paint (ClutterActor *self)
/* cogl_clear is called to clear the buffers */
cogl_color_set_from_4ub (&transparent_col, 0, 0, 0, 0);
cogl_clear (&transparent_col);
cogl_clear (&transparent_col,
COGL_BUFFER_BIT_COLOR |
COGL_BUFFER_BIT_DEPTH);
cogl_disable_fog ();
/* Clear the clipping stack so that if the FBO actor is being
@ -588,7 +592,7 @@ clutter_texture_paint (ClutterActor *self)
cogl_clip_stack_restore ();
/* Restore drawing to the frame buffer */
cogl_draw_buffer (COGL_WINDOW_BUFFER, COGL_INVALID_HANDLE);
cogl_set_draw_buffer (COGL_WINDOW_BUFFER, COGL_INVALID_HANDLE);
/* Restore the perspective matrix using cogl_perspective so that
the inverse matrix will be right */
@ -653,7 +657,7 @@ clutter_texture_async_data_free (ClutterTextureAsyncData *data)
g_free (data->load_filename);
if (data->load_bitmap)
cogl_bitmap_free (data->load_bitmap);
cogl_handle_unref (data->load_bitmap);
if (data->load_error)
g_error_free (data->load_error);
@ -763,83 +767,83 @@ clutter_texture_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
ClutterTexture *texture;
ClutterTexture *texture;
ClutterTexturePrivate *priv;
texture = CLUTTER_TEXTURE(object);
texture = CLUTTER_TEXTURE (object);
priv = texture->priv;
switch (prop_id)
{
case PROP_MAX_TILE_WASTE:
clutter_texture_set_max_tile_waste (texture,
g_value_get_int (value));
clutter_texture_set_max_tile_waste (texture, g_value_get_int (value));
break;
case PROP_SYNC_SIZE:
priv->sync_actor_size = g_value_get_boolean (value);
clutter_actor_queue_relayout (CLUTTER_ACTOR (texture));
clutter_texture_set_sync_size (texture, g_value_get_boolean (value));
break;
case PROP_REPEAT_X:
if (priv->repeat_x != g_value_get_boolean (value))
{
priv->repeat_x = !priv->repeat_x;
if (CLUTTER_ACTOR_IS_VISIBLE (texture))
clutter_actor_queue_redraw (CLUTTER_ACTOR (texture));
}
clutter_texture_set_repeat (texture,
g_value_get_boolean (value),
priv->repeat_y);
break;
case PROP_REPEAT_Y:
if (priv->repeat_y != g_value_get_boolean (value))
{
priv->repeat_y = !priv->repeat_y;
if (CLUTTER_ACTOR_IS_VISIBLE (texture))
clutter_actor_queue_redraw (CLUTTER_ACTOR (texture));
}
clutter_texture_set_repeat (texture,
priv->repeat_x,
g_value_get_boolean (value));
break;
case PROP_FILTER_QUALITY:
clutter_texture_set_filter_quality (texture,
g_value_get_enum (value));
break;
case PROP_COGL_TEXTURE:
clutter_texture_set_cogl_texture
(texture, (CoglHandle) g_value_get_boxed (value));
{
CoglHandle hnd = g_value_get_boxed (value);
clutter_texture_set_cogl_texture (texture, hnd);
}
break;
#if EXPOSE_COGL_MATERIAL_PROP
case PROP_COGL_MATERIAL:
clutter_texture_set_cogl_material
(texture, (CoglHandle) g_value_get_boxed (value));
{
CoglHandle hnd = g_value_get_boxed (value);
clutter_texture_set_cogl_material (texture, hnd);
}
break;
#endif
case PROP_FILENAME:
clutter_texture_set_from_file (texture,
g_value_get_string (value),
NULL);
break;
case PROP_NO_SLICE:
priv->no_slice = g_value_get_boolean (value);
break;
case PROP_KEEP_ASPECT_RATIO:
priv->keep_aspect_ratio = g_value_get_boolean (value);
clutter_actor_queue_relayout (CLUTTER_ACTOR (object));
clutter_texture_set_keep_aspect_ratio (texture,
g_value_get_boolean (value));
break;
case PROP_LOAD_DATA_ASYNC:
if (g_value_get_boolean (value))
{
priv->load_async_set = TRUE;
priv->load_data_async = TRUE;
}
clutter_texture_set_load_data_async (texture,
g_value_get_boolean (value));
break;
case PROP_LOAD_ASYNC:
if (g_value_get_boolean (value))
{
priv->load_data_async = TRUE;
priv->load_async_set = TRUE;
priv->load_size_async = TRUE;
}
clutter_texture_set_load_async (texture, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
}
static void
@ -850,7 +854,6 @@ clutter_texture_get_property (GObject *object,
{
ClutterTexture *texture;
ClutterTexturePrivate *priv;
CoglHandle cogl_texture;
texture = CLUTTER_TEXTURE(object);
priv = texture->priv;
@ -860,37 +863,43 @@ clutter_texture_get_property (GObject *object,
case PROP_MAX_TILE_WASTE:
g_value_set_int (value, clutter_texture_get_max_tile_waste (texture));
break;
case PROP_PIXEL_FORMAT:
cogl_texture = clutter_texture_get_cogl_texture (texture);
if (cogl_texture == COGL_INVALID_HANDLE)
g_value_set_int (value, COGL_PIXEL_FORMAT_ANY);
else
g_value_set_int (value, cogl_texture_get_format (cogl_texture));
g_value_set_enum (value, clutter_texture_get_pixel_format (texture));
break;
case PROP_SYNC_SIZE:
g_value_set_boolean (value, priv->sync_actor_size);
break;
case PROP_REPEAT_X:
g_value_set_boolean (value, priv->repeat_x);
break;
case PROP_REPEAT_Y:
g_value_set_boolean (value, priv->repeat_y);
break;
case PROP_FILTER_QUALITY:
g_value_set_enum (value, clutter_texture_get_filter_quality (texture));
break;
case PROP_COGL_TEXTURE:
g_value_set_boxed (value, clutter_texture_get_cogl_texture (texture));
break;
case PROP_COGL_MATERIAL:
g_value_set_boxed (value, clutter_texture_get_cogl_material (texture));
break;
case PROP_NO_SLICE:
g_value_set_boolean (value, priv->no_slice);
break;
case PROP_KEEP_ASPECT_RATIO:
g_value_set_boolean (value, priv->keep_aspect_ratio);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -900,11 +909,8 @@ clutter_texture_get_property (GObject *object,
static void
clutter_texture_class_init (ClutterTextureClass *klass)
{
GObjectClass *gobject_class;
ClutterActorClass *actor_class;
gobject_class = (GObjectClass*) klass;
actor_class = (ClutterActorClass*) klass;
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
g_type_class_add_private (klass, sizeof (ClutterTexturePrivate));
@ -983,13 +989,12 @@ clutter_texture_class_init (ClutterTextureClass *klass)
g_object_class_install_property
(gobject_class, PROP_PIXEL_FORMAT,
g_param_spec_int ("pixel-format",
"Texture pixel format",
"CoglPixelFormat to use.",
0,
G_MAXINT,
COGL_PIXEL_FORMAT_RGBA_8888,
G_PARAM_READABLE));
g_param_spec_enum ("pixel-format",
"Texture pixel format",
"CoglPixelFormat to use.",
COGL_TYPE_PIXEL_FORMAT,
COGL_PIXEL_FORMAT_RGBA_8888,
CLUTTER_PARAM_READABLE));
g_object_class_install_property
(gobject_class, PROP_COGL_TEXTURE,
@ -1200,7 +1205,6 @@ clutter_texture_init (ClutterTexture *self)
priv->repeat_y = FALSE;
priv->sync_actor_size = TRUE;
priv->material = cogl_material_new ();
priv->fbo_texture = COGL_INVALID_HANDLE;
priv->fbo_handle = COGL_INVALID_HANDLE;
priv->local_data = NULL;
priv->keep_aspect_ratio = FALSE;
@ -1650,7 +1654,7 @@ clutter_texture_set_from_yuv_data (ClutterTexture *texture,
/*
* clutter_texture_async_load_complete:
* @self: a #ClutterTexture
* @bitmap: a #CoglBitmap
* @bitmap: a handle to a CoglBitmap
* @error: load error
*
* If @error is %NULL, loads @bitmap into a #CoglTexture.
@ -1659,7 +1663,7 @@ clutter_texture_set_from_yuv_data (ClutterTexture *texture,
*/
static void
clutter_texture_async_load_complete (ClutterTexture *self,
CoglBitmap *bitmap,
CoglHandle bitmap,
const GError *error)
{
ClutterTexturePrivate *priv = self->priv;
@ -2155,31 +2159,19 @@ clutter_texture_new (void)
/**
* clutter_texture_get_base_size:
* @texture: A #ClutterTexture
* @width: Pointer to gint to be populated with width value if non NULL.
* @height: Pointer to gint to be populated with height value if non NULL.
* @texture: a #ClutterTexture
* @width: (out): return location for the width, or %NULL
* @height: (out): return location for the height, or %NULL
*
* Gets the size in pixels of the untransformed underlying texture pixbuf data.
*
**/
void /* FIXME: rename to get_image_size */
* Gets the size in pixels of the untransformed underlying image
*/
void
clutter_texture_get_base_size (ClutterTexture *texture,
gint *width,
gint *height)
{
g_return_if_fail (CLUTTER_IS_TEXTURE (texture));
/* Attempt to realize, mainly for subclasses ( such as labels )
* which may not create pixbuf data and thus base size until
* realization happens. If we aren't in a stage we can't realize
* though. Doing this here is probably just broken; instead
* we could virtualize get_base_size, or have the subclasses
* create the pixbufs sooner, or something better.
*/
if (!CLUTTER_ACTOR_IS_REALIZED (texture) &&
clutter_actor_get_stage (CLUTTER_ACTOR (texture)) != NULL)
clutter_actor_realize (CLUTTER_ACTOR (texture));
if (width)
*width = texture->priv->width;
@ -2309,9 +2301,11 @@ on_fbo_source_size_change (GObject *object,
{
CoglTextureFlags flags = COGL_TEXTURE_NONE;
gint min_filter, mag_filter;
CoglHandle tex;
/* tear down the FBO */
cogl_handle_unref (priv->fbo_handle);
if (priv->fbo_handle != COGL_INVALID_HANDLE)
cogl_handle_unref (priv->fbo_handle);
texture_free_gl_resources (texture);
@ -2321,20 +2315,25 @@ on_fbo_source_size_change (GObject *object,
if (priv->filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH)
flags |= COGL_TEXTURE_AUTO_MIPMAP;
priv->fbo_texture =
cogl_texture_new_with_size (MAX (priv->width, 1),
MAX (priv->height, 1),
-1,
flags,
COGL_PIXEL_FORMAT_RGBA_8888);
tex = cogl_texture_new_with_size (MAX (priv->width, 1),
MAX (priv->height, 1),
-1,
flags,
COGL_PIXEL_FORMAT_RGBA_8888);
cogl_material_set_layer (priv->material, 0, tex);
clutter_texture_quality_to_filters (priv->filter_quality,
&min_filter,
&mag_filter);
cogl_texture_set_filters (priv->fbo_texture, min_filter, mag_filter);
cogl_texture_set_filters (tex, min_filter, mag_filter);
priv->fbo_handle = cogl_offscreen_new_to_texture (priv->fbo_texture);
priv->fbo_handle = cogl_offscreen_new_to_texture (tex);
/* The material now has a reference to the texture so it will
stick around */
cogl_handle_unref (tex);
if (priv->fbo_handle == COGL_INVALID_HANDLE)
{
@ -2560,3 +2559,323 @@ texture_fbo_free_resources (ClutterTexture *texture)
priv->fbo_handle = COGL_INVALID_HANDLE;
}
}
/**
* clutter_texture_set_sync_size:
* @texture: a #ClutterTexture
* @sync_size: %TRUE if the texture should have the same size of the
* underlying image data
*
* Sets whether @texture should have the same preferred size as the
* underlying image data.
*
* Since: 1.0
*/
void
clutter_texture_set_sync_size (ClutterTexture *texture,
gboolean sync_size)
{
ClutterTexturePrivate *priv;
g_return_if_fail (CLUTTER_IS_TEXTURE (texture));
priv = texture->priv;
if (priv->sync_actor_size != sync_size)
{
priv->sync_actor_size = sync_size;
clutter_actor_queue_relayout (CLUTTER_ACTOR (texture));
g_object_notify (G_OBJECT (texture), "sync-size");
}
}
/**
* clutter_texture_get_sync_size:
* @texture: a #ClutterTexture
*
* Retrieves the value set with clutter_texture_get_sync_size()
*
* Return value: %TRUE if the #ClutterTexture should have the same
* preferred size of the underlying image data
*
* Since: 1.0
*/
gboolean
clutter_texture_get_sync_size (ClutterTexture *texture)
{
g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), FALSE);
return texture->priv->sync_actor_size;
}
/**
* clutter_texture_set_repeat:
* @texture: a #ClutterTexture
* @repeat_x: %TRUE if the texture should repeat horizontally
* @repeat_y: %TRUE if the texture should repeat vertically
*
* Sets whether the @texture should repeat horizontally or
* vertically when the actor size is bigger than the image size
*
* Since: 1.0
*/
void
clutter_texture_set_repeat (ClutterTexture *texture,
gboolean repeat_x,
gboolean repeat_y)
{
ClutterTexturePrivate *priv;
gboolean changed = FALSE;
g_return_if_fail (CLUTTER_IS_TEXTURE (texture));
priv = texture->priv;
g_object_freeze_notify (G_OBJECT (texture));
if (priv->repeat_x != repeat_x)
{
priv->repeat_x = repeat_x;
g_object_notify (G_OBJECT (texture), "repeat-x");
changed = TRUE;
}
if (priv->repeat_y != repeat_y)
{
priv->repeat_y = repeat_y;
g_object_notify (G_OBJECT (texture), "repeat-y");
changed = TRUE;
}
if (changed)
clutter_actor_queue_redraw (CLUTTER_ACTOR (texture));
g_object_thaw_notify (G_OBJECT (texture));
}
/**
* clutter_texture_get_repeat:
* @texture: a #ClutterTexture
* @repeat_x: (out): return location for the horizontal repeat
* @repeat_y: (out): return location for the vertical repeat
*
* Retrieves the horizontal and vertical repeat values set
* using clutter_texture_set_repeat()
*
* Since: 1.0
*/
void
clutter_texture_get_repeat (ClutterTexture *texture,
gboolean *repeat_x,
gboolean *repeat_y)
{
g_return_if_fail (CLUTTER_IS_TEXTURE (texture));
if (repeat_x != NULL)
*repeat_x = texture->priv->repeat_x;
if (repeat_y != NULL)
*repeat_y = texture->priv->repeat_y;
}
/**
* clutter_texture_get_pixel_format:
* @texture: a #ClutterTexture
*
* Retrieves the pixel format used by @texture. This is
* equivalent to:
*
* |[
* handle = clutter_texture_get_pixel_format (texture);
*
* if (handle != COGL_INVALID_HANDLE)
* format = cogl_texture_get_format (handle);
* ]|
*
* Return value: a #CoglPixelFormat value
*
* Since: 1.0
*/
CoglPixelFormat
clutter_texture_get_pixel_format (ClutterTexture *texture)
{
CoglHandle cogl_texture;
g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), COGL_PIXEL_FORMAT_ANY);
cogl_texture = clutter_texture_get_cogl_texture (texture);
if (cogl_texture == COGL_INVALID_HANDLE)
return COGL_PIXEL_FORMAT_ANY;
return cogl_texture_get_format (cogl_texture);
}
/**
* clutter_texture_set_keep_aspect_ratio:
* @texture: a #ClutterTexture
* @keep_aspect: %TRUE to maintain aspect ratio
*
* Sets whether @texture should have a preferred size maintaining
* the aspect ratio of the underlying image
*
* Since: 1.0
*/
void
clutter_texture_set_keep_aspect_ratio (ClutterTexture *texture,
gboolean keep_aspect)
{
ClutterTexturePrivate *priv;
g_return_if_fail (CLUTTER_IS_TEXTURE (texture));
priv = texture->priv;
if (priv->keep_aspect_ratio != keep_aspect)
{
priv->keep_aspect_ratio = keep_aspect;
clutter_actor_queue_relayout (CLUTTER_ACTOR (texture));
g_object_notify (G_OBJECT (texture), "keep-aspect-ratio");
}
}
/**
* clutter_texture_get_keep_aspect_ratio:
* @texture: a #ClutterTexture
*
* Retrieves the value set using clutter_texture_get_keep_aspect_ratio()
*
* Return value: %TRUE if the #ClutterTexture should maintain the
* aspect ratio of the underlying image
*
* Since: 1.0
*/
gboolean
clutter_texture_get_keep_aspect_ratio (ClutterTexture *texture)
{
g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), FALSE);
return texture->priv->keep_aspect_ratio;
}
/**
* clutter_texture_set_load_async:
* @texture: a #ClutterTexture
* @load_sync: %TRUE if the texture should asynchronously load data
* from a filename
*
* Sets whether @texture should use a worker thread to load the data
* from disk asynchronously. Setting @load_async to %TRUE will make
* clutter_texture_set_from_file() return immediately.
*
* See the #ClutterTexture:load-async property documentation, and
* clutter_texture_set_load_data_async().
*
* Since: 1.0
*/
void
clutter_texture_set_load_async (ClutterTexture *texture,
gboolean load_async)
{
ClutterTexturePrivate *priv;
g_return_if_fail (CLUTTER_IS_TEXTURE (texture));
priv = texture->priv;
if (priv->load_async_set != load_async)
{
priv->load_data_async = load_async;
priv->load_size_async = load_async;
priv->load_async_set = load_async;
g_object_notify (G_OBJECT (texture), "load-async");
g_object_notify (G_OBJECT (texture), "load-data-async");
}
}
/**
* clutter_texture_get_load_async:
* @texture: a #ClutterTexture
*
* Retrieves the value set using clutter_texture_get_load_async()
*
* Return value: %TRUE if the #ClutterTexture should load the data from
* disk asynchronously
*
* Since: 1.0
*/
gboolean
clutter_texture_get_load_async (ClutterTexture *texture)
{
g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), FALSE);
return texture->priv->load_async_set;
}
/**
* clutter_texture_set_load_data_async:
* @texture: a #ClutterTexture
* @load_async: %TRUE if the texture should asynchronously load data
* from a filename
*
* Sets whether @texture should use a worker thread to load the data
* from disk asynchronously. Setting @load_async to %TRUE will make
* clutter_texture_set_from_file() block until the #ClutterTexture has
* determined the width and height of the image data.
*
* See the #ClutterTexture:load-async property documentation, and
* clutter_texture_set_load_async().
*
* Since: 1.0
*/
void
clutter_texture_set_load_data_async (ClutterTexture *texture,
gboolean load_async)
{
ClutterTexturePrivate *priv;
g_return_if_fail (CLUTTER_IS_TEXTURE (texture));
priv = texture->priv;
if (priv->load_data_async != load_async)
{
/* load-data-async always unsets load-size-async */
priv->load_data_async = load_async;
priv->load_size_async = FALSE;
priv->load_async_set = load_async;
g_object_notify (G_OBJECT (texture), "load-async");
g_object_notify (G_OBJECT (texture), "load-data-async");
}
}
/**
* clutter_texture_get_load_data_async:
* @texture: a #ClutterTexture
*
* Retrieves the value set by clutter_texture_set_load_data_async()
*
* Return value: %TRUE if the #ClutterTexture should load the image
* data from a file asynchronously
*
* Since: 1.0
*/
gboolean
clutter_texture_get_load_data_async (ClutterTexture *texture)
{
g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), FALSE);
return texture->priv->load_async_set &&
texture->priv->load_data_async;
}

View file

@ -10,7 +10,7 @@
* 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.
* version 2.1 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
@ -105,12 +105,12 @@ struct _ClutterTextureClass
ClutterActorClass parent_class;
/*< public >*/
void (*size_change) (ClutterTexture *texture,
gint width,
gint height);
void (*pixbuf_change) (ClutterTexture *texture);
void (*load_finished) (ClutterTexture *texture,
GError *error);
void (* size_change) (ClutterTexture *texture,
gint width,
gint height);
void (* pixbuf_change) (ClutterTexture *texture);
void (* load_finished) (ClutterTexture *texture,
const GError *error);
/*< private >*/
/* padding, for future expansion */
@ -123,6 +123,7 @@ struct _ClutterTextureClass
/**
* ClutterTextureFlags:
* @CLUTTER_TEXTURE_NONE: No flags
* @CLUTTER_TEXTURE_RGB_FLAG_BGR: FIXME
* @CLUTTER_TEXTURE_RGB_FLAG_PREMULT: FIXME
* @CLUTTER_TEXTURE_YUV_FLAG_YUV2: FIXME
@ -133,11 +134,12 @@ struct _ClutterTextureClass
* Since: 0.4
*/
typedef enum { /*< prefix=CLUTTER_TEXTURE >*/
CLUTTER_TEXTURE_RGB_FLAG_BGR = 1 << 1,
CLUTTER_TEXTURE_RGB_FLAG_PREMULT = 1 << 2, /* FIXME: not handled */
CLUTTER_TEXTURE_YUV_FLAG_YUV2 = 1 << 3
CLUTTER_TEXTURE_NONE = 0,
CLUTTER_TEXTURE_RGB_FLAG_BGR = 1 << 1,
CLUTTER_TEXTURE_RGB_FLAG_PREMULT = 1 << 2, /* FIXME: not handled */
CLUTTER_TEXTURE_YUV_FLAG_YUV2 = 1 << 3
/* FIXME: add compressed types ? */
/* FIXME: add compressed types ? */
} ClutterTextureFlags;
/**
@ -154,7 +156,7 @@ typedef enum { /*< prefix=CLUTTER_TEXTURE >*/
* Since: 0.8
*/
typedef enum { /*< prefix=CLUTTER_TEXTURE_QUALITY >*/
CLUTTER_TEXTURE_QUALITY_LOW = 0,
CLUTTER_TEXTURE_QUALITY_LOW,
CLUTTER_TEXTURE_QUALITY_MEDIUM,
CLUTTER_TEXTURE_QUALITY_HIGH
} ClutterTextureQuality;
@ -209,6 +211,25 @@ void clutter_texture_set_cogl_texture (ClutterTexture
CoglHandle clutter_texture_get_cogl_material (ClutterTexture *texture);
void clutter_texture_set_cogl_material (ClutterTexture *texture,
CoglHandle cogl_material);
void clutter_texture_set_sync_size (ClutterTexture *texture,
gboolean sync_size);
gboolean clutter_texture_get_sync_size (ClutterTexture *texture);
void clutter_texture_set_repeat (ClutterTexture *texture,
gboolean repeat_x,
gboolean repeat_y);
void clutter_texture_get_repeat (ClutterTexture *texture,
gboolean *repeat_x,
gboolean *repeat_y);
CoglPixelFormat clutter_texture_get_pixel_format (ClutterTexture *texture);
void clutter_texture_set_keep_aspect_ratio (ClutterTexture *texture,
gboolean keep_aspect);
gboolean clutter_texture_get_keep_aspect_ratio (ClutterTexture *texture);
void clutter_texture_set_load_async (ClutterTexture *texture,
gboolean load_async);
gboolean clutter_texture_get_load_async (ClutterTexture *texture);
void clutter_texture_set_load_data_async (ClutterTexture *texture,
gboolean load_async);
gboolean clutter_texture_get_load_data_async (ClutterTexture *texture);
G_END_DECLS

View file

@ -20,3 +20,53 @@ pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = $(pc_files)
CLEANFILES = $(pc_files)
AM_CPPFLAGS = $(CLUTTER_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS)
cogl_headers = \
$(top_srcdir)/clutter/cogl/cogl-bitmap.h \
$(top_srcdir)/clutter/cogl/cogl-color.h \
$(top_srcdir)/clutter/cogl/cogl-debug.h \
$(top_srcdir)/clutter/cogl/cogl-fixed.h \
$(top_srcdir)/clutter/cogl/cogl-material.h \
$(top_srcdir)/clutter/cogl/cogl-matrix.h \
$(top_srcdir)/clutter/cogl/cogl-offscreen.h \
$(top_srcdir)/clutter/cogl/cogl-path.h \
$(top_srcdir)/clutter/cogl/cogl-shader.h \
$(top_srcdir)/clutter/cogl/cogl-texture.h \
$(top_srcdir)/clutter/cogl/cogl-types.h \
$(top_srcdir)/clutter/cogl/cogl-vertex-buffer.h
# HACK - gobject-introspection can't scan a library in another directory
# so we create a libclutter-cogl.la that's just identical to the one
# in the subdir
noinst_LTLIBRARIES = libclutter-cogl.la
libclutter_cogl_la_LIBADD = $(CLUTTER_COGL)/libclutter-cogl.la
libclutter_cogl_la_SOURCES = $(cogl_headers)
if HAVE_INTROSPECTION
Cogl-@CLUTTER_API_VERSION@.gir: $(INTROSPECTION_SCANNER) $(CLUTTER_COGL)/libclutter-cogl.la
$(QUIET_GEN)$(INTROSPECTION_SCANNER) -v \
--namespace Cogl --nsversion=@CLUTTER_API_VERSION@ \
-I$(top_srcdir)/clutter/cogl \
-I$(top_srcdir)/clutter/cogl/common \
-I$(top_srcdir)/clutter/cogl/@CLUTTER_COGL@ \
-I$(top_builddir)/clutter \
-DCLUTTER_COMPILATION \
--include=GL-1.0 \
--include=GObject-2.0 \
--library=clutter-cogl \
--libtool="$(top_builddir)/doltlibtool" \
--pkg gobject-2.0 \
--output $@ \
$(top_builddir)/clutter/cogl/cogl-defines-@CLUTTER_COGL@.h \
$(top_builddir)/clutter/cogl/cogl.h \
$(cogl_headers)
BUILT_GIRSOURCES = Cogl-@CLUTTER_API_VERSION@.gir
girdir = $(datadir)/gir-1.0
gir_DATA = $(BUILT_GIRSOURCES)
CLEANFILES += $(BUILT_GIRSOURCES)
endif

View file

@ -0,0 +1,78 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007,2008,2009 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
#error "Only <cogl/cogl.h> can be included directly."
#endif
#ifndef __COGL_BITMAP_H__
#define __COGL_BITMAP_H__
#include <cogl/cogl-types.h>
G_BEGIN_DECLS
/**
* SECTION:cogl-bitmap
* @short_description: Fuctions for loading images but not directly
* into textures
*
* Cogl allows loading image data into memory as CoglBitmaps without
* loading them immediately into GPU textures.
*/
/**
* cogl_bitmap_new_from_file:
* @filename: the file to load.
* @error: a #GError or %NULL.
*
* Load an image file from disk. This function can be safely called from
* within a thread.
*
* Returns: A CoglBitmap to the new loaded image data, or %NULL if loading
* the image failed.
*
* Since: 1.0
*/
CoglHandle cogl_bitmap_new_from_file (const gchar *filename,
GError **error);
/**
* cogl_bitmap_get_size_from_file:
* @filename: the file to check
* @width: return location for the bitmap width
* @height: return location for the bitmap height
*
* Parses an image file enough to extract the width and height
* of the bitmap.
*
* Since: 1.0
*/
gboolean cogl_bitmap_get_size_from_file (const gchar *filename,
gint *width,
gint *height);
G_END_DECLS
#endif /* __COGL_BITMAP_H__ */

View file

@ -1,7 +1,9 @@
/* cogl-color.h: Color type for COGL
* This file is part of Clutter
/*
* Cogl
*
* Copyright (C) 2008 Intel Corporation.
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -14,7 +16,9 @@
* 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/>.
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)

View file

@ -1,3 +1,26 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007,2008,2009 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __COGL_DEBUG_H__
#define __COGL_DEBUG_H__
@ -13,7 +36,8 @@ typedef enum {
COGL_DEBUG_OFFSCREEN = 1 << 4,
COGL_DEBUG_DRAW = 1 << 5,
COGL_DEBUG_PANGO = 1 << 6,
COGL_DEBUG_RECTANGLES = 1 << 7
COGL_DEBUG_RECTANGLES = 1 << 7,
COGL_DEBUG_HANDLE = 1 << 8
} CoglDebugFlags;
#ifdef COGL_ENABLE_DEBUG

View file

@ -1,3 +1,26 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2008,2009 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef COGL_DEPRECATED_H
#define cogl_color cogl_color_REPLACED_BY_cogl_set_source_color

View file

@ -1,7 +1,9 @@
/* cogl-fixed.h: Fixed point API
* This file is part of Clutter
/*
* Cogl
*
* Copyright (C) 2008 Intel Corporation.
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -14,7 +16,9 @@
* 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/>.
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)

View file

@ -1,3 +1,26 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007,2008,2009 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
#error "Only <cogl/cogl.h> can be included directly."
#endif
@ -86,7 +109,7 @@ void cogl_material_set_color (CoglHandle material, const CoglColor *color);
*
* This is the basic color of the material, used when no lighting is enabled.
*
* The default value is (1.0, 1.0, 1.0, 1.0)
* The default value is (0xff, 0xff, 0xff, 0xff)
*
* Since 1.0
*/
@ -111,7 +134,7 @@ void cogl_material_set_color4ub (CoglHandle material,
* Since 1.0
*/
void cogl_material_set_color4f (CoglHandle material,
float red,
float red,
float green,
float blue,
float alpha);

View file

@ -1,3 +1,29 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2008,2009 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* Robert Bragg <robert@linux.intel.com>
*/
#ifndef __COGL_MATRIX_H
#define __COGL_MATRIX_H

View file

@ -1,7 +1,9 @@
/* cogl-offscreen.h: Offscreen objects
* This file is part of Clutter
/*
* Cogl
*
* Copyright (C) 2008 Intel Corporation.
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -14,7 +16,9 @@
* 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/>.
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
@ -31,43 +35,47 @@ G_BEGIN_DECLS
/**
* SECTION:cogl-offscreen
* @short_description: Fuctions for creating and manipulating offscreen
* frame buffer objects
* frame buffer objects
*
* COGL allows creating and operating on FBOs (Framebuffer Objects).
* Cogl allows creating and operating on offscreen render targets.
*/
/* Offscreen api */
/**
* cogl_offscreen_new_to_texture:
* @texhandle:
* @handle: A CoglHandle for a Cogl texture
*
* Returns:
* This creates an offscreen buffer object using the given texture as the
* primary color buffer. It doesn't just initialize the contents of the
* offscreen buffer with the texture; they are tightly bound so that
* drawing to the offscreen buffer effectivly updates the contents of the
* given texture. You don't need to destroy the offscreen buffer before
* you can use the texture again.
*
* Note: This does not work with sliced Cogl textures.
*
* Returns: a CoglHandle for the new offscreen buffer or COGL_INVALID_HANDLE
* if it wasn't possible to create the buffer.
*/
CoglHandle cogl_offscreen_new_to_texture (CoglHandle texhandle);
/**
* cogl_offscreen_new_multisample:
*
*
* Returns:
*/
CoglHandle cogl_offscreen_new_multisample (void);
/**
* cogl_offscreen_ref:
* @handle:
* @handle: A CoglHandle for an offscreen buffer
*
* Returns:
* Increments the reference count on the offscreen buffer.
*
* Returns: For convenience it returns the given CoglHandle
*/
CoglHandle cogl_offscreen_ref (CoglHandle handle);
/**
* cogl_is_offscreen:
* @handle: A CoglHandle
* @handle: A CoglHandle for an offscreen buffer
*
* Gets whether the given handle references an existing offscreen
* buffer object.
* Gets whether the given handle references an existing offscreen buffer
* object.
*
* Returns: %TRUE if the handle references an offscreen buffer,
* %FALSE otherwise
@ -76,54 +84,13 @@ gboolean cogl_is_offscreen (CoglHandle handle);
/**
* cogl_offscreen_unref:
* @handle:
* @handle: A CoglHandle for an offscreen buffer
*
* Decreases the reference count for the offscreen buffer and frees it when
* the count reaches 0.
*/
void cogl_offscreen_unref (CoglHandle handle);
/**
* cogl_offscreen_blit:
* @src_buffer:
* @dst_buffer:
*
*/
void cogl_offscreen_blit (CoglHandle src_buffer,
CoglHandle dst_buffer);
/**
* cogl_offscreen_blit_region:
* @src_buffer:
* @dst_buffer:
* @src_x:
* @src_y:
* @src_w:
* @src_h:
* @dst_x:
* @dst_y:
* @dst_w:
* @dst_h:
*
*/
void cogl_offscreen_blit_region (CoglHandle src_buffer,
CoglHandle dst_buffer,
gint src_x,
gint src_y,
gint src_w,
gint src_h,
gint dst_x,
gint dst_y,
gint dst_w,
gint dst_h);
/**
* cogl_draw_buffer:
* @target:
* @offscreen:
*
*/
void cogl_draw_buffer (CoglBufferTarget target,
CoglHandle offscreen);
G_END_DECLS
#endif /* __COGL_OFFSCREEN_H__ */

View file

@ -1,7 +1,9 @@
/* cogl-path.h: Path primitives
* This file is part of Clutter
/*
* Cogl
*
* Copyright (C) 2008 Intel Corporation.
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -14,7 +16,9 @@
* 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/>.
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)

View file

@ -1,7 +1,9 @@
/* cogl-shader.h: Shaders and programmable pipeline
* This file is part of Clutter
/*
* Cogl
*
* Copyright (C) 2008 Intel Corporation.
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -14,7 +16,9 @@
* 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/>.
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
@ -24,7 +28,7 @@
#ifndef __COGL_SHADER_H__
#define __COGL_SHADER_H__
#include <glib.h>
#include <cogl/cogl-types.h>
G_BEGIN_DECLS
@ -38,6 +42,17 @@ G_BEGIN_DECLS
* The only supported format is GLSL shaders.
*/
/**
* CoglShaderType:
* @COGL_SHADER_TYPE_VERTEX: A program for proccessing vertices
* @COGL_SHADER_TYPE_FRAGMENT: A program for processing fragments
*/
typedef enum _CoglShaderType
{
COGL_SHADER_TYPE_VERTEX,
COGL_SHADER_TYPE_FRAGMENT
} CoglShaderType;
/**
* cogl_create_shader:
* @shader_type: CGL_VERTEX_SHADER or CGL_FRAGMENT_SHADER.
@ -47,7 +62,7 @@ G_BEGIN_DECLS
*
* Returns: a new shader handle.
*/
CoglHandle cogl_create_shader (COGLenum shader_type);
CoglHandle cogl_create_shader (CoglShaderType shader_type);
/**
* cogl_shader_ref:
@ -87,8 +102,8 @@ gboolean cogl_is_shader (CoglHandle handle);
* Replaces the current GLSL source associated with a shader with a new
* one.
*/
void cogl_shader_source (CoglHandle shader,
const gchar *source);
void cogl_shader_source (CoglHandle shader,
const char *source);
/**
* cogl_shader_compile:
* @handle: #CoglHandle for a shader.
@ -109,22 +124,26 @@ void cogl_shader_compile (CoglHandle handle);
* messages that caused a shader to not compile correctly, mainly useful for
* debugging purposes.
*/
void cogl_shader_get_info_log (CoglHandle handle,
guint size,
gchar *buffer);
void cogl_shader_get_info_log (CoglHandle handle,
size_t size,
char *buffer);
/**
* cogl_shader_get_parameteriv:
* cogl_shader_get_type:
* @handle: #CoglHandle for a shader.
* @pname: the named COGL parameter to retrieve.
* @dest: storage location for COGLint return value.
*
* Retrieve a named parameter from a shader can be used to query to compile
* satus of a shader by passing in CGL_OBJECT_COMPILE_STATUS for @pname.
* Returns: COGL_SHADER_TYPE_VERTEX if the shader is a vertex processor
* or COGL_SHADER_TYPE_FRAGMENT if the shader is a frament processor
*/
void cogl_shader_get_parameteriv (CoglHandle handle,
COGLenum pname,
COGLint *dest);
CoglShaderType cogl_shader_get_type (CoglHandle handle);
/**
* cogl_shader_is_compiled:
* @handle: #CoglHandle for a shader.
*
* Returns: TRUE if the shader object has sucessfully be compiled else FALSE
*/
gboolean cogl_shader_is_compiled (CoglHandle handle);
/**
* cogl_create_program:
@ -209,9 +228,9 @@ void cogl_program_use (CoglHandle handle);
* This uniform can be set using cogl_program_uniform_1f() when the
* program is in use.
*/
COGLint cogl_program_get_uniform_location
(CoglHandle handle,
const gchar *uniform_name);
int cogl_program_get_uniform_location
(CoglHandle handle,
const char *uniform_name);
/**
* cogl_program_uniform_1f:
@ -221,8 +240,8 @@ COGLint cogl_program_get_uniform_location
* Changes the value of a floating point uniform in the currently
* used (see cogl_program_use()) shader program.
*/
void cogl_program_uniform_1f (COGLint uniform_no,
gfloat value);
void cogl_program_uniform_1f (int uniform_no,
float value);
/**
* cogl_program_uniform_1i:
@ -232,8 +251,8 @@ void cogl_program_uniform_1f (COGLint uniform_no,
* Changes the value of an integer uniform in the currently
* used (see cogl_program_use()) shader program.
*/
void cogl_program_uniform_1i (COGLint uniform_no,
gint value);
void cogl_program_uniform_1i (int uniform_no,
int value);
/**
* cogl_program_uniform_float:
@ -245,9 +264,9 @@ void cogl_program_uniform_1i (COGLint uniform_no,
* Changes the value of a float vector uniform, or uniform array in the
* currently used (see #cogl_program_use) shader program.
*/
void cogl_program_uniform_float (COGLint uniform_no,
gint size,
gint count,
void cogl_program_uniform_float (int uniform_no,
int size,
int count,
const GLfloat *value);
/**
@ -260,10 +279,10 @@ void cogl_program_uniform_float (COGLint uniform_no,
* Changes the value of a int vector uniform, or uniform array in the
* currently used (see cogl_program_use()) shader program.
*/
void cogl_program_uniform_int (COGLint uniform_no,
gint size,
gint count,
const COGLint *value);
void cogl_program_uniform_int (int uniform_no,
int size,
int count,
const int *value);
/**
* cogl_program_uniform_matrix:
@ -277,11 +296,11 @@ void cogl_program_uniform_int (COGLint uniform_no,
* currently used (see cogl_program_use()) shader program. The @size
* parameter is used to determine the square size of the matrix.
*/
void cogl_program_uniform_matrix (COGLint uniform_no,
gint size,
gint count,
gboolean transpose,
const GLfloat *value);
void cogl_program_uniform_matrix (int uniform_no,
int size,
int count,
gboolean transpose,
const float *value);
G_END_DECLS

View file

@ -1,7 +1,9 @@
/* cogl-texture.h: Texture objects
* This file is part of Clutter
/*
* Cogl
*
* Copyright (C) 2008 Intel Corporation.
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -14,7 +16,9 @@
* 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/>.
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
@ -24,10 +28,10 @@
#ifndef __COGL_TEXTURE_H__
#define __COGL_TEXTURE_H__
G_BEGIN_DECLS
#include <cogl/cogl-types.h>
G_BEGIN_DECLS
/**
* SECTION:cogl-texture
* @short_description: Fuctions for creating and manipulating textures
@ -142,21 +146,21 @@ CoglHandle cogl_texture_new_from_foreign (GLuint gl_handle,
/**
* cogl_texture_new_from_bitmap:
* @bitmap: a #CoglBitmap
* @bmp_handle: A CoglBitmap handle
* @max_waste: maximum extra horizontal and|or vertical margin pixels
* to make the texture fit GPU limitations
* @flags: Optional flags for the texture, or %COGL_TEXTURE_NONE
* @internal_format: the #CoglPixelFormat to use for the GPU storage of the
* texture
*
* Creates a COGL texture from a #CoglBitmap.
* Creates a COGL texture from a CoglBitmap.
*
* Return value: a #CoglHandle to the newly created texture or
* %COGL_INVALID_HANDLE on failure
*
* Since: 1.0
*/
CoglHandle cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
CoglHandle cogl_texture_new_from_bitmap (CoglHandle bmp_handle,
gint max_waste,
CoglTextureFlags flags,
CoglPixelFormat internal_format);
@ -224,6 +228,52 @@ guint cogl_texture_get_rowstride (CoglHandle handle);
*/
gint cogl_texture_get_max_waste (CoglHandle handle);
/**
* CoglTextureFilter:
* @COGL_TEXTURE_FILTER_NEAREST: Measuring in manhatten distance from the,
* current pixel center, use the nearest texture
* texel.
* @COGL_TEXTURE_FILTER_LINEAR: Use the weighted average of the 4 texels
* nearest the current pixel center.
* @COGL_TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST: Select the mimap level whose
* texel size most closely matches
* the current pixel, and use the
* COGL_TEXTURE_FILTER_NEAREST
* criterion.
* @COGL_TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST: Select the mimap level whose
* texel size most closely matches
* the current pixel, and use the
* COGL_TEXTURE_FILTER_LINEAR
* criterion.
* @COGL_TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR: Select the two mimap levels
* whose texel size most closely
* matches the current pixel, use
* the COGL_TEXTURE_FILTER_NEAREST
* criterion on each one and take
* their weighted average.
* @COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR: Select the two mimap levels
* whose texel size most closely
* matches the current pixel, use
* the COGL_TEXTURE_FILTER_LINEAR
* criterion on each one and take
* their weighted average.
*
* Texture filtering is used whenever the current pixel maps either to more
* than one texture element (texel) or less than one. These filter enums
* correspond to different strategies used to come up with a pixel color, by
* possibly referring to multiple neighbouring texels and taking a weighted
* average or simply using the nearest texel.
*/
typedef enum _CoglTextureFilter
{
COGL_TEXTURE_FILTER_NEAREST = GL_NEAREST,
COGL_TEXTURE_FILTER_LINEAR = GL_LINEAR,
COGL_TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST = GL_NEAREST_MIPMAP_NEAREST,
COGL_TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST = GL_LINEAR_MIPMAP_NEAREST,
COGL_TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR = GL_NEAREST_MIPMAP_LINEAR,
COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR = GL_LINEAR_MIPMAP_LINEAR
} CoglTextureFilter;
/**
* cogl_texture_get_min_filter:
* @handle: a #CoglHandle for a texture.
@ -232,7 +282,7 @@ gint cogl_texture_get_max_waste (CoglHandle handle);
*
* Returns: the current downscaling filter for a cogl texture.
*/
COGLenum cogl_texture_get_min_filter (CoglHandle handle);
CoglTextureFilter cogl_texture_get_min_filter (CoglHandle handle);
/**
* cogl_texture_get_mag_filter:
@ -242,7 +292,7 @@ COGLenum cogl_texture_get_min_filter (CoglHandle handle);
*
* Returns: the current downscaling filter for a cogl texture.
*/
COGLenum cogl_texture_get_mag_filter (CoglHandle handle);
CoglTextureFilter cogl_texture_get_mag_filter (CoglHandle handle);
/**
* cogl_texture_is_sliced:
@ -303,8 +353,8 @@ gint cogl_texture_get_data (CoglHandle handle,
* drawn at other scales than 100%.
*/
void cogl_texture_set_filters (CoglHandle handle,
COGLenum min_filter,
COGLenum mag_filter);
CoglTextureFilter min_filter,
CoglTextureFilter mag_filter);
/**
@ -359,45 +409,6 @@ CoglHandle cogl_texture_ref (CoglHandle handle);
*/
void cogl_texture_unref (CoglHandle handle);
/**
* cogl_bitmap_new_from_file:
* @filename: the file to load.
* @error: a #GError or %NULL.
*
* Load an image file from disk. This function can be safely called from
* within a thread.
*
* Returns: A #CoglBitmap to the new loaded image data, or %NULL if loading
* the image failed.
*
* Since: 1.0
*/
CoglBitmap * cogl_bitmap_new_from_file (const gchar *filename,
GError **error);
/**
* cogl_bitmap_get_size_from_file:
* @filename: the file to check
* @width: return location for the bitmap width
* @height: return location for the bitmap height
*
* Parses an image file enough to extract the width and height
* of the bitmap.
*
* Since: 1.0
*/
gboolean cogl_bitmap_get_size_from_file (const gchar *filename,
gint *width,
gint *height);
/**
* cogl_bitmap_free:
* @bmp: a #CoglBitmap.
*
* Frees a #CoglBitmap.
*/
void cogl_bitmap_free (CoglBitmap *bmp);
/**
* cogl_rectangle_with_texture_coords:
* @x1: x coordinate upper left on screen.

View file

@ -1,13 +1,14 @@
/* cogl-types.h: Shared COGL types
/*
* Cogl
*
* This file is part of Clutter
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2008 Intel Corporation.
* Copyright (C) 2008,2009 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.1 of the License, or (at your option) any later version.
* 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
@ -15,7 +16,9 @@
* 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/>.
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
@ -29,13 +32,6 @@
G_BEGIN_DECLS
/**
* CoglBitmap:
*
* Type used for storing image data.
*/
typedef struct _CoglBitmap CoglBitmap;
/**
* CoglHandle:
*
@ -232,7 +228,6 @@ GType cogl_feature_flags_get_type (void) G_GNUC_CONST;
/**
* CoglBufferTarget:
* @COGL_WINDOW_BUFFER: FIXME
* @COGL_MASK_BUFFER: FIXME
* @COGL_OFFSCREEN_BUFFER: FIXME
*
* Target flags for FBOs.
@ -242,8 +237,7 @@ GType cogl_feature_flags_get_type (void) G_GNUC_CONST;
typedef enum
{
COGL_WINDOW_BUFFER = (1 << 1),
COGL_MASK_BUFFER = (1 << 2),
COGL_OFFSCREEN_BUFFER = (1 << 3)
COGL_OFFSCREEN_BUFFER = (1 << 2)
} CoglBufferTarget;
#define COGL_TYPE_BUFFER_TARGET (cogl_buffer_target_get_type ())

View file

@ -1,13 +1,9 @@
/*
* Cogl.
* Cogl
*
* An OpenGL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Vertex Buffer API: Handle extensible arrays of vertex attributes
*
* Copyright (C) 2008 Intel Corporation.
*
* Authored by: Robert Bragg <robert@linux.intel.com>
* Copyright (C) 2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,7 +16,12 @@
* 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/>.
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* Robert Bragg <robert@linux.intel.com>
*/
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)

View file

@ -1,13 +1,12 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2008,2009 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.
@ -41,6 +40,7 @@
#include <cogl/cogl-material.h>
#include <cogl/cogl-path.h>
#include <cogl/cogl-shader.h>
#include <cogl/cogl-bitmap.h>
#include <cogl/cogl-texture.h>
#include <cogl/cogl-types.h>
#include <cogl/cogl-debug.h>
@ -363,14 +363,29 @@ void cogl_set_fog (const CoglColor *fog_color,
*/
void cogl_disable_fog (void);
/**
* CoglBufferBit:
* @COGL_BUFFER_BIT_COLOR: Selects the primary color buffer
* @COGL_BUFFER_BIT_DEPTH: Selects the depth buffer
* @COGL_BUFFER_BIT_STENCIL: Selects the stencil buffer
*/
typedef enum _CoglBufferBit
{
COGL_BUFFER_BIT_COLOR = 1L<<0,
COGL_BUFFER_BIT_DEPTH = 1L<<1,
COGL_BUFFER_BIT_STENCIL = 1L<<2
} CoglBufferBit;
/**
* cogl_clear:
* @color: Background color to clear to
* @buffers: A mask of @CoglBufferBit<!-- -->'s identifying which auxiliary
* buffers to clear
*
* Clears the color buffer to @color. The depth buffer and stencil
* buffers are also cleared.
* Clears all the auxiliary buffers identified in the @buffers mask, and if
* that includes the color buffer then the specified @color is used.
*/
void cogl_clear (const CoglColor *color);
void cogl_clear (const CoglColor *color, gulong buffers);
/**
* cogl_set_source:
@ -475,6 +490,27 @@ void cogl_set_source_texture (CoglHandle texture_handle);
* intersected with the previous region.
*/
/**
* cogl_clip_push_window_rect:
* @x_offset: left edge of the clip rectangle in window coordinates
* @y_offset: top edge of the clip rectangle in window coordinates
* @width: width of the clip rectangle
* @height: height of the clip rectangle
*
* Specifies a rectangular clipping area for all subsequent drawing
* operations. Any drawing commands that extend outside the rectangle
* will be clipped so that only the portion inside the rectangle will
* be displayed. The rectangle dimensions are not transformed by the
* current model-view matrix.
*
* The rectangle is intersected with the current clip region. To undo
* the effect of this function, call cogl_clip_pop().
*/
void cogl_clip_push_window_rect (float x_offset,
float y_offset,
float width,
float height);
/**
* cogl_clip_push:
* @x_offset: left edge of the clip rectangle
@ -563,6 +599,35 @@ void cogl_clip_stack_save (void);
*/
void cogl_clip_stack_restore (void);
/**
* cogl_set_draw_buffer:
* @target: A #CoglBufferTarget that specifies what kind of draw buffer you
* are setting as the render target.
* @offscreen: If you are setting a draw buffer of type COGL_OFFSCREEN_BUFFER
* then this is a CoglHandle for the offscreen buffer.
*
* This redirects all subsequent drawing to the specified draw buffer. This
* can either be an offscreen buffer created with
* cogl_offscreen_new_to_texture () or you can revert to your original
* on screen window buffer.
*/
void cogl_set_draw_buffer (CoglBufferTarget target,
CoglHandle offscreen);
/**
* cogl_push_draw_buffer:
*
* Save cogl_set_draw_buffer() state.
*/
void cogl_push_draw_buffer (void);
/**
* cogl_pop_draw_buffer:
*
* Restore cogl_set_draw_buffer() state.
*/
void cogl_pop_draw_buffer (void);
/**
* cogl_flush_gl_state:
* @flags: flags controlling what is flushed; currently unused, pass in 0

View file

@ -2,27 +2,25 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/clutter \
-I$(top_srcdir)/clutter/cogl \
-I$(top_srcdir)/clutter/cogl/common \
-I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \
-I$(top_builddir)/clutter \
-I$(top_builddir)/clutter/cogl \
-DG_LOG_DOMAIN=\"Cogl-Common\" \
-DCLUTTER_COMPILATION \
$(CLUTTER_CFLAGS) \
$(CLUTTER_DEBUG_CFLAGS) \
$(MAINTAINER_CFLAGS) \
$(GCC_FLAGS)
LDADD = $(CLUTTER_LIBS)
-DCLUTTER_COMPILATION
noinst_LTLIBRARIES = libclutter-cogl-common.la
EXTRA_DIST = stb_image.c
libclutter_cogl_common_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(COGL_DEBUG_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS)
libclutter_cogl_common_la_LIBADD = -lm $(CLUTTER_LIBS)
libclutter_cogl_common_la_SOURCES = \
cogl-handle.h \
cogl-internal.h \
cogl.c \
cogl-util.h \
cogl-util.c \
cogl-bitmap.h \
cogl-bitmap-private.h \
cogl-bitmap.c \
cogl-bitmap-fallback.c \
cogl-current-matrix.c \

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -29,7 +27,7 @@
#include "cogl.h"
#include "cogl-internal.h"
#include "cogl-bitmap.h"
#include "cogl-bitmap-private.h"
#include <string.h>

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -29,7 +27,7 @@
#include "cogl.h"
#include "cogl-internal.h"
#include "cogl-bitmap.h"
#include "cogl-bitmap-private.h"
#include <string.h>

View file

@ -28,14 +28,17 @@
#include <glib.h>
struct _CoglBitmap
#include "cogl-handle.h"
typedef struct _CoglBitmap
{
CoglHandleObject _parent;
guchar *data;
CoglPixelFormat format;
gint width;
gint height;
gint rowstride;
};
} CoglBitmap;
gboolean
_cogl_bitmap_can_convert (CoglPixelFormat src, CoglPixelFormat dst);

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -29,10 +27,21 @@
#include "cogl.h"
#include "cogl-internal.h"
#include "cogl-bitmap.h"
#include "cogl-bitmap-private.h"
#include <string.h>
static void _cogl_bitmap_free (CoglBitmap *bmp);
COGL_HANDLE_DEFINE (Bitmap, bitmap);
static void
_cogl_bitmap_free (CoglBitmap *bmp)
{
g_free (bmp->data);
g_free (bmp);
}
gint
_cogl_get_format_bpp (CoglPixelFormat format)
{
@ -157,11 +166,12 @@ cogl_bitmap_get_size_from_file (const gchar *filename,
return _cogl_bitmap_get_size_from_file (filename, width, height);
}
CoglBitmap *
CoglHandle
cogl_bitmap_new_from_file (const gchar *filename,
GError **error)
{
CoglBitmap bmp;
CoglBitmap *ret;
g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE);
@ -178,12 +188,7 @@ cogl_bitmap_new_from_file (const gchar *filename,
}
}
return (CoglBitmap *) g_memdup (&bmp, sizeof (CoglBitmap));
ret = g_memdup (&bmp, sizeof (CoglBitmap));
return _cogl_bitmap_handle_new (ret);
}
void
cogl_bitmap_free (CoglBitmap *bmp)
{
g_free (bmp->data);
g_free (bmp);
}

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2008 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -28,10 +26,14 @@
#endif
#include <string.h>
#include <glib.h>
#include "cogl.h"
#include "cogl-clip-stack.h"
#include "cogl-primitives.h"
#include "cogl-context.h"
#include "cogl-internal.h"
/* These are defined in the particular backend (float in GL vs fixed
in GL ES) */
@ -57,11 +59,13 @@ void _cogl_set_matrix (const CoglMatrix *matrix);
typedef struct _CoglClipStack CoglClipStack;
typedef struct _CoglClipStackEntryRect CoglClipStackEntryRect;
typedef struct _CoglClipStackEntryWindowRect CoglClipStackEntryWindowRect;
typedef struct _CoglClipStackEntryPath CoglClipStackEntryPath;
typedef enum
{
COGL_CLIP_STACK_RECT,
COGL_CLIP_STACK_WINDOW_RECT,
COGL_CLIP_STACK_PATH
} CoglClipStackEntryType;
@ -72,7 +76,7 @@ struct _CoglClipStack
struct _CoglClipStackEntryRect
{
CoglClipStackEntryType type;
CoglClipStackEntryType type;
/* The rectangle for this clip */
float x_offset;
@ -84,20 +88,126 @@ struct _CoglClipStackEntryRect
CoglMatrix matrix;
};
struct _CoglClipStackEntryWindowRect
{
CoglClipStackEntryType type;
/* The window space rectangle for this clip */
float x0;
float y0;
float x1;
float y1;
};
struct _CoglClipStackEntryPath
{
CoglClipStackEntryType type;
CoglClipStackEntryType type;
/* The matrix that was current when the clip was set */
CoglMatrix matrix;
CoglMatrix matrix;
floatVec2 path_nodes_min;
floatVec2 path_nodes_max;
guint path_size;
CoglPathNode path[1];
guint path_size;
CoglPathNode path[1];
};
void
cogl_clip_push_window_rect (float x_offset,
float y_offset,
float width,
float height)
{
CoglClipStackEntryWindowRect *entry;
CoglClipStack *stack;
float v[4];
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
stack = (CoglClipStack *) ctx->clip.stacks->data;
cogl_get_viewport (v);
entry = g_slice_new (CoglClipStackEntryWindowRect);
/* We convert from coords with (0,0) at top left to coords
* with (0,0) at bottom left. */
entry->type = COGL_CLIP_STACK_WINDOW_RECT;
entry->x0 = x_offset;
entry->y0 = v[3] - y_offset - height;
entry->x1 = x_offset + width;
entry->y1 = v[3] - y_offset;
/* Store it in the stack */
stack->stack_top = g_list_prepend (stack->stack_top, entry);
ctx->clip.stack_dirty = TRUE;
}
/* Scale from OpenGL <-1,1> coordinates system to window coordinates
* <0,window-size> with (0,0) being top left. */
#define VIEWPORT_SCALE_X(x, w, width, origin) \
((((((x) / (w)) + 1.0) / 2) * (width)) + (origin))
#define VIEWPORT_SCALE_Y(y, w, height, origin) \
((height) - (((((y) / (w)) + 1.0) / 2) * (height)) + (origin))
static void
transform_point (CoglMatrix *matrix_mv,
CoglMatrix *matrix_p,
float *viewport,
float *x,
float *y)
{
float z = 0;
float w = 1;
/* Apply the model view matrix */
cogl_matrix_transform_point (matrix_mv, x, y, &z, &w);
/* Apply the projection matrix */
cogl_matrix_transform_point (matrix_p, x, y, &z, &w);
/* Apply viewport transform */
*x = VIEWPORT_SCALE_X (*x, w, viewport[2], viewport[0]);
*y = VIEWPORT_SCALE_Y (*y, w, viewport[3], viewport[1]);
}
#undef VIEWPORT_SCALE_X
#undef VIEWPORT_SCALE_Y
/* Try to push a rectangle given in object coordinates as a rectangle in window
* coordinates instead of object coordinates */
gboolean
try_pushing_rect_as_window_rect (float x_offset,
float y_offset,
float width,
float height)
{
CoglMatrix matrix;
CoglMatrix matrix_p;
float v[4];
float _x0 = x_offset;
float _y0 = y_offset;
float _x1 = x_offset + width;
float _y1 = y_offset + height;
cogl_get_modelview_matrix (&matrix);
if (matrix.xy != 0 || matrix.xz != 0 ||
matrix.yx != 0 || matrix.yz != 0 ||
matrix.zx != 0 || matrix.zy != 0)
return FALSE;
cogl_get_projection_matrix (&matrix_p);
cogl_get_viewport (v);
transform_point (&matrix, &matrix_p, v, &_x0, &_y0);
transform_point (&matrix, &matrix_p, v, &_x1, &_y1);
cogl_clip_push_window_rect (_x0, _y0, _x1 - _x0, _y1 - _y0);
return TRUE;
}
void
cogl_clip_push (float x_offset,
float y_offset,
@ -109,6 +219,11 @@ cogl_clip_push (float x_offset,
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
/* Try and catch window space rectangles so we can redirect to
* cogl_clip_push_window_rect which will use scissoring. */
if (try_pushing_rect_as_window_rect (x_offset, y_offset, width, height))
return;
stack = (CoglClipStack *) ctx->clip.stacks->data;
entry = g_slice_new (CoglClipStackEntryRect);
@ -169,6 +284,7 @@ cogl_clip_pop (void)
{
gpointer entry;
CoglClipStack *stack;
CoglClipStackEntryType type;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -177,10 +293,13 @@ cogl_clip_pop (void)
g_return_if_fail (stack->stack_top != NULL);
entry = stack->stack_top->data;
type = *(CoglClipStackEntryType *) entry;
/* Remove the top entry from the stack */
if (*(CoglClipStackEntryType *) entry == COGL_CLIP_STACK_RECT)
if (type == COGL_CLIP_STACK_RECT)
g_slice_free (CoglClipStackEntryRect, entry);
else if (type == COGL_CLIP_STACK_WINDOW_RECT)
g_slice_free (CoglClipStackEntryWindowRect, entry);
else
g_free (entry);
@ -198,6 +317,10 @@ _cogl_clip_stack_rebuild (void)
gboolean using_stencil_buffer = FALSE;
GList *node;
CoglClipStack *stack;
guint scissor_x0 = 0;
guint scissor_y0 = 0;
guint scissor_x1 = G_MAXUINT;
guint scissor_y1 = G_MAXUINT;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -208,6 +331,7 @@ _cogl_clip_stack_rebuild (void)
_cogl_disable_clip_planes ();
_cogl_disable_stencil_buffer ();
GE (glDisable (GL_SCISSOR_TEST));
/* If the stack is empty then there's nothing else to do */
if (stack->stack_top == NULL)
@ -220,8 +344,9 @@ _cogl_clip_stack_rebuild (void)
for (; node; node = node->prev)
{
gpointer entry = node->data;
CoglClipStackEntryType type = *(CoglClipStackEntryType *) entry;
if (*(CoglClipStackEntryType *) entry == COGL_CLIP_STACK_PATH)
if (type == COGL_CLIP_STACK_PATH)
{
CoglClipStackEntryPath *path = (CoglClipStackEntryPath *) entry;
@ -241,7 +366,7 @@ _cogl_clip_stack_rebuild (void)
/* We can't use clip planes any more */
has_clip_planes = FALSE;
}
else
else if (type == COGL_CLIP_STACK_RECT)
{
CoglClipStackEntryRect *rect = (CoglClipStackEntryRect *) entry;
@ -272,6 +397,16 @@ _cogl_clip_stack_rebuild (void)
cogl_pop_matrix ();
}
else
{
/* Get the intersection of all window space rectangles in the clip
* stack */
CoglClipStackEntryWindowRect *window_rect = entry;
scissor_x0 = MAX (scissor_x0, window_rect->x0);
scissor_y0 = MAX (scissor_y0, window_rect->y0);
scissor_x1 = MIN (scissor_x1, window_rect->x1);
scissor_y1 = MIN (scissor_y1, window_rect->y1);
}
}
/* Enabling clip planes is delayed to now so that they won't affect
@ -279,6 +414,18 @@ _cogl_clip_stack_rebuild (void)
if (using_clip_planes)
_cogl_enable_clip_planes ();
if (scissor_x0 >= scissor_x1 || scissor_y0 >= scissor_y1)
scissor_x0 = scissor_y0 = scissor_x1 = scissor_y1 = 0;
if (!(scissor_x0 == 0 && scissor_y0 == 0 &&
scissor_x1 == G_MAXUINT && scissor_y1 == G_MAXUINT))
{
GE (glEnable (GL_SCISSOR_TEST));
GE (glScissor (scissor_x0, scissor_y0,
scissor_x1 - scissor_x0,
scissor_y1 - scissor_y0));
}
ctx->clip.stencil_used = using_stencil_buffer;
}

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2008 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,3 +1,26 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2008,2009 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Havoc Pennington <hp@pobox.com> for litl
*
* Copyright (C) 2009 OpenedHand
* Copyright (C) 2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -21,6 +19,9 @@
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* Havoc Pennington <hp@pobox.com> for litl
*/
#ifdef HAVE_CONFIG_H

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Havoc Pennington <hp@pobox.com> for litl
*
* Copyright (C) 2009 OpenedHand
* Copyright (C) 2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -21,6 +19,9 @@
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* Havoc Pennington <hp@pobox.com> for litl
*/
#ifndef __COGL_CURRENT_MATRIX_H

View file

@ -1,3 +1,26 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2009 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@ -15,7 +38,8 @@ static const GDebugKey cogl_debug_keys[] = {
{ "offscreen", COGL_DEBUG_OFFSCREEN },
{ "draw", COGL_DEBUG_DRAW },
{ "pango", COGL_DEBUG_PANGO },
{ "rectangles", COGL_DEBUG_RECTANGLES }
{ "rectangles", COGL_DEBUG_RECTANGLES },
{ "handle", COGL_DEBUG_HANDLE }
};
static const gint n_cogl_debug_keys = G_N_ELEMENTS (cogl_debug_keys);

View file

@ -1,3 +1,26 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007,2008,2009 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#define G_IMPLEMENT_INLINES
#ifdef HAVE_CONFIG_H

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2008 OpenedHand
* Copyright (C) 2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -48,65 +46,60 @@ typedef struct _CoglHandleObject
/* Helper macro to encapsulate the common code for COGL reference
counted handles */
#if COGL_DEBUG
#ifdef COGL_HANDLE_DEBUG
#define _COGL_HANDLE_DEBUG_NEW(type_name, obj) \
printf ("COGL " G_STRINGIFY (type_name) " NEW %p %i\n", \
(obj), (obj)->ref_count)
#define _COGL_HANDLE_DEBUG_NEW(type_name, obj) \
COGL_NOTE (HANDLE, "COGL " G_STRINGIFY (type_name) " NEW %p %i\n", \
(obj), (obj)->ref_count)
#define _COGL_HANDLE_DEBUG_REF(type_name, handle) \
do { \
CoglHandleObject *obj = (CoglHandleObject *)handle; \
printf ("COGL %s REF %p %i\n", \
g_quark_to_string ((obj)->klass->type), \
(obj), (obj)->ref_count); \
} while (0)
#define _COGL_HANDLE_DEBUG_REF(type_name, handle) G_STMT_START { \
CoglHandleObject *__obj = (CoglHandleObject *)handle; \
COGL_NOTE (HANDLE, "COGL %s REF %p %i\n", \
g_quark_to_string ((__obj)->klass->type), \
(__obj), (__obj)->ref_count); } G_STMT_END
#define _COGL_HANDLE_DEBUG_UNREF(type_name, handle) \
do { \
CoglHandleObject *obj = (CoglHandleObject *)handle; \
printf ("COGL %s UNREF %p %i\n", \
g_quark_to_string ((obj)->klass->type), \
(obj), (obj)->ref_count - 1); \
} while (0)
#define _COGL_HANDLE_DEBUG_UNREF(type_name, handle) G_STMT_START { \
CoglHandleObject *__obj = (CoglHandleObject *)handle; \
COGL_NOTE (HANDLE, "COGL %s UNREF %p %i\n", \
g_quark_to_string ((__obj)->klass->type), \
(__obj), (__obj)->ref_count - 1); } G_STMT_END
#define COGL_HANDLE_DEBUG_FREE(obj) \
printf ("COGL %s FREE %p\n", \
g_quark_to_string ((obj)->klass->type), (obj)) \
#define COGL_HANDLE_DEBUG_FREE(obj) \
COGL_NOTE (HANDLE, "COGL %s FREE %p\n", \
g_quark_to_string ((obj)->klass->type), (obj))
#else /* COGL_DEBUG */
#else /* !COGL_HANDLE_DEBUG */
#define _COGL_HANDLE_DEBUG_NEW(type_name, obj)
#define _COGL_HANDLE_DEBUG_REF(type_name, obj)
#define _COGL_HANDLE_DEBUG_UNREF(type_name, obj)
#define COGL_HANDLE_DEBUG_FREE(obj)
#endif /* COGL_DEBUG */
#endif /* COGL_HANDLE_DEBUG */
#define COGL_HANDLE_DEFINE(TypeName, type_name) \
\
static CoglHandleClass _cogl_##type_name##_class; \
static CoglHandleClass _cogl_##type_name##_class; \
\
static GQuark \
_cogl_##type_name##_get_type (void) \
{ \
static GQuark type = 0; \
if (!type) \
type = g_quark_from_static_string ("Cogl"#TypeName); \
return type; \
} \
static GQuark \
_cogl_##type_name##_get_type (void) \
{ \
static GQuark type = 0; \
if (!type) \
type = g_quark_from_static_string ("Cogl"#TypeName); \
return type; \
} \
\
static CoglHandle \
_cogl_##type_name##_handle_new (Cogl##TypeName *new_obj) \
{ \
CoglHandleObject *obj = &new_obj->_parent; \
obj->ref_count = 1; \
static CoglHandle \
_cogl_##type_name##_handle_new (Cogl##TypeName *new_obj) \
{ \
CoglHandleObject *obj = &new_obj->_parent; \
obj->ref_count = 1; \
\
obj->klass = &_cogl_##type_name##_class; \
if (!obj->klass->type) \
{ \
obj->klass->type = \
_cogl_##type_name##_get_type (); \
obj->klass = &_cogl_##type_name##_class; \
if (!obj->klass->type) \
{ \
obj->klass->type = _cogl_##type_name##_get_type (); \
obj->klass->virt_free = _cogl_##type_name##_free; \
} \
\
@ -114,51 +107,50 @@ typedef struct _CoglHandleObject
return (CoglHandle) new_obj; \
} \
\
Cogl##TypeName * \
_cogl_##type_name##_pointer_from_handle (CoglHandle handle) \
{ \
return (Cogl##TypeName *) handle; \
} \
Cogl##TypeName * \
_cogl_##type_name##_pointer_from_handle (CoglHandle handle) \
{ \
return (Cogl##TypeName *) handle; \
} \
\
gboolean \
cogl_is_##type_name (CoglHandle handle) \
{ \
CoglHandleObject *obj = (CoglHandleObject *)handle; \
gboolean \
cogl_is_##type_name (CoglHandle handle) \
{ \
CoglHandleObject *obj = (CoglHandleObject *)handle; \
\
if (handle == COGL_INVALID_HANDLE) \
return FALSE; \
if (handle == COGL_INVALID_HANDLE) \
return FALSE; \
\
return (obj->klass->type == \
_cogl_##type_name##_get_type ()); \
} \
return (obj->klass->type == _cogl_##type_name##_get_type ()); \
} \
\
CoglHandle G_GNUC_DEPRECATED \
cogl_##type_name##_ref (CoglHandle handle) \
{ \
if (!cogl_is_##type_name (handle)) \
return COGL_INVALID_HANDLE; \
CoglHandle G_GNUC_DEPRECATED \
cogl_##type_name##_ref (CoglHandle handle) \
{ \
if (!cogl_is_##type_name (handle)) \
return COGL_INVALID_HANDLE; \
\
_COGL_HANDLE_DEBUG_REF (TypeName, handle); \
_COGL_HANDLE_DEBUG_REF (TypeName, handle); \
\
cogl_handle_ref (handle); \
cogl_handle_ref (handle); \
\
return handle; \
} \
return handle; \
} \
\
void G_GNUC_DEPRECATED \
cogl_##type_name##_unref (CoglHandle handle) \
{ \
if (!cogl_is_##type_name (handle)) \
{ \
g_warning (G_STRINGIFY (cogl_##type_name##_unref) \
": Ignoring unref of Cogl handle " \
"due to type missmatch"); \
return; \
} \
void G_GNUC_DEPRECATED \
cogl_##type_name##_unref (CoglHandle handle) \
{ \
if (!cogl_is_##type_name (handle)) \
{ \
g_warning (G_STRINGIFY (cogl_##type_name##_unref) \
": Ignoring unref of Cogl handle " \
"due to type mismatch"); \
return; \
} \
\
_COGL_HANDLE_DEBUG_UNREF (TypeName, handle); \
_COGL_HANDLE_DEBUG_UNREF (TypeName, handle); \
\
cogl_handle_unref (handle); \
}
cogl_handle_unref (handle); \
}
#endif /* __COGL_HANDLE_H */

View file

@ -1,10 +1,9 @@
/*
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007, 2008 OpenedHand
* Copyright (C) 2009 Intel Corp.
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -25,6 +24,8 @@
#ifndef __COGL_INTERNAL_H
#define __COGL_INTERNAL_H
#include "cogl-debug.h"
#ifdef HAVE_COGL_GLES2
typedef enum {
COGL_BOXED_NONE,
@ -50,29 +51,25 @@ typedef struct _CoglBoxedValue
} CoglBoxedValue;
#endif
#define COGL_DEBUG 0
#ifdef COGL_GL_DEBUG
#if COGL_DEBUG
const gchar *cogl_gl_error_to_string (GLenum error_code);
#include <stdio.h>
#define GE(x...) G_STMT_START { \
GLenum __err; \
(x); \
while ((__err = glGetError ()) != GL_NO_ERROR) \
{ \
g_warning ("%s: GL error (%d): %s\n", \
G_STRLOC, \
cogl_gl_error_to_string (__err)); \
} } G_STMT_END
const char *_cogl_error_string(GLenum errorCode);
#define GE(x...) G_STMT_START { \
GLenum err; \
(x); \
while ((err = glGetError()) != GL_NO_ERROR) { \
fprintf(stderr, "glError: %s caught at %s:%u\n", \
(char *)_cogl_error_string(err), \
__FILE__, __LINE__); \
} \
} G_STMT_END
#else /* COGL_DEBUG */
#else /* !COGL_GL_DEBUG */
#define GE(x) (x)
#endif /* COGL_DEBUG */
#endif /* COGL_GL_DEBUG */
#define COGL_ENABLE_BLEND (1<<1)
#define COGL_ENABLE_ALPHA_TEST (1<<2)
@ -80,16 +77,10 @@ const char *_cogl_error_string(GLenum errorCode);
#define COGL_ENABLE_COLOR_ARRAY (1<<4)
#define COGL_ENABLE_BACKFACE_CULLING (1<<5)
void
_cogl_features_init (void);
void _cogl_features_init (void);
gint _cogl_get_format_bpp (CoglPixelFormat format);
gint
_cogl_get_format_bpp (CoglPixelFormat format);
void
cogl_enable (gulong flags);
gulong
cogl_get_enable ();
void cogl_enable (gulong flags);
gulong cogl_get_enable (void);
#endif /* __COGL_INTERNAL_H */

View file

@ -1,3 +1,29 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2008,2009 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* Robert Bragg <robert@linux.intel.com>
*/
#ifndef __COGL_MATERIAL_PRIVATE_H
#define __COGL_MATERIAL_PRIVATE_H

View file

@ -1,3 +1,28 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2008,2009 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* Robert Bragg <robert@linux.intel.com>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
@ -168,6 +193,18 @@ cogl_material_set_color4ub (CoglHandle handle,
cogl_material_set_color (handle, &color);
}
void
cogl_material_set_color4f (CoglHandle handle,
float red,
float green,
float blue,
float alpha)
{
CoglColor color;
cogl_color_set_from_4f (&color, red, green, blue, alpha);
cogl_material_set_color (handle, &color);
}
void
cogl_material_get_ambient (CoglHandle handle,
CoglColor *ambient)
@ -619,7 +656,8 @@ cogl_material_set_layer_matrix (CoglHandle material_handle,
static void
_cogl_material_layer_free (CoglMaterialLayer *layer)
{
cogl_handle_unref (layer->texture);
if (layer->texture != COGL_INVALID_HANDLE)
cogl_handle_unref (layer->texture);
g_free (layer);
}

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Havoc Pennington <hp@pobox.com> for litl
*
* Copyright (C) 2009 OpenedHand
* Copyright (C) 2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -21,6 +19,9 @@
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* Havoc Pennington <hp@pobox.com> for litl
*/
#ifdef HAVE_CONFIG_H

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Havoc Pennington <hp@pobox.com> for litl
*
* Copyright (C) 2009 OpenedHand
* Copyright (C) 2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -21,6 +19,9 @@
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* Havoc Pennington <hp@pobox.com> for litl
*/
#ifndef __COGL_MATRIX_STACK_H

View file

@ -1,3 +1,29 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2008,2009 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* Robert Bragg <robert@linux.intel.com>
*/
#include <cogl-matrix.h>
#include <glib.h>

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -374,9 +372,7 @@ _cogl_texture_sliced_quad (CoglTexture *tex,
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
#if COGL_DEBUG
printf("=== Drawing Tex Quad (Sliced Mode) ===\n");
#endif
COGL_NOTE (DRAW, "Drawing Tex Quad (Sliced Mode)");
/* We can't use hardware repeat so we need to set clamp to edge
otherwise it might pull in edge pixels from the other side */
@ -487,17 +483,21 @@ _cogl_texture_sliced_quad (CoglTexture *tex,
slice_tx2 /= iter_x.span->size;
}
#if COGL_DEBUG
printf("~~~~~ slice (%d,%d)\n", iter_x.index, iter_y.index);
printf("qx1: %f\n", (slice_qx1));
printf("qy1: %f\n", (slice_qy1));
printf("qx2: %f\n", (slice_qx2));
printf("qy2: %f\n", (slice_qy2));
printf("tx1: %f\n", (slice_tx1));
printf("ty1: %f\n", (slice_ty1));
printf("tx2: %f\n", (slice_tx2));
printf("ty2: %f\n", (slice_ty2));
#endif
COGL_NOTE (DRAW,
"~~~~~ slice (%d, %d)\n"
"qx1: %f\t"
"qy1: %f\n"
"qx2: %f\t"
"qy2: %f\n"
"tx1: %f\t"
"ty1: %f\n"
"tx2: %f\t"
"ty2: %f\n",
iter_x.index, iter_y.index,
slice_qx1, slice_qy1,
slice_qx2, slice_qy2,
slice_tx1, slice_ty1,
slice_tx2, slice_ty2);
/* Pick and bind opengl texture object */
gl_handle = g_array_index (tex->slice_gl_handles, GLuint,

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,18 +1,14 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By: Matthew Allum <mallum@openedhand.com>
* Emmanuele Bassi <ebassi@linux.intel.com>
*
* Copyright (C) 2007, 2008 OpenedHand
* Copyright (C) 2009 Intel Corp.
* Copyright (C) 2007,2008,2009 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.1 of the License, or (at your option) any later version.
* 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
@ -20,7 +16,9 @@
* 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/>.
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
@ -181,7 +179,6 @@ cogl_buffer_target_get_type (void)
{
static const GFlagsValue values[] = {
{ COGL_WINDOW_BUFFER, "COGL_WINDOW_BUFFER", "window-buffer" },
{ COGL_MASK_BUFFER, "COGL_MASK_BUFFER", "mask-buffer" },
{ COGL_OFFSCREEN_BUFFER, "COGL_OFFSCREEN_BUFFER", "offscreen-buffer" },
{ 0, NULL, NULL }
};

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,11 +1,9 @@
/*
* Cogl.
* Cogl
*
* An OpenGL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2008 Intel Corporation.
*
* Authored By: Robert Bragg <robert@linux.intel.com>
* Copyright (C) 2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -18,7 +16,12 @@
* 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/>.
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* Robert Bragg <robert@linux.intel.com>
*/
#ifndef __COGL_VERTEX_BUFFER_H

View file

@ -1,13 +1,9 @@
/*
* Cogl.
* Cogl
*
* An OpenGL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Vertex Buffer API: Handle extensible arrays of vertex attributes
*
* Copyright (C) 2008, 2009 Intel Corporation.
*
* Authored by: Robert Bragg <robert@linux.intel.com>
* Copyright (C) 2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,7 +16,12 @@
* 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/>.
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* Robert Bragg <robert@linux.intel.com>
*/
/* XXX: For an overview of the functionality implemented here, please
@ -126,7 +127,7 @@
#include <stdio.h>
#include <string.h>
#include <glib/gprintf.h>
#include <glib.h>
#include "cogl.h"
#include "cogl-internal.h"
@ -1775,4 +1776,3 @@ _cogl_vertex_buffer_free (CoglVertexBuffer *buffer)
g_slice_free (CoglVertexBuffer, buffer);
}

View file

@ -1,10 +1,9 @@
/*
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007, 2008 OpenedHand
* Copyright (C) 2009 Intel Corp.
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -39,6 +38,7 @@
typedef CoglFuncPtr (*GLXGetProcAddressProc) (const guint8 *procName);
#endif
#include "cogl-debug.h"
#include "cogl-internal.h"
#include "cogl-util.h"
#include "cogl-context.h"
@ -47,67 +47,82 @@ typedef CoglFuncPtr (*GLXGetProcAddressProc) (const guint8 *procName);
#include "cogl-gles2-wrapper.h"
#endif
#ifdef COGL_GL_DEBUG
/* GL error to string conversion */
#if COGL_DEBUG
struct token_string
{
GLuint Token;
const char *String;
};
static const struct {
GLuint error_code;
const gchar *error_string;
} gl_errors[] = {
{ GL_NO_ERROR, "No error" },
{ GL_INVALID_ENUM, "Invalid enumeration value" },
{ GL_INVALID_VALUE, "Invalid value" },
{ GL_INVALID_OPERATION, "Invalid operation" },
{ GL_STACK_OVERFLOW, "Stack overflow" },
{ GL_STACK_UNDERFLOW, "Stack underflow" },
{ GL_OUT_OF_MEMORY, "Out of memory" },
static const struct token_string Errors[] = {
{ GL_NO_ERROR, "no error" },
{ GL_INVALID_ENUM, "invalid enumerant" },
{ GL_INVALID_VALUE, "invalid value" },
{ GL_INVALID_OPERATION, "invalid operation" },
{ GL_STACK_OVERFLOW, "stack overflow" },
{ GL_STACK_UNDERFLOW, "stack underflow" },
{ GL_OUT_OF_MEMORY, "out of memory" },
#ifdef GL_INVALID_FRAMEBUFFER_OPERATION_EXT
{ GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "invalid framebuffer operation" },
{ GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "Invalid framebuffer operation" }
#endif
{ ~0, NULL }
};
const char*
_cogl_error_string(GLenum errorCode)
static const guint n_gl_errors = G_N_ELEMENTS (gl_errors);
const gchar *
cogl_gl_error_to_string (GLenum error_code)
{
int i;
for (i = 0; Errors[i].String; i++) {
if (Errors[i].Token == errorCode)
return Errors[i].String;
}
return "unknown";
gint i;
for (i = 0; i < n_gl_errors; i++)
{
if (gl_errors[i].error_code == error_code)
return gl_errors[i].error_string;
}
return "Unknown GL error";
}
#endif
#endif /* COGL_GL_DEBUG */
void
cogl_clear (const CoglColor *color)
cogl_clear (const CoglColor *color, gulong buffers)
{
#if COGL_DEBUG
fprintf(stderr, "\n ============== Paint Start ================ \n");
#endif
GLbitfield gl_buffers = 0;
GE( glClearColor (cogl_color_get_red_float (color),
cogl_color_get_green_float (color),
cogl_color_get_blue_float (color),
0.0) );
COGL_NOTE (DRAW, "Clear begin");
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
cogl_clip_ensure ();
/*
* Disable the depth test for now as has some strange side effects,
* mainly on x/y axis rotation with multiple layers at same depth
* (eg rotating text on a bg has very strange effect). Seems no clean
* 100% effective way to fix without other odd issues.. So for now
* move to application to handle and add cogl_enable_depth_test()
* as for custom actors (i.e groups) to enable if need be.
*
* glEnable (GL_DEPTH_TEST);
* glEnable (GL_ALPHA_TEST)
* glDepthFunc (GL_LEQUAL);
* glAlphaFunc (GL_GREATER, 0.1);
*/
if (buffers & COGL_BUFFER_BIT_COLOR)
{
GE( glClearColor (cogl_color_get_red_float (color),
cogl_color_get_green_float (color),
cogl_color_get_blue_float (color),
0.0) );
gl_buffers |= GL_COLOR_BUFFER_BIT;
}
if (buffers & COGL_BUFFER_BIT_DEPTH)
gl_buffers |= GL_DEPTH_BUFFER_BIT;
if (buffers & COGL_BUFFER_BIT_STENCIL)
gl_buffers |= GL_STENCIL_BUFFER_BIT;
if (!gl_buffers)
{
static gboolean shown = FALSE;
if (!shown)
{
g_warning ("You should specify at least one auxiliary buffer "
"when calling cogl_clear");
}
return;
}
glClear (gl_buffers);
COGL_NOTE (DRAW, "Clear end");
}
static inline gboolean
@ -556,24 +571,31 @@ cogl_get_viewport (float v[4])
}
void
cogl_get_bitmasks (gint *red, gint *green, gint *blue, gint *alpha)
cogl_get_bitmasks (gint *red,
gint *green,
gint *blue,
gint *alpha)
{
GLint value;
if (red)
{
GE( glGetIntegerv(GL_RED_BITS, &value) );
*red = value;
}
if (green)
{
GE( glGetIntegerv(GL_GREEN_BITS, &value) );
*green = value;
}
if (blue)
{
GE( glGetIntegerv(GL_BLUE_BITS, &value) );
*blue = value;
}
if (alpha)
{
GE( glGetIntegerv(GL_ALPHA_BITS, &value ) );

View file

@ -1,65 +1,65 @@
libclutterincludedir = $(includedir)/clutter-@CLUTTER_API_VERSION@/cogl
libclutterinclude_HEADERS = \
$(top_builddir)/clutter/cogl/cogl.h \
$(top_builddir)/clutter/cogl/cogl-defines-gl.h \
$(top_builddir)/clutter/cogl/cogl-color.h \
$(top_builddir)/clutter/cogl/cogl-deprecated.h \
$(top_builddir)/clutter/cogl/cogl-fixed.h \
$(top_builddir)/clutter/cogl/cogl-offscreen.h \
$(top_builddir)/clutter/cogl/cogl-path.h \
$(top_builddir)/clutter/cogl/cogl-shader.h \
$(top_builddir)/clutter/cogl/cogl-texture.h \
$(top_builddir)/clutter/cogl/cogl-types.h \
$(top_builddir)/clutter/cogl/cogl-vertex-buffer.h \
$(top_builddir)/clutter/cogl/cogl-material.h \
$(top_builddir)/clutter/cogl/cogl-matrix.h \
$(top_builddir)/clutter/cogl/cogl-debug.h
NULL =
cogl_headers = \
$(top_builddir)/clutter/cogl/cogl-defines-gl.h \
$(top_srcdir)/clutter/cogl/cogl-color.h \
$(top_srcdir)/clutter/cogl/cogl-deprecated.h \
$(top_srcdir)/clutter/cogl/cogl-fixed.h \
$(top_srcdir)/clutter/cogl/cogl-offscreen.h \
$(top_srcdir)/clutter/cogl/cogl-path.h \
$(top_srcdir)/clutter/cogl/cogl-shader.h \
$(top_srcdir)/clutter/cogl/cogl-bitmap.h \
$(top_srcdir)/clutter/cogl/cogl-texture.h \
$(top_srcdir)/clutter/cogl/cogl-types.h \
$(top_srcdir)/clutter/cogl/cogl-vertex-buffer.h \
$(top_srcdir)/clutter/cogl/cogl-material.h \
$(top_srcdir)/clutter/cogl/cogl-matrix.h \
$(top_srcdir)/clutter/cogl/cogl-debug.h \
$(NULL)
cogl_priv_headers = \
cogl-texture-private.h \
cogl-fbo.h \
cogl-shader-private.h \
cogl-program.h \
cogl-context.h \
$(NULL)
cogl_sources = \
cogl.c \
cogl-primitives.c \
cogl-texture.c \
cogl-fbo.c \
cogl-shader.c \
cogl-program.c \
cogl-context.c \
$(NULL)
coglincludedir = $(includedir)/clutter-@CLUTTER_API_VERSION@/cogl
coglinclude_HEADERS = \
$(cogl_headers) \
$(top_builddir)/clutter/cogl/cogl.h
INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/clutter \
-I$(top_srcdir)/clutter/cogl \
-I$(top_srcdir)/clutter/cogl/common \
-I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \
-I$(top_srcdir)/clutter \
-I$(top_builddir)/clutter \
-I$(top_builddir)/clutter/cogl \
-DG_LOG_DOMAIN=\"Cogl-GL\" \
-DCLUTTER_COMPILATION \
$(CLUTTER_CFLAGS) \
$(CLUTTER_DEBUG_CFLAGS) \
$(MAINTAINER_CFLAGS) \
$(GCC_FLAGS)
LDADD = $(CLUTTER_LIBS)
-DG_LOG_DOMAIN=\"Cogl-GL\" \
-DCLUTTER_COMPILATION
noinst_LTLIBRARIES = libclutter-cogl.la
libclutter_cogl_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(COGL_DEBUG_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS)
libclutter_cogl_la_LIBADD = -lm $(CLUTTER_LIBS) $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la
libclutter_cogl_la_DEPENDENCIES = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la
libclutter_cogl_la_SOURCES = \
$(top_builddir)/clutter/cogl/cogl.h \
$(top_builddir)/clutter/cogl/cogl-defines-gl.h \
$(top_builddir)/clutter/cogl/cogl-color.h \
$(top_builddir)/clutter/cogl/cogl-deprecated.h \
$(top_builddir)/clutter/cogl/cogl-fixed.h \
$(top_builddir)/clutter/cogl/cogl-offscreen.h \
$(top_builddir)/clutter/cogl/cogl-path.h \
$(top_builddir)/clutter/cogl/cogl-shader.h \
$(top_builddir)/clutter/cogl/cogl-texture.h \
$(top_builddir)/clutter/cogl/cogl-types.h \
$(top_builddir)/clutter/cogl/cogl-debug.h \
cogl-internal.h \
cogl-texture-private.h \
cogl-fbo.h \
cogl-shader-private.h \
cogl-program.h \
cogl-context.h \
cogl.c \
cogl-primitives.c \
cogl-texture.c \
cogl-fbo.c \
cogl-shader.c \
cogl-program.c \
cogl-context.c
$(top_builddir)/clutter/cogl/cogl.h \
$(cogl_headers) \
$(cogl_priv_headers) \
$(cogl_sources) \
$(NULL)
EXTRA_DIST = cogl-defines.h.in
libclutter_cogl_la_LIBADD = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -44,6 +42,7 @@ cogl_create_context ()
{
GLubyte default_texture_data[] = { 0xff, 0xff, 0xff, 0x0 };
gulong enable_flags = 0;
CoglDrawBufferState *draw_buffer;
if (_context != NULL)
return FALSE;
@ -80,7 +79,11 @@ cogl_create_context ()
sizeof (CoglLayerInfo));
_context->n_texcoord_arrays_enabled = 0;
_context->draw_buffer = COGL_WINDOW_BUFFER;
draw_buffer = g_slice_new0 (CoglDrawBufferState);
draw_buffer->target = COGL_WINDOW_BUFFER;
draw_buffer->offscreen = COGL_INVALID_HANDLE;
_context->draw_buffer_stack =
g_slist_prepend (NULL, draw_buffer);
_context->path_nodes = g_array_new (FALSE, FALSE, sizeof (CoglPathNode));
_context->last_path = 0;

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -38,6 +36,12 @@ typedef struct
GLubyte c[4];
} CoglTextureGLVertex;
typedef struct
{
CoglBufferTarget target;
CoglHandle offscreen;
} CoglDrawBufferState;
typedef struct
{
/* Features cache */
@ -84,7 +88,7 @@ typedef struct
guint n_texcoord_arrays_enabled;
/* Framebuffer objects */
CoglBufferTarget draw_buffer;
GSList *draw_buffer_stack;
/* Clip stack */
CoglClipStackState clip;

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -26,14 +24,11 @@
#ifndef __COGL_DEFINES_H__
#define __COGL_DEFINES_H__
#include <glib.h>
#include <@CLUTTER_GL_HEADER@>
G_BEGIN_DECLS
typedef GLenum COGLenum;
typedef GLint COGLint;
typedef GLuint COGLuint;
/* FIXME + DOCUMENT */
#define COPENSTEP OPENSTEP
@ -227,7 +222,6 @@ typedef GLuint COGLuint;
#define CGL_FOG_INDEX GL_FOG_INDEX
#define CGL_FOG_START GL_FOG_START
#define CGL_FOG_END GL_FOG_END
#define CGL_LINEAR GL_LINEAR
#define CGL_EXP GL_EXP
#define CGL_LOGIC_OP GL_LOGIC_OP
#define CGL_INDEX_LOGIC_OP GL_INDEX_LOGIC_OP
@ -420,10 +414,6 @@ typedef GLuint COGLuint;
#define CGL_TEXTURE_ALPHA_SIZE GL_TEXTURE_ALPHA_SIZE
#define CGL_TEXTURE_LUMINANCE_SIZE GL_TEXTURE_LUMINANCE_SIZE
#define CGL_TEXTURE_INTENSITY_SIZE GL_TEXTURE_INTENSITY_SIZE
#define CGL_NEAREST_MIPMAP_NEAREST GL_NEAREST_MIPMAP_NEAREST
#define CGL_NEAREST_MIPMAP_LINEAR GL_NEAREST_MIPMAP_LINEAR
#define CGL_LINEAR_MIPMAP_NEAREST GL_LINEAR_MIPMAP_NEAREST
#define CGL_LINEAR_MIPMAP_LINEAR GL_LINEAR_MIPMAP_LINEAR
#define CGL_OBJECT_LINEAR GL_OBJECT_LINEAR
#define CGL_OBJECT_PLANE GL_OBJECT_PLANE
#define CGL_EYE_LINEAR GL_EYE_LINEAR
@ -431,7 +421,6 @@ typedef GLuint COGLuint;
#define CGL_SPHERE_MAP GL_SPHERE_MAP
#define CGL_DECAL GL_DECAL
#define CGL_MODULATE GL_MODULATE
#define CGL_NEAREST GL_NEAREST
#define CGL_REPEAT GL_REPEAT
#define CGL_CLAMP GL_CLAMP
#define CGL_S GL_S
@ -693,9 +682,6 @@ typedef GLuint COGLuint;
#define CGL_UNSIGNED_SHORT_8_8_MESA 0
#endif
#define CGL_FRAGMENT_SHADER GL_FRAGMENT_SHADER_ARB
#define CGL_VERTEX_SHADER GL_VERTEX_SHADER_ARB
#define CGL_OBJECT_COMPILE_STATUS GL_OBJECT_COMPILE_STATUS_ARB
#define CLUTTER_COGL_HAS_GL 1

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -150,15 +148,6 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
return _cogl_offscreen_handle_new (fbo);
}
CoglHandle
cogl_offscreen_new_multisample ()
{
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_MULTISAMPLE))
return COGL_INVALID_HANDLE;
return COGL_INVALID_HANDLE;
}
static void
_cogl_offscreen_free (CoglFbo *fbo)
{
@ -173,80 +162,16 @@ _cogl_offscreen_free (CoglFbo *fbo)
}
void
cogl_offscreen_blit_region (CoglHandle src_buffer,
CoglHandle dst_buffer,
int src_x,
int src_y,
int src_w,
int src_h,
int dst_x,
int dst_y,
int dst_w,
int dst_h)
{
CoglFbo *src_fbo;
CoglFbo *dst_fbo;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_BLIT))
return;
/* Make sure these are valid fbo handles */
if (!cogl_is_offscreen (src_buffer))
return;
if (!cogl_is_offscreen (dst_buffer))
return;
src_fbo = _cogl_offscreen_pointer_from_handle (src_buffer);
dst_fbo = _cogl_offscreen_pointer_from_handle (dst_buffer);
/* Copy (and scale) a region from one to another framebuffer */
GE( glBindFramebufferEXT (GL_READ_FRAMEBUFFER_EXT, src_fbo->gl_handle) );
GE( glBindFramebufferEXT (GL_DRAW_FRAMEBUFFER_EXT, dst_fbo->gl_handle) );
GE( glBlitFramebufferEXT (src_x, src_y, src_x + src_w, src_y + src_h,
dst_x, dst_y, dst_x + dst_w, dst_y + dst_h,
GL_COLOR_BUFFER_BIT, GL_LINEAR) );
}
void
cogl_offscreen_blit (CoglHandle src_buffer,
CoglHandle dst_buffer)
{
CoglFbo *src_fbo;
CoglFbo *dst_fbo;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_BLIT))
return;
/* Make sure these are valid fbo handles */
if (!cogl_is_offscreen (src_buffer))
return;
if (!cogl_is_offscreen (dst_buffer))
return;
src_fbo = _cogl_offscreen_pointer_from_handle (src_buffer);
dst_fbo = _cogl_offscreen_pointer_from_handle (dst_buffer);
/* Copy (and scale) whole image from one to another framebuffer */
GE( glBindFramebufferEXT (GL_READ_FRAMEBUFFER_EXT, src_fbo->gl_handle) );
GE( glBindFramebufferEXT (GL_DRAW_FRAMEBUFFER_EXT, dst_fbo->gl_handle) );
GE( glBlitFramebufferEXT (0, 0, src_fbo->width, src_fbo->height,
0, 0, dst_fbo->width, dst_fbo->height,
GL_COLOR_BUFFER_BIT, GL_LINEAR) );
}
void
cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
{
CoglFbo *fbo = NULL;
CoglDrawBufferState *draw_buffer;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_assert (ctx->draw_buffer_stack != NULL);
draw_buffer = ctx->draw_buffer_stack->data;
if (target == COGL_OFFSCREEN_BUFFER)
{
/* Make sure it is a valid fbo handle */
@ -256,7 +181,7 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
fbo = _cogl_offscreen_pointer_from_handle (offscreen);
/* Check current draw buffer target */
if (ctx->draw_buffer != COGL_OFFSCREEN_BUFFER)
if (draw_buffer->target != COGL_OFFSCREEN_BUFFER)
{
/* Push the viewport and matrix setup if redirecting
from a non-screen buffer */
@ -299,13 +224,11 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
GE( glEnable (GL_SCISSOR_TEST) );
GE( glClear (GL_COLOR_BUFFER_BIT) );
GE( glPopAttrib () );
}
else if ((target & COGL_WINDOW_BUFFER) ||
(target & COGL_MASK_BUFFER))
else if (target & COGL_WINDOW_BUFFER)
{
/* Check current draw buffer target */
if (ctx->draw_buffer == COGL_OFFSCREEN_BUFFER)
if (draw_buffer->target == COGL_OFFSCREEN_BUFFER)
{
/* Pop viewport and matrices if redirecting back
from an offscreen buffer */
@ -320,19 +243,74 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
/* Bind window framebuffer object */
GE( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0) );
if (target == COGL_MASK_BUFFER)
{
/* Draw only to ALPHA channel */
GE( glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE) );
}
else
{
/* Draw to all channels */
GE( glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) );
}
}
/* Store new target */
ctx->draw_buffer = target;
draw_buffer->target = target;
if (draw_buffer->offscreen != offscreen)
{
if (draw_buffer->offscreen != COGL_INVALID_HANDLE)
cogl_handle_unref (draw_buffer->offscreen);
if (offscreen != COGL_INVALID_HANDLE)
cogl_handle_ref (offscreen);
draw_buffer->offscreen = offscreen;
}
}
void
cogl_push_draw_buffer(void)
{
CoglDrawBufferState *old;
CoglDrawBufferState *draw_buffer;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_assert (ctx->draw_buffer_stack != NULL);
old = ctx->draw_buffer_stack->data;
draw_buffer = g_slice_new0 (CoglDrawBufferState);
*draw_buffer = *old;
ctx->draw_buffer_stack =
g_slist_prepend (ctx->draw_buffer_stack, draw_buffer);
}
void
cogl_pop_draw_buffer(void)
{
CoglDrawBufferState *to_pop;
CoglDrawBufferState *to_restore;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_assert (ctx->draw_buffer_stack != NULL);
if (ctx->draw_buffer_stack->next == NULL)
{
g_warning ("1 more cogl_pop_draw_buffer() than cogl_push_draw_buffer()");
return;
}
to_pop = ctx->draw_buffer_stack->data;
to_restore = ctx->draw_buffer_stack->next->data;
/* the logic in cogl_set_draw_buffer() only works if
* to_pop is still on top of the stack, because
* cogl_set_draw_buffer() needs to know the previous
* state.
*/
cogl_set_draw_buffer (to_restore->target, to_restore->offscreen);
/* cogl_set_draw_buffer() should have set top of stack
* to to_restore
*/
g_assert (to_restore->target == to_pop->target);
g_assert (to_restore->offscreen == to_pop->offscreen);
g_assert (ctx->draw_buffer_stack->data == to_pop);
ctx->draw_buffer_stack =
g_slist_remove_link (ctx->draw_buffer_stack,
ctx->draw_buffer_stack);
g_slice_free (CoglDrawBufferState, to_pop);
}

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,68 +0,0 @@
/*
* Clutter COGL
*
* A basic GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
*
* 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __COGL_INTERNAL_H
#define __COGL_INTERNAL_H
#define COGL_DEBUG 0
#if COGL_DEBUG
#include <stdio.h>
const char *_cogl_error_string(GLenum errorCode);
#define GE(x...) G_STMT_START { \
GLenum err; \
(x); \
while ((err = glGetError()) != GL_NO_ERROR) { \
fprintf(stderr, "glError: %s caught at %s:%u\n", \
(char *)_cogl_error_string(err), \
__FILE__, __LINE__); \
} \
} G_STMT_END
#else /* COGL_DEBUG */
#define GE(x) (x)
#endif /* COGL_DEBUG */
#define COGL_ENABLE_BLEND (1<<1)
#define COGL_ENABLE_ALPHA_TEST (1<<2)
#define COGL_ENABLE_VERTEX_ARRAY (1<<3)
#define COGL_ENABLE_COLOR_ARRAY (1<<4)
#define COGL_ENABLE_BACKFACE_CULLING (1<<5)
gint
_cogl_get_format_bpp (CoglPixelFormat format);
void
cogl_enable (gulong flags);
gulong
cogl_get_enable ();
#endif /* __COGL_INTERNAL_H */

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2008 OpenedHand
* Copyright (C) 2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -141,7 +139,7 @@ cogl_program_use (CoglHandle handle)
glUseProgramObjectARB (gl_handle);
}
COGLint
int
cogl_program_get_uniform_location (CoglHandle handle,
const gchar *uniform_name)
{
@ -157,7 +155,7 @@ cogl_program_get_uniform_location (CoglHandle handle,
}
void
cogl_program_uniform_1f (COGLint uniform_no,
cogl_program_uniform_1f (int uniform_no,
gfloat value)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -165,7 +163,7 @@ cogl_program_uniform_1f (COGLint uniform_no,
}
void
cogl_program_uniform_1i (COGLint uniform_no,
cogl_program_uniform_1i (int uniform_no,
gint value)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -173,7 +171,7 @@ cogl_program_uniform_1i (COGLint uniform_no,
}
void
cogl_program_uniform_float (COGLint uniform_no,
cogl_program_uniform_float (int uniform_no,
gint size,
gint count,
const GLfloat *value)
@ -200,10 +198,10 @@ cogl_program_uniform_float (COGLint uniform_no,
}
void
cogl_program_uniform_int (COGLint uniform_no,
cogl_program_uniform_int (int uniform_no,
gint size,
gint count,
const COGLint *value)
const int *value)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -227,7 +225,7 @@ cogl_program_uniform_int (COGLint uniform_no,
}
void
cogl_program_uniform_matrix (COGLint uniform_no,
cogl_program_uniform_matrix (int uniform_no,
gint size,
gint count,
gboolean transpose,

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2008 OpenedHand
* Copyright (C) 2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2008 OpenedHand
* Copyright (C) 2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2008 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -57,21 +55,33 @@ _cogl_shader_free (CoglShader *shader)
}
CoglHandle
cogl_create_shader (COGLenum shaderType)
cogl_create_shader (CoglShaderType type)
{
CoglShader *shader;
GLenum gl_type;
_COGL_GET_CONTEXT (ctx, 0);
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
if (type == COGL_SHADER_TYPE_VERTEX)
gl_type = GL_VERTEX_SHADER;
else if (type == COGL_SHADER_TYPE_FRAGMENT)
gl_type = GL_FRAGMENT_SHADER;
else
{
g_warning ("Unexpected shader type (0x%08lX) given to "
"cogl_create_shader", (unsigned long) type);
return COGL_INVALID_HANDLE;
}
shader = g_slice_new (CoglShader);
shader->gl_handle = glCreateShaderObjectARB (shaderType);
shader->gl_handle = glCreateShaderObjectARB (gl_type);
return _cogl_shader_handle_new (shader);
}
void
cogl_shader_source (CoglHandle handle,
const gchar *source)
const char *source)
{
CoglShader *shader;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -100,11 +110,11 @@ cogl_shader_compile (CoglHandle handle)
void
cogl_shader_get_info_log (CoglHandle handle,
guint size,
gchar *buffer)
size_t size,
char *buffer)
{
CoglShader *shader;
COGLint len;
int len;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (!cogl_is_shader (handle))
@ -116,18 +126,51 @@ cogl_shader_get_info_log (CoglHandle handle,
buffer[len]='\0';
}
void
cogl_shader_get_parameteriv (CoglHandle handle,
COGLenum pname,
COGLint *dest)
CoglShaderType
cogl_shader_get_type (CoglHandle handle)
{
GLint type;
CoglShader *shader;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
_COGL_GET_CONTEXT (ctx, COGL_SHADER_TYPE_VERTEX);
if (!cogl_is_shader (handle))
return;
{
g_warning ("Non shader handle type passed to cogl_shader_get_type");
return COGL_SHADER_TYPE_VERTEX;
}
shader = _cogl_shader_pointer_from_handle (handle);
glGetObjectParameterivARB (shader->gl_handle, pname, dest);
GE (glGetObjectParameterivARB (shader->gl_handle, GL_SHADER_TYPE, &type));
if (type == GL_VERTEX_SHADER)
return COGL_SHADER_TYPE_VERTEX;
else if (type == GL_FRAGMENT_SHADER)
return COGL_SHADER_TYPE_VERTEX;
else
{
g_warning ("Unexpected shader type 0x%08lX", (unsigned long)type);
return COGL_SHADER_TYPE_VERTEX;
}
}
gboolean
cogl_shader_is_compiled (CoglHandle handle)
{
GLint status;
CoglShader *shader;
_COGL_GET_CONTEXT (ctx, FALSE);
if (!cogl_is_shader (handle))
return FALSE;
shader = _cogl_shader_pointer_from_handle (handle);
GE (glGetObjectParameterivARB (shader->gl_handle, GL_COMPILE_STATUS, &status));
if (status == GL_TRUE)
return TRUE;
else
return FALSE;
}

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -26,7 +24,7 @@
#ifndef __COGL_TEXTURE_H
#define __COGL_TEXTURE_H
#include "cogl-bitmap.h"
#include "cogl-bitmap-private.h"
#include "cogl-handle.h"
typedef struct _CoglTexture CoglTexture;
@ -70,8 +68,8 @@ struct _CoglTexture
GArray *slice_y_spans;
GArray *slice_gl_handles;
gint max_waste;
COGLenum min_filter;
COGLenum mag_filter;
CoglTextureFilter min_filter;
CoglTextureFilter mag_filter;
gboolean is_foreign;
GLint wrap_mode;
gboolean auto_mipmap;

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -21,6 +19,11 @@
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* Matthew Allum <mallum@openedhand.com>
* Neil Roberts <neil@linux.intel.com>
* Robert Bragg <robert@linux.intel.com>
*/
#ifdef HAVE_CONFIG_H
@ -31,6 +34,7 @@
#include "cogl-internal.h"
#include "cogl-util.h"
#include "cogl-bitmap.h"
#include "cogl-bitmap-private.h"
#include "cogl-texture-private.h"
#include "cogl-material.h"
#include "cogl-context.h"
@ -40,17 +44,6 @@
#include <stdlib.h>
#include <math.h>
/*
#define COGL_DEBUG 1
#define GE(x) \
{ \
glGetError(); x; \
GLuint err = glGetError(); \
if (err != 0) \
printf("err: 0x%x\n", err); \
} */
#ifdef HAVE_COGL_GL
#define glDrawRangeElements ctx->pf_glDrawRangeElements
@ -939,12 +932,11 @@ _cogl_texture_slices_create (CoglTexture *tex)
{
x_span = &g_array_index (tex->slice_x_spans, CoglTexSliceSpan, x);
#if COGL_DEBUG
printf ("CREATE SLICE (%d,%d)\n", x,y);
printf ("size: (%d x %d)\n",
x_span->size - x_span->waste,
y_span->size - y_span->waste);
#endif
COGL_NOTE (TEXTURE, "CREATE SLICE (%d,%d)\tsize (%d,%d)",
x, y,
x_span->size - x_span->waste,
y_span->size - y_span->waste);
/* Setup texture parameters */
GE( glBindTexture (tex->gl_target,
gl_handles[y * n_x_slices + x]) );
@ -1243,8 +1235,8 @@ cogl_texture_new_with_size (guint width,
tex->slice_gl_handles = NULL;
tex->max_waste = max_waste;
tex->min_filter = CGL_NEAREST;
tex->mag_filter = CGL_NEAREST;
tex->min_filter = COGL_TEXTURE_FILTER_NEAREST;
tex->mag_filter = COGL_TEXTURE_FILTER_NEAREST;
/* Find closest GL format match */
tex->bitmap.format =
@ -1304,8 +1296,8 @@ cogl_texture_new_from_data (guint width,
tex->slice_gl_handles = NULL;
tex->max_waste = max_waste;
tex->min_filter = CGL_NEAREST;
tex->mag_filter = CGL_NEAREST;
tex->min_filter = COGL_TEXTURE_FILTER_NEAREST;
tex->mag_filter = COGL_TEXTURE_FILTER_NEAREST;
/* FIXME: If upload fails we should set some kind of
* error flag but still return texture handle (this
@ -1336,12 +1328,15 @@ cogl_texture_new_from_data (guint width,
}
CoglHandle
cogl_texture_new_from_bitmap (CoglBitmap *bmp,
cogl_texture_new_from_bitmap (CoglHandle bmp_handle,
gint max_waste,
CoglTextureFlags flags,
CoglPixelFormat internal_format)
{
CoglTexture *tex;
CoglBitmap *bmp = (CoglBitmap *)bmp_handle;
g_return_val_if_fail (bmp_handle != COGL_INVALID_HANDLE, COGL_INVALID_HANDLE);
/* Create new texture and fill with loaded data */
tex = (CoglTexture*) g_malloc ( sizeof (CoglTexture));
@ -1358,8 +1353,8 @@ cogl_texture_new_from_bitmap (CoglBitmap *bmp,
tex->slice_gl_handles = NULL;
tex->max_waste = max_waste;
tex->min_filter = CGL_NEAREST;
tex->mag_filter = CGL_NEAREST;
tex->min_filter = COGL_TEXTURE_FILTER_NEAREST;
tex->mag_filter = COGL_TEXTURE_FILTER_NEAREST;
/* FIXME: If upload fails we should set some kind of
* error flag but still return texture handle if the
@ -1399,19 +1394,20 @@ cogl_texture_new_from_file (const gchar *filename,
CoglPixelFormat internal_format,
GError **error)
{
CoglBitmap *bmp;
CoglHandle bmp;
CoglHandle handle;
g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE);
if (!(bmp = cogl_bitmap_new_from_file (filename, error)))
bmp = cogl_bitmap_new_from_file (filename, error);
if (bmp == COGL_INVALID_HANDLE)
return COGL_INVALID_HANDLE;
handle = cogl_texture_new_from_bitmap (bmp,
max_waste,
flags,
internal_format);
cogl_bitmap_free (bmp);
cogl_handle_unref (bmp);
return handle;
}
@ -1685,7 +1681,7 @@ cogl_texture_get_gl_texture (CoglHandle handle,
return TRUE;
}
COGLenum
CoglTextureFilter
cogl_texture_get_min_filter (CoglHandle handle)
{
CoglTexture *tex;
@ -1698,7 +1694,7 @@ cogl_texture_get_min_filter (CoglHandle handle)
return tex->min_filter;
}
COGLenum
CoglTextureFilter
cogl_texture_get_mag_filter (CoglHandle handle)
{
CoglTexture *tex;
@ -1713,8 +1709,8 @@ cogl_texture_get_mag_filter (CoglHandle handle)
void
cogl_texture_set_filters (CoglHandle handle,
COGLenum min_filter,
COGLenum mag_filter)
CoglTextureFilter min_filter,
CoglTextureFilter mag_filter)
{
CoglTexture *tex;
GLuint gl_handle;

View file

@ -1,9 +1,9 @@
/*
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007,2008,2009 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -8,6 +8,7 @@ libclutterinclude_HEADERS = \
$(top_builddir)/clutter/cogl/cogl-offscreen.h \
$(top_builddir)/clutter/cogl/cogl-path.h \
$(top_builddir)/clutter/cogl/cogl-shader.h \
$(top_builddir)/clutter/cogl/cogl-bitmap.h \
$(top_builddir)/clutter/cogl/cogl-texture.h \
$(top_builddir)/clutter/cogl/cogl-types.h \
$(top_builddir)/clutter/cogl/cogl-vertex-buffer.h \
@ -24,16 +25,13 @@ INCLUDES = \
-I$(top_builddir)/clutter \
-I$(top_builddir)/clutter/cogl \
-DG_LOG_DOMAIN=\"Cogl-GLES\" \
-DCLUTTER_COMPILATION \
$(CLUTTER_CFLAGS) \
$(CLUTTER_DEBUG_CFLAGS) \
$(MAINTAINER_CFLAGS) \
$(GCC_FLAGS)
LDADD = $(CLUTTER_LIBS)
-DCLUTTER_COMPILATION
noinst_LTLIBRARIES = libclutter-cogl.la
libclutter_cogl_la_CPPFLAGS = $(CLUTTER_CFLAGS) $(COGL_DEBUG_CFLAGS) $(CLUTTER_DEBUG_CFLAGS) $(MAINTAINER_CFLAGS)
libclutter_cogl_la_LIBADD = -lm $(CLUTTER_LIBS) $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la
libclutter_cogl_la_DEPENDENCIES = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la
libclutter_cogl_la_SOURCES = \
$(top_builddir)/clutter/cogl/cogl.h \
$(top_builddir)/clutter/cogl/cogl-defines-gles.h \
@ -43,10 +41,10 @@ libclutter_cogl_la_SOURCES = \
$(top_builddir)/clutter/cogl/cogl-offscreen.h \
$(top_builddir)/clutter/cogl/cogl-path.h \
$(top_builddir)/clutter/cogl/cogl-shader.h \
$(top_builddir)/clutter/cogl/cogl-bitmap.h \
$(top_builddir)/clutter/cogl/cogl-texture.h \
$(top_builddir)/clutter/cogl/cogl-types.h \
$(top_builddir)/clutter/cogl/cogl-debug.h \
cogl-internal.h \
cogl-texture-private.h \
cogl-fbo.h \
cogl-context.h \
@ -75,8 +73,6 @@ EXTRA_DIST = cogl-defines.h.in \
cogl-fixed-vertex-shader.glsl \
cogl-fixed-fragment-shader.glsl
libclutter_cogl_la_LIBADD = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la
.glsl.h :
/bin/sh $(top_srcdir)/clutter/cogl/gles/stringify.sh -h $<

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -46,6 +44,7 @@ cogl_create_context ()
{
GLubyte default_texture_data[] = { 0xff, 0xff, 0xff, 0x0 };
gulong enable_flags = 0;
CoglDrawBufferState *draw_buffer;
if (_context != NULL)
return FALSE;
@ -83,7 +82,11 @@ cogl_create_context ()
sizeof (CoglLayerInfo));
_context->n_texcoord_arrays_enabled = 0;
_context->draw_buffer = COGL_WINDOW_BUFFER;
draw_buffer = g_slice_new0 (CoglDrawBufferState);
draw_buffer->target = COGL_WINDOW_BUFFER;
draw_buffer->offscreen = COGL_INVALID_HANDLE;
_context->draw_buffer_stack =
g_slist_prepend (NULL, draw_buffer);
_context->path_nodes = g_array_new (FALSE, FALSE, sizeof (CoglPathNode));
_context->last_path = 0;

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -40,6 +38,12 @@ typedef struct
GLubyte c[4];
} CoglTextureGLVertex;
typedef struct
{
CoglBufferTarget target;
CoglHandle offscreen;
} CoglDrawBufferState;
typedef struct
{
/* Features cache */
@ -86,7 +90,7 @@ typedef struct
guint n_texcoord_arrays_enabled;
/* Framebuffer objects */
CoglBufferTarget draw_buffer;
GSList *draw_buffer_stack;
/* Clip stack */
CoglClipStackState clip;

View file

@ -26,6 +26,7 @@
#ifndef __COGL_DEFINES_H__
#define __COGL_DEFINES_H__
#include <glib.h>
#include <@CLUTTER_GL_HEADER@>
G_BEGIN_DECLS
@ -429,10 +430,6 @@ G_BEGIN_DECLS
#define CGL_WEIGHT_ARRAY_BUFFER_BINDING_OES GL_WEIGHT_ARRAY_BUFFER_BINDING_OES
#define CGL_TEXTURE_CROP_RECT_OES GL_TEXTURE_CROP_RECT_OES
typedef GLenum COGLenum;
typedef GLint COGLint;
typedef GLuint COGLuint;
/* extras */
/* YUV textures also unsupported */
@ -440,18 +437,6 @@ typedef GLuint COGLuint;
#define CGL_UNSIGNED_SHORT_8_8_REV_MESA 0
#define CGL_UNSIGNED_SHORT_8_8_MESA 0
#ifdef GL_FRAGMENT_SHADER
#define CGL_FRAGMENT_SHADER GL_FRAGMENT_SHADER
#else
#define CGL_FRAGMENT_SHADER 0
#endif
#ifdef GL_VERTEX_SHADER
#define CGL_VERTEX_SHADER GL_VERTEX_SHADER
#else
#define CGL_VERTEX_SHADER 0
#endif
#if defined(GL_OBJECT_COMPILE_STATUS)
#define CGL_OBJECT_COMPILE_STATUS GL_OBJECT_COMPILE_STATUS
#elif defined(GL_COMPILE_STATUS)

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2008 OpenedHand
* Copyright (C) 2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -132,15 +130,6 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
return _cogl_offscreen_handle_new (fbo);
}
CoglHandle
cogl_offscreen_new_multisample ()
{
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN_MULTISAMPLE))
return COGL_INVALID_HANDLE;
return COGL_INVALID_HANDLE;
}
static void
_cogl_offscreen_free (CoglFbo *fbo)
{
@ -155,36 +144,16 @@ _cogl_offscreen_free (CoglFbo *fbo)
}
void
cogl_offscreen_blit_region (CoglHandle src_buffer,
CoglHandle dst_buffer,
int src_x,
int src_y,
int src_w,
int src_h,
int dst_x,
int dst_y,
int dst_w,
int dst_h)
{
/* Not supported on GLES */
return;
}
void
cogl_offscreen_blit (CoglHandle src_buffer,
CoglHandle dst_buffer)
{
/* Not supported on GLES */
return;
}
void
cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
{
CoglFbo *fbo = NULL;
CoglDrawBufferState *draw_buffer;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_assert (ctx->draw_buffer_stack != NULL);
draw_buffer = ctx->draw_buffer_stack->data;
if (target == COGL_OFFSCREEN_BUFFER)
{
GLboolean scissor_enabled;
@ -197,7 +166,7 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
fbo = _cogl_offscreen_pointer_from_handle (offscreen);
/* Check current draw buffer target */
if (ctx->draw_buffer != COGL_OFFSCREEN_BUFFER)
if (draw_buffer->target != COGL_OFFSCREEN_BUFFER)
{
/* Push the viewport and matrix setup if redirecting
from a non-screen buffer */
@ -247,11 +216,10 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
scissor_box[2], scissor_box[3]);
}
else if ((target & COGL_WINDOW_BUFFER) ||
(target & COGL_MASK_BUFFER))
else if (target & COGL_WINDOW_BUFFER)
{
/* Check current draw buffer target */
if (ctx->draw_buffer == COGL_OFFSCREEN_BUFFER)
if (draw_buffer->target == COGL_OFFSCREEN_BUFFER)
{
/* Pop viewport and matrices if redirecting back
from an offscreen buffer */
@ -267,27 +235,75 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
/* Bind window framebuffer object */
GE( glBindFramebuffer (GL_FRAMEBUFFER, 0) );
if (target == COGL_WINDOW_BUFFER)
{
/* Draw to RGB channels */
GE( glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) );
}
else if (target == COGL_MASK_BUFFER)
{
/* Draw only to ALPHA channel */
GE( glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE) );
}
else
{
/* Draw to all channels */
GE( glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) );
}
}
/* Store new target */
ctx->draw_buffer = target;
draw_buffer->target = target;
if (draw_buffer->offscreen != offscreen)
{
if (draw_buffer->offscreen != COGL_INVALID_HANDLE)
cogl_handle_unref (draw_buffer->offscreen);
if (offscreen != COGL_INVALID_HANDLE)
cogl_handle_ref (offscreen);
draw_buffer->offscreen = offscreen;
}
}
void
cogl_push_draw_buffer(void)
{
CoglDrawBufferState *old;
CoglDrawBufferState *draw_buffer;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_assert (ctx->draw_buffer_stack != NULL);
old = ctx->draw_buffer_stack->data;
draw_buffer = g_slice_new0 (CoglDrawBufferState);
*draw_buffer = *old;
ctx->draw_buffer_stack =
g_slist_prepend (ctx->draw_buffer_stack, draw_buffer);
}
void
cogl_pop_draw_buffer(void)
{
CoglDrawBufferState *to_pop;
CoglDrawBufferState *to_restore;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_assert (ctx->draw_buffer_stack != NULL);
if (ctx->draw_buffer_stack->next == NULL)
{
g_warning ("1 more cogl_pop_draw_buffer() than cogl_push_draw_buffer()");
return;
}
to_pop = ctx->draw_buffer_stack->data;
to_restore = ctx->draw_buffer_stack->next->data;
/* the logic in cogl_set_draw_buffer() only works if
* to_pop is still on top of the stack, because
* cogl_set_draw_buffer() needs to know the previous
* state.
*/
cogl_set_draw_buffer (to_restore->target, to_restore->offscreen);
/* cogl_set_draw_buffer() should have set top of stack
* to to_restore
*/
g_assert (to_restore->target == to_pop->target);
g_assert (to_restore->offscreen == to_pop->offscreen);
g_assert (ctx->draw_buffer_stack->data == to_pop);
ctx->draw_buffer_stack =
g_slist_remove_link (ctx->draw_buffer_stack,
ctx->draw_buffer_stack);
g_slice_free (CoglDrawBufferState, to_pop);
}
#else /* HAVE_COGL_GLES2 */
@ -306,12 +322,6 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
return COGL_INVALID_HANDLE;
}
CoglHandle
cogl_offscreen_new_multisample ()
{
return COGL_INVALID_HANDLE;
}
CoglHandle
cogl_offscreen_ref (CoglHandle handle)
{
@ -324,27 +334,7 @@ cogl_offscreen_unref (CoglHandle handle)
}
void
cogl_offscreen_blit_region (CoglHandle src_buffer,
CoglHandle dst_buffer,
int src_x,
int src_y,
int src_w,
int src_h,
int dst_x,
int dst_y,
int dst_w,
int dst_h)
{
}
void
cogl_offscreen_blit (CoglHandle src_buffer,
CoglHandle dst_buffer)
{
}
void
cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
{
}

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2008 OpenedHand
* Copyright (C) 2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2008 OpenedHand
* Copyright (C) 2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,95 +0,0 @@
/*
* Clutter COGL
*
* A basic GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
*
* 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __COGL_INTERNAL_H
#define __COGL_INTERNAL_H
typedef enum {
COGL_BOXED_NONE,
COGL_BOXED_INT,
COGL_BOXED_FLOAT,
COGL_BOXED_MATRIX
} CoglBoxedType;
typedef struct _CoglBoxedValue
{
CoglBoxedType type;
int size, count;
gboolean transpose;
union {
gfloat float_value[4];
gint int_value[4];
gfloat matrix[16];
gfloat *float_array;
gint *int_array;
gpointer array;
} v;
} CoglBoxedValue;
#define COGL_DEBUG 0
#if COGL_DEBUG
#include <stdio.h>
const char *_cogl_error_string(GLenum errorCode);
#define GE(x...) G_STMT_START { \
GLenum err; \
(x); \
while ((err = glGetError()) != GL_NO_ERROR) { \
fprintf(stderr, "glError: %s caught at %s:%u\n", \
(char *)_cogl_error_string(err), \
__FILE__, __LINE__); \
} \
} G_STMT_END
#else /* COGL_DEBUG */
#define GE(x) (x)
#endif /* COGL_DEBUG */
#define COGL_ENABLE_BLEND (1<<1)
#define COGL_ENABLE_ALPHA_TEST (1<<2)
#define COGL_ENABLE_VERTEX_ARRAY (1<<3)
#define COGL_ENABLE_COLOR_ARRAY (1<<4)
#define COGL_ENABLE_BACKFACE_CULLING (1<<5)
void
_cogl_features_init (void);
gint
_cogl_get_format_bpp (CoglPixelFormat format);
void
cogl_enable (gulong flags);
gulong
cogl_get_enable ();
#endif /* __COGL_INTERNAL_H */

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2008 OpenedHand
* Copyright (C) 2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -124,7 +122,7 @@ cogl_program_use (CoglHandle handle)
ctx->gles2.settings_dirty = TRUE;
}
COGLint
int
cogl_program_get_uniform_location (CoglHandle handle,
const gchar *uniform_name)
{
@ -157,21 +155,21 @@ cogl_program_get_uniform_location (CoglHandle handle,
}
void
cogl_program_uniform_1f (COGLint uniform_no,
cogl_program_uniform_1f (int uniform_no,
gfloat value)
{
cogl_program_uniform_float (uniform_no, 1, 1, &value);
}
void
cogl_program_uniform_1i (COGLint uniform_no,
cogl_program_uniform_1i (int uniform_no,
gint value)
{
cogl_program_uniform_int (uniform_no, 1, 1, &value);
}
static void
cogl_program_uniform_x (COGLint uniform_no,
cogl_program_uniform_x (int uniform_no,
gint size,
gint count,
CoglBoxedType type,
@ -217,7 +215,7 @@ cogl_program_uniform_x (COGLint uniform_no,
}
void
cogl_program_uniform_float (COGLint uniform_no,
cogl_program_uniform_float (int uniform_no,
gint size,
gint count,
const GLfloat *value)
@ -227,7 +225,7 @@ cogl_program_uniform_float (COGLint uniform_no,
}
void
cogl_program_uniform_int (COGLint uniform_no,
cogl_program_uniform_int (int uniform_no,
gint size,
gint count,
const GLint *value)
@ -237,7 +235,7 @@ cogl_program_uniform_int (COGLint uniform_no,
}
void
cogl_program_uniform_matrix (COGLint uniform_no,
cogl_program_uniform_matrix (int uniform_no,
gint size,
gint count,
gboolean transpose,
@ -298,7 +296,7 @@ cogl_program_use (CoglHandle program_handle)
{
}
COGLint
int
cogl_program_get_uniform_location (CoglHandle program_handle,
const gchar *uniform_name)
{
@ -306,13 +304,13 @@ cogl_program_get_uniform_location (CoglHandle program_handle,
}
void
cogl_program_uniform_1f (COGLint uniform_no,
cogl_program_uniform_1f (int uniform_no,
gfloat value)
{
}
void
cogl_program_uniform_float (COGLint uniform_no,
cogl_program_uniform_float (int uniform_no,
gint size,
gint count,
const GLfloat *value)
@ -320,15 +318,15 @@ cogl_program_uniform_float (COGLint uniform_no,
}
void
cogl_program_uniform_int (COGLint uniform_no,
cogl_program_uniform_int (int uniform_no,
gint size,
gint count,
const COGLint *value)
const int *value)
{
}
void
cogl_program_uniform_matrix (COGLint uniform_no,
cogl_program_uniform_matrix (int uniform_no,
gint size,
gint count,
gboolean transpose,

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2008 OpenedHand
* Copyright (C) 2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2008 OpenedHand
* Copyright (C) 2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2008 OpenedHand
* Copyright (C) 2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -50,22 +48,31 @@ _cogl_shader_free (CoglShader *shader)
}
CoglHandle
cogl_create_shader (COGLenum shaderType)
cogl_create_shader (CoglShaderType type)
{
CoglShader *shader;
GLenum gl_type;
_COGL_GET_CONTEXT (ctx, 0);
if (type == COGL_SHADER_TYPE_VERTEX)
gl_type = GL_VERTEX_SHADER;
else if (type == COGL_SHADER_TYPE_FRAGMENT)
gl_type = GL_FRAGMENT_SHADER;
else
{
g_warning ("Unexpected shader type (0x%08lX) given to "
"cogl_create_shader", (unsigned long) type);
return COGL_INVALID_HANDLE;
}
shader = g_slice_new (CoglShader);
shader->gl_handle = glCreateShader (shaderType);
shader->type = shaderType;
shader->gl_handle = glCreateShader (gl_type);
return _cogl_shader_handle_new (shader);
}
void
cogl_shader_source (CoglHandle handle,
const gchar *source)
const char *source)
{
CoglShader *shader;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -94,11 +101,11 @@ cogl_shader_compile (CoglHandle handle)
void
cogl_shader_get_info_log (CoglHandle handle,
guint size,
gchar *buffer)
size_t size,
char *buffer)
{
CoglShader *shader;
COGLint len = 0;
int len = 0;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (!cogl_is_shader (handle))
@ -110,20 +117,48 @@ cogl_shader_get_info_log (CoglHandle handle,
buffer[len] = '\0';
}
void
cogl_shader_get_parameteriv (CoglHandle handle,
COGLenum pname,
COGLint *dest)
CoglShaderType
cogl_shader_get_type (CoglHandle handle)
{
GLint type;
CoglShader *shader;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (!cogl_is_shader (handle))
return;
{
g_warning ("Non shader handle type passed to cogl_shader_get_type");
return COGL_SHADER_TYPE_VERTEX;
}
shader = _cogl_shader_pointer_from_handle (handle);
glGetShaderiv (shader->gl_handle, pname, dest);
GE (glGetShaderiv (shader->gl_handle, GL_SHADER_TYPE, &type));
if (type == GL_VERTEX_SHADER)
return COGL_SHADER_TYPE_VERTEX;
else if (type == GL_FRAGMENT_SHADER)
return COGL_SHADER_TYPE_VERTEX;
else
{
g_warning ("Unexpected shader type 0x%08lX", (unsigned long)type);
return COGL_SHADER_TYPE_VERTEX;
}
}
gboolean
cogl_shader_is_compiled (CoglHandle handle)
{
GLint status;
CoglShader *shader;
if (!cogl_is_shader (handle))
return FALSE;
shader = _cogl_shader_pointer_from_handle (handle);
GE (glGetShaderiv (shader->gl_handle, GL_COMPILE_STATUS, &status));
if (status == GL_TRUE)
return TRUE;
else
return FALSE;
}
#else /* HAVE_COGL_GLES2 */
@ -131,7 +166,7 @@ cogl_shader_get_parameteriv (CoglHandle handle,
/* No support on regular OpenGL 1.1 */
CoglHandle
cogl_create_shader (COGLenum shaderType)
cogl_create_shader (CoglShaderType type)
{
return COGL_INVALID_HANDLE;
}
@ -155,7 +190,7 @@ cogl_shader_unref (CoglHandle handle)
void
cogl_shader_source (CoglHandle shader,
const gchar *source)
const char *source)
{
}
@ -166,16 +201,21 @@ cogl_shader_compile (CoglHandle shader_handle)
void
cogl_shader_get_info_log (CoglHandle handle,
guint size,
gchar *buffer)
size_t size,
char *buffer)
{
}
void
cogl_shader_get_parameteriv (CoglHandle handle,
COGLenum pname,
COGLint *dest)
CoglShaderType
cogl_shader_get_type (CoglHandle handle)
{
return COGL_SHADER_TYPE_VERTEX;
}
gboolean
cogl_shader_is_compiled (CoglHandle handle)
{
return FALSE;
}
#endif /* HAVE_COGL_GLES2 */

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -26,7 +24,7 @@
#ifndef __COGL_TEXTURE_H
#define __COGL_TEXTURE_H
#include "cogl-bitmap.h"
#include "cogl-bitmap-private.h"
#include "cogl-handle.h"
typedef struct _CoglTexture CoglTexture;
@ -70,8 +68,8 @@ struct _CoglTexture
GArray *slice_y_spans;
GArray *slice_gl_handles;
gint max_waste;
COGLenum min_filter;
COGLenum mag_filter;
CoglTextureFilter min_filter;
CoglTextureFilter mag_filter;
gboolean is_foreign;
GLint wrap_mode;
gboolean auto_mipmap;

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -30,7 +28,7 @@
#include "cogl.h"
#include "cogl-internal.h"
#include "cogl-util.h"
#include "cogl-bitmap.h"
#include "cogl-bitmap-private.h"
#include "cogl-texture-private.h"
#include "cogl-material.h"
#include "cogl-context.h"
@ -42,17 +40,6 @@
#include <stdlib.h>
#include <math.h>
/*
#define COGL_DEBUG 1
#define GE(x) \
{ \
glGetError(); x; \
GLuint err = glGetError(); \
if (err != 0) \
printf("err: 0x%x\n", err); \
} */
extern void _cogl_journal_flush (void);
static void _cogl_texture_free (CoglTexture *tex);
@ -485,9 +472,6 @@ _cogl_texture_download_from_gl (CoglTexture *tex,
_cogl_current_matrix_push ();
_cogl_current_matrix_identity ();
/* Draw to all channels */
cogl_draw_buffer (COGL_WINDOW_BUFFER | COGL_MASK_BUFFER, 0);
/* Direct copy operation */
if (ctx->texture_download_material == COGL_INVALID_HANDLE)
@ -584,8 +568,6 @@ _cogl_texture_download_from_gl (CoglTexture *tex,
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_current_matrix_pop ();
cogl_draw_buffer (COGL_WINDOW_BUFFER, 0);
return TRUE;
}
@ -1435,12 +1417,13 @@ cogl_texture_new_from_data (guint width,
}
CoglHandle
cogl_texture_new_from_bitmap (CoglBitmap *bmp,
cogl_texture_new_from_bitmap (CoglHandle bmp_handle,
gint max_waste,
CoglTextureFlags flags,
CoglPixelFormat internal_format)
{
CoglTexture *tex;
CoglBitmap *bmp = (CoglBitmap *)bmp_handle;
/* Create new texture and fill with loaded data */
tex = (CoglTexture*) g_malloc ( sizeof (CoglTexture));
@ -1498,19 +1481,20 @@ cogl_texture_new_from_file (const gchar *filename,
CoglPixelFormat internal_format,
GError **error)
{
CoglBitmap *bmp;
CoglHandle bmp;
CoglHandle handle;
g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE);
if (!(bmp = cogl_bitmap_new_from_file (filename, error)))
bmp = cogl_bitmap_new_from_file (filename, error);
if (bmp == COGL_INVALID_HANDLE)
return COGL_INVALID_HANDLE;
handle = cogl_texture_new_from_bitmap (bmp,
max_waste,
flags,
internal_format);
cogl_bitmap_free (bmp);
cogl_handle_unref (bmp);
return handle;
}
@ -1783,7 +1767,7 @@ cogl_texture_get_gl_texture (CoglHandle handle,
return TRUE;
}
COGLenum
CoglTextureFilter
cogl_texture_get_min_filter (CoglHandle handle)
{
CoglTexture *tex;
@ -1796,7 +1780,7 @@ cogl_texture_get_min_filter (CoglHandle handle)
return tex->min_filter;
}
COGLenum
CoglTextureFilter
cogl_texture_get_mag_filter (CoglHandle handle)
{
CoglTexture *tex;
@ -1811,8 +1795,8 @@ cogl_texture_get_mag_filter (CoglHandle handle)
void
cogl_texture_set_filters (CoglHandle handle,
COGLenum min_filter,
COGLenum mag_filter)
CoglTextureFilter min_filter,
CoglTextureFilter mag_filter)
{
CoglTexture *tex;
GLuint gl_handle;

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,11 +1,9 @@
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2007 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,9 +1,9 @@
/*
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007,2008,2009 OpenedHand
* Copyright (C) 2007,2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,16 +1,36 @@
#! /bin/sh
# Cogl
#
# An object oriented GL/GLES Abstraction/Utility Layer
#
# Copyright (C) 2008,2009 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, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
output_copyright ()
{
cat <<EOF > "$1";
/*
* Clutter COGL
* Cogl
*
* A basic GL/GLES Abstraction/Utility Layer
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2008 OpenedHand
* Copyright (C) 2008,2009 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -94,8 +94,6 @@ static RectangleState _rectangle_state = CLUTTER_GLX_RECTANGLE_ALLOW;
struct _ClutterGLXTexturePixmapPrivate
{
COGLenum target_type;
guint texture_id;
GLXPixmap glx_pixmap;
gboolean use_fallback;
@ -141,8 +139,8 @@ texture_bind (ClutterGLXTexturePixmap *tex)
== CLUTTER_TEXTURE_QUALITY_HIGH && tex->priv->can_mipmap)
{
cogl_texture_set_filters (cogl_tex,
CGL_LINEAR_MIPMAP_LINEAR,
CGL_LINEAR);
COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR,
COGL_TEXTURE_FILTER_LINEAR);
}
return TRUE;

View file

@ -311,12 +311,12 @@ cogl_pango_glyph_cache_set (CoglPangoGlyphCache *cache,
if (cache->use_mipmapping)
cogl_texture_set_filters (texture->texture,
CGL_LINEAR_MIPMAP_LINEAR,
CGL_LINEAR);
COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR,
COGL_TEXTURE_FILTER_LINEAR);
else
cogl_texture_set_filters (texture->texture,
CGL_LINEAR,
CGL_LINEAR);
COGL_TEXTURE_FILTER_LINEAR,
COGL_TEXTURE_FILTER_LINEAR);
}
band = g_slice_new (CoglPangoGlyphCacheBand);

View file

@ -95,7 +95,7 @@ static Display *_foreign_dpy = NULL;
/* options */
static gchar *clutter_display_name = NULL;
static gint clutter_screen = 0;
static gint clutter_screen = -1;
static gboolean clutter_synchronise = FALSE;
/* X error trap */
@ -167,7 +167,7 @@ clutter_backend_x11_post_parse (ClutterBackend *backend,
CLUTTER_NOTE (BACKEND, "Getting the X screen");
if (clutter_screen == 0)
if (clutter_screen == -1)
backend_x11->xscreen = DefaultScreenOfDisplay (backend_x11->xdpy);
else
backend_x11->xscreen = ScreenOfDisplay (backend_x11->xdpy,

View file

@ -585,6 +585,24 @@ fi
AC_SUBST(CLUTTER_DEBUG_CFLAGS)
m4_define([cogl_debug_default], [no])
AC_ARG_ENABLE([cogl-debug],
[AC_HELP_STRING([--enable-cogl-debug=@<:@no/yes@:>@],
[Turn on COGL debugging])],
[],
[enable_debug=debug_default])
AS_CASE([$enable_debug],
[yes], [COGL_DEBUG_CFLAGS="-DCOGL_GL_DEBUG -DCOGL_HANDLE_DEBUG -DCOGL_ENABLE_DEBUG"],
[no], [COGL_DEBUG_CFLAGS=""],
[*], [AC_MSG_ERROR([Invalid value for --enable-cogl-debug])]
)
AC_SUBST(COGL_DEBUG_CFLAGS)
dnl = Enable strict compiler flags =========================================
# use strict compiler flags only on development releases
@ -726,7 +744,8 @@ fi
echo " GL Headers: ${CLUTTER_GL_HEADER}"
echo " Image backend: ${imagebackend}"
echo " Target library: ${clutterbackendlib}"
echo " Debug level: ${enable_debug}"
echo " Clutter Debug level: ${enable_debug}"
echo " Enable COGL debug flags: ${enable_cogl_debug}"
echo " Compiler flags: ${CPPFLAGS} ${MAINTAINER_CFLAGS}"
echo " Build API Documentation: ${enable_gtk_doc}"
echo " Build Manual Documentation: ${enable_manual}"

View file

@ -428,6 +428,8 @@ ClutterTextureQuality
clutter_texture_new
clutter_texture_new_from_file
clutter_texture_new_from_actor
<SUBSECTION>
CLUTTER_TEXTURE_ERROR
ClutterTextureError
clutter_texture_set_from_file
@ -435,6 +437,7 @@ clutter_texture_set_from_rgb_data
clutter_texture_set_from_yuv_data
clutter_texture_set_area_from_rgb_data
clutter_texture_get_base_size
clutter_texture_get_pixel_format
clutter_texture_get_filter_quality
clutter_texture_set_filter_quality
clutter_texture_get_max_tile_waste
@ -443,6 +446,16 @@ clutter_texture_get_cogl_texture
clutter_texture_set_cogl_texture
clutter_texture_get_cogl_material
clutter_texture_set_cogl_material
clutter_texture_get_sync_size
clutter_texture_set_sync_size
clutter_texture_get_repeat
clutter_texture_set_repeat
clutter_texture_get_keep_aspect_ratio
clutter_texture_set_keep_aspect_ratio
clutter_texture_get_load_async
clutter_texture_set_load_async
clutter_texture_get_load_data_async
clutter_texture_set_load_data_async
<SUBSECTION Standard>
CLUTTER_TEXTURE
@ -1220,6 +1233,7 @@ clutter_model_set_sort
clutter_model_resort
ClutterModelFilterFunc
clutter_model_set_filter
clutter_model_get_filter_set
clutter_model_filter_iter
clutter_model_filter_row

View file

@ -103,6 +103,13 @@ cogl_path_stroke_preserve
cogl_color
</SECTION>
<SECTION>
<FILE>cogl-bitmap</FILE>
<TITLE>Bitmaps</TITLE>
cogl_bitmap_new_from_file
cogl_bitmap_get_size_from_file
</SECTION>
<SECTION>
<FILE>cogl-texture</FILE>
<TITLE>Textures</TITLE>
@ -130,12 +137,6 @@ cogl_texture_get_gl_texture
cogl_texture_get_data
cogl_texture_set_filters
cogl_texture_set_region
<SUBSECTION>
CoglBitmap
cogl_bitmap_new_from_file
cogl_bitmap_free
cogl_bitmap_get_size_from_file
</SECTION>
<SECTION>
@ -148,7 +149,8 @@ cogl_is_shader
cogl_shader_source
cogl_shader_compile
cogl_shader_get_info_log
cogl_shader_get_parameteriv
cogl_shader_get_type
cogl_shader_is_compiled
<SUBSECTION>
cogl_create_program
cogl_program_ref
@ -172,9 +174,7 @@ cogl_offscreen_new_to_texture
cogl_offscreen_ref
cogl_offscreen_unref
cogl_is_offscreen
cogl_offscreen_blit
cogl_offscreen_blit_region
cogl_draw_buffer
cogl_set_draw_buffer
<SUBSECTION Private>
cogl_offscreen_new_multisample
</SECTION>

Some files were not shown because too many files have changed in this diff Show more