GNOME Bugzilla – Bug 663636
Use newer Cogl API in ClutterDeformEffect
Last modified: 2011-11-15 11:55:09 UTC
Here's some patches to make ClutterDeformEffect use the Cogl 2.0 API. The second patch depends on bug 663628.
Created attachment 201012 [details] [review] deform-effect: Use CoglPrimitives instead of CoglVertexBuffers This changes ClutterDeformEffect to use a CoglAttributeBuffer with a CoglPrimitive instead of the old CoglVertexBuffer. The old vertex buffer code is now implemented in terms of the attribute buffer code and it will eventually be deprecated. Using CoglPrimitives should be slightly more efficient. This also changes the struct we store the vertices to be CoglVertexP3T2C4 instead of CoglTextureVertex. The latter is technically not compatible with neither vertex buffers nor attribute buffers because it contains a CoglColor and the internal members of that are private so it is not valid to assume it contains 4 bytes and use that as an attribute. Also it contains padding so it ends up redundantly creating a larger buffer. CoglTextureVertex is in the public API for the deform_vertex virtual so we still have to maintain that. Instead of directly manipulating the array to upload, the application is now passed a stack allocated temporary struct which gets converted to a CoglVertexP3T2C4. This also means that we can map the buffer as write only and still let the application read-write the vertex. The paint debug code to draw line strips for the deform mesh was previously trying to set a red source material. However this wasn't working because the material color was being overwritten by the color attribute in the vertex buffer. This patch fixes that by creating a seperate primitive for the lines and not adding the color attribute. The lines code was also drawing both the front and back indices. I don't think that entirely makes sense so I've just changed it to draw only the front indices. Maybe painting both would make more sense if backface culling was still enabled.
Created attachment 201013 [details] [review] deform-effect: Use CoglPipeline instead of setting legacy state Instead of calling cogl_set_depth_test_enabled and cogl_set_backface_culling_enabled ClutterDeformEffect now uses the experimental CoglPipeline API. Those global state functions will soon be deprecated in Cogl and they are implemented by flushing a temporary override pipline which isn't ideal. Using the new culling API we can also avoid having a separate buffer of indices for the back of the texture by just changing the culling mode to cull front baces instead of the back.
Review of attachment 201012 [details] [review]: looks good to me.
Review of attachment 201013 [details] [review]: looks good to me. feel free to commit it when the API lands in Cogl.
Attachment 201012 [details] pushed as 8a752d6 - deform-effect: Use CoglPrimitives instead of CoglVertexBuffers Attachment 201013 [details] pushed as 58b6ad7 - deform-effect: Use CoglPipeline instead of setting legacy state