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

Side by Side Diff: src/opts/SkColorCubeFilter_opts.h

Issue 1295873004: SkColorCubeFilter: require alpha == 0xFF. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: just perf Created 5 years, 4 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SkColorCubeFilter_opts_DEFINED 5 #ifndef SkColorCubeFilter_opts_DEFINED
6 #define SkColorCubeFilter_opts_DEFINED 6 #define SkColorCubeFilter_opts_DEFINED
7 7
8 #include "SkColor.h" 8 #include "SkColor.h"
9 #include "SkPMFloat.h" 9 #include "SkPMFloat.h"
10 #include "SkUnPreMultiply.h" 10 #include "SkUnPreMultiply.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 g1b0(g1*b0), 46 g1b0(g1*b0),
47 g1b1(g1*b1); 47 g1b1(g1*b1);
48 48
49 const int i00 = (colorToIndex[0][g] + colorToIndex[0][b] * dim) * dim; 49 const int i00 = (colorToIndex[0][g] + colorToIndex[0][b] * dim) * dim;
50 const int i01 = (colorToIndex[0][g] + colorToIndex[1][b] * dim) * dim; 50 const int i01 = (colorToIndex[0][g] + colorToIndex[1][b] * dim) * dim;
51 const int i10 = (colorToIndex[1][g] + colorToIndex[0][b] * dim) * dim; 51 const int i10 = (colorToIndex[1][g] + colorToIndex[0][b] * dim) * dim;
52 const int i11 = (colorToIndex[1][g] + colorToIndex[1][b] * dim) * dim; 52 const int i11 = (colorToIndex[1][g] + colorToIndex[1][b] * dim) * dim;
53 53
54 SkPMFloat color(0); 54 SkPMFloat color(0);
55 55
56 for (int x = 0; x < 2; ++x) { 56 for (int x = 0; x < 2; ++x) {
Noel Gordon 2015/08/20 07:10:07 Possible followup: unroll this loop. Mac air goes
57 const int ix = colorToIndex[x][r]; 57 const int ix = colorToIndex[x][r];
58 58
59 const SkColor lutColor00 = colorCube[ix + i00]; 59 const SkColor lutColor00 = colorCube[ix + i00];
60 const SkColor lutColor01 = colorCube[ix + i01]; 60 const SkColor lutColor01 = colorCube[ix + i01];
61 const SkColor lutColor10 = colorCube[ix + i10]; 61 const SkColor lutColor10 = colorCube[ix + i10];
62 const SkColor lutColor11 = colorCube[ix + i11]; 62 const SkColor lutColor11 = colorCube[ix + i11];
63 63
64 Sk4f sum = SkPMFloat::FromBGRx(lutColor00) * g0b0; 64 Sk4f sum = SkPMFloat::FromOpaqueColor(lutColor00) * g0b0;
65 sum = sum + SkPMFloat::FromBGRx(lutColor01) * g0b1; 65 sum = sum + SkPMFloat::FromOpaqueColor(lutColor01) * g0b1;
66 sum = sum + SkPMFloat::FromBGRx(lutColor10) * g1b0; 66 sum = sum + SkPMFloat::FromOpaqueColor(lutColor10) * g1b0;
67 sum = sum + SkPMFloat::FromBGRx(lutColor11) * g1b1; 67 sum = sum + SkPMFloat::FromOpaqueColor(lutColor11) * g1b1;
68 68
69 color = color + sum * Sk4f((float)colorToFactors[x][r]); 69 color = color + sum * Sk4f((float)colorToFactors[x][r]);
70 } 70 }
71 71
72 if (a != 255) { 72 if (a != 255) {
73 color = color * Sk4f(a * 1.0f/255); 73 color = color * Sk4f(a * 1.0f/255);
74 } 74 }
75 75
76 dst[i] = color.round(); 76 dst[i] = color.round();
77 77
78 ptr_dst[SK_A32_SHIFT / 8] = a; 78 ptr_dst[SK_A32_SHIFT / 8] = a;
79 ptr_dst += 4; 79 ptr_dst += 4;
80 } 80 }
81 } 81 }
82 82
83 } // namespace SK_OPTS NS 83 } // namespace SK_OPTS NS
84 84
85 #endif // SkColorCubeFilter_opts_DEFINED 85 #endif // SkColorCubeFilter_opts_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698