This updates some of the cogl.h cogl_clip_ API documentation to make it
consistent with the documentation for corresponding framebuffer clip
stack API in cogl-framebuffer.h
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This adds CoglFramebuffer methods for accessing the clip stack. We plan
on making some optimizations to how framebuffer state is flushed which
will require us to track when a framebuffer's clip state has changed.
This api also ties in to the longer term goal of removing the need for a
default global CoglContext since these methods are all implicitly
related to a specific context via their framebuffer argument.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This ensures we don't touch a framebuffer's matrix stack directly if we
are also relying on _cogl_framebuffer_flush_state(). We want to get to
the point where we can set dirty flags against framebuffer state at the
point it changes but that means we can't allow direct access to the
matrix stack. _cogl_texture_draw_and_read() has now been changed so it
uses cogl_framebuffer_ methods to update the matrix stacks including
adding new internal _cogl_framebuffer_push/pop_projection() functions
that allow us to set transient projections.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This adds a cogl_framebuffer_identity_matrix() method that can be used
to reset the current modelview matrix to the identity matrix.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This updates the cogl.h matrix stack documentation consistent with the
corresponding documentation in cogl-framebuffer.h for the framebuffer
matrix stack methods.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This adds cogl_framebuffer_ methods to update the modelview and
projection matrix stacks to replace functions like cogl_translate(),
cogl_rotate() and cogl_scale() etc.
This is part of the on-going effort to get rid of the global CoglContext
pointer since the existing methods don't take an explicit pointer to a
CoglContext. All the methods are now related to a context via the
framebuffer.
We added framebuffer methods instead of direct context methods because
the matrix stacks are per-framebuffer and as well as removing the global
CoglContext we would rather aim for a more direct state access API
design than, say, cairo or OpenGL, so we'd like to avoid needing the
cogl_push/pop_framebuffer(). We anticipate that Cogl will mostly be
consumed by middleware graphics layers such as toolkits or game engines
and feel that a more stateless model will avoid impedance mismatches if
higher levels want to expose a stateless model to their developers and
statefullness can still be added by higher levels if really desired.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This adds an experimental cogl_matrix_orthographic() function that is
more consistent with other Cogl api by taking x_1, y_1, x_2, y_2
arguments to define the top-left and bottom-right coordinates of the
orthographic coordinates instead of OpenGL style left, right, bottom and
top values.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This improves the documentation for cogl_texture_set_region() and
cogl_texture_set_region_from_bitmap() to explain that the region can't
be larger than the source data and also adds runtime assertions that
such a request isn't made.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
The documentation for CoglPipelineCullFaceMode had a repeated typo with
"called" being used instead of "culled" which this fixes.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
When saving the CRTC we were trying to use a struct member for the encoder
that wasn't valid at that point in time - instead use the local variable.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
_cogl_pipeline_init_multi_property_sparse_state was missing a break in
the case statement handling uniforms. This doesn't yet matter because
it is the last one handled anyway but it will bite someone later.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
We were missing various platform header includes in
cogl-winsys-egl-private.h when building support for non KMS egl
platforms.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
For example when building on windows we don't want to require EGL
headers when compiling cogl-renderer.c or cogl-texture-2d.c so we make
sure not to include cogl-winsys-egl-private.h if we aren't supporting
EGL.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
A small, pedantic change to remove the use of redundant gint and GLuint
types instead of int and unsigned int.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This adds a check for the EGL_KHR_surfaceless_opengl extension which we
depend on for being able to MakeCurrent (NO_SURFACE) as well as create a
context without and EGLConfig.
Reviewed-by: Rob Bradford <rob@linux.intel.com>
Since _cogl_winsys_kms_display_setup was basically just calling
setup_kms() it made sense to fold the code of setup_kms() back into the
_cogl_winsys_kms_display_setup() function.
Reviewed-by: Rob Bradford <rob@linux.intel.com>
So that the various internal Cogl*EGL typedefs can be available to
cogl-winsys-kms.c this moves them into cogl-winsys-egl-private.h
Reviewed-by: Rob Bradford <rob@linux.intel.com>
To start with this backend only supports creating a single CoglOnscreen
framebuffer and will automatically set is up to display fullscreen on
the first suitable crtc it can find.
To compile this backend - get some dribbly black candles, sacrifice a
goat and configure with: --enable-kms-egl-platform
Note: There is currently a problem with using GLES2 with this winsys
so you need to run with EGL_DRIVER=gl
Note: If you have problems with mesa crashing in XCB during
eglInitialize then you may need to explicitly run with EGL_PLATFORM=gbm
Reviewed-by: Robert Bragg <robert@linux.intel.com>
When building with MSVC, symbols to be exported that point to data
need to be marked with dllimport to be successfully imported. The
_cogl_debug_flags variable is currently exported because it is used
from cogl-pango. This patch adds a COGL_EXPORT macro to cogl-util.h
which is used in cogl-debug.h
Based on a patch by Chun-wei Fan
https://bugzilla.gnome.org/show_bug.cgi?id=650020
Reviewed-by: Robert Bragg <robert@linux.intel.com>
These are the VS 2008/2010 project files to build Cogl, with a README.txt
to explain the process involved.
Note that the Cogl and Cogl-Pango projects (and filters for VS2010) are
expanded with the correct source file listings during "make dist", which
is done to simplify maintenance of these project files.
-added preconfigured config.h(.win32.in), which is expanded with the
correct versioining info during autogen
-added preconfigued cogl/cogl-defines.h.win32
-added symbols files for cogl and cogl-pango
-Have configure.ac expand the config.h.win32.in into config.h.win32
with the correct versioning info, etc, and to include the Visual C++
project files for distribution
-Added rules in cogl/Makefile.am to expand the cogl VS 2008/2010 projects
and filters from the templates with up-to-date source file listings, to
distribute cogl-enum-types.c, cogl-enum-types.h to ease compilation and
to avoid depending on PERL on Windows installations.
-Added rules in cogl-pango/Makefile.am to expand the cogl-pango VS2008/
2010 projects and filters from the templates with up-to-date source file
listings.
-Added/edited various Makefile.am's in build to distribute the VS2008/2010
project files and associated items required for the build.
-Update .gitignore. There needs to be a pre-configured
config.h(.win32) and its template, config.h.win32.in for Visual C++
builds
https://bugzilla.gnome.org/show_bug.cgi?id=650020
Reviewed-by: Neil Roberts <neil@linux.intel.com>
When comparing uniform values, it was not correctly handling the case
where pipeline0 has the value set but pipeline1 does not (only the
other way around) so it would crash.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Deal with c99ism... I know it's not pretty, but it is the way
to go with non-c99 compilers. That's life...
Reviewed-by: Neil Roberts <neil@linux.intel.com>
Reviewed-by: Robert Bragg <robert@linux.intel.com>
When the flags contain a value that only has the most-significant bit
set then ffsl will return the size of an unsigned long. According to
the C spec it is undefined what happens when shifting by a number
greater than or equal to the size of the left operand. On Intel (and
probably others) this seems to end up being a no-op so the iteration
breaks. To fix this we can split the shift into two separate
shifts. We always need to shift by at least one bit so we can put this
one bit shift into a separate operator.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
The uniform names are now stored in a GPtrArray instead of a linked
list. There is also a hash table to speed up converting names to
locations.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Previously the uniform overrides were stored in a linked list. Now
they are stored in a g_malloc'd array. The values are still tightly
packed so that there is only a value for each uniform that has a
corresponding bit in override_mask. The allocated size of the array
always exactly corresponds to the number of bits set in the
override_mask. This means that when a new uniform value is set on a
pipeline it will have to grow the array and copy the old values
in. The assumption is that setting a value for a new uniform is much
less frequent then setting a value for an existing uniform so it makes
more sense to optimise the latter.
The advantage of using an array is that we can quickly jump to right
boxed value given a uniform location by doing a population count in
the bitmask for the number of bits less than the given uniform
location. This can be done in O(1) time whereas the old approach using
a list would scale by the number of bits set.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This returns a population count of all the bits that are set in the
bitmask.
There is now also a _cogl_bitmask_popcount_upto which counts the
number of bits set up to but not including the given bit index. This
will be useful to determine the number of uniform overrides to skip if
we tightly pack the values in an array.
The test-bitmask test has been modified to check these two functions.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This adds the following new public experimental functions to set
uniform values on a CoglPipeline:
void
cogl_pipeline_set_uniform_1f (CoglPipeline *pipeline,
int uniform_location,
float value);
void
cogl_pipeline_set_uniform_1i (CoglPipeline *pipeline,
int uniform_location,
int value);
void
cogl_pipeline_set_uniform_float (CoglPipeline *pipeline,
int uniform_location,
int n_components,
int count,
const float *value);
void
cogl_pipeline_set_uniform_int (CoglPipeline *pipeline,
int uniform_location,
int n_components,
int count,
const int *value);
void
cogl_pipeline_set_uniform_matrix (CoglPipeline *pipeline,
int uniform_location,
int dimensions,
int count,
gboolean transpose,
const float *value);
These are similar to the old functions used to set uniforms on a
CoglProgram. To get a value to pass in as the uniform_location there
is also:
int
cogl_pipeline_get_uniform_location (CoglPipeline *pipeline,
const char *uniform_name);
Conceptually the uniform locations are tied to the pipeline so that
whenever setting a value for a new pipeline the application is
expected to call this function. However in practice the uniform
locations are global to the CoglContext. The names are stored in a
linked list where the position in the list is the uniform location.
The global indices are used so that each pipeline can store a mask of
which uniforms it overrides. That way it is quicker to detect which
uniforms are different from the last pipeline that used the same
CoglProgramState so it can avoid flushing uniforms that haven't
changed. Currently the values are not actually compared which means
that it will only avoid flushing a uniform if there is a common
ancestor that sets the value (or if the same pipeline is being flushed
again - in which case the pipeline and its common ancestor are the
same thing).
The uniform values are stored in the big state of the pipeline as a
sparse linked list. A bitmask stores which values have been overridden
and only overridden values are stored in the linked list.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This adds a _cogl_bitmask_set_flags function which can be used to copy
the values from a CoglBitmask to an array of unsigned longs which can
be used with the COGL_FLAGS_* macros. The values are or'd in so that
in can be used multiple times to combine multiple bitmasks.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This moves the POPCOUNTL macro from cogl-winsys-glx to cogl-util and
renames it to _cogl_util_popcountl so that it can be used in more
places. The fallback function for when the GCC builtin is not
available has been replaced with an 8-bit lookup table because the
HAKMEM implementation doesn't look like it would work when longs are
64-bit so it's not suitable for a general purpose function on 64-bit
architectures. Some of the pages regarding population counts seem to
suggest that using a lookup table is the fastest method anyway.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This adds a function to copy one boxed value to another. It is assumed
that the destination boxed value is totally initialised (so it won't
try to free any memory in it).
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This wraps all of the calls to glUniform* in the GE() macro so that it
will detect GL errors in the right place.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
The code for manipulating CoglBoxedValues is now separated from
cogl-program.c into its own file. That way when we add support for
setting uniform values on a CoglPipeline the code for storing the
values can be shared.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This adds some macros to iterate over all the bits set in an array of
flags. The macros are a bit awkward because it tries to avoid using a
callback pointer so that the code is inlined.
cogl_bitmask is now using these macros as well so that the logic can
be shared.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Previously cogl-flags was using an array of ints to store the
flags. There was a comment saying that it would be nice to use longs
but this is awkward because g_parse_debug_flags can only work in
ints. This is a silly reason not to use longs because we can just
parse multiple sets of flags per long. This patch therefore changes
cogl-flags to use longs and tweaks the debug key parsing code.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Instead of testing each bit when iterating a bitmask, we can use ffsl
to skip over unset bits in single instruction. That way it will scale
by the number of bits set, not the total number of bits.
ffsl is a non-standard function which glibc only provides by defining
GNUC_SOURCE. However if we are compiling with GCC we can avoid that
mess and just use the equivalent builtin. When not compiling for GCC
it will fall back to _cogl_util_ffs if the size of ints and longs are
the same (which is the case on i686). Otherwise it fallbacks to a slow
function implementation.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
The boilerplate for defining a GType for CoglFixed lived in
cogl-util.c but this didn't seem to make much sense seeing as nothing
in the cogl-util.h header file relates to CoglFixed and there is
already a separate C file for CoglFixed code. This also removes some
redundant header includes from cogl-util.c
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Instead of storing only 31 bits in the pointer for a CoglBitmask, it
now assumes it can store a whole unsigned long minus the one bit used
to mark whether it has been converted to a GArray or not. This works
on the assumption that we can cast an unsigned long to a pointer and
back without losing information which I think should be true for any
platforms that Cogl is interested in. This has the advantage that on
64-bit architectures we can store 63 bits before we have to resort to
using a GArray at no extra cost. The values in the GArray are now
stored as unsigned longs as well on the assumption that it is more
efficient to load and store data in chunks of longs rather than ints.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Cogl keeps a pointer to the last used onscreen framebuffer from the
context to implement the deprecated cogl_set_draw_buffer function
which can take COGL_WINDOW_BUFFER as the target to use the last
onscreen buffer. Previously this would also take a reference to that
pointer. However that was causing a circular reference between the
framebuffer and the context which makes it impossible to clean up
resources properly when onscreen buffers are used. This patch instead
changes it to just store the pointer and then clear the pointer during
_cogl_onscreen_free as a kind of cheap weak reference.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This adds two new experimental public functions to replace the old
internal _cogl_pipeline_set_cull_face_state function:
void
cogl_pipeline_set_cull_face_mode (CoglPipeline *pipeline,
CoglPipelineCullFaceMode cull_face_mode);
void
cogl_pipeline_set_front_face_winding (CoglPipeline *pipeline,
CoglWinding front_winding);
There are also the corresponding getters.
https://bugzilla.gnome.org/show_bug.cgi?id=663628
Reviewed-by: Robert Bragg <robert@linux.intel.com>
cogl-utils.h needs to include cogl-defines.h so that it knows whether
COGL_HAS_GLIB_SUPPORT is defined.
https://bugzilla.gnome.org/show_bug.cgi?id=663578
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
This patch moves the call to _cogl_destroy_texture_units() from
_cogl_context_free() to later on. When destroying a GL texture the
texture units are checked. This would end up accessing invalid memory
so we need to try to destroy the texture units only after everything
that might be referencing a texture has been destroyed.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Although there was a comment in cogl_texture_2d_copy_from_framebuffer
explaining that we shouldn't flush the clip state, the comment was a bit
miss-leading implying we were going to explicitly set a NULL clip. Also
we weren't actually avoiding flushing the clip state since we were
passing 0 for the CoglDrawFlags.
We now pass COGL_FRAMEBUFFER_FLUSH_SKIP_CLIP_STATE in to the flags when
flushing the framebuffer state and the comment has be updated to explain
that clipping won't affect reading from the framebuffer so we don't need
to flush it.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This api is deprecated and documented to be a NOP which wasn't actually
true. This patch actually updates the function to be a NOP. Its nice
that this gets rid of a point where we flush framebuffer state because
we are looking to add a new VirtualFramebuffer interface which will need
special consideration at each of the points we flush framebuffer state.
It was a mistake that this API was ever published, we don't believe
anyone is using the api but until we break api we have to keep the
symbol. The documented semantics are vague enough that a NOP is ok since
we never explicitly documented how the state would be flushed to GL so
there would be no way to reliably use that state anyway.
Reviewed-by: Neil Roberts <neil@linux.intel.com>