| 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 |  | 
|---|
| 44 | static int SaveBehind(SkCanvas* canvas, const SkRect* subset) { | 
|---|
| 45 | return canvas->only_axis_aligned_saveBehind(subset); | 
|---|
| 46 | } | 
|---|
| 47 | static void DrawBehind(SkCanvas* canvas, const SkPaint& paint) { | 
|---|
| 48 | canvas->drawClippedToSaveBehind(paint); | 
|---|
| 49 | } | 
|---|
| 50 |  | 
|---|
| 51 | // Exposed for testing on non-Android framework builds | 
|---|
| 52 | static void ReplaceClip(SkCanvas* canvas, const SkIRect& rect) { | 
|---|
| 53 | canvas->androidFramework_replaceClip(rect); | 
|---|
| 54 | } | 
|---|
| 55 |  | 
|---|
| 56 | // The experimental_DrawEdgeAAImageSet API accepts separate dstClips and preViewMatrices arrays, | 
|---|
| 57 | // where entries refer into them, but no explicit size is provided. Given a set of entries, | 
|---|
| 58 | // computes the minimum length for these arrays that would provide index access errors. | 
|---|
| 59 | static void GetDstClipAndMatrixCounts(const SkCanvas::ImageSetEntry set[], int count, | 
|---|
| 60 | int* totalDstClipCount, int* totalMatrixCount); | 
|---|
| 61 |  | 
|---|
| 62 | // Checks that the marker name is an identifier ([a-zA-Z][a-zA-Z0-9_]*) | 
|---|
| 63 | // Identifiers with leading underscores are reserved (not allowed). | 
|---|
| 64 | static bool ValidateMarker(const char*); | 
|---|
| 65 | }; | 
|---|
| 66 |  | 
|---|
| 67 | #endif | 
|---|
| 68 |  | 
|---|