Chromium Code Reviews| Index: content/common/gpu/media/rendering_helper.cc |
| diff --git a/content/common/gpu/media/rendering_helper.cc b/content/common/gpu/media/rendering_helper.cc |
| index 6693f5f07dd5a2cb2b983ea5d289d1a1dc7b835c..957ccd9d895820709a60001a73218ef55382434d 100644 |
| --- a/content/common/gpu/media/rendering_helper.cc |
| +++ b/content/common/gpu/media/rendering_helper.cc |
| @@ -302,9 +302,36 @@ void RenderingHelper::Initialize(const RenderingHelperParams& params, |
| glEnableVertexAttribArray(tc_location); |
| glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, 0, kTextureCoords); |
| + if (frame_duration_ != base::TimeDelta()) |
| + WarmUpRendering(params.warm_up_iterations); |
| + |
| done->Signal(); |
| } |
| +// The rendering for the first few frames is slow (e.g., 100ms on Peach Pit). |
| +// This affects the numbers measured in the performance test. We try to render |
| +// several frames here to warm up the rendering. |
| +void RenderingHelper::WarmUpRendering(int warm_up_iterations) { |
| + unsigned int texture_id; |
| + std::vector<GLubyte> emptyData(screen_size_.GetArea() * 2); |
|
piman
2014/10/14 17:26:43
nit: scoped_ptr<GLubyte[]> empty_data(new GLubyte[
|
| + glGenTextures(1, &texture_id); |
| + glBindTexture(GL_TEXTURE_2D, texture_id); |
| + glTexImage2D(GL_TEXTURE_2D, |
| + 0, |
| + GL_RGB, |
| + screen_size_.width(), |
| + screen_size_.height(), |
| + 0, |
| + GL_RGB, |
| + GL_UNSIGNED_SHORT_5_6_5, |
| + &emptyData[0]); |
| + for (int i = 0; i < warm_up_iterations; ++i) { |
| + RenderTexture(GL_TEXTURE_2D, texture_id); |
| + gl_surface_->SwapBuffers(); |
| + } |
| + glDeleteTextures(1, &texture_id); |
| +} |
| + |
| void RenderingHelper::UnInitialize(base::WaitableEvent* done) { |
| CHECK_EQ(base::MessageLoop::current(), message_loop_); |