mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 00:20:42 -05:00
f005f517fe
Previously flushing the matrices was performed as part of the framebuffer state. When on GLES2 this matrix flushing is actually diverted so that it only keeps a reference to the intended matrix stack. This is necessary because on GLES2 there are no builtin uniforms so it can't actually flush the matrices until the program for the pipeline is generated. When the matrices are flushed it would store the age of modifications on the matrix stack so that it could detect when the matrix hasn't changed and avoid flushing it. This patch changes it so that the pipeline is responsible for flushing the matrices even when we are using the GL builtins. The same mechanism for detecting unmodified matrix stacks is used in all cases. There is a new CoglMatrixStackCache type which is used to store a reference to the intended matrix stack along with its last flushed age. There are now two of these attached to the CoglContext to track the flushed state for the global matrix builtins and also two for each glsl progend program state to track the flushed state for a program. The framebuffer matrix flush now just updates the intended matrix stacks without actually trying to flush. When a vertex snippet is attached to the pipeline, the GLSL vertend will now avoid using the projection matrix to flip the rendering. This is necessary because any vertex snippet may cause the projection matrix not to be used. Instead the flip is done as a forced final step by multiplying cogl_position_out by a vec4 uniform. This uniform is updated as part of the progend pre_paint depending on whether the framebuffer is offscreen or not. Reviewed-by: Robert Bragg <robert@linux.intel.com>
151 lines
4.6 KiB
C
151 lines
4.6 KiB
C
/*
|
|
* Cogl
|
|
*
|
|
* An object oriented GL/GLES Abstraction/Utility Layer
|
|
*
|
|
* Copyright (C) 2009,2010 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, see
|
|
* <http://www.gnu.org/licenses/>.
|
|
*
|
|
*
|
|
*
|
|
* Authors:
|
|
* Havoc Pennington <hp@pobox.com> for litl
|
|
* Robert Bragg <robert@linux.intel.com>
|
|
*/
|
|
|
|
#ifndef __COGL_MATRIX_STACK_H
|
|
#define __COGL_MATRIX_STACK_H
|
|
|
|
#include "cogl-matrix.h"
|
|
#include "cogl-context.h"
|
|
|
|
typedef struct _CoglMatrixStack CoglMatrixStack;
|
|
|
|
typedef struct
|
|
{
|
|
CoglMatrixStack *stack;
|
|
unsigned int age;
|
|
gboolean flushed_identity;
|
|
gboolean flipped;
|
|
} CoglMatrixStackCache;
|
|
|
|
typedef enum {
|
|
COGL_MATRIX_MODELVIEW,
|
|
COGL_MATRIX_PROJECTION,
|
|
COGL_MATRIX_TEXTURE
|
|
} CoglMatrixMode;
|
|
|
|
typedef void (* CoglMatrixStackFlushFunc) (CoglContext *context,
|
|
gboolean is_identity,
|
|
const CoglMatrix *matrix,
|
|
void *user_data);
|
|
|
|
CoglMatrixStack *
|
|
_cogl_matrix_stack_new (void);
|
|
|
|
void
|
|
_cogl_matrix_stack_push (CoglMatrixStack *stack);
|
|
|
|
void
|
|
_cogl_matrix_stack_pop (CoglMatrixStack *stack);
|
|
|
|
void
|
|
_cogl_matrix_stack_load_identity (CoglMatrixStack *stack);
|
|
|
|
void
|
|
_cogl_matrix_stack_scale (CoglMatrixStack *stack,
|
|
float x,
|
|
float y,
|
|
float z);
|
|
void
|
|
_cogl_matrix_stack_translate (CoglMatrixStack *stack,
|
|
float x,
|
|
float y,
|
|
float z);
|
|
void
|
|
_cogl_matrix_stack_rotate (CoglMatrixStack *stack,
|
|
float angle,
|
|
float x,
|
|
float y,
|
|
float z);
|
|
void
|
|
_cogl_matrix_stack_multiply (CoglMatrixStack *stack,
|
|
const CoglMatrix *matrix);
|
|
void
|
|
_cogl_matrix_stack_frustum (CoglMatrixStack *stack,
|
|
float left,
|
|
float right,
|
|
float bottom,
|
|
float top,
|
|
float z_near,
|
|
float z_far);
|
|
void
|
|
_cogl_matrix_stack_perspective (CoglMatrixStack *stack,
|
|
float fov_y,
|
|
float aspect,
|
|
float z_near,
|
|
float z_far);
|
|
void
|
|
_cogl_matrix_stack_ortho (CoglMatrixStack *stack,
|
|
float left,
|
|
float right,
|
|
float bottom,
|
|
float top,
|
|
float z_near,
|
|
float z_far);
|
|
gboolean
|
|
_cogl_matrix_stack_get_inverse (CoglMatrixStack *stack,
|
|
CoglMatrix *inverse);
|
|
void
|
|
_cogl_matrix_stack_get (CoglMatrixStack *stack,
|
|
CoglMatrix *matrix);
|
|
void
|
|
_cogl_matrix_stack_set (CoglMatrixStack *stack,
|
|
const CoglMatrix *matrix);
|
|
|
|
void
|
|
_cogl_matrix_stack_flush_to_gl_builtins (CoglContext *ctx,
|
|
CoglMatrixStack *stack,
|
|
CoglMatrixMode mode,
|
|
gboolean disable_flip);
|
|
|
|
unsigned int
|
|
_cogl_matrix_stack_get_age (CoglMatrixStack *stack);
|
|
|
|
/* If this returns TRUE then the top of the matrix is definitely the
|
|
identity matrix. If it returns FALSE it may or may not be the
|
|
identity matrix but no expensive comparison is performed to verify
|
|
it. */
|
|
gboolean
|
|
_cogl_matrix_stack_has_identity_flag (CoglMatrixStack *stack);
|
|
|
|
gboolean
|
|
_cogl_matrix_stack_equal (CoglMatrixStack *stack0,
|
|
CoglMatrixStack *stack1);
|
|
|
|
void
|
|
_cogl_matrix_stack_init_cache (CoglMatrixStackCache *cache);
|
|
|
|
gboolean
|
|
_cogl_matrix_stack_check_and_update_cache (CoglMatrixStack *stack,
|
|
CoglMatrixStackCache *cache,
|
|
gboolean flip);
|
|
|
|
void
|
|
_cogl_matrix_stack_destroy_cache (CoglMatrixStackCache *cache);
|
|
|
|
#endif /* __COGL_MATRIX_STACK_H */
|