Comparing the pointed-to value is clearly what was meant.
Found by Coverity.
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit f676352210fad856ae85962733e488bc1a832411)
textures[iter_y.index * n_y_spans + iter_x.index]
only works for vertical rectangles when n_x_spans > 0 (ie x != {0} )
is also wrong for horizontal rectangles ( x = {0, 1, 2, 3} , y = {0, 1}
-> second line will start at 2 = iter_y.index * n_y_spans + iter_x.index
-> iteration are 0, 1, 2, 3, \n 2, 3, 4, 5 instead of 0, 1, 2, 3 \n 4, 5, 6, 7
Reviewed-by: Robert Bragg <robert@linux.inte.com>
(cherry picked from commit bf0d187f1b5423b9ce1281aab1333fa2dfb9863f)
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
This option to GCC makes it give a warning whenever a global function
is defined without a declaration. This should catch cases were we've
defined a function but forgot to put it in a header. In that case it
is either only used within one file so we should make it static or we
should declare it in a header.
The following changes where made to fix problems:
• Some functions were made static
• cogl-path.h (the one containing the 1.0 API) was split into two
files, one defining the functions and one defining the enums so that
cogl-path.c can include the enum and function declarations from the
2.0 API as well as the function declarations from the 1.0 API.
• cogl2-clip-state has been removed. This only had one experimental
function called cogl_clip_push_from_path but as this is unstable we
might as well remove it favour of the equivalent cogl_framebuffer_*
API.
• The GLX, SDL and WGL winsys's now have a private header to define
their get_vtable function instead of directly declaring in the C
file where it is called.
• All places that were calling COGL_OBJECT_DEFINE need to have the
cogl_is_whatever function declared so these have been added either
as a public function or in a private header.
• Some files that were not including the header containing their
function declarations have been fixed to do so.
• Any unused error quark functions have been removed. If we later want
them we should add them back one by one and add a declaration for
them in a header.
• _cogl_is_framebuffer has been renamed to cogl_is_framebuffer and
made a public function with a declaration in cogl-framebuffer.h
• Similarly for CoglOnscreen.
• cogl_vdraw_indexed_attributes is called
cogl_framebuffer_vdraw_indexed_attributes in the header. The
definition has been changed to match the header.
• cogl_index_buffer_allocate has been removed. This had no declaration
and I'm not sure what it's supposed to do.
• CoglJournal has been changed to use the internal CoglObject macro so
that it won't define an exported cogl_is_journal symbol.
• The _cogl_blah_pointer_from_handle functions have been removed.
CoglHandle isn't used much anymore anyway and in the few places
where it is used I think it's safe to just use the implicit cast
from void* to the right type.
• The test-utils.h header for the conformance tests explicitly
disables the -Wmissing-declaration option using a pragma because all
of the tests declare their main function without a header. Any
mistakes relating to missing declarations aren't really important
for the tests.
• cogl_quaternion_init_from_quaternion and init_from_matrix have been
given declarations in cogl-quaternion.h
Reviewed-by: Robert Bragg <robert@linux.intel.com>
cogl_meta_texture_foreach_in_region() now directly supports
CLAMP_TO_EDGE wrap modes. This means the cogl_rectangle code will be
able to build on this and makes the logic accessible to anyone
developing custom primitives that need to support meta textures.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This exposes CoglTextureRectangle in the experimental cogl 2.0 api. For
now we just expose a single constructor;
cogl_texture_rectangle_new_with_size() but we can add more later.
This is part of going work to improve our texture apis with more
emphasis on providing low-level access to the varying semantics of
different texture types understood by the gpu instead of only trying to
present a lowest common denominator api.
CoglTextureRectangle is notably useful for never being restricted to
power of two sizes and for being sampled with non-normalized texture
coordinates which can be convenient for use a lookup tables in glsl due
to not needing separate uniforms for mapping normalized coordinates to
texels. Unlike CoglTexture2D though rectangle textures can't have a
mipmap and they only support the _CLAMP_TO_EDGE wrap mode.
Applications wanting to use CoglTextureRectangle should first check
cogl_has_feature (COGL_FEATURE_ID_TEXTURE_RECTANGLE).
Reviewed-by: Neil Roberts <neil@linux.intel.com>
CoglMetaTexture is an interface for dealing with high level textures
that may be comprised of one or more low-level textures internally. The
interface allows the development of primitive drawing APIs that can draw
with high-level textures (such as atlas textures) even though the
GPU doesn't natively understand these texture types.
There is currently just one function that's part of this interface:
cogl_meta_texture_foreach_in_region() which allows an application to
resolve the internal, low-level textures of a high-level texture.
cogl_rectangle() uses this API for example so that it can easily emulate
the _REPEAT wrap mode for textures that the hardware can't natively
handle repeating of.
Reviewed-by: Neil Roberts <neil@linux.intel.com>