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