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