LCOV - code coverage report
Current view: top level - gfx/skia/skia/src/core - SkDraw.h (source / functions) Hit Total Coverage
Test: output.info Lines: 7 13 53.8 %
Date: 2017-07-14 16:53:18 Functions: 4 6 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : 
       2             : /*
       3             :  * Copyright 2006 The Android Open Source Project
       4             :  *
       5             :  * Use of this source code is governed by a BSD-style license that can be
       6             :  * found in the LICENSE file.
       7             :  */
       8             : 
       9             : 
      10             : #ifndef SkDraw_DEFINED
      11             : #define SkDraw_DEFINED
      12             : 
      13             : #include "SkCanvas.h"
      14             : #include "SkMask.h"
      15             : #include "SkPaint.h"
      16             : #include "SkStrokeRec.h"
      17             : #include "SkVertices.h"
      18             : 
      19             : class SkBitmap;
      20             : class SkClipStack;
      21             : class SkBaseDevice;
      22             : class SkBlitter;
      23             : class SkMatrix;
      24             : class SkPath;
      25             : class SkRegion;
      26             : class SkRasterClip;
      27             : struct SkDrawProcs;
      28             : struct SkRect;
      29             : class SkRRect;
      30             : 
      31         523 : class SkDraw {
      32             : public:
      33             :     SkDraw();
      34             : 
      35             :     void    drawPaint(const SkPaint&) const;
      36             :     void    drawPoints(SkCanvas::PointMode, size_t count, const SkPoint[],
      37             :                        const SkPaint&, SkBaseDevice*) const;
      38             :     void    drawRect(const SkRect& prePaintRect, const SkPaint&, const SkMatrix* paintMatrix,
      39             :                      const SkRect* postPaintRect) const;
      40         196 :     void    drawRect(const SkRect& rect, const SkPaint& paint) const {
      41         196 :         this->drawRect(rect, paint, NULL, NULL);
      42         196 :     }
      43             :     void    drawRRect(const SkRRect&, const SkPaint&) const;
      44             :     /**
      45             :      *  To save on mallocs, we allow a flag that tells us that srcPath is
      46             :      *  mutable, so that we don't have to make copies of it as we transform it.
      47             :      *
      48             :      *  If prePathMatrix is not null, it should logically be applied before any
      49             :      *  stroking or other effects. If there are no effects on the paint that
      50             :      *  affect the geometry/rasterization, then the pre matrix can just be
      51             :      *  pre-concated with the current matrix.
      52             :      */
      53          74 :     void    drawPath(const SkPath& path, const SkPaint& paint,
      54             :                      const SkMatrix* prePathMatrix, bool pathIsMutable) const {
      55          74 :         this->drawPath(path, paint, prePathMatrix, pathIsMutable, false);
      56          74 :     }
      57             : 
      58           0 :     void drawPath(const SkPath& path, const SkPaint& paint,
      59             :                   SkBlitter* customBlitter = NULL) const {
      60           0 :         this->drawPath(path, paint, NULL, false, false, customBlitter);
      61           0 :     }
      62             : 
      63             :     /* If dstOrNull is null, computes a dst by mapping the bitmap's bounds through the matrix. */
      64             :     void    drawBitmap(const SkBitmap&, const SkMatrix&, const SkRect* dstOrNull,
      65             :                        const SkPaint&) const;
      66             :     void    drawSprite(const SkBitmap&, int x, int y, const SkPaint&) const;
      67             :     void    drawText(const char text[], size_t byteLength, SkScalar x,
      68             :                      SkScalar y, const SkPaint& paint, const SkSurfaceProps*) const;
      69             :     void    drawPosText(const char text[], size_t byteLength,
      70             :                         const SkScalar pos[], int scalarsPerPosition,
      71             :                         const SkPoint& offset, const SkPaint&, const SkSurfaceProps*) const;
      72             :     void    drawVertices(SkVertices::VertexMode mode, int count,
      73             :                          const SkPoint vertices[], const SkPoint textures[],
      74             :                          const SkColor colors[], SkBlendMode bmode,
      75             :                          const uint16_t indices[], int ptCount,
      76             :                          const SkPaint& paint) const;
      77             : 
      78             :     /**
      79             :      *  Overwrite the target with the path's coverage (i.e. its mask).
      80             :      *  Will overwrite the entire device, so it need not be zero'd first.
      81             :      *
      82             :      *  Only device A8 is supported right now.
      83             :      */
      84           0 :     void drawPathCoverage(const SkPath& src, const SkPaint& paint,
      85             :                           SkBlitter* customBlitter = NULL) const {
      86           0 :         this->drawPath(src, paint, NULL, false, true, customBlitter);
      87           0 :     }
      88             : 
      89             :     /** Helper function that creates a mask from a path and an optional maskfilter.
      90             :         Note however, that the resulting mask will not have been actually filtered,
      91             :         that must be done afterwards (by calling filterMask). The maskfilter is provided
      92             :         solely to assist in computing the mask's bounds (if the mode requests that).
      93             :     */
      94             :     static bool DrawToMask(const SkPath& devPath, const SkIRect* clipBounds,
      95             :                            const SkMaskFilter*, const SkMatrix* filterMatrix,
      96             :                            SkMask* mask, SkMask::CreateMode mode,
      97             :                            SkStrokeRec::InitStyle style);
      98             : 
      99             :     enum RectType {
     100             :         kHair_RectType,
     101             :         kFill_RectType,
     102             :         kStroke_RectType,
     103             :         kPath_RectType
     104             :     };
     105             : 
     106             :     /**
     107             :      *  Based on the paint's style, strokeWidth, and the matrix, classify how
     108             :      *  to draw the rect. If no special-case is available, returns
     109             :      *  kPath_RectType.
     110             :      *
     111             :      *  Iff RectType == kStroke_RectType, then strokeSize is set to the device
     112             :      *  width and height of the stroke.
     113             :      */
     114             :     static RectType ComputeRectType(const SkPaint&, const SkMatrix&,
     115             :                                     SkPoint* strokeSize);
     116             : 
     117             :     static bool ShouldDrawTextAsPaths(const SkPaint&, const SkMatrix&);
     118             :     void        drawText_asPaths(const char text[], size_t byteLength, SkScalar x, SkScalar y,
     119             :                                  const SkPaint&) const;
     120             :     void        drawPosText_asPaths(const char text[], size_t byteLength, const SkScalar pos[],
     121             :                                     int scalarsPerPosition, const SkPoint& offset,
     122             :                                     const SkPaint&, const SkSurfaceProps*) const;
     123             :     static SkScalar ComputeResScaleForStroking(const SkMatrix& );
     124             : private:
     125             :     void    drawDevMask(const SkMask& mask, const SkPaint&) const;
     126             :     void    drawBitmapAsMask(const SkBitmap&, const SkPaint&) const;
     127             : 
     128             :     void    drawPath(const SkPath&, const SkPaint&, const SkMatrix* preMatrix,
     129             :                      bool pathIsMutable, bool drawCoverage,
     130             :                      SkBlitter* customBlitter = NULL) const;
     131             : 
     132             :     void drawLine(const SkPoint[2], const SkPaint&) const;
     133             :     void drawDevPath(const SkPath& devPath, const SkPaint& paint, bool drawCoverage,
     134             :                      SkBlitter* customBlitter, bool doFill) const;
     135             :     /**
     136             :      *  Return the current clip bounds, in local coordinates, with slop to account
     137             :      *  for antialiasing or hairlines (i.e. device-bounds outset by 1, and then
     138             :      *  run through the inverse of the matrix).
     139             :      *
     140             :      *  If the matrix cannot be inverted, or the current clip is empty, return
     141             :      *  false and ignore bounds parameter.
     142             :      */
     143             :     bool SK_WARN_UNUSED_RESULT
     144             :     computeConservativeLocalClipBounds(SkRect* bounds) const;
     145             : 
     146             :     /** Returns the current setting for using fake gamma and contrast. */
     147             :     uint32_t SK_WARN_UNUSED_RESULT scalerContextFlags() const;
     148             : 
     149             : public:
     150             :     SkPixmap        fDst;
     151             :     const SkMatrix* fMatrix;        // required
     152             :     const SkRasterClip* fRC;        // required
     153             : 
     154             : #ifdef SK_DEBUG
     155             :     void validate() const;
     156             : #else
     157             :     void validate() const {}
     158             : #endif
     159             : };
     160             : 
     161             : #endif

Generated by: LCOV version 1.13