send SkPMColor::toPMColor() through Sk4f_toL32()
This doesn't fix that 8888 gradient if we stop clamping, but it seems like a good idea to land first anyway. Change-Id: Ie0feda67da5996223db2fe4458f99d57cf13db71 Reviewed-on: https://skia-review.googlesource.com/155782 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
parent
e0e8393e10
commit
a85838c22e
@ -23,6 +23,27 @@ static inline Sk4f swizzle_rb_if_bgra(const Sk4f& x) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline Sk4f Sk4f_fromL32(uint32_t px) {
|
||||
return SkNx_cast<float>(Sk4b::Load(&px)) * (1/255.0f);
|
||||
}
|
||||
|
||||
static inline uint32_t Sk4f_toL32(const Sk4f& px) {
|
||||
Sk4f v = px;
|
||||
|
||||
#if !defined(SKNX_NO_SIMD) && SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
|
||||
// SkNx_cast<uint8_t, int32_t>() pins, and we don't anticipate giant floats
|
||||
#elif !defined(SKNX_NO_SIMD) && defined(SK_ARM_HAS_NEON)
|
||||
// SkNx_cast<uint8_t, int32_t>() pins, and so does Sk4f_round().
|
||||
#else
|
||||
// No guarantee of a pin.
|
||||
v = Sk4f::Max(0, Sk4f::Min(v, 1));
|
||||
#endif
|
||||
|
||||
uint32_t l32;
|
||||
SkNx_cast<uint8_t>(Sk4f_round(v * 255.0f)).store(&l32);
|
||||
return l32;
|
||||
}
|
||||
|
||||
/*
|
||||
* The float values are 0...1 premultiplied in RGBA order (regardless of SkPMColor order)
|
||||
*/
|
||||
@ -60,10 +81,7 @@ struct SK_API SkPM4f {
|
||||
Sk4f to4f_pmorder() const { return swizzle_rb_if_bgra(this->to4f()); }
|
||||
|
||||
SkPMColor toPMColor() const {
|
||||
Sk4f value = swizzle_rb_if_bgra(this->to4f());
|
||||
SkPMColor result;
|
||||
SkNx_cast<uint8_t>(value * Sk4f(255) + Sk4f(0.5f)).store(&result);
|
||||
return result;
|
||||
return Sk4f_toL32(swizzle_rb_if_bgra(this->to4f()));
|
||||
}
|
||||
|
||||
void toF16(uint16_t[4]) const;
|
||||
|
@ -8,14 +8,9 @@
|
||||
#ifndef SkPM4fPriv_DEFINED
|
||||
#define SkPM4fPriv_DEFINED
|
||||
|
||||
#include "SkColorData.h"
|
||||
#include "SkColorSpace.h"
|
||||
#include "SkColorSpacePriv.h"
|
||||
#include "SkColorSpaceXformSteps.h"
|
||||
#include "SkArenaAlloc.h"
|
||||
#include "SkPM4f.h"
|
||||
#include "SkRasterPipeline.h"
|
||||
#include "../jumper/SkJumper.h"
|
||||
|
||||
// This file is mostly helper routines for doing color space management.
|
||||
// It probably wants a new name, and they likely don't need to be inline.
|
||||
@ -27,27 +22,6 @@
|
||||
// We'll start with the new as-encoded routines first,
|
||||
// and shove all the old broken routines towards the bottom.
|
||||
|
||||
static inline Sk4f Sk4f_fromL32(uint32_t px) {
|
||||
return SkNx_cast<float>(Sk4b::Load(&px)) * (1/255.0f);
|
||||
}
|
||||
|
||||
static inline uint32_t Sk4f_toL32(const Sk4f& px) {
|
||||
Sk4f v = px;
|
||||
|
||||
#if !defined(SKNX_NO_SIMD) && SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
|
||||
// SkNx_cast<uint8_t, int32_t>() pins, and we don't anticipate giant floats
|
||||
#elif !defined(SKNX_NO_SIMD) && defined(SK_ARM_HAS_NEON)
|
||||
// SkNx_cast<uint8_t, int32_t>() pins, and so does Sk4f_round().
|
||||
#else
|
||||
// No guarantee of a pin.
|
||||
v = Sk4f::Max(0, Sk4f::Min(v, 1));
|
||||
#endif
|
||||
|
||||
uint32_t l32;
|
||||
SkNx_cast<uint8_t>(Sk4f_round(v * 255.0f)).store(&l32);
|
||||
return l32;
|
||||
}
|
||||
|
||||
static inline SkPM4f premul_in_dst_colorspace(SkColor4f color4f,
|
||||
SkColorSpace* srcCS, SkColorSpace* dstCS) {
|
||||
// TODO: In the very common case of srcCS being sRGB,
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "SkFloatBits.h"
|
||||
#include "SkHalf.h"
|
||||
#include "SkPM4fPriv.h"
|
||||
#include "SkTemplates.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "SkPatchUtils.h"
|
||||
|
||||
#include "SkArenaAlloc.h"
|
||||
#include "SkColorData.h"
|
||||
#include "SkColorSpacePriv.h"
|
||||
#include "SkGeometry.h"
|
||||
|
Loading…
Reference in New Issue
Block a user