Bug 1409018 - Remove ifdefs for OS X 10.7 from webrtc; r=pehrsons
authorDan Minor <dminor@mozilla.com>
Tue, 05 Jun 2018 08:11:56 -0400
changeset 479579 a7bd9bd361a3da29ab46cc4bbedc34270d23fd5a
parent 479578 89b72c9c5db5dc38c0dd6547eac9b1b1a777c53f
child 479580 1a8d462805f02ed0314c6da98e37000ccdd04592
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspehrsons
bugs1409018
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1409018 - Remove ifdefs for OS X 10.7 from webrtc; r=pehrsons MozReview-Commit-ID: Ahc7KPlY8uW
media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
media/webrtc/trunk/webrtc/modules/desktop_capture/mac/desktop_configuration.mm
media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_mac.mm
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
@@ -26,21 +26,16 @@
 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
 #include "webrtc/common_video/include/video_frame_buffer.h"
 #include "webrtc/api/video/i420_buffer.h"
 
 #ifdef WEBRTC_MAC
 #include <AvailabilityMacros.h>
-#endif
-
-#if defined(MAC_OS_X_VERSION_10_8) && \
-  (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8)
-// XXX not available in Mac 10.7 SDK
 #include "webrtc/common_video/include/corevideo_frame_buffer.h"
 #endif
 
 #include "mozilla/Unused.h"
 
 #if defined(MOZ_WIDGET_ANDROID)
 #include "VideoEngine.h"
 #endif
@@ -1902,26 +1897,22 @@ WebrtcVideoConduit::SendVideoFrame(const
     crop_y = (frame.height() - crop_height) / 2;
 
     rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer;
     if (adapted_width == frame.width() && adapted_height == frame.height()) {
       // No adaption - optimized path.
       buffer = frame.video_frame_buffer();
       // XXX Bug 1367651 - Use nativehandles where possible instead of software scaling
 #ifdef WEBRTC_MAC
-#if defined(MAC_OS_X_VERSION_10_8) && \
-  (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8)
-      // XXX not available in Mac 10.7 SDK
       // code adapted from objvideotracksource.mm
     } else if (frame.video_frame_buffer()->native_handle()) {
       // Adapted CVPixelBuffer frame.
       buffer = new rtc::RefCountedObject<webrtc::CoreVideoFrameBuffer>(
         static_cast<CVPixelBufferRef>(frame.video_frame_buffer()->native_handle()), adapted_width, adapted_height,
         crop_width, crop_height, crop_x, crop_y);
-#endif
 #elif WEBRTC_WIN
       // XX FIX
 #elif WEBRTC_LINUX
       // XX FIX
 #elif WEBRTC_ANDROID
       // XX FIX
 #endif
     } else {
--- a/media/webrtc/trunk/webrtc/modules/desktop_capture/mac/desktop_configuration.mm
+++ b/media/webrtc/trunk/webrtc/modules/desktop_capture/mac/desktop_configuration.mm
@@ -11,26 +11,16 @@
 #include "webrtc/modules/desktop_capture/mac/desktop_configuration.h"
 
 #include <math.h>
 #include <algorithm>
 #include <Cocoa/Cocoa.h>
 
 #include "webrtc/system_wrappers/include/logging.h"
 
-#if !defined(MAC_OS_X_VERSION_10_7) || \
-    MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
-
-@interface NSScreen (LionAPI)
-- (CGFloat)backingScaleFactor;
-- (NSRect)convertRectToBacking:(NSRect)aRect;
-@end
-
-#endif  // MAC_OS_X_VERSION_10_7
-
 namespace webrtc {
 
 namespace {
 
 DesktopRect NSRectToDesktopRect(const NSRect& ns_rect) {
   return DesktopRect::MakeLTRB(
       static_cast<int>(floor(ns_rect.origin.x)),
       static_cast<int>(floor(ns_rect.origin.y)),
--- a/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_mac.mm
+++ b/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_mac.mm
@@ -11,21 +11,17 @@
 #include <stddef.h>
 
 #include <memory>
 #include <set>
 #include <utility>
 
 #include <ApplicationServices/ApplicationServices.h>
 #include <Cocoa/Cocoa.h>
-#if defined(MAC_OS_X_VERSION_10_8) && \
-  MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
-// 10.8 and above
 #include <CoreGraphics/CoreGraphics.h>
-#endif
 #include <dlfcn.h>
 #include <IOKit/pwr_mgt/IOPMLib.h>
 #include <OpenGL/CGLMacro.h>
 #include <OpenGL/OpenGL.h>
 
 #include "webrtc/base/checks.h"
 #include "webrtc/base/constructormagic.h"
 #include "webrtc/base/macutils.h"
@@ -43,42 +39,37 @@
 #include "webrtc/modules/desktop_capture/screen_capturer_helper.h"
 #include "webrtc/modules/desktop_capture/shared_desktop_frame.h"
 #include "webrtc/system_wrappers/include/logging.h"
 
 // Once Chrome no longer supports OSX 10.8, everything within this
 // preprocessor block can be removed. https://crbug.com/579255
 #if !defined(MAC_OS_X_VERSION_10_9) || \
     MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9
-#if defined(MAC_OS_X_VERSION_10_8) && \
-    MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
 CG_EXTERN const CGRect* CGDisplayStreamUpdateGetRects(
     CGDisplayStreamUpdateRef updateRef,
     CGDisplayStreamUpdateRectType rectType,
     size_t* rectCount);
 CG_EXTERN CFRunLoopSourceRef
 CGDisplayStreamGetRunLoopSource(CGDisplayStreamRef displayStream);
 CG_EXTERN CGError CGDisplayStreamStop(CGDisplayStreamRef displayStream);
 CG_EXTERN CGError CGDisplayStreamStart(CGDisplayStreamRef displayStream);
 CG_EXTERN CGDisplayStreamRef
 CGDisplayStreamCreate(CGDirectDisplayID display,
                       size_t outputWidth,
                       size_t outputHeight,
                       int32_t pixelFormat,
                       CFDictionaryRef properties,
                       CGDisplayStreamFrameAvailableHandler handler);
 #endif
-#endif
 
 namespace webrtc {
 
 namespace {
 
-#if defined(MAC_OS_X_VERSION_10_8) && \
-  (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8)
 // CGDisplayStreamRefs need to be destroyed asynchronously after receiving a
 // kCGDisplayStreamFrameStatusStopped callback from CoreGraphics. This may
 // happen after the ScreenCapturerMac has been destroyed. DisplayStreamManager
 // is responsible for destroying all extant CGDisplayStreamRefs, and will
 // destroy itself once it's done.
 class DisplayStreamManager {
  public:
   int GetUniqueId() { return ++unique_id_generator_; }
@@ -135,17 +126,16 @@ class DisplayStreamManager {
     // from CoreGraphics will let us destroy the CGDisplayStreamRef.
     bool active = true;
   };
 
   std::map<int, DisplayStreamWrapper> display_stream_wrappers_;
   int unique_id_generator_ = 0;
   bool ready_for_self_destruction_ = false;
 };
-#endif
 
 // Definitions used to dynamic-link to deprecated OS 10.6 functions.
 const char* kApplicationServicesLibraryName =
     "/System/Library/Frameworks/ApplicationServices.framework/"
     "ApplicationServices";
 typedef void* (*CGDisplayBaseAddressFunc)(CGDirectDisplayID);
 typedef size_t (*CGDisplayBytesPerRowFunc)(CGDirectDisplayID);
 typedef size_t (*CGDisplayBitsPerPixelFunc)(CGDirectDisplayID);
@@ -315,38 +305,16 @@ class ScreenCapturerMac : public Desktop
   void ScreenConfigurationChanged();
 
   bool RegisterRefreshAndMoveHandlers();
   void UnregisterRefreshAndMoveHandlers();
 
   void ScreenRefresh(CGRectCount count, const CGRect *rect_array);
   void ReleaseBuffers();
 
-#if !defined(MAC_OS_X_VERSION_10_8) || \
-  (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8)
-  void ScreenUpdateMove(CGScreenUpdateMoveDelta delta,
-                        size_t count,
-                        const CGRect *rect_array);
-  static void ScreenRefreshCallback(CGRectCount count,
-                                    const CGRect *rect_array,
-                                    void *user_parameter);
-  static void ScreenUpdateMoveCallback(CGScreenUpdateMoveDelta delta,
-                                       size_t count,
-                                       const CGRect *rect_array,
-                                       void *user_parameter);
-  struct ScreenCallbackData {
-    explicit ScreenCallbackData(ScreenCapturerMac* capturer)
-              : capturer(capturer) {}
-    rtc::CriticalSection crit_sect_;
-    ScreenCapturerMac* capturer;
-  };
-
-  ScreenCallbackData* screen_callback_data_;
-#endif
-
   std::unique_ptr<DesktopFrame> CreateFrame();
 
   Callback* callback_ = nullptr;
 
   CGLContextObj cgl_context_ = nullptr;
   ScopedPixelBufferObject pixel_buffer_object_;
 
   // Queue of the frames buffers.
@@ -386,22 +354,19 @@ class ScreenCapturerMac : public Desktop
   CGDisplayBaseAddressFunc cg_display_base_address_ = nullptr;
   CGDisplayBytesPerRowFunc cg_display_bytes_per_row_ = nullptr;
   CGDisplayBitsPerPixelFunc cg_display_bits_per_pixel_ = nullptr;
   void* opengl_library_ = nullptr;
   CGLSetFullScreenFunc cgl_set_full_screen_ = nullptr;
 
   CGWindowID excluded_window_ = 0;
 
-#if defined(MAC_OS_X_VERSION_10_8) && \
-  (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8)
   // A self-owned object that will destroy itself after ScreenCapturerMac and
   // all display streams have been destroyed..
   DisplayStreamManager* display_stream_manager_;
-#endif
 
   RTC_DISALLOW_COPY_AND_ASSIGN(ScreenCapturerMac);
 };
 
 // DesktopFrame wrapper that flips wrapped frame upside down by inverting
 // stride.
 class InvertedDesktopFrame : public DesktopFrame {
  public:
@@ -422,35 +387,22 @@ class InvertedDesktopFrame : public Desk
   std::unique_ptr<DesktopFrame> original_frame_;
 
   RTC_DISALLOW_COPY_AND_ASSIGN(InvertedDesktopFrame);
 };
 
 ScreenCapturerMac::ScreenCapturerMac(
     rtc::scoped_refptr<DesktopConfigurationMonitor> desktop_config_monitor)
     : desktop_config_monitor_(desktop_config_monitor) {
-#if defined(MAC_OS_X_VERSION_10_8) && \
-  (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8)
   display_stream_manager_ = new DisplayStreamManager;
-#else
-  screen_callback_data_ = new ScreenCallbackData(this);
-#endif
 }
 
 ScreenCapturerMac::~ScreenCapturerMac() {
   ReleaseBuffers();
-#if defined(MAC_OS_X_VERSION_10_8) && \
-  (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8)
   display_stream_manager_->PrepareForSelfDestruction();
-#else
-  {
-    rtc::CritScope lock(&screen_callback_data_->crit_sect_);
-    screen_callback_data_->capturer = nullptr;
-  }
-#endif
   dlclose(app_services_library_);
   dlclose(opengl_library_);
 }
 
 bool ScreenCapturerMac::Init() {
   desktop_config_monitor_->Lock();
   desktop_config_ = desktop_config_monitor_->desktop_configuration();
   desktop_config_monitor_->Unlock();
@@ -992,18 +944,16 @@ void ScreenCapturerMac::ScreenConfigurat
 
   size_t buffer_size = screen_pixel_bounds_.width() *
                        screen_pixel_bounds_.height() *
                        sizeof(uint32_t);
   pixel_buffer_object_.Init(cgl_context_, buffer_size);
 }
 
 bool ScreenCapturerMac::RegisterRefreshAndMoveHandlers() {
-#if defined(MAC_OS_X_VERSION_10_8) && \
-  (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8)
   desktop_config_ = desktop_config_monitor_->desktop_configuration();
   for (const auto& config : desktop_config_.displays) {
     size_t pixel_width = config.pixel_bounds.width();
     size_t pixel_height = config.pixel_bounds.height();
     if (pixel_width == 0 || pixel_height == 0)
       continue;
     // Using a local variable forces the block to capture the raw pointer.
     DisplayStreamManager* manager = display_stream_manager_;
@@ -1042,138 +992,40 @@ bool ScreenCapturerMac::RegisterRefreshA
         return false;
 
       CFRunLoopSourceRef source =
           CGDisplayStreamGetRunLoopSource(display_stream);
       CFRunLoopAddSource(CFRunLoopGetCurrent(), source, kCFRunLoopDefaultMode);
       display_stream_manager_->SaveStream(unique_id, display_stream);
     }
   }
-#else
- CGError err = CGRegisterScreenRefreshCallback(
-      ScreenCapturerMac::ScreenRefreshCallback, screen_callback_data_);
-  if (err != kCGErrorSuccess) {
-    LOG(LS_ERROR) << "CGRegisterScreenRefreshCallback " << err;
-    return false;
-  }
-
-  err = CGScreenRegisterMoveCallback(
-      ScreenCapturerMac::ScreenUpdateMoveCallback, screen_callback_data_);
-  if (err != kCGErrorSuccess) {
-    LOG(LS_ERROR) << "CGScreenRegisterMoveCallback " << err;
-    return false;
-  }
-#endif
 
   return true;
 }
 
 void ScreenCapturerMac::UnregisterRefreshAndMoveHandlers() {
-#if defined(MAC_OS_X_VERSION_10_8) && \
-  (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8)
   display_stream_manager_->UnregisterActiveStreams();
-#else
-  CGUnregisterScreenRefreshCallback(
-      ScreenCapturerMac::ScreenRefreshCallback, this);
-  CGScreenUnregisterMoveCallback(
-      ScreenCapturerMac::ScreenUpdateMoveCallback, this);
-#endif
 }
 
 void ScreenCapturerMac::ScreenRefresh(CGRectCount count,
                                       const CGRect* rect_array) {
   if (screen_pixel_bounds_.is_empty())
     ScreenConfigurationChanged();
 
   DesktopRegion region;
-#if defined(MAC_OS_X_VERSION_10_8) && \
-  (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8)
   for (CGRectCount i = 0; i < count; ++i) {
     // All rects are already in physical pixel coordinates.
     DesktopRect rect = DesktopRect::MakeXYWH(
         rect_array[i].origin.x, rect_array[i].origin.y,
         rect_array[i].size.width, rect_array[i].size.height);
      region.AddRect(rect);
    }
-#else
-  DesktopVector translate_vector =
-      DesktopVector().subtract(screen_pixel_bounds_.top_left());
-  for (CGRectCount i = 0; i < count; ++i) {
-    // Convert from Density-Independent Pixel to physical pixel coordinates.
-    DesktopRect rect = ScaleAndRoundCGRect(rect_array[i], dip_to_pixel_scale_);
-    // Translate from local desktop to capturer framebuffer coordinates.
-    rect.Translate(translate_vector);
-    region.AddRect(rect);
-  }
-#endif
   helper_.InvalidateRegion(region);
 }
 
-#if !defined(MAC_OS_X_VERSION_10_8) || \
-  (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8)
-void ScreenCapturerMac::ScreenUpdateMove(CGScreenUpdateMoveDelta delta,
-                                         size_t count,
-                                         const CGRect* rect_array) {
-  // Translate |rect_array| to identify the move's destination.
-  CGRect refresh_rects[count];
-  for (CGRectCount i = 0; i < count; ++i) {
-    refresh_rects[i] = CGRectOffset(rect_array[i], delta.dX, delta.dY);
-  }
-
-  // Currently we just treat move events the same as refreshes.
-  ScreenRefresh(count, refresh_rects);
-}
-
-void ScreenCapturerMac::ScreenRefreshCallback(CGRectCount count,
-                                              const CGRect* rect_array,
-                                              void* user_parameter) {
-  ScreenCallbackData* screen_callback_data =
-      reinterpret_cast<ScreenCallbackData*>(user_parameter);
-
-  screen_callback_data->crit_sect_.Enter();
-  if (!screen_callback_data->capturer) {
-    CGUnregisterScreenRefreshCallback(
-        ScreenCapturerMac::ScreenRefreshCallback, screen_callback_data);
-    CGScreenUnregisterMoveCallback(
-        ScreenCapturerMac::ScreenUpdateMoveCallback, screen_callback_data);
-    screen_callback_data->crit_sect_.Leave();
-    delete screen_callback_data;
-    return;
-  }
-
-  if (screen_callback_data->capturer->screen_pixel_bounds_.is_empty())
-    screen_callback_data->capturer->ScreenConfigurationChanged();
-  screen_callback_data->capturer->ScreenRefresh(count, rect_array);
-  screen_callback_data->crit_sect_.Leave();
-}
-
-void ScreenCapturerMac::ScreenUpdateMoveCallback(
-    CGScreenUpdateMoveDelta delta,
-    size_t count,
-    const CGRect* rect_array,
-    void* user_parameter) {
-  ScreenCallbackData* screen_callback_data =
-      reinterpret_cast<ScreenCallbackData*>(user_parameter);
-
-  screen_callback_data->crit_sect_.Enter();
-  if (!screen_callback_data->capturer) {
-    CGUnregisterScreenRefreshCallback(
-        ScreenCapturerMac::ScreenRefreshCallback, screen_callback_data);
-    CGScreenUnregisterMoveCallback(
-        ScreenCapturerMac::ScreenUpdateMoveCallback, screen_callback_data);
-    screen_callback_data->crit_sect_.Leave();
-    delete screen_callback_data;
-    return;
-  }
-
-  screen_callback_data->capturer->ScreenUpdateMove(delta, count, rect_array);
-  screen_callback_data->crit_sect_.Leave();
-}
-#endif
-
 std::unique_ptr<DesktopFrame> ScreenCapturerMac::CreateFrame() {
   std::unique_ptr<DesktopFrame> frame(
       new BasicDesktopFrame(screen_pixel_bounds_.size()));
   frame->set_dpi(DesktopVector(kStandardDPI * dip_to_pixel_scale_,
                                kStandardDPI * dip_to_pixel_scale_));
   return frame;
 }