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 virtual bool isOpaque() const SK_OVERRIDE; | 23 bool isOpaque() const SK_OVERRIDE; |
24 virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const SK_OVERR
IDE; | 24 BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const SK_OVERRIDE; |
25 | 25 |
26 virtual size_t contextSize() const SK_OVERRIDE; | 26 size_t contextSize() const SK_OVERRIDE; |
27 | 27 |
28 static bool CanDo(const SkBitmap&, TileMode tx, TileMode ty); | 28 static bool CanDo(const SkBitmap&, TileMode tx, TileMode ty); |
29 | 29 |
30 SK_TO_STRING_OVERRIDE() | 30 SK_TO_STRING_OVERRIDE() |
31 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader) | 31 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader) |
32 | 32 |
33 | 33 |
34 bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix& viewM,
const SkMatrix*, | 34 bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix& viewM,
const SkMatrix*, |
35 GrColor*, GrFragmentProcessor**) const SK_OVERRIDE; | 35 GrColor*, GrFragmentProcessor**) const SK_OVERRIDE; |
36 | 36 |
37 class BitmapProcShaderContext : public SkShader::Context { | 37 class BitmapProcShaderContext : public SkShader::Context { |
38 public: | 38 public: |
39 // The context takes ownership of the state. It will call its destructor | 39 // The context takes ownership of the state. It will call its destructor |
40 // but will NOT free the memory. | 40 // but will NOT free the memory. |
41 BitmapProcShaderContext(const SkBitmapProcShader&, const ContextRec&, Sk
BitmapProcState*); | 41 BitmapProcShaderContext(const SkBitmapProcShader&, const ContextRec&, Sk
BitmapProcState*); |
42 virtual ~BitmapProcShaderContext(); | 42 virtual ~BitmapProcShaderContext(); |
43 | 43 |
44 virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVE
RRIDE; | 44 void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVERRIDE; |
45 virtual ShadeProc asAShadeProc(void** ctx) SK_OVERRIDE; | 45 ShadeProc asAShadeProc(void** ctx) SK_OVERRIDE; |
46 virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count) SK_OV
ERRIDE; | 46 void shadeSpan16(int x, int y, uint16_t dstC[], int count) SK_OVERRIDE; |
47 | 47 |
48 virtual uint32_t getFlags() const SK_OVERRIDE { return fFlags; } | 48 uint32_t getFlags() const SK_OVERRIDE { return fFlags; } |
49 | 49 |
50 private: | 50 private: |
51 SkBitmapProcState* fState; | 51 SkBitmapProcState* fState; |
52 uint32_t fFlags; | 52 uint32_t fFlags; |
53 | 53 |
54 typedef SkShader::Context INHERITED; | 54 typedef SkShader::Context INHERITED; |
55 }; | 55 }; |
56 | 56 |
57 protected: | 57 protected: |
58 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 58 void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
59 virtual Context* onCreateContext(const ContextRec&, void* storage) const SK_
OVERRIDE; | 59 Context* onCreateContext(const ContextRec&, void* storage) const SK_OVERRIDE
; |
60 | 60 |
61 SkBitmap fRawBitmap; // experimental for RLE encoding | 61 SkBitmap fRawBitmap; // experimental for RLE encoding |
62 uint8_t fTileModeX, fTileModeY; | 62 uint8_t fTileModeX, fTileModeY; |
63 | 63 |
64 private: | 64 private: |
65 typedef SkShader INHERITED; | 65 typedef SkShader INHERITED; |
66 }; | 66 }; |
67 | 67 |
68 // 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 |
69 // 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 |
70 // an Sk3DBlitter in SkDraw.cpp | 70 // an Sk3DBlitter in SkDraw.cpp |
71 // 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 |
72 // 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. |
73 typedef SkSmallAllocator<3, 1024> SkTBlitterAllocator; | 73 typedef SkSmallAllocator<3, 1024> SkTBlitterAllocator; |
74 | 74 |
75 // If alloc is non-NULL, it will be used to allocate the returned SkShader, and
MUST outlive | 75 // If alloc is non-NULL, it will be used to allocate the returned SkShader, and
MUST outlive |
76 // the SkShader. | 76 // the SkShader. |
77 SkShader* SkCreateBitmapShader(const SkBitmap& src, SkShader::TileMode, SkShader
::TileMode, | 77 SkShader* SkCreateBitmapShader(const SkBitmap& src, SkShader::TileMode, SkShader
::TileMode, |
78 const SkMatrix* localMatrix, SkTBlitterAllocator*
alloc); | 78 const SkMatrix* localMatrix, SkTBlitterAllocator*
alloc); |
79 | 79 |
80 #endif | 80 #endif |
OLD | NEW |