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.
5 #include "cc/output/geometry_binding.h"
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"
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
));
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] = {
24 reinterpret_cast<const void*>(3 * sizeof(float)),
25 reinterpret_cast<const void*>(5 * sizeof(float)),
29 gl
->VertexAttribPointer(GeometryBinding::PositionAttribLocation(), 3,
30 GL_FLOAT
, false, 6 * sizeof(float), offsets
[0]));
32 gl
->VertexAttribPointer(GeometryBinding::TexCoordAttribLocation(), 2,
33 GL_FLOAT
, false, 6 * sizeof(float), offsets
[1]));
35 gl
->VertexAttribPointer(GeometryBinding::TriangleIndexAttribLocation(), 1,
36 GL_FLOAT
, false, 6 * sizeof(float), offsets
[2]));
38 gl
->EnableVertexAttribArray(GeometryBinding::PositionAttribLocation()));
40 gl
->EnableVertexAttribArray(GeometryBinding::TexCoordAttribLocation()));
41 GLC(gl
, gl
->EnableVertexAttribArray(
42 GeometryBinding::TriangleIndexAttribLocation()));
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};
52 GeometryBindingQuad::GeometryBindingQuad(const GeometryBindingVertex
& vert0
,
53 const GeometryBindingVertex
& vert1
,
54 const GeometryBindingVertex
& vert2
,
55 const GeometryBindingVertex
& vert3
) {
62 GeometryBindingQuadIndex::GeometryBindingQuadIndex() {
63 memset(data
, 0x0, sizeof(data
));
66 GeometryBindingQuadIndex::GeometryBindingQuadIndex(uint16 index0
,