OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "cc/output/static_geometry_binding.h" | 5 #include "cc/output/static_geometry_binding.h" |
6 | 6 |
7 #include "cc/output/gl_renderer.h" // For the GLC() macro. | |
8 #include "gpu/command_buffer/client/gles2_interface.h" | 7 #include "gpu/command_buffer/client/gles2_interface.h" |
9 #include "ui/gfx/geometry/rect_f.h" | 8 #include "ui/gfx/geometry/rect_f.h" |
10 | 9 |
11 namespace cc { | 10 namespace cc { |
12 | 11 |
13 StaticGeometryBinding::StaticGeometryBinding(gpu::gles2::GLES2Interface* gl, | 12 StaticGeometryBinding::StaticGeometryBinding(gpu::gles2::GLES2Interface* gl, |
14 const gfx::RectF& quad_vertex_rect) | 13 const gfx::RectF& quad_vertex_rect) |
15 : gl_(gl), quad_vertices_vbo_(0), quad_elements_vbo_(0) { | 14 : gl_(gl), quad_vertices_vbo_(0), quad_elements_vbo_(0) { |
16 GeometryBindingQuad quads[8]; | 15 GeometryBindingQuad quads[8]; |
17 GeometryBindingQuadIndex quad_indices[8]; | 16 GeometryBindingQuadIndex quad_indices[8]; |
(...skipping 22 matching lines...) Expand all Loading... |
40 i * 4.0f + 3.0f}; | 39 i * 4.0f + 3.0f}; |
41 GeometryBindingQuad x(v0, v1, v2, v3); | 40 GeometryBindingQuad x(v0, v1, v2, v3); |
42 quads[i] = x; | 41 quads[i] = x; |
43 GeometryBindingQuadIndex y( | 42 GeometryBindingQuadIndex y( |
44 static_cast<uint16>(0 + 4 * i), static_cast<uint16>(1 + 4 * i), | 43 static_cast<uint16>(0 + 4 * i), static_cast<uint16>(1 + 4 * i), |
45 static_cast<uint16>(2 + 4 * i), static_cast<uint16>(3 + 4 * i), | 44 static_cast<uint16>(2 + 4 * i), static_cast<uint16>(3 + 4 * i), |
46 static_cast<uint16>(0 + 4 * i), static_cast<uint16>(2 + 4 * i)); | 45 static_cast<uint16>(0 + 4 * i), static_cast<uint16>(2 + 4 * i)); |
47 quad_indices[i] = y; | 46 quad_indices[i] = y; |
48 } | 47 } |
49 | 48 |
50 GLC(gl_, gl_->GenBuffers(1, &quad_vertices_vbo_)); | 49 gl_->GenBuffers(1, &quad_vertices_vbo_); |
51 GLC(gl_, gl_->GenBuffers(1, &quad_elements_vbo_)); | 50 gl_->GenBuffers(1, &quad_elements_vbo_); |
52 | 51 |
53 GLC(gl_, gl_->BindBuffer(GL_ARRAY_BUFFER, quad_vertices_vbo_)); | 52 gl_->BindBuffer(GL_ARRAY_BUFFER, quad_vertices_vbo_); |
54 GLC(gl_, gl_->BufferData(GL_ARRAY_BUFFER, sizeof(GeometryBindingQuad) * 8, | 53 gl_->BufferData(GL_ARRAY_BUFFER, sizeof(GeometryBindingQuad) * 8, quads, |
55 quads, GL_STATIC_DRAW)); | 54 GL_STATIC_DRAW); |
56 | 55 |
57 GLC(gl_, gl_->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_elements_vbo_)); | 56 gl_->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_elements_vbo_); |
58 GLC(gl_, gl_->BufferData(GL_ELEMENT_ARRAY_BUFFER, | 57 gl_->BufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GeometryBindingQuadIndex) * 8, |
59 sizeof(GeometryBindingQuadIndex) * 8, &quad_indices, | 58 &quad_indices, GL_STATIC_DRAW); |
60 GL_STATIC_DRAW)); | |
61 } | 59 } |
62 | 60 |
63 StaticGeometryBinding::~StaticGeometryBinding() { | 61 StaticGeometryBinding::~StaticGeometryBinding() { |
64 gl_->DeleteBuffers(1, &quad_vertices_vbo_); | 62 gl_->DeleteBuffers(1, &quad_vertices_vbo_); |
65 gl_->DeleteBuffers(1, &quad_elements_vbo_); | 63 gl_->DeleteBuffers(1, &quad_elements_vbo_); |
66 } | 64 } |
67 | 65 |
68 void StaticGeometryBinding::PrepareForDraw() { | 66 void StaticGeometryBinding::PrepareForDraw() { |
69 SetupGLContext(gl_, quad_elements_vbo_, quad_vertices_vbo_); | 67 SetupGLContext(gl_, quad_elements_vbo_, quad_vertices_vbo_); |
70 } | 68 } |
71 | 69 |
72 } // namespace cc | 70 } // namespace cc |
OLD | NEW |