OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkBitmapProcShader_DEFINED | 10 #ifndef SkBitmapProcShader_DEFINED |
11 #define SkBitmapProcShader_DEFINED | 11 #define SkBitmapProcShader_DEFINED |
12 | 12 |
13 #include "SkShader.h" | 13 #include "SkShader.h" |
14 #include "SkSmallAllocator.h" | 14 #include "SkSmallAllocator.h" |
15 | 15 |
16 struct SkBitmapProcState; | 16 struct SkBitmapProcState; |
17 | 17 |
18 class SkBitmapProcShader : public SkShader { | 18 class SkBitmapProcShader : public SkShader { |
19 public: | 19 public: |
20 SkBitmapProcShader(const SkBitmap& src, TileMode tx, TileMode ty, | 20 SkBitmapProcShader(const SkBitmap& src, TileMode tx, TileMode ty, |
21 const SkMatrix* localMatrix = nullptr); | 21 const SkMatrix* localMatrix = nullptr); |
22 | 22 |
23 // overrides from SkShader | |
24 bool isOpaque() const override; | 23 bool isOpaque() const override; |
25 BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const override; | |
26 | 24 |
27 size_t contextSize() const override; | 25 size_t contextSize() const override; |
28 | 26 |
29 SK_TO_STRING_OVERRIDE() | 27 SK_TO_STRING_OVERRIDE() |
30 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader) | 28 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader) |
31 | 29 |
32 #if SK_SUPPORT_GPU | 30 #if SK_SUPPORT_GPU |
33 const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& v
iewM, | 31 const GrFragmentProcessor* asFragmentProcessor(GrContext*, const SkMatrix& v
iewM, |
34 const SkMatrix*, SkFilterQual
ity, | 32 const SkMatrix*, SkFilterQual
ity, |
35 GrProcessorDataManager*) cons
t override; | 33 GrProcessorDataManager*) cons
t override; |
(...skipping 15 matching lines...) Expand all Loading... |
51 private: | 49 private: |
52 SkBitmapProcState* fState; | 50 SkBitmapProcState* fState; |
53 uint32_t fFlags; | 51 uint32_t fFlags; |
54 | 52 |
55 typedef SkShader::Context INHERITED; | 53 typedef SkShader::Context INHERITED; |
56 }; | 54 }; |
57 | 55 |
58 protected: | 56 protected: |
59 void flatten(SkWriteBuffer&) const override; | 57 void flatten(SkWriteBuffer&) const override; |
60 Context* onCreateContext(const ContextRec&, void* storage) const override; | 58 Context* onCreateContext(const ContextRec&, void* storage) const override; |
| 59 bool onIsABitmap(SkBitmap*, SkMatrix*, TileMode*) const override; |
61 | 60 |
62 SkBitmap fRawBitmap; // experimental for RLE encoding | 61 SkBitmap fRawBitmap; // experimental for RLE encoding |
63 uint8_t fTileModeX, fTileModeY; | 62 uint8_t fTileModeX, fTileModeY; |
64 | 63 |
65 private: | 64 private: |
66 typedef SkShader INHERITED; | 65 typedef SkShader INHERITED; |
67 }; | 66 }; |
68 | 67 |
69 // Commonly used allocator. It currently is only used to allocate up to 3 object
s. The total | 68 // Commonly used allocator. It currently is only used to allocate up to 3 object
s. The total |
70 // bytes requested is calculated using one of our large shaders, its context siz
e plus the size of | 69 // bytes requested is calculated using one of our large shaders, its context siz
e plus the size of |
71 // an Sk3DBlitter in SkDraw.cpp | 70 // an Sk3DBlitter in SkDraw.cpp |
72 // Note that some contexts may contain other contexts (e.g. for compose shaders)
, but we've not | 71 // Note that some contexts may contain other contexts (e.g. for compose shaders)
, but we've not |
73 // yet found a situation where the size below isn't big enough. | 72 // yet found a situation where the size below isn't big enough. |
74 typedef SkSmallAllocator<3, 1152> SkTBlitterAllocator; | 73 typedef SkSmallAllocator<3, 1152> SkTBlitterAllocator; |
75 | 74 |
76 // If alloc is non-nullptr, it will be used to allocate the returned SkShader, a
nd MUST outlive | 75 // If alloc is non-nullptr, it will be used to allocate the returned SkShader, a
nd MUST outlive |
77 // the SkShader. | 76 // the SkShader. |
78 SkShader* SkCreateBitmapShader(const SkBitmap& src, SkShader::TileMode, SkShader
::TileMode, | 77 SkShader* SkCreateBitmapShader(const SkBitmap& src, SkShader::TileMode, SkShader
::TileMode, |
79 const SkMatrix* localMatrix, SkTBlitterAllocator*
alloc); | 78 const SkMatrix* localMatrix, SkTBlitterAllocator*
alloc); |
80 | 79 |
81 #endif | 80 #endif |
OLD | NEW |