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

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

Issue 2097883002: revise row blits to keep intermediate precision so that color is preserved when blended against its… (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Fix overflow in destination scale calculation Created 4 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 8
9 #include "SkSpriteBlitter.h" 9 #include "SkSpriteBlitter.h"
10 #include "SkBlitRow.h" 10 #include "SkBlitRow.h"
(...skipping 12 matching lines...) Expand all
23 unsigned src_scale) { 23 unsigned src_scale) {
24 uint16_t dc = *dst; 24 uint16_t dc = *dst;
25 unsigned sa = SkGetPackedA32(sc); 25 unsigned sa = SkGetPackedA32(sc);
26 unsigned dr, dg, db; 26 unsigned dr, dg, db;
27 27
28 if (255 == sa) { 28 if (255 == sa) {
29 dr = SkAlphaBlend(SkPacked32ToR16(sc), SkGetPackedR16(dc), src_scale); 29 dr = SkAlphaBlend(SkPacked32ToR16(sc), SkGetPackedR16(dc), src_scale);
30 dg = SkAlphaBlend(SkPacked32ToG16(sc), SkGetPackedG16(dc), src_scale); 30 dg = SkAlphaBlend(SkPacked32ToG16(sc), SkGetPackedG16(dc), src_scale);
31 db = SkAlphaBlend(SkPacked32ToB16(sc), SkGetPackedB16(dc), src_scale); 31 db = SkAlphaBlend(SkPacked32ToB16(sc), SkGetPackedB16(dc), src_scale);
32 } else { 32 } else {
33 unsigned dst_scale = 255 - SkAlphaMul(sa, src_scale); 33 unsigned dst_scale = SkAlphaMulInv256(sa, src_scale);
34 dr = (SkPacked32ToR16(sc) * src_scale + SkGetPackedR16(dc) * dst_scale) >> 8; 34 dr = (SkPacked32ToR16(sc) * src_scale + SkGetPackedR16(dc) * dst_scale) >> 8;
35 dg = (SkPacked32ToG16(sc) * src_scale + SkGetPackedG16(dc) * dst_scale) >> 8; 35 dg = (SkPacked32ToG16(sc) * src_scale + SkGetPackedG16(dc) * dst_scale) >> 8;
36 db = (SkPacked32ToB16(sc) * src_scale + SkGetPackedB16(dc) * dst_scale) >> 8; 36 db = (SkPacked32ToB16(sc) * src_scale + SkGetPackedB16(dc) * dst_scale) >> 8;
37 } 37 }
38 *dst = SkPackRGB16(dr, dg, db); 38 *dst = SkPackRGB16(dr, dg, db);
39 } 39 }
40 40
41 #define D16_S32A_Blend_Pixel(dst, sc, src_scale) \ 41 #define D16_S32A_Blend_Pixel(dst, sc, src_scale) \
42 do { if (sc) D16_S32A_Blend_Pixel_helper(dst, sc, src_scale); } while (0) 42 do { if (sc) D16_S32A_Blend_Pixel_helper(dst, sc, src_scale); } while (0)
43 43
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 } else { 360 } else {
361 blitter = allocator->createT<Sprite_D16_SIndex8A_Blend>(sour ce, alpha); 361 blitter = allocator->createT<Sprite_D16_SIndex8A_Blend>(sour ce, alpha);
362 } 362 }
363 } 363 }
364 break; 364 break;
365 default: 365 default:
366 break; 366 break;
367 } 367 }
368 return blitter; 368 return blitter;
369 } 369 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698