LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/modules/desktop_capture/x11 - x_server_pixel_buffer.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 2 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2013 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             : // Don't include this file in any .h files because it pulls in some X headers.
      12             : 
      13             : #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_X11_X_SERVER_PIXEL_BUFFER_H_
      14             : #define WEBRTC_MODULES_DESKTOP_CAPTURE_X11_X_SERVER_PIXEL_BUFFER_H_
      15             : 
      16             : #include "webrtc/base/constructormagic.h"
      17             : #include "webrtc/modules/desktop_capture/desktop_geometry.h"
      18             : 
      19             : #include <X11/Xutil.h>
      20             : #include <X11/extensions/XShm.h>
      21             : 
      22             : namespace webrtc {
      23             : 
      24             : class DesktopFrame;
      25             : 
      26             : // A class to allow the X server's pixel buffer to be accessed as efficiently
      27             : // as possible.
      28             : class XServerPixelBuffer {
      29             :  public:
      30             :   XServerPixelBuffer();
      31             :   ~XServerPixelBuffer();
      32             : 
      33             :   void Release();
      34             : 
      35             :   // Allocate (or reallocate) the pixel buffer for |window|. Returns false in
      36             :   // case of an error (e.g. window doesn't exist).
      37             :   bool Init(Display* display, Window window);
      38             : 
      39           0 :   bool is_initialized() { return window_ != 0; }
      40             : 
      41             :   // Returns the size of the window the buffer was initialized for.
      42           0 :   const DesktopSize& window_size() { return window_size_; }
      43             : 
      44             :   // Returns true if the window can be found.
      45             :   bool IsWindowValid() const;
      46             : 
      47             :   // If shared memory is being used without pixmaps, synchronize this pixel
      48             :   // buffer with the root window contents (otherwise, this is a no-op).
      49             :   // This is to avoid doing a full-screen capture for each individual
      50             :   // rectangle in the capture list, when it only needs to be done once at the
      51             :   // beginning.
      52             :   void Synchronize();
      53             : 
      54             :   // Capture the specified rectangle and stores it in the |frame|. In the case
      55             :   // where the full-screen data is captured by Synchronize(), this simply
      56             :   // returns the pointer without doing any more work. The caller must ensure
      57             :   // that |rect| is not larger than window_size().
      58             :   bool CaptureRect(const DesktopRect& rect, DesktopFrame* frame);
      59             : 
      60             :  private:
      61             :   void InitShm(const XWindowAttributes& attributes);
      62             :   bool InitPixmaps(int depth);
      63             : 
      64             :   // We expose two forms of blitting to handle variations in the pixel format.
      65             :   // In FastBlit(), the operation is effectively a memcpy.
      66             :   void FastBlit(uint8_t* image,
      67             :                 const DesktopRect& rect,
      68             :                 DesktopFrame* frame);
      69             :   void SlowBlit(uint8_t* image,
      70             :                 const DesktopRect& rect,
      71             :                 DesktopFrame* frame);
      72             : 
      73             :   Display* display_ = nullptr;
      74             :   Window window_ = 0;
      75             :   DesktopSize window_size_;
      76             :   XImage* x_image_ = nullptr;
      77             :   XShmSegmentInfo* shm_segment_info_ = nullptr;
      78             :   Pixmap shm_pixmap_ = 0;
      79             :   GC shm_gc_ = nullptr;
      80             :   bool xshm_get_image_succeeded_ = false;
      81             : 
      82             :   RTC_DISALLOW_COPY_AND_ASSIGN(XServerPixelBuffer);
      83             : };
      84             : 
      85             : }  // namespace webrtc
      86             : 
      87             : #endif  // WEBRTC_MODULES_DESKTOP_CAPTURE_X11_X_SERVER_PIXEL_BUFFER_H_

Generated by: LCOV version 1.13