Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 glGenTextures(1, &texture_id); | |
| 317 glBindTexture(GL_TEXTURE_2D, texture_id); | |
| 318 glTexImage2D(GL_TEXTURE_2D, | |
| 319 0, | |
| 320 GL_RGB, | |
| 321 screen_size_.width(), | |
| 322 screen_size_.height(), | |
| 323 0, | |
| 324 GL_RGB, | |
| 325 GL_UNSIGNED_SHORT_5_6_5, | |
| 326 NULL); | |
|
piman
2014/10/07 19:31:07
It'd be better not to render an uninitialized text
Owen Lin
2014/10/14 06:01:50
Done.
| |
| 327 for (int i = 0; i < warm_up_iterations; ++i) { | |
| 328 RenderTexture(GL_TEXTURE_2D, texture_id); | |
| 329 gl_surface_->SwapBuffers(); | |
| 330 } | |
| 331 glDeleteTextures(1, &texture_id); | |
| 332 } | |
| 333 | |
| 308 void RenderingHelper::UnInitialize(base::WaitableEvent* done) { | 334 void RenderingHelper::UnInitialize(base::WaitableEvent* done) { |
| 309 CHECK_EQ(base::MessageLoop::current(), message_loop_); | 335 CHECK_EQ(base::MessageLoop::current(), message_loop_); |
| 310 | 336 |
| 311 render_task_.Cancel(); | 337 render_task_.Cancel(); |
| 312 | 338 |
| 313 if (render_as_thumbnails_) { | 339 if (render_as_thumbnails_) { |
| 314 glDeleteTextures(1, &thumbnails_texture_id_); | 340 glDeleteTextures(1, &thumbnails_texture_id_); |
| 315 glDeleteFramebuffersEXT(1, &thumbnails_fbo_id_); | 341 glDeleteFramebuffersEXT(1, &thumbnails_fbo_id_); |
| 316 } | 342 } |
| 317 | 343 |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 604 scale = std::min(1.0f, scale); | 630 scale = std::min(1.0f, scale); |
| 605 | 631 |
| 606 size_t w = scale * size.width(); | 632 size_t w = scale * size.width(); |
| 607 size_t h = scale * size.height(); | 633 size_t h = scale * size.height(); |
| 608 size_t x = offset_x[i % cols] + (widths[i % cols] - w) / 2; | 634 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; | 635 size_t y = offset_y[i / cols] + (heights[i / cols] - h) / 2; |
| 610 videos_[i].render_area = gfx::Rect(x, y, w, h); | 636 videos_[i].render_area = gfx::Rect(x, y, w, h); |
| 611 } | 637 } |
| 612 } | 638 } |
| 613 } // namespace content | 639 } // namespace content |
| OLD | NEW |