| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 #ifndef SkMaskSwizzler_DEFINED | 7 #ifndef SkMaskSwizzler_DEFINED |
| 8 #define SkMaskSwizzler_DEFINED | 8 #define SkMaskSwizzler_DEFINED |
| 9 | 9 |
| 10 #include "SkMasks.h" | 10 #include "SkMasks.h" |
| 11 #include "SkSampler.h" |
| 11 #include "SkSwizzler.h" | 12 #include "SkSwizzler.h" |
| 12 #include "SkTypes.h" | 13 #include "SkTypes.h" |
| 13 | 14 |
| 14 /* | 15 /* |
| 15 * | 16 * |
| 16 * Used to swizzle images whose pixel components are extracted by bit masks | 17 * Used to swizzle images whose pixel components are extracted by bit masks |
| 17 * Currently only used by bmp | 18 * Currently only used by bmp |
| 18 * | 19 * |
| 19 */ | 20 */ |
| 20 class SkMaskSwizzler { | 21 class SkMaskSwizzler : public SkSampler { |
| 21 public: | 22 public: |
| 22 | 23 |
| 23 /* | 24 /* |
| 24 * Create a new swizzler | 25 * Create a new swizzler |
| 25 * @param masks Unowned pointer to helper class | 26 * @param masks Unowned pointer to helper class |
| 26 */ | 27 */ |
| 27 static SkMaskSwizzler* CreateMaskSwizzler(const SkImageInfo& dstInfo, | 28 static SkMaskSwizzler* CreateMaskSwizzler(const SkImageInfo& dstInfo, |
| 28 const SkImageInfo& srcInfo, | 29 const SkImageInfo& srcInfo, |
| 29 SkMasks* masks, | 30 SkMasks* masks, |
| 30 uint32_t bitsPerPixel); | 31 uint32_t bitsPerPixel); |
| 31 | 32 |
| 32 /* | 33 /* |
| 33 * Swizzle a row | 34 * Swizzle a row |
| 34 */ | 35 */ |
| 35 SkSwizzler::ResultAlpha swizzle(void* dst, const uint8_t* SK_RESTRICT src); | 36 SkSwizzler::ResultAlpha swizzle(void* dst, const uint8_t* SK_RESTRICT src); |
| 36 | 37 |
| 37 private: | 38 private: |
| 38 | 39 |
| 39 /* | 40 /* |
| 40 * Row procedure used for swizzle | 41 * Row procedure used for swizzle |
| 41 */ | 42 */ |
| 42 typedef SkSwizzler::ResultAlpha (*RowProc)( | 43 typedef SkSwizzler::ResultAlpha (*RowProc)( |
| 43 void* dstRow, const uint8_t* srcRow, int width, | 44 void* dstRow, const uint8_t* srcRow, int width, |
| 44 SkMasks* masks, uint32_t startX, uint32_t sampleX); | 45 SkMasks* masks, uint32_t startX, uint32_t sampleX); |
| 45 | 46 |
| 46 /* | 47 /* |
| 47 * Constructor for mask swizzler | 48 * Constructor for mask swizzler |
| 48 */ | 49 */ |
| 49 SkMaskSwizzler(const SkImageInfo& info, SkMasks* masks, RowProc proc, | 50 SkMaskSwizzler(int width, SkMasks* masks, RowProc proc); |
| 50 uint32_t sampleX); | |
| 51 | 51 |
| 52 // Fields | 52 int onSetSampleX(int) override; |
| 53 const SkImageInfo& fDstInfo; | 53 |
| 54 SkMasks* fMasks; // unowned | 54 SkMasks* fMasks; // unowned |
| 55 const RowProc fRowProc; | 55 const RowProc fRowProc; |
| 56 const uint32_t fSampleX; | 56 |
| 57 const uint32_t fStartX; | 57 // FIXME: Can this class share more with SkSwizzler? These variables are all
the same. |
| 58 const int fSrcWidth; // Width of the source - i.e. before any s
ampling. |
| 59 int fDstWidth; // Width of dst, which may differ with sam
pling. |
| 60 int fSampleX; |
| 61 int fX0; |
| 58 }; | 62 }; |
| 59 | 63 |
| 60 #endif | 64 #endif |
| OLD | NEW |