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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « media/gpu/rendering_helper.h ('k') | ui/gl/gl_bindings.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "media/gpu/rendering_helper.h" 5 #include "media/gpu/rendering_helper.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 glBindFramebufferEXT(GL_FRAMEBUFFER, 391 glBindFramebufferEXT(GL_FRAMEBUFFER,
392 gl_surface_->GetBackingFramebufferObject()); 392 gl_surface_->GetBackingFramebufferObject());
393 } 393 }
394 394
395 // These vertices and texture coords. map (0,0) in the texture to the 395 // These vertices and texture coords. map (0,0) in the texture to the
396 // bottom left of the viewport. Since we get the video frames with the 396 // bottom left of the viewport. Since we get the video frames with the
397 // the top left at (0,0) we need to flip the texture y coordinate 397 // the top left at (0,0) we need to flip the texture y coordinate
398 // in the vertex shader for this to be rendered the right way up. 398 // in the vertex shader for this to be rendered the right way up.
399 // In the case of thumbnail rendering we use the same vertex shader 399 // In the case of thumbnail rendering we use the same vertex shader
400 // to render the FBO the screen, where we do not want this flipping. 400 // to render the FBO the screen, where we do not want this flipping.
401 // Vertices are 2 floats for position and 2 floats for texcoord each.
401 static const float kVertices[] = { 402 static const float kVertices[] = {
402 -1.f, 1.f, -1.f, -1.f, 1.f, 1.f, 1.f, -1.f, 403 -1, 1, 0, 1, // Vertex 0
404 -1, -1, 0, 0, // Vertex 1
405 1, 1, 1, 1, // Vertex 2
406 1, -1, 1, 0, // Vertex 3
403 }; 407 };
404 static const float kTextureCoords[] = { 408 static const GLvoid* kVertexPositionOffset = 0;
405 0, 1, 0, 0, 1, 1, 1, 0, 409 static const GLvoid* kVertexTexcoordOffset =
406 }; 410 reinterpret_cast<GLvoid*>(sizeof(float) * 2);
411 static const GLsizei kVertexStride = sizeof(float) * 4;
412
413 glGenBuffersARB(1, &vertex_buffer_);
414 glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_);
415 glBufferData(GL_ARRAY_BUFFER, sizeof(kVertices), kVertices, GL_STATIC_DRAW);
416
407 static const char kVertexShader[] = 417 static const char kVertexShader[] =
408 STRINGIZE(varying vec2 interp_tc; attribute vec4 in_pos; 418 STRINGIZE(varying vec2 interp_tc; attribute vec4 in_pos;
409 attribute vec2 in_tc; uniform bool tex_flip; void main() { 419 attribute vec2 in_tc; uniform bool tex_flip; void main() {
410 if (tex_flip) 420 if (tex_flip)
411 interp_tc = vec2(in_tc.x, 1.0 - in_tc.y); 421 interp_tc = vec2(in_tc.x, 1.0 - in_tc.y);
412 else 422 else
413 interp_tc = in_tc; 423 interp_tc = in_tc;
414 gl_Position = in_pos; 424 gl_Position = in_pos;
415 }); 425 });
416 426
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 glDeleteProgram(program_); 468 glDeleteProgram(program_);
459 469
460 glUniform1i(glGetUniformLocation(program_, "tex_flip"), 0); 470 glUniform1i(glGetUniformLocation(program_, "tex_flip"), 0);
461 glUniform1i(glGetUniformLocation(program_, "tex"), 0); 471 glUniform1i(glGetUniformLocation(program_, "tex"), 0);
462 GLint tex_external = glGetUniformLocation(program_, "tex_external"); 472 GLint tex_external = glGetUniformLocation(program_, "tex_external");
463 if (tex_external != -1) { 473 if (tex_external != -1) {
464 glUniform1i(tex_external, 1); 474 glUniform1i(tex_external, 1);
465 } 475 }
466 int pos_location = glGetAttribLocation(program_, "in_pos"); 476 int pos_location = glGetAttribLocation(program_, "in_pos");
467 glEnableVertexAttribArray(pos_location); 477 glEnableVertexAttribArray(pos_location);
468 glVertexAttribPointer(pos_location, 2, GL_FLOAT, GL_FALSE, 0, kVertices); 478 glVertexAttribPointer(pos_location, 2, GL_FLOAT, GL_FALSE, kVertexStride,
479 kVertexPositionOffset);
469 int tc_location = glGetAttribLocation(program_, "in_tc"); 480 int tc_location = glGetAttribLocation(program_, "in_tc");
470 glEnableVertexAttribArray(tc_location); 481 glEnableVertexAttribArray(tc_location);
471 glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, 0, kTextureCoords); 482 glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, kVertexStride,
483 kVertexTexcoordOffset);
484
485 // Unbind the vertex buffer
486 glBindBuffer(GL_ARRAY_BUFFER, 0);
472 487
473 if (!frame_duration_.is_zero()) { 488 if (!frame_duration_.is_zero()) {
474 int warm_up_iterations = params.warm_up_iterations; 489 int warm_up_iterations = params.warm_up_iterations;
475 #if defined(USE_OZONE) 490 #if defined(USE_OZONE)
476 // On Ozone the VSyncProvider can't provide a vsync interval until 491 // On Ozone the VSyncProvider can't provide a vsync interval until
477 // we render at least a frame, so we warm up with at least one 492 // we render at least a frame, so we warm up with at least one
478 // frame. 493 // frame.
479 // On top of this, we want to make sure all the buffers backing 494 // On top of this, we want to make sure all the buffers backing
480 // the GL surface are cleared, otherwise we can see the previous 495 // the GL surface are cleared, otherwise we can see the previous
481 // test's last frames, so we set warm up iterations to 2, to clear 496 // test's last frames, so we set warm up iterations to 2, to clear
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 void RenderingHelper::UnInitialize(base::WaitableEvent* done) { 555 void RenderingHelper::UnInitialize(base::WaitableEvent* done) {
541 CHECK(task_runner_->BelongsToCurrentThread()); 556 CHECK(task_runner_->BelongsToCurrentThread());
542 557
543 render_task_.Cancel(); 558 render_task_.Cancel();
544 559
545 if (render_as_thumbnails_) { 560 if (render_as_thumbnails_) {
546 glDeleteTextures(1, &thumbnails_texture_id_); 561 glDeleteTextures(1, &thumbnails_texture_id_);
547 glDeleteFramebuffersEXT(1, &thumbnails_fbo_id_); 562 glDeleteFramebuffersEXT(1, &thumbnails_fbo_id_);
548 } 563 }
549 564
565 glDeleteBuffersARB(1, &vertex_buffer_);
566
550 gl_context_->ReleaseCurrent(gl_surface_.get()); 567 gl_context_->ReleaseCurrent(gl_surface_.get());
551 gl_context_ = NULL; 568 gl_context_ = NULL;
552 gl_surface_ = NULL; 569 gl_surface_ = NULL;
553 570
554 Clear(); 571 Clear();
555 572
556 #if defined(OS_WIN) 573 #if defined(OS_WIN)
557 if (window_) 574 if (window_)
558 DestroyWindow(window_); 575 DestroyWindow(window_);
559 window_ = gfx::kNullAcceleratedWidget; 576 window_ = gfx::kNullAcceleratedWidget;
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 // When the rendering falls behind, drops frames. 906 // When the rendering falls behind, drops frames.
890 while (scheduled_render_time_ < target) { 907 while (scheduled_render_time_ < target) {
891 scheduled_render_time_ += frame_duration_; 908 scheduled_render_time_ += frame_duration_;
892 DropOneFrameForAllVideos(); 909 DropOneFrameForAllVideos();
893 } 910 }
894 911
895 task_runner_->PostDelayedTask(FROM_HERE, render_task_.callback(), 912 task_runner_->PostDelayedTask(FROM_HERE, render_task_.callback(),
896 target - now); 913 target - now);
897 } 914 }
898 } // namespace media 915 } // namespace media
OLDNEW
« 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