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

Unified Diff: src/opts/SkColorCubeFilter_opts.h

Issue 1319413003: Move float<->byte conversions into Sk4f. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: ranges 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPMFloat.h ('k') | src/opts/SkNx_neon.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/opts/SkColorCubeFilter_opts.h
diff --git a/src/opts/SkColorCubeFilter_opts.h b/src/opts/SkColorCubeFilter_opts.h
index 41d2525b5a387a8df89bf017f0e22a59eb3bbae6..afd6149cffaf27c003196a49d66c2dc13a684d29 100644
--- a/src/opts/SkColorCubeFilter_opts.h
+++ b/src/opts/SkColorCubeFilter_opts.h
@@ -6,7 +6,7 @@
#define SkColorCubeFilter_opts_DEFINED
#include "SkColor.h"
-#include "SkPMFloat.h"
+#include "SkNx.h"
#include "SkUnPreMultiply.h"
namespace SK_OPTS_NS {
@@ -18,7 +18,6 @@ void color_cube_filter_span(const SkPMColor src[],
const SkScalar* colorToFactors[2],
int dim,
const SkColor* colorCube) {
- uint8_t* ptr_dst = reinterpret_cast<uint8_t*>(dst);
uint8_t r, g, b, a;
for (int i = 0; i < count; ++i) {
@@ -51,8 +50,7 @@ void color_cube_filter_span(const SkPMColor src[],
const int i10 = (colorToIndex[1][g] + colorToIndex[0][b] * dim) * dim;
const int i11 = (colorToIndex[1][g] + colorToIndex[1][b] * dim) * dim;
- SkPMFloat color(0,0,0,0);
-
+ Sk4f color(0,0,0,0);
for (int x = 0; x < 2; ++x) {
const int ix = colorToIndex[x][r];
@@ -61,22 +59,23 @@ void color_cube_filter_span(const SkPMColor src[],
const SkColor lutColor10 = colorCube[ix + i10];
const SkColor lutColor11 = colorCube[ix + i11];
- Sk4f sum = SkPMFloat::FromOpaqueColor(lutColor00) * g0b0;
- sum = sum + SkPMFloat::FromOpaqueColor(lutColor01) * g0b1;
- sum = sum + SkPMFloat::FromOpaqueColor(lutColor10) * g1b0;
- sum = sum + SkPMFloat::FromOpaqueColor(lutColor11) * g1b1;
-
+ Sk4f sum = Sk4f::FromBytes((const uint8_t*)&lutColor00) * g0b0;
+ sum = sum + Sk4f::FromBytes((const uint8_t*)&lutColor01) * g0b1;
+ sum = sum + Sk4f::FromBytes((const uint8_t*)&lutColor10) * g1b0;
+ sum = sum + Sk4f::FromBytes((const uint8_t*)&lutColor11) * g1b1;
color = color + sum * Sk4f((float)colorToFactors[x][r]);
}
-
if (a != 255) {
- color = color * Sk4f(a * 1.0f/255);
+ color = color * Sk4f(a * (1.0f/255));
}
- dst[i] = color.round();
-
Noel Gordon 2015/09/01 04:00:05 round() clamped as well. Dose the new CL clamp?
- ptr_dst[SK_A32_SHIFT / 8] = a;
- ptr_dst += 4;
+ // color is BGRA (SkColor order), dst is SkPMColor order, so may need to swap R+B.
+ #if defined(SK_PMCOLOR_IS_RGBA)
+ color = Sk4f(color.kth<2>(), color.kth<1>(), color.kth<0>(), color.kth<3>());
+ #endif
+ uint8_t* dstBytes = (uint8_t*)(dst+i);
+ color.toBytes(dstBytes);
+ dstBytes[SK_A32_SHIFT/8] = a;
}
}
« no previous file with comments | « src/core/SkPMFloat.h ('k') | src/opts/SkNx_neon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698