| 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 "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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 LOG(FATAL) << "Could not initialize GL"; | 201 LOG(FATAL) << "Could not initialize GL"; |
| 202 done->Signal(); | 202 done->Signal(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 RenderingHelper::RenderingHelper() : ignore_vsync_(false) { | 205 RenderingHelper::RenderingHelper() : ignore_vsync_(false) { |
| 206 window_ = gfx::kNullAcceleratedWidget; | 206 window_ = gfx::kNullAcceleratedWidget; |
| 207 Clear(); | 207 Clear(); |
| 208 } | 208 } |
| 209 | 209 |
| 210 RenderingHelper::~RenderingHelper() { | 210 RenderingHelper::~RenderingHelper() { |
| 211 CHECK_EQ(videos_.size(), 0U) << "Must call UnInitialize before dtor."; | 211 // Must call UnInitialize before dtor. |
| 212 CHECK_EQ(videos_.size(), 0U); |
| 212 Clear(); | 213 Clear(); |
| 213 } | 214 } |
| 214 | 215 |
| 215 void RenderingHelper::Setup() { | 216 void RenderingHelper::Setup() { |
| 216 #if defined(USE_X11) | 217 #if defined(USE_X11) |
| 217 Display* display = gfx::GetXDisplay(); | 218 Display* display = gfx::GetXDisplay(); |
| 218 Screen* screen = DefaultScreenOfDisplay(display); | 219 Screen* screen = DefaultScreenOfDisplay(display); |
| 219 | 220 |
| 220 CHECK(display); | 221 CHECK(display); |
| 221 | 222 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 378 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 378 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 379 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 379 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 380 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 380 glBindTexture(GL_TEXTURE_2D, 0); | 381 glBindTexture(GL_TEXTURE_2D, 0); |
| 381 | 382 |
| 382 glBindFramebufferEXT(GL_FRAMEBUFFER, thumbnails_fbo_id_); | 383 glBindFramebufferEXT(GL_FRAMEBUFFER, thumbnails_fbo_id_); |
| 383 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 384 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 384 GL_TEXTURE_2D, thumbnails_texture_id_, 0); | 385 GL_TEXTURE_2D, thumbnails_texture_id_, 0); |
| 385 | 386 |
| 386 GLenum fb_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); | 387 GLenum fb_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); |
| 387 CHECK(fb_status == GL_FRAMEBUFFER_COMPLETE) << fb_status; | 388 CHECK(fb_status == GL_FRAMEBUFFER_COMPLETE); |
| 388 glClearColor(0.0f, 0.0f, 0.0f, 1.0f); | 389 glClearColor(0.0f, 0.0f, 0.0f, 1.0f); |
| 389 glClear(GL_COLOR_BUFFER_BIT); | 390 glClear(GL_COLOR_BUFFER_BIT); |
| 390 glBindFramebufferEXT(GL_FRAMEBUFFER, | 391 glBindFramebufferEXT(GL_FRAMEBUFFER, |
| 391 gl_surface_->GetBackingFramebufferObject()); | 392 gl_surface_->GetBackingFramebufferObject()); |
| 392 } | 393 } |
| 393 | 394 |
| 394 // These vertices and texture coords. map (0,0) in the texture to the | 395 // These vertices and texture coords. map (0,0) in the texture to the |
| 395 // bottom left of the viewport. Since we get the video frames with the | 396 // bottom left of the viewport. Since we get the video frames with the |
| 396 // the top left at (0,0) we need to flip the texture y coordinate | 397 // the top left at (0,0) we need to flip the texture y coordinate |
| 397 // in the vertex shader for this to be rendered the right way up. | 398 // in the vertex shader for this to be rendered the right way up. |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 // When the rendering falls behind, drops frames. | 889 // When the rendering falls behind, drops frames. |
| 889 while (scheduled_render_time_ < target) { | 890 while (scheduled_render_time_ < target) { |
| 890 scheduled_render_time_ += frame_duration_; | 891 scheduled_render_time_ += frame_duration_; |
| 891 DropOneFrameForAllVideos(); | 892 DropOneFrameForAllVideos(); |
| 892 } | 893 } |
| 893 | 894 |
| 894 task_runner_->PostDelayedTask(FROM_HERE, render_task_.callback(), | 895 task_runner_->PostDelayedTask(FROM_HERE, render_task_.callback(), |
| 895 target - now); | 896 target - now); |
| 896 } | 897 } |
| 897 } // namespace media | 898 } // namespace media |
| OLD | NEW |