LCOV - code coverage report
Current view: top level - gfx/skia/skia/include/core - SkSize.h (source / functions) Hit Total Coverage
Test: output.info Lines: 8 14 57.1 %
Date: 2017-07-14 16:53:18 Functions: 7 13 53.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright 2011 Google Inc.
       3             :  *
       4             :  * Use of this source code is governed by a BSD-style license that can be
       5             :  * found in the LICENSE file.
       6             :  */
       7             : 
       8             : #ifndef SkSize_DEFINED
       9             : #define SkSize_DEFINED
      10             : 
      11             : #include "SkScalar.h"
      12             : 
      13             : struct SkISize {
      14             :     int32_t fWidth;
      15             :     int32_t fHeight;
      16             : 
      17         414 :     static SkISize Make(int32_t w, int32_t h) { return {w, h}; }
      18             : 
      19             :     static SkISize MakeEmpty() { return {0, 0}; }
      20             : 
      21         152 :     void set(int32_t w, int32_t h) { *this = SkISize{w, h}; }
      22             : 
      23             :     /** Returns true iff fWidth == 0 && fHeight == 0
      24             :      */
      25           0 :     bool isZero() const { return 0 == fWidth && 0 == fHeight; }
      26             : 
      27             :     /** Returns true if either widht or height are <= 0 */
      28         152 :     bool isEmpty() const { return fWidth <= 0 || fHeight <= 0; }
      29             : 
      30             :     /** Set the width and height to 0 */
      31             :     void setEmpty() { fWidth = fHeight = 0; }
      32             : 
      33         431 :     int32_t width() const { return fWidth; }
      34         431 :     int32_t height() const { return fHeight; }
      35             : 
      36             :     bool equals(int32_t w, int32_t h) const { return fWidth == w && fHeight == h; }
      37             : };
      38             : 
      39          88 : static inline bool operator==(const SkISize& a, const SkISize& b) {
      40          88 :     return a.fWidth == b.fWidth && a.fHeight == b.fHeight;
      41             : }
      42             : 
      43          44 : static inline bool operator!=(const SkISize& a, const SkISize& b) { return !(a == b); }
      44             : 
      45             : ///////////////////////////////////////////////////////////////////////////////
      46             : 
      47             : struct SkSize {
      48             :     SkScalar fWidth;
      49             :     SkScalar fHeight;
      50             : 
      51           0 :     static SkSize Make(SkScalar w, SkScalar h) { return {w, h}; }
      52             : 
      53             :     static SkSize Make(const SkISize& src) {
      54             :         return {SkIntToScalar(src.width()), SkIntToScalar(src.height())};
      55             :     }
      56             : 
      57             :     SkSize& operator=(const SkISize& src) {
      58             :         return *this = SkSize{SkIntToScalar(src.fWidth), SkIntToScalar(src.fHeight)};
      59             :     }
      60             : 
      61             :     static SkSize MakeEmpty() { return {0, 0}; }
      62             : 
      63           0 :     void set(SkScalar w, SkScalar h) { *this = SkSize{w, h}; }
      64             : 
      65             :     /** Returns true iff fWidth == 0 && fHeight == 0
      66             :      */
      67             :     bool isZero() const { return 0 == fWidth && 0 == fHeight; }
      68             : 
      69             :     /** Returns true if either widht or height are <= 0 */
      70             :     bool isEmpty() const { return fWidth <= 0 || fHeight <= 0; }
      71             : 
      72             :     /** Set the width and height to 0 */
      73             :     void setEmpty() { *this = SkSize{0, 0}; }
      74             : 
      75           0 :     SkScalar width() const { return fWidth; }
      76           0 :     SkScalar height() const { return fHeight; }
      77             : 
      78             :     bool equals(SkScalar w, SkScalar h) const { return fWidth == w && fHeight == h; }
      79             : 
      80             :     SkISize toRound() const { return {SkScalarRoundToInt(fWidth), SkScalarRoundToInt(fHeight)}; }
      81             : 
      82           0 :     SkISize toCeil() const { return {SkScalarCeilToInt(fWidth), SkScalarCeilToInt(fHeight)}; }
      83             : 
      84             :     SkISize toFloor() const { return {SkScalarFloorToInt(fWidth), SkScalarFloorToInt(fHeight)}; }
      85             : };
      86             : 
      87             : static inline bool operator==(const SkSize& a, const SkSize& b) {
      88             :     return a.fWidth == b.fWidth && a.fHeight == b.fHeight;
      89             : }
      90             : 
      91             : static inline bool operator!=(const SkSize& a, const SkSize& b) { return !(a == b); }
      92             : #endif

Generated by: LCOV version 1.13