diff options
author | Mike Klein <mtklein@chromium.org> | 2018-05-10 11:29:15 -0400 |
---|---|---|
committer | Mike Klein <mtklein@chromium.org> | 2018-05-10 18:26:22 +0000 |
commit | ce4cf72e3487f661e53f6d0c3416c9b58da4fd00 (patch) | |
tree | 5e8a5b884c787a095ea25ea93070569731e937a1 | |
parent | 024615e9752d93c842ad3cad597fd65382ddb678 (diff) |
non-linear blending first steps
Code:
- Add a non-linear blending bit and makeNonlinearBlending()
to SkColorSpace
- remove enough F16=linear checks to make it possible to
create surfaces and encode pngs with nonlinear F16
Testing:
- add "esrgb" software config to DM, run it
- add "srgbnl" software config, run it
- deemphasize importance of "srgb" config on bots
- update unit tests to reflect relaxed F16 constraints
- add a new unit test file with _really_ basic tests,
and a new unit test that's not working yet
Bug: skia:7942
Change-Id: I8ac042bdf9f3d791765393b68fd9256375184d83
Reviewed-on: https://skia-review.googlesource.com/127325
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
38 files changed, 151 insertions, 55 deletions
@@ -903,6 +903,7 @@ static Sink* create_sink(const GrContextOptions& grCtxOptions, const SkCommandLi if (FLAGS_cpu) { auto srgbColorSpace = SkColorSpace::MakeSRGB(); auto srgbLinearColorSpace = SkColorSpace::MakeSRGBLinear(); + auto esrgb = SkColorSpace::MakeSRGB()->makeNonlinearBlending(); SINK("g8", RasterSink, kGray_8_SkColorType); SINK("565", RasterSink, kRGB_565_SkColorType); @@ -915,6 +916,8 @@ static Sink* create_sink(const GrContextOptions& grCtxOptions, const SkCommandLi SINK("1010102", RasterSink, kRGBA_1010102_SkColorType); SINK("101010x", RasterSink, kRGB_101010x_SkColorType); SINK("f16", RasterSink, kRGBA_F16_SkColorType, srgbLinearColorSpace); + SINK("esrgb", RasterSink, kRGBA_F16_SkColorType, esrgb); + SINK("srgbnl", RasterSink, kRGBA_8888_SkColorType, esrgb); SINK("t8888", ThreadedSink, kN32_SkColorType); SINK("pdf", PDFSink, false, SK_ScalarDefaultRasterDPI); SINK("skp", SKPSink); diff --git a/gm/dstreadshuffle.cpp b/gm/dstreadshuffle.cpp index aaef61d63c..c4c19fcd4e 100644 --- a/gm/dstreadshuffle.cpp +++ b/gm/dstreadshuffle.cpp @@ -166,6 +166,7 @@ protected: canvas->imageInfo().refColorSpace()); } surf = SkSurface::MakeRaster(info); + SkASSERT(surf); } canvas->scale(5.f, 5.f); canvas->translate(67.f, 10.f); diff --git a/gn/tests.gni b/gn/tests.gni index 68f4f829fa..19017c45e6 100644 --- a/gn/tests.gni +++ b/gn/tests.gni @@ -141,6 +141,7 @@ tests_sources = [ "$_tests/MessageBusTest.cpp", "$_tests/MetaDataTest.cpp", "$_tests/MipMapTest.cpp", + "$_tests/NonlinearBlendingTest.cpp", "$_tests/OnceTest.cpp", "$_tests/OSPathTest.cpp", "$_tests/OverAlignedTest.cpp", diff --git a/include/core/SkColorSpace.h b/include/core/SkColorSpace.h index 2bc297efe0..801ccf2098 100644 --- a/include/core/SkColorSpace.h +++ b/include/core/SkColorSpace.h @@ -259,6 +259,9 @@ public: */ const SkData* profileData() const { return this->onProfileData(); } + virtual bool nonlinearBlending() const { return false; } + virtual sk_sp<SkColorSpace> makeNonlinearBlending() const { return nullptr; } + private: virtual const SkMatrix44* onToXYZD50() const = 0; virtual uint32_t onToXYZD50Hash() const = 0; diff --git a/include/private/SkImageInfoPriv.h b/include/private/SkImageInfoPriv.h index 597906af29..aac1750708 100644 --- a/include/private/SkImageInfoPriv.h +++ b/include/private/SkImageInfoPriv.h @@ -115,11 +115,6 @@ static inline bool SkImageInfoIsValidCommon(const SkImageInfo& info) { return false; } - if (kRGBA_F16_SkColorType == info.colorType() && - (info.colorSpace() && (!info.colorSpace()->gammaIsLinear()))) { - return false; - } - return true; } diff --git a/infra/bots/recipes/test.expected/Test-Android-Clang-Nexus5x-CPU-Snapdragon808-arm-Release-All-Android_ASAN.json b/infra/bots/recipes/test.expected/Test-Android-Clang-Nexus5x-CPU-Snapdragon808-arm-Release-All-Android_ASAN.json index 404248df34..c88bd32285 100644 --- a/infra/bots/recipes/test.expected/Test-Android-Clang-Nexus5x-CPU-Snapdragon808-arm-Release-All-Android_ASAN.json +++ b/infra/bots/recipes/test.expected/Test-Android-Clang-Nexus5x-CPU-Snapdragon808-arm-Release-All-Android_ASAN.json @@ -945,7 +945,7 @@ "--json-output", "/path/to/tmp/json", "copy", - "set -x; /data/local/tmp/dm --resourcePath /sdcard/revenge_of_the_skiabot/resources --skps /sdcard/revenge_of_the_skiabot/skps --images /sdcard/revenge_of_the_skiabot/images/dm --colorImages /sdcard/revenge_of_the_skiabot/images/colorspace --nameByHash --properties gitHash abc123 builder Test-Android-Clang-Nexus5x-CPU-Snapdragon808-arm-Release-All-Android_ASAN buildbucket_build_id 123454321 swarming_bot_id skia-bot-123 swarming_task_id 123456 --svgs /sdcard/revenge_of_the_skiabot/svgs --key arch arm compiler Clang configuration Release cpu_or_gpu CPU cpu_or_gpu_value Snapdragon808 extra_config Android_ASAN model Nexus5x os Android --dont_write pdf --nogpu --config 8888 srgb serialize-8888 tiles_rt-8888 pic-8888 --src tests gm image colorImage --blacklist _ test _ GrShape serialize-8888 gm _ bleed_image serialize-8888 gm _ c_gms serialize-8888 gm _ colortype serialize-8888 gm _ colortype_xfermodes serialize-8888 gm _ drawfilter serialize-8888 gm _ fontmgr_bounds_0.75_0 serialize-8888 gm _ fontmgr_bounds_1_-0.25 serialize-8888 gm _ fontmgr_bounds serialize-8888 gm _ fontmgr_match serialize-8888 gm _ fontmgr_iter serialize-8888 gm _ imagemasksubset serialize-8888 gm _ bitmapfilters serialize-8888 gm _ bitmapshaders serialize-8888 gm _ bleed serialize-8888 gm _ bleed_alpha_bmp serialize-8888 gm _ bleed_alpha_bmp_shader serialize-8888 gm _ convex_poly_clip serialize-8888 gm _ extractalpha serialize-8888 gm _ filterbitmap_checkerboard_32_32_g8 serialize-8888 gm _ filterbitmap_image_mandrill_64 serialize-8888 gm _ shadows serialize-8888 gm _ simpleaaclip_aaclip serialize-8888 gm _ composeshader_bitmap serialize-8888 gm _ scaled_tilemodes_npot serialize-8888 gm _ scaled_tilemodes serialize-8888 gm _ typefacerendering_pfaMac serialize-8888 gm _ parsedpaths serialize-8888 gm _ ImageGeneratorExternal_rect serialize-8888 gm _ ImageGeneratorExternal_shader serialize-8888 gm _ shadow_utils serialize-8888 gm _ all_bitmap_configs serialize-8888 gm _ makecolorspace serialize-8888 gm _ analytic_antialias_convex serialize-8888 gm _ bleed_alpha_image serialize-8888 gm _ bleed_alpha_image_shader serialize-8888 gm _ verylargebitmap serialize-8888 gm _ verylarge_picture_image pic-8888 gm _ drawfilter pic-8888 gm _ image-cacherator-from-picture serialize-8888 gm _ image-cacherator-from-picture pic-8888 gm _ image-cacherator-from-raster serialize-8888 gm _ image-cacherator-from-raster pic-8888 gm _ image-cacherator-from-ctable serialize-8888 gm _ image-cacherator-from-ctable pic-8888 gm _ gamut serialize-8888 gm _ gamut pic-8888 gm _ complexclip4_bw serialize-8888 gm _ complexclip4_bw pic-8888 gm _ complexclip4_aa serialize-8888 gm _ complexclip4_aa tiles_rt-8888 gm _ complexclip4_bw tiles_rt-8888 gm _ complexclip4_aa --match ~BadImage --noRAW_threading --nonativeFonts --verbose; echo $? >/data/local/tmp/rc", + "set -x; /data/local/tmp/dm --resourcePath /sdcard/revenge_of_the_skiabot/resources --skps /sdcard/revenge_of_the_skiabot/skps --images /sdcard/revenge_of_the_skiabot/images/dm --colorImages /sdcard/revenge_of_the_skiabot/images/colorspace --nameByHash --properties gitHash abc123 builder Test-Android-Clang-Nexus5x-CPU-Snapdragon808-arm-Release-All-Android_ASAN buildbucket_build_id 123454321 swarming_bot_id skia-bot-123 swarming_task_id 123456 --svgs /sdcard/revenge_of_the_skiabot/svgs --key arch arm compiler Clang configuration Release cpu_or_gpu CPU cpu_or_gpu_value Snapdragon808 extra_config Android_ASAN model Nexus5x os Android --dont_write pdf --nogpu --config 8888 serialize-8888 tiles_rt-8888 pic-8888 --src tests gm image colorImage --blacklist _ test _ GrShape serialize-8888 gm _ bleed_image serialize-8888 gm _ c_gms serialize-8888 gm _ colortype serialize-8888 gm _ colortype_xfermodes serialize-8888 gm _ drawfilter serialize-8888 gm _ fontmgr_bounds_0.75_0 serialize-8888 gm _ fontmgr_bounds_1_-0.25 serialize-8888 gm _ fontmgr_bounds serialize-8888 gm _ fontmgr_match serialize-8888 gm _ fontmgr_iter serialize-8888 gm _ imagemasksubset serialize-8888 gm _ bitmapfilters serialize-8888 gm _ bitmapshaders serialize-8888 gm _ bleed serialize-8888 gm _ bleed_alpha_bmp serialize-8888 gm _ bleed_alpha_bmp_shader serialize-8888 gm _ convex_poly_clip serialize-8888 gm _ extractalpha serialize-8888 gm _ filterbitmap_checkerboard_32_32_g8 serialize-8888 gm _ filterbitmap_image_mandrill_64 serialize-8888 gm _ shadows serialize-8888 gm _ simpleaaclip_aaclip serialize-8888 gm _ composeshader_bitmap serialize-8888 gm _ scaled_tilemodes_npot serialize-8888 gm _ scaled_tilemodes serialize-8888 gm _ typefacerendering_pfaMac serialize-8888 gm _ parsedpaths serialize-8888 gm _ ImageGeneratorExternal_rect serialize-8888 gm _ ImageGeneratorExternal_shader serialize-8888 gm _ shadow_utils serialize-8888 gm _ all_bitmap_configs serialize-8888 gm _ makecolorspace serialize-8888 gm _ analytic_antialias_convex serialize-8888 gm _ bleed_alpha_image serialize-8888 gm _ bleed_alpha_image_shader serialize-8888 gm _ verylargebitmap serialize-8888 gm _ verylarge_picture_image pic-8888 gm _ drawfilter pic-8888 gm _ image-cacherator-from-picture serialize-8888 gm _ image-cacherator-from-picture pic-8888 gm _ image-cacherator-from-raster serialize-8888 gm _ image-cacherator-from-raster pic-8888 gm _ image-cacherator-from-ctable serialize-8888 gm _ image-cacherator-from-ctable pic-8888 gm _ gamut serialize-8888 gm _ gamut pic-8888 gm _ complexclip4_bw serialize-8888 gm _ complexclip4_bw pic-8888 gm _ complexclip4_aa serialize-8888 gm _ complexclip4_aa tiles_rt-8888 gm _ complexclip4_bw tiles_rt-8888 gm _ complexclip4_aa --match ~BadImage --noRAW_threading --nonativeFonts --verbose; echo $? >/data/local/tmp/rc", "[START_DIR]/tmp/dm.sh" ], "env": { diff --git a/infra/bots/recipes/test.expected/Test-Android-Clang-Nexus7-CPU-Tegra3-arm-Release-All-Android.json b/infra/bots/recipes/test.expected/Test-Android-Clang-Nexus7-CPU-Tegra3-arm-Release-All-Android.json index bde0312cf9..934c7ac4ec 100644 --- a/infra/bots/recipes/test.expected/Test-Android-Clang-Nexus7-CPU-Tegra3-arm-Release-All-Android.json +++ b/infra/bots/recipes/test.expected/Test-Android-Clang-Nexus7-CPU-Tegra3-arm-Release-All-Android.json @@ -750,7 +750,7 @@ "--json-output", "/path/to/tmp/json", "copy", - "set -x; /data/local/tmp/dm --resourcePath /sdcard/revenge_of_the_skiabot/resources --skps /sdcard/revenge_of_the_skiabot/skps --images /sdcard/revenge_of_the_skiabot/images/dm --colorImages /sdcard/revenge_of_the_skiabot/images/colorspace --nameByHash --properties gitHash abc123 builder Test-Android-Clang-Nexus7-CPU-Tegra3-arm-Release-All-Android buildbucket_build_id 123454321 swarming_bot_id skia-bot-123 swarming_task_id 123456 --svgs /sdcard/revenge_of_the_skiabot/svgs --key arch arm compiler Clang configuration Release cpu_or_gpu CPU cpu_or_gpu_value Tegra3 extra_config Android model Nexus7 os Android --uninterestingHashesFile /sdcard/revenge_of_the_skiabot/uninteresting_hashes.txt --writePath /sdcard/revenge_of_the_skiabot/dm_out --dont_write pdf --threads 2 --nogpu --config 8888 srgb serialize-8888 tiles_rt-8888 pic-8888 --src tests gm image colorImage --blacklist _ test _ GrShape serialize-8888 gm _ bleed_image serialize-8888 gm _ c_gms serialize-8888 gm _ colortype serialize-8888 gm _ colortype_xfermodes serialize-8888 gm _ drawfilter serialize-8888 gm _ fontmgr_bounds_0.75_0 serialize-8888 gm _ fontmgr_bounds_1_-0.25 serialize-8888 gm _ fontmgr_bounds serialize-8888 gm _ fontmgr_match serialize-8888 gm _ fontmgr_iter serialize-8888 gm _ imagemasksubset serialize-8888 gm _ bitmapfilters serialize-8888 gm _ bitmapshaders serialize-8888 gm _ bleed serialize-8888 gm _ bleed_alpha_bmp serialize-8888 gm _ bleed_alpha_bmp_shader serialize-8888 gm _ convex_poly_clip serialize-8888 gm _ extractalpha serialize-8888 gm _ filterbitmap_checkerboard_32_32_g8 serialize-8888 gm _ filterbitmap_image_mandrill_64 serialize-8888 gm _ shadows serialize-8888 gm _ simpleaaclip_aaclip serialize-8888 gm _ composeshader_bitmap serialize-8888 gm _ scaled_tilemodes_npot serialize-8888 gm _ scaled_tilemodes serialize-8888 gm _ typefacerendering_pfaMac serialize-8888 gm _ parsedpaths serialize-8888 gm _ ImageGeneratorExternal_rect serialize-8888 gm _ ImageGeneratorExternal_shader serialize-8888 gm _ shadow_utils serialize-8888 gm _ all_bitmap_configs serialize-8888 gm _ makecolorspace serialize-8888 gm _ analytic_antialias_convex serialize-8888 gm _ bleed_alpha_image serialize-8888 gm _ bleed_alpha_image_shader serialize-8888 gm _ verylargebitmap serialize-8888 gm _ verylarge_picture_image pic-8888 gm _ drawfilter pic-8888 gm _ image-cacherator-from-picture serialize-8888 gm _ image-cacherator-from-picture pic-8888 gm _ image-cacherator-from-raster serialize-8888 gm _ image-cacherator-from-raster pic-8888 gm _ image-cacherator-from-ctable serialize-8888 gm _ image-cacherator-from-ctable pic-8888 gm _ gamut serialize-8888 gm _ gamut pic-8888 gm _ complexclip4_bw serialize-8888 gm _ complexclip4_bw pic-8888 gm _ complexclip4_aa serialize-8888 gm _ complexclip4_aa tiles_rt-8888 gm _ complexclip4_bw tiles_rt-8888 gm _ complexclip4_aa --nonativeFonts --verbose; echo $? >/data/local/tmp/rc", + "set -x; /data/local/tmp/dm --resourcePath /sdcard/revenge_of_the_skiabot/resources --skps /sdcard/revenge_of_the_skiabot/skps --images /sdcard/revenge_of_the_skiabot/images/dm --colorImages /sdcard/revenge_of_the_skiabot/images/colorspace --nameByHash --properties gitHash abc123 builder Test-Android-Clang-Nexus7-CPU-Tegra3-arm-Release-All-Android buildbucket_build_id 123454321 swarming_bot_id skia-bot-123 swarming_task_id 123456 --svgs /sdcard/revenge_of_the_skiabot/svgs --key arch arm compiler Clang configuration Release cpu_or_gpu CPU cpu_or_gpu_value Tegra3 extra_config Android model Nexus7 os Android --uninterestingHashesFile /sdcard/revenge_of_the_skiabot/uninteresting_hashes.txt --writePath /sdcard/revenge_of_the_skiabot/dm_out --dont_write pdf --threads 2 --nogpu --config 8888 serialize-8888 tiles_rt-8888 pic-8888 --src tests gm image colorImage --blacklist _ test _ GrShape serialize-8888 gm _ bleed_image serialize-8888 gm _ c_gms serialize-8888 gm _ colortype serialize-8888 gm _ colortype_xfermodes serialize-8888 gm _ drawfilter serialize-8888 gm _ fontmgr_bounds_0.75_0 serialize-8888 gm _ fontmgr_bounds_1_-0.25 serialize-8888 gm _ fontmgr_bounds serialize-8888 gm _ fontmgr_match serialize-8888 gm _ fontmgr_iter serialize-8888 gm _ imagemasksubset serialize-8888 gm _ bitmapfilters serialize-8888 gm _ bitmapshaders serialize-8888 gm _ bleed serialize-8888 gm _ bleed_alpha_bmp serialize-8888 gm _ bleed_alpha_bmp_shader serialize-8888 gm _ convex_poly_clip serialize-8888 gm _ extractalpha serialize-8888 gm _ filterbitmap_checkerboard_32_32_g8 serialize-8888 gm _ filterbitmap_image_mandrill_64 serialize-8888 gm _ shadows serialize-8888 gm _ simpleaaclip_aaclip serialize-8888 gm _ composeshader_bitmap serialize-8888 gm _ scaled_tilemodes_npot serialize-8888 gm _ scaled_tilemodes serialize-8888 gm _ typefacerendering_pfaMac serialize-8888 gm _ parsedpaths serialize-8888 gm _ ImageGeneratorExternal_rect serialize-8888 gm _ ImageGeneratorExternal_shader serialize-8888 gm _ shadow_utils serialize-8888 gm _ all_bitmap_configs serialize-8888 gm _ makecolorspace serialize-8888 gm _ analytic_antialias_convex serialize-8888 gm _ bleed_alpha_image serialize-8888 gm _ bleed_alpha_image_shader serialize-8888 gm _ verylargebitmap serialize-8888 gm _ verylarge_picture_image pic-8888 gm _ drawfilter pic-8888 gm _ image-cacherator-from-picture serialize-8888 gm _ image-cacherator-from-picture pic-8888 gm _ image-cacherator-from-raster serialize-8888 gm _ image-cacherator-from-raster pic-8888 gm _ image-cacherator-from-ctable serialize-8888 gm _ image-cacherator-from-ctable pic-8888 gm _ gamut serialize-8888 gm _ gamut pic-8888 gm _ complexclip4_bw serialize-8888 gm _ complexclip4_bw pic-8888 gm _ complexclip4_aa serialize-8888 gm _ complexclip4_aa tiles_rt-8888 gm _ complexclip4_bw tiles_rt-8888 gm _ complexclip4_aa --nonativeFonts --verbose; echo $? >/data/local/tmp/rc", "[START_DIR]/tmp/dm.sh" ], "env": { diff --git a/infra/bots/recipes/test.expected/Test-Android-Clang-NexusPlayer-CPU-Moorefield-x86-Release-All-Android.json b/infra/bots/recipes/test.expected/Test-Android-Clang-NexusPlayer-CPU-Moorefield-x86-Release-All-Android.json index a98ef32f02..d566bf90b0 100644 --- a/infra/bots/recipes/test.expected/Test-Android-Clang-NexusPlayer-CPU-Moorefield-x86-Release-All-Android.json +++ b/infra/bots/recipes/test.expected/Test-Android-Clang-NexusPlayer-CPU-Moorefield-x86-Release-All-Android.json @@ -794,7 +794,7 @@ "--json-output", "/path/to/tmp/json", "copy", - "set -x; /data/local/tmp/dm --resourcePath /sdcard/revenge_of_the_skiabot/resources --skps /sdcard/revenge_of_the_skiabot/skps --images /sdcard/revenge_of_the_skiabot/images/dm --colorImages /sdcard/revenge_of_the_skiabot/images/colorspace --nameByHash --properties gitHash abc123 builder Test-Android-Clang-NexusPlayer-CPU-Moorefield-x86-Release-All-Android buildbucket_build_id 123454321 swarming_bot_id skia-bot-123 swarming_task_id 123456 --svgs /sdcard/revenge_of_the_skiabot/svgs --key arch x86 compiler Clang configuration Release cpu_or_gpu CPU cpu_or_gpu_value Moorefield extra_config Android model NexusPlayer os Android --uninterestingHashesFile /sdcard/revenge_of_the_skiabot/uninteresting_hashes.txt --writePath /sdcard/revenge_of_the_skiabot/dm_out --dont_write pdf --ignoreSigInt --nogpu --config 8888 srgb serialize-8888 tiles_rt-8888 pic-8888 --src tests gm image colorImage --blacklist _ test _ GrShape serialize-8888 gm _ bleed_image serialize-8888 gm _ c_gms serialize-8888 gm _ colortype serialize-8888 gm _ colortype_xfermodes serialize-8888 gm _ drawfilter serialize-8888 gm _ fontmgr_bounds_0.75_0 serialize-8888 gm _ fontmgr_bounds_1_-0.25 serialize-8888 gm _ fontmgr_bounds serialize-8888 gm _ fontmgr_match serialize-8888 gm _ fontmgr_iter serialize-8888 gm _ imagemasksubset serialize-8888 gm _ bitmapfilters serialize-8888 gm _ bitmapshaders serialize-8888 gm _ bleed serialize-8888 gm _ bleed_alpha_bmp serialize-8888 gm _ bleed_alpha_bmp_shader serialize-8888 gm _ convex_poly_clip serialize-8888 gm _ extractalpha serialize-8888 gm _ filterbitmap_checkerboard_32_32_g8 serialize-8888 gm _ filterbitmap_image_mandrill_64 serialize-8888 gm _ shadows serialize-8888 gm _ simpleaaclip_aaclip serialize-8888 gm _ composeshader_bitmap serialize-8888 gm _ scaled_tilemodes_npot serialize-8888 gm _ scaled_tilemodes serialize-8888 gm _ typefacerendering_pfaMac serialize-8888 gm _ parsedpaths serialize-8888 gm _ ImageGeneratorExternal_rect serialize-8888 gm _ ImageGeneratorExternal_shader serialize-8888 gm _ shadow_utils serialize-8888 gm _ all_bitmap_configs serialize-8888 gm _ makecolorspace serialize-8888 gm _ analytic_antialias_convex serialize-8888 gm _ bleed_alpha_image serialize-8888 gm _ bleed_alpha_image_shader serialize-8888 gm _ verylargebitmap serialize-8888 gm _ verylarge_picture_image pic-8888 gm _ drawfilter pic-8888 gm _ image-cacherator-from-picture serialize-8888 gm _ image-cacherator-from-picture pic-8888 gm _ image-cacherator-from-raster serialize-8888 gm _ image-cacherator-from-raster pic-8888 gm _ image-cacherator-from-ctable serialize-8888 gm _ image-cacherator-from-ctable pic-8888 gm _ gamut serialize-8888 gm _ gamut pic-8888 gm _ complexclip4_bw serialize-8888 gm _ complexclip4_bw pic-8888 gm _ complexclip4_aa serialize-8888 gm _ complexclip4_aa tiles_rt-8888 gm _ complexclip4_bw tiles_rt-8888 gm _ complexclip4_aa --noRAW_threading --nonativeFonts --verbose; echo $? >/data/local/tmp/rc", + "set -x; /data/local/tmp/dm --resourcePath /sdcard/revenge_of_the_skiabot/resources --skps /sdcard/revenge_of_the_skiabot/skps --images /sdcard/revenge_of_the_skiabot/images/dm --colorImages /sdcard/revenge_of_the_skiabot/images/colorspace --nameByHash --properties gitHash abc123 builder Test-Android-Clang-NexusPlayer-CPU-Moorefield-x86-Release-All-Android buildbucket_build_id 123454321 swarming_bot_id skia-bot-123 swarming_task_id 123456 --svgs /sdcard/revenge_of_the_skiabot/svgs --key arch x86 compiler Clang configuration Release cpu_or_gpu CPU cpu_or_gpu_value Moorefield extra_config Android model NexusPlayer os Android --uninterestingHashesFile /sdcard/revenge_of_the_skiabot/uninteresting_hashes.txt --writePath /sdcard/revenge_of_the_skiabot/dm_out --dont_write pdf --ignoreSigInt --nogpu --config 8888 serialize-8888 tiles_rt-8888 pic-8888 --src tests gm image colorImage --blacklist _ test _ GrShape serialize-8888 gm _ bleed_image serialize-8888 gm _ c_gms serialize-8888 gm _ colortype serialize-8888 gm _ colortype_xfermodes serialize-8888 gm _ drawfilter serialize-8888 gm _ fontmgr_bounds_0.75_0 serialize-8888 gm _ fontmgr_bounds_1_-0.25 serialize-8888 gm _ fontmgr_bounds serialize-8888 gm _ fontmgr_match serialize-8888 gm _ fontmgr_iter serialize-8888 gm _ imagemasksubset serialize-8888 gm _ bitmapfilters serialize-8888 gm _ bitmapshaders serialize-8888 gm _ bleed serialize-8888 gm _ bleed_alpha_bmp serialize-8888 gm _ bleed_alpha_bmp_shader serialize-8888 gm _ convex_poly_clip serialize-8888 gm _ extractalpha serialize-8888 gm _ filterbitmap_checkerboard_32_32_g8 serialize-8888 gm _ filterbitmap_image_mandrill_64 serialize-8888 gm _ shadows serialize-8888 gm _ simpleaaclip_aaclip serialize-8888 gm _ composeshader_bitmap serialize-8888 gm _ scaled_tilemodes_npot serialize-8888 gm _ scaled_tilemodes serialize-8888 gm _ typefacerendering_pfaMac serialize-8888 gm _ parsedpaths serialize-8888 gm _ ImageGeneratorExternal_rect serialize-8888 gm _ ImageGeneratorExternal_shader serialize-8888 gm _ shadow_utils serialize-8888 gm _ all_bitmap_configs serialize-8888 gm _ makecolorspace serialize-8888 gm _ analytic_antialias_convex serialize-8888 gm _ bleed_alpha_image serialize-8888 gm _ bleed_alpha_image_shader serialize-8888 gm _ verylargebitmap serialize-8888 gm _ verylarge_picture_image pic-8888 gm _ drawfilter pic-8888 gm _ image-cacherator-from-picture serialize-8888 gm _ image-cacherator-from-picture pic-8888 gm _ image-cacherator-from-raster serialize-8888 gm _ image-cacherator-from-raster pic-8888 gm _ image-cacherator-from-ctable serialize-8888 gm _ image-cacherator-from-ctable pic-8888 gm _ gamut serialize-8888 gm _ gamut pic-8888 gm _ complexclip4_bw serialize-8888 gm _ complexclip4_bw pic-8888 gm _ complexclip4_aa serialize-8888 gm _ complexclip4_aa tiles_rt-8888 gm _ complexclip4_bw tiles_rt-8888 gm _ complexclip4_aa --noRAW_threading --nonativeFonts --verbose; echo $? >/data/local/tmp/rc", "[START_DIR]/tmp/dm.sh" ], "env": { diff --git a/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-ASAN.json b/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-ASAN.json index d1ac5e5ec9..84e7c288db 100644 --- a/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-ASAN.json +++ b/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-ASAN.json @@ -178,13 +178,15 @@ "--nogpu", "--config", "8888", - "srgb", "pdf", "g8", "565", "f16", "lite-8888", "gbr-8888", + "srgb", + "srgbnl", + "esrgb", "t8888", "serialize-8888", "tiles_rt-8888", diff --git a/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-MSAN.json b/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-MSAN.json index 1aef9343e9..1e59a27970 100644 --- a/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-MSAN.json +++ b/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-MSAN.json @@ -177,13 +177,15 @@ "--nogpu", "--config", "8888", - "srgb", "pdf", "g8", "565", "f16", "lite-8888", "gbr-8888", + "srgb", + "srgbnl", + "esrgb", "t8888", "serialize-8888", "tiles_rt-8888", diff --git a/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-SK_USE_DISCARDABLE_SCALEDIMAGECACHE.json b/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-SK_USE_DISCARDABLE_SCALEDIMAGECACHE.json index 2aad257348..a59fcc07ec 100644 --- a/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-SK_USE_DISCARDABLE_SCALEDIMAGECACHE.json +++ b/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-All-SK_USE_DISCARDABLE_SCALEDIMAGECACHE.json @@ -262,13 +262,15 @@ "--nogpu", "--config", "8888", - "srgb", "pdf", "g8", "565", "f16", "lite-8888", "gbr-8888", + "srgb", + "srgbnl", + "esrgb", "serialize-8888", "tiles_rt-8888", "pic-8888", diff --git a/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-shard_00_10-Coverage.json b/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-shard_00_10-Coverage.json index e63da2e979..edbc51d7fc 100644 --- a/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-shard_00_10-Coverage.json +++ b/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-shard_00_10-Coverage.json @@ -183,13 +183,15 @@ "10", "--config", "8888", - "srgb", "pdf", "g8", "565", "f16", "lite-8888", "gbr-8888", + "srgb", + "srgbnl", + "esrgb", "serialize-8888", "tiles_rt-8888", "pic-8888", diff --git a/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-All-SK_FORCE_RASTER_PIPELINE_BLITTER.json b/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-All-SK_FORCE_RASTER_PIPELINE_BLITTER.json index 522377c455..3c7ffd9efd 100644 --- a/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-All-SK_FORCE_RASTER_PIPELINE_BLITTER.json +++ b/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-All-SK_FORCE_RASTER_PIPELINE_BLITTER.json @@ -260,7 +260,6 @@ "--nogpu", "--config", "8888", - "srgb", "--src", "gm", "image", diff --git a/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-All-TSAN.json b/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-All-TSAN.json index 7583e00f7a..bc8c070db5 100644 --- a/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-All-TSAN.json +++ b/infra/bots/recipes/test.expected/Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-All-TSAN.json @@ -178,13 +178,15 @@ "--nogpu", "--config", "8888", - "srgb", "pdf", "g8", "565", "f16", "lite-8888", "gbr-8888", + "srgb", + "srgbnl", + "esrgb", "t8888", "serialize-8888", "tiles_rt-8888", diff --git a/infra/bots/recipes/test.expected/Test-Debian9-GCC-GCE-CPU-AVX2-x86-Debug-All.json b/infra/bots/recipes/test.expected/Test-Debian9-GCC-GCE-CPU-AVX2-x86-Debug-All.json index eece4bb4f0..cc73c5c03d 100644 --- a/infra/bots/recipes/test.expected/Test-Debian9-GCC-GCE-CPU-AVX2-x86-Debug-All.json +++ b/infra/bots/recipes/test.expected/Test-Debian9-GCC-GCE-CPU-AVX2-x86-Debug-All.json @@ -260,13 +260,15 @@ "--nogpu", "--config", "8888", - "srgb", "pdf", "g8", "565", "f16", "lite-8888", "gbr-8888", + "srgb", + "srgbnl", + "esrgb", "serialize-8888", "tiles_rt-8888", "pic-8888", diff --git a/infra/bots/recipes/test.expected/Test-Debian9-GCC-GCE-CPU-AVX2-x86_64-Debug-All.json b/infra/bots/recipes/test.expected/Test-Debian9-GCC-GCE-CPU-AVX2-x86_64-Debug-All.json index 85c6c7a863..457dadced2 100644 --- a/infra/bots/recipes/test.expected/Test-Debian9-GCC-GCE-CPU-AVX2-x86_64-Debug-All.json +++ b/infra/bots/recipes/test.expected/Test-Debian9-GCC-GCE-CPU-AVX2-x86_64-Debug-All.json @@ -258,13 +258,15 @@ "--nogpu", "--config", "8888", - "srgb", "pdf", "g8", "565", "f16", "lite-8888", "gbr-8888", + "srgb", + "srgbnl", + "esrgb", "serialize-8888", "tiles_rt-8888", "pic-8888", diff --git a/infra/bots/recipes/test.expected/Test-Mac-Clang-MacMini7.1-CPU-AVX-x86_64-Release-All.json b/infra/bots/recipes/test.expected/Test-Mac-Clang-MacMini7.1-CPU-AVX-x86_64-Release-All.json index 496cffe1e5..95a9dfcdbb 100644 --- a/infra/bots/recipes/test.expected/Test-Mac-Clang-MacMini7.1-CPU-AVX-x86_64-Release-All.json +++ b/infra/bots/recipes/test.expected/Test-Mac-Clang-MacMini7.1-CPU-AVX-x86_64-Release-All.json @@ -253,7 +253,6 @@ "--nogpu", "--config", "8888", - "srgb", "pdf", "serialize-8888", "tiles_rt-8888", diff --git a/infra/bots/recipes/test.expected/Test-Win8-Clang-Golo-CPU-AVX-x86-Debug-All.json b/infra/bots/recipes/test.expected/Test-Win8-Clang-Golo-CPU-AVX-x86-Debug-All.json index 0bf27b117d..d67e8e12db 100644 --- a/infra/bots/recipes/test.expected/Test-Win8-Clang-Golo-CPU-AVX-x86-Debug-All.json +++ b/infra/bots/recipes/test.expected/Test-Win8-Clang-Golo-CPU-AVX-x86-Debug-All.json @@ -255,7 +255,6 @@ "--nogpu", "--config", "8888", - "srgb", "pdf", "serialize-8888", "tiles_rt-8888", diff --git a/infra/bots/recipes/test.expected/failed_dm.json b/infra/bots/recipes/test.expected/failed_dm.json index 0a03678a5f..12719c887b 100644 --- a/infra/bots/recipes/test.expected/failed_dm.json +++ b/infra/bots/recipes/test.expected/failed_dm.json @@ -258,13 +258,15 @@ "--nogpu", "--config", "8888", - "srgb", "pdf", "g8", "565", "f16", "lite-8888", "gbr-8888", + "srgb", + "srgbnl", + "esrgb", "serialize-8888", "tiles_rt-8888", "pic-8888", diff --git a/infra/bots/recipes/test.expected/trybot.json b/infra/bots/recipes/test.expected/trybot.json index fb5c48436f..8514aaec39 100644 --- a/infra/bots/recipes/test.expected/trybot.json +++ b/infra/bots/recipes/test.expected/trybot.json @@ -259,13 +259,15 @@ "--nogpu", "--config", "8888", - "srgb", "pdf", "g8", "565", "f16", "lite-8888", "gbr-8888", + "srgb", + "srgbnl", + "esrgb", "serialize-8888", "tiles_rt-8888", "pic-8888", diff --git a/infra/bots/recipes/test.py b/infra/bots/recipes/test.py index 8345d97a9e..742e098bad 100644 --- a/infra/bots/recipes/test.py +++ b/infra/bots/recipes/test.py @@ -92,7 +92,7 @@ def dm_flags(api, bot): # These are the canonical configs that we would ideally run on all bots. We # may opt out or substitute some below for specific bots - configs.extend(['8888', 'srgb', 'pdf']) + configs.extend(['8888', 'pdf']) # Runs out of memory on Android bots. Everyone else seems fine. if 'Android' in bot: @@ -104,6 +104,9 @@ def dm_flags(api, bot): configs.extend(['f16']) configs.extend(['lite-8888']) # Experimental display list. configs.extend(['gbr-8888']) + configs.extend(['srgb']) + configs.extend(['srgbnl']) + configs.extend(['esrgb']) if 'SAN' in bot: configs.extend(['t8888']) @@ -115,7 +118,7 @@ def dm_flags(api, bot): # This bot only differs from vanilla CPU bots in 8888 config. if 'SK_FORCE_RASTER_PIPELINE_BLITTER' in bot: - configs = ['8888', 'srgb'] + configs = ['8888'] if 'FSAA' in bot or 'FAAA' in bot or 'FDAA' in bot: # Scan converters shouldn't really be sensitive to different color diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp index 53fa6f4643..f67e6c06d3 100644 --- a/src/codec/SkCodec.cpp +++ b/src/codec/SkCodec.cpp @@ -169,7 +169,7 @@ bool SkCodec::conversionSupported(const SkImageInfo& dst, SkColorType srcColor, case kBGRA_8888_SkColorType: return true; case kRGBA_F16_SkColorType: - return dst.colorSpace() && dst.colorSpace()->gammaIsLinear(); + return dst.colorSpace(); case kRGB_565_SkColorType: return srcIsOpaque; case kGray_8_SkColorType: diff --git a/src/codec/SkHeifCodec.cpp b/src/codec/SkHeifCodec.cpp index 6e82904115..31057a0385 100644 --- a/src/codec/SkHeifCodec.cpp +++ b/src/codec/SkHeifCodec.cpp @@ -192,10 +192,6 @@ bool SkHeifCodec::setOutputColorFormat(const SkImageInfo& dstInfo) { case kRGBA_F16_SkColorType: SkASSERT(this->colorXform()); - - if (!dstInfo.colorSpace()->gammaIsLinear()) { - return false; - } return fHeifDecoder->setOutputColor(kHeifColorFormat_RGBA_8888); default: diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp index 2cc7921277..d44258f9b0 100644 --- a/src/codec/SkJpegCodec.cpp +++ b/src/codec/SkJpegCodec.cpp @@ -433,11 +433,6 @@ bool SkJpegCodec::setOutputColorSpace(const SkImageInfo& dstInfo) { break; case kRGBA_F16_SkColorType: SkASSERT(this->colorXform()); - - if (!dstInfo.colorSpace()->gammaIsLinear()) { - return false; - } - fDecoderMgr->dinfo()->out_color_space = JCS_EXT_RGBA; break; default: diff --git a/src/codec/SkWbmpCodec.cpp b/src/codec/SkWbmpCodec.cpp index d8b10287f6..b5fd591729 100644 --- a/src/codec/SkWbmpCodec.cpp +++ b/src/codec/SkWbmpCodec.cpp @@ -29,7 +29,7 @@ static inline bool valid_color_type(const SkImageInfo& dstInfo) { case kRGB_565_SkColorType: return true; case kRGBA_F16_SkColorType: - return dstInfo.colorSpace() && dstInfo.colorSpace()->gammaIsLinear(); + return dstInfo.colorSpace(); default: return false; } diff --git a/src/core/SkColorSpace.cpp b/src/core/SkColorSpace.cpp index be399bda6f..b75edcef94 100644 --- a/src/core/SkColorSpace.cpp +++ b/src/core/SkColorSpace.cpp @@ -500,6 +500,10 @@ bool SkColorSpace::Equals(const SkColorSpace* src, const SkColorSpace* dst) { return false; } + if (src->nonlinearBlending() != dst->nonlinearBlending()) { + return false; + } + const SkData* srcData = src->onProfileData(); const SkData* dstData = dst->onProfileData(); if (srcData || dstData) { diff --git a/src/core/SkColorSpace_XYZ.cpp b/src/core/SkColorSpace_XYZ.cpp index 17462a117a..968f01d793 100644 --- a/src/core/SkColorSpace_XYZ.cpp +++ b/src/core/SkColorSpace_XYZ.cpp @@ -119,3 +119,13 @@ void SkColorSpace_XYZ::toDstGammaTables(const uint8_t* tables[3], sk_sp<SkData>* tables[1] = fToDstGammaTables[1]; tables[2] = fToDstGammaTables[2]; } + +sk_sp<SkColorSpace> SkColorSpace_XYZ::makeNonlinearBlending() const { + if (this->nonlinearBlending()) { + return sk_ref_sp(const_cast<SkColorSpace_XYZ*>(this)); + } + + auto cs = sk_make_sp<SkColorSpace_XYZ>(fGammaNamed, fGammas, fToXYZD50, fProfileData); + cs->fNonlinearBlending = true; + return cs; +} diff --git a/src/core/SkColorSpace_XYZ.h b/src/core/SkColorSpace_XYZ.h index 2ad2e38b1b..d0984ecd1e 100644 --- a/src/core/SkColorSpace_XYZ.h +++ b/src/core/SkColorSpace_XYZ.h @@ -23,12 +23,14 @@ public: bool onGammaCloseToSRGB() const override; bool onGammaIsLinear() const override; bool onIsNumericalTransferFn(SkColorSpaceTransferFn* coeffs) const override; + bool nonlinearBlending() const override { return fNonlinearBlending; } const SkData* onProfileData() const override { return fProfileData.get(); } sk_sp<SkColorSpace> makeLinearGamma() const override; sk_sp<SkColorSpace> makeSRGBGamma() const override; sk_sp<SkColorSpace> makeColorSpin() const override; + sk_sp<SkColorSpace> makeNonlinearBlending() const override; SkGammaNamed onGammaNamed() const override { return fGammaNamed; } @@ -56,6 +58,8 @@ private: mutable const uint8_t* fToDstGammaTables[3]; mutable SkOnce fToDstGammaOnce; + bool fNonlinearBlending = false; + friend class SkColorSpace; friend class ColorSpaceXformTest; }; diff --git a/src/core/SkPictureImageGenerator.cpp b/src/core/SkPictureImageGenerator.cpp index 4b68ffdd93..f17ff647ae 100644 --- a/src/core/SkPictureImageGenerator.cpp +++ b/src/core/SkPictureImageGenerator.cpp @@ -23,10 +23,6 @@ SkPictureImageGenerator::Make(const SkISize& size, sk_sp<SkPicture> picture, con return nullptr; } - if (SkImage::BitDepth::kF16 == bitDepth && (!colorSpace || !colorSpace->gammaIsLinear())) { - return nullptr; - } - if (colorSpace && (!colorSpace->gammaCloseToSRGB() && !colorSpace->gammaIsLinear())) { return nullptr; } diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 99465f620b..60586ea503 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -300,6 +300,7 @@ GrPixelConfig GrRenderableConfigForColorSpace(const SkColorSpace* colorSpace) { if (!colorSpace) { return kRGBA_8888_GrPixelConfig; } else if (colorSpace->gammaIsLinear()) { + // TODO return kRGBA_half_GrPixelConfig; } else if (colorSpace->gammaCloseToSRGB()) { return kSRGBA_8888_GrPixelConfig; diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index b646f9e506..d86b316ef6 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -271,7 +271,7 @@ bool SkSurface_Gpu::onDraw(const SkDeferredDisplayList* ddl) { bool SkSurface_Gpu::Valid(const SkImageInfo& info) { switch (info.colorType()) { case kRGBA_F16_SkColorType: - return (!info.colorSpace()) || info.colorSpace()->gammaIsLinear(); + return true; case kRGBA_8888_SkColorType: case kBGRA_8888_SkColorType: return !info.colorSpace() || info.colorSpace()->gammaCloseToSRGB(); @@ -283,7 +283,7 @@ bool SkSurface_Gpu::Valid(const SkImageInfo& info) { bool SkSurface_Gpu::Valid(const GrCaps* caps, GrPixelConfig config, SkColorSpace* colorSpace) { switch (config) { case kRGBA_half_GrPixelConfig: - return (!colorSpace) || colorSpace->gammaIsLinear(); + return true; case kSRGBA_8888_GrPixelConfig: case kSBGRA_8888_GrPixelConfig: return caps->srgbSupport() && colorSpace && colorSpace->gammaCloseToSRGB(); diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp index 47d5542ac6..fd120072f4 100644 --- a/src/image/SkSurface_Raster.cpp +++ b/src/image/SkSurface_Raster.cpp @@ -68,9 +68,6 @@ bool SkSurfaceValidateRasterInfo(const SkImageInfo& info, size_t rowBytes) { } break; case kRGBA_F16_SkColorType: - if (info.colorSpace() && (!info.colorSpace()->gammaIsLinear())) { - return false; - } break; default: return false; diff --git a/src/images/SkJpegEncoder.cpp b/src/images/SkJpegEncoder.cpp index 305152d978..606b553537 100644 --- a/src/images/SkJpegEncoder.cpp +++ b/src/images/SkJpegEncoder.cpp @@ -118,7 +118,7 @@ bool SkJpegEncoderMgr::setParams(const SkImageInfo& srcInfo, const SkJpegEncoder numComponents = 1; break; case kRGBA_F16_SkColorType: - if (!srcInfo.colorSpace() || !srcInfo.colorSpace()->gammaIsLinear() || + if (!srcInfo.colorSpace() || SkTransferFunctionBehavior::kRespect != options.fBlendBehavior) { return false; } diff --git a/src/images/SkPngEncoder.cpp b/src/images/SkPngEncoder.cpp index c7952df57a..19fc27e4a6 100644 --- a/src/images/SkPngEncoder.cpp +++ b/src/images/SkPngEncoder.cpp @@ -106,7 +106,7 @@ bool SkPngEncoderMgr::setHeader(const SkImageInfo& srcInfo, const SkPngEncoder:: int bitDepth = 8; switch (srcInfo.colorType()) { case kRGBA_F16_SkColorType: - SkASSERT(srcInfo.colorSpace() && srcInfo.colorSpace()->gammaIsLinear()); + SkASSERT(srcInfo.colorSpace()); sigBit.red = 16; sigBit.green = 16; sigBit.blue = 16; diff --git a/src/images/SkWebpEncoder.cpp b/src/images/SkWebpEncoder.cpp index a7809b2fa0..ee13563ea7 100644 --- a/src/images/SkWebpEncoder.cpp +++ b/src/images/SkWebpEncoder.cpp @@ -88,10 +88,6 @@ static transform_scanline_proc choose_proc(const SkImageInfo& info, case kGray_8_SkColorType: return transform_scanline_gray; case kRGBA_F16_SkColorType: - if (!info.colorSpace() || !info.colorSpace()->gammaIsLinear()) { - return nullptr; - } - switch (info.alphaType()) { case kOpaque_SkAlphaType: case kUnpremul_SkAlphaType: diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp index ceb10a10df..474cdc6931 100644 --- a/tests/CodecTest.cpp +++ b/tests/CodecTest.cpp @@ -1144,22 +1144,22 @@ static void test_conversion_possible(skiatest::Reporter* r, const char* path, SkBitmap bm; bm.allocPixels(infoF16); SkCodec::Result result = codec->getPixels(infoF16, bm.getPixels(), bm.rowBytes()); - REPORTER_ASSERT(r, SkCodec::kInvalidConversion == result); + REPORTER_ASSERT(r, SkCodec::kSuccess == result); result = codec->startScanlineDecode(infoF16); if (supportsScanlineDecoder) { - REPORTER_ASSERT(r, SkCodec::kInvalidConversion == result); + REPORTER_ASSERT(r, SkCodec::kSuccess == result); } else { REPORTER_ASSERT(r, SkCodec::kUnimplemented == result - || SkCodec::kInvalidConversion == result); + || SkCodec::kSuccess == result); } result = codec->startIncrementalDecode(infoF16, bm.getPixels(), bm.rowBytes()); if (supportsIncrementalDecoder) { - REPORTER_ASSERT(r, SkCodec::kInvalidConversion == result); + REPORTER_ASSERT(r, SkCodec::kSuccess == result); } else { REPORTER_ASSERT(r, SkCodec::kUnimplemented == result - || SkCodec::kInvalidConversion == result); + || SkCodec::kSuccess == result); } infoF16 = infoF16.makeColorSpace(infoF16.colorSpace()->makeLinearGamma()); diff --git a/tests/NonlinearBlendingTest.cpp b/tests/NonlinearBlendingTest.cpp new file mode 100644 index 0000000000..10c12aa280 --- /dev/null +++ b/tests/NonlinearBlendingTest.cpp @@ -0,0 +1,76 @@ +/* + * Copyright 2018 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "Test.h" +#include "SkHalf.h" +#include "SkSurface.h" +#include "SkCanvas.h" + +DEF_TEST(NonlinearBlending, r) { + + // First check our familiar basics with linear F16. + { + auto info = SkImageInfo::Make(1,1, kRGBA_F16_SkColorType, kPremul_SkAlphaType, + SkColorSpace::MakeSRGBLinear()); + + auto surface = SkSurface::MakeRaster(info); + surface->getCanvas()->clear(0xff808080); + uint64_t pix; + REPORTER_ASSERT(r, surface->readPixels(info, &pix, sizeof(pix),0,0)); + + // 0x80 in sRGB is ≈ 0.22 linear. + REPORTER_ASSERT(r, SkHalfToFloat(pix & 0xffff) < 0.25f); + } + + // Test that we support sRGB-encoded F16. This is somewhat new. + { + auto info = SkImageInfo::Make(1,1, kRGBA_F16_SkColorType, kPremul_SkAlphaType, + SkColorSpace::MakeSRGB()); + + auto surface = SkSurface::MakeRaster(info); + surface->getCanvas()->clear(0xff808080); + uint64_t pix; + REPORTER_ASSERT(r, surface->readPixels(info, &pix, sizeof(pix),0,0)); + + // 0x80 sRGB is ≈ 0.501. + REPORTER_ASSERT(r, SkHalfToFloat(pix & 0xffff) >= 0.5f); + } + + // Since we're only clear()ing, this should work the same as the last block. + { + auto info = SkImageInfo::Make(1,1, kRGBA_F16_SkColorType, kPremul_SkAlphaType, + SkColorSpace::MakeSRGB()->makeNonlinearBlending()); + + auto surface = SkSurface::MakeRaster(info); + surface->getCanvas()->clear(0xff808080); + uint64_t pix; + REPORTER_ASSERT(r, surface->readPixels(info, &pix, sizeof(pix),0,0)); + + // 0x80 sRGB is ≈ 0.501. + REPORTER_ASSERT(r, SkHalfToFloat(pix & 0xffff) >= 0.5f); + } + + // This won't work until we actually support color spaces with non-linear blending. + if (0) { + auto info = SkImageInfo::Make(1,1, kRGBA_F16_SkColorType, kPremul_SkAlphaType, + SkColorSpace::MakeSRGB()->makeNonlinearBlending()); + + auto surface = SkSurface::MakeRaster(info); + + surface->getCanvas()->clear(SK_ColorWHITE); + SkPaint p; + p.setColor(0x80000000); + surface->getCanvas()->drawPaint(p); + + uint64_t pix; + REPORTER_ASSERT(r, surface->readPixels(info, &pix, sizeof(pix),0,0)); + + // 0x80 sRGB is ≈ 0.501. A likely failure here is ~0.75, linear blending. + REPORTER_ASSERT(r, SkHalfToFloat(pix & 0xffff) >= 0.45f && + SkHalfToFloat(pix & 0xffff) <= 0.55f); + } +} diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index 835e9ffc7f..e757230aa1 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -951,8 +951,8 @@ static void test_surface_creation_and_snapshot_with_color_space( { kN32_SkColorType, oddColorSpace, false, "N32-odd" }, { kRGBA_F16_SkColorType, nullptr, true, "F16-nullptr" }, { kRGBA_F16_SkColorType, linearColorSpace, true, "F16-linear" }, - { kRGBA_F16_SkColorType, srgbColorSpace, false, "F16-srgb" }, - { kRGBA_F16_SkColorType, oddColorSpace, false, "F16-odd" }, + { kRGBA_F16_SkColorType, srgbColorSpace, true, "F16-srgb" }, + { kRGBA_F16_SkColorType, oddColorSpace, true, "F16-odd" }, { kRGB_565_SkColorType, srgbColorSpace, false, "565-srgb" }, { kAlpha_8_SkColorType, srgbColorSpace, false, "A8-srgb" }, { kRGBA_1010102_SkColorType, nullptr, true, "1010102-nullptr" }, |