OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkBlitter_DEFINED | 10 #ifndef SkBlitter_DEFINED |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 SkAutoMalloc fBlitMemory; | 113 SkAutoMalloc fBlitMemory; |
114 | 114 |
115 private: | 115 private: |
116 }; | 116 }; |
117 | 117 |
118 /** This blitter silently never draws anything. | 118 /** This blitter silently never draws anything. |
119 */ | 119 */ |
120 class SkNullBlitter : public SkBlitter { | 120 class SkNullBlitter : public SkBlitter { |
121 public: | 121 public: |
122 virtual void blitH(int x, int y, int width) SK_OVERRIDE; | 122 void blitH(int x, int y, int width) SK_OVERRIDE; |
123 virtual void blitAntiH(int x, int y, const SkAlpha[], | 123 virtual void blitAntiH(int x, int y, const SkAlpha[], |
124 const int16_t runs[]) SK_OVERRIDE; | 124 const int16_t runs[]) SK_OVERRIDE; |
125 virtual void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE; | 125 void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE; |
126 virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE; | 126 void blitRect(int x, int y, int width, int height) SK_OVERRIDE; |
127 virtual void blitMask(const SkMask&, const SkIRect& clip) SK_OVERRIDE; | 127 void blitMask(const SkMask&, const SkIRect& clip) SK_OVERRIDE; |
128 virtual const SkBitmap* justAnOpaqueColor(uint32_t* value) SK_OVERRIDE; | 128 const SkBitmap* justAnOpaqueColor(uint32_t* value) SK_OVERRIDE; |
129 virtual bool isNullBlitter() const SK_OVERRIDE; | 129 bool isNullBlitter() const SK_OVERRIDE; |
130 }; | 130 }; |
131 | 131 |
132 /** Wraps another (real) blitter, and ensures that the real blitter is only | 132 /** Wraps another (real) blitter, and ensures that the real blitter is only |
133 called with coordinates that have been clipped by the specified clipRect. | 133 called with coordinates that have been clipped by the specified clipRect. |
134 This means the caller need not perform the clipping ahead of time. | 134 This means the caller need not perform the clipping ahead of time. |
135 */ | 135 */ |
136 class SkRectClipBlitter : public SkBlitter { | 136 class SkRectClipBlitter : public SkBlitter { |
137 public: | 137 public: |
138 void init(SkBlitter* blitter, const SkIRect& clipRect) { | 138 void init(SkBlitter* blitter, const SkIRect& clipRect) { |
139 SkASSERT(!clipRect.isEmpty()); | 139 SkASSERT(!clipRect.isEmpty()); |
140 fBlitter = blitter; | 140 fBlitter = blitter; |
141 fClipRect = clipRect; | 141 fClipRect = clipRect; |
142 } | 142 } |
143 | 143 |
144 virtual void blitH(int x, int y, int width) SK_OVERRIDE; | 144 void blitH(int x, int y, int width) SK_OVERRIDE; |
145 virtual void blitAntiH(int x, int y, const SkAlpha[], | 145 virtual void blitAntiH(int x, int y, const SkAlpha[], |
146 const int16_t runs[]) SK_OVERRIDE; | 146 const int16_t runs[]) SK_OVERRIDE; |
147 virtual void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE; | 147 void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE; |
148 virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE; | 148 void blitRect(int x, int y, int width, int height) SK_OVERRIDE; |
149 virtual void blitAntiRect(int x, int y, int width, int height, | 149 virtual void blitAntiRect(int x, int y, int width, int height, |
150 SkAlpha leftAlpha, SkAlpha rightAlpha) SK_OVERRIDE; | 150 SkAlpha leftAlpha, SkAlpha rightAlpha) SK_OVERRIDE; |
151 virtual void blitMask(const SkMask&, const SkIRect& clip) SK_OVERRIDE; | 151 void blitMask(const SkMask&, const SkIRect& clip) SK_OVERRIDE; |
152 virtual const SkBitmap* justAnOpaqueColor(uint32_t* value) SK_OVERRIDE; | 152 const SkBitmap* justAnOpaqueColor(uint32_t* value) SK_OVERRIDE; |
153 | 153 |
154 virtual int requestRowsPreserved() const SK_OVERRIDE { | 154 int requestRowsPreserved() const SK_OVERRIDE { |
155 return fBlitter->requestRowsPreserved(); | 155 return fBlitter->requestRowsPreserved(); |
156 } | 156 } |
157 | 157 |
158 virtual void* allocBlitMemory(size_t sz) SK_OVERRIDE { | 158 void* allocBlitMemory(size_t sz) SK_OVERRIDE { |
159 return fBlitter->allocBlitMemory(sz); | 159 return fBlitter->allocBlitMemory(sz); |
160 } | 160 } |
161 | 161 |
162 private: | 162 private: |
163 SkBlitter* fBlitter; | 163 SkBlitter* fBlitter; |
164 SkIRect fClipRect; | 164 SkIRect fClipRect; |
165 }; | 165 }; |
166 | 166 |
167 /** Wraps another (real) blitter, and ensures that the real blitter is only | 167 /** Wraps another (real) blitter, and ensures that the real blitter is only |
168 called with coordinates that have been clipped by the specified clipRgn. | 168 called with coordinates that have been clipped by the specified clipRgn. |
169 This means the caller need not perform the clipping ahead of time. | 169 This means the caller need not perform the clipping ahead of time. |
170 */ | 170 */ |
171 class SkRgnClipBlitter : public SkBlitter { | 171 class SkRgnClipBlitter : public SkBlitter { |
172 public: | 172 public: |
173 void init(SkBlitter* blitter, const SkRegion* clipRgn) { | 173 void init(SkBlitter* blitter, const SkRegion* clipRgn) { |
174 SkASSERT(clipRgn && !clipRgn->isEmpty()); | 174 SkASSERT(clipRgn && !clipRgn->isEmpty()); |
175 fBlitter = blitter; | 175 fBlitter = blitter; |
176 fRgn = clipRgn; | 176 fRgn = clipRgn; |
177 } | 177 } |
178 | 178 |
179 virtual void blitH(int x, int y, int width) SK_OVERRIDE; | 179 void blitH(int x, int y, int width) SK_OVERRIDE; |
180 virtual void blitAntiH(int x, int y, const SkAlpha[], | 180 virtual void blitAntiH(int x, int y, const SkAlpha[], |
181 const int16_t runs[]) SK_OVERRIDE; | 181 const int16_t runs[]) SK_OVERRIDE; |
182 virtual void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE; | 182 void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE; |
183 virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE; | 183 void blitRect(int x, int y, int width, int height) SK_OVERRIDE; |
184 virtual void blitAntiRect(int x, int y, int width, int height, | 184 virtual void blitAntiRect(int x, int y, int width, int height, |
185 SkAlpha leftAlpha, SkAlpha rightAlpha) SK_OVERRIDE; | 185 SkAlpha leftAlpha, SkAlpha rightAlpha) SK_OVERRIDE; |
186 virtual void blitMask(const SkMask&, const SkIRect& clip) SK_OVERRIDE; | 186 void blitMask(const SkMask&, const SkIRect& clip) SK_OVERRIDE; |
187 virtual const SkBitmap* justAnOpaqueColor(uint32_t* value) SK_OVERRIDE; | 187 const SkBitmap* justAnOpaqueColor(uint32_t* value) SK_OVERRIDE; |
188 | 188 |
189 virtual int requestRowsPreserved() const SK_OVERRIDE { | 189 int requestRowsPreserved() const SK_OVERRIDE { |
190 return fBlitter->requestRowsPreserved(); | 190 return fBlitter->requestRowsPreserved(); |
191 } | 191 } |
192 | 192 |
193 virtual void* allocBlitMemory(size_t sz) SK_OVERRIDE { | 193 void* allocBlitMemory(size_t sz) SK_OVERRIDE { |
194 return fBlitter->allocBlitMemory(sz); | 194 return fBlitter->allocBlitMemory(sz); |
195 } | 195 } |
196 | 196 |
197 private: | 197 private: |
198 SkBlitter* fBlitter; | 198 SkBlitter* fBlitter; |
199 const SkRegion* fRgn; | 199 const SkRegion* fRgn; |
200 }; | 200 }; |
201 | 201 |
202 /** Factory to set up the appropriate most-efficient wrapper blitter | 202 /** Factory to set up the appropriate most-efficient wrapper blitter |
203 to apply a clip. Returns a pointer to a member, so lifetime must | 203 to apply a clip. Returns a pointer to a member, so lifetime must |
204 be managed carefully. | 204 be managed carefully. |
205 */ | 205 */ |
206 class SkBlitterClipper { | 206 class SkBlitterClipper { |
207 public: | 207 public: |
208 SkBlitter* apply(SkBlitter* blitter, const SkRegion* clip, | 208 SkBlitter* apply(SkBlitter* blitter, const SkRegion* clip, |
209 const SkIRect* bounds = NULL); | 209 const SkIRect* bounds = NULL); |
210 | 210 |
211 private: | 211 private: |
212 SkNullBlitter fNullBlitter; | 212 SkNullBlitter fNullBlitter; |
213 SkRectClipBlitter fRectBlitter; | 213 SkRectClipBlitter fRectBlitter; |
214 SkRgnClipBlitter fRgnBlitter; | 214 SkRgnClipBlitter fRgnBlitter; |
215 }; | 215 }; |
216 | 216 |
217 #endif | 217 #endif |
OLD | NEW |