Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrGradientBitmapCache.h
Go to the documentation of this file.
1/*
2 * Copyright 2018 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
9#ifndef GrGradientBitmapCache_DEFINED
10#define GrGradientBitmapCache_DEFINED
11
17
18class SkColorSpace;
19
21public:
22 GrGradientBitmapCache(int maxEntries, int resolution);
24
25 // Assumes colors are compatible with the specified alphaType (e.g. if it's premul then colors
26 // are already premultiplied). Thread safe.
27 void getGradient(const SkPMColor4f* colors,
28 const SkScalar* positions,
29 int count,
30 bool colorsAreOpaque,
31 const SkGradientShader::Interpolation& interpolation,
32 const SkColorSpace* intermediateColorSpace,
33 const SkColorSpace* dstColorSpace,
35 SkAlphaType alphaType,
37
38private:
39 SkMutex fMutex;
40
41 int fEntryCount;
42 const int fMaxEntries;
43 const int fResolution;
44
45 struct Entry;
46 mutable Entry* fHead;
47 mutable Entry* fTail;
48
49 inline Entry* release(Entry*) const;
50 inline void attachToHead(Entry*) const;
51
52 bool find(const void* buffer, size_t len, SkBitmap*) const;
53 void add(const void* buffer, size_t len, const SkBitmap&);
54
55 void fillGradient(const SkPMColor4f* colors,
56 const SkScalar* positions,
57 int count,
58 bool colorsAreOpaque,
59 const SkGradientShader::Interpolation& interpolation,
60 const SkColorSpace* intermediateColorSpace,
61 const SkColorSpace* dstColorSpace,
63
64#ifdef SK_DEBUG
65 void validate() const;
66#else
67 void validate() const {}
68#endif
69
70 class AutoValidate : SkNoncopyable {
71 public:
72 AutoValidate(const GrGradientBitmapCache* bc) : fBC(bc) { bc->validate(); }
73 ~AutoValidate() { fBC->validate(); }
74 private:
75 const GrGradientBitmapCache* fBC;
76 };
77};
78
79#endif
int count
SkAlphaType
Definition SkAlphaType.h:26
SkColorType
Definition SkColorType.h:19
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
int find(T *array, int N, T item)
void getGradient(const SkPMColor4f *colors, const SkScalar *positions, int count, bool colorsAreOpaque, const SkGradientShader::Interpolation &interpolation, const SkColorSpace *intermediateColorSpace, const SkColorSpace *dstColorSpace, SkColorType colorType, SkAlphaType alphaType, SkBitmap *bitmap)
float SkScalar
Definition extension.cpp:12
static const uint8_t buffer[]