aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrColorSpaceXform.cpp
Commit message (Collapse)AuthorAge
* add explicit accessor for sRGB singleton colorspacesGravatar Mike Klein2018-07-25
| | | | | | | | | | | | | | SkColorSpace::MakeSRGB().get() is scary, and causes more ref/unref pairs than strictly necessary for these singletons. This time the implementation is still in SkColorSpace.cpp, so these should really work as singletons. Change-Id: I40f2942c8dcde3040663a04c4f5330aca90868ae Reviewed-on: https://skia-review.googlesource.com/143305 Auto-Submit: Mike Klein <mtklein@chromium.org> Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
* Implement nonlinear (as-encoded) blending in GrColorSpaceXformGravatar Brian Osman2018-06-18
| | | | | | | | | | | | | | | | | | Make GrColorSpaceXform a wrapper over SkColorSpaceXformSteps, and removed the xform cache. The shader code does up to five steps to correctly transform (unpremul, linearize, gamut, encode, premul). Remove all clamping, so we can support sRGB encoded F16. Most of https://skia-review.googlesource.com/c/skia/+/132090, except that GrNonlinearColorSpaceXformEffect is still used for SkColorSpaceXformCanvas and a few other places. As a result, this doesn't trigger any layout test failures. Change-Id: I789a5e327a419b5f7634c00d1b355912046c07b7 Reviewed-on: https://skia-review.googlesource.com/135326 Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
* Simplify usage of GrGLSLColorSpaceXformHelperGravatar Brian Osman2018-06-15
| | | | | | | | | | | | | | | | It was already safe to call setData without (redundantly) checking isValid, so remove those. Made the emitCode helpers safe, too, so that we only need to check for isValid in one spot. Then, because it made more sense, invert the logic and rename it to isNoop(). Pulled out of https://skia-review.googlesource.com/c/skia/+/132090 Bug: skia: Change-Id: I147fa2e0a06c04024c6aa98725fa73501044e4cd Reviewed-on: https://skia-review.googlesource.com/134948 Commit-Queue: Mike Klein <mtklein@google.com> Auto-Submit: Brian Osman <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
* Remove GrPixelConfig argument to GrColorSpaceXform[Effect]::MakeGravatar Brian Osman2018-06-14
| | | | | | | | | | | This was for sRGB configs, which are no longer treated special. Pulling this out of https://skia-review.googlesource.com/c/skia/+/132090 to land separately. Change-Id: Id04c4e82ad4ffe375cfd384490839b0488e54d44 Reviewed-on: https://skia-review.googlesource.com/134843 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
* Remove const from (immutable) SkColorSpace args to some functionsGravatar Brian Osman2018-06-14
| | | | | | | | | | | | Another piece of https://skia-review.googlesource.com/c/skia/+/132090 that I'd like to land separately. Change-Id: I64d8968cf7e0fb0d288eca71c79d361410c924b8 Reviewed-on: https://skia-review.googlesource.com/134782 Commit-Queue: Brian Osman <brianosman@google.com> Commit-Queue: Mike Klein <mtklein@google.com> Auto-Submit: Brian Osman <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
* Fix a logical test in GrColorSpaceXform::EqualsGravatar Brian Osman2018-03-09
| | | | | | | Change-Id: I2408278355cdd5a8a65748b5dd313b9466aee2b1 Reviewed-on: https://skia-review.googlesource.com/113211 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
* remove SkColorSpace_BaseGravatar Mike Klein2018-01-26
| | | | | | | | | | | | The type SkColorSpace_Base doesn't need to exist. Its one type() query can be answered instead by toXYZD50(). Now all that's left in the file is SkGammas, so rename it to SkGammas.h. Change-Id: Id60ddbfb342accfd5674ae89b37a24a6583ef7b8 Reviewed-on: https://skia-review.googlesource.com/99702 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Push much of the SkColorSpace_Base interface up to SkColorSpaceGravatar Brian Osman2017-12-12
| | | | | | | | | | | Some pieces still remain, but the next step looks less mechanical, so I wanted to land this piece independently. Bug: skia: Change-Id: Ie63afcfa08af2f6e4996911fa2225c43441dbfb2 Reviewed-on: https://skia-review.googlesource.com/84120 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Brian Osman <brianosman@google.com>
* Add support for transfer functions to GrColorSpaceXformGravatar Brian Osman2017-10-31
| | | | | | | | | | | | | | | | | | | With this change, untagged sources (eg N32) are treated as sRGB data, which causes a huge number of GMs to render more correctly in GPU sRGB/F16/etc... configs. Also, because the sources are treated as having a color space, we actually do gamut conversion for wide or narrow gamut outputs. This change also applies the transfer function math to individual colors in the case of gradient stops and color shaders. (The CPU backend doesn't do this yet, but I think we've decided there's no reason not to support it). Bug: skia: Change-Id: If76e9e4a268f9f74110ff4bbe4fe189ba5d19d9f Reviewed-on: https://skia-review.googlesource.com/64100 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
* Add clamped/unclamped xform to GrColorSpaceXformGravatar Brian Osman2017-10-20
| | | | | | | | | | | Use that in analytic gradient setup for future-proofing. Also fixed several out-of-date comments in gradient code. Bug: skia: Change-Id: I79726cad786c22f80e08cdc2b7a1e15ae27ecd5a Reviewed-on: https://skia-review.googlesource.com/62320 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Brian Osman <brianosman@google.com>
* Add GrColorSpaceXformEffectGravatar Brian Osman2017-10-18
| | | | | | | | | | | | | This is an FP that just applies a GrColorSpaceXform. I have a long string of follow-up changes that use this, which greatly simplifies many other FPs, and ultimately eliminates the need for color space xforms to be a first-class type in SkSL. Bug: skia: Change-Id: I070d8bab81c9a620a2173c83b0013c63ad53bc8e Reviewed-on: https://skia-review.googlesource.com/60726 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
* Add const to GrColorSpaceXform member argumentsGravatar Brian Osman2017-03-14
| | | | | | | | | BUG=skia: Change-Id: I643c486066a0cd48e9c985ab5f3ee453c2a533c5 Reviewed-on: https://skia-review.googlesource.com/9644 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
* Clamp premul colors correctly after a gamut changeGravatar Brian Osman2017-01-04
| | | | | | | | | | | | | | | Textures that we sample on the GPU are always premul, so we should actually clamp to alpha. Colors that are xformed on the CPU are always unpremul, so clamping to [0,1] is correct. Add a comment explaining that. BUG=skia: Change-Id: I180f2d410f24afc78bd03ab8636a83fb443d68e2 Reviewed-on: https://skia-review.googlesource.com/6581 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org>
* Clamp colors after gamut xform in GaneshGravatar Brian Osman2016-12-02
| | | | | | | | | | | Fixes many blatant errors with glnarrow config BUG=skia: Change-Id: I729cda350ebce126bdac4eb41c91f30294e1c61e Reviewed-on: https://skia-review.googlesource.com/5469 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Brian Osman <brianosman@google.com>
* Cache GrColorSpaceXformsGravatar Brian Osman2016-10-20
| | | | | | | | | | | | | | | | | | | | Even with a modest cache, we're going to get nearly 100% hit rate for typical usage scenarios. I'm hoping to avoid the special case caching of sRGB -> destination, and just rely on the more general mechanism. Yes, this is yet-another cache class. I wanted to use one of many that are laying around, but couldn't find a good fit. On the plus side, it's not much code. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3726 Change-Id: I943be5c99f0d691a87ffe8c5bc3067a8eb491fc2 Reviewed-on: https://skia-review.googlesource.com/3726 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
* Hash the gamut of XYZ color spaces, to speed up comparisonGravatar Brian Osman2016-10-20
| | | | | | | | | | | | | | Also going to use this to allow caching of GrColorSpaceXforms BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3670 Change-Id: I56ed2dcbdddc22046263f56d68f2d6aea55547c8 Reviewed-on: https://skia-review.googlesource.com/3670 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Matt Sarett <msarett@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
* Refactored SkColorSpace and added in a Lab PCS GMGravatar raftias2016-10-18
| | | | | | | | | | | | | | | | | | | | The refactoring breaks off A2B0 tag support into a separate subclass of SkColorSpace_Base, while keeping the current (besides CLUT) functionality in a XYZTRC subclass. ICC profile loading is now aware of this and creates the A2B0 subclass when SkColorSpace::NewICC() is called on a profile in need of the A2B0 functionality. The LabPCSDemo GM loads a .icc profile containing a LAB PCS and then runs a Lab->XYZ conversion on an image using it so we can display it and test out the A2B0 SkColorSpace functionality, sans a/b/m-curves, as well as the Lab->XYZ conversion code. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2389983002 Review-Url: https://codereview.chromium.org/2389983002
* Move toXYZD50() to SkColorSpace_BaseGravatar msarett2016-09-28
| | | | | | | | | | | | SkColorSpace needs to become more versatile, in order to support profiles that cannot specified with just a "to XYZ D50" matrix. This a just first step to clean up the public API. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2381553002 Review-Url: https://codereview.chromium.org/2381553002
* Add storage and computation of SkColor4f version of gradient stops.Gravatar brianosman2016-09-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | For now, we still only have the SkColor factory, but the Descriptor can now carry either an SkColor or SkColor4f specified gradient. Base class constructor automatically populates both forms of color, so that legacy raster backend will continue to work, and new backend work can operate directly from the float4 version. On the GPU side, we have similar logic, but GrGradientEffect only keeps one version of colors around: SkColor if the destination is legacy, and SkColor4f (with an optional gamut xform) if the destination is gamma correct. The 4f colors are already linear, and we gamut xform them in setData, so gradients are now fully color-correct in sRGB and F16 modes... ... unless there are more than three stops. Then we use a texture, and that code path isn't handled yet. We have a few choices here (do we use an 8-bit sRGB atlas, or just always use F16 linear atlas so we can share it among both sRGB and wide-gamut rendering). In any case, I'd like to defer that to a second CL. This change does fix the non-texture gradients in the gamut GM. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2337313002 Review-Url: https://codereview.chromium.org/2337313002
* Gamut transformation of the paint color in GaneshGravatar brianosman2016-09-12
| | | | | | | | | | | | Conversion from sRGB to destination gamut is going to be very common, so I'm caching that xform (if there is one) on the draw context. Results verified in the gamut GM (two more boxes correct). BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2330553003 Review-Url: https://codereview.chromium.org/2330553003
* Two changes:Gravatar brianosman2016-09-12
| | | | | | | | | | | | | | | | | 1. Remove special premul handling from gamut xform code Alpha is a constant, so the gamut transformation results remain unchanged (it distributes across the linear matrix multiply). 2. Use SkMatrix44 rather than array of floats Preserves semantic intention, and makes upcoming code (where we transform colors on the CPU by that matrix) simpler. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2329553002 Review-Url: https://codereview.chromium.org/2329553002
* Fix color gamut xform matrices in GPU codeGravatar brianosman2016-09-09
| | | | | | | | | | | Now that we're not storing them transposed, we can plumb them to the shader column-major all the way, and then multiply colors on the right, as it should be. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2326093002 Review-Url: https://codereview.chromium.org/2326093002
* Fix storage of gamut transform matrices in SkColorSpaceGravatar brianosman2016-09-09
| | | | | | | | | | | | | | | We were effectively storing the transpose, which made all of our operations on individual colors, and our concatenation of matrices awkward and backwards. I'm planning to push this further into Ganesh, where I had incorrectly adjusted to the previous layout, treating colors as row vectors in the shaders. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2324843003 Review-Url: https://codereview.chromium.org/2324843003
* Cache the inverse matrix on SkColorSpace. Rename xyz() to toXYZ().Gravatar brianosman2016-09-08
| | | | | | | BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2323003002 Review-Url: https://codereview.chromium.org/2323003002
* Add color gamut xform helpers to GrGLSLShaderBuilderGravatar brianosman2016-09-07
| | | | | | | | | | | | | | New helper functions inject the necessary shader function. Texture lookup functions can now insert the gamut xform at the appropriate place, too. As written, could be used to transform non-texture colors (e.g. vertex colors) as well. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2180803005 Review-Url: https://codereview.chromium.org/2180803005
* Simplify color space xform storage and usage (float[] vs. SkMatrix44)Gravatar brianosman2016-07-27
| | | | | | | | | | Public API is really just internal. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2185533005 TBR=bsalomon@google.com Review-Url: https://codereview.chromium.org/2185533005
* Introduce GrColorSpaceXform, for gamut conversion on texturesGravatar brianosman2016-07-18
GrTextureAccess optionally includes an instance, computed from the src and dst color spaces. In all common cases (no color space for either src or dst, or same color space for both), no object is allocated. This change is orthogonal to my attempts to get color space attached to render targets - regardless of how we choose to do that, this will give us the source color space at all points where we are connecting src to dst. There are many dangling injection points where I've been inserting nullptr, but I have a record of all of them. Additionally, there are now three places (the most common simple paths for bitmap/image rendering) where things are plumbed enough that I expect to have access to the dst color space (all marked with XFORMTODO). In addition to getting the dst color space, I need to inject shader code and uniform uploading for appendTextureLookup and friends. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2154753003 Review-Url: https://codereview.chromium.org/2154753003