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 "SkBitmapProcState.h" | 14 #include "SkBitmapProcState.h" |
15 #include "SkSmallAllocator.h" | 15 #include "SkSmallAllocator.h" |
16 | 16 |
17 class SkBitmapProcShader : public SkShader { | 17 class SkBitmapProcShader : public SkShader { |
18 public: | 18 public: |
19 SkBitmapProcShader(const SkBitmap& src, TileMode tx, TileMode ty, | 19 SkBitmapProcShader(const SkBitmap& src, TileMode tx, TileMode ty, |
20 const SkMatrix* localMatrix = NULL); | 20 const SkMatrix* localMatrix = NULL); |
21 | 21 |
22 // overrides from SkShader | 22 // overrides from SkShader |
23 bool isOpaque() const override; | 23 bool isOpaque() const override; |
24 BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const override; | 24 BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const override; |
25 | 25 |
26 size_t contextSize() const override; | 26 size_t contextSize() const override; |
27 | 27 |
28 static bool CanDo(const SkBitmap&, TileMode tx, TileMode ty); | |
29 | |
30 SK_TO_STRING_OVERRIDE() | 28 SK_TO_STRING_OVERRIDE() |
31 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader) | 29 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader) |
32 | 30 |
33 | 31 |
34 bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix& viewM,
const SkMatrix*, | 32 bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix& viewM,
const SkMatrix*, |
35 GrColor*, GrProcessorDataManager*, | 33 GrColor*, GrProcessorDataManager*, |
36 GrFragmentProcessor**) const override; | 34 GrFragmentProcessor**) const override; |
37 | 35 |
38 class BitmapProcShaderContext : public SkShader::Context { | 36 class BitmapProcShaderContext : public SkShader::Context { |
39 public: | 37 public: |
40 // The context takes ownership of the state. It will call its destructor | 38 // The context takes ownership of the state. It will call its destructor |
41 // but will NOT free the memory. | 39 // but will NOT free the memory. |
42 BitmapProcShaderContext(const SkBitmapProcShader&, const ContextRec&, Sk
BitmapProcState*); | 40 BitmapProcShaderContext(const SkBitmapProcShader&, const ContextRec&, Sk
BitmapProcState*); |
43 virtual ~BitmapProcShaderContext(); | 41 ~BitmapProcShaderContext() override; |
44 | 42 |
45 void shadeSpan(int x, int y, SkPMColor dstC[], int count) override; | 43 void shadeSpan(int x, int y, SkPMColor dstC[], int count) override; |
46 ShadeProc asAShadeProc(void** ctx) override; | 44 ShadeProc asAShadeProc(void** ctx) override; |
47 void shadeSpan16(int x, int y, uint16_t dstC[], int count) override; | 45 void shadeSpan16(int x, int y, uint16_t dstC[], int count) override; |
48 | 46 |
49 uint32_t getFlags() const override { return fFlags; } | 47 uint32_t getFlags() const override { return fFlags; } |
50 | 48 |
51 private: | 49 private: |
52 SkBitmapProcState* fState; | 50 SkBitmapProcState* fState; |
53 uint32_t fFlags; | 51 uint32_t fFlags; |
(...skipping 10 matching lines...) Expand all Loading... |
64 | 62 |
65 private: | 63 private: |
66 typedef SkShader INHERITED; | 64 typedef SkShader INHERITED; |
67 }; | 65 }; |
68 | 66 |
69 // Commonly used allocator. It currently is only used to allocate up to 3 object
s. The total | 67 // 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 | 68 // bytes requested is calculated using one of our large shaders, its context siz
e plus the size of |
71 // an Sk3DBlitter in SkDraw.cpp | 69 // an Sk3DBlitter in SkDraw.cpp |
72 // Note that some contexts may contain other contexts (e.g. for compose shaders)
, but we've not | 70 // 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. | 71 // yet found a situation where the size below isn't big enough. |
74 typedef SkSmallAllocator<3, 1024> SkTBlitterAllocator; | 72 typedef SkSmallAllocator<3, 1152> SkTBlitterAllocator; |
75 | 73 |
76 // If alloc is non-NULL, it will be used to allocate the returned SkShader, and
MUST outlive | 74 // If alloc is non-NULL, it will be used to allocate the returned SkShader, and
MUST outlive |
77 // the SkShader. | 75 // the SkShader. |
78 SkShader* SkCreateBitmapShader(const SkBitmap& src, SkShader::TileMode, SkShader
::TileMode, | 76 SkShader* SkCreateBitmapShader(const SkBitmap& src, SkShader::TileMode, SkShader
::TileMode, |
79 const SkMatrix* localMatrix, SkTBlitterAllocator*
alloc); | 77 const SkMatrix* localMatrix, SkTBlitterAllocator*
alloc); |
80 | 78 |
81 #endif | 79 #endif |
OLD | NEW |