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

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

Issue 2163683002: Correct sRGB <-> linear everywhere. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: back to brute 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
« no previous file with comments | « src/core/SkPM4fPriv.h ('k') | src/core/SkXfermode4f.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 2016 Google Inc. 2 * Copyright 2016 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 "SkColorFilter.h" 8 #include "SkColorFilter.h"
9 #include "SkHalf.h" 9 #include "SkHalf.h"
10 #include "SkNx.h" 10 #include "SkNx.h"
11 #include "SkPaint.h" 11 #include "SkPaint.h"
12 #include "SkPixmap.h" 12 #include "SkPixmap.h"
13 #include "SkPM4f.h" 13 #include "SkPM4f.h"
14 #include "SkPM4fPriv.h" 14 #include "SkPM4fPriv.h"
15 #include "SkSpanProcs.h" 15 #include "SkSpanProcs.h"
16 16
17 //////////////////////////////////////////////////////////////////////////////// /////////////////// 17 //////////////////////////////////////////////////////////////////////////////// ///////////////////
18 18
19 static void load_l32(const SkPixmap& src, int x, int y, SkPM4f span[], int count ) { 19 static void load_l32(const SkPixmap& src, int x, int y, SkPM4f span[], int count ) {
20 SkASSERT(count > 0); 20 SkASSERT(count > 0);
21 const uint32_t* addr = src.addr32(x, y); 21 const uint32_t* addr = src.addr32(x, y);
22 SkASSERT(src.addr32(x + count - 1, y)); 22 SkASSERT(src.addr32(x + count - 1, y));
23 23
24 for (int i = 0; i < count; ++i) { 24 for (int i = 0; i < count; ++i) {
25 (to_4f_rgba(addr[i]) * Sk4f(1.0f/255)).store(span[i].fVec); 25 swizzle_rb_if_bgra(Sk4f_fromL32(addr[i])).store(span[i].fVec);
26 } 26 }
27 } 27 }
28 28
29 static void load_s32(const SkPixmap& src, int x, int y, SkPM4f span[], int count ) { 29 static void load_s32(const SkPixmap& src, int x, int y, SkPM4f span[], int count ) {
30 SkASSERT(count > 0); 30 SkASSERT(count > 0);
31 const uint32_t* addr = src.addr32(x, y); 31 const uint32_t* addr = src.addr32(x, y);
32 SkASSERT(src.addr32(x + count - 1, y)); 32 SkASSERT(src.addr32(x + count - 1, y));
33 33
34 for (int i = 0; i < count; ++i) { 34 for (int i = 0; i < count; ++i) {
35 srgb_to_linear(to_4f_rgba(addr[i]) * Sk4f(1.0f/255)).store(span[i].fVec) ; 35 swizzle_rb_if_bgra(Sk4f_fromS32(addr[i])).store(span[i].fVec);
36 } 36 }
37 } 37 }
38 38
39 static void load_f16(const SkPixmap& src, int x, int y, SkPM4f span[], int count ) { 39 static void load_f16(const SkPixmap& src, int x, int y, SkPM4f span[], int count ) {
40 SkASSERT(count > 0); 40 SkASSERT(count > 0);
41 const uint64_t* addr = src.addr64(x, y); 41 const uint64_t* addr = src.addr64(x, y);
42 SkASSERT(src.addr64(x + count - 1, y)); 42 SkASSERT(src.addr64(x + count - 1, y));
43 43
44 for (int i = 0; i < count; ++i) { 44 for (int i = 0; i < count; ++i) {
45 SkHalfToFloat_finite(addr[i]).store(span[i].fVec); 45 SkHalfToFloat_finite(addr[i]).store(span[i].fVec);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 paint.getColorFilter()->filterSpan4f(span, count, span); 86 paint.getColorFilter()->filterSpan4f(span, count, span);
87 } 87 }
88 88
89 SkFilterSpanProc SkFilterSpanProc_Choose(const SkPaint& paint) { 89 SkFilterSpanProc SkFilterSpanProc_Choose(const SkPaint& paint) {
90 if (paint.getColorFilter()) { 90 if (paint.getColorFilter()) {
91 return 0xFF == paint.getAlpha() ? colorfilter_filterspan : colorfilter_a lpha_filterspan; 91 return 0xFF == paint.getAlpha() ? colorfilter_filterspan : colorfilter_a lpha_filterspan;
92 } else { 92 } else {
93 return 0xFF == paint.getAlpha() ? noop_filterspan : alpha_filterspan; 93 return 0xFF == paint.getAlpha() ? noop_filterspan : alpha_filterspan;
94 } 94 }
95 } 95 }
OLDNEW
« no previous file with comments | « src/core/SkPM4fPriv.h ('k') | src/core/SkXfermode4f.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698