• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "include/core/SkCanvas.h"
12 #include "include/private/SkNoncopyable.h"
13 
14 class SkReadBuffer;
15 class SkWriteBuffer;
16 
17 class SkAutoCanvasMatrixPaint : SkNoncopyable {
18 public:
19     SkAutoCanvasMatrixPaint(SkCanvas*, const SkMatrix*, const SkPaint*, const SkRect& bounds);
20     ~SkAutoCanvasMatrixPaint();
21 
22 private:
23     SkCanvas*   fCanvas;
24     int         fSaveCount;
25 };
26 
27 class SkCanvasPriv {
28 public:
29     enum {
30         kDontClipToLayer_SaveLayerFlag = SkCanvas::kDontClipToLayer_PrivateSaveLayerFlag,
31     };
32 
33     // The lattice has pointers directly into the readbuffer
34     static bool ReadLattice(SkReadBuffer&, SkCanvas::Lattice*);
35 
36     static void WriteLattice(SkWriteBuffer&, const SkCanvas::Lattice&);
37 
38     // return the byte-size of the lattice, even if the buffer is null
39     // storage must be 4-byte aligned
40     static size_t WriteLattice(void* storage, const SkCanvas::Lattice&);
41 
42     static SkCanvas::SaveLayerFlags LegacySaveFlagsToSaveLayerFlags(uint32_t legacySaveFlags);
43 
SaveBehind(SkCanvas * canvas,const SkRect * subset)44     static int SaveBehind(SkCanvas* canvas, const SkRect* subset) {
45         return canvas->only_axis_aligned_saveBehind(subset);
46     }
DrawBehind(SkCanvas * canvas,const SkPaint & paint)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