| 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 #include "cc/output/geometry_binding.h" | 5 #include "cc/output/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 void SetupGLContext(gpu::gles2::GLES2Interface* gl, | 12 void SetupGLContext(gpu::gles2::GLES2Interface* gl, |
| 14 GLuint quad_elements_vbo, | 13 GLuint quad_elements_vbo, |
| 15 GLuint quad_vertices_vbo) { | 14 GLuint quad_vertices_vbo) { |
| 16 GLC(gl, gl->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_elements_vbo)); | 15 gl->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_elements_vbo); |
| 17 | 16 |
| 18 GLC(gl, gl->BindBuffer(GL_ARRAY_BUFFER, quad_vertices_vbo)); | 17 gl->BindBuffer(GL_ARRAY_BUFFER, quad_vertices_vbo); |
| 19 // OpenGL defines the last parameter to VertexAttribPointer as type | 18 // OpenGL defines the last parameter to VertexAttribPointer as type |
| 20 // "const GLvoid*" even though it is actually an offset into the buffer | 19 // "const GLvoid*" even though it is actually an offset into the buffer |
| 21 // object's data store and not a pointer to the client's address space. | 20 // object's data store and not a pointer to the client's address space. |
| 22 const void* offsets[3] = { | 21 const void* offsets[3] = { |
| 23 0, | 22 0, |
| 24 reinterpret_cast<const void*>(3 * sizeof(float)), | 23 reinterpret_cast<const void*>(3 * sizeof(float)), |
| 25 reinterpret_cast<const void*>(5 * sizeof(float)), | 24 reinterpret_cast<const void*>(5 * sizeof(float)), |
| 26 }; | 25 }; |
| 27 | 26 |
| 28 GLC(gl, | 27 gl->VertexAttribPointer(GeometryBinding::PositionAttribLocation(), 3, |
| 29 gl->VertexAttribPointer(GeometryBinding::PositionAttribLocation(), 3, | 28 GL_FLOAT, false, 6 * sizeof(float), offsets[0]); |
| 30 GL_FLOAT, false, 6 * sizeof(float), offsets[0])); | 29 gl->VertexAttribPointer(GeometryBinding::TexCoordAttribLocation(), 2, |
| 31 GLC(gl, | 30 GL_FLOAT, false, 6 * sizeof(float), offsets[1]); |
| 32 gl->VertexAttribPointer(GeometryBinding::TexCoordAttribLocation(), 2, | 31 gl->VertexAttribPointer(GeometryBinding::TriangleIndexAttribLocation(), 1, |
| 33 GL_FLOAT, false, 6 * sizeof(float), offsets[1])); | 32 GL_FLOAT, false, 6 * sizeof(float), offsets[2]); |
| 34 GLC(gl, | 33 gl->EnableVertexAttribArray(GeometryBinding::PositionAttribLocation()); |
| 35 gl->VertexAttribPointer(GeometryBinding::TriangleIndexAttribLocation(), 1, | 34 gl->EnableVertexAttribArray(GeometryBinding::TexCoordAttribLocation()); |
| 36 GL_FLOAT, false, 6 * sizeof(float), offsets[2])); | 35 gl->EnableVertexAttribArray(GeometryBinding::TriangleIndexAttribLocation()); |
| 37 GLC(gl, | |
| 38 gl->EnableVertexAttribArray(GeometryBinding::PositionAttribLocation())); | |
| 39 GLC(gl, | |
| 40 gl->EnableVertexAttribArray(GeometryBinding::TexCoordAttribLocation())); | |
| 41 GLC(gl, gl->EnableVertexAttribArray( | |
| 42 GeometryBinding::TriangleIndexAttribLocation())); | |
| 43 } | 36 } |
| 44 | 37 |
| 45 GeometryBindingQuad::GeometryBindingQuad() { | 38 GeometryBindingQuad::GeometryBindingQuad() { |
| 46 v0 = {{0, 0, 0}, {0, 0}, 0}; | 39 v0 = {{0, 0, 0}, {0, 0}, 0}; |
| 47 v1 = {{0, 0, 0}, {0, 0}, 0}; | 40 v1 = {{0, 0, 0}, {0, 0}, 0}; |
| 48 v2 = {{0, 0, 0}, {0, 0}, 0}; | 41 v2 = {{0, 0, 0}, {0, 0}, 0}; |
| 49 v3 = {{0, 0, 0}, {0, 0}, 0}; | 42 v3 = {{0, 0, 0}, {0, 0}, 0}; |
| 50 } | 43 } |
| 51 | 44 |
| 52 GeometryBindingQuad::GeometryBindingQuad(const GeometryBindingVertex& vert0, | 45 GeometryBindingQuad::GeometryBindingQuad(const GeometryBindingVertex& vert0, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 71 uint16 index5) { | 64 uint16 index5) { |
| 72 data[0] = index0; | 65 data[0] = index0; |
| 73 data[1] = index1; | 66 data[1] = index1; |
| 74 data[2] = index2; | 67 data[2] = index2; |
| 75 data[3] = index3; | 68 data[3] = index3; |
| 76 data[4] = index4; | 69 data[4] = index4; |
| 77 data[5] = index5; | 70 data[5] = index5; |
| 78 } | 71 } |
| 79 | 72 |
| 80 } // namespace cc | 73 } // namespace cc |
| OLD | NEW |