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

Side by Side Diff: media/gpu/rendering_helper.cc

Issue 2268993003: [Command Buffer] Coding style: FrameBuffer -> Framebuffer to be comformant (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: code rebase Created 4 years, 3 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
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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 385
386 glBindFramebufferEXT(GL_FRAMEBUFFER, thumbnails_fbo_id_); 386 glBindFramebufferEXT(GL_FRAMEBUFFER, thumbnails_fbo_id_);
387 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 387 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
388 GL_TEXTURE_2D, thumbnails_texture_id_, 0); 388 GL_TEXTURE_2D, thumbnails_texture_id_, 0);
389 389
390 GLenum fb_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); 390 GLenum fb_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER);
391 CHECK(fb_status == GL_FRAMEBUFFER_COMPLETE) << fb_status; 391 CHECK(fb_status == GL_FRAMEBUFFER_COMPLETE) << fb_status;
392 glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 392 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
393 glClear(GL_COLOR_BUFFER_BIT); 393 glClear(GL_COLOR_BUFFER_BIT);
394 glBindFramebufferEXT(GL_FRAMEBUFFER, 394 glBindFramebufferEXT(GL_FRAMEBUFFER,
395 gl_surface_->GetBackingFrameBufferObject()); 395 gl_surface_->GetBackingFramebufferObject());
396 } 396 }
397 397
398 // These vertices and texture coords. map (0,0) in the texture to the 398 // These vertices and texture coords. map (0,0) in the texture to the
399 // bottom left of the viewport. Since we get the video frames with the 399 // bottom left of the viewport. Since we get the video frames with the
400 // the top left at (0,0) we need to flip the texture y coordinate 400 // the top left at (0,0) we need to flip the texture y coordinate
401 // in the vertex shader for this to be rendered the right way up. 401 // in the vertex shader for this to be rendered the right way up.
402 // In the case of thumbnail rendering we use the same vertex shader 402 // In the case of thumbnail rendering we use the same vertex shader
403 // to render the FBO the screen, where we do not want this flipping. 403 // to render the FBO the screen, where we do not want this flipping.
404 static const float kVertices[] = { 404 static const float kVertices[] = {
405 -1.f, 1.f, -1.f, -1.f, 1.f, 1.f, 1.f, -1.f, 405 -1.f, 1.f, -1.f, -1.f, 1.f, 1.f, 1.f, -1.f,
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 const int row = (frame_count_ / thumbnails_in_row) % thumbnails_in_column; 603 const int row = (frame_count_ / thumbnails_in_row) % thumbnails_in_column;
604 const int col = frame_count_ % thumbnails_in_row; 604 const int col = frame_count_ % thumbnails_in_row;
605 605
606 gfx::Rect area(col * width, row * height, width, height); 606 gfx::Rect area(col * width, row * height, width, height);
607 607
608 glUniform1i(glGetUniformLocation(program_, "tex_flip"), 0); 608 glUniform1i(glGetUniformLocation(program_, "tex_flip"), 0);
609 glBindFramebufferEXT(GL_FRAMEBUFFER, thumbnails_fbo_id_); 609 glBindFramebufferEXT(GL_FRAMEBUFFER, thumbnails_fbo_id_);
610 GLSetViewPort(area); 610 GLSetViewPort(area);
611 RenderTexture(texture_target, texture_id); 611 RenderTexture(texture_target, texture_id);
612 glBindFramebufferEXT(GL_FRAMEBUFFER, 612 glBindFramebufferEXT(GL_FRAMEBUFFER,
613 gl_surface_->GetBackingFrameBufferObject()); 613 gl_surface_->GetBackingFramebufferObject());
614 614
615 // Need to flush the GL commands before we return the tnumbnail texture to 615 // Need to flush the GL commands before we return the tnumbnail texture to
616 // the decoder. 616 // the decoder.
617 glFlush(); 617 glFlush();
618 ++frame_count_; 618 ++frame_count_;
619 } 619 }
620 620
621 void RenderingHelper::QueueVideoFrame( 621 void RenderingHelper::QueueVideoFrame(
622 size_t window_id, 622 size_t window_id,
623 scoped_refptr<VideoFrameTexture> video_frame) { 623 scoped_refptr<VideoFrameTexture> video_frame) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 rgba.resize(num_pixels * 4); 690 rgba.resize(num_pixels * 4);
691 glBindFramebufferEXT(GL_FRAMEBUFFER, thumbnails_fbo_id_); 691 glBindFramebufferEXT(GL_FRAMEBUFFER, thumbnails_fbo_id_);
692 glPixelStorei(GL_PACK_ALIGNMENT, 1); 692 glPixelStorei(GL_PACK_ALIGNMENT, 1);
693 // We can only count on GL_RGBA/GL_UNSIGNED_BYTE support. 693 // We can only count on GL_RGBA/GL_UNSIGNED_BYTE support.
694 glReadPixels(0, 0, 694 glReadPixels(0, 0,
695 thumbnails_fbo_size_.width(), thumbnails_fbo_size_.height(), 695 thumbnails_fbo_size_.width(), thumbnails_fbo_size_.height(),
696 GL_RGBA, 696 GL_RGBA,
697 GL_UNSIGNED_BYTE, 697 GL_UNSIGNED_BYTE,
698 &rgba[0]); 698 &rgba[0]);
699 glBindFramebufferEXT(GL_FRAMEBUFFER, 699 glBindFramebufferEXT(GL_FRAMEBUFFER,
700 gl_surface_->GetBackingFrameBufferObject()); 700 gl_surface_->GetBackingFramebufferObject());
701 rgb->resize(num_pixels * 3); 701 rgb->resize(num_pixels * 3);
702 // Drop the alpha channel, but check as we go that it is all 0xff. 702 // Drop the alpha channel, but check as we go that it is all 0xff.
703 bool solid = true; 703 bool solid = true;
704 unsigned char* rgb_ptr = &((*rgb)[0]); 704 unsigned char* rgb_ptr = &((*rgb)[0]);
705 unsigned char* rgba_ptr = &rgba[0]; 705 unsigned char* rgba_ptr = &rgba[0];
706 for (size_t i = 0; i < num_pixels; ++i) { 706 for (size_t i = 0; i < num_pixels; ++i) {
707 *rgb_ptr++ = *rgba_ptr++; 707 *rgb_ptr++ = *rgba_ptr++;
708 *rgb_ptr++ = *rgba_ptr++; 708 *rgb_ptr++ = *rgba_ptr++;
709 *rgb_ptr++ = *rgba_ptr++; 709 *rgb_ptr++ = *rgba_ptr++;
710 solid = solid && (*rgba_ptr == 0xff); 710 solid = solid && (*rgba_ptr == 0xff);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 // When the rendering falls behind, drops frames. 882 // When the rendering falls behind, drops frames.
883 while (scheduled_render_time_ < target) { 883 while (scheduled_render_time_ < target) {
884 scheduled_render_time_ += frame_duration_; 884 scheduled_render_time_ += frame_duration_;
885 DropOneFrameForAllVideos(); 885 DropOneFrameForAllVideos();
886 } 886 }
887 887
888 message_loop_->PostDelayedTask(FROM_HERE, render_task_.callback(), 888 message_loop_->PostDelayedTask(FROM_HERE, render_task_.callback(),
889 target - now); 889 target - now);
890 } 890 }
891 } // namespace media 891 } // namespace media
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h ('k') | ui/gl/gl_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698