LCOV - code coverage report
Current view: directory - gfx/2d - DrawTargetCairo.h (source / functions) Found Hit Coverage
Test: app.info Lines: 10 0 0.0 %
Date: 2012-06-02 Functions: 6 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2                 :  * ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is Mozilla Corporation code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is Mozilla Foundation.
      18                 :  * Portions created by the Initial Developer are Copyright (C) 2011
      19                 :  * the Initial Developer. All Rights Reserved.
      20                 :  *
      21                 :  * Contributor(s):
      22                 :  *
      23                 :  * Alternatively, the contents of this file may be used under the terms of
      24                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      25                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      26                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      27                 :  * of those above. If you wish to allow use of your version of this file only
      28                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      29                 :  * use your version of this file under the terms of the MPL, indicate your
      30                 :  * decision by deleting the provisions above and replace them with the notice
      31                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      32                 :  * the provisions above, a recipient may use your version of this file under
      33                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      34                 :  *
      35                 :  * ***** END LICENSE BLOCK ***** */
      36                 : 
      37                 : #ifndef _MOZILLA_GFX_DRAWTARGET_CAIRO_H_
      38                 : #define _MOZILLA_GFX_DRAWTARGET_CAIRO_H_
      39                 : 
      40                 : #include "2D.h"
      41                 : #include "cairo.h"
      42                 : #include "PathCairo.h"
      43                 : 
      44                 : #include <vector>
      45                 : 
      46                 : namespace mozilla {
      47                 : namespace gfx {
      48                 : 
      49                 : class SourceSurfaceCairo;
      50                 : 
      51                 : class GradientStopsCairo : public GradientStops
      52                 : {
      53                 :   public:
      54               0 :     GradientStopsCairo(GradientStop* aStops, uint32_t aNumStops)
      55               0 :     {
      56               0 :       for (uint32_t i = 0; i < aNumStops; ++i) {
      57               0 :         mStops.push_back(aStops[i]);
      58                 :       }
      59               0 :     }
      60                 : 
      61               0 :     virtual ~GradientStopsCairo() {}
      62                 : 
      63               0 :     const std::vector<GradientStop>& GetStops() const
      64                 :     {
      65               0 :       return mStops;
      66                 :     }
      67                 : 
      68               0 :     virtual BackendType GetBackendType() const { return BACKEND_CAIRO; }
      69                 : 
      70                 :   private:
      71                 :     std::vector<GradientStop> mStops;
      72                 : };
      73                 : 
      74                 : class DrawTargetCairo : public DrawTarget
      75                 : {
      76                 : public:
      77                 :   DrawTargetCairo();
      78                 :   virtual ~DrawTargetCairo();
      79                 : 
      80               0 :   virtual BackendType GetType() const { return BACKEND_CAIRO; }
      81                 :   virtual TemporaryRef<SourceSurface> Snapshot();
      82                 :   virtual IntSize GetSize();
      83                 : 
      84                 :   virtual void Flush();
      85                 :   virtual void DrawSurface(SourceSurface *aSurface,
      86                 :                            const Rect &aDest,
      87                 :                            const Rect &aSource,
      88                 :                            const DrawSurfaceOptions &aSurfOptions = DrawSurfaceOptions(),
      89                 :                            const DrawOptions &aOptions = DrawOptions());
      90                 :   virtual void DrawSurfaceWithShadow(SourceSurface *aSurface,
      91                 :                                      const Point &aDest,
      92                 :                                      const Color &aColor,
      93                 :                                      const Point &aOffset,
      94                 :                                      Float aSigma,
      95                 :                                      CompositionOp aOperator);
      96                 : 
      97                 :   virtual void ClearRect(const Rect &aRect);
      98                 : 
      99                 :   virtual void CopySurface(SourceSurface *aSurface,
     100                 :                            const IntRect &aSourceRect,
     101                 :                            const IntPoint &aDestination);
     102                 : 
     103                 :   virtual void FillRect(const Rect &aRect,
     104                 :                         const Pattern &aPattern,
     105                 :                         const DrawOptions &aOptions = DrawOptions());
     106                 :   virtual void StrokeRect(const Rect &aRect,
     107                 :                           const Pattern &aPattern,
     108                 :                           const StrokeOptions &aStrokeOptions = StrokeOptions(),
     109                 :                           const DrawOptions &aOptions = DrawOptions());
     110                 :   virtual void StrokeLine(const Point &aStart,
     111                 :                           const Point &aEnd,
     112                 :                           const Pattern &aPattern,
     113                 :                           const StrokeOptions &aStrokeOptions = StrokeOptions(),
     114                 :                           const DrawOptions &aOptions = DrawOptions());
     115                 : 
     116                 :   virtual void Stroke(const Path *aPath,
     117                 :                       const Pattern &aPattern,
     118                 :                       const StrokeOptions &aStrokeOptions = StrokeOptions(),
     119                 :                       const DrawOptions &aOptions = DrawOptions());
     120                 : 
     121                 :   virtual void Fill(const Path *aPath,
     122                 :                     const Pattern &aPattern,
     123                 :                     const DrawOptions &aOptions = DrawOptions());
     124                 : 
     125                 :   virtual void FillGlyphs(ScaledFont *aFont,
     126                 :                           const GlyphBuffer &aBuffer,
     127                 :                           const Pattern &aPattern,
     128                 :                           const DrawOptions &aOptions);
     129                 :   virtual void Mask(const Pattern &aSource,
     130                 :                     const Pattern &aMask,
     131                 :                     const DrawOptions &aOptions = DrawOptions());
     132                 : 
     133                 :   virtual void PushClip(const Path *aPath);
     134                 :   virtual void PushClipRect(const Rect &aRect);
     135                 :   virtual void PopClip();
     136                 : 
     137                 :   virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FILL_WINDING) const;
     138                 : 
     139                 :   virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
     140                 :                                                             const IntSize &aSize,
     141                 :                                                             int32_t aStride,
     142                 :                                                             SurfaceFormat aFormat) const;
     143                 :   virtual TemporaryRef<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const;
     144                 :   virtual TemporaryRef<SourceSurface>
     145                 :     CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const;
     146                 :   virtual TemporaryRef<DrawTarget>
     147                 :     CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const;
     148                 : 
     149                 :   virtual TemporaryRef<GradientStops>
     150                 :     CreateGradientStops(GradientStop *aStops,
     151                 :                         uint32_t aNumStops,
     152                 :                         ExtendMode aExtendMode = EXTEND_CLAMP) const;
     153                 : 
     154                 :   virtual void *GetNativeSurface(NativeSurfaceType aType);
     155                 : 
     156                 :   bool Init(cairo_surface_t* aSurface);
     157                 : 
     158                 :   void SetPathObserver(CairoPathContext* aPathObserver);
     159                 : 
     160                 :   virtual void SetTransform(const Matrix& aTransform);
     161                 : 
     162                 :   // Call to set up aContext for drawing (with the current transform, etc).
     163                 :   // Pass the path you're going to be using if you have one.
     164                 :   // Implicitly calls WillChange(aPath).
     165                 :   void PrepareForDrawing(cairo_t* aContext, const Path* aPath = NULL);
     166                 : 
     167                 : private: // methods
     168                 :   enum DrawPatternType { DRAW_FILL, DRAW_STROKE };
     169                 :   void DrawPattern(const Pattern& aPattern,
     170                 :                    const StrokeOptions& aStrokeOptions,
     171                 :                    const DrawOptions& aOptions,
     172                 :                    DrawPatternType aDrawType);
     173                 : 
     174                 :   // Copy-on-write support for snapshot surfaces.
     175                 :   friend class SourceSurfaceCairo;
     176                 :   void AppendSnapshot(SourceSurfaceCairo* aSnapshot);
     177                 :   void RemoveSnapshot(SourceSurfaceCairo* aSnapshot);
     178                 : 
     179                 :   // Call before you make any changes to the backing surface with which this
     180                 :   // context is associated. Pass the path you're going to be using if you have
     181                 :   // one.
     182                 :   void WillChange(const Path* aPath = NULL);
     183                 : 
     184                 :   // Call if there is any reason to disassociate all snapshots from this draw
     185                 :   // target; for example, because we're going to be destroyed.
     186                 :   void MarkSnapshotsIndependent();
     187                 : 
     188                 : private: // data
     189                 :   cairo_t* mContext;
     190                 :   std::vector<SourceSurfaceCairo*> mSnapshots;
     191                 :   mutable RefPtr<CairoPathContext> mPathObserver;
     192                 : };
     193                 : 
     194                 : }
     195                 : }
     196                 : 
     197                 : #endif // _MOZILLA_GFX_DRAWTARGET_CAIRO_H_

Generated by: LCOV version 1.7