msarett | 7411438 | 2015-03-16 11:55:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 7 | #ifndef SkMaskSwizzler_DEFINED |
| 8 | #define SkMaskSwizzler_DEFINED |
msarett | 7411438 | 2015-03-16 11:55:18 -0700 | [diff] [blame] | 9 | |
| 10 | #include "SkMasks.h" |
| 11 | #include "SkSwizzler.h" |
| 12 | #include "SkTypes.h" |
| 13 | |
| 14 | /* |
| 15 | * |
| 16 | * Used to swizzle images whose pixel components are extracted by bit masks |
| 17 | * Currently only used by bmp |
| 18 | * |
| 19 | */ |
| 20 | class SkMaskSwizzler { |
| 21 | public: |
| 22 | |
| 23 | /* |
msarett | 7411438 | 2015-03-16 11:55:18 -0700 | [diff] [blame] | 24 | * Create a new swizzler |
| 25 | * @param masks Unowned pointer to helper class |
msarett | 7411438 | 2015-03-16 11:55:18 -0700 | [diff] [blame] | 26 | */ |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 27 | static SkMaskSwizzler* CreateMaskSwizzler(const SkImageInfo& dstInfo, |
| 28 | const SkImageInfo& srcInfo, |
msarett | 7411438 | 2015-03-16 11:55:18 -0700 | [diff] [blame] | 29 | SkMasks* masks, |
| 30 | uint32_t bitsPerPixel); |
| 31 | |
| 32 | /* |
msarett | 614aa07 | 2015-07-27 15:13:17 -0700 | [diff] [blame] | 33 | * Swizzle a row |
msarett | 7411438 | 2015-03-16 11:55:18 -0700 | [diff] [blame] | 34 | */ |
msarett | 614aa07 | 2015-07-27 15:13:17 -0700 | [diff] [blame] | 35 | SkSwizzler::ResultAlpha swizzle(void* dst, const uint8_t* SK_RESTRICT src); |
msarett | 7411438 | 2015-03-16 11:55:18 -0700 | [diff] [blame] | 36 | |
| 37 | private: |
| 38 | |
| 39 | /* |
msarett | 7411438 | 2015-03-16 11:55:18 -0700 | [diff] [blame] | 40 | * Row procedure used for swizzle |
msarett | 7411438 | 2015-03-16 11:55:18 -0700 | [diff] [blame] | 41 | */ |
| 42 | typedef SkSwizzler::ResultAlpha (*RowProc)( |
| 43 | void* dstRow, const uint8_t* srcRow, int width, |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 44 | SkMasks* masks, uint32_t startX, uint32_t sampleX); |
msarett | 7411438 | 2015-03-16 11:55:18 -0700 | [diff] [blame] | 45 | |
| 46 | /* |
msarett | 7411438 | 2015-03-16 11:55:18 -0700 | [diff] [blame] | 47 | * Constructor for mask swizzler |
msarett | 7411438 | 2015-03-16 11:55:18 -0700 | [diff] [blame] | 48 | */ |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 49 | SkMaskSwizzler(const SkImageInfo& info, SkMasks* masks, RowProc proc, |
| 50 | uint32_t sampleX); |
msarett | 7411438 | 2015-03-16 11:55:18 -0700 | [diff] [blame] | 51 | |
| 52 | // Fields |
msarett | eed039b | 2015-03-18 11:11:19 -0700 | [diff] [blame] | 53 | const SkImageInfo& fDstInfo; |
msarett | eed039b | 2015-03-18 11:11:19 -0700 | [diff] [blame] | 54 | SkMasks* fMasks; // unowned |
msarett | 7411438 | 2015-03-16 11:55:18 -0700 | [diff] [blame] | 55 | const RowProc fRowProc; |
msarett | 5406d6f | 2015-08-31 06:55:13 -0700 | [diff] [blame] | 56 | const uint32_t fSampleX; |
| 57 | const uint32_t fStartX; |
msarett | 7411438 | 2015-03-16 11:55:18 -0700 | [diff] [blame] | 58 | }; |
msarett | 4ab9d5f | 2015-08-06 15:34:42 -0700 | [diff] [blame] | 59 | |
| 60 | #endif |