LCOV - code coverage report
Current view: top level - layout/painting - nsCSSRenderingGradients.h (source / functions) Hit Total Coverage
Test: output.info Lines: 4 5 80.0 %
Date: 2017-07-14 16:53:18 Functions: 3 4 75.0 %
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 nsCSSRenderingGradients_h__
       7             : #define nsCSSRenderingGradients_h__
       8             : 
       9             : #include "nsLayoutUtils.h"
      10             : #include "nsStyleStruct.h"
      11             : #include "Units.h"
      12             : #include "mozilla/Maybe.h"
      13             : #include "mozilla/gfx/2D.h"
      14             : 
      15             : namespace mozilla {
      16             : 
      17             : namespace layers {
      18             : class StackingContextHelper;
      19             : class WebRenderDisplayItemLayer;
      20             : } // namespace layers
      21             : 
      22             : namespace wr {
      23             : class DisplayListBuilder;
      24             : } // namespace wr
      25             : 
      26             : // A resolved color stop, with a specific position along the gradient line and
      27             : // a color.
      28             : struct ColorStop {
      29           0 :   ColorStop(): mPosition(0), mIsMidpoint(false) {}
      30         104 :   ColorStop(double aPosition, bool aIsMidPoint, const gfx::Color& aColor) :
      31         104 :     mPosition(aPosition), mIsMidpoint(aIsMidPoint), mColor(aColor) {}
      32             :   double mPosition; // along the gradient line; 0=start, 1=end
      33             :   bool mIsMidpoint;
      34             :   gfx::Color mColor;
      35             : };
      36             : 
      37          26 : class nsCSSGradientRenderer final {
      38             : public:
      39             :   /**
      40             :    * Prepare a nsCSSGradientRenderer for a gradient for an element.
      41             :    * aIntrinsicSize - the size of the source gradient.
      42             :    */
      43             :   static nsCSSGradientRenderer Create(nsPresContext* aPresContext,
      44             :                                       nsStyleGradient* aGradient,
      45             :                                       const nsSize& aIntrinsiceSize);
      46             : 
      47             :   /**
      48             :    * Draw the gradient to aContext
      49             :    * aDest - where the first tile of gradient is
      50             :    * aFill - the area to be filled with tiles of aDest
      51             :    * aSrc - the area of the gradient that will fill aDest
      52             :    * aRepeatSize - the distance from the origin of a tile
      53             :    *               to the next origin of a tile
      54             :    * aDirtyRect - pixels outside of this area may be skipped
      55             :    */
      56             :   void Paint(gfxContext& aContext,
      57             :              const nsRect& aDest,
      58             :              const nsRect& aFill,
      59             :              const nsSize& aRepeatSize,
      60             :              const mozilla::CSSIntRect& aSrc,
      61             :              const nsRect& aDirtyRect,
      62             :              float aOpacity = 1.0);
      63             : 
      64             :   /**
      65             :    * Collect the gradient parameters
      66             :    */
      67             :   void BuildWebRenderParameters(float aOpacity,
      68             :                                 WrGradientExtendMode& aMode,
      69             :                                 nsTArray<WrGradientStop>& aStops,
      70             :                                 LayoutDevicePoint& aLineStart,
      71             :                                 LayoutDevicePoint& aLineEnd,
      72             :                                 LayoutDeviceSize& aGradientRadius);
      73             : 
      74             :   /**
      75             :    * Build display items for the gradient
      76             :    * aLayer - the layer to make this display item relative to
      77             :    * aDest - where the first tile of gradient is
      78             :    * aFill - the area to be filled with tiles of aDest
      79             :    * aRepeatSize - the distance from the origin of a tile
      80             :    *               to the next origin of a tile
      81             :    * aSrc - the area of the gradient that will fill aDest
      82             :    */
      83             :   void BuildWebRenderDisplayItems(wr::DisplayListBuilder& aBuilder,
      84             :                                   const layers::StackingContextHelper& aSc,
      85             :                                   layers::WebRenderDisplayItemLayer* aLayer,
      86             :                                   const nsRect& aDest,
      87             :                                   const nsRect& aFill,
      88             :                                   const nsSize& aRepeatSize,
      89             :                                   const mozilla::CSSIntRect& aSrc,
      90             :                                   float aOpacity = 1.0);
      91             : 
      92             : private:
      93          26 :   nsCSSGradientRenderer() {}
      94             : 
      95             :   nsPresContext* mPresContext;
      96             :   nsStyleGradient* mGradient;
      97             :   nsTArray<ColorStop> mStops;
      98             :   gfxPoint mLineStart, mLineEnd;
      99             :   double mRadiusX, mRadiusY;
     100             : };
     101             : 
     102             : } // namespace mozilla
     103             : 
     104             : #endif /* nsCSSRenderingGradients_h__ */

Generated by: LCOV version 1.13