diff options
author | Brian Osman <brianosman@google.com> | 2017-03-22 10:57:00 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-03-22 16:31:39 +0000 |
commit | de1a60534648ca8a6eb3ae32e06a7a9e9c0591f3 (patch) | |
tree | b198af69715b55724ca5e5f1b746db4fc7c11498 /include/gpu/GrColor.h | |
parent | ca0913ceb9a64d02e6fd6345e71af219f568430e (diff) |
Support premul/unpremul of F16 during read/writePixels
Added PremulOutput and UnpremulOutput FP helpers. These are used
(rather than GrConfigConversionEffect) when working with FP16
textures (and will also be used for other configs that can't be
round-tripped via rounding).
BUG=skia:5853
Change-Id: I101592c26c4f0b379d5e5a8678ef7b2f08e6ad56
Reviewed-on: https://skia-review.googlesource.com/9980
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'include/gpu/GrColor.h')
-rw-r--r-- | include/gpu/GrColor.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/gpu/GrColor.h b/include/gpu/GrColor.h index 64368b9ef9..ad66523bcb 100644 --- a/include/gpu/GrColor.h +++ b/include/gpu/GrColor.h @@ -259,6 +259,15 @@ struct GrColor4f { float a = fRGBA[3]; return GrColor4f(fRGBA[0] * a, fRGBA[1] * a, fRGBA[2] * a, a); } + + GrColor4f unpremul() const { + float a = fRGBA[3]; + if (a <= 0.0f) { + return GrColor4f(0.0f, 0.0f, 0.0f, 0.0f); + } + float invAlpha = 1.0f / a; + return GrColor4f(fRGBA[0] * invAlpha, fRGBA[1] * invAlpha, fRGBA[2] * invAlpha, a); + } }; /** |