Commit Graph

1042 Commits

Author SHA1 Message Date
Robert Bragg
5ab0b38657 pipeline: don't leak the layers_cache
When freeing a pipeline in _cogl_pipeline_free we weren't making sure to
free the layers_cache which was leading to a memory leak.

Thanks to Sunjin Yang for finding this.

https://bugzilla.gnome.org/show_bug.cgi?id=660986

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-10-12 15:29:07 +01:00
Robert Bragg
1f61868fed x11-tfp: don't call winsys x11_damage_notify without winsys
If we failed to create a native texture from pixmap via EGL or GLX then
we shouldn't call the winsys's texture_pixmap_x11_damage_notify
function. By doing the validation in cogl-texture-pixmap-x11.c the
winsys code can continue to assume that it doesn't need to verify there
is a valid tex_pixmap->winsys pointer.

Thanks to Damien Leone <dleone@nvidia.com> for catching this issue.

https://bugzilla.gnome.org/show_bug.cgi?id=660184
2011-10-12 14:24:44 +01:00
Damien Leone
895055c836 cogl-winsys-glx: fix texture format detection
The previous detection was based on color depth only to determine the
texture format to use in GLX. If that worked fine at depths 24 (RGB8)
and 32 (ARGB8), that would fail at depth 30 (BGR10) and fallback to
software instead of using the TFP extension.

This commit uses an efficient population count implementation to
compare the number of 1-bits in color masks against the color depth
requested by the X client. If they are not equal this means that an
alpha channel has been requested.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-10-01 16:44:55 +01:00
Neil Roberts
5aab8a2310 Add an option to avoid defining G_DISABLE_DEPRECATED
G_DISABLE_DEPRECATED is only intended for developers of Cogl and it
sometimes breaks the build for people just trying to build a
release. This patch adds an option to enable deprecated Glib
features. By default it is enabled for non-git versions of Cogl.

The patch is based on similar code in Clutter except it adds the flags
to COGL_EXTRA_CFLAGS instead of having a separate variable.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-27 10:27:19 +01:00
Chun-wei Fan
34181d34f5 Makefile.am: Update sources list
There is no cogl/cogl-pipeline-debug-private.h, so remove that from
Makefile.am

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-26 15:54:07 +01:00
Chun-wei Fan
98a9428967 cogl-pipeline/cogl-pango: Added forgotten includes
It seems that cogl-context-private.h needs to be included before including
any of the pipeline-related stuff to avoid build errors on C89 compilers.

This is due to the recent cogl-pipeline decoupling, seems like.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-26 15:53:30 +01:00
Robert Bragg
dd5208b0ba arbfp: assume GL_TEXTURE_2D target for NULL texture
During arbfp codegen we weren't checking for NULL textures and so we
would crash when trying to query a NULL texture's GL texture target.
Since NULL texture targets result in ctx->default_gl_texture_2d_tex
being bound we can assume that a NULL texture corresponds to a
GL_TEXTURE_2D target.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-09-23 15:31:07 +01:00
Robert Bragg
30f8521790 pipeline: optimize _compare_differences functions
This optimizes the layer and pipeline _compare_differences functions so
neither of them use the GArray api since building up the list of
ancestors by appending to a shared GArray was showing quite high on
profiles due to how frequently pipeline comparisons are made. Instead
we now build up a transient, singly linked list by allocating GList
nodes via alloca to build up the parallel lists of ancestors.

This tweaked approach actually ends up being a bit more concise than
before, we avoid the overhead of the GArray api and now avoid making any
function calls while comparing (assuming the _get_parent() calls always
inline), we avoiding needing to get the default cogl context.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-09-21 17:28:32 +01:00
Robert Bragg
f16d3756df pipeline: lazily get ctx in _get_layer
We only need a ctx pointer if we need to refer to the default_layer_x
layers to copy as templates so only call  _cogl_context_get_default()
once we need to copy a template. _cogl_context_get_default() was
starting to show up in profiles and this was the main cause.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-09-21 17:28:22 +01:00
Robert Bragg
d4459e2d42 pipeline: Split more code out from cogl-pipeline.c
This splits out the core CoglPipelineLayer support code from
cogl-pipeline.c into cogl-pipeline-layer.c; it splits out the debugging
code for dumping a pipeline to a .dot file into cogl-pipeline-debug.c
and it splits the CoglPipelineNode support which is shared between
CoglPipeline and CoglPipelineLayer into cogl-node.c.

Note: cogl-pipeline-layer.c only contains the layer code directly
relating to CoglPipelineLayer objects; it does not contain any
_cogl_pipeline API relating to how CoglPipeline tracks and manipulates
layers.
2011-09-21 17:03:10 +01:00
Robert Bragg
77a7add50e attributes: optimize validation of tex_coord%d_in names
This avoids using sscanf to determine the texture_unit that a
tex_coord%d_in attribute name corresponds to since that was showing high
on profiles. Instead once we know we have a "tex_coord" name then we
can simply use strtoul which is much cheaper and use the returned endptr
we get to verify we have a "_in" suffix after the number.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-09-21 15:50:13 +01:00
Robert Bragg
d739892a5c primitive: micro optimize primitive allocations
We've started seeing cases where we want to allocate lots of one-shot
primitives per-frame and the cost of allocating primitives becomes
important in this case since it can start being noticeable in profiles.

The main cost for allocating primitives was the GArray allocation
and appending the attributes to the array. This updates the code to
simply over allocate the primitive storage so we can embed the list
of attributes directly in that allocation.

If the user later sets new attributes and there isn't enough embedded
space then a separate slice allocation for the new attributes is made
but still this should be far less costly than using a GArray as before.
Most of the time we would expect when setting new attributes there will
still be the same number of attributes, so the embedded space can simple
be reused.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-09-21 15:50:08 +01:00
Robert Bragg
791773987c attributes: avoid g_strdup in cogl_attribute_new
Calling g_strdup for attribute names was starting to show up in profiles
due to calling malloc for new string storage so frequently. This avoids
calling g_strdup and calls g_intern_string() instead. For the really
common case names we even avoid the cost of g_intern_string since we
can trivially relate our internal name_id to a static string.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-09-21 15:39:46 +01:00
Robert Bragg
4c3dadd35e Add a strong CoglTexture type to replace CoglHandle
As part of the on going, incremental effort to purge the non type safe
CoglHandle type from the Cogl API this patch tackles most of the
CoglHandle uses relating to textures.

We'd postponed making this change for quite a while because we wanted to
have a clearer understanding of how we wanted to evolve the texture APIs
towards Cogl 2.0 before exposing type safety here which would be
difficult to change later since it would imply breaking APIs.

The basic idea that we are steering towards now is that CoglTexture
can be considered to be the most primitive interface we have for any
object representing a texture. The texture interface would provide
roughly these methods:

  cogl_texture_get_width
  cogl_texture_get_height
  cogl_texture_can_repeat
  cogl_texture_can_mipmap
  cogl_texture_generate_mipmap;
  cogl_texture_get_format
  cogl_texture_set_region
  cogl_texture_get_region

Besides the texture interface we will then start to expose types
corresponding to specific texture types: CoglTexture2D,
CoglTexture3D, CoglTexture2DSliced, CoglSubTexture, CoglAtlasTexture and
CoglTexturePixmapX11.

We will then also expose an interface for the high-level texture types
we have (such as CoglTexture2DSlice, CoglSubTexture and
CoglAtlasTexture) called CoglMetaTexture. CoglMetaTexture is an
additional interface that lets you iterate a virtual region of a meta
texture and get mappings of primitive textures to sub-regions of that
virtual region. Internally we already have this kind of abstraction for
dealing with sliced texture, sub-textures and atlas textures in a
consistent way, so this will just make that abstraction public. The aim
here is to clarify that there is a difference between primitive textures
(CoglTexture2D/3D) and some of the other high-level textures, and also
enable developers to implement primitives that can support meta textures
since they can only be used with the cogl_rectangle API currently.

The thing that's not so clean-cut with this are the texture constructors
we have currently; such as cogl_texture_new_from_file which no longer
make sense when CoglTexture is considered to be an interface.  These
will basically just become convenient factory functions and it's just a
bit unusual that they are within the cogl_texture namespace.  It's worth
noting here that all the texture type APIs will also have their own type
specific constructors so these functions will only be used for the
convenience of being able to create a texture without really wanting to
know the details of what type of texture you need.  Longer term for 2.0
we may come up with replacement names for these factory functions or the
other thing we are considering is designing some asynchronous factory
functions instead since it's so often detrimental to application
performance to be blocked waiting for a texture to be uploaded to the
GPU.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-09-21 15:27:03 +01:00
Neil Roberts
1984fea4b1 cogl-primitives: Don't warn if using sliced textures without multi-tex
cogl_rectangle has some validation code to check whether the first
layer has a sliced texture. If so it will abandon the rest of the
layers and print a warning. However it was even doing this pruning and
displaying the warning if there is only one layer. This patch just
makes it check whether the pipeline actually has more than one layer
before pruning or displaying the warning but it will still fallback to
the multiple quads path.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-19 16:40:07 +01:00
Neil Roberts
dbff3a357e Make backface culling be part of the legacy state
This adds an internal function to set the backface culling state on a
pipeline. This includes properties to set the culling mode (front,
back or both) and also to set which face is considered the front
(COGL_WINDING_CLOCKWISE or COGL_WINDING_COUNTER_CLOCKWISE). The actual
front face flushed to GL depends on whether we are rendering to an
offscreen buffer or not. This means that when changing between on- and
off- screen framebuffers it now checks whether the last flushed
pipeline has backface culling enabled and forces a reflush of the cull
face state if so.

The backface culling is now set on a pipeline as part of the legacy
state. This is important because some code in Cogl assumes it can
flush a temporary pipeline to revert to a known state, but previously
this wouldn't disable backface culling so things such as flushing the
clip stack could get confused.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-19 16:40:07 +01:00
Neil Roberts
879ce7301a cogl-framebuffer: Force flushing the color mask when changing fbs
When changing between two framebuffers that have different color masks
it now forces the pipeline to flush the mask by setting
current_pipeline_changes_since_flush. For this to work there needs to
be a common bit of code that gets called when the framebuffers are
changed that has access to both the old framebuffer and the new
framebuffer. _cogl_set_framebuffers_real can't be used for this
because when it is called from cogl_pop_framebuffer the stack entries
have already changed so it can't know the old framebuffer. This patch
adds a new function called notify_buffers_changed which should get
called whenever the buffers are changed and it explicitly gets passed
pointers to the old and new buffers. cogl_pop_framebuffer now calls
this instead of trying to use _cogl_set_framebuffers_real to force a
flush.

This patch also fixes the ctx->window_buffer pointer. Previously this
was implemented by searching in the framebuffer stack for an onscreen
framebuffer whenever the current buffers are changed. However it does
this after the stack has already changed so it won't usually find the
right buffer.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-19 16:40:07 +01:00
Neil Roberts
f6ec6e2d0e pipeline-arbfp: Check for fog on the pipeline not the legacy state
The ARBfp backend can't handle fog so it tries to check for when it's
enabled and bails out. However it was checking using the global legacy
state value on the CoglContext but this doesn't necessarily reflect
the state that will actually be used by the pipeline because Cogl may
have internally pushed a different pipeline.

This patch adds an internal _cogl_pipeline_get_fog_enabled which the
ARBfp backend now uses.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-19 16:40:06 +01:00
Neil Roberts
2059ae3ac8 Add internal _cogl_push_source to optionally disable legacy state
Some code in Cogl such as when flushing a stencil clip assumes that it
can push a temporary simple pipeline to reset to a known state for
internal drawing operations. However this breaks down if the
application has set any legacy state because that is set globally so
it will also get applied to the internal pipeline.

_cogl_draw_attributes already had an internal flag to disable applying
the legacy state but I think this is quite awkward to use because not
all places that push a pipeline draw the attribute buffers directly so
it is difficult to pass the flag down through the layers.

Conceptually the legacy state is meant to be like a layer on top of
the purely pipeline-based state API so I think ideally we should have
an internal function to push the source without the applying the
legacy state. The legacy state can't be applied as the pipeline is
pushed because the global state can be modified even after it is
pushed. This patch adds a _cogl_push_source() function which takes an
extra boolean flag to mark whether to enable the legacy state. The
value of this flag is stored alongside the pipeline in the pipeline
stack. Another new internal function called
_cogl_get_enable_legacy_state queries whether the top entry in the
pipeline stack has legacy state enabled. cogl-primitives and the
vertex array drawing code now use this to determine whether to apply
the legacy state when drawing. The COGL_DRAW_SKIP_LEGACY_STATE flag is
now removed.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-19 16:40:06 +01:00
Neil Roberts
acc7d25188 cogl-path: Don't apply legacy state twice when stroking
Since 12b3d21aaa cogl is using the vertex attribute API to stroke a
path. However it was still manually appllying the legacy state to the
pipeline. cogl_vdraw_attributes also applies the legacy state so it
ends up getting applied twice. This patch just removes it from
_cogl_path_stroke_nodes.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-19 16:40:06 +01:00
Adel Gadllah
671a4dfb34 winsys-glx: Fix synchronisation behaviour in _cogl_winsys_onscreen_swap_region
This patch basically restores the logic from 1.6.  There we assumed that
glXCopySubBuffer won't tear and thus only needs to be throttled to the
framerate, while glBlitFramebuffer needs to always wait to avoid
tearing.

With Nvidia drivers specifically we have seen that glBlitFramebuffer is
not synchronized. Eventually the plan is that Cogl will actually take
into consideration the underlying driver/hw vendor and driver version
and we may want to only mark glBlitFramebuffer un-synchronized on
Nvidia.

https://bugzilla.gnome.org/show_bug.cgi?id=659360

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-19 16:40:06 +01:00
Robert Bragg
3c82fd056c pipeline: mark all cogl-pipeline.h symbols experimental
All of the cogl_pipeline API is currently experimental so this makes
sure the API is surrounded by #ifdef COGL_ENABLE_EXPERIMENTAL_API
guards and all the symbols have a #define to give them an _EXP suffix as
we do for other experimental API.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-09-19 16:40:06 +01:00
Robert Bragg
db6c452aaa pipeline: split out all layer state apis
As part of an on-going effort to get cogl-pipeline.c into a more
maintainable state this splits out all the apis relating just to
layer state. This just leaves code relating to the core CoglPipeline
and CoglPipelineLayer design left in cogl-pipeline.c.

This splits out around 2k more lines from cogl-pipeline.c although we
are still left with nearly 4k lines so we still have some way to go!

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-09-19 16:40:00 +01:00
Robert Bragg
9b58b6f472 pipeline: split out all core state apis
Since cogl-pipeline.c has become very unwieldy this make a start at
trying to shape this code back into a manageable state. This patche
moves all the API relating to core pipeline state into
cogl-pipeline-state.c. This doesn't move code relating to layer state
out nor does it move any of the code supporting the core design
of CoglPipeline itself.

This change alone factors out 2k lines of code from cogl-pipeline.c
which is obviously a good start. The next step will be to factor
out the layer state and then probably look at breaking all of this
state code down into state-groups.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-09-19 16:35:59 +01:00
Neil Roberts
c7969a33af cogl: Bind the locale dir for the Cogl domain
dgettext (which Cogl is using) doesn't work unless you first tell
gettext where the locale dir is for the library's domain. This just
adds the necessary calls into _cogl_init.

https://bugzilla.gnome.org/show_bug.cgi?id=658700

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-19 12:53:58 +01:00
Neil Roberts
e81c1f3e9a cogl-journal: Fix software clipping for non-intersecting rectangles
When the clip contains two rectangles which do not intersect it was
generating a clip bounds where the bottom-right corner was above or to
the left of the top-left corner. This would end up allowing the pixels
between the two rectangles instead of clipping everything like it
should. To fix this there is now an extra check which detects this
situation and just clears the clip bounds to all zeroes in a similar
way to what cogl-clip-stack does.

https://bugzilla.gnome.org/show_bug.cgi?id=659029

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-14 16:30:16 +01:00
Neil Roberts
9082dd0d71 cogl-path: Clear the stroke attribute buffer when modifying the path
Commit 12b3d21a changed cogl-path so that it will use the vertex
attribute API to stroke the path in a similar way to how it was using
the API to fill the path. However it wasn't clearing the stroke buffer
when the path is modified so it would continue to use the unmodified
stroke.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-12 18:54:16 +01:00
Robert Bragg
f1c2d7e965 2.0: Add cogl2-experimental.h + don't pollute .pc CFLAGS
Instead of adding -DCOGL_ENABLE_EXPERIMENTAL_2_0_API to the
cogl-2.0-experimental.pc file we now install a cogl2-experimental.h
that #defines COGL_ENABLE_EXPERIMENTAL_2_0_API before including
cogl.h.

The problem with having the define in the .pc file is that you might
develop a library that depends on the experimental 2.0 api internally
and then you might want to use that library with Clutter which still
uses the 1.0 API but the .pc file for your library will indirectly,
automatically enable the 2.0 api which can cause conflicts.
2011-09-09 15:06:31 +01:00
Robert Bragg
d43505db22 arbfp: remove redundant unit_state re-initialization
When we are about to start arbfp codegen we call shader_state_new() to
allocate new state structures used to build up the code and that
function makes sure to zero the newly allocated structures.

Right after calling shader_state_new() we were then also explicitly
iterating though the newly allocated unit_state structures and zeroing
the .sampled and .dirty_combine_constant members as well as resetting
shader_state->next_constant_id = 0. This patch removes that redundant
re-initialization of state.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-09-09 14:40:48 +01:00
Robert Bragg
b6cea6bed6 arbfp: track which layers have combine constants
We weren't actually tracking which layers have been allocated param
space for combine constants; all layers just had a default constant_id
of 0 that indexes into the program.local[] params array and a dirty flag
to say when the constant needs updating. There are times though when we
say to update everything by-passing the dirty flag and because we
weren't actually tracking which layers needed constants we would always
write a constant to program.local[0] for every layer. The upshot was
that we could end up clobbering a real constant that was actually
allocated the constant_id = 0 slot.

This patch adds a new UnitState bitfield to track if the layer has a
corresponding constant that may need flushing and we only ever write the
constant with glProgramLocalParameter4fv if that's set.

https://bugzilla.gnome.org/show_bug.cgi?id=658092

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-09-09 14:40:48 +01:00
Robert Bragg
b5a7657076 Starts porting Cogl conformance tests from Clutter
This makes a start on porting the Cogl conformance tests that currently
still live in the Clutter repository to be standalone Cogl tests that no
longer require a ClutterStage.

The main thing is that this commit brings in is the basic testing
infrastructure we need, so now we can port more and more tests
incrementally.

Since the test suite wants a way to synchronize X requests/replies and
we can't simply call XSynchronize in the test-utils code before we know
if we are really running on X this adds a check for an environment
variable named "COGL_X11_SYNC" in cogl-xlib-renderer.c and if it's set
it forces XSynchronize (dpy, TRUE) to be called.

By default the conformance tests are run off screen. This makes the
tests run much faster and they also don't interfere with other work you
may want to do by constantly stealing focus. CoglOnscreen framebuffers
obviously don't get tested this way so it's important that the tests
also get run on screen every once in a while, especially if changes are
being made to CoglFramebuffer related code.  On screen testing can be
enabled by setting COGL_TEST_ONSCREEN=1 in your environment.
2011-09-08 15:48:07 +01:00
Chun-wei Fan
a1d869384e Fix typo in cogl/cogl-display.h
The line "#define cogl_display_get_rendrer cogl_display_get_rendrer_EXP"
should read
"#define cogl_display_get_renderer cogl_display_get_renderer_EXP"...

https://bugzilla.gnome.org/show_bug.cgi?id=658333

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-09-06 11:19:20 +01:00
Robert Bragg
191d915671 framebuffer: Add a getter for the framebuffer format
This adds a new function, cogl_framebuffer_get_color_format() to be able
to query the common pixel format for any color buffers attached to a
given CoglFramebuffer. For example an offscreen framebuffer created
using cogl_offscreen_new_to_texture() would have a format matching the
texture.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-09-05 19:02:05 +01:00
Robert Bragg
476ff37fa6 display: always ensure we have an onscreen_template
If the user doesn't explicitly pass an onscreen template then instead of
leaving display->onscreen_template as NULL we now instantiate a template
ourselves. This simplifies winsys code that might want to refer to the
template since it needn't first check for a NULL pointer.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-09-05 19:02:05 +01:00
Robert Bragg
21e87a9bf0 texture-2d: move #defines before gtk-doc
All our experimental Cogl symbols have a corresponding #define to add
"_EXP" to the end of the symbol name, but those defines are often
positioned right after the corresponding gtk-doc comment and before
the symbol definition which means the generated documentation ends up
refering to the define and not the real definition. This tidies up
cogl-texture-2d.h and moves all the defines to be be before the gtk-doc
comments.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-09-05 19:02:05 +01:00
Neil Roberts
e7f374d799 cogl-pipeline-fragend-glsl: Cache the results of texture lookups
Whenever a texture lookup is performed for a layer the result is now
stored in a variable and used repeatedly instead of generating the
code for the lookup every time it is accessed. This means for example
when using the INTERPOLATE function with a texture lookup for the
third parameter it will only generate one texture lookup instead of
two.

https://bugzilla.gnome.org/show_bug.cgi?id=656426

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-05 19:02:04 +01:00
Neil Roberts
769c8472dd fragend-glsl: Don't generate code for ignored layers
This patch changes it so that code for each layer is generated on
demand instead of directly in the add_layer implementation. The
pipeline only explicitly generates code for the last layer. If this
layer references the result from any other layers, these will also be
recursively generated. This means that if a layer is using 'REPLACE'
then it won't redundantly generate the code for the previous
layers.

The result for each layer is generated into a variable called layer%i
where %i is the layer index (not the unit index). Therefore to get the
result from layer n we just have to refer to the varible layern.

https://bugzilla.gnome.org/show_bug.cgi?id=656426

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-05 19:02:04 +01:00
Neil Roberts
503f138fb6 texture: Call _cogl_texture_prepare_for_upload in set_region impl
Instead of calling _cogl_texutre_prepare_for_upload in
cogl_texture_set_region_from_bitmap the call is now deferred to the
implementation of the virtual for set_region. This is needed if the
texture backend is using a different format for the actual GL texture
than what is reported by cogl_texture_get_format. This happens for
example with atlas textures which report the original internal format
specified when the texture was created but actually always store the
data in an RGBA texture.

Also when creating an atlas texture from a bitmap it was preparing the
bitmap to be uploaded to the original format instead of the format of
the actual texture used for the atlas. Then it was using
cogl_texture_set_region_from_bitmap to upload the 5 pieces to make the
copies of the edge pixels. This would end up converting the image to
the actual format 5 times. The atlas textures have now been changed to
prepare the bitmap for the right format.

https://bugzilla.gnome.org/show_bug.cgi?id=657840

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-05 19:02:04 +01:00
Robert Bragg
9b56ce4d5b blend-strings: Make braces around blend factor optional
for a blend string like:
"RGBA=ADD(SRC_COLOR, SRC_COLOR * (DST_COLOR[A]))"
it was awkward that we were requiring developers to explicitly put
redundant brackets around the DST_COLOR[A] blend factor. The parser has
been updated so now braces are only required for factors like
"(1-SRC_COLOR[A])"

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-09-05 17:54:46 +01:00
Damien Lespiau
c36652a4c3 renderer: Add cogl_renderer_get_n_fragment_texture_units()
Add a method on the renderer to know how many texture image units are
accessible from fragment shaders.

https://bugzilla.gnome.org/show_bug.cgi?id=657347

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-05 17:54:46 +01:00
Damien Lespiau
6a2e21183c display: Add an accessor to get the renderer out of a display
https://bugzilla.gnome.org/show_bug.cgi?id=657347

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-05 17:54:46 +01:00
Damien Lespiau
6584c183f0 context: Add an accessor to get display associated with the context
https://bugzilla.gnome.org/show_bug.cgi?id=657347

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-05 17:54:46 +01:00
Damien Lespiau
4e1d08d59e pipeline: Remove unsused get_max_texture_image_units()
This function was not used in the opengl pipeline, probably because of
the more precise get_max_activable_texture_units().

Remove it then.

https://bugzilla.gnome.org/show_bug.cgi?id=657347

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-05 17:54:46 +01:00
Robert Bragg
f37d9bbb4d matrix: Add cogl_matrix_look_at
Similar to the widely used gluLookAt API, this adds a CoglMatrix utility
for setting up a view transform in terms of positioning a camera/eye
position that points to a given object position aligned to a given
world-up vector.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-08-12 15:28:44 +01:00
Robert Bragg
3a2f94045e framebuffer: make _swap_region coords top-left relative
Cogl aims to consistently put the origin of 2D objects at the top-left
instead of the bottom left as OpenGL does, but there was an oversight
and the experimental cogl_framebuffer_swap_region API was accepting
coordinates relative to the bottom left. Cogl will now flip the user's
given rectangles to be relative to the bottom of the framebufffer before
sending them to APIs like glXCopySubBuffer and glBlitFramebuffer.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-08-12 15:28:43 +01:00
Robert Bragg
8e8690a562 framebuffer: lazily allocate framebuffers as needed
If the user doesn't explicitly allocate a CoglFramebuffer then Cogl
should automatically allocate the framebuffer when the user starts to
draw to the framebuffer. So this way calling cogl_framebuffer_allocate
is only required if you are explicitly interested in checking for and
gracefully handling failures to allocate a framebuffer. If automatic
allocation fails then application behaviour becomes undefined.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-08-12 15:28:43 +01:00
Robert Bragg
a3ad808f57 framebuffer: Make framebuffer_clear APIs public experimental
This makes cogl_framebuffer_clear and cogl_framebuffer_clear4f public as
experimental API. Since these functions take explicit framebuffer
pointers you don't need to push/pop a framebuffer just to clear it. Also
these functions are implicitly tied to a specific CoglContext via the
framebuffer pointer unlike cogl_clear.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-08-12 15:28:43 +01:00
Robert Bragg
f7b1bab1ad framebuffer: don't reference default fb in _clear apis
Some of the functions we were calling in cogl_framebuffer_clear[4f] were
referring to the current framebuffer, which would result in a crash
if nothing had been pushed before trying to explicitly clear a given
framebuffer.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-08-12 15:28:43 +01:00
Robert Bragg
19d12e65e5 framebuffer: avoid redundant calls to _init_bits
There is no need to call _cogl_framebuffer_init_bits for the draw and
read buffers each time we flush the framebuffer state since we will
always re-sync with gl if necessary when the
cogl_framebuffer_get_red/green/blue/alpha_bits functions are called.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-08-12 15:28:43 +01:00
Robert Bragg
64b2bbab84 framebuffer: Adds a context getter for CoglFramebuffer
This adds a function to query what CoglContext a given framebuffer
belongs too. This can be useful if you pass framebuffer pointers around
and at some point you want to create another framebuffer as part of the
same context as a given framebuffer without assuming there is a single
default context.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-08-12 15:28:43 +01:00