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" | |
11 #include "third_party/khronos/GLES2/gl2.h" | 9 #include "third_party/khronos/GLES2/gl2.h" |
12 #include "third_party/khronos/GLES2/gl2ext.h" | |
13 #include "ui/gfx/geometry/rect_f.h" | |
14 | 10 |
15 namespace gfx { | 11 namespace gfx { |
16 class QuadF; | 12 class RectF; |
17 class Quad; | 13 } |
18 class QuadIndex; | 14 namespace gpu { |
19 class PointF; | 15 namespace gles2 { |
| 16 class GLES2Interface; |
| 17 } |
20 } | 18 } |
21 | 19 |
22 namespace cc { | 20 namespace cc { |
23 | 21 |
24 struct GeometryBindingVertex { | 22 class GeometryBinding { |
25 float a_position[3]; | 23 public: |
26 float a_texCoord[2]; | 24 GeometryBinding(gpu::gles2::GLES2Interface* gl, |
27 // Index of the vertex, divide by 4 to have the matrix for this quad. | 25 const gfx::RectF& quad_vertex_rect); |
28 float a_index; | 26 ~GeometryBinding(); |
29 }; | |
30 | 27 |
31 struct GeometryBindingQuad { | 28 void PrepareForDraw(); |
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 }; | |
39 | 29 |
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 { | |
56 // All layer shaders share the same attribute locations for the vertex | 30 // All layer shaders share the same attribute locations for the vertex |
57 // positions and texture coordinates. This allows switching shaders without | 31 // positions and texture coordinates. This allows switching shaders without |
58 // rebinding attribute arrays. | 32 // rebinding attribute arrays. |
59 static int PositionAttribLocation() { return 0; } | 33 static int PositionAttribLocation() { return 0; } |
60 static int TexCoordAttribLocation() { return 1; } | 34 static int TexCoordAttribLocation() { return 1; } |
61 static int TriangleIndexAttribLocation() { return 2; } | 35 static int TriangleIndexAttribLocation() { return 2; } |
| 36 |
| 37 private: |
| 38 gpu::gles2::GLES2Interface* gl_; |
| 39 |
| 40 GLuint quad_vertices_vbo_; |
| 41 GLuint quad_elements_vbo_; |
| 42 |
| 43 DISALLOW_COPY_AND_ASSIGN(GeometryBinding); |
62 }; | 44 }; |
63 | 45 |
64 void SetupGLContext(gpu::gles2::GLES2Interface* gl, | |
65 GLuint quad_elements_vbo, | |
66 GLuint quad_vertices_vbo); | |
67 | |
68 } // namespace cc | 46 } // namespace cc |
69 | 47 |
70 #endif // CC_OUTPUT_GEOMETRY_BINDING_H_ | 48 #endif // CC_OUTPUT_GEOMETRY_BINDING_H_ |
OLD | NEW |