Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 bool CgBlitPostLion(const DesktopFrame& frame, | 280 bool CgBlitPostLion(const DesktopFrame& frame, |
| 281 const DesktopRegion& region); | 281 const DesktopRegion& region); |
| 282 | 282 |
| 283 // Called when the screen configuration is changed. | 283 // Called when the screen configuration is changed. |
| 284 void ScreenConfigurationChanged(); | 284 void ScreenConfigurationChanged(); |
| 285 | 285 |
| 286 bool RegisterRefreshAndMoveHandlers(); | 286 bool RegisterRefreshAndMoveHandlers(); |
| 287 void UnregisterRefreshAndMoveHandlers(); | 287 void UnregisterRefreshAndMoveHandlers(); |
| 288 | 288 |
| 289 void ScreenRefresh(CGRectCount count, const CGRect *rect_array); | 289 void ScreenRefresh(CGRectCount count, const CGRect *rect_array); |
| 290 void ScreenUpdateMove(CGFloat delta_x, | |
| 291 CGFloat delta_y, | |
| 292 size_t count, | |
| 293 const CGRect* rect_array); | |
| 294 void ScreenRefreshCallback(CGRectCount count, const CGRect* rect_array); | 290 void ScreenRefreshCallback(CGRectCount count, const CGRect* rect_array); |
| 295 void ReleaseBuffers(); | 291 void ReleaseBuffers(); |
| 296 | 292 |
| 297 std::unique_ptr<DesktopFrame> CreateFrame(); | 293 std::unique_ptr<DesktopFrame> CreateFrame(); |
| 298 | 294 |
| 299 Callback* callback_ = nullptr; | 295 Callback* callback_ = nullptr; |
| 300 | 296 |
| 301 CGLContextObj cgl_context_ = nullptr; | 297 CGLContextObj cgl_context_ = nullptr; |
| 302 ScopedPixelBufferObject pixel_buffer_object_; | 298 ScopedPixelBufferObject pixel_buffer_object_; |
| 303 | 299 |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 938 if (display_stream_manager_->ShouldIgnoreUpdates()) | 934 if (display_stream_manager_->ShouldIgnoreUpdates()) |
| 939 return; | 935 return; |
| 940 | 936 |
| 941 // Only pay attention to frame updates. | 937 // Only pay attention to frame updates. |
| 942 if (status != kCGDisplayStreamFrameStatusFrameComplete) | 938 if (status != kCGDisplayStreamFrameStatusFrameComplete) |
| 943 return; | 939 return; |
| 944 | 940 |
| 945 size_t count = 0; | 941 size_t count = 0; |
| 946 #pragma clang diagnostic push | 942 #pragma clang diagnostic push |
| 947 #pragma clang diagnostic ignored "-Wunguarded-availability" | 943 #pragma clang diagnostic ignored "-Wunguarded-availability" |
| 948 // TODO(erikchen): Use kCGDisplayStreamUpdateDirtyRects. | |
| 949 const CGRect* rects = CGDisplayStreamUpdateGetRects( | |
| 950 updateRef, kCGDisplayStreamUpdateMovedRects, &count); | |
| 951 #pragma clang diagnostic pop | |
| 952 if (count != 0) { | |
| 953 CGFloat dx = 0; | |
| 954 CGFloat dy = 0; | |
| 955 #pragma clang diagnostic push | |
| 956 #pragma clang diagnostic ignored "-Wunguarded-availability" | |
| 957 CGDisplayStreamUpdateGetMovedRectsDelta(updateRef, &dx, &dy); | |
| 958 #pragma clang diagnostic pop | |
| 959 ScreenUpdateMove(dx, dy, count, rects); | |
| 960 } | |
| 961 | |
| 962 count = 0; | |
| 963 #pragma clang diagnostic push | |
| 964 #pragma clang diagnostic ignored "-Wunguarded-availability" | |
| 965 rects = CGDisplayStreamUpdateGetRects( | 944 rects = CGDisplayStreamUpdateGetRects( |
|
erikchen
2016/10/10 21:54:42
It's not clear to me whether CGDisplayStreamUpdate
Sergey Ulanov
2016/10/11 17:59:22
Dirty rects are passed to helper_ and then Capture
| |
| 966 updateRef, kCGDisplayStreamUpdateRefreshedRects, &count); | 945 updateRef, kCGDisplayStreamUpdateDirtyRects, &count); |
| 967 #pragma clang diagnostic pop | 946 #pragma clang diagnostic pop |
| 968 if (count != 0) { | 947 if (count != 0) { |
| 969 // According to CGDisplayStream.h, it's safe to call | 948 // According to CGDisplayStream.h, it's safe to call |
| 970 // CGDisplayStreamStop() from within the callback. | 949 // CGDisplayStreamStop() from within the callback. |
| 971 ScreenRefreshCallback(count, rects); | 950 ScreenRefreshCallback(count, rects); |
| 972 } | 951 } |
| 973 }; | 952 }; |
| 974 #pragma clang diagnostic push | 953 #pragma clang diagnostic push |
| 975 #pragma clang diagnostic ignored "-Wunguarded-availability" | 954 #pragma clang diagnostic ignored "-Wunguarded-availability" |
| 976 CGDisplayStreamRef display_stream = CGDisplayStreamCreate( | 955 CGDisplayStreamRef display_stream = CGDisplayStreamCreate( |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 1004 // Convert from Density-Independent Pixel to physical pixel coordinates. | 983 // Convert from Density-Independent Pixel to physical pixel coordinates. |
| 1005 DesktopRect rect = ScaleAndRoundCGRect(rect_array[i], dip_to_pixel_scale_); | 984 DesktopRect rect = ScaleAndRoundCGRect(rect_array[i], dip_to_pixel_scale_); |
| 1006 // Translate from local desktop to capturer framebuffer coordinates. | 985 // Translate from local desktop to capturer framebuffer coordinates. |
| 1007 rect.Translate(translate_vector); | 986 rect.Translate(translate_vector); |
| 1008 region.AddRect(rect); | 987 region.AddRect(rect); |
| 1009 } | 988 } |
| 1010 | 989 |
| 1011 helper_.InvalidateRegion(region); | 990 helper_.InvalidateRegion(region); |
| 1012 } | 991 } |
| 1013 | 992 |
| 1014 void ScreenCapturerMac::ScreenUpdateMove(CGFloat delta_x, | |
| 1015 CGFloat delta_y, | |
| 1016 size_t count, | |
| 1017 const CGRect* rect_array) { | |
| 1018 // Translate |rect_array| to identify the move's destination. | |
| 1019 CGRect refresh_rects[count]; | |
| 1020 for (CGRectCount i = 0; i < count; ++i) { | |
| 1021 refresh_rects[i] = CGRectOffset(rect_array[i], delta_x, delta_y); | |
| 1022 } | |
| 1023 | |
| 1024 // Currently we just treat move events the same as refreshes. | |
| 1025 ScreenRefresh(count, refresh_rects); | |
| 1026 } | |
| 1027 | |
| 1028 void ScreenCapturerMac::ScreenRefreshCallback(CGRectCount count, | 993 void ScreenCapturerMac::ScreenRefreshCallback(CGRectCount count, |
| 1029 const CGRect* rect_array) { | 994 const CGRect* rect_array) { |
| 1030 if (screen_pixel_bounds_.is_empty()) | 995 if (screen_pixel_bounds_.is_empty()) |
| 1031 ScreenConfigurationChanged(); | 996 ScreenConfigurationChanged(); |
| 1032 ScreenRefresh(count, rect_array); | 997 ScreenRefresh(count, rect_array); |
| 1033 } | 998 } |
| 1034 | 999 |
| 1035 std::unique_ptr<DesktopFrame> ScreenCapturerMac::CreateFrame() { | 1000 std::unique_ptr<DesktopFrame> ScreenCapturerMac::CreateFrame() { |
| 1036 std::unique_ptr<DesktopFrame> frame( | 1001 std::unique_ptr<DesktopFrame> frame( |
| 1037 new BasicDesktopFrame(screen_pixel_bounds_.size())); | 1002 new BasicDesktopFrame(screen_pixel_bounds_.size())); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1054 } | 1019 } |
| 1055 | 1020 |
| 1056 if (options.detect_updated_region()) { | 1021 if (options.detect_updated_region()) { |
| 1057 capturer.reset(new ScreenCapturerDifferWrapper(std::move(capturer))); | 1022 capturer.reset(new ScreenCapturerDifferWrapper(std::move(capturer))); |
| 1058 } | 1023 } |
| 1059 | 1024 |
| 1060 return capturer.release(); | 1025 return capturer.release(); |
| 1061 } | 1026 } |
| 1062 | 1027 |
| 1063 } // namespace webrtc | 1028 } // namespace webrtc |
| OLD | NEW |