Revert "transform paint color to dst colorspace"

This reverts commit 6eb3621446.

Reason for revert: UBSAN/ASAN failures

Original change's description:
> transform paint color to dst colorspace
> 
> Hopefully I can start to knock off effects that need
> to be converted to dst colorspace one at a time now.
> 
> My rough list is,
>    - paint color               <----
>    - image shader
>    - sprite blitter
>    - gradients?
>    - mode color filter
>    - lighting color filter
>    - high contrast filter
>    - toSRGB color filter
> 
> This change cuts the diffs between 8888 and srgb from
> ~540 to ~500.
> 
> I left myself a note about not being able to interpret null
> to sRGB at a high level yet.  That'd cause a ton of 8888 diffs,
> and I think SkColorSpaceXformCanvas diffs too.
> 
> Change-Id: Id66a63e0e92130927f267719aeccb8bbcd92973a
> Reviewed-on: https://skia-review.googlesource.com/140244
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Mike Klein <mtklein@google.com>

TBR=mtklein@google.com,brianosman@google.com

Change-Id: I31a17b6e70916c463d38488703cfade347c05f2b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/140382
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2018-07-10 20:42:02 +00:00 committed by Skia Commit-Bot
parent 383c9bbf0f
commit 351f4daca4
2 changed files with 4 additions and 31 deletions

View File

@ -90,7 +90,9 @@ void SkRasterPipeline::dump() const {
#endif
void SkRasterPipeline::append_constant_color(SkArenaAlloc* alloc, const float rgba[4]) {
// r,g,b might be outside [0,1], but alpha should probably always be in [0,1].
SkASSERT(0 <= rgba[0] && rgba[0] <= 1);
SkASSERT(0 <= rgba[1] && rgba[1] <= 1);
SkASSERT(0 <= rgba[2] && rgba[2] <= 1);
SkASSERT(0 <= rgba[3] && rgba[3] <= 1);
if (rgba[0] == 0 && rgba[1] == 0 && rgba[2] == 0 && rgba[3] == 1) {
@ -104,10 +106,6 @@ void SkRasterPipeline::append_constant_color(SkArenaAlloc* alloc, const float rg
Sk4f color = Sk4f::Load(rgba);
color.store(&ctx->r);
// TODO: if any channel is out of [0,1], append a float-only stage
// that can handle that, instead of this uniform_color that assumes
// in-range values so it can work in lowp.
// To make loads more direct, we store 8-bit values in 16-bit slots.
color = color * 255.0f + 0.5f;
ctx->rgba[0] = (uint16_t)color[0];

View File

@ -12,7 +12,6 @@
#include "SkColor.h"
#include "SkColorFilter.h"
#include "SkColorSpaceXformer.h"
#include "SkColorSpaceXformSteps.h"
#include "SkOpts.h"
#include "SkPM4f.h"
#include "SkPM4fPriv.h"
@ -86,36 +85,12 @@ private:
typedef SkBlitter INHERITED;
};
static SkPM4f premul_in_dst_colorspace(SkColor color, SkColorSpace* dstCS) {
float rgba[4];
swizzle_rb(SkNx_cast<float>(Sk4b::Load(&color)) * (1/255.0f)).store(rgba);
// SkColors are always sRGB.
auto srcCS = SkColorSpace::MakeSRGB().get();
// If dstCS is null, no color space transformation is needed (and apply() will just premul).
if (!dstCS) { dstCS = srcCS; }
SkColorSpaceXformSteps(srcCS, kUnpremul_SkAlphaType, dstCS)
.apply(rgba);
return {{rgba[0], rgba[1], rgba[2], rgba[3]}};
}
SkBlitter* SkCreateRasterPipelineBlitter(const SkPixmap& dst,
const SkPaint& paint,
const SkMatrix& ctm,
SkArenaAlloc* alloc) {
// For legacy/SkColorSpaceXformCanvas to keep working,
// we need to sometimes still need to distinguish null dstCS from sRGB.
#if 0
SkColorSpace* dstCS = dst.colorSpace() ? dst.colorSpace()
: SkColorSpace::MakeSRGB().get();
#else
SkColorSpace* dstCS = dst.colorSpace();
#endif
SkPM4f paintColor = premul_in_dst_colorspace(paint.getColor(), dstCS);
SkPM4f paintColor = SkPM4f_from_SkColor(paint.getColor(), dstCS);
auto shader = as_SB(paint.getShader());
SkRasterPipeline_<256> shaderPipeline;