LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/modules/desktop_capture - desktop_geometry.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 36 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 26 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             : #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_GEOMETRY_H_
      12             : #define WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_GEOMETRY_H_
      13             : 
      14             : #include "webrtc/base/constructormagic.h"
      15             : #include "webrtc/typedefs.h"
      16             : 
      17             : namespace webrtc {
      18             : 
      19             : // A vector in the 2D integer space. E.g. can be used to represent screen DPI.
      20             : class DesktopVector {
      21             :  public:
      22           0 :   DesktopVector() : x_(0), y_(0) {}
      23           0 :   DesktopVector(int32_t x, int32_t y) : x_(x), y_(y) {}
      24             : 
      25           0 :   int32_t x() const { return x_; }
      26           0 :   int32_t y() const { return y_; }
      27             :   bool is_zero() const { return x_ == 0 && y_ == 0; }
      28             : 
      29             :   bool equals(const DesktopVector& other) const {
      30             :     return x_ == other.x_ && y_ == other.y_;
      31             :   }
      32             : 
      33             :   void set(int32_t x, int32_t y) {
      34             :     x_ = x;
      35             :     y_ = y;
      36             :   }
      37             : 
      38             :   DesktopVector add(const DesktopVector& other) const {
      39             :     return DesktopVector(x() + other.x(), y() + other.y());
      40             :   }
      41           0 :   DesktopVector subtract(const DesktopVector& other) const {
      42           0 :     return DesktopVector(x() - other.x(), y() - other.y());
      43             :   }
      44             : 
      45             :  private:
      46             :   int32_t x_;
      47             :   int32_t y_;
      48             : };
      49             : 
      50             : // Type used to represent screen/window size.
      51             : class DesktopSize {
      52             :  public:
      53           0 :   DesktopSize() : width_(0), height_(0) {}
      54           0 :   DesktopSize(int32_t width, int32_t height)
      55           0 :       : width_(width), height_(height) {
      56           0 :   }
      57             : 
      58           0 :   int32_t width() const { return width_; }
      59           0 :   int32_t height() const { return height_; }
      60             : 
      61             :   bool is_empty() const { return width_ <= 0 || height_ <= 0; }
      62             : 
      63           0 :   bool equals(const DesktopSize& other) const {
      64           0 :     return width_ == other.width_ && height_ == other.height_;
      65             :   }
      66             : 
      67             :   void set(int32_t width, int32_t height) {
      68             :     width_ = width;
      69             :     height_ = height;
      70             :   }
      71             : 
      72             :  private:
      73             :   int32_t width_;
      74             :   int32_t height_;
      75             : };
      76             : 
      77             : // Represents a rectangle on the screen.
      78             : class DesktopRect {
      79             :  public:
      80           0 :   static DesktopRect MakeSize(const DesktopSize& size) {
      81           0 :     return DesktopRect(0, 0, size.width(), size.height());
      82             :   }
      83             :   static DesktopRect MakeWH(int32_t width, int32_t height) {
      84             :     return DesktopRect(0, 0, width, height);
      85             :   }
      86           0 :   static DesktopRect MakeXYWH(int32_t x, int32_t y,
      87             :                               int32_t width, int32_t height) {
      88           0 :     return DesktopRect(x, y, x + width, y + height);
      89             :   }
      90           0 :   static DesktopRect MakeLTRB(int32_t left, int32_t top,
      91             :                               int32_t right, int32_t bottom) {
      92           0 :     return DesktopRect(left, top, right, bottom);
      93             :   }
      94           0 :   static DesktopRect MakeOriginSize(const DesktopVector& origin,
      95             :                                     const DesktopSize& size) {
      96           0 :     return MakeXYWH(origin.x(), origin.y(), size.width(), size.height());
      97             :   }
      98             : 
      99           0 :   DesktopRect() : left_(0), top_(0), right_(0), bottom_(0) {}
     100             : 
     101           0 :   int32_t left() const { return left_; }
     102           0 :   int32_t top() const { return top_; }
     103           0 :   int32_t right() const { return right_; }
     104           0 :   int32_t bottom() const { return bottom_; }
     105           0 :   int32_t width() const { return right_ - left_; }
     106           0 :   int32_t height() const { return bottom_ - top_; }
     107             : 
     108           0 :   DesktopVector top_left() const { return DesktopVector(left_, top_); }
     109           0 :   DesktopSize size() const { return DesktopSize(width(), height()); }
     110             : 
     111           0 :   bool is_empty() const { return left_ >= right_ || top_ >= bottom_; }
     112             : 
     113             :   bool equals(const DesktopRect& other) const {
     114             :     return left_ == other.left_ && top_ == other.top_ &&
     115             :         right_ == other.right_ && bottom_ == other.bottom_;
     116             :   }
     117             : 
     118             :   // Returns true if |point| lies within the rectangle boundaries.
     119             :   bool Contains(const DesktopVector& point) const;
     120             : 
     121             :   // Returns true if |rect| lies within the boundaries of this rectangle.
     122             :   bool ContainsRect(const DesktopRect& rect) const;
     123             : 
     124             :   // Finds intersection with |rect|.
     125             :   void IntersectWith(const DesktopRect& rect);
     126             : 
     127             :   // Adds (dx, dy) to the position of the rectangle.
     128             :   void Translate(int32_t dx, int32_t dy);
     129           0 :   void Translate(DesktopVector d) { Translate(d.x(), d.y()); };
     130             : 
     131             :   // Enlarges current DesktopRect by subtracting |left_offset| and |top_offset|
     132             :   // from |left_| and |top_|, and adding |right_offset| and |bottom_offset| to
     133             :   // |right_| and |bottom_|. This function does not normalize the result, so
     134             :   // |left_| and |top_| may be less than zero or larger than |right_| and
     135             :   // |bottom_|.
     136             :   void Extend(int32_t left_offset,
     137             :               int32_t top_offset,
     138             :               int32_t right_offset,
     139             :               int32_t bottom_offset);
     140             : 
     141             :  private:
     142           0 :   DesktopRect(int32_t left, int32_t top, int32_t right, int32_t bottom)
     143           0 :       : left_(left), top_(top), right_(right), bottom_(bottom) {
     144           0 :   }
     145             : 
     146             :   int32_t left_;
     147             :   int32_t top_;
     148             :   int32_t right_;
     149             :   int32_t bottom_;
     150             : };
     151             : 
     152             : }  // namespace webrtc
     153             : 
     154             : #endif  // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_GEOMETRY_H_
     155             : 

Generated by: LCOV version 1.13