Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Side by Side Diff: src/core/SkBlitRow_D16.cpp

Issue 847443003: rename blitrow::proc and add (uncalled) hook for colorproc16 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkBlitRow.h ('k') | src/core/SkBlitter_RGB16.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "SkBlitRow.h" 8 #include "SkBlitRow.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkDither.h" 10 #include "SkDither.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 196
197 *dst = SkPackRGB16(dr, dg, db); 197 *dst = SkPackRGB16(dr, dg, db);
198 } 198 }
199 dst += 1; 199 dst += 1;
200 DITHER_INC_X(x); 200 DITHER_INC_X(x);
201 } while (--count != 0); 201 } while (--count != 0);
202 } 202 }
203 } 203 }
204 204
205 /////////////////////////////////////////////////////////////////////////////// 205 ///////////////////////////////////////////////////////////////////////////////
206
207 static uint32_t pmcolor_to_expand16(SkPMColor c) {
208 unsigned r = SkGetPackedR32(c);
209 unsigned g = SkGetPackedG32(c);
210 unsigned b = SkGetPackedB32(c);
211 return (g << 24) | (r << 13) | (b << 2);
212 }
213
214 static void Color32A_D565(uint16_t dst[], SkPMColor src, int count, int x, int y ) {
215 SkASSERT(count > 0);
216 uint32_t src_expand = pmcolor_to_expand16(src);
217 unsigned scale = SkAlpha255To256(0xFF - SkGetPackedA32(src)) >> 3;
218 do {
219 uint32_t dst_expand = SkExpand_rgb_16(*dst) * scale;
220 *dst = SkCompact_rgb_16((src_expand + dst_expand) >> 5);
221 dst += 1;
222 } while (--count != 0);
223 }
224
225 ///////////////////////////////////////////////////////////////////////////////
206 /////////////////////////////////////////////////////////////////////////////// 226 ///////////////////////////////////////////////////////////////////////////////
207 227
208 static const SkBlitRow::Proc gDefault_565_Procs[] = { 228 static const SkBlitRow::Proc16 gDefault_565_Procs[] = {
209 // no dither 229 // no dither
210 S32_D565_Opaque, 230 S32_D565_Opaque,
211 S32_D565_Blend, 231 S32_D565_Blend,
212 232
213 S32A_D565_Opaque, 233 S32A_D565_Opaque,
214 S32A_D565_Blend, 234 S32A_D565_Blend,
215 235
216 // dither 236 // dither
217 S32_D565_Opaque_Dither, 237 S32_D565_Opaque_Dither,
218 S32_D565_Blend_Dither, 238 S32_D565_Blend_Dither,
219 239
220 S32A_D565_Opaque_Dither, 240 S32A_D565_Opaque_Dither,
221 S32A_D565_Blend_Dither 241 S32A_D565_Blend_Dither
222 }; 242 };
223 243
224 SkBlitRow::Proc SkBlitRow::Factory(unsigned flags, SkColorType ct) { 244 SkBlitRow::Proc16 SkBlitRow::Factory16(unsigned flags) {
225 SkASSERT(flags < SK_ARRAY_COUNT(gDefault_565_Procs)); 245 SkASSERT(flags < SK_ARRAY_COUNT(gDefault_565_Procs));
226 // just so we don't crash 246 // just so we don't crash
227 flags &= kFlags16_Mask; 247 flags &= kFlags16_Mask;
228 248
229 SkBlitRow::Proc proc = NULL; 249 SkBlitRow::Proc16 proc = PlatformFactory565(flags);
230 250 if (NULL == proc) {
231 switch (ct) { 251 proc = gDefault_565_Procs[flags];
232 case kRGB_565_SkColorType:
233 proc = PlatformProcs565(flags);
234 if (NULL == proc) {
235 proc = gDefault_565_Procs[flags];
236 }
237 break;
238 default:
239 break;
240 } 252 }
241 return proc; 253 return proc;
242 } 254 }
255
256 static const SkBlitRow::ColorProc16 gDefault_565_ColorProcs[] = {
257 #if 0
258 Color32_D565,
259 Color32A_D565,
260 Color32_D565_Dither,
261 Color32A_D565_Dither
262 #else
263 // TODO: stop cheating and fill in the above specializations!
264 Color32A_D565,
265 Color32A_D565,
266 Color32A_D565,
267 Color32A_D565,
268 #endif
269 };
270
271 SkBlitRow::ColorProc16 SkBlitRow::ColorFactory16(unsigned flags) {
272 SkASSERT((flags & ~kFlags16_Mask) == 0);
273 // just so we don't crash
274 flags &= kFlags16_Mask;
275 // we ignore kGlobalAlpha_Flag, so shift down
276 flags >>= 1;
277
278 SkASSERT(flags < SK_ARRAY_COUNT(gDefault_565_ColorProcs));
279
280 SkBlitRow::ColorProc16 proc = PlatformColorFactory565(flags);
281 if (NULL == proc) {
282 proc = gDefault_565_ColorProcs[flags];
283 }
284 return proc;
285 }
OLDNEW
« no previous file with comments | « include/core/SkBlitRow.h ('k') | src/core/SkBlitter_RGB16.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698