2009-09-16 13:01:57 +00:00
|
|
|
/*
|
|
|
|
* 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
|
2010-03-01 12:56:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*
|
2009-09-16 13:01:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __COGL_JOURNAL_PRIVATE_H
|
|
|
|
#define __COGL_JOURNAL_PRIVATE_H
|
|
|
|
|
2012-02-25 20:04:45 +00:00
|
|
|
#include "cogl-texture.h"
|
2012-04-16 13:14:10 +00:00
|
|
|
#include "cogl-object-private.h"
|
2010-11-02 17:35:17 +00:00
|
|
|
#include "cogl-clip-stack.h"
|
2013-01-11 01:13:34 +00:00
|
|
|
#include "cogl-fence-private.h"
|
2009-09-16 13:01:57 +00:00
|
|
|
|
2011-06-01 13:30:45 +00:00
|
|
|
#define COGL_JOURNAL_VBO_POOL_SIZE 8
|
|
|
|
|
2011-01-06 13:25:45 +00:00
|
|
|
typedef struct _CoglJournal
|
|
|
|
{
|
|
|
|
CoglObject _parent;
|
|
|
|
|
2012-01-24 18:16:03 +00:00
|
|
|
/* A pointer the framebuffer that is using this journal. This is
|
|
|
|
only valid when the journal is not empty. It *does* take a
|
|
|
|
reference on the framebuffer. Although this creates a circular
|
|
|
|
reference, the framebuffer has special code to handle the case
|
|
|
|
where the journal is the only thing holding a reference and it
|
|
|
|
will cause the journal to flush */
|
|
|
|
CoglFramebuffer *framebuffer;
|
|
|
|
|
2011-01-06 13:25:45 +00:00
|
|
|
GArray *entries;
|
|
|
|
GArray *vertices;
|
|
|
|
size_t needed_vbo_len;
|
|
|
|
|
2011-06-01 13:30:45 +00:00
|
|
|
/* A pool of attribute buffers is used so that we can avoid repeatedly
|
|
|
|
reallocating buffers. Only one of these buffers at a time will be
|
|
|
|
used by Cogl but we keep more than one alive anyway in case the
|
|
|
|
GL driver is internally using the buffer and it would have to
|
|
|
|
allocate a new one when we start writing to it */
|
|
|
|
CoglAttributeBuffer *vbo_pool[COGL_JOURNAL_VBO_POOL_SIZE];
|
|
|
|
/* The next vbo to use from the pool. We just cycle through them in
|
|
|
|
order */
|
|
|
|
unsigned int next_vbo_in_pool;
|
|
|
|
|
2011-01-12 22:12:41 +00:00
|
|
|
int fast_read_pixel_count;
|
|
|
|
|
2013-01-11 01:13:34 +00:00
|
|
|
CoglFenceList pending_fences;
|
|
|
|
|
2011-01-06 13:25:45 +00:00
|
|
|
} CoglJournal;
|
|
|
|
|
2009-09-16 13:01:57 +00:00
|
|
|
/* To improve batching of geometry when submitting vertices to OpenGL we
|
|
|
|
* log the texture rectangles we want to draw to a journal, so when we
|
|
|
|
* later flush the journal we aim to batch data, and gl draw calls. */
|
|
|
|
typedef struct _CoglJournalEntry
|
|
|
|
{
|
2010-10-27 17:54:57 +00:00
|
|
|
CoglPipeline *pipeline;
|
Re-design the matrix stack using a graph of ops
This re-designs the matrix stack so we now keep track of each separate
operation such as rotating, scaling, translating and multiplying as
immutable, ref-counted nodes in a graph.
Being a "graph" here means that different transformations composed of
a sequence of linked operation nodes may share nodes.
The first node in a matrix-stack is always a LOAD_IDENTITY operation.
As an example consider if an application where to draw three rectangles
A, B and C something like this:
cogl_framebuffer_scale (fb, 2, 2, 2);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_translate (fb, 10, 0, 0);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_rotate (fb, 45, 0, 0, 1);
cogl_framebuffer_draw_rectangle (...); /* A */
cogl_framebuffer_pop_matrix(fb);
cogl_framebuffer_draw_rectangle (...); /* B */
cogl_framebuffer_pop_matrix(fb);
cogl_framebuffer_push_matrix(fb);
cogl_framebuffer_set_modelview_matrix (fb, &mv);
cogl_framebuffer_draw_rectangle (...); /* C */
cogl_framebuffer_pop_matrix(fb);
That would result in a graph of nodes like this:
LOAD_IDENTITY
|
SCALE
/ \
SAVE LOAD
| |
TRANSLATE RECTANGLE(C)
| \
SAVE RECTANGLE(B)
|
ROTATE
|
RECTANGLE(A)
Each push adds a SAVE operation which serves as a marker to rewind too
when a corresponding pop is issued and also each SAVE node may also
store a cached matrix representing the composition of all its ancestor
nodes. This means if we repeatedly need to resolve a real CoglMatrix
for a given node then we don't need to repeat the composition.
Some advantages of this design are:
- A single pointer to any node in the graph can now represent a
complete, immutable transformation that can be logged for example
into a journal. Previously we were storing a full CoglMatrix in
each journal entry which is 16 floats for the matrix itself as well
as space for flags and another 16 floats for possibly storing a
cache of the inverse. This means that we significantly reduce
the size of the journal when drawing lots of primitives and we also
avoid copying over 128 bytes per entry.
- It becomes much cheaper to check for equality. In cases where some
(unlikely) false negatives are allowed simply comparing the pointers
of two matrix stack graph entries is enough. Previously we would use
memcmp() to compare matrices.
- It becomes easier to do comparisons of transformations. By looking
for the common ancestry between nodes we can determine the operations
that differentiate the transforms and use those to gain a high level
understanding of the differences. For example we use this in the
journal to be able to efficiently determine when two rectangle
transforms only differ by some translation so that we can perform
software clipping.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit f75aee93f6b293ca7a7babbd8fcc326ee6bf7aef)
2012-02-20 15:59:48 +00:00
|
|
|
CoglMatrixEntry *modelview_entry;
|
2010-11-02 17:35:17 +00:00
|
|
|
CoglClipStack *clip_stack;
|
2010-11-09 19:18:37 +00:00
|
|
|
/* Offset into ctx->logged_vertices */
|
|
|
|
size_t array_offset;
|
2013-01-10 14:21:04 +00:00
|
|
|
int n_layers;
|
2009-09-16 13:01:57 +00:00
|
|
|
} CoglJournalEntry;
|
|
|
|
|
2011-01-06 13:25:45 +00:00
|
|
|
CoglJournal *
|
2012-03-16 17:26:30 +00:00
|
|
|
_cogl_journal_new (CoglFramebuffer *framebuffer);
|
2011-01-06 13:25:45 +00:00
|
|
|
|
2009-09-16 13:01:57 +00:00
|
|
|
void
|
2011-01-06 13:25:45 +00:00
|
|
|
_cogl_journal_log_quad (CoglJournal *journal,
|
|
|
|
const float *position,
|
2010-10-27 17:54:57 +00:00
|
|
|
CoglPipeline *pipeline,
|
2009-09-16 13:01:57 +00:00
|
|
|
int n_layers,
|
2011-08-24 20:30:34 +00:00
|
|
|
CoglTexture *layer0_override_texture,
|
2009-12-02 17:17:24 +00:00
|
|
|
const float *tex_coords,
|
2009-09-16 13:01:57 +00:00
|
|
|
unsigned int tex_coords_len);
|
|
|
|
|
2010-02-10 18:18:30 +00:00
|
|
|
void
|
2012-03-16 17:26:30 +00:00
|
|
|
_cogl_journal_flush (CoglJournal *journal);
|
2010-02-10 18:18:30 +00:00
|
|
|
|
2011-01-12 22:12:41 +00:00
|
|
|
void
|
|
|
|
_cogl_journal_discard (CoglJournal *journal);
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
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)
2012-04-16 20:56:40 +00:00
|
|
|
CoglBool
|
2011-01-12 22:12:41 +00:00
|
|
|
_cogl_journal_all_entries_within_bounds (CoglJournal *journal,
|
|
|
|
float clip_x0,
|
|
|
|
float clip_y0,
|
|
|
|
float clip_x1,
|
|
|
|
float clip_y1);
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
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)
2012-04-16 20:56:40 +00:00
|
|
|
CoglBool
|
2011-01-12 22:12:41 +00:00
|
|
|
_cogl_journal_try_read_pixel (CoglJournal *journal,
|
|
|
|
int x,
|
|
|
|
int y,
|
2012-02-25 19:23:51 +00:00
|
|
|
CoglBitmap *bitmap,
|
Switch use of primitive glib types to c99 equivalents
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)
2012-04-16 20:56:40 +00:00
|
|
|
CoglBool *found_intersection);
|
2011-01-12 22:12:41 +00:00
|
|
|
|
Switch use of primitive glib types to c99 equivalents
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)
2012-04-16 20:56:40 +00:00
|
|
|
CoglBool
|
2012-03-06 18:21:28 +00:00
|
|
|
_cogl_is_journal (void *object);
|
|
|
|
|
2009-09-16 13:01:57 +00:00
|
|
|
#endif /* __COGL_JOURNAL_PRIVATE_H */
|