| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "cc/output/geometry_binding.h" | |
| 6 | |
| 7 #include "cc/output/gl_renderer.h" // For the GLC() macro. | |
| 8 #include "gpu/command_buffer/client/gles2_interface.h" | |
| 9 #include "ui/gfx/geometry/rect_f.h" | |
| 10 | |
| 11 namespace cc { | |
| 12 | |
| 13 void SetupGLContext(gpu::gles2::GLES2Interface* gl, | |
| 14 GLuint quad_elements_vbo, | |
| 15 GLuint quad_vertices_vbo) { | |
| 16 GLC(gl, gl->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_elements_vbo)); | |
| 17 | |
| 18 GLC(gl, gl->BindBuffer(GL_ARRAY_BUFFER, quad_vertices_vbo)); | |
| 19 // OpenGL defines the last parameter to VertexAttribPointer as type | |
| 20 // "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. | |
| 22 const void* offsets[3] = { | |
| 23 0, | |
| 24 reinterpret_cast<const void*>(3 * sizeof(float)), | |
| 25 reinterpret_cast<const void*>(5 * sizeof(float)), | |
| 26 }; | |
| 27 | |
| 28 GLC(gl, | |
| 29 gl->VertexAttribPointer(GeometryBinding::PositionAttribLocation(), 3, | |
| 30 GL_FLOAT, false, 6 * sizeof(float), offsets[0])); | |
| 31 GLC(gl, | |
| 32 gl->VertexAttribPointer(GeometryBinding::TexCoordAttribLocation(), 2, | |
| 33 GL_FLOAT, false, 6 * sizeof(float), offsets[1])); | |
| 34 GLC(gl, | |
| 35 gl->VertexAttribPointer(GeometryBinding::TriangleIndexAttribLocation(), 1, | |
| 36 GL_FLOAT, false, 6 * sizeof(float), offsets[2])); | |
| 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 } | |
| 44 | |
| 45 GeometryBindingQuad::GeometryBindingQuad() { | |
| 46 v0 = {{0, 0, 0}, {0, 0}, 0}; | |
| 47 v1 = {{0, 0, 0}, {0, 0}, 0}; | |
| 48 v2 = {{0, 0, 0}, {0, 0}, 0}; | |
| 49 v3 = {{0, 0, 0}, {0, 0}, 0}; | |
| 50 } | |
| 51 | |
| 52 GeometryBindingQuad::GeometryBindingQuad(const GeometryBindingVertex& vert0, | |
| 53 const GeometryBindingVertex& vert1, | |
| 54 const GeometryBindingVertex& vert2, | |
| 55 const GeometryBindingVertex& vert3) { | |
| 56 v0 = vert0; | |
| 57 v1 = vert1; | |
| 58 v2 = vert2; | |
| 59 v3 = vert3; | |
| 60 } | |
| 61 | |
| 62 GeometryBindingQuadIndex::GeometryBindingQuadIndex() { | |
| 63 memset(data, 0x0, sizeof(data)); | |
| 64 } | |
| 65 | |
| 66 GeometryBindingQuadIndex::GeometryBindingQuadIndex(uint16 index0, | |
| 67 uint16 index1, | |
| 68 uint16 index2, | |
| 69 uint16 index3, | |
| 70 uint16 index4, | |
| 71 uint16 index5) { | |
| 72 data[0] = index0; | |
| 73 data[1] = index1; | |
| 74 data[2] = index2; | |
| 75 data[3] = index3; | |
| 76 data[4] = index4; | |
| 77 data[5] = index5; | |
| 78 } | |
| 79 | |
| 80 } // namespace cc | |
| OLD | NEW |