tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

desktop_frame_cgimage.h (2036B)


      1 /*
      2 *  Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
      3 *
      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
      6 *  tree. An additional intellectual property rights grant can be found
      7 *  in the file PATENTS.  All contributing project authors may
      8 *  be found in the AUTHORS file in the root of the source tree.
      9 */
     10 
     11 #ifndef MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_FRAME_CGIMAGE_H_
     12 #define MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_FRAME_CGIMAGE_H_
     13 
     14 #include <CoreGraphics/CoreGraphics.h>
     15 
     16 #include <memory>
     17 
     18 #include "modules/desktop_capture/desktop_frame.h"
     19 #include "sdk/objc/helpers/scoped_cftyperef.h"
     20 
     21 namespace webrtc {
     22 
     23 class RTC_EXPORT DesktopFrameCGImage final : public DesktopFrame {
     24 public:
     25  // Create an image containing a snapshot of the display at the time this is
     26  // being called.
     27  static std::unique_ptr<DesktopFrameCGImage> CreateForDisplay(
     28      CGDirectDisplayID display_id);
     29 
     30  // Create an image containing a snaphot of the given window at the time this
     31  // is being called. This also works when the window is overlapped or in
     32  // another workspace.
     33  static std::unique_ptr<DesktopFrameCGImage> CreateForWindow(
     34      CGWindowID window_id);
     35 
     36  static std::unique_ptr<DesktopFrameCGImage> CreateFromCGImage(
     37      ScopedCFTypeRef<CGImageRef> cg_image);
     38 
     39  ~DesktopFrameCGImage() override;
     40 
     41  DesktopFrameCGImage(const DesktopFrameCGImage&) = delete;
     42  DesktopFrameCGImage& operator=(const DesktopFrameCGImage&) = delete;
     43 
     44 private:
     45  // This constructor expects `cg_image` to hold a non-null CGImageRef.
     46  DesktopFrameCGImage(DesktopSize size,
     47                      int stride,
     48                      uint8_t* data,
     49                      ScopedCFTypeRef<CGImageRef> cg_image,
     50                      ScopedCFTypeRef<CFDataRef> cg_data);
     51 
     52  const ScopedCFTypeRef<CGImageRef> cg_image_;
     53  const ScopedCFTypeRef<CFDataRef> cg_data_;
     54 };
     55 
     56 }  // namespace webrtc
     57 
     58 #endif  // MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_FRAME_CGIMAGE_H_