Index: cc/output/geometry_binding.h |
diff --git a/cc/output/geometry_binding.h b/cc/output/geometry_binding.h |
index cfa21efd1fc1ef2c7bbcdb03b982c1421191d5c2..bdd2b4ec24bebbc1db0f2f42ae2503d2d533c23c 100644 |
--- a/cc/output/geometry_binding.h |
+++ b/cc/output/geometry_binding.h |
@@ -6,26 +6,32 @@ |
#define CC_OUTPUT_GEOMETRY_BINDING_H_ |
#include "base/basictypes.h" |
+#include "cc/output/gl_renderer.h" // For the GLC() macro. |
+#include "gpu/command_buffer/client/gles2_interface.h" |
#include "third_party/khronos/GLES2/gl2.h" |
+#include "third_party/khronos/GLES2/gl2ext.h" |
+#include "ui/gfx/rect_f.h" |
namespace gfx { |
-class RectF; |
-} |
-namespace gpu { |
-namespace gles2 { |
-class GLES2Interface; |
-} |
+class QuadF; |
+class PointF; |
} |
+using gpu::gles2::GLES2Interface; |
namespace cc { |
+class DrawQuad; |
+class DrawPolygon; |
+ |
class GeometryBinding { |
public: |
GeometryBinding(gpu::gles2::GLES2Interface* gl, |
- const gfx::RectF& quad_vertex_rect); |
+ const gfx::RectF& quad_vertex_rect, |
+ size_t buffer_size); |
~GeometryBinding(); |
void PrepareForDraw(); |
+ void InitializeBaseQuads(size_t buffer_size); |
// All layer shaders share the same attribute locations for the vertex |
// positions and texture coordinates. This allows switching shaders without |
@@ -34,15 +40,63 @@ class GeometryBinding { |
static int TexCoordAttribLocation() { return 1; } |
static int TriangleIndexAttribLocation() { return 2; } |
- private: |
+ protected: |
+ struct Vertex { |
+ float a_position[3]; |
+ float a_texCoord[2]; |
+ // Index of the vertex, divide by 4 to have the matrix for this quad. |
+ float a_index; |
+ }; |
+ struct Quad { |
+ Vertex v0, v1, v2, v3; |
+ }; |
+ |
+ struct QuadIndex { |
+ uint16 data[6]; |
+ }; |
+ |
gpu::gles2::GLES2Interface* gl_; |
GLuint quad_vertices_vbo_; |
GLuint quad_elements_vbo_; |
+ gfx::RectF quad_vertex_rect_; |
+ |
+ bool initialized_; |
+ |
+ template <typename S, typename T> |
+ void SetBuffers(S* verts, |
+ T* indices, |
+ int vert_offset, |
+ int elem_offset, |
+ int vert_size, |
+ int elem_size) { |
+ // GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, quad_vertices_vbo_)); |
+ GLC(gl_, |
+ gl_->BufferSubData(GL_ARRAY_BUFFER, |
+ sizeof(S) * vert_offset, |
+ sizeof(S) * vert_size, |
+ verts)); |
+ |
+ /* GLC(context_, |
+ context_->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_elements_vbo_)); */ |
+ GLC(gl_, |
+ gl_->BufferSubData(GL_ELEMENT_ARRAY_BUFFER, |
+ sizeof(T) * elem_offset, |
+ sizeof(T) * elem_size, |
+ indices)); |
+ } |
DISALLOW_COPY_AND_ASSIGN(GeometryBinding); |
}; |
+class GeometryBindingQuad : public GeometryBinding { |
+ public: |
+ GeometryBindingQuad(gpu::gles2::GLES2Interface* gl, |
+ const gfx::RectF& quad_vertex_rect); |
+ void InitializeCustomQuad(const gfx::QuadF& quad); |
+ void InitializeCustomQuadWithUVs(const gfx::QuadF& quad, float uv[8]); |
+}; |
+ |
} // namespace cc |
#endif // CC_OUTPUT_GEOMETRY_BINDING_H_ |