| 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 virtual bool isOpaque() const SK_OVERRIDE; |
| 24 virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const SK_OVERR
IDE; | 24 virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const SK_OVERR
IDE; |
| 25 | 25 |
| 26 virtual bool validContext(const ContextRec&, SkMatrix* totalInverse) const S
K_OVERRIDE; | |
| 27 virtual SkShader::Context* createContext(const ContextRec&, void* storage) c
onst SK_OVERRIDE; | |
| 28 virtual size_t contextSize() const SK_OVERRIDE; | 26 virtual size_t contextSize() const SK_OVERRIDE; |
| 29 | 27 |
| 30 static bool CanDo(const SkBitmap&, TileMode tx, TileMode ty); | 28 static bool CanDo(const SkBitmap&, TileMode tx, TileMode ty); |
| 31 | 29 |
| 32 SK_TO_STRING_OVERRIDE() | 30 SK_TO_STRING_OVERRIDE() |
| 33 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader) | 31 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader) |
| 34 | 32 |
| 35 #if SK_SUPPORT_GPU | 33 #if SK_SUPPORT_GPU |
| 36 GrEffectRef* asNewEffect(GrContext*, const SkPaint&) const SK_OVERRIDE; | 34 GrEffectRef* asNewEffect(GrContext*, const SkPaint&) const SK_OVERRIDE; |
| 37 #endif | 35 #endif |
| (...skipping 14 matching lines...) Expand all Loading... |
| 52 private: | 50 private: |
| 53 SkBitmapProcState* fState; | 51 SkBitmapProcState* fState; |
| 54 uint32_t fFlags; | 52 uint32_t fFlags; |
| 55 | 53 |
| 56 typedef SkShader::Context INHERITED; | 54 typedef SkShader::Context INHERITED; |
| 57 }; | 55 }; |
| 58 | 56 |
| 59 protected: | 57 protected: |
| 60 SkBitmapProcShader(SkReadBuffer& ); | 58 SkBitmapProcShader(SkReadBuffer& ); |
| 61 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 59 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 60 virtual Context* onCreateContext(const ContextRec&, void* storage) const SK_
OVERRIDE; |
| 62 | 61 |
| 63 SkBitmap fRawBitmap; // experimental for RLE encoding | 62 SkBitmap fRawBitmap; // experimental for RLE encoding |
| 64 uint8_t fTileModeX, fTileModeY; | 63 uint8_t fTileModeX, fTileModeY; |
| 65 | 64 |
| 66 private: | 65 private: |
| 67 bool validInternal(const ContextRec&, SkMatrix* totalInverse, SkBitmapProcSt
ate*) const; | |
| 68 | |
| 69 typedef SkShader INHERITED; | 66 typedef SkShader INHERITED; |
| 70 }; | 67 }; |
| 71 | 68 |
| 72 // Commonly used allocator. It currently is only used to allocate up to 3 object
s. The total | 69 // Commonly used allocator. It currently is only used to allocate up to 3 object
s. The total |
| 73 // bytes requested is calculated using one of our large shaders, its context siz
e plus the size of | 70 // bytes requested is calculated using one of our large shaders, its context siz
e plus the size of |
| 74 // an Sk3DBlitter in SkDraw.cpp | 71 // an Sk3DBlitter in SkDraw.cpp |
| 75 // Note that some contexts may contain other contexts (e.g. for compose shaders)
, but we've not | 72 // Note that some contexts may contain other contexts (e.g. for compose shaders)
, but we've not |
| 76 // yet found a situation where the size below isn't big enough. | 73 // yet found a situation where the size below isn't big enough. |
| 77 typedef SkSmallAllocator<3, sizeof(SkBitmapProcShader) + | 74 typedef SkSmallAllocator<3, sizeof(SkBitmapProcShader) + |
| 78 sizeof(SkBitmapProcShader::BitmapProcShaderContext)
+ | 75 sizeof(SkBitmapProcShader::BitmapProcShaderContext)
+ |
| 79 sizeof(SkBitmapProcState) + | 76 sizeof(SkBitmapProcState) + |
| 80 sizeof(void*) * 2> SkTBlitterAllocator; | 77 sizeof(void*) * 2> SkTBlitterAllocator; |
| 81 | 78 |
| 82 // If alloc is non-NULL, it will be used to allocate the returned SkShader, and
MUST outlive | 79 // If alloc is non-NULL, it will be used to allocate the returned SkShader, and
MUST outlive |
| 83 // the SkShader. | 80 // the SkShader. |
| 84 SkShader* CreateBitmapShader(const SkBitmap& src, SkShader::TileMode, SkShader::
TileMode, | 81 SkShader* CreateBitmapShader(const SkBitmap& src, SkShader::TileMode, SkShader::
TileMode, |
| 85 const SkMatrix* localMatrix, SkTBlitterAllocator* a
lloc); | 82 const SkMatrix* localMatrix, SkTBlitterAllocator* a
lloc); |
| 86 | 83 |
| 87 #endif | 84 #endif |
| OLD | NEW |