LCOV - code coverage report
Current view: top level - gfx/layers/basic - BasicImplData.h (source / functions) Hit Total Coverage
Test: output.info Lines: 12 26 46.2 %
Date: 2017-07-14 16:53:18 Functions: 6 15 40.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* This Source Code Form is subject to the terms of the Mozilla Public
       2             :  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
       3             :  * You can obtain one at http://mozilla.org/MPL/2.0/. */
       4             : 
       5             : #ifndef GFX_BASICIMPLDATA_H
       6             : #define GFX_BASICIMPLDATA_H
       7             : 
       8             : #include "Layers.h"                     // for Layer (ptr only), etc
       9             : #include "gfxContext.h"                 // for gfxContext, etc
      10             : #include "nsDebug.h"                    // for NS_ASSERTION
      11             : #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
      12             : #include "mozilla/gfx/Types.h"
      13             : 
      14             : namespace mozilla {
      15             : namespace layers {
      16             : 
      17             : class ReadbackProcessor;
      18             : 
      19             : /**
      20             :  * This is the ImplData for all Basic layers. It also exposes methods
      21             :  * private to the Basic implementation that are common to all Basic layer types.
      22             :  * In particular, there is an internal Paint() method that we can use
      23             :  * to paint the contents of non-PaintedLayers.
      24             :  *
      25             :  * The class hierarchy for Basic layers is like this:
      26             :  *                                 BasicImplData
      27             :  * Layer                            |   |   |
      28             :  *  |                               |   |   |
      29             :  *  +-> ContainerLayer              |   |   |
      30             :  *  |    |                          |   |   |
      31             :  *  |    +-> BasicContainerLayer <--+   |   |
      32             :  *  |                                   |   |
      33             :  *  +-> PaintedLayer                     |   |
      34             :  *  |    |                              |   |
      35             :  *  |    +-> BasicPaintedLayer <---------+   |
      36             :  *  |                                       |
      37             :  *  +-> ImageLayer                          |
      38             :  *       |                                  |
      39             :  *       +-> BasicImageLayer <--------------+
      40             :  */
      41             : class BasicImplData {
      42             : public:
      43         177 :   BasicImplData() : mHidden(false),
      44             :     mClipToVisibleRegion(false),
      45             :     mDrawAtomically(false),
      46         177 :     mOperator(gfx::CompositionOp::OP_OVER)
      47             :   {
      48         177 :     MOZ_COUNT_CTOR(BasicImplData);
      49         177 :   }
      50         165 :   virtual ~BasicImplData()
      51         330 :   {
      52         165 :     MOZ_COUNT_DTOR(BasicImplData);
      53         165 :   }
      54             : 
      55             :   /**
      56             :    * Layers that paint themselves, such as ImageLayers, should paint
      57             :    * in response to this method call. aContext will already have been
      58             :    * set up to account for all the properties of the layer (transform,
      59             :    * opacity, etc).
      60             :    */
      61           0 :   virtual void Paint(gfx::DrawTarget* aDT,
      62             :                      const gfx::Point& aDeviceOffset,
      63           0 :                      Layer* aMaskLayer) {}
      64             : 
      65             :   /**
      66             :    * Like Paint() but called for PaintedLayers with the additional parameters
      67             :    * they need.
      68             :    * If mClipToVisibleRegion is set, then the layer must clip to its
      69             :    * effective visible region (snapped or unsnapped, it doesn't matter).
      70             :    */
      71           0 :   virtual void PaintThebes(gfxContext* aContext,
      72             :                            Layer* aMasklayer,
      73             :                            LayerManager::DrawPaintedLayerCallback aCallback,
      74           0 :                            void* aCallbackData) {}
      75             : 
      76           0 :   virtual void Validate(LayerManager::DrawPaintedLayerCallback aCallback,
      77             :                         void* aCallbackData,
      78           0 :                         ReadbackProcessor* aReadback) {}
      79             : 
      80             :   /**
      81             :    * Layers will get this call when their layer manager is destroyed, this
      82             :    * indicates they should clear resources they don't really need after their
      83             :    * LayerManager ceases to exist.
      84             :    */
      85          48 :   virtual void ClearCachedResources() {}
      86             : 
      87             :   /**
      88             :    * This variable is set by MarkLayersHidden() before painting. It indicates
      89             :    * that the layer should not be composited during this transaction.
      90             :    */
      91           0 :   void SetHidden(bool aCovered) { mHidden = aCovered; }
      92          51 :   bool IsHidden() const { return false; }
      93             :   /**
      94             :    * This variable is set by MarkLayersHidden() before painting. This is
      95             :    * the operator to be used when compositing the layer in this transaction. It must
      96             :    * be OVER or SOURCE.
      97             :    */
      98           0 :   void SetOperator(gfx::CompositionOp aOperator)
      99             :   {
     100           0 :     NS_ASSERTION(aOperator == gfx::CompositionOp::OP_OVER ||
     101             :                  aOperator == gfx::CompositionOp::OP_SOURCE,
     102             :                  "Bad composition operator");
     103           0 :     mOperator = aOperator;
     104           0 :   }
     105             : 
     106         142 :   gfx::CompositionOp GetOperator() const { return mOperator; }
     107             : 
     108             :   /**
     109             :    * Return a surface for this layer. Will use an existing surface, if
     110             :    * possible, or may create a temporary surface.  Implement this
     111             :    * method for any layers that might be used as a mask.  Should only
     112             :    * return false if a surface cannot be created.  If true is
     113             :    * returned, only one of |aSurface| or |aDescriptor| is valid.
     114             :    */
     115           0 :   virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() { return nullptr; }
     116             : 
     117         123 :   bool GetClipToVisibleRegion() { return mClipToVisibleRegion; }
     118           0 :   void SetClipToVisibleRegion(bool aClip) { mClipToVisibleRegion = aClip; }
     119             : 
     120           0 :   void SetDrawAtomically(bool aDrawAtomically) { mDrawAtomically = aDrawAtomically; }
     121             : 
     122             : protected:
     123             :   bool mHidden;
     124             :   bool mClipToVisibleRegion;
     125             :   bool mDrawAtomically;
     126             :   gfx::CompositionOp mOperator;
     127             : };
     128             : 
     129             : } // namespace layers
     130             : } // namespace mozilla
     131             : 
     132             : #endif

Generated by: LCOV version 1.13