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

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

Issue 2927893002: Remove FORMAT_RGB from gfx::PngCodec (Closed)
Patch Set: Response to comments Created 3 years, 6 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 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 task_runner_ = nullptr; 703 task_runner_ = nullptr;
704 gl_context_ = NULL; 704 gl_context_ = NULL;
705 gl_surface_ = NULL; 705 gl_surface_ = NULL;
706 706
707 render_as_thumbnails_ = false; 707 render_as_thumbnails_ = false;
708 frame_count_ = 0; 708 frame_count_ = 0;
709 thumbnails_fbo_id_ = 0; 709 thumbnails_fbo_id_ = 0;
710 thumbnails_texture_id_ = 0; 710 thumbnails_texture_id_ = 0;
711 } 711 }
712 712
713 void RenderingHelper::GetThumbnailsAsRGB(std::vector<unsigned char>* rgb, 713 void RenderingHelper::GetThumbnailsAsRGBA(std::vector<unsigned char>* rgba,
714 bool* alpha_solid, 714 base::WaitableEvent* done) {
715 base::WaitableEvent* done) {
716 CHECK(render_as_thumbnails_); 715 CHECK(render_as_thumbnails_);
717 716
718 const size_t num_pixels = thumbnails_fbo_size_.GetArea(); 717 const size_t num_pixels = thumbnails_fbo_size_.GetArea();
719 std::vector<unsigned char> rgba; 718 rgba->resize(num_pixels * 4);
720 rgba.resize(num_pixels * 4);
721 glBindFramebufferEXT(GL_FRAMEBUFFER, thumbnails_fbo_id_); 719 glBindFramebufferEXT(GL_FRAMEBUFFER, thumbnails_fbo_id_);
722 glPixelStorei(GL_PACK_ALIGNMENT, 1); 720 glPixelStorei(GL_PACK_ALIGNMENT, 1);
723 // We can only count on GL_RGBA/GL_UNSIGNED_BYTE support. 721 // We can only count on GL_RGBA/GL_UNSIGNED_BYTE support.
724 glReadPixels(0, 0, 722 glReadPixels(0, 0,
725 thumbnails_fbo_size_.width(), thumbnails_fbo_size_.height(), 723 thumbnails_fbo_size_.width(), thumbnails_fbo_size_.height(),
726 GL_RGBA, 724 GL_RGBA,
727 GL_UNSIGNED_BYTE, 725 GL_UNSIGNED_BYTE,
728 &rgba[0]); 726 &rgba[0]);
Owen Lin 2017/06/15 07:28:05 &(*rgba)[0]
msarett 2017/06/15 18:06:43 Done.
729 glBindFramebufferEXT(GL_FRAMEBUFFER, 727 glBindFramebufferEXT(GL_FRAMEBUFFER,
730 gl_surface_->GetBackingFramebufferObject()); 728 gl_surface_->GetBackingFramebufferObject());
731 rgb->resize(num_pixels * 3);
732 // Drop the alpha channel, but check as we go that it is all 0xff.
733 bool solid = true;
734 unsigned char* rgb_ptr = &((*rgb)[0]);
735 unsigned char* rgba_ptr = &rgba[0];
736 for (size_t i = 0; i < num_pixels; ++i) {
737 *rgb_ptr++ = *rgba_ptr++;
738 *rgb_ptr++ = *rgba_ptr++;
739 *rgb_ptr++ = *rgba_ptr++;
740 solid = solid && (*rgba_ptr == 0xff);
741 rgba_ptr++;
742 }
743 *alpha_solid = solid;
744 729
745 done->Signal(); 730 done->Signal();
746 } 731 }
747 732
748 void RenderingHelper::Flush(size_t window_id) { 733 void RenderingHelper::Flush(size_t window_id) {
749 videos_[window_id].is_flushing = true; 734 videos_[window_id].is_flushing = true;
750 } 735 }
751 736
752 void RenderingHelper::RenderContent() { 737 void RenderingHelper::RenderContent() {
753 CHECK(task_runner_->BelongsToCurrentThread()); 738 CHECK(task_runner_->BelongsToCurrentThread());
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 // When the rendering falls behind, drops frames. 897 // When the rendering falls behind, drops frames.
913 while (scheduled_render_time_ < target) { 898 while (scheduled_render_time_ < target) {
914 scheduled_render_time_ += frame_duration_; 899 scheduled_render_time_ += frame_duration_;
915 DropOneFrameForAllVideos(); 900 DropOneFrameForAllVideos();
916 } 901 }
917 902
918 task_runner_->PostDelayedTask(FROM_HERE, render_task_.callback(), 903 task_runner_->PostDelayedTask(FROM_HERE, render_task_.callback(),
919 target - now); 904 target - now);
920 } 905 }
921 } // namespace media 906 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698