LCOV - code coverage report
Current view: top level - gfx/2d - DrawTargetDual.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 44 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 26 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 20; 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 MOZILLA_GFX_DRAWTARGETDUAL_H_
       7             : #define MOZILLA_GFX_DRAWTARGETDUAL_H_
       8             :      
       9             : #include <vector>
      10             : #include <sstream>
      11             : 
      12             : #include "SourceSurfaceDual.h"
      13             :      
      14             : #include "2D.h"
      15             : #include "Filters.h"
      16             :      
      17             : namespace mozilla {
      18             : namespace gfx {
      19             :      
      20             : #define FORWARD_FUNCTION(funcName) \
      21             :   virtual void funcName() override { mA->funcName(); mB->funcName(); }
      22             : #define FORWARD_FUNCTION1(funcName, var1Type, var1Name) \
      23             :   virtual void funcName(var1Type var1Name) override { mA->funcName(var1Name); mB->funcName(var1Name); }
      24             : 
      25             : /* This is a special type of DrawTarget. It duplicates all drawing calls
      26             :  * accross two drawtargets. An exception to this is when a snapshot of another
      27             :  * dual DrawTarget is used as the source for any surface data. In this case
      28             :  * the snapshot of the first source DrawTarget is used as a source for the call
      29             :  * to the first destination DrawTarget (mA) and the snapshot of the second
      30             :  * source DrawTarget is used at the source for the second destination
      31             :  * DrawTarget (mB). This class facilitates black-background/white-background
      32             :  * drawing for per-component alpha extraction for backends which do not support
      33             :  * native component alpha.
      34             :  */
      35           0 : class DrawTargetDual : public DrawTarget
      36             : {
      37             : public:
      38           0 :   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawTargetDual, override)
      39           0 :   DrawTargetDual(DrawTarget *aA, DrawTarget *aB)
      40           0 :     : mA(aA)
      41           0 :     , mB(aB)
      42             :   { 
      43           0 :     mFormat = aA->GetFormat();
      44           0 :   }
      45             :      
      46           0 :   virtual DrawTargetType GetType() const override { return mA->GetType(); }
      47           0 :   virtual BackendType GetBackendType() const override { return mA->GetBackendType(); }
      48           0 :   virtual already_AddRefed<SourceSurface> Snapshot() override {
      49           0 :     return MakeAndAddRef<SourceSurfaceDual>(mA, mB);
      50             :   }
      51           0 :   virtual IntSize GetSize() override { return mA->GetSize(); }
      52             : 
      53             :   virtual void DetachAllSnapshots() override;
      54             : 
      55           0 :   FORWARD_FUNCTION(Flush)
      56           0 :   FORWARD_FUNCTION1(PushClip, const Path *, aPath)
      57           0 :   FORWARD_FUNCTION1(PushClipRect, const Rect &, aRect)
      58           0 :   FORWARD_FUNCTION(PopClip)
      59           0 :   FORWARD_FUNCTION(PopLayer)
      60           0 :   FORWARD_FUNCTION1(ClearRect, const Rect &, aRect)
      61             : 
      62           0 :   virtual void SetTransform(const Matrix &aTransform) override {
      63           0 :     mTransform = aTransform;
      64           0 :     mA->SetTransform(aTransform);
      65           0 :     mB->SetTransform(aTransform);
      66           0 :   }
      67             : 
      68             :   virtual void DrawSurface(SourceSurface *aSurface, const Rect &aDest, const Rect & aSource,
      69             :                            const DrawSurfaceOptions &aSurfOptions, const DrawOptions &aOptions) override;
      70             : 
      71           0 :   virtual void DrawFilter(FilterNode *aNode,
      72             :                           const Rect &aSourceRect,
      73             :                           const Point &aDestPoint,
      74             :                           const DrawOptions &aOptions = DrawOptions()) override
      75             :   {
      76           0 :     mA->DrawFilter(aNode, aSourceRect, aDestPoint, aOptions);
      77           0 :     mB->DrawFilter(aNode, aSourceRect, aDestPoint, aOptions);
      78           0 :   }
      79             : 
      80             :   virtual void MaskSurface(const Pattern &aSource,
      81             :                            SourceSurface *aMask,
      82             :                            Point aOffset,
      83             :                            const DrawOptions &aOptions = DrawOptions()) override;
      84             : 
      85             :   virtual void DrawSurfaceWithShadow(SourceSurface *aSurface, const Point &aDest,
      86             :                                      const Color &aColor, const Point &aOffset,
      87             :                                      Float aSigma, CompositionOp aOp) override;
      88             : 
      89             :   virtual void CopySurface(SourceSurface *aSurface, const IntRect &aSourceRect,
      90             :                            const IntPoint &aDestination) override;
      91             : 
      92             :   virtual void FillRect(const Rect &aRect, const Pattern &aPattern, const DrawOptions &aOptions) override;
      93             : 
      94             :   virtual void StrokeRect(const Rect &aRect, const Pattern &aPattern,
      95             :                           const StrokeOptions &aStrokeOptions, const DrawOptions &aOptions) override;
      96             : 
      97             :   virtual void StrokeLine(const Point &aStart, const Point &aEnd, const Pattern &aPattern,
      98             :                           const StrokeOptions &aStrokeOptions, const DrawOptions &aOptions) override;
      99             : 
     100             :   virtual void Stroke(const Path *aPath, const Pattern &aPattern,
     101             :                       const StrokeOptions &aStrokeOptions, const DrawOptions &aOptions) override;
     102             : 
     103             :   virtual void Fill(const Path *aPath, const Pattern &aPattern, const DrawOptions &aOptions) override;
     104             : 
     105             :   virtual void FillGlyphs(ScaledFont *aScaledFont, const GlyphBuffer &aBuffer,
     106             :                           const Pattern &aPattern, const DrawOptions &aOptions,
     107             :                           const GlyphRenderingOptions *aRenderingOptions) override;
     108             :   
     109             :   virtual void Mask(const Pattern &aSource, const Pattern &aMask, const DrawOptions &aOptions) override;
     110             : 
     111             :   virtual void PushLayer(bool aOpaque, Float aOpacity,
     112             :                          SourceSurface* aMask,
     113             :                          const Matrix& aMaskTransform,
     114             :                          const IntRect& aBounds = IntRect(),
     115             :                          bool aCopyBackground = false) override;
     116             : 
     117             :   virtual already_AddRefed<SourceSurface>
     118           0 :     CreateSourceSurfaceFromData(unsigned char *aData,
     119             :                                 const IntSize &aSize,
     120             :                                 int32_t aStride,
     121             :                                 SurfaceFormat aFormat) const override
     122             :   {
     123           0 :     return mA->CreateSourceSurfaceFromData(aData, aSize, aStride, aFormat);
     124             :   }
     125             :      
     126           0 :   virtual already_AddRefed<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const override
     127             :   {
     128           0 :     return mA->OptimizeSourceSurface(aSurface);
     129             :   }
     130             :      
     131             :   virtual already_AddRefed<SourceSurface>
     132           0 :     CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const override
     133             :   {
     134           0 :     return mA->CreateSourceSurfaceFromNativeSurface(aSurface);
     135             :   }
     136             :      
     137             :   virtual already_AddRefed<DrawTarget>
     138             :     CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const override;
     139             :      
     140           0 :   virtual already_AddRefed<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const override
     141             :   {
     142           0 :     return mA->CreatePathBuilder(aFillRule);
     143             :   }
     144             :      
     145             :   virtual already_AddRefed<GradientStops>
     146           0 :     CreateGradientStops(GradientStop *aStops,
     147             :                         uint32_t aNumStops,
     148             :                         ExtendMode aExtendMode = ExtendMode::CLAMP) const override
     149             :   {
     150           0 :     return mA->CreateGradientStops(aStops, aNumStops, aExtendMode);
     151             :   }
     152             : 
     153           0 :   virtual already_AddRefed<FilterNode> CreateFilter(FilterType aType) override
     154             :   {
     155           0 :     return mA->CreateFilter(aType);
     156             :   }
     157             : 
     158           0 :   virtual void *GetNativeSurface(NativeSurfaceType aType) override
     159             :   {
     160           0 :     return nullptr;
     161             :   }
     162             : 
     163           0 :   virtual bool IsDualDrawTarget() const override
     164             :   {
     165           0 :     return true;
     166             :   }
     167             : 
     168           0 :   virtual bool IsCurrentGroupOpaque() override { return mA->IsCurrentGroupOpaque(); }
     169             :      
     170             : private:
     171             :   RefPtr<DrawTarget> mA;
     172             :   RefPtr<DrawTarget> mB;
     173             : };
     174             :      
     175             : } // namespace gfx
     176             : } // namespace mozilla
     177             :      
     178             : #endif /* MOZILLA_GFX_DRAWTARGETDUAL_H_ */ 

Generated by: LCOV version 1.13