"Initial commit to Gerrit"
[profile/ivi/cogl.git] / cogl / cogl-attribute-private.h
1 /*
2  * Cogl
3  *
4  * An object oriented GL/GLES Abstraction/Utility Layer
5  *
6  * Copyright (C) 2010 Intel Corporation.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library. If not, see
20  * <http://www.gnu.org/licenses/>.
21  *
22  *
23  *
24  * Authors:
25  *   Robert Bragg <robert@linux.intel.com>
26  */
27
28 #ifndef __COGL_ATTRIBUTE_PRIVATE_H
29 #define __COGL_ATTRIBUTE_PRIVATE_H
30
31 #include "cogl-object-private.h"
32 #include "cogl-attribute.h"
33 #include "cogl-framebuffer.h"
34
35 typedef enum
36 {
37   COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY,
38   COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY,
39   COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY,
40   COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY,
41   COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY
42 } CoglAttributeNameID;
43
44 typedef struct _CoglAttributeNameState
45 {
46   char *name;
47   CoglAttributeNameID name_id;
48   int name_index;
49   gboolean normalized_default;
50   int texture_unit;
51 } CoglAttributeNameState;
52
53 struct _CoglAttribute
54 {
55   CoglObject _parent;
56
57   CoglAttributeBuffer *attribute_buffer;
58   const CoglAttributeNameState *name_state;
59   gsize stride;
60   gsize offset;
61   int n_components;
62   CoglAttributeType type;
63   gboolean normalized;
64
65   int immutable_ref;
66 };
67
68 typedef enum
69 {
70   COGL_DRAW_SKIP_JOURNAL_FLUSH = 1 << 0,
71   COGL_DRAW_SKIP_PIPELINE_VALIDATION = 1 << 1,
72   COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH = 1 << 2,
73   COGL_DRAW_SKIP_LEGACY_STATE = 1 << 3,
74   /* By default the vertex attribute drawing code will assume that if
75      there is a color attribute array enabled then we can't determine
76      if the colors will be opaque so we need to enabling
77      blending. However when drawing from the journal we know what the
78      contents of the color array is so we can override this by passing
79      this flag. */
80   COGL_DRAW_COLOR_ATTRIBUTE_IS_OPAQUE = 1 << 4
81 } CoglDrawFlags;
82
83 /* During CoglContext initialization we register the "cogl_color_in"
84  * attribute name so it gets a global name_index of 0. We need to know
85  * the name_index for "cogl_color_in" in
86  * _cogl_pipeline_flush_gl_state() */
87 #define COGL_ATTRIBUTE_COLOR_NAME_INDEX 0
88
89 CoglAttributeNameState *
90 _cogl_attribute_register_attribute_name (CoglContext *context,
91                                          const char *name);
92
93 CoglAttribute *
94 _cogl_attribute_immutable_ref (CoglAttribute *attribute);
95
96 void
97 _cogl_attribute_immutable_unref (CoglAttribute *attribute);
98
99 void
100 _cogl_attribute_disable_cached_arrays (void);
101
102 void
103 _cogl_flush_attributes_state (CoglFramebuffer *framebuffer,
104                               CoglPipeline *pipeline,
105                               CoglDrawFlags flags,
106                               CoglAttribute **attributes,
107                               int n_attributes);
108
109 #endif /* __COGL_ATTRIBUTE_PRIVATE_H */
110