blob: d1e4dea59411291ed7aa7f49f4141a321c2eb730 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkPDFGradientShader_DEFINED
#define SkPDFGradientShader_DEFINED
#include "include/core/SkShader.h"
#include "src/pdf/SkPDFTypes.h"
#include "src/pdf/SkPDFUtils.h"
#include "src/shaders/SkShaderBase.h"
class SkMatrix;
class SkPDFDocument;
struct SkIRect;
namespace SkPDFGradientShader {
SkPDFIndirectReference Make(SkPDFDocument* doc,
SkShader* shader,
const SkMatrix& matrix,
const SkIRect& surfaceBBox);
struct Key {
SkShaderBase::GradientType fType;
SkShaderBase::GradientInfo fInfo;
std::unique_ptr<SkColor[]> fColors;
std::unique_ptr<SkScalar[]> fStops;
SkMatrix fCanvasTransform;
SkMatrix fShaderTransform;
SkIRect fBBox;
uint32_t fHash;
};
struct KeyHash {
uint32_t operator()(const Key& k) const { return k.fHash; }
};
inline bool operator==(const SkShaderBase::GradientInfo& u, const SkShaderBase::GradientInfo& v) {
return u.fColorCount == v.fColorCount
&& u.fPoint[0] == v.fPoint[0]
&& u.fPoint[1] == v.fPoint[1]
&& u.fRadius[0] == v.fRadius[0]
&& u.fRadius[1] == v.fRadius[1]
&& u.fTileMode == v.fTileMode
&& u.fGradientFlags == v.fGradientFlags
&& SkPackedArrayEqual(u.fColors, v.fColors, u.fColorCount)
&& SkPackedArrayEqual(u.fColorOffsets, v.fColorOffsets, u.fColorCount);
}
inline bool operator==(const Key& u, const Key& v) {
SkASSERT(u.fInfo.fColors == u.fColors.get());
SkASSERT(u.fInfo.fColorOffsets == u.fStops.get());
SkASSERT(v.fInfo.fColors == v.fColors.get());
SkASSERT(v.fInfo.fColorOffsets == v.fStops.get());
return u.fType == v.fType
&& u.fInfo == v.fInfo
&& u.fCanvasTransform == v.fCanvasTransform
&& u.fShaderTransform == v.fShaderTransform
&& u.fBBox == v.fBBox;
}
inline bool operator!=(const Key& u, const Key& v) { return !(u == v); }
} // namespace SkPDFGradientShader
#endif // SkPDFGradientShader_DEFINED
|