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 "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 packet->format().y_dpi()); | 227 packet->format().y_dpi()); |
228 if (!frame_dpi_.equals(frame_dpi)) { | 228 if (!frame_dpi_.equals(frame_dpi)) { |
229 frame_dpi_ = frame_dpi; | 229 frame_dpi_ = frame_dpi; |
230 resolution_changed = true; | 230 resolution_changed = true; |
231 } | 231 } |
232 } | 232 } |
233 | 233 |
234 if (resolution_changed) | 234 if (resolution_changed) |
235 event_handler_->OnVideoSize(frame_size_, frame_dpi_); | 235 event_handler_->OnVideoSize(frame_size_, frame_dpi_); |
236 | 236 |
237 // Update the desktop shape region. | 237 // Process the frame shape, if supplied. |
238 webrtc::DesktopRegion desktop_shape; | |
239 if (packet->has_use_desktop_shape()) { | 238 if (packet->has_use_desktop_shape()) { |
240 for (int i = 0; i < packet->desktop_shape_rects_size(); ++i) { | 239 if (packet->use_desktop_shape()) { |
241 Rect remoting_rect = packet->desktop_shape_rects(i); | 240 scoped_ptr<webrtc::DesktopRegion> shape(new webrtc::DesktopRegion); |
242 desktop_shape.AddRect(webrtc::DesktopRect::MakeXYWH( | 241 for (int i = 0; i < packet->desktop_shape_rects_size(); ++i) { |
243 remoting_rect.x(), remoting_rect.y(), | 242 Rect remoting_rect = packet->desktop_shape_rects(i); |
244 remoting_rect.width(), remoting_rect.height())); | 243 shape->AddRect(webrtc::DesktopRect::MakeXYWH( |
| 244 remoting_rect.x(), remoting_rect.y(), remoting_rect.width(), |
| 245 remoting_rect.height())); |
| 246 } |
| 247 if (!frame_shape_ || !frame_shape_->Equals(*shape)) { |
| 248 frame_shape_ = shape.Pass(); |
| 249 event_handler_->OnVideoShape(frame_shape_.get()); |
| 250 } |
| 251 } else if (frame_shape_) { |
| 252 frame_shape_ = nullptr; |
| 253 event_handler_->OnVideoShape(nullptr); |
245 } | 254 } |
246 } else { | |
247 // Fallback for the case when the host didn't include the desktop shape. | |
248 desktop_shape = | |
249 webrtc::DesktopRegion(webrtc::DesktopRect::MakeSize(frame_size_)); | |
250 } | |
251 | |
252 if (!desktop_shape_.Equals(desktop_shape)) { | |
253 desktop_shape_.Swap(&desktop_shape); | |
254 event_handler_->OnVideoShape(desktop_shape_); | |
255 } | 255 } |
256 | 256 |
257 // Report the dirty region, for debugging, if requested. | 257 // Report the dirty region, for debugging, if requested. |
258 if (debug_dirty_region_) { | 258 if (debug_dirty_region_) { |
259 webrtc::DesktopRegion dirty_region; | 259 webrtc::DesktopRegion dirty_region; |
260 for (int i = 0; i < packet->dirty_rects_size(); ++i) { | 260 for (int i = 0; i < packet->dirty_rects_size(); ++i) { |
261 Rect remoting_rect = packet->dirty_rects(i); | 261 Rect remoting_rect = packet->dirty_rects(i); |
262 dirty_region.AddRect(webrtc::DesktopRect::MakeXYWH( | 262 dirty_region.AddRect(webrtc::DesktopRect::MakeXYWH( |
263 remoting_rect.x(), remoting_rect.y(), | 263 remoting_rect.x(), remoting_rect.y(), |
264 remoting_rect.width(), remoting_rect.height())); | 264 remoting_rect.width(), remoting_rect.height())); |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 gles2_if_->AttachShader(graphics_.pp_resource(), shader_program_, shader); | 530 gles2_if_->AttachShader(graphics_.pp_resource(), shader_program_, shader); |
531 gles2_if_->DeleteShader(graphics_.pp_resource(), shader); | 531 gles2_if_->DeleteShader(graphics_.pp_resource(), shader); |
532 } | 532 } |
533 | 533 |
534 void PepperVideoRenderer3D::CheckGLError() { | 534 void PepperVideoRenderer3D::CheckGLError() { |
535 GLenum error = gles2_if_->GetError(graphics_.pp_resource()); | 535 GLenum error = gles2_if_->GetError(graphics_.pp_resource()); |
536 CHECK_EQ(error, static_cast<GLenum>(GL_NO_ERROR)) << "GL error: " << error; | 536 CHECK_EQ(error, static_cast<GLenum>(GL_NO_ERROR)) << "GL error: " << error; |
537 } | 537 } |
538 | 538 |
539 } // namespace remoting | 539 } // namespace remoting |
OLD | NEW |