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 <stdint.h> |
| 8 |
7 #include "gpu/command_buffer/client/gles2_interface.h" | 9 #include "gpu/command_buffer/client/gles2_interface.h" |
8 #include "ui/gfx/geometry/quad_f.h" | 10 #include "ui/gfx/geometry/quad_f.h" |
9 #include "ui/gfx/geometry/rect_f.h" | 11 #include "ui/gfx/geometry/rect_f.h" |
10 | 12 |
11 namespace cc { | 13 namespace cc { |
12 | 14 |
13 DynamicGeometryBinding::DynamicGeometryBinding(gpu::gles2::GLES2Interface* gl) | 15 DynamicGeometryBinding::DynamicGeometryBinding(gpu::gles2::GLES2Interface* gl) |
14 : gl_(gl), quad_vertices_vbo_(0), quad_elements_vbo_(0) { | 16 : gl_(gl), quad_vertices_vbo_(0), quad_elements_vbo_(0) { |
15 GeometryBindingQuad quads[1]; | 17 GeometryBindingQuad quads[1]; |
16 GeometryBindingQuadIndex quad_indices[1]; | 18 GeometryBindingQuadIndex quad_indices[1]; |
(...skipping 26 matching lines...) Expand all Loading... |
43 {quad.p1().x(), quad.p1().y(), 0.0f}, {uv[0], uv[1]}, 0.0f}; | 45 {quad.p1().x(), quad.p1().y(), 0.0f}, {uv[0], uv[1]}, 0.0f}; |
44 GeometryBindingVertex v1 = { | 46 GeometryBindingVertex v1 = { |
45 {quad.p2().x(), quad.p2().y(), 0.0f}, {uv[2], uv[3]}, 1.0f}; | 47 {quad.p2().x(), quad.p2().y(), 0.0f}, {uv[2], uv[3]}, 1.0f}; |
46 GeometryBindingVertex v2 = { | 48 GeometryBindingVertex v2 = { |
47 {quad.p3().x(), quad.p3().y(), 0.0f}, {uv[4], uv[5]}, 2.0f}; | 49 {quad.p3().x(), quad.p3().y(), 0.0f}, {uv[4], uv[5]}, 2.0f}; |
48 GeometryBindingVertex v3 = { | 50 GeometryBindingVertex v3 = { |
49 {quad.p4().x(), quad.p4().y(), 0.0f}, {uv[6], uv[7]}, 3.0f}; | 51 {quad.p4().x(), quad.p4().y(), 0.0f}, {uv[6], uv[7]}, 3.0f}; |
50 | 52 |
51 GeometryBindingQuad local_quad = {v0, v1, v2, v3}; | 53 GeometryBindingQuad local_quad = {v0, v1, v2, v3}; |
52 GeometryBindingQuadIndex quad_index( | 54 GeometryBindingQuadIndex quad_index( |
53 static_cast<uint16>(0), static_cast<uint16>(1), static_cast<uint16>(2), | 55 static_cast<uint16_t>(0), static_cast<uint16_t>(1), |
54 static_cast<uint16>(3), static_cast<uint16>(0), static_cast<uint16>(2)); | 56 static_cast<uint16_t>(2), static_cast<uint16_t>(3), |
| 57 static_cast<uint16_t>(0), static_cast<uint16_t>(2)); |
55 | 58 |
56 gl_->BufferSubData(GL_ARRAY_BUFFER, 0, sizeof(GeometryBindingQuad), | 59 gl_->BufferSubData(GL_ARRAY_BUFFER, 0, sizeof(GeometryBindingQuad), |
57 &local_quad); | 60 &local_quad); |
58 gl_->BufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, | 61 gl_->BufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, |
59 sizeof(GeometryBindingQuadIndex), &quad_index); | 62 sizeof(GeometryBindingQuadIndex), &quad_index); |
60 } | 63 } |
61 | 64 |
62 void DynamicGeometryBinding::PrepareForDraw() { | 65 void DynamicGeometryBinding::PrepareForDraw() { |
63 SetupGLContext(gl_, quad_elements_vbo_, quad_vertices_vbo_); | 66 SetupGLContext(gl_, quad_elements_vbo_, quad_vertices_vbo_); |
64 } | 67 } |
65 | 68 |
66 } // namespace cc | 69 } // namespace cc |
OLD | NEW |