Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b85fc3b

Browse files
Mike KleinSkia Commit-Bot
authored andcommitted
treat opaque dsts as src alpha type
Ignoring for the moment principled reasons to do this, this has the following nice properties: 1) in the absence of a color space transform, all sources are transformed to opaque by dropping their alpha channel (not part of the steps) 2) premul sources are not unpremultiplied unless we need to transform color spaces 3) unpremul sources are never premultiplied This seems like the best generalization of 1) to cases that require a color space transformation. The alternative that we have at head treats opaque as unpremul, so transforming from premul to opaque preserves the abstract color but not the color composed on black. Change-Id: Ic7d7ee24012da3d53378c20f5a4e54fa32405613 Reviewed-on: https://skia-review.googlesource.com/148388 Commit-Queue: Mike Klein <mtklein@google.com> Commit-Queue: Brian Osman <brianosman@google.com> Auto-Submit: Mike Klein <mtklein@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
1 parent 764e546 commit b85fc3b

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/core/SkColorSpaceXformSteps.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212

1313
SkColorSpaceXformSteps::SkColorSpaceXformSteps(SkColorSpace* src, SkAlphaType srcAT,
1414
SkColorSpace* dst, SkAlphaType dstAT) {
15-
// It's mildly interesting to know the output is opaque, but mechanically that's just unpremul.
15+
// Opaque outputs are treated as the same alpha type as the source input.
16+
// TODO: we'd really like to have a good way of explaining why we think this is useful.
1617
if (dstAT == kOpaque_SkAlphaType) {
17-
dstAT = kUnpremul_SkAlphaType;
18+
dstAT = srcAT;
1819
}
1920

2021
// Set all bools to false, all floats to 0.0f.

tests/SkColorSpaceXformStepsTest.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,26 @@ DEF_TEST(SkColorSpaceXformSteps, r) {
107107
{ srgb , srgb22, premul, unpremul, true, true,false, true,false },
108108
{ srgb1, adobe , premul, unpremul, true,false, true, true,false },
109109
{ srgb , adobe , premul, unpremul, true, true, true, true,false },
110+
111+
// Opaque outputs are treated as the same alpha type as the source input.
112+
// TODO: we'd really like to have a good way of explaining why we think this is useful.
113+
{ srgb , srgb , premul, opaque, false,false,false,false,false },
114+
{ srgb , srgb1 , premul, opaque, true, true,false,false, true },
115+
{ srgb1, adobe1, premul, opaque, false,false, true,false,false },
116+
{ srgb , adobe1, premul, opaque, true, true, true,false, true },
117+
{ srgb1, srgb , premul, opaque, true,false,false, true, true },
118+
{ srgb , srgb22, premul, opaque, true, true,false, true, true },
119+
{ srgb1, adobe , premul, opaque, true,false, true, true, true },
120+
{ srgb , adobe , premul, opaque, true, true, true, true, true },
121+
122+
{ srgb , srgb , unpremul, opaque, false,false,false,false,false },
123+
{ srgb , srgb1 , unpremul, opaque, false, true,false,false,false },
124+
{ srgb1, adobe1, unpremul, opaque, false,false, true,false,false },
125+
{ srgb , adobe1, unpremul, opaque, false, true, true,false,false },
126+
{ srgb1, srgb , unpremul, opaque, false,false,false, true,false },
127+
{ srgb , srgb22, unpremul, opaque, false, true,false, true,false },
128+
{ srgb1, adobe , unpremul, opaque, false,false, true, true,false },
129+
{ srgb , adobe , unpremul, opaque, false, true, true, true,false },
110130
};
111131

112132
uint32_t tested = 0x00000000;

0 commit comments

Comments
 (0)