summaryrefslogtreecommitdiff
path: root/cogl/cogl-attribute.c
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2013-05-16 15:19:30 +0100
committerRobert Bragg <robert@linux.intel.com>2013-06-06 21:27:09 +0100
commit8f9151303d4d744205cce5cf0235b3e83e6687ef (patch)
tree0414558aa37f2c58c54ed32d71e1f63d00a6cfb6 /cogl/cogl-attribute.c
parent2ed926120d11a3ef5fe51d613e79568b36259ddf (diff)
downloadcogl-8f9151303d4d744205cce5cf0235b3e83e6687ef.tar.gz
pipeline: improve real_blend_enable checks
Since _cogl_pipeline_update_blend_enable() can sometimes show up quite high in profiles; instead of calling _cogl_pipeline_update_blend_enable() whenever we change pipeline state that may affect blending we now just set a dirty flag and when we flush a pipeline we check this dirty flag and lazily calculate whether blender really needs to be enabled if it's set. Since it turns out we were too optimistic in assuming most GL drivers would recognize blending with ADD(src,0) is equivalent to disabling GL_BLEND we now check this case ourselves so we can always explicitly disable GL_BLEND if we know we don't need blending. This introduces the idea of an 'unknown_color_alpha' boolean to the pipeline flush code which is set whenever we can't guarantee that the color attribute is opaque. For example this is set whenever a user specifies a color attribute with 4 components when drawing a primitive. This boolean needs to be cached along with every pipeline because pipeline::real_blend_enabled depends on this and so we need to also call _cogl_pipeline_update_blend_enable() if the status of this changes. Incidentally with this patch we now no longer ever use _cogl_pipeline_set_blend_enable() internally. For now the internal api hasn't been removed though since we might want to consider re-purposing it as a public api since it will now not conflict with our own internal state tracking and could provide a more convenient way to disable blending than setting a blend string. Reviewed-by: Neil Roberts <neil@linux.intel.com> (cherry picked from commit ab2ae18f3207514c91fa6fd9f2d3f2ed93a86497)
Diffstat (limited to 'cogl/cogl-attribute.c')
-rw-r--r--cogl/cogl-attribute.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/cogl/cogl-attribute.c b/cogl/cogl-attribute.c
index b0ac790e..bc45399f 100644
--- a/cogl/cogl-attribute.c
+++ b/cogl/cogl-attribute.c
@@ -657,3 +657,12 @@ _cogl_flush_attributes_state (CoglFramebuffer *framebuffer,
if (copy)
cogl_object_unref (copy);
}
+
+int
+_cogl_attribute_get_n_components (CoglAttribute *attribute)
+{
+ if (attribute->is_buffered)
+ return attribute->d.buffered.n_components;
+ else
+ return attribute->d.constant.boxed.size;
+}