Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2921)

Unified Diff: cc/geometry_binding.cc

Issue 11415161: Texture Draw Calls Coalescing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/geometry_binding.cc
diff --git a/cc/geometry_binding.cc b/cc/geometry_binding.cc
index 3ccea1f1f3efa4c227f93267a2ac625855cf8abc..3844c5a226840a01174394be60bcb003c9fe4f01 100644
--- a/cc/geometry_binding.cc
+++ b/cc/geometry_binding.cc
@@ -22,13 +22,68 @@ GeometryBinding::GeometryBinding(WebKit::WebGraphicsContext3D* context, const gf
quadVertexRect.x(), quadVertexRect.y(), 0.0f, 0.0f, 0.0f,
quadVertexRect.right(), quadVertexRect.y(), 0.0f, 1.0f, 0.0f,
quadVertexRect.right(), quadVertexRect.bottom(), 0.0f, 1.0f, 1.0f };
- uint16_t indices[] = { 0, 1, 2, 0, 2, 3, // The two triangles that make up the layer quad.
- 0, 1, 2, 3}; // A line path for drawing the layer border.
+
+ // Vertex positions, texture coordinates and skinning values for the 4 corners of 8 1x1 quads.
shawnsingh 2012/11/28 19:44:16 I think the word skinning might confuse/complicate
whunt 2012/11/28 22:01:15 Done, I made the language more uniform and avoided
+ float vertexListData[] = {
shawnsingh 2012/11/28 19:44:16 If possible, we should make this an array of struc
whunt 2012/11/28 22:01:15 Done. On 2012/11/28 19:44:16, shawnsingh wrote:
+ -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 0.0f,
+ -0.5f, -0.5f, 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.5f, 0.5f, 0.0f, 1.0f, 1.0f, 0.0f,
+ -0.5f, 0.5f, 0.0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f, 1.0f, 7.0f,
+ -0.5f, -0.5f, 0.0f, 0.0f, 0.0f, 7.0f,
+ 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 7.0f,
+ 0.5f, 0.5f, 0.0f, 1.0f, 1.0f, 7.0f,
+ };
+
+ // Index buffer for up to 8 quads.
+ uint16_t indices[] = {
+ 0, 1, 2,
+ 3, 0, 2,
+ 4, 5, 6,
jamesr 2012/11/28 00:00:37 Same here - each 6-tuple is just the previous one
whunt 2012/11/28 22:01:15 Yes, but this one is slightly more subtle. You pr
+ 4, 6, 7,
+ 8, 9, 10,
+ 8, 10, 11,
+ 12, 13, 14,
+ 12, 14, 15,
+ 16, 17, 18,
+ 16, 18, 19,
+ 20, 21, 22,
+ 20, 22, 23,
+ 24, 25, 26,
+ 24, 26, 27,
+ 28, 29, 30,
+ 28, 30, 31,
+ };
GLC(m_context, m_quadVerticesVbo = m_context->createBuffer());
GLC(m_context, m_quadElementsVbo = m_context->createBuffer());
+ GLC(m_context, m_quadListVerticesVbo = m_context->createBuffer());
GLC(m_context, m_context->bindBuffer(GL_ARRAY_BUFFER, m_quadVerticesVbo));
- GLC(m_context, m_context->bufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW));
+ GLC(m_context, m_context->bufferData(GL_ARRAY_BUFFER, sizeof(vertexListData), vertexListData, GL_STATIC_DRAW));
GLC(m_context, m_context->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_quadElementsVbo));
GLC(m_context, m_context->bufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW));
@@ -43,14 +98,15 @@ GeometryBinding::~GeometryBinding()
void GeometryBinding::prepareForDraw()
{
- GLC(m_context, m_context->bindBuffer(GL_ARRAY_BUFFER, quadVerticesVbo()));
GLC(m_context, m_context->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, quadElementsVbo()));
- unsigned offset = 0;
- GLC(m_context, m_context->vertexAttribPointer(positionAttribLocation(), 3, GL_FLOAT, false, 5 * sizeof(float), offset));
- offset += 3 * sizeof(float);
- GLC(m_context, m_context->vertexAttribPointer(texCoordAttribLocation(), 2, GL_FLOAT, false, 5 * sizeof(float), offset));
+
+ GLC(m_context, m_context->bindBuffer(GL_ARRAY_BUFFER, quadVerticesVbo()));
+ GLC(m_context, m_context->vertexAttribPointer(positionAttribLocation(), 3, GL_FLOAT, false, 6 * sizeof(float), 0));
+ GLC(m_context, m_context->vertexAttribPointer(texCoordAttribLocation(), 2, GL_FLOAT, false, 6 * sizeof(float), 12));
shawnsingh 2012/11/28 19:44:16 This "12" should probably remain 3 * sizeof(float)
+ GLC(m_context, m_context->vertexAttribPointer(triangleIndexAttribLocation(), 1, GL_FLOAT, false, 6 * sizeof(float), 20));
shawnsingh 2012/11/28 19:44:16 And this "20" should probably remain 5 * sizeof(fl
GLC(m_context, m_context->enableVertexAttribArray(positionAttribLocation()));
GLC(m_context, m_context->enableVertexAttribArray(texCoordAttribLocation()));
+ GLC(m_context, m_context->enableVertexAttribArray(triangleIndexAttribLocation()));
}
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698