| 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 <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
| 7 #include "gpu/command_buffer/client/gles2_interface.h" | 10 #include "gpu/command_buffer/client/gles2_interface.h" |
| 8 #include "ui/gfx/geometry/rect_f.h" | 11 #include "ui/gfx/geometry/rect_f.h" |
| 9 | 12 |
| 10 namespace cc { | 13 namespace cc { |
| 11 | 14 |
| 12 StaticGeometryBinding::StaticGeometryBinding(gpu::gles2::GLES2Interface* gl, | 15 StaticGeometryBinding::StaticGeometryBinding(gpu::gles2::GLES2Interface* gl, |
| 13 const gfx::RectF& quad_vertex_rect) | 16 const gfx::RectF& quad_vertex_rect) |
| 14 : gl_(gl), quad_vertices_vbo_(0), quad_elements_vbo_(0) { | 17 : gl_(gl), quad_vertices_vbo_(0), quad_elements_vbo_(0) { |
| 15 GeometryBindingQuad quads[NUM_QUADS]; | 18 GeometryBindingQuad quads[NUM_QUADS]; |
| 16 GeometryBindingQuadIndex quad_indices[NUM_QUADS]; | 19 GeometryBindingQuadIndex quad_indices[NUM_QUADS]; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 33 {quad_vertex_rect.right(), quad_vertex_rect.y(), 0.0f}, | 36 {quad_vertex_rect.right(), quad_vertex_rect.y(), 0.0f}, |
| 34 {1.0f, 0.0f}, | 37 {1.0f, 0.0f}, |
| 35 i * 4.0f + 2.0f}; | 38 i * 4.0f + 2.0f}; |
| 36 GeometryBindingVertex v3 = { | 39 GeometryBindingVertex v3 = { |
| 37 {quad_vertex_rect.right(), quad_vertex_rect.bottom(), 0.0f}, | 40 {quad_vertex_rect.right(), quad_vertex_rect.bottom(), 0.0f}, |
| 38 {1.0f, 1.0f}, | 41 {1.0f, 1.0f}, |
| 39 i * 4.0f + 3.0f}; | 42 i * 4.0f + 3.0f}; |
| 40 GeometryBindingQuad x(v0, v1, v2, v3); | 43 GeometryBindingQuad x(v0, v1, v2, v3); |
| 41 quads[i] = x; | 44 quads[i] = x; |
| 42 GeometryBindingQuadIndex y( | 45 GeometryBindingQuadIndex y( |
| 43 static_cast<uint16>(0 + 4 * i), static_cast<uint16>(1 + 4 * i), | 46 static_cast<uint16_t>(0 + 4 * i), static_cast<uint16_t>(1 + 4 * i), |
| 44 static_cast<uint16>(2 + 4 * i), static_cast<uint16>(3 + 4 * i), | 47 static_cast<uint16_t>(2 + 4 * i), static_cast<uint16_t>(3 + 4 * i), |
| 45 static_cast<uint16>(0 + 4 * i), static_cast<uint16>(2 + 4 * i)); | 48 static_cast<uint16_t>(0 + 4 * i), static_cast<uint16_t>(2 + 4 * i)); |
| 46 quad_indices[i] = y; | 49 quad_indices[i] = y; |
| 47 } | 50 } |
| 48 | 51 |
| 49 gl_->GenBuffers(1, &quad_vertices_vbo_); | 52 gl_->GenBuffers(1, &quad_vertices_vbo_); |
| 50 gl_->GenBuffers(1, &quad_elements_vbo_); | 53 gl_->GenBuffers(1, &quad_elements_vbo_); |
| 51 | 54 |
| 52 gl_->BindBuffer(GL_ARRAY_BUFFER, quad_vertices_vbo_); | 55 gl_->BindBuffer(GL_ARRAY_BUFFER, quad_vertices_vbo_); |
| 53 gl_->BufferData(GL_ARRAY_BUFFER, sizeof(GeometryBindingQuad) * NUM_QUADS, | 56 gl_->BufferData(GL_ARRAY_BUFFER, sizeof(GeometryBindingQuad) * NUM_QUADS, |
| 54 quads, GL_STATIC_DRAW); | 57 quads, GL_STATIC_DRAW); |
| 55 | 58 |
| 56 gl_->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_elements_vbo_); | 59 gl_->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_elements_vbo_); |
| 57 gl_->BufferData(GL_ELEMENT_ARRAY_BUFFER, | 60 gl_->BufferData(GL_ELEMENT_ARRAY_BUFFER, |
| 58 sizeof(GeometryBindingQuadIndex) * NUM_QUADS, &quad_indices, | 61 sizeof(GeometryBindingQuadIndex) * NUM_QUADS, &quad_indices, |
| 59 GL_STATIC_DRAW); | 62 GL_STATIC_DRAW); |
| 60 } | 63 } |
| 61 | 64 |
| 62 StaticGeometryBinding::~StaticGeometryBinding() { | 65 StaticGeometryBinding::~StaticGeometryBinding() { |
| 63 gl_->DeleteBuffers(1, &quad_vertices_vbo_); | 66 gl_->DeleteBuffers(1, &quad_vertices_vbo_); |
| 64 gl_->DeleteBuffers(1, &quad_elements_vbo_); | 67 gl_->DeleteBuffers(1, &quad_elements_vbo_); |
| 65 } | 68 } |
| 66 | 69 |
| 67 void StaticGeometryBinding::PrepareForDraw() { | 70 void StaticGeometryBinding::PrepareForDraw() { |
| 68 SetupGLContext(gl_, quad_elements_vbo_, quad_vertices_vbo_); | 71 SetupGLContext(gl_, quad_elements_vbo_, quad_vertices_vbo_); |
| 69 } | 72 } |
| 70 | 73 |
| 71 } // namespace cc | 74 } // namespace cc |
| OLD | NEW |