LCOV - code coverage report
Current view: top level - gfx/src - nsSize.h (source / functions) Hit Total Coverage
Test: output.info Lines: 2 18 11.1 %
Date: 2017-07-14 16:53:18 Functions: 2 6 33.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef NSSIZE_H
       7             : #define NSSIZE_H
       8             : 
       9             : #include "nsCoord.h"
      10             : #include "mozilla/gfx/BaseSize.h"
      11             : #include "mozilla/gfx/Point.h"
      12             : 
      13             : // Maximum allowable size
      14             : #define NS_MAXSIZE nscoord_MAX
      15             : 
      16             : typedef mozilla::gfx::IntSize nsIntSize;
      17             : 
      18             : struct nsSize : public mozilla::gfx::BaseSize<nscoord, nsSize> {
      19             :   typedef mozilla::gfx::BaseSize<nscoord, nsSize> Super;
      20             : 
      21        5050 :   nsSize() : Super() {}
      22       62805 :   nsSize(nscoord aWidth, nscoord aHeight) : Super(aWidth, aHeight) {}
      23             : 
      24             :   inline mozilla::gfx::IntSize ScaleToNearestPixels(float aXScale, float aYScale,
      25             :                                         nscoord aAppUnitsPerPixel) const;
      26             :   inline mozilla::gfx::IntSize ToNearestPixels(nscoord aAppUnitsPerPixel) const;
      27             : 
      28             :   /**
      29             :    * Return this size scaled to a different appunits per pixel (APP) ratio.
      30             :    * @param aFromAPP the APP to scale from
      31             :    * @param aToAPP the APP to scale to
      32             :    */
      33             :   MOZ_MUST_USE inline nsSize
      34             :     ScaleToOtherAppUnits(int32_t aFromAPP, int32_t aToAPP) const;
      35             : };
      36             : 
      37             : inline mozilla::gfx::IntSize
      38           0 : nsSize::ScaleToNearestPixels(float aXScale, float aYScale,
      39             :                              nscoord aAppUnitsPerPixel) const
      40             : {
      41           0 :   return mozilla::gfx::IntSize(
      42           0 :       NSToIntRoundUp(NSAppUnitsToDoublePixels(width, aAppUnitsPerPixel) * aXScale),
      43           0 :       NSToIntRoundUp(NSAppUnitsToDoublePixels(height, aAppUnitsPerPixel) * aYScale));
      44             : }
      45             : 
      46             : inline mozilla::gfx::IntSize
      47           0 : nsSize::ToNearestPixels(nscoord aAppUnitsPerPixel) const
      48             : {
      49           0 :   return ScaleToNearestPixels(1.0f, 1.0f, aAppUnitsPerPixel);
      50             : }
      51             : 
      52             : inline nsSize
      53           0 : nsSize::ScaleToOtherAppUnits(int32_t aFromAPP, int32_t aToAPP) const {
      54           0 :   if (aFromAPP != aToAPP) {
      55           0 :     nsSize size;
      56           0 :     size.width = NSToCoordRound(NSCoordScale(width, aFromAPP, aToAPP));
      57           0 :     size.height = NSToCoordRound(NSCoordScale(height, aFromAPP, aToAPP));
      58           0 :     return size;
      59             :   }
      60           0 :   return *this;
      61             : }
      62             : 
      63             : inline nsSize
      64           0 : IntSizeToAppUnits(mozilla::gfx::IntSize aSize, nscoord aAppUnitsPerPixel)
      65             : {
      66           0 :   return nsSize(NSIntPixelsToAppUnits(aSize.width, aAppUnitsPerPixel),
      67           0 :                 NSIntPixelsToAppUnits(aSize.height, aAppUnitsPerPixel));
      68             : }
      69             : 
      70             : #endif /* NSSIZE_H */

Generated by: LCOV version 1.13