Flutter Engine
The Flutter Engine
SkPDFGradientShader.h
Go to the documentation of this file.
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#ifndef SkPDFGradientShader_DEFINED
8#define SkPDFGradientShader_DEFINED
9
12#include "include/core/SkRect.h"
16#include "src/pdf/SkPDFTypes.h"
17#include "src/pdf/SkPDFUtils.h"
19
20#include <cstdint>
21#include <memory>
22
23class SkPDFDocument;
24class SkShader;
25
26namespace SkPDFGradientShader {
27
29 SkShader* shader,
30 const SkMatrix& matrix,
31 const SkIRect& surfaceBBox);
32
33struct Key {
36 std::unique_ptr<SkColor[]> fColors;
37 std::unique_ptr<SkScalar[]> fStops;
41 uint32_t fHash;
42};
43
44struct KeyHash {
45 uint32_t operator()(const Key& k) const { return k.fHash; }
46};
47
49 return u.fColorCount == v.fColorCount
50 && u.fPoint[0] == v.fPoint[0]
51 && u.fPoint[1] == v.fPoint[1]
52 && u.fRadius[0] == v.fRadius[0]
53 && u.fRadius[1] == v.fRadius[1]
54 && u.fTileMode == v.fTileMode
58}
59
60inline bool operator==(const Key& u, const Key& v) {
61 SkASSERT(u.fInfo.fColors == u.fColors.get());
62 SkASSERT(u.fInfo.fColorOffsets == u.fStops.get());
63 SkASSERT(v.fInfo.fColors == v.fColors.get());
64 SkASSERT(v.fInfo.fColorOffsets == v.fStops.get());
65 return u.fType == v.fType
66 && u.fInfo == v.fInfo
69 && u.fBBox == v.fBBox;
70}
71inline bool operator!=(const Key& u, const Key& v) { return !(u == v); }
72
73} // namespace SkPDFGradientShader
74#endif // SkPDFGradientShader_DEFINED
#define SkASSERT(cond)
Definition: SkAssert.h:116
bool SkPackedArrayEqual(T *u, T *v, size_t n)
Definition: SkPDFUtils.h:39
bool operator==(const SkShaderBase::GradientInfo &u, const SkShaderBase::GradientInfo &v)
bool operator!=(const Key &u, const Key &v)
SkPDFIndirectReference Make(SkPDFDocument *doc, SkShader *shader, const SkMatrix &matrix, const SkIRect &surfaceBBox)
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
Definition: SkRect.h:32
uint32_t operator()(const Key &k) const
SkShaderBase::GradientType fType
std::unique_ptr< SkScalar[]> fStops
std::unique_ptr< SkColor[]> fColors
SkShaderBase::GradientInfo fInfo
uint32_t fGradientFlags
see SkGradientShader::Flags
Definition: SkShaderBase.h:252
SkPoint fPoint[2]
Type specific, see above.
Definition: SkShaderBase.h:249
SkColor * fColors
The colors in the gradient.
Definition: SkShaderBase.h:247
int fColorCount
In-out parameter, specifies passed size.
Definition: SkShaderBase.h:243
SkScalar fRadius[2]
Type specific, see above.
Definition: SkShaderBase.h:250
SkScalar * fColorOffsets
The unit offset for color transitions.
Definition: SkShaderBase.h:248