• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef SkBlitRow_DEFINED
2 #define SkBlitRow_DEFINED
3 
4 #include "SkBitmap.h"
5 #include "SkColor.h"
6 
7 class SkBlitRow {
8 public:
9     enum Flags16 {
10         //! If set, the alpha parameter will be != 255
11         kGlobalAlpha_Flag   = 0x01,
12         //! If set, the src colors may have alpha != 255
13         kSrcPixelAlpha_Flag = 0x02,
14         //! If set, the resulting 16bit colors should be dithered
15         kDither_Flag        = 0x04
16     };
17 
18     /** Function pointer that reads a scanline of src SkPMColors, and writes
19         a corresponding scanline of 16bit colors (specific format based on the
20         config passed to the Factory.
21 
22         The x,y params are useful just for dithering
23 
24         @param alpha A global alpha to be applied to all of the src colors
25         @param x The x coordinate of the beginning of the scanline
26         @param y THe y coordinate of the scanline
27      */
28     typedef void (*Proc)(uint16_t* SK_RESTRICT dst,
29                          const SkPMColor* SK_RESTRICT src,
30                          int count, U8CPU alpha, int x, int y);
31 
32     //! Public entry-point to return a blit function ptr
33     static Proc Factory(unsigned flags, SkBitmap::Config);
34 
35     ///////////// D32 version
36 
37     enum Flags32 {
38         kGlobalAlpha_Flag32     = 1 << 0,
39         kSrcPixelAlpha_Flag32   = 1 << 1,
40     };
41 
42     /** Function pointer that blends 32bit colors onto a 32bit destination.
43         @param dst  array of dst 32bit colors
44         @param src  array of src 32bit colors (w/ or w/o alpha)
45         @param count number of colors to blend
46         @param alpha global alpha to be applied to all src colors
47      */
48     typedef void (*Proc32)(uint32_t* SK_RESTRICT dst,
49                          const SkPMColor* SK_RESTRICT src,
50                          int count, U8CPU alpha);
51 
52     static Proc32 Factory32(unsigned flags32);
53 
54     /** Blend a single color onto a row of S32 pixels, writing the result
55         into a row of D32 pixels. src and dst may be the same memory, but
56         if they are not, they may not overlap.
57      */
58     static void Color32(SkPMColor dst[], const SkPMColor src[], int count,
59                          SkPMColor color);
60 
61     /** Blend a single color onto a row of 32bit pixels, writing the result
62         into the same row.
63      */
Color32(SkPMColor row[],int count,SkPMColor color)64     static void Color32(SkPMColor row[], int count, SkPMColor color) {
65         Color32(row, row, count, color);
66     }
67 
68     /** These static functions are called by the Factory and Factory32
69         functions, and should return either NULL, or a
70         platform-specific function-ptr to be used in place of the
71         system default.
72      */
73 
74     static Proc32 PlatformProcs32(unsigned flags);
75     static Proc PlatformProcs565(unsigned flags);
76     static Proc PlatformProcs4444(unsigned flags);
77 
78 private:
79     enum {
80         kFlags16_Mask = 7,
81         kFlags32_Mask = 3
82     };
83 };
84 
85 #endif
86