LCOV - code coverage report
Current view: directory - gfx/skia/src/core - SkPictureRecord.h (source / functions) Found Hit Coverage
Test: app.info Lines: 22 0 0.0 %
Date: 2012-06-02 Functions: 10 0 0.0 %

       1                 : 
       2                 : /*
       3                 :  * Copyright 2011 Google Inc.
       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                 : #ifndef SkPictureRecord_DEFINED
       9                 : #define SkPictureRecord_DEFINED
      10                 : 
      11                 : #include "SkCanvas.h"
      12                 : #include "SkFlattenable.h"
      13                 : #include "SkPathHeap.h"
      14                 : #include "SkPicture.h"
      15                 : #include "SkPictureFlat.h"
      16                 : #include "SkTemplates.h"
      17                 : #include "SkWriter32.h"
      18                 : 
      19                 : class SkPictureRecord : public SkCanvas {
      20                 : public:
      21                 :     SkPictureRecord(uint32_t recordFlags);
      22                 :     virtual ~SkPictureRecord();
      23                 : 
      24                 :     virtual int save(SaveFlags) SK_OVERRIDE;
      25                 :     virtual int saveLayer(const SkRect* bounds, const SkPaint*, SaveFlags) SK_OVERRIDE;
      26                 :     virtual void restore() SK_OVERRIDE;
      27                 :     virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE;
      28                 :     virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE;
      29                 :     virtual bool rotate(SkScalar degrees) SK_OVERRIDE;
      30                 :     virtual bool skew(SkScalar sx, SkScalar sy) SK_OVERRIDE;
      31                 :     virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE;
      32                 :     virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE;
      33                 :     virtual bool clipRect(const SkRect&, SkRegion::Op, bool) SK_OVERRIDE;
      34                 :     virtual bool clipPath(const SkPath&, SkRegion::Op, bool) SK_OVERRIDE;
      35                 :     virtual bool clipRegion(const SkRegion& region, SkRegion::Op op) SK_OVERRIDE;
      36                 :     virtual void clear(SkColor) SK_OVERRIDE;
      37                 :     virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE;
      38                 :     virtual void drawPoints(PointMode, size_t count, const SkPoint pts[],
      39                 :                             const SkPaint&) SK_OVERRIDE;
      40                 :     virtual void drawRect(const SkRect& rect, const SkPaint&) SK_OVERRIDE;
      41                 :     virtual void drawPath(const SkPath& path, const SkPaint&) SK_OVERRIDE;
      42                 :     virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top,
      43                 :                             const SkPaint*) SK_OVERRIDE;
      44                 :     virtual void drawBitmapRect(const SkBitmap&, const SkIRect* src,
      45                 :                                 const SkRect& dst, const SkPaint*) SK_OVERRIDE;
      46                 :     virtual void drawBitmapMatrix(const SkBitmap&, const SkMatrix&,
      47                 :                                   const SkPaint*) SK_OVERRIDE;
      48                 :     virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
      49                 :                                 const SkRect& dst, const SkPaint*) SK_OVERRIDE;
      50                 :     virtual void drawSprite(const SkBitmap&, int left, int top,
      51                 :                             const SkPaint*) SK_OVERRIDE;
      52                 :     virtual void drawText(const void* text, size_t byteLength, SkScalar x, 
      53                 :                           SkScalar y, const SkPaint&) SK_OVERRIDE;
      54                 :     virtual void drawPosText(const void* text, size_t byteLength, 
      55                 :                              const SkPoint pos[], const SkPaint&) SK_OVERRIDE;
      56                 :     virtual void drawPosTextH(const void* text, size_t byteLength,
      57                 :                       const SkScalar xpos[], SkScalar constY, const SkPaint&) SK_OVERRIDE;
      58                 :     virtual void drawTextOnPath(const void* text, size_t byteLength, 
      59                 :                             const SkPath& path, const SkMatrix* matrix, 
      60                 :                                 const SkPaint&) SK_OVERRIDE;
      61                 :     virtual void drawPicture(SkPicture& picture) SK_OVERRIDE;
      62                 :     virtual void drawVertices(VertexMode, int vertexCount,
      63                 :                           const SkPoint vertices[], const SkPoint texs[],
      64                 :                           const SkColor colors[], SkXfermode*,
      65                 :                           const uint16_t indices[], int indexCount,
      66                 :                               const SkPaint&) SK_OVERRIDE;
      67                 :     virtual void drawData(const void*, size_t) SK_OVERRIDE;
      68                 : 
      69                 :     void addFontMetricsTopBottom(const SkPaint& paint, SkScalar baselineY);
      70                 :     
      71               0 :     const SkTDArray<const SkFlatBitmap* >& getBitmaps() const {
      72               0 :         return fBitmaps;
      73                 :     }
      74               0 :     const SkTDArray<const SkFlatMatrix* >& getMatrices() const {
      75               0 :         return fMatrices;
      76                 :     }
      77               0 :     const SkTDArray<const SkFlatPaint* >& getPaints() const {
      78               0 :         return fPaints;
      79                 :     }
      80               0 :     const SkTDArray<SkPicture* >& getPictureRefs() const {
      81               0 :         return fPictureRefs;
      82                 :     }
      83               0 :     const SkTDArray<const SkFlatRegion* >& getRegions() const {
      84               0 :         return fRegions;
      85                 :     }
      86                 :     
      87                 :     void reset();
      88                 : 
      89               0 :     const SkWriter32& writeStream() const {
      90               0 :         return fWriter;
      91                 :     }
      92                 : 
      93                 : private:
      94                 :     SkTDArray<uint32_t> fRestoreOffsetStack;
      95                 : 
      96               0 :     void addDraw(DrawType drawType) {
      97                 : #ifdef SK_DEBUG_TRACE
      98                 :         SkDebugf("add %s\n", DrawTypeToString(drawType));
      99                 : #endif
     100               0 :         fWriter.writeInt(drawType);
     101               0 :     }    
     102               0 :     void addInt(int value) {
     103               0 :         fWriter.writeInt(value);
     104               0 :     }
     105               0 :     void addScalar(SkScalar scalar) {
     106               0 :         fWriter.writeScalar(scalar);
     107               0 :     }
     108                 :     
     109                 :     void addBitmap(const SkBitmap& bitmap);
     110                 :     void addMatrix(const SkMatrix& matrix);
     111                 :     void addMatrixPtr(const SkMatrix* matrix);
     112                 :     void addPaint(const SkPaint& paint);
     113                 :     void addPaintPtr(const SkPaint* paint);
     114                 :     void addPath(const SkPath& path);
     115                 :     void addPicture(SkPicture& picture);
     116                 :     void addPoint(const SkPoint& point);
     117                 :     void addPoints(const SkPoint pts[], int count);
     118                 :     void addRect(const SkRect& rect);
     119                 :     void addRectPtr(const SkRect* rect);
     120                 :     void addIRect(const SkIRect& rect);
     121                 :     void addIRectPtr(const SkIRect* rect);
     122                 :     void addRegion(const SkRegion& region);
     123                 :     void addText(const void* text, size_t byteLength);
     124                 : 
     125                 :     int find(SkTDArray<const SkFlatBitmap* >& bitmaps,
     126                 :                    const SkBitmap& bitmap);
     127                 :     int find(SkTDArray<const SkFlatMatrix* >& matrices,
     128                 :                    const SkMatrix* matrix);
     129                 :     int find(SkTDArray<const SkFlatPaint* >& paints, const SkPaint* paint);
     130                 :     int find(SkTDArray<const SkFlatRegion* >& regions, const SkRegion& region);
     131                 : 
     132                 : #ifdef SK_DEBUG_DUMP
     133                 : public:
     134                 :     void dumpMatrices();
     135                 :     void dumpPaints();
     136                 : #endif
     137                 : 
     138                 : #ifdef SK_DEBUG_SIZE
     139                 : public:
     140                 :     size_t size() const;    
     141                 :     int bitmaps(size_t* size) const;
     142                 :     int matrices(size_t* size) const;
     143                 :     int paints(size_t* size) const;
     144                 :     int paths(size_t* size) const;
     145                 :     int regions(size_t* size) const;
     146                 :     size_t streamlen() const;
     147                 :     
     148                 :     size_t fPointBytes, fRectBytes, fTextBytes;
     149                 :     int fPointWrites, fRectWrites, fTextWrites;
     150                 : #endif
     151                 : 
     152                 : #ifdef SK_DEBUG_VALIDATE
     153                 : public:
     154                 :     void validate() const;
     155                 : private:
     156                 :     void validateBitmaps() const;
     157                 :     void validateMatrices() const;
     158                 :     void validatePaints() const;
     159                 :     void validatePaths() const;
     160                 :     void validateRegions() const;
     161                 : #else
     162                 : public:
     163               0 :     void validate() const {}
     164                 : #endif
     165                 : 
     166                 : private:
     167                 :     SkChunkAlloc fHeap;
     168                 :     int fBitmapIndex;
     169                 :     SkTDArray<const SkFlatBitmap* > fBitmaps;
     170                 :     int fMatrixIndex;
     171                 :     SkTDArray<const SkFlatMatrix* > fMatrices;
     172                 :     int fPaintIndex;
     173                 :     SkTDArray<const SkFlatPaint* > fPaints;
     174                 :     int fRegionIndex;
     175                 :     SkTDArray<const SkFlatRegion* > fRegions;
     176                 :     SkPathHeap* fPathHeap;  // reference counted
     177                 :     SkWriter32 fWriter;
     178                 : 
     179                 :     // we ref each item in these arrays
     180                 :     SkTDArray<SkPicture*> fPictureRefs;
     181                 : 
     182                 :     SkRefCntSet fRCSet;
     183                 :     SkRefCntSet fTFSet;
     184                 :     
     185                 :     uint32_t fRecordFlags;
     186                 : 
     187                 :     // helper function to handle save/restore culling offsets
     188                 :     void recordOffsetForRestore(SkRegion::Op op);
     189                 : 
     190                 :     friend class SkPicturePlayback;
     191                 : 
     192                 :     typedef SkCanvas INHERITED;
     193                 : };
     194                 : 
     195                 : #endif

Generated by: LCOV version 1.7