| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 | 7 |
| 8 #ifndef SkBlitRow_DEFINED | 8 #ifndef SkBlitRow_DEFINED |
| 9 #define SkBlitRow_DEFINED | 9 #define SkBlitRow_DEFINED |
| 10 | 10 |
| 11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
| 12 #include "SkColor.h" | 12 #include "SkColor.h" |
| 13 | 13 |
| 14 class SkBlitRow { | 14 class SkBlitRow { |
| 15 public: | 15 public: |
| 16 enum Flags16 { | 16 enum Flags16 { |
| 17 //! If set, the alpha parameter will be != 255 | 17 //! If set, the alpha parameter will be != 255 |
| 18 kGlobalAlpha_Flag = 0x01, | 18 kGlobalAlpha_Flag = 0x01, |
| 19 //! If set, the src colors may have alpha != 255 | 19 //! If set, the src colors may have alpha != 255 |
| 20 kSrcPixelAlpha_Flag = 0x02, | 20 kSrcPixelAlpha_Flag = 0x02, |
| 21 //! If set, the resulting 16bit colors should be dithered | 21 //! If set, the resulting 16bit colors should be dithered |
| 22 kDither_Flag = 0x04 | 22 kDither_Flag = 0x04 |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 /** Function pointer that reads a scanline of src SkPMColors, and writes | 25 /** Function pointer that reads a scanline of src SkPMColors, and writes |
| 26 a corresponding scanline of 16bit colors (specific format based on the | 26 a corresponding scanline of 16bit colors (specific format based on the |
| 27 config passed to the Factory. | 27 config passed to the Factory. |
| 28 | 28 |
| 29 The x,y params are useful just for dithering | 29 The x,y params provide the dithering phase for the start of the scanline |
| 30 | 30 |
| 31 @param alpha A global alpha to be applied to all of the src colors | 31 @param alpha A global alpha to be applied to all of the src colors |
| 32 @param x The x coordinate of the beginning of the scanline | 32 @param x The x coordinate of the beginning of the scanline |
| 33 @param y THe y coordinate of the scanline | 33 @param y THe y coordinate of the scanline |
| 34 */ | 34 */ |
| 35 typedef void (*Proc)(uint16_t* dst, | 35 typedef void (*Proc16)(uint16_t dst[], const SkPMColor src[], int count, |
| 36 const SkPMColor* src, | 36 U8CPU alpha, int x, int y); |
| 37 int count, U8CPU alpha, int x, int y); | |
| 38 | 37 |
| 39 static Proc Factory(unsigned flags, SkColorType); | 38 static Proc16 Factory16(unsigned flags); |
| 39 |
| 40 /** |
| 41 * Function pointer that blends a single src color onto a scaline of dst co
lors. |
| 42 * |
| 43 * The x,y params provide the dithering phase for the start of the scanline |
| 44 */ |
| 45 typedef void (*ColorProc16)(uint16_t dst[], SkPMColor src, int count, int x,
int y); |
| 46 |
| 47 // Note : we ignore the kGlobalAlpha_Flag setting, but do respect kSrcPixelA
lpha_Flag |
| 48 static ColorProc16 ColorFactory16(unsigned flags); |
| 40 | 49 |
| 41 ///////////// D32 version | 50 ///////////// D32 version |
| 42 | 51 |
| 43 enum Flags32 { | 52 enum Flags32 { |
| 44 kGlobalAlpha_Flag32 = 1 << 0, | 53 kGlobalAlpha_Flag32 = 1 << 0, |
| 45 kSrcPixelAlpha_Flag32 = 1 << 1 | 54 kSrcPixelAlpha_Flag32 = 1 << 1 |
| 46 }; | 55 }; |
| 47 | 56 |
| 48 /** Function pointer that blends 32bit colors onto a 32bit destination. | 57 /** Function pointer that blends 32bit colors onto a 32bit destination. |
| 49 @param dst array of dst 32bit colors | 58 @param dst array of dst 32bit colors |
| 50 @param src array of src 32bit colors (w/ or w/o alpha) | 59 @param src array of src 32bit colors (w/ or w/o alpha) |
| 51 @param count number of colors to blend | 60 @param count number of colors to blend |
| 52 @param alpha global alpha to be applied to all src colors | 61 @param alpha global alpha to be applied to all src colors |
| 53 */ | 62 */ |
| 54 typedef void (*Proc32)(uint32_t* dst, | 63 typedef void (*Proc32)(uint32_t dst[], const SkPMColor src[], int count, U8C
PU alpha); |
| 55 const SkPMColor* src, | |
| 56 int count, U8CPU alpha); | |
| 57 | 64 |
| 58 static Proc32 Factory32(unsigned flags32); | 65 static Proc32 Factory32(unsigned flags32); |
| 59 | 66 |
| 60 /** Function pointer that blends a single color with a row of 32-bit colors | 67 /** Function pointer that blends a single color with a row of 32-bit colors |
| 61 onto a 32-bit destination | 68 onto a 32-bit destination |
| 62 */ | 69 */ |
| 63 typedef void (*ColorProc)(SkPMColor* dst, const SkPMColor* src, int count, | 70 typedef void (*ColorProc)(SkPMColor dst[], const SkPMColor src[], int count,
SkPMColor color); |
| 64 SkPMColor color); | |
| 65 | 71 |
| 66 /** Blend a single color onto a row of S32 pixels, writing the result | 72 /** Blend a single color onto a row of S32 pixels, writing the result |
| 67 into a row of D32 pixels. src and dst may be the same memory, but | 73 into a row of D32 pixels. src and dst may be the same memory, but |
| 68 if they are not, they may not overlap. | 74 if they are not, they may not overlap. |
| 69 */ | 75 */ |
| 70 static void Color32(SkPMColor dst[], const SkPMColor src[], | 76 static void Color32(SkPMColor dst[], const SkPMColor src[], int count, SkPMC
olor color); |
| 71 int count, SkPMColor color); | |
| 72 | 77 |
| 73 //! Public entry-point to return a blit function ptr | 78 //! Public entry-point to return a blit function ptr |
| 74 static ColorProc ColorProcFactory(); | 79 static ColorProc ColorProcFactory(); |
| 75 | 80 |
| 76 /** Function pointer that blends a single color onto a 32-bit rectangle. */ | 81 /** Function pointer that blends a single color onto a 32-bit rectangle. */ |
| 77 typedef void (*ColorRectProc)(SkPMColor* dst, int width, int height, | 82 typedef void (*ColorRectProc)(SkPMColor dst[], int width, int height, |
| 78 size_t rowBytes, SkPMColor color); | 83 size_t rowBytes, SkPMColor color); |
| 79 | 84 |
| 80 /** Blend a single color into a rectangle of D32 pixels. */ | 85 /** Blend a single color into a rectangle of D32 pixels. */ |
| 81 static void ColorRect32(SkPMColor* dst, int width, int height, | 86 static void ColorRect32(SkPMColor dst[], int width, int height, |
| 82 size_t rowBytes, SkPMColor color); | 87 size_t rowBytes, SkPMColor color); |
| 83 | 88 |
| 84 //! Public entry-point to return a blit function ptr | 89 //! Public entry-point to return a blit function ptr |
| 85 static ColorRectProc ColorRectProcFactory(); | 90 static ColorRectProc ColorRectProcFactory(); |
| 86 | 91 |
| 87 /** These static functions are called by the Factory and Factory32 | 92 /** These static functions are called by the Factory and Factory32 |
| 88 functions, and should return either NULL, or a | 93 functions, and should return either NULL, or a |
| 89 platform-specific function-ptr to be used in place of the | 94 platform-specific function-ptr to be used in place of the |
| 90 system default. | 95 system default. |
| 91 */ | 96 */ |
| 92 | 97 |
| 93 static Proc32 PlatformProcs32(unsigned flags); | 98 static Proc32 PlatformProcs32(unsigned flags); |
| 94 static Proc PlatformProcs565(unsigned flags); | |
| 95 static ColorProc PlatformColorProc(); | 99 static ColorProc PlatformColorProc(); |
| 96 | 100 |
| 101 static Proc16 PlatformFactory565(unsigned flags); |
| 102 static ColorProc16 PlatformColorFactory565(unsigned flags); |
| 103 |
| 97 private: | 104 private: |
| 98 enum { | 105 enum { |
| 99 kFlags16_Mask = 7, | 106 kFlags16_Mask = 7, |
| 100 kFlags32_Mask = 3 | 107 kFlags32_Mask = 3 |
| 101 }; | 108 }; |
| 102 }; | 109 }; |
| 103 | 110 |
| 104 #endif | 111 #endif |
| OLD | NEW |