summaryrefslogtreecommitdiffstats
path: root/cc/output/geometry_binding.cc
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-11 11:28:35 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-11 11:28:35 +0000
commit8cb79f2529a67652002551b98883936e5cc1c9e7 (patch)
tree217dedb4affa0d55eaaee4e97c66e81fab4d13cb /cc/output/geometry_binding.cc
parentfa5230c8ab83c83c34225e7086e99ff7243e293a (diff)
downloadchromium_src-8cb79f2529a67652002551b98883936e5cc1c9e7.zip
chromium_src-8cb79f2529a67652002551b98883936e5cc1c9e7.tar.gz
chromium_src-8cb79f2529a67652002551b98883936e5cc1c9e7.tar.bz2
Convert cc::GeometryBinding over to GLES2Interface
BUG=181120 Review URL: https://codereview.chromium.org/108353007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240076 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/output/geometry_binding.cc')
-rw-r--r--cc/output/geometry_binding.cc141
1 files changed, 67 insertions, 74 deletions
diff --git a/cc/output/geometry_binding.cc b/cc/output/geometry_binding.cc
index e1f168a..bf87b1e 100644
--- a/cc/output/geometry_binding.cc
+++ b/cc/output/geometry_binding.cc
@@ -5,17 +5,15 @@
#include "cc/output/geometry_binding.h"
#include "cc/output/gl_renderer.h" // For the GLC() macro.
-#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
+#include "gpu/command_buffer/client/gles2_interface.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "ui/gfx/rect_f.h"
namespace cc {
-GeometryBinding::GeometryBinding(blink::WebGraphicsContext3D* context,
+GeometryBinding::GeometryBinding(gpu::gles2::GLES2Interface* gl,
const gfx::RectF& quad_vertex_rect)
- : context_(context),
- quad_vertices_vbo_(0),
- quad_elements_vbo_(0) {
+ : gl_(gl), quad_vertices_vbo_(0), quad_elements_vbo_(0) {
struct Vertex {
float a_position[3];
float a_texCoord[2];
@@ -29,9 +27,8 @@ GeometryBinding::GeometryBinding(blink::WebGraphicsContext3D* context,
uint16 data[6];
};
- COMPILE_ASSERT(
- sizeof(Quad) == 24 * sizeof(float), // NOLINT(runtime/sizeof)
- struct_is_densely_packed);
+ COMPILE_ASSERT(sizeof(Quad) == 24 * sizeof(float), // NOLINT(runtime/sizeof)
+ struct_is_densely_packed);
COMPILE_ASSERT(
sizeof(QuadIndex) == 6 * sizeof(uint16_t), // NOLINT(runtime/sizeof)
struct_is_densely_packed);
@@ -39,84 +36,80 @@ GeometryBinding::GeometryBinding(blink::WebGraphicsContext3D* context,
Quad quad_list[8];
QuadIndex quad_index_list[8];
for (int i = 0; i < 8; i++) {
- Vertex v0 = { { quad_vertex_rect.x(), quad_vertex_rect.bottom(), 0.0f, },
- { 0.0f, 1.0f, },
- i * 4.0f + 0.0f };
- Vertex v1 = { { quad_vertex_rect.x(), quad_vertex_rect.y(), 0.0f, },
- { 0.0f, 0.0f, },
- i * 4.0f + 1.0f };
- Vertex v2 = { { quad_vertex_rect.right(), quad_vertex_rect.y(), 0.0f, },
- { 1.0f, .0f, },
- i * 4.0f + 2.0f };
- Vertex v3 = { { quad_vertex_rect.right(),
- quad_vertex_rect.bottom(),
- 0.0f, },
- { 1.0f, 1.0f, },
- i * 4.0f + 3.0f };
- Quad x = { v0, v1, v2, v3 };
+ Vertex v0 = {{quad_vertex_rect.x(), quad_vertex_rect.bottom(), 0.0f, },
+ {0.0f, 1.0f, }, i * 4.0f + 0.0f};
+ Vertex v1 = {{quad_vertex_rect.x(), quad_vertex_rect.y(), 0.0f, },
+ {0.0f, 0.0f, }, i * 4.0f + 1.0f};
+ Vertex v2 = {{quad_vertex_rect.right(), quad_vertex_rect.y(), 0.0f, },
+ {1.0f, .0f, }, i * 4.0f + 2.0f};
+ Vertex v3 = {{quad_vertex_rect.right(), quad_vertex_rect.bottom(), 0.0f, },
+ {1.0f, 1.0f, }, i * 4.0f + 3.0f};
+ Quad x = {v0, v1, v2, v3};
quad_list[i] = x;
- QuadIndex y = { { static_cast<uint16>(0 + 4 * i),
- static_cast<uint16>(1 + 4 * i),
- static_cast<uint16>(2 + 4 * i),
- static_cast<uint16>(3 + 4 * i),
- static_cast<uint16>(0 + 4 * i),
- static_cast<uint16>(2 + 4 * i) } };
+ QuadIndex y = {
+ {static_cast<uint16>(0 + 4 * i), static_cast<uint16>(1 + 4 * i),
+ static_cast<uint16>(2 + 4 * i), static_cast<uint16>(3 + 4 * i),
+ static_cast<uint16>(0 + 4 * i), static_cast<uint16>(2 + 4 * i)}};
quad_index_list[i] = y;
}
- GLC(context_, quad_vertices_vbo_ = context_->createBuffer());
- GLC(context_, quad_elements_vbo_ = context_->createBuffer());
- GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, quad_vertices_vbo_));
- GLC(context_,
- context_->bufferData(
+ gl_->GenBuffers(1, &quad_vertices_vbo_);
+ gl_->GenBuffers(1, &quad_elements_vbo_);
+ GLC(gl_, gl_->BindBuffer(GL_ARRAY_BUFFER, quad_vertices_vbo_));
+ GLC(gl_,
+ gl_->BufferData(
GL_ARRAY_BUFFER, sizeof(quad_list), quad_list, GL_STATIC_DRAW));
- GLC(context_,
- context_->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_elements_vbo_));
- GLC(context_,
- context_->bufferData(GL_ELEMENT_ARRAY_BUFFER,
- sizeof(quad_index_list),
- quad_index_list,
- GL_STATIC_DRAW));
+ GLC(gl_, gl_->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_elements_vbo_));
+ GLC(gl_,
+ gl_->BufferData(GL_ELEMENT_ARRAY_BUFFER,
+ sizeof(quad_index_list),
+ quad_index_list,
+ GL_STATIC_DRAW));
}
GeometryBinding::~GeometryBinding() {
- GLC(context_, context_->deleteBuffer(quad_vertices_vbo_));
- GLC(context_, context_->deleteBuffer(quad_elements_vbo_));
+ gl_->DeleteBuffers(1, &quad_vertices_vbo_);
+ gl_->DeleteBuffers(1, &quad_elements_vbo_);
}
void GeometryBinding::PrepareForDraw() {
- GLC(context_,
- context_->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_elements_vbo_));
+ GLC(gl_, gl_->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_elements_vbo_));
+
+ GLC(gl_, gl_->BindBuffer(GL_ARRAY_BUFFER, quad_vertices_vbo_));
+ // OpenGL defines the last parameter to VertexAttribPointer as type
+ // "const GLvoid*" even though it is actually an offset into the buffer
+ // object's data store and not a pointer to the client's address space.
+ const void* offsets[3] = {
+ 0, reinterpret_cast<const void*>(
+ 3 * sizeof(float)), // NOLINT(runtime/sizeof)
+ reinterpret_cast<const void*>(5 *
+ sizeof(float)), // NOLINT(runtime/sizeof)
+ };
- GLC(context_, context_->bindBuffer(GL_ARRAY_BUFFER, quad_vertices_vbo_));
- GLC(context_,
- context_->vertexAttribPointer(
- PositionAttribLocation(),
- 3,
- GL_FLOAT,
- false,
- 6 * sizeof(float), // NOLINT(runtime/sizeof)
- 0));
- GLC(context_,
- context_->vertexAttribPointer(
- TexCoordAttribLocation(),
- 2,
- GL_FLOAT,
- false,
- 6 * sizeof(float), // NOLINT(runtime/sizeof)
- 3 * sizeof(float))); // NOLINT(runtime/sizeof)
- GLC(context_,
- context_->vertexAttribPointer(
- TriangleIndexAttribLocation(),
- 1,
- GL_FLOAT,
- false,
- 6 * sizeof(float), // NOLINT(runtime/sizeof)
- 5 * sizeof(float))); // NOLINT(runtime/sizeof)
- GLC(context_, context_->enableVertexAttribArray(PositionAttribLocation()));
- GLC(context_, context_->enableVertexAttribArray(TexCoordAttribLocation()));
- GLC(context_,
- context_->enableVertexAttribArray(TriangleIndexAttribLocation()));
+ GLC(gl_,
+ gl_->VertexAttribPointer(PositionAttribLocation(),
+ 3,
+ GL_FLOAT,
+ false,
+ 6 * sizeof(float), // NOLINT(runtime/sizeof)
+ offsets[0]));
+ GLC(gl_,
+ gl_->VertexAttribPointer(TexCoordAttribLocation(),
+ 2,
+ GL_FLOAT,
+ false,
+ 6 * sizeof(float), // NOLINT(runtime/sizeof)
+ offsets[1]));
+ GLC(gl_,
+ gl_->VertexAttribPointer(TriangleIndexAttribLocation(),
+ 1,
+ GL_FLOAT,
+ false,
+ 6 * sizeof(float), // NOLINT(runtime/sizeof)
+ offsets[2]));
+ GLC(gl_, gl_->EnableVertexAttribArray(PositionAttribLocation()));
+ GLC(gl_, gl_->EnableVertexAttribArray(TexCoordAttribLocation()));
+ GLC(gl_, gl_->EnableVertexAttribArray(TriangleIndexAttribLocation()));
}
} // namespace cc