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

75
README
View File

@ -2,7 +2,7 @@ Clutter 1.0 README
================== ==================
Clutter is an open source software library for creating fast, visually Clutter is an open source software library for creating fast, visually
rich and animated graphical user interfaces. rich and animated graphical user interfaces.
Clutter currently requires: Clutter currently requires:
@ -11,15 +11,15 @@ Clutter currently requires:
* OpenGL >= 1.4, OpenGL ES 1.1 or OpenGL ES 2.0 * OpenGL >= 1.4, OpenGL ES 1.1 or OpenGL ES 2.0
* GLX, SDL, WGL or an EGL Implementation * GLX, SDL, WGL or an EGL Implementation
The official website is: The official website is:
http://www.clutter-project.org http://www.clutter-project.org
The Clutter blog is at The Clutter blog is at
http://www.clutter-project.org/blog http://www.clutter-project.org/blog
To subscribe to the Clutter mailing list, send mail to: To subscribe to the Clutter mailing list, send mail to:
clutter+subscribe@o-hand.com clutter+subscribe@o-hand.com
The official mailing list archive is: The official mailing list archive is:
http://lists.o-hand.com/clutter/ http://lists.o-hand.com/clutter/
New bug page on Bugzilla: New bug page on Bugzilla:
http://bugzilla.o-hand.com/enter_bug.cgi?product=Clutter http://bugzilla.o-hand.com/enter_bug.cgi?product=Clutter
Clutter is licensed under the terms of the GNU Lesser General Public Clutter is licensed under the terms of the GNU Lesser General Public
@ -32,7 +32,7 @@ See the INSTALL file. Info on specific Clutter options;
--enable-debug=[no/minimum/yes] --enable-debug=[no/minimum/yes]
Turn on debugging (default=yes): Turn on debugging (default=yes):
yes: All glib asserts, checks and runtime clutter verbose messages. yes: All glib asserts, checks and runtime clutter verbose messages.
minimum: Just glib cast checks and runtime clutter verbose messagaes. minimum: Just glib cast checks and runtime clutter verbose messagaes.
no: No glib asserts or checks and no runtime clutter verbose messages no: No glib asserts or checks and no runtime clutter verbose messages
(Only really of use in extreme performance cases) (Only really of use in extreme performance cases)
@ -40,15 +40,15 @@ See the INSTALL file. Info on specific Clutter options;
--enable-maintainer-flags=[no/yes] --enable-maintainer-flags=[no/yes]
Use strict compiler flags (default=no) Use strict compiler flags (default=no)
--enable-gtk-doc --enable-gtk-doc
use gtk-doc to build API documentation (default=no). Requires gtk-doc use gtk-doc to build API documentation (default=no). Requires gtk-doc
present on system present on system
--enable-manual=[no/yes] --enable-manual=[no/yes]
Build application developers manual. Requires jw and xmlto binaries. Build application developers manual. Requires jw and xmlto binaries.
Presently incomplete. Presently incomplete.
--without-fpu --without-fpu
Assume target hardware has no floating point unit. Useful only Assume target hardware has no floating point unit. Useful only
for embedded targets such as ARM. for embedded targets such as ARM.
@ -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_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_clip_pop respectively so they self document their stacking semantics.
* cogl_paint_init was renamed to cogl_clear and no longer disables lighting * cogl_paint_init was renamed to cogl_clear and no longer disables lighting and
and fogging. 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 * 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 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 * cogl_get_*_matrix were changed to use the CoglMatrix type instead of
GLfloat m[16] arrays. 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 Release Notes for Clutter 0.8
------------------------------- -------------------------------
@ -317,7 +344,7 @@ Release Notes for Clutter 0.8
support. It is now also fully documented. support. It is now also fully documented.
* GL Texture Rectangle ext is no longer used, the regular 2D NPOTS * GL Texture Rectangle ext is no longer used, the regular 2D NPOTS
extension is preffered instead but not required. extension is preffered instead but not required.
* Clutter now has basic suppport for multiple input devices assuming * Clutter now has basic suppport for multiple input devices assuming
the backend supports it (currently X11 based via XInput and Fruity the backend supports it (currently X11 based via XInput and Fruity
@ -326,7 +353,7 @@ Release Notes for Clutter 0.8
clutter_grab_pointer_for_device & clutter_ungrab_pointer_for_device. clutter_grab_pointer_for_device & clutter_ungrab_pointer_for_device.
XInput support needs to be explicitly enabled at runtime by calling XInput support needs to be explicitly enabled at runtime by calling
clutter_x11_enable_xinput () before clutter_init. clutter_x11_has_xinput () clutter_x11_enable_xinput () before clutter_init. clutter_x11_has_xinput ()
can then be called after to check if XInput extension present and use-able. can then be called after to check if XInput extension present and use-able.
* The functions that return the transformed position of an actor have * The functions that return the transformed position of an actor have
@ -422,16 +449,16 @@ Release Notes for Clutter 0.8
* Clutter now features support for multiple stages assuming supported * Clutter now features support for multiple stages assuming supported
by the backend. See test-multistage.c for example of usage. This by the backend. See test-multistage.c for example of usage. This
does not change the automatic creation of the default stage. does not change the automatic creation of the default stage.
A single GL context is used across all stages meaning GL resources A single GL context is used across all stages meaning GL resources
are shared. are shared.
* There is now an experimental native iPod Touch/iPhone UIKit backend * There is now an experimental native iPod Touch/iPhone UIKit backend
named 'fruity'. named 'fruity'.
* There is now an experimental native Win32 WGL backend. * There is now an experimental native Win32 WGL backend.
* COGL (and therefor Clutter) now optionally features initial support for * COGL (and therefor Clutter) now optionally features initial support for
OpenGL ES 2.0. It features support for shaders. OpenGL ES 2.0. It features support for shaders.
* Some more focused timeline unit tests have been added and some tweaks to * Some more focused timeline unit tests have been added and some tweaks to
timeline semantics were made; E.g. For a 10 frame timeline here are some timeline semantics were made; E.g. For a 10 frame timeline here are some
@ -468,7 +495,7 @@ Release Notes for Clutter 0.8
X Drawables (such as windows as pixmaps) via the 'texture_from_pixmap' GLX X Drawables (such as windows as pixmaps) via the 'texture_from_pixmap' GLX
extension if available and fallback to slower XGetImage copies if not. extension if available and fallback to slower XGetImage copies if not.
* ClutterContainer can have per child custom properties via ClutterChildMeta. * ClutterContainer can have per child custom properties via ClutterChildMeta.
Release Notes for Clutter 0.6 Release Notes for Clutter 0.6
------------------------------- -------------------------------
@ -581,11 +608,11 @@ Release Notes for Clutter 0.4.0
Release Notes for Clutter 0.3.1 Release Notes for Clutter 0.3.1
------------------------------- -------------------------------
* clutter_actor_apply_transform_to_point() parameters changed to use * clutter_actor_apply_transform_to_point() parameters changed to use
ClutterVertices. ClutterVertices.
* New 'Native API' backend expects EGL implementation to provide a * New 'Native API' backend expects EGL implementation to provide a
CreateNativeWindow() API call. CreateNativeWindow() API call.
* Exisiting X11 based egl backend public API calls now prefixed eglx. * Exisiting X11 based egl backend public API calls now prefixed eglx.
@ -599,7 +626,7 @@ Release Notes for Clutter 0.3
clutter_texture_set_from_yuv_data(). clutter_texture_set_from_yuv_data().
* The GLX specific API has been moved to the GLX backend code and * The GLX specific API has been moved to the GLX backend code and
it's now under the ClutterGlx namespace. it's now under the ClutterGlx namespace.
* The priority of the various users of the GLib main loop has been * The priority of the various users of the GLib main loop has been
reviewed and changed were necessary. Every paint is queued with a reviewed and changed were necessary. Every paint is queued with a
@ -634,7 +661,7 @@ Release Notes for Clutter 0.3
* clutter_color_parse() now handles color definitions with alpha. Alpha * clutter_color_parse() now handles color definitions with alpha. Alpha
will default to fully Opaque rather than fully transparent if not specified. will default to fully Opaque rather than fully transparent if not specified.
* The Clutter examples/ directory has been removed and replaced with a * The Clutter examples/ directory has been removed and replaced with a
tests/ directory. tests/ directory.
* The ClutterEvent API has been changed, and specific functions have been * The ClutterEvent API has been changed, and specific functions have been

View File

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

View File

@ -54,6 +54,12 @@
* cairo_destroy (cr); * 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 * <warning><para>Note that you should never use the code above inside the
* #ClutterActor::paint or #ClutterActor::pick virtual functions or * #ClutterActor::paint or #ClutterActor::pick virtual functions or
* signal handlers because it will lead to performance * signal handlers because it will lead to performance
@ -760,3 +766,28 @@ clutter_cairo_texture_get_surface_size (ClutterCairoTexture *self,
if (height) if (height)
*height = self->priv->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 *width,
guint *height); guint *height);
void clutter_cairo_set_source_color (cairo_t *cr, void clutter_cairo_texture_clear (ClutterCairoTexture *self);
const ClutterColor *color);
void clutter_cairo_set_source_color (cairo_t *cr,
const ClutterColor *color);
G_END_DECLS G_END_DECLS

View File

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

View File

@ -81,6 +81,8 @@ typedef struct _ClutterModelIterClass ClutterListModelIterClass;
struct _ClutterListModelPrivate struct _ClutterListModelPrivate
{ {
GSequence *sequence; GSequence *sequence;
ClutterModelIter *temp_iter;
}; };
struct _ClutterListModelIter struct _ClutterListModelIter
@ -214,27 +216,22 @@ clutter_list_model_iter_is_first (ClutterModelIter *iter)
ClutterModelIter *temp_iter; ClutterModelIter *temp_iter;
GSequence *sequence; GSequence *sequence;
GSequenceIter *begin, *end; GSequenceIter *begin, *end;
guint row;
iter_default = CLUTTER_LIST_MODEL_ITER (iter); iter_default = CLUTTER_LIST_MODEL_ITER (iter);
g_assert (iter_default->seq_iter != NULL); g_assert (iter_default->seq_iter != NULL);
model = clutter_model_iter_get_model (iter); model = clutter_model_iter_get_model (iter);
row = clutter_model_iter_get_row (iter);
sequence = CLUTTER_LIST_MODEL (model)->priv->sequence; sequence = CLUTTER_LIST_MODEL (model)->priv->sequence;
begin = g_sequence_get_begin_iter (sequence); begin = g_sequence_get_begin_iter (sequence);
end = iter_default->seq_iter; end = iter_default->seq_iter;
temp_iter = g_object_new (CLUTTER_TYPE_LIST_MODEL_ITER, temp_iter = CLUTTER_LIST_MODEL (model)->priv->temp_iter;
"model", model,
NULL);
while (!g_sequence_iter_is_begin (begin)) while (!g_sequence_iter_is_begin (begin))
{ {
CLUTTER_LIST_MODEL_ITER (temp_iter)->seq_iter = 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)) 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); 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 /* This is because the 'begin_iter' is always *before* the last valid
* iter, otherwise we'd have endless loops * iter, otherwise we'd have endless loops
*/ */
@ -264,7 +258,6 @@ clutter_list_model_iter_is_last (ClutterModelIter *iter)
ClutterModel *model; ClutterModel *model;
GSequence *sequence; GSequence *sequence;
GSequenceIter *begin, *end; GSequenceIter *begin, *end;
guint row;
iter_default = CLUTTER_LIST_MODEL_ITER (iter); iter_default = CLUTTER_LIST_MODEL_ITER (iter);
g_assert (iter_default->seq_iter != NULL); g_assert (iter_default->seq_iter != NULL);
@ -273,7 +266,6 @@ clutter_list_model_iter_is_last (ClutterModelIter *iter)
return TRUE; return TRUE;
model = clutter_model_iter_get_model (iter); model = clutter_model_iter_get_model (iter);
row = clutter_model_iter_get_row (iter);
sequence = CLUTTER_LIST_MODEL (model)->priv->sequence; 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); begin = g_sequence_iter_prev (begin);
end = iter_default->seq_iter; end = iter_default->seq_iter;
temp_iter = g_object_new (CLUTTER_TYPE_LIST_MODEL_ITER, temp_iter = CLUTTER_LIST_MODEL (model)->priv->temp_iter;
"model", model,
NULL);
while (!g_sequence_iter_is_begin (begin)) while (!g_sequence_iter_is_begin (begin))
{ {
CLUTTER_LIST_MODEL_ITER (temp_iter)->seq_iter = 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)) 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); 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. /* This is because the 'end_iter' is always *after* the last valid iter.
* Otherwise we'd have endless loops * Otherwise we'd have endless loops
*/ */
@ -323,37 +309,31 @@ clutter_list_model_iter_next (ClutterModelIter *iter)
g_assert (iter_default->seq_iter != NULL); g_assert (iter_default->seq_iter != NULL);
model = clutter_model_iter_get_model (iter); 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); filter_next = g_sequence_iter_next (iter_default->seq_iter);
g_assert (filter_next != NULL); g_assert (filter_next != NULL);
temp_iter = g_object_new (CLUTTER_TYPE_LIST_MODEL_ITER, temp_iter = CLUTTER_LIST_MODEL (model)->priv->temp_iter;
"model", model,
NULL);
while (!g_sequence_iter_is_end (filter_next)) while (!g_sequence_iter_is_end (filter_next))
{ {
CLUTTER_LIST_MODEL_ITER (temp_iter)->seq_iter = 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)) if (clutter_model_filter_iter (model, temp_iter))
break; {
row += 1;
break;
}
filter_next = g_sequence_iter_next (filter_next); filter_next = g_sequence_iter_next (filter_next);
row += 1;
} }
g_object_unref (temp_iter); if (g_sequence_iter_is_end (filter_next))
row += 1;
/* 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);
/* update the iterator and return it */ /* 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; iter_default->seq_iter = filter_next;
return CLUTTER_MODEL_ITER (iter_default); return CLUTTER_MODEL_ITER (iter_default);
@ -372,37 +352,31 @@ clutter_list_model_iter_prev (ClutterModelIter *iter)
g_assert (iter_default->seq_iter != NULL); g_assert (iter_default->seq_iter != NULL);
model = clutter_model_iter_get_model (iter); 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); filter_prev = g_sequence_iter_prev (iter_default->seq_iter);
g_assert (filter_prev != NULL); g_assert (filter_prev != NULL);
temp_iter = g_object_new (CLUTTER_TYPE_LIST_MODEL_ITER, temp_iter = CLUTTER_LIST_MODEL (model)->priv->temp_iter;
"model", model,
NULL);
while (!g_sequence_iter_is_begin (filter_prev)) while (!g_sequence_iter_is_begin (filter_prev))
{ {
CLUTTER_LIST_MODEL_ITER (temp_iter)->seq_iter = 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)) if (clutter_model_filter_iter (model, temp_iter))
break; {
row -= 1;
break;
}
filter_prev = g_sequence_iter_prev (filter_prev); filter_prev = g_sequence_iter_prev (filter_prev);
row -= 1;
} }
g_object_unref (temp_iter); if (g_sequence_iter_is_begin (filter_prev))
row -= 1;
/* 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);
/* update the iterator and return it */ /* 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; iter_default->seq_iter = filter_prev;
return CLUTTER_MODEL_ITER (iter_default); 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); ClutterListModel *model_default = CLUTTER_LIST_MODEL (model);
GSequence *sequence = model_default->priv->sequence; GSequence *sequence = model_default->priv->sequence;
gint seq_length = g_sequence_get_length (sequence);
ClutterListModelIter *retval; ClutterListModelIter *retval;
if (row >= g_sequence_get_length (sequence)) if (row >= seq_length)
return NULL; return NULL;
retval = g_object_new (CLUTTER_TYPE_LIST_MODEL_ITER, retval = g_object_new (CLUTTER_TYPE_LIST_MODEL_ITER,
"model", model, "model", model,
"row", row, "row", row,
NULL); 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); return CLUTTER_MODEL_ITER (retval);
} }
@ -507,7 +538,7 @@ clutter_list_model_insert_row (ClutterModel *model,
if (index_ < 0) if (index_ < 0)
{ {
seq_iter = g_sequence_append (sequence, array); seq_iter = g_sequence_append (sequence, array);
pos = g_sequence_get_length (sequence); pos = g_sequence_get_length (sequence) - 1;
} }
else if (index_ == 0) 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 typedef struct
{ {
ClutterModel *model; ClutterModel *model;
@ -658,6 +681,20 @@ clutter_list_model_finalize (GObject *gobject)
G_OBJECT_CLASS (clutter_list_model_parent_class)->finalize (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 static void
clutter_list_model_class_init (ClutterListModelClass *klass) 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)); g_type_class_add_private (klass, sizeof (ClutterListModelPrivate));
gobject_class->finalize = clutter_list_model_finalize; 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->get_iter_at_row = clutter_list_model_get_iter_at_row;
model_class->insert_row = clutter_list_model_insert_row; model_class->insert_row = clutter_list_model_insert_row;
model_class->remove_row = clutter_list_model_remove_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 = CLUTTER_LIST_MODEL_GET_PRIVATE (model);
model->priv->sequence = g_sequence_new (NULL); 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 */ /* needed for when a context switch happens */
_clutter_stage_maybe_setup_viewport (stage); _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_color_set_from_4ub (&white, 255, 255, 255, 255);
cogl_disable_fog (); 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 */ /* Disable dithering (if any) when doing the painting in pick mode */
dither_was_on = glIsEnabled (GL_DITHER); 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 /* Render the entire scence in pick mode - just single colored silhouette's
* are drawn offscreen (as we never swap buffers) * are drawn offscreen (as we never swap buffers)
@ -387,15 +391,11 @@ _clutter_do_pick (ClutterStage *stage,
context->pick_mode = mode; context->pick_mode = mode;
clutter_actor_paint (CLUTTER_ACTOR (stage)); clutter_actor_paint (CLUTTER_ACTOR (stage));
context->pick_mode = CLUTTER_PICK_NONE; context->pick_mode = CLUTTER_PICK_NONE;
cogl_clip_pop ();
/* Calls should work under both GL and GLES, note GLES needs RGBA */ /* Calls should work under both GL and GLES, note GLES needs RGBA */
glGetIntegerv(GL_VIEWPORT, viewport); 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 */ /* Read the color of the screen co-ords pixel */
glReadPixels (x, viewport[3] - y -1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 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, gint column,
const gchar *name); const gchar *name);
void clutter_model_iter_set_row (ClutterModelIter *iter,
guint row);
G_END_DECLS G_END_DECLS
#endif /* __CLUTTER_MODEL_PRIVATE_H__ */ #endif /* __CLUTTER_MODEL_PRIVATE_H__ */

View File

@ -133,9 +133,15 @@
#include "clutter-private.h" #include "clutter-private.h"
#include "clutter-debug.h" #include "clutter-debug.h"
G_DEFINE_ABSTRACT_TYPE (ClutterModel, clutter_model, G_TYPE_OBJECT); G_DEFINE_ABSTRACT_TYPE (ClutterModel, clutter_model, G_TYPE_OBJECT);
enum
{
PROP_0,
PROP_FILTER_SET
};
enum enum
{ {
ROW_ADDED, ROW_ADDED,
@ -202,28 +208,6 @@ clutter_model_real_get_n_columns (ClutterModel *model)
return model->priv->n_columns; 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 static void
clutter_model_finalize (GObject *object) clutter_model_finalize (GObject *object)
{ {
@ -249,11 +233,33 @@ clutter_model_finalize (GObject *object)
G_OBJECT_CLASS (clutter_model_parent_class)->finalize (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 static void
clutter_model_class_init (ClutterModelClass *klass) clutter_model_class_init (ClutterModelClass *klass)
{ {
GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GParamSpec *pspec;
gobject_class->get_property = clutter_model_get_property;
gobject_class->finalize = clutter_model_finalize; gobject_class->finalize = clutter_model_finalize;
g_type_class_add_private (gobject_class, sizeof (ClutterModelPrivate)); 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_name = clutter_model_real_get_column_name;
klass->get_column_type = clutter_model_real_get_column_type; klass->get_column_type = clutter_model_real_get_column_type;
klass->get_n_columns = clutter_model_real_get_n_columns; 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: * ClutterModel::row-added:
@ -419,6 +441,8 @@ clutter_model_check_type (GType gtype)
return FALSE; return FALSE;
} }
/** /**
* clutter_model_resort: * clutter_model_resort:
* @model: a #ClutterModel * @model: a #ClutterModel
@ -474,7 +498,7 @@ clutter_model_filter_row (ClutterModel *model,
return TRUE; return TRUE;
iter = clutter_model_get_iter_at_row (model, row); iter = clutter_model_get_iter_at_row (model, row);
if (!iter) if (iter == NULL)
return FALSE; return FALSE;
res = priv->filter_func (model, iter, priv->filter_data); 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. * 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 * 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() * out of bounds. When done using the iterator object, call g_object_unref()
* to deallocate its resources * to deallocate its resources
@ -1143,49 +1171,65 @@ clutter_model_get_iter_at_row (ClutterModel *model,
* clutter_model_get_first_iter: * clutter_model_get_first_iter:
* @model: a #ClutterModel * @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 * Return value: (transfer full): A new #ClutterModelIter.
* done using it * Call g_object_unref() when done using it
* *
* Since: 0.6 * Since: 0.6
*/ */
ClutterModelIter * ClutterModelIter *
clutter_model_get_first_iter (ClutterModel *model) clutter_model_get_first_iter (ClutterModel *model)
{ {
ClutterModelIter *retval;
g_return_val_if_fail (CLUTTER_IS_MODEL (model), NULL); 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: * clutter_model_get_last_iter:
* @model: a #ClutterModel * @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 * Return value: (transfer full): A new #ClutterModelIter.
* done using it * Call g_object_unref() when done using it
* *
* Since: 0.6 * Since: 0.6
*/ */
ClutterModelIter * ClutterModelIter *
clutter_model_get_last_iter (ClutterModel *model) clutter_model_get_last_iter (ClutterModel *model)
{ {
ClutterModelIter *retval;
guint length; guint length;
g_return_val_if_fail (CLUTTER_IS_MODEL (model), NULL); g_return_val_if_fail (CLUTTER_IS_MODEL (model), NULL);
length = clutter_model_get_n_rows (model); 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: * clutter_model_get_n_rows:
* @model: a #ClutterModel * @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 * Return value: The length of the @model. If there is a filter set, then
* the length of the filtered @model is returned. * the length of the filtered @model is returned.
@ -1195,9 +1239,35 @@ clutter_model_get_last_iter (ClutterModel *model)
guint guint
clutter_model_get_n_rows (ClutterModel *model) clutter_model_get_n_rows (ClutterModel *model)
{ {
ClutterModelClass *klass;
guint row_count;
g_return_val_if_fail (CLUTTER_IS_MODEL (model), 0); 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; ClutterModelPrivate *priv;
g_return_if_fail (CLUTTER_IS_MODEL (model)); g_return_if_fail (CLUTTER_IS_MODEL (model));
g_return_if_fail ((func != NULL && column >= 0) ||
(func == NULL && column == -1));
priv = model->priv; priv = model->priv;
if (priv->sort_notify) if (priv->sort_notify)
@ -1356,6 +1429,26 @@ clutter_model_set_filter (ClutterModel *model,
priv->filter_notify = notify; priv->filter_notify = notify;
g_signal_emit (model, model_signals[FILTER_CHANGED], 0); 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; return iter->priv->row;
} }
/* private function */
void
clutter_model_iter_set_row (ClutterModelIter *iter,
guint row)
{
iter->priv->row = row;
}
static void static void
clutter_model_iter_get_value_unimplemented (ClutterModelIter *iter, clutter_model_iter_get_value_unimplemented (ClutterModelIter *iter,
guint column, guint column,
@ -1539,7 +1640,8 @@ clutter_model_iter_set_property (GObject *object,
static void static void
clutter_model_iter_class_init (ClutterModelIterClass *klass) 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->get_property = clutter_model_iter_get_property;
gobject_class->set_property = clutter_model_iter_set_property; gobject_class->set_property = clutter_model_iter_set_property;
@ -1563,28 +1665,26 @@ clutter_model_iter_class_init (ClutterModelIterClass *klass)
* *
* Since: 0.6 * Since: 0.6
*/ */
g_object_class_install_property (gobject_class, pspec = g_param_spec_object ("model",
ITER_PROP_MODEL, "Model",
g_param_spec_object ("model", "The model to which the iterator belongs to",
"Model", CLUTTER_TYPE_MODEL,
"The model to which the iterator belongs to", CLUTTER_PARAM_READWRITE);
CLUTTER_TYPE_MODEL, g_object_class_install_property (gobject_class, ITER_PROP_MODEL, pspec);
CLUTTER_PARAM_READWRITE));
/** /**
* ClutterModelIter:row: * ClutterModelIter:row:
* *
* The row number to which this iter points to. * The row number to which this iter points to.
* *
* Since: 0.6 * Since: 0.6
*/ */
g_object_class_install_property (gobject_class, pspec = g_param_spec_uint ("row",
ITER_PROP_ROW, "Row",
g_param_spec_uint ("row", "The row to which the iterator points to",
"Row", 0, G_MAXUINT, 0,
"The row to which the iterator points to", CLUTTER_PARAM_READWRITE);
0, G_MAXUINT, 0, g_object_class_install_property (gobject_class, ITER_PROP_ROW, pspec);
CLUTTER_PARAM_READWRITE));
g_type_class_add_private (gobject_class, sizeof (ClutterModelIterPrivate)); 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 * @get_iter_at_row: virtual function for returning an iterator for the
* given row * given row
* @get_n_rows: virtual function for returning the number of rows * @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 * @get_n_columns: virtual function for retuning the number of columns
* of the model * of the model
* @resort: virtual function for sorting the model using the passed * @resort: virtual function for sorting the model using the passed
@ -177,11 +177,15 @@ struct _ClutterModelClass
void (* filter_changed) (ClutterModel *model); void (* filter_changed) (ClutterModel *model);
/*< private >*/ /*< private >*/
/* padding for future */ /* padding for future expansion */
void (*_clutter_model_1) (void); void (*_clutter_model_1) (void);
void (*_clutter_model_2) (void); void (*_clutter_model_2) (void);
void (*_clutter_model_3) (void); void (*_clutter_model_3) (void);
void (*_clutter_model_4) (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; GType clutter_model_get_type (void) G_GNUC_CONST;
@ -248,6 +252,7 @@ void clutter_model_set_filter (ClutterModel *model,
ClutterModelFilterFunc func, ClutterModelFilterFunc func,
gpointer user_data, gpointer user_data,
GDestroyNotify notify); GDestroyNotify notify);
gboolean clutter_model_get_filter_set (ClutterModel *model);
void clutter_model_resort (ClutterModel *model); void clutter_model_resort (ClutterModel *model);
gboolean clutter_model_filter_row (ClutterModel *model, gboolean clutter_model_filter_row (ClutterModel *model,
@ -333,11 +338,15 @@ struct _ClutterModelIterClass
ClutterModelIter *(* copy) (ClutterModelIter *iter); ClutterModelIter *(* copy) (ClutterModelIter *iter);
/*< private >*/ /*< private >*/
/* padding for future */ /* padding for future expansion */
void (*_clutter_model_iter_1) (void); void (*_clutter_model_iter_1) (void);
void (*_clutter_model_iter_2) (void); void (*_clutter_model_iter_2) (void);
void (*_clutter_model_iter_3) (void); void (*_clutter_model_iter_3) (void);
void (*_clutter_model_iter_4) (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; GType clutter_model_iter_get_type (void) G_GNUC_CONST;

View File

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

View File

@ -86,7 +86,7 @@ void clutter_value_set_shader_matrix (GValue *value,
const gfloat *matrix); const gfloat *matrix);
G_CONST_RETURN gfloat * clutter_value_get_shader_float (const GValue *value, G_CONST_RETURN gfloat * clutter_value_get_shader_float (const GValue *value,
gsize *length); 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); gsize *length);
G_CONST_RETURN gfloat * clutter_value_get_shader_matrix (const GValue *value, G_CONST_RETURN gfloat * clutter_value_get_shader_matrix (const GValue *value,
gsize *length); gsize *length);

View File

@ -84,7 +84,7 @@ struct _ClutterShaderPrivate
CoglHandle fragment_shader; CoglHandle fragment_shader;
}; };
enum enum
{ {
PROP_0, PROP_0,
@ -126,11 +126,11 @@ clutter_shader_set_property (GObject *object,
switch (prop_id) switch (prop_id)
{ {
case PROP_VERTEX_SOURCE: case PROP_VERTEX_SOURCE:
clutter_shader_set_vertex_source (shader, clutter_shader_set_vertex_source (shader,
g_value_get_string (value), -1); g_value_get_string (value), -1);
break; break;
case PROP_FRAGMENT_SOURCE: case PROP_FRAGMENT_SOURCE:
clutter_shader_set_fragment_source (shader, clutter_shader_set_fragment_source (shader,
g_value_get_string (value), -1); g_value_get_string (value), -1);
break; break;
case PROP_ENABLED: case PROP_ENABLED:
@ -427,20 +427,19 @@ clutter_shader_glsl_bind (ClutterShader *self,
GError **error) GError **error)
{ {
ClutterShaderPrivate *priv = self->priv; ClutterShaderPrivate *priv = self->priv;
GLint is_compiled = CGL_FALSE;
CoglHandle shader = COGL_INVALID_HANDLE; CoglHandle shader = COGL_INVALID_HANDLE;
switch (shader_type) switch (shader_type)
{ {
case CLUTTER_VERTEX_SHADER: 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); cogl_shader_source (shader, priv->vertex_source);
priv->vertex_shader = shader; priv->vertex_shader = shader;
break; break;
case CLUTTER_FRAGMENT_SHADER: 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); cogl_shader_source (shader, priv->fragment_source);
priv->fragment_shader = shader; priv->fragment_shader = shader;
@ -450,11 +449,7 @@ clutter_shader_glsl_bind (ClutterShader *self,
g_assert (shader != COGL_INVALID_HANDLE); g_assert (shader != COGL_INVALID_HANDLE);
cogl_shader_compile (shader); cogl_shader_compile (shader);
cogl_shader_get_parameteriv (shader, if (!cogl_shader_is_compiled (shader))
CGL_OBJECT_COMPILE_STATUS,
&is_compiled);
if (is_compiled != CGL_TRUE)
{ {
gchar error_buf[512]; gchar error_buf[512];
@ -739,7 +734,7 @@ clutter_shader_set_uniform (ClutterShader *shader,
} }
else if (CLUTTER_VALUE_HOLDS_SHADER_INT (value)) else if (CLUTTER_VALUE_HOLDS_SHADER_INT (value))
{ {
const COGLint *ints; const int *ints;
ints = clutter_value_get_shader_int (value, &size); ints = clutter_value_get_shader_int (value, &size);
cogl_program_uniform_int (location, size, 1, ints); 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)) 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); 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.green,
priv->color.blue, priv->color.blue,
priv->color.alpha); priv->color.alpha);
cogl_clear (&stage_color); cogl_clear (&stage_color,
COGL_BUFFER_BIT_COLOR |
COGL_BUFFER_BIT_DEPTH);
if (priv->use_fog) 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_alignment (layout, priv->alignment);
pango_layout_set_single_paragraph_mode (layout, priv->single_line_mode); pango_layout_set_single_paragraph_mode (layout, priv->single_line_mode);
pango_layout_set_justify (layout, priv->justify); pango_layout_set_justify (layout, priv->justify);
pango_layout_set_wrap (layout, priv->wrap_mode);
/* Cases, assuming ellipsize != NONE on actor: /* 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 /* We do not limit the layout width on editable, single-line text
* text actors, since those can scroll the layout * 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 && 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; gint width;
@ -459,6 +463,10 @@ clutter_text_coords_to_position (ClutterText *text,
gint px, py; gint px, py;
gint trailing; 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; px = x * PANGO_SCALE;
py = y * PANGO_SCALE; py = y * PANGO_SCALE;
@ -528,7 +536,13 @@ clutter_text_position_to_coords (ClutterText *self,
&rect, NULL); &rect, NULL);
if (x) 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) if (y)
*y = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.y); *y = CLUTTER_UNITS_FROM_PANGO_UNIT (rect.y);
@ -970,6 +984,12 @@ cursor_paint (ClutterText *self)
range_x = ranges[i * 2] range_x = ranges[i * 2]
/ PANGO_SCALE; / 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]) range_width = (ranges[i * 2 + 1] - ranges[i * 2])
/ PANGO_SCALE; / PANGO_SCALE;
@ -1375,34 +1395,38 @@ clutter_text_paint (ClutterActor *self)
if (priv->position == -1) if (priv->position == -1)
{ {
text_x = actor_width - text_width; text_x = actor_width - text_width;
priv->cursor_pos.x += text_x + TEXT_PADDING;
} }
else if (priv->position == 0) else if (priv->position == 0)
{ {
text_x = 0; text_x = TEXT_PADDING;
} }
else else
{ {
if (text_x <= 0) if (cursor_x < 0)
{ {
gint diff = -1 * text_x; text_x = text_x - cursor_x - TEXT_PADDING;
}
if (cursor_x < diff) else if (cursor_x > actor_width)
text_x += diff - cursor_x; {
else if (cursor_x > (diff + actor_width)) text_x = text_x + (actor_width - cursor_x) - TEXT_PADDING;
text_x -= cursor_x - (diff - actor_width);
} }
} }
/* 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 else
{ {
text_x = 0; text_x = TEXT_PADDING;
priv->cursor_pos.x += text_x + TEXT_PADDING;
} }
} }
else else
text_x = 0; text_x = 0;
priv->text_x = text_x;
cursor_paint (text); cursor_paint (text);
real_opacity = clutter_actor_get_paint_opacity (self) real_opacity = clutter_actor_get_paint_opacity (self)
@ -1421,7 +1445,6 @@ clutter_text_paint (ClutterActor *self)
if (clip_set) if (clip_set)
cogl_clip_pop (); cogl_clip_pop ();
priv->text_x = text_x;
} }
static void static void
@ -1460,7 +1483,12 @@ clutter_text_get_preferred_width (ClutterActor *self,
} }
if (natural_width_p) 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 static void
@ -1469,7 +1497,7 @@ clutter_text_get_preferred_height (ClutterActor *self,
gfloat *min_height_p, gfloat *min_height_p,
gfloat *natural_height_p) gfloat *natural_height_p)
{ {
ClutterText *text = CLUTTER_TEXT (self); ClutterTextPrivate *priv = CLUTTER_TEXT (self)->priv;
if (for_width == 0) if (for_width == 0)
{ {
@ -1486,7 +1514,8 @@ clutter_text_get_preferred_height (ClutterActor *self,
gint logical_height; gint logical_height;
gfloat layout_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); pango_layout_get_extents (layout, NULL, &logical_rect);
@ -1495,13 +1524,26 @@ clutter_text_get_preferred_height (ClutterActor *self,
* the height accordingly * the height accordingly
*/ */
logical_height = logical_rect.y + logical_rect.height; logical_height = logical_rect.y + logical_rect.height;
layout_height = CLUTTER_UNITS_FROM_PANGO_UNIT (logical_height); layout_height = CLUTTER_UNITS_FROM_PANGO_UNIT (logical_height);
if (min_height_p) if (min_height_p)
{ {
if (text->priv->ellipsize) /* if we wrap and ellipsize then the minimum height is
*min_height_p = 1; * 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 else
*min_height_p = layout_height; *min_height_p = layout_height;
} }
@ -1772,17 +1814,17 @@ clutter_text_real_del_prev (ClutterText *self,
{ {
if (pos == -1) 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_delete_text (self, len - 1, len);
clutter_text_set_cursor_position (self, -1);
clutter_text_set_selection_bound (self, -1);
} }
else else
{ {
clutter_text_delete_text (self, pos - 1, pos);
clutter_text_set_cursor_position (self, pos - 1); clutter_text_set_cursor_position (self, pos - 1);
clutter_text_set_selection_bound (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) if (end_index == start_index)
return g_strdup (""); return g_strdup ("");
if (end_index < start_index) if ((end_index != -1 && end_index < start_index) ||
start_index == -1)
{ {
gint temp = start_index; gint temp = start_index;
start_index = end_index; start_index = end_index;
@ -3147,6 +3190,8 @@ clutter_text_set_text_internal (ClutterText *self,
{ {
ClutterTextPrivate *priv = self->priv; ClutterTextPrivate *priv = self->priv;
g_object_freeze_notify (G_OBJECT (self));
if (priv->max_length > 0) if (priv->max_length > 0)
{ {
gint len = g_utf8_strlen (text, -1); 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); 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_signal_emit (self, text_signals[TEXT_CHANGED], 0);
g_object_notify (G_OBJECT (self), "text"); g_object_notify (G_OBJECT (self), "text");
g_object_thaw_notify (G_OBJECT (self));
} }
static inline void static inline void

View File

@ -82,7 +82,6 @@ struct _ClutterTexturePrivate
gint max_tile_waste; gint max_tile_waste;
ClutterTextureQuality filter_quality; ClutterTextureQuality filter_quality;
CoglHandle material; CoglHandle material;
CoglHandle fbo_texture;
gboolean no_slice; gboolean no_slice;
ClutterActor *fbo_source; ClutterActor *fbo_source;
@ -128,7 +127,7 @@ struct _ClutterTextureAsyncData
guint load_idle; guint load_idle;
gchar *load_filename; gchar *load_filename;
CoglBitmap *load_bitmap; CoglHandle load_bitmap;
GError *load_error; GError *load_error;
}; };
@ -188,18 +187,18 @@ clutter_texture_quality_to_filters (ClutterTextureQuality quality,
switch (quality) switch (quality)
{ {
case CLUTTER_TEXTURE_QUALITY_LOW: case CLUTTER_TEXTURE_QUALITY_LOW:
min_filter = CGL_NEAREST; min_filter = COGL_TEXTURE_FILTER_NEAREST;
mag_filter = CGL_NEAREST; mag_filter = COGL_TEXTURE_FILTER_NEAREST;
break; break;
case CLUTTER_TEXTURE_QUALITY_MEDIUM: case CLUTTER_TEXTURE_QUALITY_MEDIUM:
min_filter = CGL_LINEAR; min_filter = COGL_TEXTURE_FILTER_LINEAR;
mag_filter = CGL_LINEAR; mag_filter = COGL_TEXTURE_FILTER_LINEAR;
break; break;
case CLUTTER_TEXTURE_QUALITY_HIGH: case CLUTTER_TEXTURE_QUALITY_HIGH:
min_filter = CGL_LINEAR_MIPMAP_LINEAR; min_filter = COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR;
mag_filter = CGL_LINEAR; mag_filter = COGL_TEXTURE_FILTER_LINEAR;
break; break;
} }
@ -289,31 +288,34 @@ clutter_texture_realize (ClutterActor *actor)
CoglTextureFlags flags = COGL_TEXTURE_NONE; CoglTextureFlags flags = COGL_TEXTURE_NONE;
gint min_filter, mag_filter; gint min_filter, mag_filter;
gint max_waste = -1; gint max_waste = -1;
CoglHandle tex;
/* Handle FBO's */ /* Handle FBO's */
if (priv->fbo_texture != COGL_INVALID_HANDLE)
cogl_handle_unref (priv->fbo_texture);
if (!priv->no_slice) if (!priv->no_slice)
max_waste = priv->max_tile_waste; max_waste = priv->max_tile_waste;
if (priv->filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH) if (priv->filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH)
flags |= COGL_TEXTURE_AUTO_MIPMAP; flags |= COGL_TEXTURE_AUTO_MIPMAP;
priv->fbo_texture = tex = cogl_texture_new_with_size (priv->width,
cogl_texture_new_with_size (priv->width, priv->height,
priv->height, max_waste, flags,
max_waste, flags, COGL_PIXEL_FORMAT_RGBA_8888);
COGL_PIXEL_FORMAT_RGBA_8888);
cogl_material_set_layer (priv->material, 0, tex);
clutter_texture_quality_to_filters (priv->filter_quality, clutter_texture_quality_to_filters (priv->filter_quality,
&min_filter, &min_filter,
&mag_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) if (priv->fbo_handle == COGL_INVALID_HANDLE)
{ {
@ -544,7 +546,7 @@ clutter_texture_paint (ClutterActor *self)
clutter_shader_set_is_enabled (shader, FALSE); clutter_shader_set_is_enabled (shader, FALSE);
/* Redirect drawing to the fbo */ /* 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))) 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_clear is called to clear the buffers */
cogl_color_set_from_4ub (&transparent_col, 0, 0, 0, 0); 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 (); cogl_disable_fog ();
/* Clear the clipping stack so that if the FBO actor is being /* 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 (); cogl_clip_stack_restore ();
/* Restore drawing to the frame buffer */ /* 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 /* Restore the perspective matrix using cogl_perspective so that
the inverse matrix will be right */ the inverse matrix will be right */
@ -653,7 +657,7 @@ clutter_texture_async_data_free (ClutterTextureAsyncData *data)
g_free (data->load_filename); g_free (data->load_filename);
if (data->load_bitmap) if (data->load_bitmap)
cogl_bitmap_free (data->load_bitmap); cogl_handle_unref (data->load_bitmap);
if (data->load_error) if (data->load_error)
g_error_free (data->load_error); g_error_free (data->load_error);
@ -763,83 +767,83 @@ clutter_texture_set_property (GObject *object,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
ClutterTexture *texture; ClutterTexture *texture;
ClutterTexturePrivate *priv; ClutterTexturePrivate *priv;
texture = CLUTTER_TEXTURE(object); texture = CLUTTER_TEXTURE (object);
priv = texture->priv; priv = texture->priv;
switch (prop_id) switch (prop_id)
{ {
case PROP_MAX_TILE_WASTE: case PROP_MAX_TILE_WASTE:
clutter_texture_set_max_tile_waste (texture, clutter_texture_set_max_tile_waste (texture, g_value_get_int (value));
g_value_get_int (value));
break; break;
case PROP_SYNC_SIZE: case PROP_SYNC_SIZE:
priv->sync_actor_size = g_value_get_boolean (value); clutter_texture_set_sync_size (texture, g_value_get_boolean (value));
clutter_actor_queue_relayout (CLUTTER_ACTOR (texture));
break; break;
case PROP_REPEAT_X: case PROP_REPEAT_X:
if (priv->repeat_x != g_value_get_boolean (value)) clutter_texture_set_repeat (texture,
{ g_value_get_boolean (value),
priv->repeat_x = !priv->repeat_x; priv->repeat_y);
if (CLUTTER_ACTOR_IS_VISIBLE (texture))
clutter_actor_queue_redraw (CLUTTER_ACTOR (texture));
}
break; break;
case PROP_REPEAT_Y: case PROP_REPEAT_Y:
if (priv->repeat_y != g_value_get_boolean (value)) clutter_texture_set_repeat (texture,
{ priv->repeat_x,
priv->repeat_y = !priv->repeat_y; g_value_get_boolean (value));
if (CLUTTER_ACTOR_IS_VISIBLE (texture))
clutter_actor_queue_redraw (CLUTTER_ACTOR (texture));
}
break; break;
case PROP_FILTER_QUALITY: case PROP_FILTER_QUALITY:
clutter_texture_set_filter_quality (texture, clutter_texture_set_filter_quality (texture,
g_value_get_enum (value)); g_value_get_enum (value));
break; break;
case PROP_COGL_TEXTURE: 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; break;
#if EXPOSE_COGL_MATERIAL_PROP
case PROP_COGL_MATERIAL: 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; break;
#endif
case PROP_FILENAME: case PROP_FILENAME:
clutter_texture_set_from_file (texture, clutter_texture_set_from_file (texture,
g_value_get_string (value), g_value_get_string (value),
NULL); NULL);
break; break;
case PROP_NO_SLICE: case PROP_NO_SLICE:
priv->no_slice = g_value_get_boolean (value); priv->no_slice = g_value_get_boolean (value);
break; break;
case PROP_KEEP_ASPECT_RATIO: case PROP_KEEP_ASPECT_RATIO:
priv->keep_aspect_ratio = g_value_get_boolean (value); clutter_texture_set_keep_aspect_ratio (texture,
clutter_actor_queue_relayout (CLUTTER_ACTOR (object)); g_value_get_boolean (value));
break; break;
case PROP_LOAD_DATA_ASYNC: case PROP_LOAD_DATA_ASYNC:
if (g_value_get_boolean (value)) clutter_texture_set_load_data_async (texture,
{ g_value_get_boolean (value));
priv->load_async_set = TRUE;
priv->load_data_async = TRUE;
}
break; break;
case PROP_LOAD_ASYNC: case PROP_LOAD_ASYNC:
if (g_value_get_boolean (value)) clutter_texture_set_load_async (texture, g_value_get_boolean (value));
{
priv->load_data_async = TRUE;
priv->load_async_set = TRUE;
priv->load_size_async = TRUE;
}
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
} }
} }
static void static void
@ -850,7 +854,6 @@ clutter_texture_get_property (GObject *object,
{ {
ClutterTexture *texture; ClutterTexture *texture;
ClutterTexturePrivate *priv; ClutterTexturePrivate *priv;
CoglHandle cogl_texture;
texture = CLUTTER_TEXTURE(object); texture = CLUTTER_TEXTURE(object);
priv = texture->priv; priv = texture->priv;
@ -860,37 +863,43 @@ clutter_texture_get_property (GObject *object,
case PROP_MAX_TILE_WASTE: case PROP_MAX_TILE_WASTE:
g_value_set_int (value, clutter_texture_get_max_tile_waste (texture)); g_value_set_int (value, clutter_texture_get_max_tile_waste (texture));
break; break;
case PROP_PIXEL_FORMAT: case PROP_PIXEL_FORMAT:
cogl_texture = clutter_texture_get_cogl_texture (texture); g_value_set_enum (value, clutter_texture_get_pixel_format (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));
break; break;
case PROP_SYNC_SIZE: case PROP_SYNC_SIZE:
g_value_set_boolean (value, priv->sync_actor_size); g_value_set_boolean (value, priv->sync_actor_size);
break; break;
case PROP_REPEAT_X: case PROP_REPEAT_X:
g_value_set_boolean (value, priv->repeat_x); g_value_set_boolean (value, priv->repeat_x);
break; break;
case PROP_REPEAT_Y: case PROP_REPEAT_Y:
g_value_set_boolean (value, priv->repeat_y); g_value_set_boolean (value, priv->repeat_y);
break; break;
case PROP_FILTER_QUALITY: case PROP_FILTER_QUALITY:
g_value_set_enum (value, clutter_texture_get_filter_quality (texture)); g_value_set_enum (value, clutter_texture_get_filter_quality (texture));
break; break;
case PROP_COGL_TEXTURE: case PROP_COGL_TEXTURE:
g_value_set_boxed (value, clutter_texture_get_cogl_texture (texture)); g_value_set_boxed (value, clutter_texture_get_cogl_texture (texture));
break; break;
case PROP_COGL_MATERIAL: case PROP_COGL_MATERIAL:
g_value_set_boxed (value, clutter_texture_get_cogl_material (texture)); g_value_set_boxed (value, clutter_texture_get_cogl_material (texture));
break; break;
case PROP_NO_SLICE: case PROP_NO_SLICE:
g_value_set_boolean (value, priv->no_slice); g_value_set_boolean (value, priv->no_slice);
break; break;
case PROP_KEEP_ASPECT_RATIO: case PROP_KEEP_ASPECT_RATIO:
g_value_set_boolean (value, priv->keep_aspect_ratio); g_value_set_boolean (value, priv->keep_aspect_ratio);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -900,11 +909,8 @@ clutter_texture_get_property (GObject *object,
static void static void
clutter_texture_class_init (ClutterTextureClass *klass) clutter_texture_class_init (ClutterTextureClass *klass)
{ {
GObjectClass *gobject_class; GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
ClutterActorClass *actor_class; ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
gobject_class = (GObjectClass*) klass;
actor_class = (ClutterActorClass*) klass;
g_type_class_add_private (klass, sizeof (ClutterTexturePrivate)); g_type_class_add_private (klass, sizeof (ClutterTexturePrivate));
@ -983,13 +989,12 @@ clutter_texture_class_init (ClutterTextureClass *klass)
g_object_class_install_property g_object_class_install_property
(gobject_class, PROP_PIXEL_FORMAT, (gobject_class, PROP_PIXEL_FORMAT,
g_param_spec_int ("pixel-format", g_param_spec_enum ("pixel-format",
"Texture pixel format", "Texture pixel format",
"CoglPixelFormat to use.", "CoglPixelFormat to use.",
0, COGL_TYPE_PIXEL_FORMAT,
G_MAXINT, COGL_PIXEL_FORMAT_RGBA_8888,
COGL_PIXEL_FORMAT_RGBA_8888, CLUTTER_PARAM_READABLE));
G_PARAM_READABLE));
g_object_class_install_property g_object_class_install_property
(gobject_class, PROP_COGL_TEXTURE, (gobject_class, PROP_COGL_TEXTURE,
@ -1200,7 +1205,6 @@ clutter_texture_init (ClutterTexture *self)
priv->repeat_y = FALSE; priv->repeat_y = FALSE;
priv->sync_actor_size = TRUE; priv->sync_actor_size = TRUE;
priv->material = cogl_material_new (); priv->material = cogl_material_new ();
priv->fbo_texture = COGL_INVALID_HANDLE;
priv->fbo_handle = COGL_INVALID_HANDLE; priv->fbo_handle = COGL_INVALID_HANDLE;
priv->local_data = NULL; priv->local_data = NULL;
priv->keep_aspect_ratio = FALSE; priv->keep_aspect_ratio = FALSE;
@ -1650,7 +1654,7 @@ clutter_texture_set_from_yuv_data (ClutterTexture *texture,
/* /*
* clutter_texture_async_load_complete: * clutter_texture_async_load_complete:
* @self: a #ClutterTexture * @self: a #ClutterTexture
* @bitmap: a #CoglBitmap * @bitmap: a handle to a CoglBitmap
* @error: load error * @error: load error
* *
* If @error is %NULL, loads @bitmap into a #CoglTexture. * If @error is %NULL, loads @bitmap into a #CoglTexture.
@ -1659,7 +1663,7 @@ clutter_texture_set_from_yuv_data (ClutterTexture *texture,
*/ */
static void static void
clutter_texture_async_load_complete (ClutterTexture *self, clutter_texture_async_load_complete (ClutterTexture *self,
CoglBitmap *bitmap, CoglHandle bitmap,
const GError *error) const GError *error)
{ {
ClutterTexturePrivate *priv = self->priv; ClutterTexturePrivate *priv = self->priv;
@ -1893,7 +1897,7 @@ clutter_texture_async_load (ClutterTexture *self,
* If #ClutterTexture:load-async is set to %TRUE, this function * If #ClutterTexture:load-async is set to %TRUE, this function
* will return as soon as possible, and the actual image loading * will return as soon as possible, and the actual image loading
* from disk will be performed asynchronously. #ClutterTexture::size-change * from disk will be performed asynchronously. #ClutterTexture::size-change
* will be emitten when the size of the texture is available and * will be emitten when the size of the texture is available and
* #ClutterTexture::load-finished will be emitted when the image has been * #ClutterTexture::load-finished will be emitted when the image has been
* loaded or if an error occurred. * loaded or if an error occurred.
* *
@ -2155,31 +2159,19 @@ clutter_texture_new (void)
/** /**
* clutter_texture_get_base_size: * clutter_texture_get_base_size:
* @texture: A #ClutterTexture * @texture: a #ClutterTexture
* @width: Pointer to gint to be populated with width value if non NULL. * @width: (out): return location for the width, or %NULL
* @height: Pointer to gint to be populated with height value if non NULL. * @height: (out): return location for the height, or %NULL
* *
* Gets the size in pixels of the untransformed underlying texture pixbuf data. * Gets the size in pixels of the untransformed underlying image
* */
**/ void
void /* FIXME: rename to get_image_size */
clutter_texture_get_base_size (ClutterTexture *texture, clutter_texture_get_base_size (ClutterTexture *texture,
gint *width, gint *width,
gint *height) gint *height)
{ {
g_return_if_fail (CLUTTER_IS_TEXTURE (texture)); 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) if (width)
*width = texture->priv->width; *width = texture->priv->width;
@ -2309,9 +2301,11 @@ on_fbo_source_size_change (GObject *object,
{ {
CoglTextureFlags flags = COGL_TEXTURE_NONE; CoglTextureFlags flags = COGL_TEXTURE_NONE;
gint min_filter, mag_filter; gint min_filter, mag_filter;
CoglHandle tex;
/* tear down the FBO */ /* 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); texture_free_gl_resources (texture);
@ -2321,20 +2315,25 @@ on_fbo_source_size_change (GObject *object,
if (priv->filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH) if (priv->filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH)
flags |= COGL_TEXTURE_AUTO_MIPMAP; flags |= COGL_TEXTURE_AUTO_MIPMAP;
priv->fbo_texture = tex = cogl_texture_new_with_size (MAX (priv->width, 1),
cogl_texture_new_with_size (MAX (priv->width, 1), MAX (priv->height, 1),
MAX (priv->height, 1), -1,
-1, flags,
flags, COGL_PIXEL_FORMAT_RGBA_8888);
COGL_PIXEL_FORMAT_RGBA_8888);
cogl_material_set_layer (priv->material, 0, tex);
clutter_texture_quality_to_filters (priv->filter_quality, clutter_texture_quality_to_filters (priv->filter_quality,
&min_filter, &min_filter,
&mag_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) if (priv->fbo_handle == COGL_INVALID_HANDLE)
{ {
@ -2560,3 +2559,323 @@ texture_fbo_free_resources (ClutterTexture *texture)
priv->fbo_handle = COGL_INVALID_HANDLE; 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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * 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, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -105,12 +105,12 @@ struct _ClutterTextureClass
ClutterActorClass parent_class; ClutterActorClass parent_class;
/*< public >*/ /*< public >*/
void (*size_change) (ClutterTexture *texture, void (* size_change) (ClutterTexture *texture,
gint width, gint width,
gint height); gint height);
void (*pixbuf_change) (ClutterTexture *texture); void (* pixbuf_change) (ClutterTexture *texture);
void (*load_finished) (ClutterTexture *texture, void (* load_finished) (ClutterTexture *texture,
GError *error); const GError *error);
/*< private >*/ /*< private >*/
/* padding, for future expansion */ /* padding, for future expansion */
@ -123,6 +123,7 @@ struct _ClutterTextureClass
/** /**
* ClutterTextureFlags: * ClutterTextureFlags:
* @CLUTTER_TEXTURE_NONE: No flags
* @CLUTTER_TEXTURE_RGB_FLAG_BGR: FIXME * @CLUTTER_TEXTURE_RGB_FLAG_BGR: FIXME
* @CLUTTER_TEXTURE_RGB_FLAG_PREMULT: FIXME * @CLUTTER_TEXTURE_RGB_FLAG_PREMULT: FIXME
* @CLUTTER_TEXTURE_YUV_FLAG_YUV2: FIXME * @CLUTTER_TEXTURE_YUV_FLAG_YUV2: FIXME
@ -133,11 +134,12 @@ struct _ClutterTextureClass
* Since: 0.4 * Since: 0.4
*/ */
typedef enum { /*< prefix=CLUTTER_TEXTURE >*/ typedef enum { /*< prefix=CLUTTER_TEXTURE >*/
CLUTTER_TEXTURE_RGB_FLAG_BGR = 1 << 1, CLUTTER_TEXTURE_NONE = 0,
CLUTTER_TEXTURE_RGB_FLAG_PREMULT = 1 << 2, /* FIXME: not handled */ CLUTTER_TEXTURE_RGB_FLAG_BGR = 1 << 1,
CLUTTER_TEXTURE_YUV_FLAG_YUV2 = 1 << 3 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; } ClutterTextureFlags;
/** /**
@ -154,7 +156,7 @@ typedef enum { /*< prefix=CLUTTER_TEXTURE >*/
* Since: 0.8 * Since: 0.8
*/ */
typedef enum { /*< prefix=CLUTTER_TEXTURE_QUALITY >*/ typedef enum { /*< prefix=CLUTTER_TEXTURE_QUALITY >*/
CLUTTER_TEXTURE_QUALITY_LOW = 0, CLUTTER_TEXTURE_QUALITY_LOW,
CLUTTER_TEXTURE_QUALITY_MEDIUM, CLUTTER_TEXTURE_QUALITY_MEDIUM,
CLUTTER_TEXTURE_QUALITY_HIGH CLUTTER_TEXTURE_QUALITY_HIGH
} ClutterTextureQuality; } ClutterTextureQuality;
@ -209,6 +211,25 @@ void clutter_texture_set_cogl_texture (ClutterTexture
CoglHandle clutter_texture_get_cogl_material (ClutterTexture *texture); CoglHandle clutter_texture_get_cogl_material (ClutterTexture *texture);
void clutter_texture_set_cogl_material (ClutterTexture *texture, void clutter_texture_set_cogl_material (ClutterTexture *texture,
CoglHandle cogl_material); 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 G_END_DECLS

View File

@ -20,3 +20,53 @@ pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = $(pc_files) pkgconfig_DATA = $(pc_files)
CLEANFILES = $(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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -14,7 +16,9 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * 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) #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__ #ifndef __COGL_DEBUG_H__
#define __COGL_DEBUG_H__ #define __COGL_DEBUG_H__
@ -13,7 +36,8 @@ typedef enum {
COGL_DEBUG_OFFSCREEN = 1 << 4, COGL_DEBUG_OFFSCREEN = 1 << 4,
COGL_DEBUG_DRAW = 1 << 5, COGL_DEBUG_DRAW = 1 << 5,
COGL_DEBUG_PANGO = 1 << 6, COGL_DEBUG_PANGO = 1 << 6,
COGL_DEBUG_RECTANGLES = 1 << 7 COGL_DEBUG_RECTANGLES = 1 << 7,
COGL_DEBUG_HANDLE = 1 << 8
} CoglDebugFlags; } CoglDebugFlags;
#ifdef COGL_ENABLE_DEBUG #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 #ifndef COGL_DEPRECATED_H
#define cogl_color cogl_color_REPLACED_BY_cogl_set_source_color #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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -14,7 +16,9 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * 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) #if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
@ -725,7 +729,7 @@ CoglFixed cogl_angle_cos (CoglAngle angle);
/*< private >*/ /*< private >*/
#if defined (G_CAN_INLINE) #if defined (G_CAN_INLINE)
G_INLINE_FUNC CoglFixed G_INLINE_FUNC CoglFixed
cogl_fixed_mul (CoglFixed a, cogl_fixed_mul (CoglFixed a,
CoglFixed b) CoglFixed b)
{ {

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) #if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
#error "Only <cogl/cogl.h> can be included directly." #error "Only <cogl/cogl.h> can be included directly."
#endif #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. * 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 * Since 1.0
*/ */
@ -111,7 +134,7 @@ void cogl_material_set_color4ub (CoglHandle material,
* Since 1.0 * Since 1.0
*/ */
void cogl_material_set_color4f (CoglHandle material, void cogl_material_set_color4f (CoglHandle material,
float red, float red,
float green, float green,
float blue, float blue,
float alpha); 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 #ifndef __COGL_MATRIX_H
#define __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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -14,7 +16,9 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * 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) #if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
@ -31,43 +35,47 @@ G_BEGIN_DECLS
/** /**
* SECTION:cogl-offscreen * SECTION:cogl-offscreen
* @short_description: Fuctions for creating and manipulating 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 */ /* Offscreen api */
/** /**
* cogl_offscreen_new_to_texture: * 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); CoglHandle cogl_offscreen_new_to_texture (CoglHandle texhandle);
/**
* cogl_offscreen_new_multisample:
*
*
* Returns:
*/
CoglHandle cogl_offscreen_new_multisample (void);
/** /**
* cogl_offscreen_ref: * 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); CoglHandle cogl_offscreen_ref (CoglHandle handle);
/** /**
* cogl_is_offscreen: * cogl_is_offscreen:
* @handle: A CoglHandle * @handle: A CoglHandle for an offscreen buffer
* *
* Gets whether the given handle references an existing offscreen * Gets whether the given handle references an existing offscreen buffer
* buffer object. * object.
* *
* Returns: %TRUE if the handle references an offscreen buffer, * Returns: %TRUE if the handle references an offscreen buffer,
* %FALSE otherwise * %FALSE otherwise
@ -76,54 +84,13 @@ gboolean cogl_is_offscreen (CoglHandle handle);
/** /**
* cogl_offscreen_unref: * 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); 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 G_END_DECLS
#endif /* __COGL_OFFSCREEN_H__ */ #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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -14,7 +16,9 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * 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) #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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -14,7 +16,9 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * 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) #if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
@ -24,7 +28,7 @@
#ifndef __COGL_SHADER_H__ #ifndef __COGL_SHADER_H__
#define __COGL_SHADER_H__ #define __COGL_SHADER_H__
#include <glib.h> #include <cogl/cogl-types.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@ -38,6 +42,17 @@ G_BEGIN_DECLS
* The only supported format is GLSL shaders. * 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: * cogl_create_shader:
* @shader_type: CGL_VERTEX_SHADER or CGL_FRAGMENT_SHADER. * @shader_type: CGL_VERTEX_SHADER or CGL_FRAGMENT_SHADER.
@ -47,7 +62,7 @@ G_BEGIN_DECLS
* *
* Returns: a new shader handle. * Returns: a new shader handle.
*/ */
CoglHandle cogl_create_shader (COGLenum shader_type); CoglHandle cogl_create_shader (CoglShaderType shader_type);
/** /**
* cogl_shader_ref: * 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 * Replaces the current GLSL source associated with a shader with a new
* one. * one.
*/ */
void cogl_shader_source (CoglHandle shader, void cogl_shader_source (CoglHandle shader,
const gchar *source); const char *source);
/** /**
* cogl_shader_compile: * cogl_shader_compile:
* @handle: #CoglHandle for a shader. * @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 * messages that caused a shader to not compile correctly, mainly useful for
* debugging purposes. * debugging purposes.
*/ */
void cogl_shader_get_info_log (CoglHandle handle, void cogl_shader_get_info_log (CoglHandle handle,
guint size, size_t size,
gchar *buffer); char *buffer);
/** /**
* cogl_shader_get_parameteriv: * cogl_shader_get_type:
* @handle: #CoglHandle for a shader. * @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 * Returns: COGL_SHADER_TYPE_VERTEX if the shader is a vertex processor
* satus of a shader by passing in CGL_OBJECT_COMPILE_STATUS for @pname. * or COGL_SHADER_TYPE_FRAGMENT if the shader is a frament processor
*/ */
void cogl_shader_get_parameteriv (CoglHandle handle, CoglShaderType cogl_shader_get_type (CoglHandle handle);
COGLenum pname,
COGLint *dest); /**
* 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: * 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 * This uniform can be set using cogl_program_uniform_1f() when the
* program is in use. * program is in use.
*/ */
COGLint cogl_program_get_uniform_location int cogl_program_get_uniform_location
(CoglHandle handle, (CoglHandle handle,
const gchar *uniform_name); const char *uniform_name);
/** /**
* cogl_program_uniform_1f: * 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 * Changes the value of a floating point uniform in the currently
* used (see cogl_program_use()) shader program. * used (see cogl_program_use()) shader program.
*/ */
void cogl_program_uniform_1f (COGLint uniform_no, void cogl_program_uniform_1f (int uniform_no,
gfloat value); float value);
/** /**
* cogl_program_uniform_1i: * 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 * Changes the value of an integer uniform in the currently
* used (see cogl_program_use()) shader program. * used (see cogl_program_use()) shader program.
*/ */
void cogl_program_uniform_1i (COGLint uniform_no, void cogl_program_uniform_1i (int uniform_no,
gint value); int value);
/** /**
* cogl_program_uniform_float: * 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 * Changes the value of a float vector uniform, or uniform array in the
* currently used (see #cogl_program_use) shader program. * currently used (see #cogl_program_use) shader program.
*/ */
void cogl_program_uniform_float (COGLint uniform_no, void cogl_program_uniform_float (int uniform_no,
gint size, int size,
gint count, int count,
const GLfloat *value); 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 * Changes the value of a int vector uniform, or uniform array in the
* currently used (see cogl_program_use()) shader program. * currently used (see cogl_program_use()) shader program.
*/ */
void cogl_program_uniform_int (COGLint uniform_no, void cogl_program_uniform_int (int uniform_no,
gint size, int size,
gint count, int count,
const COGLint *value); const int *value);
/** /**
* cogl_program_uniform_matrix: * 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 * currently used (see cogl_program_use()) shader program. The @size
* parameter is used to determine the square size of the matrix. * parameter is used to determine the square size of the matrix.
*/ */
void cogl_program_uniform_matrix (COGLint uniform_no, void cogl_program_uniform_matrix (int uniform_no,
gint size, int size,
gint count, int count,
gboolean transpose, gboolean transpose,
const GLfloat *value); const float *value);
G_END_DECLS 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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -14,7 +16,9 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * 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) #if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
@ -24,10 +28,10 @@
#ifndef __COGL_TEXTURE_H__ #ifndef __COGL_TEXTURE_H__
#define __COGL_TEXTURE_H__ #define __COGL_TEXTURE_H__
G_BEGIN_DECLS
#include <cogl/cogl-types.h> #include <cogl/cogl-types.h>
G_BEGIN_DECLS
/** /**
* SECTION:cogl-texture * SECTION:cogl-texture
* @short_description: Fuctions for creating and manipulating textures * @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: * cogl_texture_new_from_bitmap:
* @bitmap: a #CoglBitmap * @bmp_handle: A CoglBitmap handle
* @max_waste: maximum extra horizontal and|or vertical margin pixels * @max_waste: maximum extra horizontal and|or vertical margin pixels
* to make the texture fit GPU limitations * to make the texture fit GPU limitations
* @flags: Optional flags for the texture, or %COGL_TEXTURE_NONE * @flags: Optional flags for the texture, or %COGL_TEXTURE_NONE
* @internal_format: the #CoglPixelFormat to use for the GPU storage of the * @internal_format: the #CoglPixelFormat to use for the GPU storage of the
* texture * 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 * Return value: a #CoglHandle to the newly created texture or
* %COGL_INVALID_HANDLE on failure * %COGL_INVALID_HANDLE on failure
* *
* Since: 1.0 * Since: 1.0
*/ */
CoglHandle cogl_texture_new_from_bitmap (CoglBitmap *bitmap, CoglHandle cogl_texture_new_from_bitmap (CoglHandle bmp_handle,
gint max_waste, gint max_waste,
CoglTextureFlags flags, CoglTextureFlags flags,
CoglPixelFormat internal_format); CoglPixelFormat internal_format);
@ -224,6 +228,52 @@ guint cogl_texture_get_rowstride (CoglHandle handle);
*/ */
gint cogl_texture_get_max_waste (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: * cogl_texture_get_min_filter:
* @handle: a #CoglHandle for a texture. * @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. * 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: * 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. * 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: * cogl_texture_is_sliced:
@ -303,8 +353,8 @@ gint cogl_texture_get_data (CoglHandle handle,
* drawn at other scales than 100%. * drawn at other scales than 100%.
*/ */
void cogl_texture_set_filters (CoglHandle handle, void cogl_texture_set_filters (CoglHandle handle,
COGLenum min_filter, CoglTextureFilter min_filter,
COGLenum mag_filter); CoglTextureFilter mag_filter);
/** /**
@ -359,45 +409,6 @@ CoglHandle cogl_texture_ref (CoglHandle handle);
*/ */
void cogl_texture_unref (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: * cogl_rectangle_with_texture_coords:
* @x1: x coordinate upper left on screen. * @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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * 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, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -15,7 +16,9 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * 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) #if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
@ -29,13 +32,6 @@
G_BEGIN_DECLS G_BEGIN_DECLS
/**
* CoglBitmap:
*
* Type used for storing image data.
*/
typedef struct _CoglBitmap CoglBitmap;
/** /**
* CoglHandle: * CoglHandle:
* *
@ -137,7 +133,7 @@ typedef enum
COGL_PIXEL_FORMAT_RGBA_5551 = 6 | COGL_A_BIT, COGL_PIXEL_FORMAT_RGBA_5551 = 6 | COGL_A_BIT,
COGL_PIXEL_FORMAT_YUV = 7, COGL_PIXEL_FORMAT_YUV = 7,
COGL_PIXEL_FORMAT_G_8 = 8, COGL_PIXEL_FORMAT_G_8 = 8,
COGL_PIXEL_FORMAT_RGB_888 = COGL_PIXEL_FORMAT_24, COGL_PIXEL_FORMAT_RGB_888 = COGL_PIXEL_FORMAT_24,
COGL_PIXEL_FORMAT_BGR_888 = (COGL_PIXEL_FORMAT_24 | COGL_PIXEL_FORMAT_BGR_888 = (COGL_PIXEL_FORMAT_24 |
@ -178,7 +174,7 @@ typedef enum
COGL_PREMULT_BIT | COGL_PREMULT_BIT |
COGL_BGR_BIT | COGL_BGR_BIT |
COGL_AFIRST_BIT), COGL_AFIRST_BIT),
COGL_PIXEL_FORMAT_RGBA_4444_PRE = (COGL_PIXEL_FORMAT_RGBA_4444 | COGL_PIXEL_FORMAT_RGBA_4444_PRE = (COGL_PIXEL_FORMAT_RGBA_4444 |
COGL_A_BIT | COGL_A_BIT |
COGL_PREMULT_BIT), COGL_PREMULT_BIT),
@ -186,8 +182,8 @@ typedef enum
COGL_PIXEL_FORMAT_RGBA_5551_PRE = (COGL_PIXEL_FORMAT_RGBA_5551 | COGL_PIXEL_FORMAT_RGBA_5551_PRE = (COGL_PIXEL_FORMAT_RGBA_5551 |
COGL_A_BIT | COGL_A_BIT |
COGL_PREMULT_BIT), COGL_PREMULT_BIT),
} CoglPixelFormat; } CoglPixelFormat;
#define COGL_TYPE_PIXEL_FORMAT (cogl_pixel_format_get_type ()) #define COGL_TYPE_PIXEL_FORMAT (cogl_pixel_format_get_type ())
@ -232,7 +228,6 @@ GType cogl_feature_flags_get_type (void) G_GNUC_CONST;
/** /**
* CoglBufferTarget: * CoglBufferTarget:
* @COGL_WINDOW_BUFFER: FIXME * @COGL_WINDOW_BUFFER: FIXME
* @COGL_MASK_BUFFER: FIXME
* @COGL_OFFSCREEN_BUFFER: FIXME * @COGL_OFFSCREEN_BUFFER: FIXME
* *
* Target flags for FBOs. * Target flags for FBOs.
@ -242,8 +237,7 @@ GType cogl_feature_flags_get_type (void) G_GNUC_CONST;
typedef enum typedef enum
{ {
COGL_WINDOW_BUFFER = (1 << 1), COGL_WINDOW_BUFFER = (1 << 1),
COGL_MASK_BUFFER = (1 << 2), COGL_OFFSCREEN_BUFFER = (1 << 2)
COGL_OFFSCREEN_BUFFER = (1 << 3)
} CoglBufferTarget; } CoglBufferTarget;
#define COGL_TYPE_BUFFER_TARGET (cogl_buffer_target_get_type ()) #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,2009 Intel Corporation.
*
* Copyright (C) 2008 Intel Corporation.
*
* Authored by: Robert Bragg <robert@linux.intel.com>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,7 +16,12 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * 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) #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) 2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version. * version 2 of the License, or (at your option) any later version.
@ -41,6 +40,7 @@
#include <cogl/cogl-material.h> #include <cogl/cogl-material.h>
#include <cogl/cogl-path.h> #include <cogl/cogl-path.h>
#include <cogl/cogl-shader.h> #include <cogl/cogl-shader.h>
#include <cogl/cogl-bitmap.h>
#include <cogl/cogl-texture.h> #include <cogl/cogl-texture.h>
#include <cogl/cogl-types.h> #include <cogl/cogl-types.h>
#include <cogl/cogl-debug.h> #include <cogl/cogl-debug.h>
@ -363,14 +363,29 @@ void cogl_set_fog (const CoglColor *fog_color,
*/ */
void cogl_disable_fog (void); 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: * cogl_clear:
* @color: Background color to clear to * @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 * Clears all the auxiliary buffers identified in the @buffers mask, and if
* buffers are also cleared. * 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: * cogl_set_source:
@ -475,6 +490,27 @@ void cogl_set_source_texture (CoglHandle texture_handle);
* intersected with the previous region. * 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: * cogl_clip_push:
* @x_offset: left edge of the clip rectangle * @x_offset: left edge of the clip rectangle
@ -563,6 +599,35 @@ void cogl_clip_stack_save (void);
*/ */
void cogl_clip_stack_restore (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: * cogl_flush_gl_state:
* @flags: flags controlling what is flushed; currently unused, pass in 0 * @flags: flags controlling what is flushed; currently unused, pass in 0

View File

@ -2,27 +2,25 @@ INCLUDES = \
-I$(top_srcdir) \ -I$(top_srcdir) \
-I$(top_srcdir)/clutter \ -I$(top_srcdir)/clutter \
-I$(top_srcdir)/clutter/cogl \ -I$(top_srcdir)/clutter/cogl \
-I$(top_srcdir)/clutter/cogl/common \
-I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \ -I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \
-I$(top_builddir)/clutter \ -I$(top_builddir)/clutter \
-I$(top_builddir)/clutter/cogl \ -I$(top_builddir)/clutter/cogl \
-DG_LOG_DOMAIN=\"Cogl-Common\" \ -DG_LOG_DOMAIN=\"Cogl-Common\" \
-DCLUTTER_COMPILATION \ -DCLUTTER_COMPILATION
$(CLUTTER_CFLAGS) \
$(CLUTTER_DEBUG_CFLAGS) \
$(MAINTAINER_CFLAGS) \
$(GCC_FLAGS)
LDADD = $(CLUTTER_LIBS)
noinst_LTLIBRARIES = libclutter-cogl-common.la noinst_LTLIBRARIES = libclutter-cogl-common.la
EXTRA_DIST = stb_image.c 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 = \ libclutter_cogl_common_la_SOURCES = \
cogl-handle.h \ cogl-handle.h \
cogl-internal.h \
cogl.c \ cogl.c \
cogl-util.h \ cogl-util.h \
cogl-util.c \ cogl-util.c \
cogl-bitmap.h \ cogl-bitmap-private.h \
cogl-bitmap.c \ cogl-bitmap.c \
cogl-bitmap-fallback.c \ cogl-bitmap-fallback.c \
cogl-current-matrix.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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -29,7 +27,7 @@
#include "cogl.h" #include "cogl.h"
#include "cogl-internal.h" #include "cogl-internal.h"
#include "cogl-bitmap.h" #include "cogl-bitmap-private.h"
#include <string.h> #include <string.h>
@ -164,7 +162,7 @@ inline static void
_cogl_unpremult_alpha_last (const guchar *src, guchar *dst) _cogl_unpremult_alpha_last (const guchar *src, guchar *dst)
{ {
guchar alpha = src[3]; guchar alpha = src[3];
dst[0] = ((((gulong) src[0] >> 16) & 0xff) * 255 ) / alpha; dst[0] = ((((gulong) src[0] >> 16) & 0xff) * 255 ) / alpha;
dst[1] = ((((gulong) src[1] >> 8) & 0xff) * 255 ) / alpha; dst[1] = ((((gulong) src[1] >> 8) & 0xff) * 255 ) / alpha;
dst[2] = ((((gulong) src[2] >> 0) & 0xff) * 255 ) / alpha; dst[2] = ((((gulong) src[2] >> 0) & 0xff) * 255 ) / alpha;
@ -175,7 +173,7 @@ inline static void
_cogl_unpremult_alpha_first (const guchar *src, guchar *dst) _cogl_unpremult_alpha_first (const guchar *src, guchar *dst)
{ {
guchar alpha = src[0]; guchar alpha = src[0];
dst[0] = alpha; dst[0] = alpha;
dst[1] = ((((gulong) src[1] >> 16) & 0xff) * 255 ) / alpha; dst[1] = ((((gulong) src[1] >> 16) & 0xff) * 255 ) / alpha;
dst[2] = ((((gulong) src[2] >> 8) & 0xff) * 255 ) / alpha; dst[2] = ((((gulong) src[2] >> 8) & 0xff) * 255 ) / alpha;
@ -187,23 +185,23 @@ _cogl_bitmap_fallback_can_convert (CoglPixelFormat src, CoglPixelFormat dst)
{ {
if (src == dst) if (src == dst)
return FALSE; return FALSE;
switch (src & COGL_UNORDERED_MASK) switch (src & COGL_UNORDERED_MASK)
{ {
case COGL_PIXEL_FORMAT_G_8: case COGL_PIXEL_FORMAT_G_8:
case COGL_PIXEL_FORMAT_24: case COGL_PIXEL_FORMAT_24:
case COGL_PIXEL_FORMAT_32: case COGL_PIXEL_FORMAT_32:
if ((dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_24 && if ((dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_24 &&
(dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_32 && (dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_32 &&
(dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_G_8) (dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_G_8)
return FALSE; return FALSE;
break; break;
default: default:
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
@ -224,11 +222,11 @@ _cogl_bitmap_fallback_convert (const CoglBitmap *bmp,
gint dst_bpp; gint dst_bpp;
gint x,y; gint x,y;
guchar temp_rgba[4] = {0,0,0,0}; guchar temp_rgba[4] = {0,0,0,0};
/* Make sure conversion supported */ /* Make sure conversion supported */
if (!_cogl_bitmap_fallback_can_convert (bmp->format, dst_format)) if (!_cogl_bitmap_fallback_can_convert (bmp->format, dst_format))
return FALSE; return FALSE;
src_bpp = _cogl_get_format_bpp (bmp->format); src_bpp = _cogl_get_format_bpp (bmp->format);
dst_bpp = _cogl_get_format_bpp (dst_format); dst_bpp = _cogl_get_format_bpp (dst_format);
@ -237,18 +235,18 @@ _cogl_bitmap_fallback_convert (const CoglBitmap *bmp,
dst_bmp->rowstride = sizeof(guchar) * dst_bpp * dst_bmp->width; dst_bmp->rowstride = sizeof(guchar) * dst_bpp * dst_bmp->width;
dst_bmp->format = ((bmp->format & COGL_PREMULT_BIT) | dst_bmp->format = ((bmp->format & COGL_PREMULT_BIT) |
(dst_format & COGL_UNPREMULT_MASK)); (dst_format & COGL_UNPREMULT_MASK));
/* Allocate a new buffer to hold converted data */ /* Allocate a new buffer to hold converted data */
dst_bmp->data = g_malloc (sizeof(guchar) dst_bmp->data = g_malloc (sizeof(guchar)
* dst_bmp->height * dst_bmp->height
* dst_bmp->rowstride); * dst_bmp->rowstride);
/* FIXME: Optimize */ /* FIXME: Optimize */
for (y = 0; y < bmp->height; y++) for (y = 0; y < bmp->height; y++)
{ {
src = (guchar*)bmp->data + y * bmp->rowstride; src = (guchar*)bmp->data + y * bmp->rowstride;
dst = (guchar*)dst_bmp->data + y * dst_bmp->rowstride; dst = (guchar*)dst_bmp->data + y * dst_bmp->rowstride;
for (x = 0; x < bmp->width; x++) for (x = 0; x < bmp->width; x++)
{ {
/* FIXME: Would be nice to at least remove this inner /* FIXME: Would be nice to at least remove this inner
@ -273,7 +271,7 @@ _cogl_bitmap_fallback_convert (const CoglBitmap *bmp,
default: default:
break; break;
} }
switch (dst_format & COGL_UNPREMULT_MASK) switch (dst_format & COGL_UNPREMULT_MASK)
{ {
case COGL_PIXEL_FORMAT_G_8: case COGL_PIXEL_FORMAT_G_8:
@ -293,12 +291,12 @@ _cogl_bitmap_fallback_convert (const CoglBitmap *bmp,
default: default:
break; break;
} }
src += src_bpp; src += src_bpp;
dst += dst_bpp; dst += dst_bpp;
} }
} }
return TRUE; return TRUE;
} }
@ -310,28 +308,28 @@ _cogl_bitmap_fallback_unpremult (const CoglBitmap *bmp,
guchar *dst; guchar *dst;
gint bpp; gint bpp;
gint x,y; gint x,y;
/* Make sure format supported for un-premultiplication */ /* Make sure format supported for un-premultiplication */
if (!_cogl_bitmap_fallback_can_unpremult (bmp->format)) if (!_cogl_bitmap_fallback_can_unpremult (bmp->format))
return FALSE; return FALSE;
bpp = _cogl_get_format_bpp (bmp->format); bpp = _cogl_get_format_bpp (bmp->format);
/* Initialize destination bitmap */ /* Initialize destination bitmap */
*dst_bmp = *bmp; *dst_bmp = *bmp;
dst_bmp->format = (bmp->format & COGL_UNPREMULT_MASK); dst_bmp->format = (bmp->format & COGL_UNPREMULT_MASK);
/* Allocate a new buffer to hold converted data */ /* Allocate a new buffer to hold converted data */
dst_bmp->data = g_malloc (sizeof(guchar) dst_bmp->data = g_malloc (sizeof(guchar)
* dst_bmp->height * dst_bmp->height
* dst_bmp->rowstride); * dst_bmp->rowstride);
/* FIXME: Optimize */ /* FIXME: Optimize */
for (y = 0; y < bmp->height; y++) for (y = 0; y < bmp->height; y++)
{ {
src = (guchar*)bmp->data + y * bmp->rowstride; src = (guchar*)bmp->data + y * bmp->rowstride;
dst = (guchar*)dst_bmp->data + y * dst_bmp->rowstride; dst = (guchar*)dst_bmp->data + y * dst_bmp->rowstride;
for (x = 0; x < bmp->width; x++) for (x = 0; x < bmp->width; x++)
{ {
/* FIXME: Would be nice to at least remove this inner /* FIXME: Would be nice to at least remove this inner
@ -351,12 +349,12 @@ _cogl_bitmap_fallback_unpremult (const CoglBitmap *bmp,
else else
_cogl_unpremult_alpha_last (src, dst); _cogl_unpremult_alpha_last (src, dst);
} }
src += bpp; src += bpp;
dst += bpp; dst += bpp;
} }
} }
return TRUE; return TRUE;
} }

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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -29,7 +27,7 @@
#include "cogl.h" #include "cogl.h"
#include "cogl-internal.h" #include "cogl-internal.h"
#include "cogl-bitmap.h" #include "cogl-bitmap-private.h"
#include <string.h> #include <string.h>
@ -222,7 +220,7 @@ _cogl_bitmap_from_file (CoglBitmap *bmp,
guchar *out_data; guchar *out_data;
guchar *out; guchar *out;
gint r; gint r;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (bmp == NULL) if (bmp == NULL)
@ -232,7 +230,7 @@ _cogl_bitmap_from_file (CoglBitmap *bmp,
pixbuf = gdk_pixbuf_new_from_file (filename, error); pixbuf = gdk_pixbuf_new_from_file (filename, error);
if (pixbuf == NULL) if (pixbuf == NULL)
return FALSE; return FALSE;
/* Get pixbuf properties */ /* Get pixbuf properties */
has_alpha = gdk_pixbuf_get_has_alpha (pixbuf); has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
color_space = gdk_pixbuf_get_colorspace (pixbuf); color_space = gdk_pixbuf_get_colorspace (pixbuf);
@ -241,10 +239,10 @@ _cogl_bitmap_from_file (CoglBitmap *bmp,
rowstride = gdk_pixbuf_get_rowstride (pixbuf); rowstride = gdk_pixbuf_get_rowstride (pixbuf);
bits_per_sample = gdk_pixbuf_get_bits_per_sample (pixbuf); bits_per_sample = gdk_pixbuf_get_bits_per_sample (pixbuf);
n_channels = gdk_pixbuf_get_n_channels (pixbuf); n_channels = gdk_pixbuf_get_n_channels (pixbuf);
/* The docs say this is the right way */ /* The docs say this is the right way */
last_row_size = width * ((n_channels * bits_per_sample + 7) / 8); last_row_size = width * ((n_channels * bits_per_sample + 7) / 8);
/* According to current docs this should be true and so /* According to current docs this should be true and so
* the translation to cogl pixel format below valid */ * the translation to cogl pixel format below valid */
g_assert (bits_per_sample == 8); g_assert (bits_per_sample == 8);
@ -253,7 +251,7 @@ _cogl_bitmap_from_file (CoglBitmap *bmp,
g_assert (n_channels == 4); g_assert (n_channels == 4);
else else
g_assert (n_channels == 3); g_assert (n_channels == 3);
/* Translate to cogl pixel format */ /* Translate to cogl pixel format */
switch (color_space) switch (color_space)
{ {
@ -263,19 +261,19 @@ _cogl_bitmap_from_file (CoglBitmap *bmp,
COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGBA_8888 :
COGL_PIXEL_FORMAT_RGB_888; COGL_PIXEL_FORMAT_RGB_888;
break; break;
default: default:
/* Ouch, spec changed! */ /* Ouch, spec changed! */
g_object_unref (pixbuf); g_object_unref (pixbuf);
return FALSE; return FALSE;
} }
/* FIXME: Any way to destroy pixbuf but retain pixel data? */ /* FIXME: Any way to destroy pixbuf but retain pixel data? */
pixels = gdk_pixbuf_get_pixels (pixbuf); pixels = gdk_pixbuf_get_pixels (pixbuf);
out_data = (guchar*) g_malloc (height * rowstride); out_data = (guchar*) g_malloc (height * rowstride);
out = out_data; out = out_data;
/* Copy up to last row */ /* Copy up to last row */
for (r = 0; r < height-1; ++r) for (r = 0; r < height-1; ++r)
{ {
@ -283,13 +281,13 @@ _cogl_bitmap_from_file (CoglBitmap *bmp,
pixels += rowstride; pixels += rowstride;
out += rowstride; out += rowstride;
} }
/* Copy last row */ /* Copy last row */
memcpy (out, pixels, last_row_size); memcpy (out, pixels, last_row_size);
/* Destroy GdkPixbuf object */ /* Destroy GdkPixbuf object */
g_object_unref (pixbuf); g_object_unref (pixbuf);
/* Store bitmap info */ /* Store bitmap info */
bmp->data = out_data; /* The stored data the same alignment constraints as a bmp->data = out_data; /* The stored data the same alignment constraints as a
* gdkpixbuf but stores a full rowstride in the last * gdkpixbuf but stores a full rowstride in the last
@ -299,7 +297,7 @@ _cogl_bitmap_from_file (CoglBitmap *bmp,
bmp->width = width; bmp->width = width;
bmp->height = height; bmp->height = height;
bmp->rowstride = rowstride; bmp->rowstride = rowstride;
return TRUE; return TRUE;
} }
@ -335,14 +333,14 @@ _cogl_bitmap_from_file (CoglBitmap *bmp,
if (bmp == NULL) if (bmp == NULL)
return FALSE; return FALSE;
/* Load from file using stb */ /* Load from file using stb */
pixels = stbi_load (filename, pixels = stbi_load (filename,
&width, &height, &stb_pixel_format, &width, &height, &stb_pixel_format,
STBI_rgb_alpha); STBI_rgb_alpha);
if (pixels == NULL) if (pixels == NULL)
return FALSE; return FALSE;
/* Store bitmap info */ /* Store bitmap info */
bmp->data = g_memdup (pixels, height * width * 4); bmp->data = g_memdup (pixels, height * width * 4);
bmp->format = COGL_PIXEL_FORMAT_RGBA_8888; bmp->format = COGL_PIXEL_FORMAT_RGBA_8888;

View File

@ -28,14 +28,17 @@
#include <glib.h> #include <glib.h>
struct _CoglBitmap #include "cogl-handle.h"
typedef struct _CoglBitmap
{ {
CoglHandleObject _parent;
guchar *data; guchar *data;
CoglPixelFormat format; CoglPixelFormat format;
gint width; gint width;
gint height; gint height;
gint rowstride; gint rowstride;
}; } CoglBitmap;
gboolean gboolean
_cogl_bitmap_can_convert (CoglPixelFormat src, CoglPixelFormat dst); _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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -29,10 +27,21 @@
#include "cogl.h" #include "cogl.h"
#include "cogl-internal.h" #include "cogl-internal.h"
#include "cogl-bitmap.h" #include "cogl-bitmap-private.h"
#include <string.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 gint
_cogl_get_format_bpp (CoglPixelFormat format) _cogl_get_format_bpp (CoglPixelFormat format)
{ {
@ -47,7 +56,7 @@ _cogl_get_format_bpp (CoglPixelFormat format)
2, /* YUV */ 2, /* YUV */
1 /* G_8 */ 1 /* G_8 */
}; };
return bpp_lut [format & COGL_UNORDERED_MASK]; return bpp_lut [format & COGL_UNORDERED_MASK];
} }
@ -59,7 +68,7 @@ _cogl_bitmap_convert_and_premult (const CoglBitmap *bmp,
CoglBitmap tmp_bmp = *bmp; CoglBitmap tmp_bmp = *bmp;
CoglBitmap new_bmp = *bmp; CoglBitmap new_bmp = *bmp;
gboolean new_bmp_owner = FALSE; gboolean new_bmp_owner = FALSE;
/* Is base format different (not considering premult status)? */ /* Is base format different (not considering premult status)? */
if ((bmp->format & COGL_UNPREMULT_MASK) != if ((bmp->format & COGL_UNPREMULT_MASK) !=
(dst_format & COGL_UNPREMULT_MASK)) (dst_format & COGL_UNPREMULT_MASK))
@ -71,12 +80,12 @@ _cogl_bitmap_convert_and_premult (const CoglBitmap *bmp,
if (!_cogl_bitmap_fallback_convert (&new_bmp, &tmp_bmp, dst_format)) if (!_cogl_bitmap_fallback_convert (&new_bmp, &tmp_bmp, dst_format))
return FALSE; return FALSE;
} }
/* Update bitmap with new data */ /* Update bitmap with new data */
new_bmp = tmp_bmp; new_bmp = tmp_bmp;
new_bmp_owner = TRUE; new_bmp_owner = TRUE;
} }
/* Do we need to unpremultiply */ /* Do we need to unpremultiply */
if ((bmp->format & COGL_PREMULT_BIT) == 0 && if ((bmp->format & COGL_PREMULT_BIT) == 0 &&
(dst_format & COGL_PREMULT_BIT) > 0) (dst_format & COGL_PREMULT_BIT) > 0)
@ -89,19 +98,19 @@ _cogl_bitmap_convert_and_premult (const CoglBitmap *bmp,
{ {
if (new_bmp_owner) if (new_bmp_owner)
g_free (new_bmp.data); g_free (new_bmp.data);
return FALSE; return FALSE;
} }
} }
/* Update bitmap with new data */ /* Update bitmap with new data */
if (new_bmp_owner) if (new_bmp_owner)
g_free (new_bmp.data); g_free (new_bmp.data);
new_bmp = tmp_bmp; new_bmp = tmp_bmp;
new_bmp_owner = TRUE; new_bmp_owner = TRUE;
} }
/* Do we need to premultiply */ /* Do we need to premultiply */
if ((bmp->format & COGL_PREMULT_BIT) > 0 && if ((bmp->format & COGL_PREMULT_BIT) > 0 &&
(dst_format & COGL_PREMULT_BIT) == 0) (dst_format & COGL_PREMULT_BIT) == 0)
@ -109,13 +118,13 @@ _cogl_bitmap_convert_and_premult (const CoglBitmap *bmp,
/* FIXME: implement premultiplication */ /* FIXME: implement premultiplication */
if (new_bmp_owner) if (new_bmp_owner)
g_free (new_bmp.data); g_free (new_bmp.data);
return FALSE; return FALSE;
} }
/* Output new bitmap info */ /* Output new bitmap info */
*dst_bmp = new_bmp; *dst_bmp = new_bmp;
return TRUE; return TRUE;
} }
@ -133,14 +142,14 @@ _cogl_bitmap_copy_subregion (CoglBitmap *src,
guchar *dstdata; guchar *dstdata;
gint bpp; gint bpp;
gint line; gint line;
/* Intended only for fast copies when format is equal! */ /* Intended only for fast copies when format is equal! */
g_assert (src->format == dst->format); g_assert (src->format == dst->format);
bpp = _cogl_get_format_bpp (src->format); bpp = _cogl_get_format_bpp (src->format);
srcdata = src->data + src_y * src->rowstride + src_x * bpp; srcdata = src->data + src_y * src->rowstride + src_x * bpp;
dstdata = dst->data + dst_y * dst->rowstride + dst_x * bpp; dstdata = dst->data + dst_y * dst->rowstride + dst_x * bpp;
for (line=0; line<height; ++line) for (line=0; line<height; ++line)
{ {
memcpy (dstdata, srcdata, width * bpp); memcpy (dstdata, srcdata, width * bpp);
@ -157,12 +166,13 @@ cogl_bitmap_get_size_from_file (const gchar *filename,
return _cogl_bitmap_get_size_from_file (filename, width, height); return _cogl_bitmap_get_size_from_file (filename, width, height);
} }
CoglBitmap * CoglHandle
cogl_bitmap_new_from_file (const gchar *filename, cogl_bitmap_new_from_file (const gchar *filename,
GError **error) GError **error)
{ {
CoglBitmap bmp; CoglBitmap bmp;
CoglBitmap *ret;
g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE); g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE);
/* Try loading with imaging backend */ /* Try loading with imaging backend */
@ -177,13 +187,8 @@ cogl_bitmap_new_from_file (const gchar *filename,
*error = NULL; *error = NULL;
} }
} }
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) 2007,2008,2009 Intel Corporation.
*
* Copyright (C) 2008 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -28,10 +26,14 @@
#endif #endif
#include <string.h> #include <string.h>
#include <glib.h>
#include "cogl.h" #include "cogl.h"
#include "cogl-clip-stack.h" #include "cogl-clip-stack.h"
#include "cogl-primitives.h" #include "cogl-primitives.h"
#include "cogl-context.h" #include "cogl-context.h"
#include "cogl-internal.h"
/* These are defined in the particular backend (float in GL vs fixed /* These are defined in the particular backend (float in GL vs fixed
in GL ES) */ in GL ES) */
@ -57,11 +59,13 @@ void _cogl_set_matrix (const CoglMatrix *matrix);
typedef struct _CoglClipStack CoglClipStack; typedef struct _CoglClipStack CoglClipStack;
typedef struct _CoglClipStackEntryRect CoglClipStackEntryRect; typedef struct _CoglClipStackEntryRect CoglClipStackEntryRect;
typedef struct _CoglClipStackEntryWindowRect CoglClipStackEntryWindowRect;
typedef struct _CoglClipStackEntryPath CoglClipStackEntryPath; typedef struct _CoglClipStackEntryPath CoglClipStackEntryPath;
typedef enum typedef enum
{ {
COGL_CLIP_STACK_RECT, COGL_CLIP_STACK_RECT,
COGL_CLIP_STACK_WINDOW_RECT,
COGL_CLIP_STACK_PATH COGL_CLIP_STACK_PATH
} CoglClipStackEntryType; } CoglClipStackEntryType;
@ -72,7 +76,7 @@ struct _CoglClipStack
struct _CoglClipStackEntryRect struct _CoglClipStackEntryRect
{ {
CoglClipStackEntryType type; CoglClipStackEntryType type;
/* The rectangle for this clip */ /* The rectangle for this clip */
float x_offset; float x_offset;
@ -84,20 +88,126 @@ struct _CoglClipStackEntryRect
CoglMatrix matrix; CoglMatrix matrix;
}; };
struct _CoglClipStackEntryWindowRect
{
CoglClipStackEntryType type;
/* The window space rectangle for this clip */
float x0;
float y0;
float x1;
float y1;
};
struct _CoglClipStackEntryPath struct _CoglClipStackEntryPath
{ {
CoglClipStackEntryType type; CoglClipStackEntryType type;
/* The matrix that was current when the clip was set */ /* The matrix that was current when the clip was set */
CoglMatrix matrix; CoglMatrix matrix;
floatVec2 path_nodes_min; floatVec2 path_nodes_min;
floatVec2 path_nodes_max; floatVec2 path_nodes_max;
guint path_size; guint path_size;
CoglPathNode path[1]; 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 void
cogl_clip_push (float x_offset, cogl_clip_push (float x_offset,
float y_offset, float y_offset,
@ -109,6 +219,11 @@ cogl_clip_push (float x_offset,
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _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; stack = (CoglClipStack *) ctx->clip.stacks->data;
entry = g_slice_new (CoglClipStackEntryRect); entry = g_slice_new (CoglClipStackEntryRect);
@ -169,6 +284,7 @@ cogl_clip_pop (void)
{ {
gpointer entry; gpointer entry;
CoglClipStack *stack; CoglClipStack *stack;
CoglClipStackEntryType type;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -177,10 +293,13 @@ cogl_clip_pop (void)
g_return_if_fail (stack->stack_top != NULL); g_return_if_fail (stack->stack_top != NULL);
entry = stack->stack_top->data; entry = stack->stack_top->data;
type = *(CoglClipStackEntryType *) entry;
/* Remove the top entry from the stack */ /* 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); g_slice_free (CoglClipStackEntryRect, entry);
else if (type == COGL_CLIP_STACK_WINDOW_RECT)
g_slice_free (CoglClipStackEntryWindowRect, entry);
else else
g_free (entry); g_free (entry);
@ -198,6 +317,10 @@ _cogl_clip_stack_rebuild (void)
gboolean using_stencil_buffer = FALSE; gboolean using_stencil_buffer = FALSE;
GList *node; GList *node;
CoglClipStack *stack; 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); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -208,6 +331,7 @@ _cogl_clip_stack_rebuild (void)
_cogl_disable_clip_planes (); _cogl_disable_clip_planes ();
_cogl_disable_stencil_buffer (); _cogl_disable_stencil_buffer ();
GE (glDisable (GL_SCISSOR_TEST));
/* If the stack is empty then there's nothing else to do */ /* If the stack is empty then there's nothing else to do */
if (stack->stack_top == NULL) if (stack->stack_top == NULL)
@ -220,8 +344,9 @@ _cogl_clip_stack_rebuild (void)
for (; node; node = node->prev) for (; node; node = node->prev)
{ {
gpointer entry = node->data; 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; CoglClipStackEntryPath *path = (CoglClipStackEntryPath *) entry;
@ -241,7 +366,7 @@ _cogl_clip_stack_rebuild (void)
/* We can't use clip planes any more */ /* We can't use clip planes any more */
has_clip_planes = FALSE; has_clip_planes = FALSE;
} }
else else if (type == COGL_CLIP_STACK_RECT)
{ {
CoglClipStackEntryRect *rect = (CoglClipStackEntryRect *) entry; CoglClipStackEntryRect *rect = (CoglClipStackEntryRect *) entry;
@ -272,6 +397,16 @@ _cogl_clip_stack_rebuild (void)
cogl_pop_matrix (); 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 /* 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) if (using_clip_planes)
_cogl_enable_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; 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) 2007,2008,2009 Intel Corporation.
*
* Copyright (C) 2008 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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 #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #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 Intel Corporation.
*
* Copyright (C) 2009 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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 * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*
* Authors:
* Havoc Pennington <hp@pobox.com> for litl
*/ */
#ifdef HAVE_CONFIG_H #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 Intel Corporation.
*
* Copyright (C) 2009 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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 * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*
* Authors:
* Havoc Pennington <hp@pobox.com> for litl
*/ */
#ifndef __COGL_CURRENT_MATRIX_H #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 #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
@ -15,7 +38,8 @@ static const GDebugKey cogl_debug_keys[] = {
{ "offscreen", COGL_DEBUG_OFFSCREEN }, { "offscreen", COGL_DEBUG_OFFSCREEN },
{ "draw", COGL_DEBUG_DRAW }, { "draw", COGL_DEBUG_DRAW },
{ "pango", COGL_DEBUG_PANGO }, { "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); 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 #define G_IMPLEMENT_INLINES
#ifdef HAVE_CONFIG_H #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,2009 Intel Corporation.
*
* Copyright (C) 2008 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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 /* Helper macro to encapsulate the common code for COGL reference
counted handles */ counted handles */
#if COGL_DEBUG #ifdef COGL_HANDLE_DEBUG
#define _COGL_HANDLE_DEBUG_NEW(type_name, obj) \ #define _COGL_HANDLE_DEBUG_NEW(type_name, obj) \
printf ("COGL " G_STRINGIFY (type_name) " NEW %p %i\n", \ COGL_NOTE (HANDLE, "COGL " G_STRINGIFY (type_name) " NEW %p %i\n", \
(obj), (obj)->ref_count) (obj), (obj)->ref_count)
#define _COGL_HANDLE_DEBUG_REF(type_name, handle) \ #define _COGL_HANDLE_DEBUG_REF(type_name, handle) G_STMT_START { \
do { \ CoglHandleObject *__obj = (CoglHandleObject *)handle; \
CoglHandleObject *obj = (CoglHandleObject *)handle; \ COGL_NOTE (HANDLE, "COGL %s REF %p %i\n", \
printf ("COGL %s REF %p %i\n", \ g_quark_to_string ((__obj)->klass->type), \
g_quark_to_string ((obj)->klass->type), \ (__obj), (__obj)->ref_count); } G_STMT_END
(obj), (obj)->ref_count); \
} while (0)
#define _COGL_HANDLE_DEBUG_UNREF(type_name, handle) \ #define _COGL_HANDLE_DEBUG_UNREF(type_name, handle) G_STMT_START { \
do { \ CoglHandleObject *__obj = (CoglHandleObject *)handle; \
CoglHandleObject *obj = (CoglHandleObject *)handle; \ COGL_NOTE (HANDLE, "COGL %s UNREF %p %i\n", \
printf ("COGL %s UNREF %p %i\n", \ g_quark_to_string ((__obj)->klass->type), \
g_quark_to_string ((obj)->klass->type), \ (__obj), (__obj)->ref_count - 1); } G_STMT_END
(obj), (obj)->ref_count - 1); \
} while (0)
#define COGL_HANDLE_DEBUG_FREE(obj) \ #define COGL_HANDLE_DEBUG_FREE(obj) \
printf ("COGL %s FREE %p\n", \ COGL_NOTE (HANDLE, "COGL %s FREE %p\n", \
g_quark_to_string ((obj)->klass->type), (obj)) \ 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_NEW(type_name, obj)
#define _COGL_HANDLE_DEBUG_REF(type_name, obj) #define _COGL_HANDLE_DEBUG_REF(type_name, obj)
#define _COGL_HANDLE_DEBUG_UNREF(type_name, obj) #define _COGL_HANDLE_DEBUG_UNREF(type_name, obj)
#define COGL_HANDLE_DEBUG_FREE(obj) #define COGL_HANDLE_DEBUG_FREE(obj)
#endif /* COGL_DEBUG */ #endif /* COGL_HANDLE_DEBUG */
#define COGL_HANDLE_DEFINE(TypeName, type_name) \ #define COGL_HANDLE_DEFINE(TypeName, type_name) \
\ \
static CoglHandleClass _cogl_##type_name##_class; \ static CoglHandleClass _cogl_##type_name##_class; \
\ \
static GQuark \ static GQuark \
_cogl_##type_name##_get_type (void) \ _cogl_##type_name##_get_type (void) \
{ \ { \
static GQuark type = 0; \ static GQuark type = 0; \
if (!type) \ if (!type) \
type = g_quark_from_static_string ("Cogl"#TypeName); \ type = g_quark_from_static_string ("Cogl"#TypeName); \
return type; \ return type; \
} \ } \
\ \
static CoglHandle \ static CoglHandle \
_cogl_##type_name##_handle_new (Cogl##TypeName *new_obj) \ _cogl_##type_name##_handle_new (Cogl##TypeName *new_obj) \
{ \ { \
CoglHandleObject *obj = &new_obj->_parent; \ CoglHandleObject *obj = &new_obj->_parent; \
obj->ref_count = 1; \ obj->ref_count = 1; \
\ \
obj->klass = &_cogl_##type_name##_class; \ obj->klass = &_cogl_##type_name##_class; \
if (!obj->klass->type) \ if (!obj->klass->type) \
{ \ { \
obj->klass->type = \ obj->klass->type = _cogl_##type_name##_get_type (); \
_cogl_##type_name##_get_type (); \
obj->klass->virt_free = _cogl_##type_name##_free; \ obj->klass->virt_free = _cogl_##type_name##_free; \
} \ } \
\ \
@ -114,51 +107,50 @@ typedef struct _CoglHandleObject
return (CoglHandle) new_obj; \ return (CoglHandle) new_obj; \
} \ } \
\ \
Cogl##TypeName * \ Cogl##TypeName * \
_cogl_##type_name##_pointer_from_handle (CoglHandle handle) \ _cogl_##type_name##_pointer_from_handle (CoglHandle handle) \
{ \ { \
return (Cogl##TypeName *) handle; \ return (Cogl##TypeName *) handle; \
} \ } \
\ \
gboolean \ gboolean \
cogl_is_##type_name (CoglHandle handle) \ cogl_is_##type_name (CoglHandle handle) \
{ \ { \
CoglHandleObject *obj = (CoglHandleObject *)handle; \ CoglHandleObject *obj = (CoglHandleObject *)handle; \
\ \
if (handle == COGL_INVALID_HANDLE) \ if (handle == COGL_INVALID_HANDLE) \
return FALSE; \ return FALSE; \
\ \
return (obj->klass->type == \ return (obj->klass->type == _cogl_##type_name##_get_type ()); \
_cogl_##type_name##_get_type ()); \ } \
} \
\ \
CoglHandle G_GNUC_DEPRECATED \ CoglHandle G_GNUC_DEPRECATED \
cogl_##type_name##_ref (CoglHandle handle) \ cogl_##type_name##_ref (CoglHandle handle) \
{ \ { \
if (!cogl_is_##type_name (handle)) \ if (!cogl_is_##type_name (handle)) \
return COGL_INVALID_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 \ void G_GNUC_DEPRECATED \
cogl_##type_name##_unref (CoglHandle handle) \ cogl_##type_name##_unref (CoglHandle handle) \
{ \ { \
if (!cogl_is_##type_name (handle)) \ if (!cogl_is_##type_name (handle)) \
{ \ { \
g_warning (G_STRINGIFY (cogl_##type_name##_unref) \ g_warning (G_STRINGIFY (cogl_##type_name##_unref) \
": Ignoring unref of Cogl handle " \ ": Ignoring unref of Cogl handle " \
"due to type missmatch"); \ "due to type mismatch"); \
return; \ 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 */ #endif /* __COGL_HANDLE_H */

View File

@ -1,10 +1,9 @@
/* /*
* Cogl * Cogl
* *
* A basic GL/GLES Abstraction/Utility Layer * An object oriented GL/GLES Abstraction/Utility Layer
* *
* Copyright (C) 2007, 2008 OpenedHand * Copyright (C) 2007,2008,2009 Intel Corporation.
* Copyright (C) 2009 Intel Corp.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -25,6 +24,8 @@
#ifndef __COGL_INTERNAL_H #ifndef __COGL_INTERNAL_H
#define __COGL_INTERNAL_H #define __COGL_INTERNAL_H
#include "cogl-debug.h"
#ifdef HAVE_COGL_GLES2 #ifdef HAVE_COGL_GLES2
typedef enum { typedef enum {
COGL_BOXED_NONE, COGL_BOXED_NONE,
@ -50,29 +51,25 @@ typedef struct _CoglBoxedValue
} CoglBoxedValue; } CoglBoxedValue;
#endif #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); #else /* !COGL_GL_DEBUG */
#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) #define GE(x) (x)
#endif /* COGL_DEBUG */ #endif /* COGL_GL_DEBUG */
#define COGL_ENABLE_BLEND (1<<1) #define COGL_ENABLE_BLEND (1<<1)
#define COGL_ENABLE_ALPHA_TEST (1<<2) #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_COLOR_ARRAY (1<<4)
#define COGL_ENABLE_BACKFACE_CULLING (1<<5) #define COGL_ENABLE_BACKFACE_CULLING (1<<5)
void void _cogl_features_init (void);
_cogl_features_init (void); gint _cogl_get_format_bpp (CoglPixelFormat format);
gint void cogl_enable (gulong flags);
_cogl_get_format_bpp (CoglPixelFormat format); gulong cogl_get_enable (void);
void
cogl_enable (gulong flags);
gulong
cogl_get_enable ();
#endif /* __COGL_INTERNAL_H */ #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 #ifndef __COGL_MATERIAL_PRIVATE_H
#define __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 #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
@ -168,6 +193,18 @@ cogl_material_set_color4ub (CoglHandle handle,
cogl_material_set_color (handle, &color); 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 void
cogl_material_get_ambient (CoglHandle handle, cogl_material_get_ambient (CoglHandle handle,
CoglColor *ambient) CoglColor *ambient)
@ -619,7 +656,8 @@ cogl_material_set_layer_matrix (CoglHandle material_handle,
static void static void
_cogl_material_layer_free (CoglMaterialLayer *layer) _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); 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 Intel Corporation.
*
* Copyright (C) 2009 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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 * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*
* Authors:
* Havoc Pennington <hp@pobox.com> for litl
*/ */
#ifdef HAVE_CONFIG_H #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 Intel Corporation.
*
* Copyright (C) 2009 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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 * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*
* Authors:
* Havoc Pennington <hp@pobox.com> for litl
*/ */
#ifndef __COGL_MATRIX_STACK_H #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 <cogl-matrix.h>
#include <glib.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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
#if COGL_DEBUG COGL_NOTE (DRAW, "Drawing Tex Quad (Sliced Mode)");
printf("=== Drawing Tex Quad (Sliced Mode) ===\n");
#endif
/* We can't use hardware repeat so we need to set clamp to edge /* 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 */ 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; slice_tx2 /= iter_x.span->size;
} }
#if COGL_DEBUG COGL_NOTE (DRAW,
printf("~~~~~ slice (%d,%d)\n", iter_x.index, iter_y.index); "~~~~~ slice (%d, %d)\n"
printf("qx1: %f\n", (slice_qx1)); "qx1: %f\t"
printf("qy1: %f\n", (slice_qy1)); "qy1: %f\n"
printf("qx2: %f\n", (slice_qx2)); "qx2: %f\t"
printf("qy2: %f\n", (slice_qy2)); "qy2: %f\n"
printf("tx1: %f\n", (slice_tx1)); "tx1: %f\t"
printf("ty1: %f\n", (slice_ty1)); "ty1: %f\n"
printf("tx2: %f\n", (slice_tx2)); "tx2: %f\t"
printf("ty2: %f\n", (slice_ty2)); "ty2: %f\n",
#endif 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 */ /* Pick and bind opengl texture object */
gl_handle = g_array_index (tex->slice_gl_handles, GLuint, gl_handle = g_array_index (tex->slice_gl_handles, GLuint,
@ -1322,9 +1322,9 @@ cogl_path_fill_preserve (void)
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_clip_ensure (); cogl_clip_ensure ();
if (ctx->path_nodes->len == 0) if (ctx->path_nodes->len == 0)
return; return;
_cogl_path_fill_nodes (); _cogl_path_fill_nodes ();
} }
@ -1341,12 +1341,12 @@ void
cogl_path_stroke_preserve (void) cogl_path_stroke_preserve (void)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_clip_ensure (); cogl_clip_ensure ();
if (ctx->path_nodes->len == 0) if (ctx->path_nodes->len == 0)
return; return;
_cogl_path_stroke_nodes(); _cogl_path_stroke_nodes();
} }
@ -1355,14 +1355,14 @@ cogl_path_move_to (float x,
float y) float y)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
/* FIXME: handle multiple contours maybe? */ /* FIXME: handle multiple contours maybe? */
_cogl_path_add_node (TRUE, x, y); _cogl_path_add_node (TRUE, x, y);
ctx->path_start.x = x; ctx->path_start.x = x;
ctx->path_start.y = y; ctx->path_start.y = y;
ctx->path_pen = ctx->path_start; ctx->path_pen = ctx->path_start;
} }
@ -1371,7 +1371,7 @@ cogl_path_rel_move_to (float x,
float y) float y)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_path_move_to (ctx->path_pen.x + x, cogl_path_move_to (ctx->path_pen.x + x,
ctx->path_pen.y + y); ctx->path_pen.y + y);
} }
@ -1381,9 +1381,9 @@ cogl_path_line_to (float x,
float y) float y)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
_cogl_path_add_node (FALSE, x, y); _cogl_path_add_node (FALSE, x, y);
ctx->path_pen.x = x; ctx->path_pen.x = x;
ctx->path_pen.y = y; ctx->path_pen.y = y;
} }
@ -1393,7 +1393,7 @@ cogl_path_rel_line_to (float x,
float y) float y)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_path_line_to (ctx->path_pen.x + x, cogl_path_line_to (ctx->path_pen.x + x,
ctx->path_pen.y + y); ctx->path_pen.y + y);
} }
@ -1402,7 +1402,7 @@ void
cogl_path_close (void) cogl_path_close (void)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
_cogl_path_add_node (FALSE, ctx->path_start.x, ctx->path_start.y); _cogl_path_add_node (FALSE, ctx->path_start.x, ctx->path_start.y);
ctx->path_pen = ctx->path_start; ctx->path_pen = ctx->path_start;
} }
@ -1430,9 +1430,9 @@ cogl_path_polyline (float *coords,
gint num_points) gint num_points)
{ {
gint c = 0; gint c = 0;
cogl_path_move_to (coords[0], coords[1]); cogl_path_move_to (coords[0], coords[1]);
for (c = 1; c < num_points; ++c) for (c = 1; c < num_points; ++c)
cogl_path_line_to (coords[2*c], coords[2*c+1]); cogl_path_line_to (coords[2*c], coords[2*c+1]);
} }
@ -1473,17 +1473,17 @@ _cogl_path_arc (float center_x,
float sina = 0x0; float sina = 0x0;
float px = 0x0; float px = 0x0;
float py = 0x0; float py = 0x0;
/* Fix invalid angles */ /* Fix invalid angles */
if (angle_1 == angle_2 || angle_step == 0x0) if (angle_1 == angle_2 || angle_step == 0x0)
return; return;
if (angle_step < 0x0) if (angle_step < 0x0)
angle_step = -angle_step; angle_step = -angle_step;
/* Walk the arc by given step */ /* Walk the arc by given step */
a = angle_1; a = angle_1;
while (a != angle_2) while (a != angle_2)
{ {
@ -1492,12 +1492,12 @@ _cogl_path_arc (float center_x,
px = center_x + (cosa * radius_x); px = center_x + (cosa * radius_x);
py = center_y + (sina * radius_y); py = center_y + (sina * radius_y);
if (a == angle_1 && move_first) if (a == angle_1 && move_first)
cogl_path_move_to (px, py); cogl_path_move_to (px, py);
else else
cogl_path_line_to (px, py); cogl_path_line_to (px, py);
if (G_LIKELY (angle_2 > angle_1)) if (G_LIKELY (angle_2 > angle_1))
{ {
a += angle_step; a += angle_step;
@ -1513,7 +1513,7 @@ _cogl_path_arc (float center_x,
} }
/* Make sure the final point is drawn */ /* Make sure the final point is drawn */
cosa = cosf (angle_2 * (G_PI/180.0)); cosa = cosf (angle_2 * (G_PI/180.0));
sina = sinf (angle_2 * (G_PI/180.0)); sina = sinf (angle_2 * (G_PI/180.0));
@ -1530,7 +1530,7 @@ cogl_path_arc (float center_x,
float radius_y, float radius_y,
float angle_1, float angle_1,
float angle_2) float angle_2)
{ {
float angle_step = 10; float angle_step = 10;
/* it is documented that a move to is needed to create a freestanding /* it is documented that a move to is needed to create a freestanding
* arc * arc
@ -1552,7 +1552,7 @@ cogl_path_arc_rel (float center_x,
float angle_step) float angle_step)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
_cogl_path_arc (ctx->path_pen.x + center_x, _cogl_path_arc (ctx->path_pen.x + center_x,
ctx->path_pen.y + center_y, ctx->path_pen.y + center_y,
radius_x, radius_y, radius_x, radius_y,
@ -1567,15 +1567,15 @@ cogl_path_ellipse (float center_x,
float radius_y) float radius_y)
{ {
float angle_step = 10; float angle_step = 10;
/* FIXME: if shows to be slow might be optimized /* FIXME: if shows to be slow might be optimized
* by mirroring just a quarter of it */ * by mirroring just a quarter of it */
_cogl_path_arc (center_x, center_y, _cogl_path_arc (center_x, center_y,
radius_x, radius_y, radius_x, radius_y,
0, 360, 0, 360,
angle_step, 1 /* move first */); angle_step, 1 /* move first */);
cogl_path_close(); cogl_path_close();
} }
@ -1589,7 +1589,7 @@ cogl_path_round_rectangle (float x_1,
{ {
float inner_width = x_2 - x_1 - radius * 2; float inner_width = x_2 - x_1 - radius * 2;
float inner_height = y_2 - y_1 - radius * 2; float inner_height = y_2 - y_1 - radius * 2;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_path_move_to (x_1, y_1 + radius); cogl_path_move_to (x_1, y_1 + radius);
@ -1598,7 +1598,7 @@ cogl_path_round_rectangle (float x_1,
180, 180,
270, 270,
arc_step); arc_step);
cogl_path_line_to (ctx->path_pen.x + inner_width, cogl_path_line_to (ctx->path_pen.x + inner_width,
ctx->path_pen.y); ctx->path_pen.y);
cogl_path_arc_rel (0, radius, cogl_path_arc_rel (0, radius,
@ -1606,7 +1606,7 @@ cogl_path_round_rectangle (float x_1,
-90, -90,
0, 0,
arc_step); arc_step);
cogl_path_line_to (ctx->path_pen.x, cogl_path_line_to (ctx->path_pen.x,
ctx->path_pen.y + inner_height); ctx->path_pen.y + inner_height);
@ -1615,7 +1615,7 @@ cogl_path_round_rectangle (float x_1,
0, 0,
90, 90,
arc_step); arc_step);
cogl_path_line_to (ctx->path_pen.x - inner_width, cogl_path_line_to (ctx->path_pen.x - inner_width,
ctx->path_pen.y); ctx->path_pen.y);
cogl_path_arc_rel (0, -radius, cogl_path_arc_rel (0, -radius,
@ -1623,7 +1623,7 @@ cogl_path_round_rectangle (float x_1,
90, 90,
180, 180,
arc_step); arc_step);
cogl_path_close (); cogl_path_close ();
} }
@ -1644,16 +1644,16 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic)
floatVec2 c4; floatVec2 c4;
floatVec2 c5; floatVec2 c5;
gint cindex; gint cindex;
/* Put first curve on stack */ /* Put first curve on stack */
cubics[0] = *cubic; cubics[0] = *cubic;
cindex = 0; cindex = 0;
while (cindex >= 0) while (cindex >= 0)
{ {
c = &cubics[cindex]; c = &cubics[cindex];
/* Calculate distance of control points from their /* Calculate distance of control points from their
* counterparts on the line between end points */ * counterparts on the line between end points */
dif1.x = (c->p2.x * 3) - (c->p1.x * 2) - c->p4.x; dif1.x = (c->p2.x * 3) - (c->p1.x * 2) - c->p4.x;
@ -1669,12 +1669,12 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic)
dif2.x = -dif2.x; dif2.x = -dif2.x;
if (dif2.y < 0) if (dif2.y < 0)
dif2.y = -dif2.y; dif2.y = -dif2.y;
/* Pick the greatest of two distances */ /* Pick the greatest of two distances */
if (dif1.x < dif2.x) dif1.x = dif2.x; if (dif1.x < dif2.x) dif1.x = dif2.x;
if (dif1.y < dif2.y) dif1.y = dif2.y; if (dif1.y < dif2.y) dif1.y = dif2.y;
/* Cancel if the curve is flat enough */ /* Cancel if the curve is flat enough */
if (dif1.x + dif1.y <= 1.0 || if (dif1.x + dif1.y <= 1.0 ||
cindex == _COGL_MAX_BEZ_RECURSE_DEPTH-1) cindex == _COGL_MAX_BEZ_RECURSE_DEPTH-1)
@ -1689,10 +1689,10 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic)
continue; continue;
} }
/* Left recursion goes on top of stack! */ /* Left recursion goes on top of stack! */
cright = c; cleft = &cubics[++cindex]; cright = c; cleft = &cubics[++cindex];
/* Subdivide into 2 sub-curves */ /* Subdivide into 2 sub-curves */
c1.x = ((c->p1.x + c->p2.x) / 2); c1.x = ((c->p1.x + c->p2.x) / 2);
c1.y = ((c->p1.y + c->p2.y) / 2); c1.y = ((c->p1.y + c->p2.y) / 2);
@ -1700,21 +1700,21 @@ _cogl_path_bezier3_sub (CoglBezCubic *cubic)
mm.y = ((c->p2.y + c->p3.y) / 2); mm.y = ((c->p2.y + c->p3.y) / 2);
c5.x = ((c->p3.x + c->p4.x) / 2); c5.x = ((c->p3.x + c->p4.x) / 2);
c5.y = ((c->p3.y + c->p4.y) / 2); c5.y = ((c->p3.y + c->p4.y) / 2);
c2.x = ((c1.x + mm.x) / 2); c2.x = ((c1.x + mm.x) / 2);
c2.y = ((c1.y + mm.y) / 2); c2.y = ((c1.y + mm.y) / 2);
c4.x = ((mm.x + c5.x) / 2); c4.x = ((mm.x + c5.x) / 2);
c4.y = ((mm.y + c5.y) / 2); c4.y = ((mm.y + c5.y) / 2);
c3.x = ((c2.x + c4.x) / 2); c3.x = ((c2.x + c4.x) / 2);
c3.y = ((c2.y + c4.y) / 2); c3.y = ((c2.y + c4.y) / 2);
/* Add left recursion to stack */ /* Add left recursion to stack */
cleft->p1 = c->p1; cleft->p1 = c->p1;
cleft->p2 = c1; cleft->p2 = c1;
cleft->p3 = c2; cleft->p3 = c2;
cleft->p4 = c3; cleft->p4 = c3;
/* Add right recursion to stack */ /* Add right recursion to stack */
cright->p1 = c3; cright->p1 = c3;
cright->p2 = c4; cright->p2 = c4;
@ -1761,7 +1761,7 @@ cogl_path_rel_curve_to (float x_1,
float y_3) float y_3)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_path_curve_to (ctx->path_pen.x + x_1, cogl_path_curve_to (ctx->path_pen.x + x_1,
ctx->path_pen.y + y_1, ctx->path_pen.y + y_1,
ctx->path_pen.x + x_2, ctx->path_pen.x + x_2,
@ -1789,17 +1789,17 @@ _cogl_path_bezier2_sub (CoglBezQuad *quad)
floatVec2 c2; floatVec2 c2;
floatVec2 c3; floatVec2 c3;
gint qindex; gint qindex;
/* Put first curve on stack */ /* Put first curve on stack */
quads[0] = *quad; quads[0] = *quad;
qindex = 0; qindex = 0;
/* While stack is not empty */ /* While stack is not empty */
while (qindex >= 0) while (qindex >= 0)
{ {
q = &quads[qindex]; q = &quads[qindex];
/* Calculate distance of control point from its /* Calculate distance of control point from its
* counterpart on the line between end points */ * counterpart on the line between end points */
mid.x = ((q->p1.x + q->p3.x) / 2); mid.x = ((q->p1.x + q->p3.x) / 2);
@ -1808,7 +1808,7 @@ _cogl_path_bezier2_sub (CoglBezQuad *quad)
dif.y = (q->p2.y - mid.y); dif.y = (q->p2.y - mid.y);
if (dif.x < 0) dif.x = -dif.x; if (dif.x < 0) dif.x = -dif.x;
if (dif.y < 0) dif.y = -dif.y; if (dif.y < 0) dif.y = -dif.y;
/* Cancel if the curve is flat enough */ /* Cancel if the curve is flat enough */
if (dif.x + dif.y <= 1.0 || if (dif.x + dif.y <= 1.0 ||
qindex == _COGL_MAX_BEZ_RECURSE_DEPTH - 1) qindex == _COGL_MAX_BEZ_RECURSE_DEPTH - 1)
@ -1818,10 +1818,10 @@ _cogl_path_bezier2_sub (CoglBezQuad *quad)
_cogl_path_add_node (FALSE, q->p3.x, q->p3.y); _cogl_path_add_node (FALSE, q->p3.x, q->p3.y);
--qindex; continue; --qindex; continue;
} }
/* Left recursion goes on top of stack! */ /* Left recursion goes on top of stack! */
qright = q; qleft = &quads[++qindex]; qright = q; qleft = &quads[++qindex];
/* Subdivide into 2 sub-curves */ /* Subdivide into 2 sub-curves */
c1.x = ((q->p1.x + q->p2.x) / 2); c1.x = ((q->p1.x + q->p2.x) / 2);
c1.y = ((q->p1.y + q->p2.y) / 2); c1.y = ((q->p1.y + q->p2.y) / 2);
@ -1829,12 +1829,12 @@ _cogl_path_bezier2_sub (CoglBezQuad *quad)
c3.y = ((q->p2.y + q->p3.y) / 2); c3.y = ((q->p2.y + q->p3.y) / 2);
c2.x = ((c1.x + c3.x) / 2); c2.x = ((c1.x + c3.x) / 2);
c2.y = ((c1.y + c3.y) / 2); c2.y = ((c1.y + c3.y) / 2);
/* Add left recursion onto stack */ /* Add left recursion onto stack */
qleft->p1 = q->p1; qleft->p1 = q->p1;
qleft->p2 = c1; qleft->p2 = c1;
qleft->p3 = c2; qleft->p3 = c2;
/* Add right recursion onto stack */ /* Add right recursion onto stack */
qright->p1 = c2; qright->p1 = c2;
qright->p2 = c3; qright->p2 = c3;
@ -1861,7 +1861,7 @@ cogl_path_curve2_to (float x_1,
/* Run subdivision */ /* Run subdivision */
_cogl_path_bezier2_sub (&quad); _cogl_path_bezier2_sub (&quad);
/* Add last point */ /* Add last point */
_cogl_path_add_node (FALSE, quad.p3.x, quad.p3.y); _cogl_path_add_node (FALSE, quad.p3.x, quad.p3.y);
ctx->path_pen = quad.p3; ctx->path_pen = quad.p3;

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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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> * Copyright (C) 2007,2008,2009 Intel Corporation.
* Emmanuele Bassi <ebassi@linux.intel.com>
*
* Copyright (C) 2007, 2008 OpenedHand
* Copyright (C) 2009 Intel Corp.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * 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, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -20,7 +16,9 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * 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 #ifdef HAVE_CONFIG_H
@ -181,7 +179,6 @@ cogl_buffer_target_get_type (void)
{ {
static const GFlagsValue values[] = { static const GFlagsValue values[] = {
{ COGL_WINDOW_BUFFER, "COGL_WINDOW_BUFFER", "window-buffer" }, { COGL_WINDOW_BUFFER, "COGL_WINDOW_BUFFER", "window-buffer" },
{ COGL_MASK_BUFFER, "COGL_MASK_BUFFER", "mask-buffer" },
{ COGL_OFFSCREEN_BUFFER, "COGL_OFFSCREEN_BUFFER", "offscreen-buffer" }, { COGL_OFFSCREEN_BUFFER, "COGL_OFFSCREEN_BUFFER", "offscreen-buffer" },
{ 0, NULL, NULL } { 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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -26,7 +24,7 @@
#ifndef __COGL_UTIL_H #ifndef __COGL_UTIL_H
#define __COGL_UTIL_H #define __COGL_UTIL_H
int int
cogl_util_next_p2 (int a); cogl_util_next_p2 (int a);
#endif /* __COGL_UTIL_H */ #endif /* __COGL_UTIL_H */

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. * Copyright (C) 2008,2009 Intel Corporation.
*
* Authored By: Robert Bragg <robert@linux.intel.com>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -18,7 +16,12 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * 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 #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.
*
* Copyright (C) 2008, 2009 Intel Corporation.
*
* Authored by: Robert Bragg <robert@linux.intel.com>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,7 +16,12 @@
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * 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 /* XXX: For an overview of the functionality implemented here, please
@ -126,7 +127,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <glib/gprintf.h> #include <glib.h>
#include "cogl.h" #include "cogl.h"
#include "cogl-internal.h" #include "cogl-internal.h"
@ -1775,4 +1776,3 @@ _cogl_vertex_buffer_free (CoglVertexBuffer *buffer)
g_slice_free (CoglVertexBuffer, buffer); g_slice_free (CoglVertexBuffer, buffer);
} }

View File

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

View File

@ -1,65 +1,65 @@
libclutterincludedir = $(includedir)/clutter-@CLUTTER_API_VERSION@/cogl NULL =
libclutterinclude_HEADERS = \
$(top_builddir)/clutter/cogl/cogl.h \ cogl_headers = \
$(top_builddir)/clutter/cogl/cogl-defines-gl.h \ $(top_builddir)/clutter/cogl/cogl-defines-gl.h \
$(top_builddir)/clutter/cogl/cogl-color.h \ $(top_srcdir)/clutter/cogl/cogl-color.h \
$(top_builddir)/clutter/cogl/cogl-deprecated.h \ $(top_srcdir)/clutter/cogl/cogl-deprecated.h \
$(top_builddir)/clutter/cogl/cogl-fixed.h \ $(top_srcdir)/clutter/cogl/cogl-fixed.h \
$(top_builddir)/clutter/cogl/cogl-offscreen.h \ $(top_srcdir)/clutter/cogl/cogl-offscreen.h \
$(top_builddir)/clutter/cogl/cogl-path.h \ $(top_srcdir)/clutter/cogl/cogl-path.h \
$(top_builddir)/clutter/cogl/cogl-shader.h \ $(top_srcdir)/clutter/cogl/cogl-shader.h \
$(top_builddir)/clutter/cogl/cogl-texture.h \ $(top_srcdir)/clutter/cogl/cogl-bitmap.h \
$(top_builddir)/clutter/cogl/cogl-types.h \ $(top_srcdir)/clutter/cogl/cogl-texture.h \
$(top_builddir)/clutter/cogl/cogl-vertex-buffer.h \ $(top_srcdir)/clutter/cogl/cogl-types.h \
$(top_builddir)/clutter/cogl/cogl-material.h \ $(top_srcdir)/clutter/cogl/cogl-vertex-buffer.h \
$(top_builddir)/clutter/cogl/cogl-matrix.h \ $(top_srcdir)/clutter/cogl/cogl-material.h \
$(top_builddir)/clutter/cogl/cogl-debug.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 = \ INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/clutter \
-I$(top_srcdir)/clutter/cogl \ -I$(top_srcdir)/clutter/cogl \
-I$(top_srcdir)/clutter/cogl/common \ -I$(top_srcdir)/clutter/cogl/common \
-I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \ -I$(top_srcdir)/clutter/cogl/$(CLUTTER_COGL) \
-I$(top_srcdir)/clutter \
-I$(top_builddir)/clutter \ -I$(top_builddir)/clutter \
-I$(top_builddir)/clutter/cogl \ -I$(top_builddir)/clutter/cogl \
-DG_LOG_DOMAIN=\"Cogl-GL\" \ -DG_LOG_DOMAIN=\"Cogl-GL\" \
-DCLUTTER_COMPILATION \ -DCLUTTER_COMPILATION
$(CLUTTER_CFLAGS) \
$(CLUTTER_DEBUG_CFLAGS) \
$(MAINTAINER_CFLAGS) \
$(GCC_FLAGS)
LDADD = $(CLUTTER_LIBS)
noinst_LTLIBRARIES = libclutter-cogl.la 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 = \ libclutter_cogl_la_SOURCES = \
$(top_builddir)/clutter/cogl/cogl.h \ $(top_builddir)/clutter/cogl/cogl.h \
$(top_builddir)/clutter/cogl/cogl-defines-gl.h \ $(cogl_headers) \
$(top_builddir)/clutter/cogl/cogl-color.h \ $(cogl_priv_headers) \
$(top_builddir)/clutter/cogl/cogl-deprecated.h \ $(cogl_sources) \
$(top_builddir)/clutter/cogl/cogl-fixed.h \ $(NULL)
$(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
EXTRA_DIST = cogl-defines.h.in 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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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 }; GLubyte default_texture_data[] = { 0xff, 0xff, 0xff, 0x0 };
gulong enable_flags = 0; gulong enable_flags = 0;
CoglDrawBufferState *draw_buffer;
if (_context != NULL) if (_context != NULL)
return FALSE; return FALSE;
@ -80,7 +79,11 @@ cogl_create_context ()
sizeof (CoglLayerInfo)); sizeof (CoglLayerInfo));
_context->n_texcoord_arrays_enabled = 0; _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->path_nodes = g_array_new (FALSE, FALSE, sizeof (CoglPathNode));
_context->last_path = 0; _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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -38,6 +36,12 @@ typedef struct
GLubyte c[4]; GLubyte c[4];
} CoglTextureGLVertex; } CoglTextureGLVertex;
typedef struct
{
CoglBufferTarget target;
CoglHandle offscreen;
} CoglDrawBufferState;
typedef struct typedef struct
{ {
/* Features cache */ /* Features cache */
@ -84,7 +88,7 @@ typedef struct
guint n_texcoord_arrays_enabled; guint n_texcoord_arrays_enabled;
/* Framebuffer objects */ /* Framebuffer objects */
CoglBufferTarget draw_buffer; GSList *draw_buffer_stack;
/* Clip stack */ /* Clip stack */
CoglClipStackState clip; 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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -26,14 +24,11 @@
#ifndef __COGL_DEFINES_H__ #ifndef __COGL_DEFINES_H__
#define __COGL_DEFINES_H__ #define __COGL_DEFINES_H__
#include <glib.h>
#include <@CLUTTER_GL_HEADER@> #include <@CLUTTER_GL_HEADER@>
G_BEGIN_DECLS G_BEGIN_DECLS
typedef GLenum COGLenum;
typedef GLint COGLint;
typedef GLuint COGLuint;
/* FIXME + DOCUMENT */ /* FIXME + DOCUMENT */
#define COPENSTEP OPENSTEP #define COPENSTEP OPENSTEP
@ -227,7 +222,6 @@ typedef GLuint COGLuint;
#define CGL_FOG_INDEX GL_FOG_INDEX #define CGL_FOG_INDEX GL_FOG_INDEX
#define CGL_FOG_START GL_FOG_START #define CGL_FOG_START GL_FOG_START
#define CGL_FOG_END GL_FOG_END #define CGL_FOG_END GL_FOG_END
#define CGL_LINEAR GL_LINEAR
#define CGL_EXP GL_EXP #define CGL_EXP GL_EXP
#define CGL_LOGIC_OP GL_LOGIC_OP #define CGL_LOGIC_OP GL_LOGIC_OP
#define CGL_INDEX_LOGIC_OP GL_INDEX_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_ALPHA_SIZE GL_TEXTURE_ALPHA_SIZE
#define CGL_TEXTURE_LUMINANCE_SIZE GL_TEXTURE_LUMINANCE_SIZE #define CGL_TEXTURE_LUMINANCE_SIZE GL_TEXTURE_LUMINANCE_SIZE
#define CGL_TEXTURE_INTENSITY_SIZE GL_TEXTURE_INTENSITY_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_LINEAR GL_OBJECT_LINEAR
#define CGL_OBJECT_PLANE GL_OBJECT_PLANE #define CGL_OBJECT_PLANE GL_OBJECT_PLANE
#define CGL_EYE_LINEAR GL_EYE_LINEAR #define CGL_EYE_LINEAR GL_EYE_LINEAR
@ -431,7 +421,6 @@ typedef GLuint COGLuint;
#define CGL_SPHERE_MAP GL_SPHERE_MAP #define CGL_SPHERE_MAP GL_SPHERE_MAP
#define CGL_DECAL GL_DECAL #define CGL_DECAL GL_DECAL
#define CGL_MODULATE GL_MODULATE #define CGL_MODULATE GL_MODULATE
#define CGL_NEAREST GL_NEAREST
#define CGL_REPEAT GL_REPEAT #define CGL_REPEAT GL_REPEAT
#define CGL_CLAMP GL_CLAMP #define CGL_CLAMP GL_CLAMP
#define CGL_S GL_S #define CGL_S GL_S
@ -693,9 +682,6 @@ typedef GLuint COGLuint;
#define CGL_UNSIGNED_SHORT_8_8_MESA 0 #define CGL_UNSIGNED_SHORT_8_8_MESA 0
#endif #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 CGL_OBJECT_COMPILE_STATUS GL_OBJECT_COMPILE_STATUS_ARB
#define CLUTTER_COGL_HAS_GL 1 #define CLUTTER_COGL_HAS_GL 1
@ -865,26 +851,26 @@ typedef void
typedef void typedef void
(APIENTRYP COGL_PFNGLBINDBUFFERARBPROC) (APIENTRYP COGL_PFNGLBINDBUFFERARBPROC)
(GLenum target, (GLenum target,
GLuint buffer); GLuint buffer);
typedef void typedef void
(APIENTRYP COGL_PFNGLBUFFERDATAARBPROC) (APIENTRYP COGL_PFNGLBUFFERDATAARBPROC)
(GLenum target, (GLenum target,
GLsizeiptr size, GLsizeiptr size,
const GLvoid *data, const GLvoid *data,
GLenum usage); GLenum usage);
typedef void typedef void
(APIENTRYP COGL_PFNGLBUFFERSUBDATAARBPROC) (APIENTRYP COGL_PFNGLBUFFERSUBDATAARBPROC)
(GLenum target, (GLenum target,
GLintptr offset, GLintptr offset,
GLsizeiptr size, GLsizeiptr size,
const GLvoid *data); const GLvoid *data);
typedef void * typedef void *
(APIENTRYP COGL_PFNGLMAPBUFFERARBPROC) (APIENTRYP COGL_PFNGLMAPBUFFERARBPROC)
(GLenum target, (GLenum target,
GLenum access); GLenum access);
typedef GLboolean typedef GLboolean

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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -71,25 +69,25 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
GLuint fbo_gl_handle; GLuint fbo_gl_handle;
GLuint gl_stencil_handle; GLuint gl_stencil_handle;
GLenum status; GLenum status;
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN)) if (!cogl_features_available (COGL_FEATURE_OFFSCREEN))
return COGL_INVALID_HANDLE; return COGL_INVALID_HANDLE;
/* Make texhandle is a valid texture object */ /* Make texhandle is a valid texture object */
if (!cogl_is_texture (texhandle)) if (!cogl_is_texture (texhandle))
return COGL_INVALID_HANDLE; return COGL_INVALID_HANDLE;
tex = _cogl_texture_pointer_from_handle (texhandle); tex = _cogl_texture_pointer_from_handle (texhandle);
/* The texture must not be sliced */ /* The texture must not be sliced */
if (tex->slice_gl_handles == NULL) if (tex->slice_gl_handles == NULL)
return COGL_INVALID_HANDLE; return COGL_INVALID_HANDLE;
if (tex->slice_gl_handles->len != 1) if (tex->slice_gl_handles->len != 1)
return COGL_INVALID_HANDLE; return COGL_INVALID_HANDLE;
/* Pick the single texture slice width, height and GL id */ /* Pick the single texture slice width, height and GL id */
x_span = &g_array_index (tex->slice_x_spans, CoglTexSliceSpan, 0); x_span = &g_array_index (tex->slice_x_spans, CoglTexSliceSpan, 0);
y_span = &g_array_index (tex->slice_y_spans, CoglTexSliceSpan, 0); y_span = &g_array_index (tex->slice_y_spans, CoglTexSliceSpan, 0);
@ -111,10 +109,10 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
GE( glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GE( glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT,
GL_STENCIL_ATTACHMENT_EXT, GL_STENCIL_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, gl_stencil_handle) ); GL_RENDERBUFFER_EXT, gl_stencil_handle) );
/* Make sure it's complete */ /* Make sure it's complete */
status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT); status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
{ {
/* Stencil renderbuffers aren't always supported. Try again /* Stencil renderbuffers aren't always supported. Try again
@ -125,9 +123,9 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
0) ); 0) );
GE( glDeleteRenderbuffersEXT (1, &gl_stencil_handle) ); GE( glDeleteRenderbuffersEXT (1, &gl_stencil_handle) );
gl_stencil_handle = 0; gl_stencil_handle = 0;
status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT); status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
{ {
/* Still failing, so give up */ /* Still failing, so give up */
@ -136,9 +134,9 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
return COGL_INVALID_HANDLE; return COGL_INVALID_HANDLE;
} }
} }
GE( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0) ); GE( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0) );
/* Allocate and init a CoglFbo object (store non-wasted size /* Allocate and init a CoglFbo object (store non-wasted size
for subsequent blits and viewport setup) */ for subsequent blits and viewport setup) */
fbo = (CoglFbo*) g_malloc (sizeof (CoglFbo)); fbo = (CoglFbo*) g_malloc (sizeof (CoglFbo));
@ -150,15 +148,6 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
return _cogl_offscreen_handle_new (fbo); 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 static void
_cogl_offscreen_free (CoglFbo *fbo) _cogl_offscreen_free (CoglFbo *fbo)
{ {
@ -173,90 +162,26 @@ _cogl_offscreen_free (CoglFbo *fbo)
} }
void void
cogl_offscreen_blit_region (CoglHandle src_buffer, cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
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)
{ {
CoglFbo *fbo = NULL; CoglFbo *fbo = NULL;
CoglDrawBufferState *draw_buffer;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _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) if (target == COGL_OFFSCREEN_BUFFER)
{ {
/* Make sure it is a valid fbo handle */ /* Make sure it is a valid fbo handle */
if (!cogl_is_offscreen (offscreen)) if (!cogl_is_offscreen (offscreen))
return; return;
fbo = _cogl_offscreen_pointer_from_handle (offscreen); fbo = _cogl_offscreen_pointer_from_handle (offscreen);
/* Check current draw buffer target */ /* 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 /* Push the viewport and matrix setup if redirecting
from a non-screen buffer */ from a non-screen buffer */
@ -280,16 +205,16 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW); _cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_current_matrix_identity (); _cogl_current_matrix_identity ();
} }
/* Setup new viewport and matrices */ /* Setup new viewport and matrices */
GE( glViewport (0, 0, fbo->width, fbo->height) ); GE( glViewport (0, 0, fbo->width, fbo->height) );
_cogl_current_matrix_translate (-1.0f, -1.0f, 0.0f); _cogl_current_matrix_translate (-1.0f, -1.0f, 0.0f);
_cogl_current_matrix_scale (2.0f / fbo->width, 2.0f / fbo->height, 1.0f); _cogl_current_matrix_scale (2.0f / fbo->width, 2.0f / fbo->height, 1.0f);
/* Bind offscreen framebuffer object */ /* Bind offscreen framebuffer object */
GE( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, fbo->gl_handle) ); GE( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, fbo->gl_handle) );
GE( glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) ); GE( glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) );
/* Some implementation require a clear before drawing /* Some implementation require a clear before drawing
to an fbo. Luckily it is affected by scissor test. */ to an fbo. Luckily it is affected by scissor test. */
/* FIXME: test where exactly this is needed end whether /* FIXME: test where exactly this is needed end whether
@ -299,13 +224,11 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
GE( glEnable (GL_SCISSOR_TEST) ); GE( glEnable (GL_SCISSOR_TEST) );
GE( glClear (GL_COLOR_BUFFER_BIT) ); GE( glClear (GL_COLOR_BUFFER_BIT) );
GE( glPopAttrib () ); GE( glPopAttrib () );
} }
else if ((target & COGL_WINDOW_BUFFER) || else if (target & COGL_WINDOW_BUFFER)
(target & COGL_MASK_BUFFER))
{ {
/* Check current draw buffer target */ /* 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 /* Pop viewport and matrices if redirecting back
from an offscreen buffer */ from an offscreen buffer */
@ -317,22 +240,77 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
_cogl_set_current_matrix (COGL_MATRIX_MODELVIEW); _cogl_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_current_matrix_pop (); _cogl_current_matrix_pop ();
} }
/* Bind window framebuffer object */ /* Bind window framebuffer object */
GE( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0) ); 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 */ /* 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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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,2009 Intel Corporation.
*
* Copyright (C) 2008 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -96,7 +94,7 @@ cogl_program_attach_shader (CoglHandle program_handle,
CoglShader *shader; CoglShader *shader;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (!cogl_is_program (program_handle) || !cogl_is_shader (shader_handle)) if (!cogl_is_program (program_handle) || !cogl_is_shader (shader_handle))
return; return;
@ -111,7 +109,7 @@ cogl_program_link (CoglHandle handle)
{ {
CoglProgram *program; CoglProgram *program;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (!cogl_is_program (handle)) if (!cogl_is_program (handle))
return; return;
@ -126,7 +124,7 @@ cogl_program_use (CoglHandle handle)
CoglProgram *program; CoglProgram *program;
GLhandleARB gl_handle; GLhandleARB gl_handle;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (handle != COGL_INVALID_HANDLE && !cogl_is_program (handle)) if (handle != COGL_INVALID_HANDLE && !cogl_is_program (handle))
return; return;
@ -141,13 +139,13 @@ cogl_program_use (CoglHandle handle)
glUseProgramObjectARB (gl_handle); glUseProgramObjectARB (gl_handle);
} }
COGLint int
cogl_program_get_uniform_location (CoglHandle handle, cogl_program_get_uniform_location (CoglHandle handle,
const gchar *uniform_name) const gchar *uniform_name)
{ {
CoglProgram *program; CoglProgram *program;
_COGL_GET_CONTEXT (ctx, 0); _COGL_GET_CONTEXT (ctx, 0);
if (!cogl_is_program (handle)) if (!cogl_is_program (handle))
return 0; return 0;
@ -157,7 +155,7 @@ cogl_program_get_uniform_location (CoglHandle handle,
} }
void void
cogl_program_uniform_1f (COGLint uniform_no, cogl_program_uniform_1f (int uniform_no,
gfloat value) gfloat value)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -165,7 +163,7 @@ cogl_program_uniform_1f (COGLint uniform_no,
} }
void void
cogl_program_uniform_1i (COGLint uniform_no, cogl_program_uniform_1i (int uniform_no,
gint value) gint value)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -173,7 +171,7 @@ cogl_program_uniform_1i (COGLint uniform_no,
} }
void void
cogl_program_uniform_float (COGLint uniform_no, cogl_program_uniform_float (int uniform_no,
gint size, gint size,
gint count, gint count,
const GLfloat *value) const GLfloat *value)
@ -200,10 +198,10 @@ cogl_program_uniform_float (COGLint uniform_no,
} }
void void
cogl_program_uniform_int (COGLint uniform_no, cogl_program_uniform_int (int uniform_no,
gint size, gint size,
gint count, gint count,
const COGLint *value) const int *value)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -227,7 +225,7 @@ cogl_program_uniform_int (COGLint uniform_no,
} }
void void
cogl_program_uniform_matrix (COGLint uniform_no, cogl_program_uniform_matrix (int uniform_no,
gint size, gint size,
gint count, gint count,
gboolean transpose, 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,2009 Intel Corporation.
*
* Copyright (C) 2008 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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,2009 Intel Corporation.
*
* Copyright (C) 2008 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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,2008,2009 Intel Corporation.
*
* Copyright (C) 2008 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -57,25 +55,37 @@ _cogl_shader_free (CoglShader *shader)
} }
CoglHandle CoglHandle
cogl_create_shader (COGLenum shaderType) cogl_create_shader (CoglShaderType type)
{ {
CoglShader *shader; 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 = g_slice_new (CoglShader);
shader->gl_handle = glCreateShaderObjectARB (shaderType); shader->gl_handle = glCreateShaderObjectARB (gl_type);
return _cogl_shader_handle_new (shader); return _cogl_shader_handle_new (shader);
} }
void void
cogl_shader_source (CoglHandle handle, cogl_shader_source (CoglHandle handle,
const gchar *source) const char *source)
{ {
CoglShader *shader; CoglShader *shader;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (!cogl_is_shader (handle)) if (!cogl_is_shader (handle))
return; return;
@ -100,11 +110,11 @@ cogl_shader_compile (CoglHandle handle)
void void
cogl_shader_get_info_log (CoglHandle handle, cogl_shader_get_info_log (CoglHandle handle,
guint size, size_t size,
gchar *buffer) char *buffer)
{ {
CoglShader *shader; CoglShader *shader;
COGLint len; int len;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (!cogl_is_shader (handle)) if (!cogl_is_shader (handle))
@ -116,18 +126,51 @@ cogl_shader_get_info_log (CoglHandle handle,
buffer[len]='\0'; buffer[len]='\0';
} }
void CoglShaderType
cogl_shader_get_parameteriv (CoglHandle handle, cogl_shader_get_type (CoglHandle handle)
COGLenum pname,
COGLint *dest)
{ {
GLint type;
CoglShader *shader; CoglShader *shader;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
_COGL_GET_CONTEXT (ctx, COGL_SHADER_TYPE_VERTEX);
if (!cogl_is_shader (handle)) 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); 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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -26,7 +24,7 @@
#ifndef __COGL_TEXTURE_H #ifndef __COGL_TEXTURE_H
#define __COGL_TEXTURE_H #define __COGL_TEXTURE_H
#include "cogl-bitmap.h" #include "cogl-bitmap-private.h"
#include "cogl-handle.h" #include "cogl-handle.h"
typedef struct _CoglTexture CoglTexture; typedef struct _CoglTexture CoglTexture;
@ -70,8 +68,8 @@ struct _CoglTexture
GArray *slice_y_spans; GArray *slice_y_spans;
GArray *slice_gl_handles; GArray *slice_gl_handles;
gint max_waste; gint max_waste;
COGLenum min_filter; CoglTextureFilter min_filter;
COGLenum mag_filter; CoglTextureFilter mag_filter;
gboolean is_foreign; gboolean is_foreign;
GLint wrap_mode; GLint wrap_mode;
gboolean auto_mipmap; 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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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 * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA. * 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 #ifdef HAVE_CONFIG_H
@ -31,6 +34,7 @@
#include "cogl-internal.h" #include "cogl-internal.h"
#include "cogl-util.h" #include "cogl-util.h"
#include "cogl-bitmap.h" #include "cogl-bitmap.h"
#include "cogl-bitmap-private.h"
#include "cogl-texture-private.h" #include "cogl-texture-private.h"
#include "cogl-material.h" #include "cogl-material.h"
#include "cogl-context.h" #include "cogl-context.h"
@ -40,17 +44,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <math.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 #ifdef HAVE_COGL_GL
#define glDrawRangeElements ctx->pf_glDrawRangeElements #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); x_span = &g_array_index (tex->slice_x_spans, CoglTexSliceSpan, x);
#if COGL_DEBUG COGL_NOTE (TEXTURE, "CREATE SLICE (%d,%d)\tsize (%d,%d)",
printf ("CREATE SLICE (%d,%d)\n", x,y); x, y,
printf ("size: (%d x %d)\n", x_span->size - x_span->waste,
x_span->size - x_span->waste, y_span->size - y_span->waste);
y_span->size - y_span->waste);
#endif
/* Setup texture parameters */ /* Setup texture parameters */
GE( glBindTexture (tex->gl_target, GE( glBindTexture (tex->gl_target,
gl_handles[y * n_x_slices + x]) ); gl_handles[y * n_x_slices + x]) );
@ -1243,8 +1235,8 @@ cogl_texture_new_with_size (guint width,
tex->slice_gl_handles = NULL; tex->slice_gl_handles = NULL;
tex->max_waste = max_waste; tex->max_waste = max_waste;
tex->min_filter = CGL_NEAREST; tex->min_filter = COGL_TEXTURE_FILTER_NEAREST;
tex->mag_filter = CGL_NEAREST; tex->mag_filter = COGL_TEXTURE_FILTER_NEAREST;
/* Find closest GL format match */ /* Find closest GL format match */
tex->bitmap.format = tex->bitmap.format =
@ -1304,8 +1296,8 @@ cogl_texture_new_from_data (guint width,
tex->slice_gl_handles = NULL; tex->slice_gl_handles = NULL;
tex->max_waste = max_waste; tex->max_waste = max_waste;
tex->min_filter = CGL_NEAREST; tex->min_filter = COGL_TEXTURE_FILTER_NEAREST;
tex->mag_filter = CGL_NEAREST; tex->mag_filter = COGL_TEXTURE_FILTER_NEAREST;
/* FIXME: If upload fails we should set some kind of /* FIXME: If upload fails we should set some kind of
* error flag but still return texture handle (this * error flag but still return texture handle (this
@ -1336,12 +1328,15 @@ cogl_texture_new_from_data (guint width,
} }
CoglHandle CoglHandle
cogl_texture_new_from_bitmap (CoglBitmap *bmp, cogl_texture_new_from_bitmap (CoglHandle bmp_handle,
gint max_waste, gint max_waste,
CoglTextureFlags flags, CoglTextureFlags flags,
CoglPixelFormat internal_format) CoglPixelFormat internal_format)
{ {
CoglTexture *tex; 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 */ /* Create new texture and fill with loaded data */
tex = (CoglTexture*) g_malloc ( sizeof (CoglTexture)); tex = (CoglTexture*) g_malloc ( sizeof (CoglTexture));
@ -1358,8 +1353,8 @@ cogl_texture_new_from_bitmap (CoglBitmap *bmp,
tex->slice_gl_handles = NULL; tex->slice_gl_handles = NULL;
tex->max_waste = max_waste; tex->max_waste = max_waste;
tex->min_filter = CGL_NEAREST; tex->min_filter = COGL_TEXTURE_FILTER_NEAREST;
tex->mag_filter = CGL_NEAREST; tex->mag_filter = COGL_TEXTURE_FILTER_NEAREST;
/* FIXME: If upload fails we should set some kind of /* FIXME: If upload fails we should set some kind of
* error flag but still return texture handle if the * error flag but still return texture handle if the
@ -1399,19 +1394,20 @@ cogl_texture_new_from_file (const gchar *filename,
CoglPixelFormat internal_format, CoglPixelFormat internal_format,
GError **error) GError **error)
{ {
CoglBitmap *bmp; CoglHandle bmp;
CoglHandle handle; CoglHandle handle;
g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_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; return COGL_INVALID_HANDLE;
handle = cogl_texture_new_from_bitmap (bmp, handle = cogl_texture_new_from_bitmap (bmp,
max_waste, max_waste,
flags, flags,
internal_format); internal_format);
cogl_bitmap_free (bmp); cogl_handle_unref (bmp);
return handle; return handle;
} }
@ -1685,7 +1681,7 @@ cogl_texture_get_gl_texture (CoglHandle handle,
return TRUE; return TRUE;
} }
COGLenum CoglTextureFilter
cogl_texture_get_min_filter (CoglHandle handle) cogl_texture_get_min_filter (CoglHandle handle)
{ {
CoglTexture *tex; CoglTexture *tex;
@ -1698,7 +1694,7 @@ cogl_texture_get_min_filter (CoglHandle handle)
return tex->min_filter; return tex->min_filter;
} }
COGLenum CoglTextureFilter
cogl_texture_get_mag_filter (CoglHandle handle) cogl_texture_get_mag_filter (CoglHandle handle)
{ {
CoglTexture *tex; CoglTexture *tex;
@ -1713,8 +1709,8 @@ cogl_texture_get_mag_filter (CoglHandle handle)
void void
cogl_texture_set_filters (CoglHandle handle, cogl_texture_set_filters (CoglHandle handle,
COGLenum min_filter, CoglTextureFilter min_filter,
COGLenum mag_filter) CoglTextureFilter mag_filter)
{ {
CoglTexture *tex; CoglTexture *tex;
GLuint gl_handle; GLuint gl_handle;

View File

@ -1,9 +1,9 @@
/* /*
* Cogl * 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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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-offscreen.h \
$(top_builddir)/clutter/cogl/cogl-path.h \ $(top_builddir)/clutter/cogl/cogl-path.h \
$(top_builddir)/clutter/cogl/cogl-shader.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-texture.h \
$(top_builddir)/clutter/cogl/cogl-types.h \ $(top_builddir)/clutter/cogl/cogl-types.h \
$(top_builddir)/clutter/cogl/cogl-vertex-buffer.h \ $(top_builddir)/clutter/cogl/cogl-vertex-buffer.h \
@ -24,16 +25,13 @@ INCLUDES = \
-I$(top_builddir)/clutter \ -I$(top_builddir)/clutter \
-I$(top_builddir)/clutter/cogl \ -I$(top_builddir)/clutter/cogl \
-DG_LOG_DOMAIN=\"Cogl-GLES\" \ -DG_LOG_DOMAIN=\"Cogl-GLES\" \
-DCLUTTER_COMPILATION \ -DCLUTTER_COMPILATION
$(CLUTTER_CFLAGS) \
$(CLUTTER_DEBUG_CFLAGS) \
$(MAINTAINER_CFLAGS) \
$(GCC_FLAGS)
LDADD = $(CLUTTER_LIBS)
noinst_LTLIBRARIES = libclutter-cogl.la 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 = \ libclutter_cogl_la_SOURCES = \
$(top_builddir)/clutter/cogl/cogl.h \ $(top_builddir)/clutter/cogl/cogl.h \
$(top_builddir)/clutter/cogl/cogl-defines-gles.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-offscreen.h \
$(top_builddir)/clutter/cogl/cogl-path.h \ $(top_builddir)/clutter/cogl/cogl-path.h \
$(top_builddir)/clutter/cogl/cogl-shader.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-texture.h \
$(top_builddir)/clutter/cogl/cogl-types.h \ $(top_builddir)/clutter/cogl/cogl-types.h \
$(top_builddir)/clutter/cogl/cogl-debug.h \ $(top_builddir)/clutter/cogl/cogl-debug.h \
cogl-internal.h \
cogl-texture-private.h \ cogl-texture-private.h \
cogl-fbo.h \ cogl-fbo.h \
cogl-context.h \ cogl-context.h \
@ -75,8 +73,6 @@ EXTRA_DIST = cogl-defines.h.in \
cogl-fixed-vertex-shader.glsl \ cogl-fixed-vertex-shader.glsl \
cogl-fixed-fragment-shader.glsl cogl-fixed-fragment-shader.glsl
libclutter_cogl_la_LIBADD = $(top_builddir)/clutter/cogl/common/libclutter-cogl-common.la
.glsl.h : .glsl.h :
/bin/sh $(top_srcdir)/clutter/cogl/gles/stringify.sh -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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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 }; GLubyte default_texture_data[] = { 0xff, 0xff, 0xff, 0x0 };
gulong enable_flags = 0; gulong enable_flags = 0;
CoglDrawBufferState *draw_buffer;
if (_context != NULL) if (_context != NULL)
return FALSE; return FALSE;
@ -83,7 +82,11 @@ cogl_create_context ()
sizeof (CoglLayerInfo)); sizeof (CoglLayerInfo));
_context->n_texcoord_arrays_enabled = 0; _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->path_nodes = g_array_new (FALSE, FALSE, sizeof (CoglPathNode));
_context->last_path = 0; _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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -40,6 +38,12 @@ typedef struct
GLubyte c[4]; GLubyte c[4];
} CoglTextureGLVertex; } CoglTextureGLVertex;
typedef struct
{
CoglBufferTarget target;
CoglHandle offscreen;
} CoglDrawBufferState;
typedef struct typedef struct
{ {
/* Features cache */ /* Features cache */
@ -86,7 +90,7 @@ typedef struct
guint n_texcoord_arrays_enabled; guint n_texcoord_arrays_enabled;
/* Framebuffer objects */ /* Framebuffer objects */
CoglBufferTarget draw_buffer; GSList *draw_buffer_stack;
/* Clip stack */ /* Clip stack */
CoglClipStackState clip; CoglClipStackState clip;

View File

@ -26,6 +26,7 @@
#ifndef __COGL_DEFINES_H__ #ifndef __COGL_DEFINES_H__
#define __COGL_DEFINES_H__ #define __COGL_DEFINES_H__
#include <glib.h>
#include <@CLUTTER_GL_HEADER@> #include <@CLUTTER_GL_HEADER@>
G_BEGIN_DECLS 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_WEIGHT_ARRAY_BUFFER_BINDING_OES GL_WEIGHT_ARRAY_BUFFER_BINDING_OES
#define CGL_TEXTURE_CROP_RECT_OES GL_TEXTURE_CROP_RECT_OES #define CGL_TEXTURE_CROP_RECT_OES GL_TEXTURE_CROP_RECT_OES
typedef GLenum COGLenum;
typedef GLint COGLint;
typedef GLuint COGLuint;
/* extras */ /* extras */
/* YUV textures also unsupported */ /* 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_REV_MESA 0
#define CGL_UNSIGNED_SHORT_8_8_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) #if defined(GL_OBJECT_COMPILE_STATUS)
#define CGL_OBJECT_COMPILE_STATUS GL_OBJECT_COMPILE_STATUS #define CGL_OBJECT_COMPILE_STATUS GL_OBJECT_COMPILE_STATUS
#elif defined(GL_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,2009 Intel Corporation.
*
* Copyright (C) 2008 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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); 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 static void
_cogl_offscreen_free (CoglFbo *fbo) _cogl_offscreen_free (CoglFbo *fbo)
{ {
@ -155,36 +144,16 @@ _cogl_offscreen_free (CoglFbo *fbo)
} }
void void
cogl_offscreen_blit_region (CoglHandle src_buffer, cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
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)
{ {
CoglFbo *fbo = NULL; CoglFbo *fbo = NULL;
CoglDrawBufferState *draw_buffer;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _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) if (target == COGL_OFFSCREEN_BUFFER)
{ {
GLboolean scissor_enabled; GLboolean scissor_enabled;
@ -197,7 +166,7 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
fbo = _cogl_offscreen_pointer_from_handle (offscreen); fbo = _cogl_offscreen_pointer_from_handle (offscreen);
/* Check current draw buffer target */ /* 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 /* Push the viewport and matrix setup if redirecting
from a non-screen buffer */ from a non-screen buffer */
@ -247,11 +216,10 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
scissor_box[2], scissor_box[3]); scissor_box[2], scissor_box[3]);
} }
else if ((target & COGL_WINDOW_BUFFER) || else if (target & COGL_WINDOW_BUFFER)
(target & COGL_MASK_BUFFER))
{ {
/* Check current draw buffer target */ /* 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 /* Pop viewport and matrices if redirecting back
from an offscreen buffer */ from an offscreen buffer */
@ -267,27 +235,75 @@ cogl_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
/* Bind window framebuffer object */ /* Bind window framebuffer object */
GE( glBindFramebuffer (GL_FRAMEBUFFER, 0) ); 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 */ /* 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 */ #else /* HAVE_COGL_GLES2 */
@ -306,12 +322,6 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
return COGL_INVALID_HANDLE; return COGL_INVALID_HANDLE;
} }
CoglHandle
cogl_offscreen_new_multisample ()
{
return COGL_INVALID_HANDLE;
}
CoglHandle CoglHandle
cogl_offscreen_ref (CoglHandle handle) cogl_offscreen_ref (CoglHandle handle)
{ {
@ -324,27 +334,7 @@ cogl_offscreen_unref (CoglHandle handle)
} }
void void
cogl_offscreen_blit_region (CoglHandle src_buffer, cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
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)
{ {
} }

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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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,2009 Intel Corporation.
*
* Copyright (C) 2008 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -356,7 +354,7 @@ cogl_gles2_get_fragment_shader (const CoglGles2WrapperSettings *settings)
g_string_append (shader_source, cogl_fixed_fragment_shader_main_declare); g_string_append (shader_source, cogl_fixed_fragment_shader_main_declare);
g_string_append (shader_source, cogl_fixed_fragment_shader_main_start); g_string_append (shader_source, cogl_fixed_fragment_shader_main_start);
/* This pointless extra variable is needed to work around an /* This pointless extra variable is needed to work around an
apparent bug in the PowerVR drivers. Without it the alpha apparent bug in the PowerVR drivers. Without it the alpha
blending seems to stop working */ blending seems to stop working */

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,2009 Intel Corporation.
*
* Copyright (C) 2008 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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,2009 Intel Corporation.
*
* Copyright (C) 2008 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -89,7 +87,7 @@ cogl_program_attach_shader (CoglHandle program_handle,
CoglProgram *program; CoglProgram *program;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (!cogl_is_program (program_handle) || !cogl_is_shader (shader_handle)) if (!cogl_is_program (program_handle) || !cogl_is_shader (shader_handle))
return; return;
@ -116,7 +114,7 @@ void
cogl_program_use (CoglHandle handle) cogl_program_use (CoglHandle handle)
{ {
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (handle != COGL_INVALID_HANDLE && !cogl_is_program (handle)) if (handle != COGL_INVALID_HANDLE && !cogl_is_program (handle))
return; return;
@ -124,7 +122,7 @@ cogl_program_use (CoglHandle handle)
ctx->gles2.settings_dirty = TRUE; ctx->gles2.settings_dirty = TRUE;
} }
COGLint int
cogl_program_get_uniform_location (CoglHandle handle, cogl_program_get_uniform_location (CoglHandle handle,
const gchar *uniform_name) const gchar *uniform_name)
{ {
@ -157,21 +155,21 @@ cogl_program_get_uniform_location (CoglHandle handle,
} }
void void
cogl_program_uniform_1f (COGLint uniform_no, cogl_program_uniform_1f (int uniform_no,
gfloat value) gfloat value)
{ {
cogl_program_uniform_float (uniform_no, 1, 1, &value); cogl_program_uniform_float (uniform_no, 1, 1, &value);
} }
void void
cogl_program_uniform_1i (COGLint uniform_no, cogl_program_uniform_1i (int uniform_no,
gint value) gint value)
{ {
cogl_program_uniform_int (uniform_no, 1, 1, &value); cogl_program_uniform_int (uniform_no, 1, 1, &value);
} }
static void static void
cogl_program_uniform_x (COGLint uniform_no, cogl_program_uniform_x (int uniform_no,
gint size, gint size,
gint count, gint count,
CoglBoxedType type, CoglBoxedType type,
@ -217,7 +215,7 @@ cogl_program_uniform_x (COGLint uniform_no,
} }
void void
cogl_program_uniform_float (COGLint uniform_no, cogl_program_uniform_float (int uniform_no,
gint size, gint size,
gint count, gint count,
const GLfloat *value) const GLfloat *value)
@ -227,7 +225,7 @@ cogl_program_uniform_float (COGLint uniform_no,
} }
void void
cogl_program_uniform_int (COGLint uniform_no, cogl_program_uniform_int (int uniform_no,
gint size, gint size,
gint count, gint count,
const GLint *value) const GLint *value)
@ -237,7 +235,7 @@ cogl_program_uniform_int (COGLint uniform_no,
} }
void void
cogl_program_uniform_matrix (COGLint uniform_no, cogl_program_uniform_matrix (int uniform_no,
gint size, gint size,
gint count, gint count,
gboolean transpose, gboolean transpose,
@ -298,7 +296,7 @@ cogl_program_use (CoglHandle program_handle)
{ {
} }
COGLint int
cogl_program_get_uniform_location (CoglHandle program_handle, cogl_program_get_uniform_location (CoglHandle program_handle,
const gchar *uniform_name) const gchar *uniform_name)
{ {
@ -306,13 +304,13 @@ cogl_program_get_uniform_location (CoglHandle program_handle,
} }
void void
cogl_program_uniform_1f (COGLint uniform_no, cogl_program_uniform_1f (int uniform_no,
gfloat value) gfloat value)
{ {
} }
void void
cogl_program_uniform_float (COGLint uniform_no, cogl_program_uniform_float (int uniform_no,
gint size, gint size,
gint count, gint count,
const GLfloat *value) const GLfloat *value)
@ -320,15 +318,15 @@ cogl_program_uniform_float (COGLint uniform_no,
} }
void void
cogl_program_uniform_int (COGLint uniform_no, cogl_program_uniform_int (int uniform_no,
gint size, gint size,
gint count, gint count,
const COGLint *value) const int *value)
{ {
} }
void void
cogl_program_uniform_matrix (COGLint uniform_no, cogl_program_uniform_matrix (int uniform_no,
gint size, gint size,
gint count, gint count,
gboolean transpose, 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,2009 Intel Corporation.
*
* Copyright (C) 2008 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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,2009 Intel Corporation.
*
* Copyright (C) 2008 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * 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,2009 Intel Corporation.
*
* Copyright (C) 2008 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -50,26 +48,35 @@ _cogl_shader_free (CoglShader *shader)
} }
CoglHandle CoglHandle
cogl_create_shader (COGLenum shaderType) cogl_create_shader (CoglShaderType type)
{ {
CoglShader *shader; 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 = g_slice_new (CoglShader);
shader->gl_handle = glCreateShader (shaderType); shader->gl_handle = glCreateShader (gl_type);
shader->type = shaderType;
return _cogl_shader_handle_new (shader); return _cogl_shader_handle_new (shader);
} }
void void
cogl_shader_source (CoglHandle handle, cogl_shader_source (CoglHandle handle,
const gchar *source) const char *source)
{ {
CoglShader *shader; CoglShader *shader;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (!cogl_is_shader (handle)) if (!cogl_is_shader (handle))
return; return;
@ -94,11 +101,11 @@ cogl_shader_compile (CoglHandle handle)
void void
cogl_shader_get_info_log (CoglHandle handle, cogl_shader_get_info_log (CoglHandle handle,
guint size, size_t size,
gchar *buffer) char *buffer)
{ {
CoglShader *shader; CoglShader *shader;
COGLint len = 0; int len = 0;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (!cogl_is_shader (handle)) if (!cogl_is_shader (handle))
@ -110,20 +117,48 @@ cogl_shader_get_info_log (CoglHandle handle,
buffer[len] = '\0'; buffer[len] = '\0';
} }
void CoglShaderType
cogl_shader_get_parameteriv (CoglHandle handle, cogl_shader_get_type (CoglHandle handle)
COGLenum pname,
COGLint *dest)
{ {
GLint type;
CoglShader *shader; CoglShader *shader;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (!cogl_is_shader (handle)) 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); 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 */ #else /* HAVE_COGL_GLES2 */
@ -131,7 +166,7 @@ cogl_shader_get_parameteriv (CoglHandle handle,
/* No support on regular OpenGL 1.1 */ /* No support on regular OpenGL 1.1 */
CoglHandle CoglHandle
cogl_create_shader (COGLenum shaderType) cogl_create_shader (CoglShaderType type)
{ {
return COGL_INVALID_HANDLE; return COGL_INVALID_HANDLE;
} }
@ -155,7 +190,7 @@ cogl_shader_unref (CoglHandle handle)
void void
cogl_shader_source (CoglHandle shader, cogl_shader_source (CoglHandle shader,
const gchar *source) const char *source)
{ {
} }
@ -166,16 +201,21 @@ cogl_shader_compile (CoglHandle shader_handle)
void void
cogl_shader_get_info_log (CoglHandle handle, cogl_shader_get_info_log (CoglHandle handle,
guint size, size_t size,
gchar *buffer) char *buffer)
{ {
} }
void CoglShaderType
cogl_shader_get_parameteriv (CoglHandle handle, cogl_shader_get_type (CoglHandle handle)
COGLenum pname,
COGLint *dest)
{ {
return COGL_SHADER_TYPE_VERTEX;
}
gboolean
cogl_shader_is_compiled (CoglHandle handle)
{
return FALSE;
} }
#endif /* HAVE_COGL_GLES2 */ #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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -26,7 +24,7 @@
#ifndef __COGL_TEXTURE_H #ifndef __COGL_TEXTURE_H
#define __COGL_TEXTURE_H #define __COGL_TEXTURE_H
#include "cogl-bitmap.h" #include "cogl-bitmap-private.h"
#include "cogl-handle.h" #include "cogl-handle.h"
typedef struct _CoglTexture CoglTexture; typedef struct _CoglTexture CoglTexture;
@ -70,8 +68,8 @@ struct _CoglTexture
GArray *slice_y_spans; GArray *slice_y_spans;
GArray *slice_gl_handles; GArray *slice_gl_handles;
gint max_waste; gint max_waste;
COGLenum min_filter; CoglTextureFilter min_filter;
COGLenum mag_filter; CoglTextureFilter mag_filter;
gboolean is_foreign; gboolean is_foreign;
GLint wrap_mode; GLint wrap_mode;
gboolean auto_mipmap; 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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -30,7 +28,7 @@
#include "cogl.h" #include "cogl.h"
#include "cogl-internal.h" #include "cogl-internal.h"
#include "cogl-util.h" #include "cogl-util.h"
#include "cogl-bitmap.h" #include "cogl-bitmap-private.h"
#include "cogl-texture-private.h" #include "cogl-texture-private.h"
#include "cogl-material.h" #include "cogl-material.h"
#include "cogl-context.h" #include "cogl-context.h"
@ -42,17 +40,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <math.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); extern void _cogl_journal_flush (void);
static void _cogl_texture_free (CoglTexture *tex); 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_push ();
_cogl_current_matrix_identity (); _cogl_current_matrix_identity ();
/* Draw to all channels */
cogl_draw_buffer (COGL_WINDOW_BUFFER | COGL_MASK_BUFFER, 0);
/* Direct copy operation */ /* Direct copy operation */
if (ctx->texture_download_material == COGL_INVALID_HANDLE) 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_set_current_matrix (COGL_MATRIX_MODELVIEW);
_cogl_current_matrix_pop (); _cogl_current_matrix_pop ();
cogl_draw_buffer (COGL_WINDOW_BUFFER, 0);
return TRUE; return TRUE;
} }
@ -1435,12 +1417,13 @@ cogl_texture_new_from_data (guint width,
} }
CoglHandle CoglHandle
cogl_texture_new_from_bitmap (CoglBitmap *bmp, cogl_texture_new_from_bitmap (CoglHandle bmp_handle,
gint max_waste, gint max_waste,
CoglTextureFlags flags, CoglTextureFlags flags,
CoglPixelFormat internal_format) CoglPixelFormat internal_format)
{ {
CoglTexture *tex; CoglTexture *tex;
CoglBitmap *bmp = (CoglBitmap *)bmp_handle;
/* Create new texture and fill with loaded data */ /* Create new texture and fill with loaded data */
tex = (CoglTexture*) g_malloc ( sizeof (CoglTexture)); tex = (CoglTexture*) g_malloc ( sizeof (CoglTexture));
@ -1498,19 +1481,20 @@ cogl_texture_new_from_file (const gchar *filename,
CoglPixelFormat internal_format, CoglPixelFormat internal_format,
GError **error) GError **error)
{ {
CoglBitmap *bmp; CoglHandle bmp;
CoglHandle handle; CoglHandle handle;
g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_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; return COGL_INVALID_HANDLE;
handle = cogl_texture_new_from_bitmap (bmp, handle = cogl_texture_new_from_bitmap (bmp,
max_waste, max_waste,
flags, flags,
internal_format); internal_format);
cogl_bitmap_free (bmp); cogl_handle_unref (bmp);
return handle; return handle;
} }
@ -1783,7 +1767,7 @@ cogl_texture_get_gl_texture (CoglHandle handle,
return TRUE; return TRUE;
} }
COGLenum CoglTextureFilter
cogl_texture_get_min_filter (CoglHandle handle) cogl_texture_get_min_filter (CoglHandle handle)
{ {
CoglTexture *tex; CoglTexture *tex;
@ -1796,7 +1780,7 @@ cogl_texture_get_min_filter (CoglHandle handle)
return tex->min_filter; return tex->min_filter;
} }
COGLenum CoglTextureFilter
cogl_texture_get_mag_filter (CoglHandle handle) cogl_texture_get_mag_filter (CoglHandle handle)
{ {
CoglTexture *tex; CoglTexture *tex;
@ -1811,8 +1795,8 @@ cogl_texture_get_mag_filter (CoglHandle handle)
void void
cogl_texture_set_filters (CoglHandle handle, cogl_texture_set_filters (CoglHandle handle,
COGLenum min_filter, CoglTextureFilter min_filter,
COGLenum mag_filter) CoglTextureFilter mag_filter)
{ {
CoglTexture *tex; CoglTexture *tex;
GLuint gl_handle; 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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -44,7 +42,7 @@ cogl_util_next_p2 (int a)
{ {
int rval=1; int rval=1;
while(rval < a) while(rval < a)
rval <<= 1; rval <<= 1;
return rval; return rval;

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,2008,2009 Intel Corporation.
*
* Copyright (C) 2007 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -26,7 +24,7 @@
#ifndef __COGL_UTIL_H #ifndef __COGL_UTIL_H
#define __COGL_UTIL_H #define __COGL_UTIL_H
int int
cogl_util_next_p2 (int a); cogl_util_next_p2 (int a);
#endif /* __COGL_UTIL_H */ #endif /* __COGL_UTIL_H */

View File

@ -1,9 +1,9 @@
/* /*
* Cogl * 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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public

View File

@ -1,16 +1,36 @@
#! /bin/sh #! /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 () output_copyright ()
{ {
cat <<EOF > "$1"; 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,2009 Intel Corporation.
*
* Copyright (C) 2008 OpenedHand
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public

View File

@ -25,7 +25,7 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
/* TODO: /* TODO:
* - Automagically handle named pixmaps, and window resizes (i.e * - Automagically handle named pixmaps, and window resizes (i.e
* essentially handle window id's being passed in) ? * essentially handle window id's being passed in) ?
*/ */
@ -94,8 +94,6 @@ static RectangleState _rectangle_state = CLUTTER_GLX_RECTANGLE_ALLOW;
struct _ClutterGLXTexturePixmapPrivate struct _ClutterGLXTexturePixmapPrivate
{ {
COGLenum target_type;
guint texture_id;
GLXPixmap glx_pixmap; GLXPixmap glx_pixmap;
gboolean use_fallback; gboolean use_fallback;
@ -107,14 +105,14 @@ struct _ClutterGLXTexturePixmapPrivate
gboolean using_rectangle; gboolean using_rectangle;
}; };
static void static void
clutter_glx_texture_pixmap_update_area (ClutterX11TexturePixmap *texture, clutter_glx_texture_pixmap_update_area (ClutterX11TexturePixmap *texture,
gint x, gint x,
gint y, gint y,
gint width, gint width,
gint height); gint height);
static void static void
clutter_glx_texture_pixmap_create_glx_pixmap (ClutterGLXTexturePixmap *tex); clutter_glx_texture_pixmap_create_glx_pixmap (ClutterGLXTexturePixmap *tex);
static ClutterX11TexturePixmapClass *parent_class = NULL; static ClutterX11TexturePixmapClass *parent_class = NULL;
@ -137,12 +135,12 @@ texture_bind (ClutterGLXTexturePixmap *tex)
/* FIXME: fire off an error here? */ /* FIXME: fire off an error here? */
glBindTexture (target, handle); glBindTexture (target, handle);
if (clutter_texture_get_filter_quality (CLUTTER_TEXTURE (tex)) if (clutter_texture_get_filter_quality (CLUTTER_TEXTURE (tex))
== CLUTTER_TEXTURE_QUALITY_HIGH && tex->priv->can_mipmap) == CLUTTER_TEXTURE_QUALITY_HIGH && tex->priv->can_mipmap)
{ {
cogl_texture_set_filters (cogl_tex, cogl_texture_set_filters (cogl_tex,
CGL_LINEAR_MIPMAP_LINEAR, COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR,
CGL_LINEAR); COGL_TEXTURE_FILTER_LINEAR);
} }
return TRUE; return TRUE;
@ -157,13 +155,13 @@ on_glx_texture_pixmap_pre_paint (ClutterGLXTexturePixmap *texture,
GLuint handle = 0; GLuint handle = 0;
GLenum target = 0; GLenum target = 0;
CoglHandle cogl_tex; CoglHandle cogl_tex;
cogl_tex = clutter_texture_get_cogl_texture cogl_tex = clutter_texture_get_cogl_texture
(CLUTTER_TEXTURE(texture)); (CLUTTER_TEXTURE(texture));
texture_bind (texture); texture_bind (texture);
cogl_texture_get_gl_texture (cogl_tex, &handle, &target); cogl_texture_get_gl_texture (cogl_tex, &handle, &target);
_gl_generate_mipmap (target); _gl_generate_mipmap (target);
texture->priv->mipmap_generate_queued = 0; texture->priv->mipmap_generate_queued = 0;
@ -408,11 +406,11 @@ clutter_glx_texture_pixmap_realize (ClutterActor *actor)
"pixmap-width", &pixmap_width, "pixmap-width", &pixmap_width,
"pixmap-height", &pixmap_height, "pixmap-height", &pixmap_height,
NULL); NULL);
if (!pixmap) if (!pixmap)
return; return;
if (!create_cogl_texture (CLUTTER_TEXTURE (actor), if (!create_cogl_texture (CLUTTER_TEXTURE (actor),
pixmap_width, pixmap_height)) pixmap_width, pixmap_height))
{ {
CLUTTER_NOTE (TEXTURE, "Unable to create a valid pixmap"); CLUTTER_NOTE (TEXTURE, "Unable to create a valid pixmap");
@ -460,7 +458,7 @@ clutter_glx_texture_pixmap_unrealize (ClutterActor *actor)
priv->bound = FALSE; priv->bound = FALSE;
} }
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED); CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
} }
@ -739,8 +737,8 @@ clutter_glx_texture_pixmap_create_glx_pixmap (ClutterGLXTexturePixmap *texture)
if (glx_pixmap != None) if (glx_pixmap != None)
{ {
priv->glx_pixmap = glx_pixmap; priv->glx_pixmap = glx_pixmap;
create_cogl_texture (CLUTTER_TEXTURE (texture), create_cogl_texture (CLUTTER_TEXTURE (texture),
pixmap_width, pixmap_height); pixmap_width, pixmap_height);
CLUTTER_NOTE (TEXTURE, "Created GLXPixmap"); CLUTTER_NOTE (TEXTURE, "Created GLXPixmap");
@ -762,7 +760,7 @@ clutter_glx_texture_pixmap_create_glx_pixmap (ClutterGLXTexturePixmap *texture)
priv->glx_pixmap = None; priv->glx_pixmap = None;
/* Some fucky logic here - we've fallen back and need to make sure /* Some fucky logic here - we've fallen back and need to make sure
* we realize here.. * we realize here..
*/ */
clutter_actor_realize (CLUTTER_ACTOR (texture)); clutter_actor_realize (CLUTTER_ACTOR (texture));
} }
@ -800,22 +798,22 @@ clutter_glx_texture_pixmap_update_area (ClutterX11TexturePixmap *texture,
if (priv->glx_pixmap == None) if (priv->glx_pixmap == None)
return; return;
if (texture_bind (CLUTTER_GLX_TEXTURE_PIXMAP(texture))) if (texture_bind (CLUTTER_GLX_TEXTURE_PIXMAP(texture)))
{ {
CLUTTER_NOTE (TEXTURE, "Really updating via GLX"); CLUTTER_NOTE (TEXTURE, "Really updating via GLX");
clutter_x11_trap_x_errors (); clutter_x11_trap_x_errors ();
(_gl_bind_tex_image) (dpy, (_gl_bind_tex_image) (dpy,
priv->glx_pixmap, priv->glx_pixmap,
GLX_FRONT_LEFT_EXT, GLX_FRONT_LEFT_EXT,
NULL); NULL);
XSync (clutter_x11_get_default_display(), FALSE); XSync (clutter_x11_get_default_display(), FALSE);
/* Note above fires X error for non name pixmaps - but /* Note above fires X error for non name pixmaps - but
* things still seem to work - i.e pixmap updated * things still seem to work - i.e pixmap updated
*/ */
if (clutter_x11_untrap_x_errors ()) if (clutter_x11_untrap_x_errors ())
CLUTTER_NOTE (TEXTURE, "Update bind_tex_image failed"); CLUTTER_NOTE (TEXTURE, "Update bind_tex_image failed");
@ -829,7 +827,7 @@ clutter_glx_texture_pixmap_update_area (ClutterX11TexturePixmap *texture,
{ {
/* FIXME: It may make more sense to set a flag here and only /* FIXME: It may make more sense to set a flag here and only
* generate the mipmap on a pre paint.. compressing need * generate the mipmap on a pre paint.. compressing need
* to call generate mipmap * to call generate mipmap
* May break clones however.. * May break clones however..
*/ */
priv->mipmap_generate_queued++; priv->mipmap_generate_queued++;
@ -870,7 +868,7 @@ clutter_glx_texture_pixmap_class_init (ClutterGLXTexturePixmapClass *klass)
* clutter_glx_texture_pixmap_using_extension: * clutter_glx_texture_pixmap_using_extension:
* @texture: A #ClutterGLXTexturePixmap * @texture: A #ClutterGLXTexturePixmap
* *
* Return value: A boolean indicating if the texture is using the * Return value: A boolean indicating if the texture is using the
* GLX_EXT_texture_from_pixmap OpenGL extension or falling back to * GLX_EXT_texture_from_pixmap OpenGL extension or falling back to
* slower software mechanism. * slower software mechanism.
* *
@ -883,8 +881,8 @@ clutter_glx_texture_pixmap_using_extension (ClutterGLXTexturePixmap *texture)
priv = CLUTTER_GLX_TEXTURE_PIXMAP (texture)->priv; priv = CLUTTER_GLX_TEXTURE_PIXMAP (texture)->priv;
return (_have_tex_from_pixmap_ext && !priv->use_fallback); return (_have_tex_from_pixmap_ext && !priv->use_fallback);
/* Assume NPOT TFP's are supported even if regular NPOT isn't advertised /* Assume NPOT TFP's are supported even if regular NPOT isn't advertised
* but tfp is. Seemingly some Intel drivers do this ? * but tfp is. Seemingly some Intel drivers do this ?
*/ */
/* && clutter_feature_available (COGL_FEATURE_TEXTURE_NPOT)); */ /* && clutter_feature_available (COGL_FEATURE_TEXTURE_NPOT)); */

View File

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

View File

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

View File

@ -585,6 +585,24 @@ fi
AC_SUBST(CLUTTER_DEBUG_CFLAGS) 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 ========================================= dnl = Enable strict compiler flags =========================================
# use strict compiler flags only on development releases # use strict compiler flags only on development releases
@ -726,7 +744,8 @@ fi
echo " GL Headers: ${CLUTTER_GL_HEADER}" echo " GL Headers: ${CLUTTER_GL_HEADER}"
echo " Image backend: ${imagebackend}" echo " Image backend: ${imagebackend}"
echo " Target library: ${clutterbackendlib}" 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 " Compiler flags: ${CPPFLAGS} ${MAINTAINER_CFLAGS}"
echo " Build API Documentation: ${enable_gtk_doc}" echo " Build API Documentation: ${enable_gtk_doc}"
echo " Build Manual Documentation: ${enable_manual}" echo " Build Manual Documentation: ${enable_manual}"

View File

@ -428,6 +428,8 @@ ClutterTextureQuality
clutter_texture_new clutter_texture_new
clutter_texture_new_from_file clutter_texture_new_from_file
clutter_texture_new_from_actor clutter_texture_new_from_actor
<SUBSECTION>
CLUTTER_TEXTURE_ERROR CLUTTER_TEXTURE_ERROR
ClutterTextureError ClutterTextureError
clutter_texture_set_from_file clutter_texture_set_from_file
@ -435,6 +437,7 @@ clutter_texture_set_from_rgb_data
clutter_texture_set_from_yuv_data clutter_texture_set_from_yuv_data
clutter_texture_set_area_from_rgb_data clutter_texture_set_area_from_rgb_data
clutter_texture_get_base_size clutter_texture_get_base_size
clutter_texture_get_pixel_format
clutter_texture_get_filter_quality clutter_texture_get_filter_quality
clutter_texture_set_filter_quality clutter_texture_set_filter_quality
clutter_texture_get_max_tile_waste clutter_texture_get_max_tile_waste
@ -443,6 +446,16 @@ clutter_texture_get_cogl_texture
clutter_texture_set_cogl_texture clutter_texture_set_cogl_texture
clutter_texture_get_cogl_material clutter_texture_get_cogl_material
clutter_texture_set_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> <SUBSECTION Standard>
CLUTTER_TEXTURE CLUTTER_TEXTURE
@ -1220,6 +1233,7 @@ clutter_model_set_sort
clutter_model_resort clutter_model_resort
ClutterModelFilterFunc ClutterModelFilterFunc
clutter_model_set_filter clutter_model_set_filter
clutter_model_get_filter_set
clutter_model_filter_iter clutter_model_filter_iter
clutter_model_filter_row clutter_model_filter_row

View File

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

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