• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2006 The Android Open Source Project
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 SkCoreBlitters_DEFINED
9 #define SkCoreBlitters_DEFINED
10 
11 #include "SkBlitter.h"
12 #include "SkBlitRow.h"
13 
14 class SkRasterBlitter : public SkBlitter {
15 public:
SkRasterBlitter(const SkBitmap & device)16     SkRasterBlitter(const SkBitmap& device) : fDevice(device) {}
17 
18 protected:
19     const SkBitmap& fDevice;
20 
21 private:
22     typedef SkBlitter INHERITED;
23 };
24 
25 class SkShaderBlitter : public SkRasterBlitter {
26 public:
27     SkShaderBlitter(const SkBitmap& device, const SkPaint& paint);
28     virtual ~SkShaderBlitter();
29 
30 protected:
31     uint32_t    fShaderFlags;
32     SkShader*   fShader;
33 
34 private:
35     // illegal
36     SkShaderBlitter& operator=(const SkShaderBlitter&);
37 
38     typedef SkRasterBlitter INHERITED;
39 };
40 
41 ///////////////////////////////////////////////////////////////////////////////
42 
43 class SkA8_Blitter : public SkRasterBlitter {
44 public:
45     SkA8_Blitter(const SkBitmap& device, const SkPaint& paint);
46     virtual void blitH(int x, int y, int width);
47     virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]);
48     virtual void blitV(int x, int y, int height, SkAlpha alpha);
49     virtual void blitRect(int x, int y, int width, int height);
50     virtual void blitMask(const SkMask&, const SkIRect&);
51     virtual const SkBitmap* justAnOpaqueColor(uint32_t*);
52 
53 private:
54     unsigned fSrcA;
55 
56     // illegal
57     SkA8_Blitter& operator=(const SkA8_Blitter&);
58 
59     typedef SkRasterBlitter INHERITED;
60 };
61 
62 class SkA8_Shader_Blitter : public SkShaderBlitter {
63 public:
64     SkA8_Shader_Blitter(const SkBitmap& device, const SkPaint& paint);
65     virtual ~SkA8_Shader_Blitter();
66     virtual void blitH(int x, int y, int width);
67     virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]);
68     virtual void blitMask(const SkMask&, const SkIRect&);
69 
70 private:
71     SkXfermode* fXfermode;
72     SkPMColor*  fBuffer;
73     uint8_t*    fAAExpand;
74 
75     // illegal
76     SkA8_Shader_Blitter& operator=(const SkA8_Shader_Blitter&);
77 
78     typedef SkShaderBlitter INHERITED;
79 };
80 
81 ////////////////////////////////////////////////////////////////
82 
83 class SkARGB32_Blitter : public SkRasterBlitter {
84 public:
85     SkARGB32_Blitter(const SkBitmap& device, const SkPaint& paint);
86     virtual void blitH(int x, int y, int width);
87     virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]);
88     virtual void blitV(int x, int y, int height, SkAlpha alpha);
89     virtual void blitRect(int x, int y, int width, int height);
90     virtual void blitMask(const SkMask&, const SkIRect&);
91     virtual const SkBitmap* justAnOpaqueColor(uint32_t*);
92 
93 protected:
94     SkColor                fColor;
95     SkPMColor              fPMColor;
96     SkBlitRow::ColorProc   fColor32Proc;
97 
98 private:
99     unsigned fSrcA, fSrcR, fSrcG, fSrcB;
100 
101     // illegal
102     SkARGB32_Blitter& operator=(const SkARGB32_Blitter&);
103 
104     typedef SkRasterBlitter INHERITED;
105 };
106 
107 class SkARGB32_Opaque_Blitter : public SkARGB32_Blitter {
108 public:
SkARGB32_Opaque_Blitter(const SkBitmap & device,const SkPaint & paint)109     SkARGB32_Opaque_Blitter(const SkBitmap& device, const SkPaint& paint)
110         : INHERITED(device, paint) { SkASSERT(paint.getAlpha() == 0xFF); }
111     virtual void blitMask(const SkMask&, const SkIRect&);
112 
113 private:
114     typedef SkARGB32_Blitter INHERITED;
115 };
116 
117 class SkARGB32_Black_Blitter : public SkARGB32_Opaque_Blitter {
118 public:
SkARGB32_Black_Blitter(const SkBitmap & device,const SkPaint & paint)119     SkARGB32_Black_Blitter(const SkBitmap& device, const SkPaint& paint)
120         : INHERITED(device, paint) {}
121     virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]);
122 
123 private:
124     typedef SkARGB32_Opaque_Blitter INHERITED;
125 };
126 
127 class SkARGB32_Shader_Blitter : public SkShaderBlitter {
128 public:
129     SkARGB32_Shader_Blitter(const SkBitmap& device, const SkPaint& paint);
130     virtual ~SkARGB32_Shader_Blitter();
131     virtual void blitH(int x, int y, int width);
132     virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]);
133     virtual void blitMask(const SkMask&, const SkIRect&);
134 
135 private:
136     SkXfermode*         fXfermode;
137     SkPMColor*          fBuffer;
138     SkBlitRow::Proc32   fProc32;
139     SkBlitRow::Proc32   fProc32Blend;
140 
141     // illegal
142     SkARGB32_Shader_Blitter& operator=(const SkARGB32_Shader_Blitter&);
143 
144     typedef SkShaderBlitter INHERITED;
145 };
146 
147 ///////////////////////////////////////////////////////////////////////////////
148 
149 class SkA1_Blitter : public SkRasterBlitter {
150 public:
151     SkA1_Blitter(const SkBitmap& device, const SkPaint& paint);
152     virtual void blitH(int x, int y, int width);
153 
154 private:
155     uint8_t fSrcA;
156 
157     // illegal
158     SkA1_Blitter& operator=(const SkA1_Blitter&);
159 
160     typedef SkRasterBlitter INHERITED;
161 };
162 
163 ///////////////////////////////////////////////////////////////////////////////
164 
165 /*  These return the correct subclass of blitter for their device config.
166 
167     Currently, they make the following assumptions about the state of the
168     paint:
169 
170     1. If there is an xfermode, there will also be a shader
171     2. If there is a colorfilter, there will be a shader that itself handles
172        calling the filter, so the blitter can always ignore the colorfilter obj
173 
174     These pre-conditions must be handled by the caller, in our case
175     SkBlitter::Choose(...)
176  */
177 
178 extern SkBlitter* SkBlitter_ChooseD4444(const SkBitmap& device,
179                                         const SkPaint& paint,
180                                         void* storage, size_t storageSize);
181 
182 extern SkBlitter* SkBlitter_ChooseD565(const SkBitmap& device,
183                                        const SkPaint& paint,
184                                        void* storage, size_t storageSize);
185 
186 #endif
187 
188