Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(504)

Unified Diff: media/gpu/rendering_helper.cc

Issue 2695063003: Hook up the ANGLE extensions for disabling client-side data. (Closed)
Patch Set: rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/gpu/rendering_helper.h ('k') | ui/gl/gl_bindings.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/gpu/rendering_helper.cc
diff --git a/media/gpu/rendering_helper.cc b/media/gpu/rendering_helper.cc
index 2ef0c3e6f250d88ab288acdf525b167a592cc59f..69d631b30cda4a97128fca6d179ba56b3f1e1282 100644
--- a/media/gpu/rendering_helper.cc
+++ b/media/gpu/rendering_helper.cc
@@ -398,12 +398,22 @@ void RenderingHelper::Initialize(const RenderingHelperParams& params,
// in the vertex shader for this to be rendered the right way up.
// In the case of thumbnail rendering we use the same vertex shader
// to render the FBO the screen, where we do not want this flipping.
+ // Vertices are 2 floats for position and 2 floats for texcoord each.
static const float kVertices[] = {
- -1.f, 1.f, -1.f, -1.f, 1.f, 1.f, 1.f, -1.f,
- };
- static const float kTextureCoords[] = {
- 0, 1, 0, 0, 1, 1, 1, 0,
+ -1, 1, 0, 1, // Vertex 0
+ -1, -1, 0, 0, // Vertex 1
+ 1, 1, 1, 1, // Vertex 2
+ 1, -1, 1, 0, // Vertex 3
};
+ static const GLvoid* kVertexPositionOffset = 0;
+ static const GLvoid* kVertexTexcoordOffset =
+ reinterpret_cast<GLvoid*>(sizeof(float) * 2);
+ static const GLsizei kVertexStride = sizeof(float) * 4;
+
+ glGenBuffersARB(1, &vertex_buffer_);
+ glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(kVertices), kVertices, GL_STATIC_DRAW);
+
static const char kVertexShader[] =
STRINGIZE(varying vec2 interp_tc; attribute vec4 in_pos;
attribute vec2 in_tc; uniform bool tex_flip; void main() {
@@ -465,10 +475,15 @@ void RenderingHelper::Initialize(const RenderingHelperParams& params,
}
int pos_location = glGetAttribLocation(program_, "in_pos");
glEnableVertexAttribArray(pos_location);
- glVertexAttribPointer(pos_location, 2, GL_FLOAT, GL_FALSE, 0, kVertices);
+ glVertexAttribPointer(pos_location, 2, GL_FLOAT, GL_FALSE, kVertexStride,
+ kVertexPositionOffset);
int tc_location = glGetAttribLocation(program_, "in_tc");
glEnableVertexAttribArray(tc_location);
- glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, 0, kTextureCoords);
+ glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, kVertexStride,
+ kVertexTexcoordOffset);
+
+ // Unbind the vertex buffer
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
if (!frame_duration_.is_zero()) {
int warm_up_iterations = params.warm_up_iterations;
@@ -547,6 +562,8 @@ void RenderingHelper::UnInitialize(base::WaitableEvent* done) {
glDeleteFramebuffersEXT(1, &thumbnails_fbo_id_);
}
+ glDeleteBuffersARB(1, &vertex_buffer_);
+
gl_context_->ReleaseCurrent(gl_surface_.get());
gl_context_ = NULL;
gl_surface_ = NULL;
« no previous file with comments | « media/gpu/rendering_helper.h ('k') | ui/gl/gl_bindings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698