Home | History | Annotate | Download | only in core
      1 /*
      2  * Copyright 2014 Google Inc.
      3  *
      4  * Use of this source code is governed by a BSD-style license that can be
      5  * found in the LICENSE file.
      6  */
      7 
      8 #ifndef SkCanvasPriv_DEFINED
      9 #define SkCanvasPriv_DEFINED
     10 
     11 #include "SkCanvas.h"
     12 
     13 class SkReadBuffer;
     14 class SkWriteBuffer;
     15 
     16 class SkAutoCanvasMatrixPaint : SkNoncopyable {
     17 public:
     18     SkAutoCanvasMatrixPaint(SkCanvas*, const SkMatrix*, const SkPaint*, const SkRect& bounds);
     19     ~SkAutoCanvasMatrixPaint();
     20 
     21 private:
     22     SkCanvas*   fCanvas;
     23     int         fSaveCount;
     24 };
     25 
     26 class SkCanvasPriv {
     27 public:
     28     enum {
     29         kDontClipToLayer_SaveLayerFlag = SkCanvas::kDontClipToLayer_PrivateSaveLayerFlag,
     30     };
     31 
     32     // The lattice has pointers directly into the readbuffer
     33     static bool ReadLattice(SkReadBuffer&, SkCanvas::Lattice*);
     34 
     35     static void WriteLattice(SkWriteBuffer&, const SkCanvas::Lattice&);
     36 
     37     // return the byte-size of the lattice, even if the buffer is null
     38     // storage must be 4-byte aligned
     39     static size_t WriteLattice(void* storage, const SkCanvas::Lattice&);
     40 
     41     static SkCanvas::SaveLayerFlags LegacySaveFlagsToSaveLayerFlags(uint32_t legacySaveFlags);
     42 
     43     static int SaveBehind(SkCanvas* canvas, const SkRect* subset) {
     44         return canvas->only_axis_aligned_saveBehind(subset);
     45     }
     46 
     47     static void DrawBehind(SkCanvas* canvas, const SkPaint& paint) {
     48         canvas->drawClippedToSaveBehind(paint);
     49     }
     50 
     51     // The experimental_DrawEdgeAAImageSet API accepts separate dstClips and preViewMatrices arrays,
     52     // where entries refer into them, but no explicit size is provided. Given a set of entries,
     53     // computes the minimum length for these arrays that would provide index access errors.
     54     static void GetDstClipAndMatrixCounts(const SkCanvas::ImageSetEntry set[], int count,
     55                                           int* totalDstClipCount, int* totalMatrixCount);
     56 };
     57 
     58 #endif
     59