Chromium Code Reviews| 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/dynamic_geometry_binding.h" | 5 #include "cc/output/dynamic_geometry_binding.h" |
| 6 | 6 |
| 7 #include "cc/output/gl_renderer.h" // For the GLC() macro. | 7 #include "cc/output/gl_renderer.h" // For the GLC() macro. |
| 8 #include "gpu/command_buffer/client/gles2_interface.h" | 8 #include "gpu/command_buffer/client/gles2_interface.h" |
| 9 #include "ui/gfx/geometry/rect_f.h" | 9 #include "ui/gfx/geometry/rect_f.h" |
| 10 | 10 |
| 11 namespace cc { | 11 namespace cc { |
| 12 | 12 |
| 13 DynamicGeometryBinding::DynamicGeometryBinding(gpu::gles2::GLES2Interface* gl) | 13 DynamicGeometryBinding::DynamicGeometryBinding(gpu::gles2::GLES2Interface* gl) |
| 14 : gl_(gl), quad_vertices_vbo_(0), quad_elements_vbo_(0) { | 14 : gl_(gl), quad_vertices_vbo_(0), quad_elements_vbo_(0) { |
| 15 GeometryBindingQuad quads[8]; | 15 GeometryBindingQuad quads[1]; |
|
enne (OOO)
2015/02/27 21:36:01
Can you initialize this in the class itself rather
awoloszyn
2015/02/27 22:08:37
Done.
| |
| 16 GeometryBindingQuadIndex quad_indices[8]; | 16 GeometryBindingQuadIndex quad_indices[1]; |
| 17 | 17 |
| 18 static_assert(sizeof(GeometryBindingQuad) == 24 * sizeof(float), | 18 static_assert(sizeof(GeometryBindingQuad) == 24 * sizeof(float), |
| 19 "struct Quad should be densely packed"); | 19 "struct Quad should be densely packed"); |
| 20 static_assert(sizeof(GeometryBindingQuadIndex) == 6 * sizeof(uint16_t), | 20 static_assert(sizeof(GeometryBindingQuadIndex) == 6 * sizeof(uint16_t), |
| 21 "struct QuadIndex should be densely packed"); | 21 "struct QuadIndex should be densely packed"); |
| 22 | 22 |
| 23 memset(quads, 0x00, sizeof(quads)); | |
| 24 memset(quads, 0x00, sizeof(quad_indices)); | |
| 25 | |
| 23 GLC(gl_, gl_->GenBuffers(1, &quad_vertices_vbo_)); | 26 GLC(gl_, gl_->GenBuffers(1, &quad_vertices_vbo_)); |
| 24 GLC(gl_, gl_->GenBuffers(1, &quad_elements_vbo_)); | 27 GLC(gl_, gl_->GenBuffers(1, &quad_elements_vbo_)); |
| 25 | 28 |
| 26 GLC(gl_, gl_->BindBuffer(GL_ARRAY_BUFFER, quad_vertices_vbo_)); | 29 GLC(gl_, gl_->BindBuffer(GL_ARRAY_BUFFER, quad_vertices_vbo_)); |
| 27 GLC(gl_, gl_->BufferData(GL_ARRAY_BUFFER, sizeof(GeometryBindingQuad) * 1, | 30 GLC(gl_, gl_->BufferData(GL_ARRAY_BUFFER, sizeof(GeometryBindingQuad) * 1, |
| 28 quads, GL_DYNAMIC_DRAW)); | 31 quads, GL_DYNAMIC_DRAW)); |
| 29 | 32 |
| 30 GLC(gl_, gl_->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_elements_vbo_)); | 33 GLC(gl_, gl_->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_elements_vbo_)); |
| 31 GLC(gl_, gl_->BufferData(GL_ELEMENT_ARRAY_BUFFER, | 34 GLC(gl_, gl_->BufferData(GL_ELEMENT_ARRAY_BUFFER, |
| 32 sizeof(GeometryBindingQuadIndex) * 1, &quad_indices, | 35 sizeof(GeometryBindingQuadIndex) * 1, &quad_indices, |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 61 &local_quad)); | 64 &local_quad)); |
| 62 GLC(gl_, gl_->BufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, | 65 GLC(gl_, gl_->BufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, |
| 63 sizeof(GeometryBindingQuadIndex), &quad_index)); | 66 sizeof(GeometryBindingQuadIndex), &quad_index)); |
| 64 } | 67 } |
| 65 | 68 |
| 66 void DynamicGeometryBinding::PrepareForDraw() { | 69 void DynamicGeometryBinding::PrepareForDraw() { |
| 67 SetupGLContext(gl_, quad_elements_vbo_, quad_vertices_vbo_); | 70 SetupGLContext(gl_, quad_elements_vbo_, quad_vertices_vbo_); |
| 68 } | 71 } |
| 69 | 72 |
| 70 } // namespace cc | 73 } // namespace cc |
| OLD | NEW |