OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_OUTPUT_GEOMETRY_BINDING_H_ | 5 #ifndef CC_OUTPUT_GEOMETRY_BINDING_H_ |
6 #define CC_OUTPUT_GEOMETRY_BINDING_H_ | 6 #define CC_OUTPUT_GEOMETRY_BINDING_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "cc/output/gl_renderer.h" // For the GLC() macro. |
| 10 #include "gpu/command_buffer/client/gles2_interface.h" |
9 #include "third_party/khronos/GLES2/gl2.h" | 11 #include "third_party/khronos/GLES2/gl2.h" |
| 12 #include "third_party/khronos/GLES2/gl2ext.h" |
| 13 #include "ui/gfx/geometry/rect_f.h" |
10 | 14 |
11 namespace gfx { | 15 namespace gfx { |
12 class RectF; | 16 class QuadF; |
13 } | 17 class Quad; |
14 namespace gpu { | 18 class QuadIndex; |
15 namespace gles2 { | 19 class PointF; |
16 class GLES2Interface; | |
17 } | |
18 } | 20 } |
19 | 21 |
20 namespace cc { | 22 namespace cc { |
21 | 23 |
22 class GeometryBinding { | 24 struct GeometryBindingVertex { |
23 public: | 25 float a_position[3]; |
24 GeometryBinding(gpu::gles2::GLES2Interface* gl, | 26 float a_texCoord[2]; |
25 const gfx::RectF& quad_vertex_rect); | 27 // Index of the vertex, divide by 4 to have the matrix for this quad. |
26 ~GeometryBinding(); | 28 float a_index; |
| 29 }; |
27 | 30 |
28 void PrepareForDraw(); | 31 struct GeometryBindingQuad { |
| 32 GeometryBindingQuad(); |
| 33 GeometryBindingQuad(const GeometryBindingVertex& vert0, |
| 34 const GeometryBindingVertex& vert1, |
| 35 const GeometryBindingVertex& vert2, |
| 36 const GeometryBindingVertex& vert3); |
| 37 GeometryBindingVertex v0, v1, v2, v3; |
| 38 }; |
29 | 39 |
| 40 struct GeometryBindingQuadIndex { |
| 41 GeometryBindingQuadIndex(); |
| 42 GeometryBindingQuadIndex(uint16 index0, |
| 43 uint16 index1, |
| 44 uint16 index2, |
| 45 uint16 index3, |
| 46 uint16 index4, |
| 47 uint16 index5); |
| 48 |
| 49 uint16 data[6]; |
| 50 }; |
| 51 |
| 52 class DrawQuad; |
| 53 class DrawPolygon; |
| 54 |
| 55 struct GeometryBinding { |
30 // All layer shaders share the same attribute locations for the vertex | 56 // All layer shaders share the same attribute locations for the vertex |
31 // positions and texture coordinates. This allows switching shaders without | 57 // positions and texture coordinates. This allows switching shaders without |
32 // rebinding attribute arrays. | 58 // rebinding attribute arrays. |
33 static int PositionAttribLocation() { return 0; } | 59 static int PositionAttribLocation() { return 0; } |
34 static int TexCoordAttribLocation() { return 1; } | 60 static int TexCoordAttribLocation() { return 1; } |
35 static int TriangleIndexAttribLocation() { return 2; } | 61 static int TriangleIndexAttribLocation() { return 2; } |
| 62 }; |
36 | 63 |
37 private: | 64 void SetupGLContext(gpu::gles2::GLES2Interface* gl, |
38 gpu::gles2::GLES2Interface* gl_; | 65 GLuint quad_elements_vbo, |
39 | 66 GLuint quad_vertices_vbo); |
40 GLuint quad_vertices_vbo_; | |
41 GLuint quad_elements_vbo_; | |
42 | |
43 DISALLOW_COPY_AND_ASSIGN(GeometryBinding); | |
44 }; | |
45 | 67 |
46 } // namespace cc | 68 } // namespace cc |
47 | 69 |
48 #endif // CC_OUTPUT_GEOMETRY_BINDING_H_ | 70 #endif // CC_OUTPUT_GEOMETRY_BINDING_H_ |
OLD | NEW |