Debian Codegraph @

include/android/SkAndroidFrameworkUtils.h

raw
1 /*
2 * Copyright 2017 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 SkAndroidFrameworkUtils_DEFINED
9 #define SkAndroidFrameworkUtils_DEFINED
10
11 #include "include/core/SkColor.h"
12 #include "include/core/SkPoint.h"
13 #include "include/core/SkRefCnt.h"
14 #include "include/core/SkTileMode.h"
15
16 class SkCanvas;
17 struct SkIRect;
18 struct SkRect;
19 class SkSurface;
20 class SkShader;
21
22 /**
23 * SkAndroidFrameworkUtils expose private APIs used only by Android framework.
24 */
25 class SkAndroidFrameworkUtils {
26 public:
27
28 #if defined(SK_GANESH)
29 /**
30 * clipWithStencil draws the current clip into a stencil buffer with reference value and mask
31 * set to 0x1. This function works only on a GPU canvas.
32 *
33 * @param canvas A GPU canvas that has a non-empty clip.
34 *
35 * @return true on success or false if clip is empty or not a GPU canvas.
36 */
37 static bool clipWithStencil(SkCanvas* canvas);
38 #endif //defined(SK_GANESH)
39
40 static void SafetyNetLog(const char*);
41
42 static sk_sp<SkSurface> getSurfaceFromCanvas(SkCanvas* canvas);
43
44 static int SaveBehind(SkCanvas* canvas, const SkRect* subset);
45
46 // Operating within the canvas' clip stack, this resets the geometry of the clip to be wide
47 // open modula any device clip restriction that was set outside of the clip stack.
48 static void ResetClip(SkCanvas* canvas);
49
50 /**
51 * Unrolls a chain of nested SkPaintFilterCanvas to return the base wrapped canvas.
52 *
53 * @param canvas A SkPaintFilterCanvas or any other SkCanvas subclass.
54 *
55 * @return SkCanvas that was found in the innermost SkPaintFilterCanvas.
56 */
57 static SkCanvas* getBaseWrappedCanvas(SkCanvas* canvas);
58
59 /**
60 * If the shader represents a linear gradient ShaderAsALinearGradient
61 * returns true and if info is not null, ShaderAsALinearGradient populates
62 * info with the parameters for the gradient. fColorCount is both an input
63 * and output parameter. On input, it indicates how many entries in
64 * fColors and fColorOffsets can be used, if they are not nullptr. After
65 * asAGradient has run, fColorCount indicates how many color-offset pairs
66 * there are in the gradient. fColorOffsets specifies where on the range of
67 * 0 to 1 to transition to the given color. fPoints represent the endpoints
68 * of the gradient.
69 */
70 struct LinearGradientInfo {
71 int fColorCount = 0; //!< In-out parameter, specifies passed size
72 // of fColors/fColorOffsets on input, and
73 // actual number of colors/offsets on
74 // output.
75 SkColor4f* fColors = nullptr; //!< The colors in the gradient.
76 SkScalar* fColorOffsets = nullptr; //!< The unit offset for color transitions.
77 SkPoint fPoints[2]; //!< Type specific, see above.
78 SkTileMode fTileMode;
79 uint32_t fGradientFlags = 0; //!< see SkGradientShader::Flags
80 };
81
82 static bool ShaderAsALinearGradient(SkShader* shader, LinearGradientInfo*);
83 };
84
85 #endif // SkAndroidFrameworkUtils_DEFINED