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

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

Issue 583503002: rendering_helper - Warm up the rendering. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments Created 6 years, 2 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 "content/common/gpu/media/rendering_helper.h" 5 #include "content/common/gpu/media/rendering_helper.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <numeric> 8 #include <numeric>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 if (tex_external != -1) { 295 if (tex_external != -1) {
296 glUniform1i(tex_external, 1); 296 glUniform1i(tex_external, 1);
297 } 297 }
298 int pos_location = glGetAttribLocation(program_, "in_pos"); 298 int pos_location = glGetAttribLocation(program_, "in_pos");
299 glEnableVertexAttribArray(pos_location); 299 glEnableVertexAttribArray(pos_location);
300 glVertexAttribPointer(pos_location, 2, GL_FLOAT, GL_FALSE, 0, kVertices); 300 glVertexAttribPointer(pos_location, 2, GL_FLOAT, GL_FALSE, 0, kVertices);
301 int tc_location = glGetAttribLocation(program_, "in_tc"); 301 int tc_location = glGetAttribLocation(program_, "in_tc");
302 glEnableVertexAttribArray(tc_location); 302 glEnableVertexAttribArray(tc_location);
303 glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, 0, kTextureCoords); 303 glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, 0, kTextureCoords);
304 304
305 if (frame_duration_ != base::TimeDelta())
306 WarmUpRendering(params.warm_up_iterations);
307
305 done->Signal(); 308 done->Signal();
306 } 309 }
307 310
311 // The rendering for the first few frames is slow (e.g., 100ms on Peach Pit).
312 // This affects the numbers measured in the performance test. We try to render
313 // several frames here to warm up the rendering.
314 void RenderingHelper::WarmUpRendering(int warm_up_iterations) {
315 unsigned int texture_id;
316 std::vector<GLubyte> emptyData(screen_size_.GetArea() * 2);
piman 2014/10/14 17:26:43 nit: scoped_ptr<GLubyte[]> empty_data(new GLubyte[
317 glGenTextures(1, &texture_id);
318 glBindTexture(GL_TEXTURE_2D, texture_id);
319 glTexImage2D(GL_TEXTURE_2D,
320 0,
321 GL_RGB,
322 screen_size_.width(),
323 screen_size_.height(),
324 0,
325 GL_RGB,
326 GL_UNSIGNED_SHORT_5_6_5,
327 &emptyData[0]);
328 for (int i = 0; i < warm_up_iterations; ++i) {
329 RenderTexture(GL_TEXTURE_2D, texture_id);
330 gl_surface_->SwapBuffers();
331 }
332 glDeleteTextures(1, &texture_id);
333 }
334
308 void RenderingHelper::UnInitialize(base::WaitableEvent* done) { 335 void RenderingHelper::UnInitialize(base::WaitableEvent* done) {
309 CHECK_EQ(base::MessageLoop::current(), message_loop_); 336 CHECK_EQ(base::MessageLoop::current(), message_loop_);
310 337
311 render_task_.Cancel(); 338 render_task_.Cancel();
312 339
313 if (render_as_thumbnails_) { 340 if (render_as_thumbnails_) {
314 glDeleteTextures(1, &thumbnails_texture_id_); 341 glDeleteTextures(1, &thumbnails_texture_id_);
315 glDeleteFramebuffersEXT(1, &thumbnails_fbo_id_); 342 glDeleteFramebuffersEXT(1, &thumbnails_fbo_id_);
316 } 343 }
317 344
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 scale = std::min(1.0f, scale); 631 scale = std::min(1.0f, scale);
605 632
606 size_t w = scale * size.width(); 633 size_t w = scale * size.width();
607 size_t h = scale * size.height(); 634 size_t h = scale * size.height();
608 size_t x = offset_x[i % cols] + (widths[i % cols] - w) / 2; 635 size_t x = offset_x[i % cols] + (widths[i % cols] - w) / 2;
609 size_t y = offset_y[i / cols] + (heights[i / cols] - h) / 2; 636 size_t y = offset_y[i / cols] + (heights[i / cols] - h) / 2;
610 videos_[i].render_area = gfx::Rect(x, y, w, h); 637 videos_[i].render_area = gfx::Rect(x, y, w, h);
611 } 638 }
612 } 639 }
613 } // namespace content 640 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/rendering_helper.h ('k') | content/common/gpu/media/video_decode_accelerator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698