| 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 <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "ppapi/c/pp_codecs.h" | 13 #include "ppapi/c/pp_codecs.h" |
| 14 #include "ppapi/c/ppb_opengles2.h" | 14 #include "ppapi/c/ppb_opengles2.h" |
| 15 #include "ppapi/c/ppb_video_decoder.h" | 15 #include "ppapi/c/ppb_video_decoder.h" |
| 16 #include "ppapi/cpp/instance.h" | 16 #include "ppapi/cpp/instance.h" |
| 17 #include "ppapi/lib/gl/include/GLES2/gl2.h" | 17 #include "ppapi/lib/gl/include/GLES2/gl2.h" |
| 18 #include "ppapi/lib/gl/include/GLES2/gl2ext.h" | 18 #include "ppapi/lib/gl/include/GLES2/gl2ext.h" |
| 19 #include "remoting/proto/video.pb.h" | 19 #include "remoting/proto/video.pb.h" |
| 20 #include "remoting/protocol/performance_tracker.h" | 20 #include "remoting/protocol/performance_tracker.h" |
| 21 #include "remoting/protocol/session_config.h" | 21 #include "remoting/protocol/session_config.h" |
| 22 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" |
| 22 | 23 |
| 23 namespace remoting { | 24 namespace remoting { |
| 24 | 25 |
| 25 // The implementation here requires that the decoder allocates at least 3 | 26 // The implementation here requires that the decoder allocates at least 3 |
| 26 // pictures. PPB_VideoDecoder didn't support this parameter prior to | 27 // pictures. PPB_VideoDecoder didn't support this parameter prior to |
| 27 // 1.1, so we have to pass 0 for backwards compatibility with older versions of | 28 // 1.1, so we have to pass 0 for backwards compatibility with older versions of |
| 28 // the browser. Currently all API implementations allocate more than 3 buffers | 29 // the browser. Currently all API implementations allocate more than 3 buffers |
| 29 // by default. | 30 // by default. |
| 30 // | 31 // |
| 31 // TODO(sergeyu): Change this to 3 once PPB_VideoDecoder v1.1 is enabled on | 32 // TODO(sergeyu): Change this to 3 once PPB_VideoDecoder v1.1 is enabled on |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 packet->format().y_dpi()); | 214 packet->format().y_dpi()); |
| 214 if (!frame_dpi_.equals(frame_dpi)) { | 215 if (!frame_dpi_.equals(frame_dpi)) { |
| 215 frame_dpi_ = frame_dpi; | 216 frame_dpi_ = frame_dpi; |
| 216 resolution_changed = true; | 217 resolution_changed = true; |
| 217 } | 218 } |
| 218 } | 219 } |
| 219 | 220 |
| 220 if (resolution_changed) | 221 if (resolution_changed) |
| 221 event_handler_->OnVideoSize(frame_size_, frame_dpi_); | 222 event_handler_->OnVideoSize(frame_size_, frame_dpi_); |
| 222 | 223 |
| 223 // Process the frame shape, if supplied. | |
| 224 if (packet->has_use_desktop_shape()) { | |
| 225 if (packet->use_desktop_shape()) { | |
| 226 scoped_ptr<webrtc::DesktopRegion> shape(new webrtc::DesktopRegion); | |
| 227 for (int i = 0; i < packet->desktop_shape_rects_size(); ++i) { | |
| 228 Rect remoting_rect = packet->desktop_shape_rects(i); | |
| 229 shape->AddRect(webrtc::DesktopRect::MakeXYWH( | |
| 230 remoting_rect.x(), remoting_rect.y(), remoting_rect.width(), | |
| 231 remoting_rect.height())); | |
| 232 } | |
| 233 if (!frame_shape_ || !frame_shape_->Equals(*shape)) { | |
| 234 frame_shape_ = std::move(shape); | |
| 235 event_handler_->OnVideoShape(frame_shape_.get()); | |
| 236 } | |
| 237 } else if (frame_shape_) { | |
| 238 frame_shape_ = nullptr; | |
| 239 event_handler_->OnVideoShape(nullptr); | |
| 240 } | |
| 241 } | |
| 242 | |
| 243 // Report the dirty region, for debugging, if requested. | 224 // Report the dirty region, for debugging, if requested. |
| 244 if (debug_dirty_region_) { | 225 if (debug_dirty_region_) { |
| 245 webrtc::DesktopRegion dirty_region; | 226 webrtc::DesktopRegion dirty_region; |
| 246 for (int i = 0; i < packet->dirty_rects_size(); ++i) { | 227 for (int i = 0; i < packet->dirty_rects_size(); ++i) { |
| 247 Rect remoting_rect = packet->dirty_rects(i); | 228 Rect remoting_rect = packet->dirty_rects(i); |
| 248 dirty_region.AddRect(webrtc::DesktopRect::MakeXYWH( | 229 dirty_region.AddRect(webrtc::DesktopRect::MakeXYWH( |
| 249 remoting_rect.x(), remoting_rect.y(), | 230 remoting_rect.x(), remoting_rect.y(), |
| 250 remoting_rect.width(), remoting_rect.height())); | 231 remoting_rect.width(), remoting_rect.height())); |
| 251 } | 232 } |
| 252 event_handler_->OnVideoFrameDirtyRegion(dirty_region); | 233 event_handler_->OnVideoFrameDirtyRegion(dirty_region); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 gles2_if_->AttachShader(graphics_.pp_resource(), shader_program_, shader); | 505 gles2_if_->AttachShader(graphics_.pp_resource(), shader_program_, shader); |
| 525 gles2_if_->DeleteShader(graphics_.pp_resource(), shader); | 506 gles2_if_->DeleteShader(graphics_.pp_resource(), shader); |
| 526 } | 507 } |
| 527 | 508 |
| 528 void PepperVideoRenderer3D::CheckGLError() { | 509 void PepperVideoRenderer3D::CheckGLError() { |
| 529 GLenum error = gles2_if_->GetError(graphics_.pp_resource()); | 510 GLenum error = gles2_if_->GetError(graphics_.pp_resource()); |
| 530 CHECK_EQ(error, static_cast<GLenum>(GL_NO_ERROR)) << "GL error: " << error; | 511 CHECK_EQ(error, static_cast<GLenum>(GL_NO_ERROR)) << "GL error: " << error; |
| 531 } | 512 } |
| 532 | 513 |
| 533 } // namespace remoting | 514 } // namespace remoting |
| OLD | NEW |