| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/geometry_binding.h" | 7 #include "cc/geometry_binding.h" |
| 8 | 8 |
| 9 #include "cc/gl_renderer.h" // For the GLC() macro. | 9 #include "cc/gl_renderer.h" // For the GLC() macro. |
| 10 #include "third_party/khronos/GLES2/gl2.h" | 10 #include "third_party/khronos/GLES2/gl2.h" |
| 11 #include "ui/gfx/rect_f.h" |
| 11 #include <public/WebGraphicsContext3D.h> | 12 #include <public/WebGraphicsContext3D.h> |
| 12 | 13 |
| 13 namespace cc { | 14 namespace cc { |
| 14 | 15 |
| 15 GeometryBinding::GeometryBinding(WebKit::WebGraphicsContext3D* context, const Fl
oatRect& quadVertexRect) | 16 GeometryBinding::GeometryBinding(WebKit::WebGraphicsContext3D* context, const gf
x::RectF& quadVertexRect) |
| 16 : m_context(context) | 17 : m_context(context) |
| 17 , m_quadVerticesVbo(0) | 18 , m_quadVerticesVbo(0) |
| 18 , m_quadElementsVbo(0) | 19 , m_quadElementsVbo(0) |
| 19 , m_initialized(false) | 20 , m_initialized(false) |
| 20 { | 21 { |
| 21 // Vertex positions and texture coordinates for the 4 corners of a 1x1 quad. | 22 // Vertex positions and texture coordinates for the 4 corners of a 1x1 quad. |
| 22 float vertices[] = { quadVertexRect.x(), quadVertexRect.maxY(), 0.0f, 0.0f,
1.0f, | 23 float vertices[] = { quadVertexRect.x(), quadVertexRect.bottom(), 0.0f, 0.0f
, 1.0f, |
| 23 quadVertexRect.x(), quadVertexRect.y(), 0.0f, 0.0f, 0.
0f, | 24 quadVertexRect.x(), quadVertexRect.y(), 0.0f, 0.0f, 0.
0f, |
| 24 quadVertexRect.maxX(), quadVertexRect.y(), 0.0f, 1.0f,
0.0f, | 25 quadVertexRect.right(), quadVertexRect.y(), 0.0f, 1.0f,
0.0f, |
| 25 quadVertexRect.maxX(), quadVertexRect.maxY(), 0.0f, 1.
0f, 1.0f }; | 26 quadVertexRect.right(), quadVertexRect.bottom(), 0.0f,
1.0f, 1.0f }; |
| 26 uint16_t indices[] = { 0, 1, 2, 0, 2, 3, // The two triangles that make up t
he layer quad. | 27 uint16_t indices[] = { 0, 1, 2, 0, 2, 3, // The two triangles that make up t
he layer quad. |
| 27 0, 1, 2, 3}; // A line path for drawing the layer bor
der. | 28 0, 1, 2, 3}; // A line path for drawing the layer bor
der. |
| 28 | 29 |
| 29 GLC(m_context, m_quadVerticesVbo = m_context->createBuffer()); | 30 GLC(m_context, m_quadVerticesVbo = m_context->createBuffer()); |
| 30 GLC(m_context, m_quadElementsVbo = m_context->createBuffer()); | 31 GLC(m_context, m_quadElementsVbo = m_context->createBuffer()); |
| 31 GLC(m_context, m_context->bindBuffer(GL_ARRAY_BUFFER, m_quadVerticesVbo)); | 32 GLC(m_context, m_context->bindBuffer(GL_ARRAY_BUFFER, m_quadVerticesVbo)); |
| 32 GLC(m_context, m_context->bufferData(GL_ARRAY_BUFFER, sizeof(vertices), vert
ices, GL_STATIC_DRAW)); | 33 GLC(m_context, m_context->bufferData(GL_ARRAY_BUFFER, sizeof(vertices), vert
ices, GL_STATIC_DRAW)); |
| 33 GLC(m_context, m_context->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_quadElements
Vbo)); | 34 GLC(m_context, m_context->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_quadElements
Vbo)); |
| 34 GLC(m_context, m_context->bufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices
), indices, GL_STATIC_DRAW)); | 35 GLC(m_context, m_context->bufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices
), indices, GL_STATIC_DRAW)); |
| 35 | 36 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 48 GLC(m_context, m_context->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, quadElementsVb
o())); | 49 GLC(m_context, m_context->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, quadElementsVb
o())); |
| 49 unsigned offset = 0; | 50 unsigned offset = 0; |
| 50 GLC(m_context, m_context->vertexAttribPointer(positionAttribLocation(), 3, G
L_FLOAT, false, 5 * sizeof(float), offset)); | 51 GLC(m_context, m_context->vertexAttribPointer(positionAttribLocation(), 3, G
L_FLOAT, false, 5 * sizeof(float), offset)); |
| 51 offset += 3 * sizeof(float); | 52 offset += 3 * sizeof(float); |
| 52 GLC(m_context, m_context->vertexAttribPointer(texCoordAttribLocation(), 2, G
L_FLOAT, false, 5 * sizeof(float), offset)); | 53 GLC(m_context, m_context->vertexAttribPointer(texCoordAttribLocation(), 2, G
L_FLOAT, false, 5 * sizeof(float), offset)); |
| 53 GLC(m_context, m_context->enableVertexAttribArray(positionAttribLocation()))
; | 54 GLC(m_context, m_context->enableVertexAttribArray(positionAttribLocation()))
; |
| 54 GLC(m_context, m_context->enableVertexAttribArray(texCoordAttribLocation()))
; | 55 GLC(m_context, m_context->enableVertexAttribArray(texCoordAttribLocation()))
; |
| 55 } | 56 } |
| 56 | 57 |
| 57 } // namespace cc | 58 } // namespace cc |
| OLD | NEW |