| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "remoting/client/plugin/pepper_video_renderer_3d.h" | 5 #include "remoting/client/plugin/pepper_video_renderer_3d.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 video_profile = PP_VIDEOPROFILE_VP9_ANY; | 203 video_profile = PP_VIDEOPROFILE_VP9_ANY; |
| 204 break; | 204 break; |
| 205 default: | 205 default: |
| 206 NOTREACHED(); | 206 NOTREACHED(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 int32_t result = video_decoder_.Initialize( | 209 int32_t result = video_decoder_.Initialize( |
| 210 graphics_, video_profile, PP_HARDWAREACCELERATION_WITHFALLBACK, | 210 graphics_, video_profile, PP_HARDWAREACCELERATION_WITHFALLBACK, |
| 211 kMinimumPictureCount, | 211 kMinimumPictureCount, |
| 212 callback_factory_.NewCallback(&PepperVideoRenderer3D::OnInitialized)); | 212 callback_factory_.NewCallback(&PepperVideoRenderer3D::OnInitialized)); |
| 213 CHECK_EQ(result, PP_OK_COMPLETIONPENDING) | 213 // video_decoder_.Initialize() returned |result| |
| 214 << "video_decoder_.Initialize() returned " << result; | 214 CHECK_EQ(result, PP_OK_COMPLETIONPENDING); |
| 215 } | 215 } |
| 216 | 216 |
| 217 protocol::VideoStub* PepperVideoRenderer3D::GetVideoStub() { | 217 protocol::VideoStub* PepperVideoRenderer3D::GetVideoStub() { |
| 218 return this; | 218 return this; |
| 219 } | 219 } |
| 220 | 220 |
| 221 protocol::FrameConsumer* PepperVideoRenderer3D::GetFrameConsumer() { | 221 protocol::FrameConsumer* PepperVideoRenderer3D::GetFrameConsumer() { |
| 222 // GetFrameConsumer() is used only for WebRTC-based connections which are not | 222 // GetFrameConsumer() is used only for WebRTC-based connections which are not |
| 223 // supported by the plugin. | 223 // supported by the plugin. |
| 224 NOTREACHED(); | 224 NOTREACHED(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 } | 286 } |
| 287 event_handler_->OnVideoFrameDirtyRegion(dirty_region); | 287 event_handler_->OnVideoFrameDirtyRegion(dirty_region); |
| 288 } | 288 } |
| 289 | 289 |
| 290 pending_frames_.push_back(std::move(frame_tracker)); | 290 pending_frames_.push_back(std::move(frame_tracker)); |
| 291 DecodeNextPacket(); | 291 DecodeNextPacket(); |
| 292 } | 292 } |
| 293 | 293 |
| 294 void PepperVideoRenderer3D::OnInitialized(int32_t result) { | 294 void PepperVideoRenderer3D::OnInitialized(int32_t result) { |
| 295 // Assume that VP8 and VP9 codecs are always supported by the browser. | 295 // Assume that VP8 and VP9 codecs are always supported by the browser. |
| 296 CHECK_EQ(result, PP_OK) << "VideoDecoder::Initialize() failed: " << result; | 296 // VideoDecoder::Initialize() failed. |
| 297 CHECK_EQ(result, PP_OK); |
| 297 initialization_finished_ = true; | 298 initialization_finished_ = true; |
| 298 | 299 |
| 299 // Start decoding in case a frame was received during decoder initialization. | 300 // Start decoding in case a frame was received during decoder initialization. |
| 300 DecodeNextPacket(); | 301 DecodeNextPacket(); |
| 301 } | 302 } |
| 302 | 303 |
| 303 void PepperVideoRenderer3D::DecodeNextPacket() { | 304 void PepperVideoRenderer3D::DecodeNextPacket() { |
| 304 if (!initialization_finished_ || decode_pending_ || pending_frames_.empty()) | 305 if (!initialization_finished_ || decode_pending_ || pending_frames_.empty()) |
| 305 return; | 306 return; |
| 306 | 307 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 CheckGLError(); | 448 CheckGLError(); |
| 448 | 449 |
| 449 // Request PPAPI display the queued texture. | 450 // Request PPAPI display the queued texture. |
| 450 int32_t result = graphics_.SwapBuffers( | 451 int32_t result = graphics_.SwapBuffers( |
| 451 callback_factory_.NewCallback(&PepperVideoRenderer3D::OnPaintDone)); | 452 callback_factory_.NewCallback(&PepperVideoRenderer3D::OnPaintDone)); |
| 452 CHECK_EQ(result, PP_OK_COMPLETIONPENDING); | 453 CHECK_EQ(result, PP_OK_COMPLETIONPENDING); |
| 453 paint_pending_ = true; | 454 paint_pending_ = true; |
| 454 } | 455 } |
| 455 | 456 |
| 456 void PepperVideoRenderer3D::OnPaintDone(int32_t result) { | 457 void PepperVideoRenderer3D::OnPaintDone(int32_t result) { |
| 457 CHECK_EQ(result, PP_OK) << "Graphics3D::SwapBuffers() failed"; | 458 // Graphics3D::SwapBuffers() failed |
| 459 CHECK_EQ(result, PP_OK); |
| 458 | 460 |
| 459 paint_pending_ = false; | 461 paint_pending_ = false; |
| 460 | 462 |
| 461 for (const auto& tracker : current_picture_frames_) { | 463 for (const auto& tracker : current_picture_frames_) { |
| 462 tracker->OnRendered(); | 464 tracker->OnRendered(); |
| 463 } | 465 } |
| 464 current_picture_frames_.clear(); | 466 current_picture_frames_.clear(); |
| 465 | 467 |
| 466 PaintIfNeeded(); | 468 PaintIfNeeded(); |
| 467 } | 469 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 int size = strlen(source); | 571 int size = strlen(source); |
| 570 GLuint shader = gles2_if_->CreateShader(graphics_.pp_resource(), type); | 572 GLuint shader = gles2_if_->CreateShader(graphics_.pp_resource(), type); |
| 571 gles2_if_->ShaderSource(graphics_.pp_resource(), shader, 1, &source, &size); | 573 gles2_if_->ShaderSource(graphics_.pp_resource(), shader, 1, &source, &size); |
| 572 gles2_if_->CompileShader(graphics_.pp_resource(), shader); | 574 gles2_if_->CompileShader(graphics_.pp_resource(), shader); |
| 573 gles2_if_->AttachShader(graphics_.pp_resource(), shader_program_, shader); | 575 gles2_if_->AttachShader(graphics_.pp_resource(), shader_program_, shader); |
| 574 gles2_if_->DeleteShader(graphics_.pp_resource(), shader); | 576 gles2_if_->DeleteShader(graphics_.pp_resource(), shader); |
| 575 } | 577 } |
| 576 | 578 |
| 577 void PepperVideoRenderer3D::CheckGLError() { | 579 void PepperVideoRenderer3D::CheckGLError() { |
| 578 GLenum error = gles2_if_->GetError(graphics_.pp_resource()); | 580 GLenum error = gles2_if_->GetError(graphics_.pp_resource()); |
| 579 CHECK_EQ(error, static_cast<GLenum>(GL_NO_ERROR)) << "GL error: " << error; | 581 // GL error. |
| 582 CHECK_EQ(error, static_cast<GLenum>(GL_NO_ERROR)); |
| 580 } | 583 } |
| 581 | 584 |
| 582 } // namespace remoting | 585 } // namespace remoting |
| OLD | NEW |