| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef ColorSpace_h | 26 #ifndef ColorSpace_h |
| 27 #define ColorSpace_h | 27 #define ColorSpace_h |
| 28 | 28 |
| 29 #include "platform/PlatformExport.h" | 29 #include "platform/PlatformExport.h" |
| 30 #include "platform/graphics/Color.h" | 30 #include "platform/graphics/Color.h" |
| 31 #include "third_party/skia/include/core/SkRefCnt.h" | 31 #include "third_party/skia/include/core/SkRefCnt.h" |
| 32 | 32 |
| 33 class SkColorFilter; | 33 class SkColorFilter; |
| 34 class SkColorSpace; |
| 34 | 35 |
| 35 namespace blink { | 36 namespace blink { |
| 36 | 37 |
| 38 struct WebScreenInfo; |
| 39 |
| 37 enum ColorSpace { ColorSpaceDeviceRGB, ColorSpaceSRGB, ColorSpaceLinearRGB }; | 40 enum ColorSpace { ColorSpaceDeviceRGB, ColorSpaceSRGB, ColorSpaceLinearRGB }; |
| 38 | 41 |
| 42 enum class ColorSpaceGamut { |
| 43 // Values synced with 'Gamut' in src/tools/metrics/histograms/histograms.xml |
| 44 Unknown = 0, |
| 45 LessThanNTSC = 1, |
| 46 NTSC = 2, |
| 47 SRGB = 3, |
| 48 AlmostP3 = 4, |
| 49 P3 = 5, |
| 50 AdobeRGB = 6, |
| 51 Wide = 7, |
| 52 BT2020 = 8, |
| 53 ProPhoto = 9, |
| 54 UltraWide = 10, |
| 55 End |
| 56 }; |
| 57 |
| 39 namespace ColorSpaceUtilities { | 58 namespace ColorSpaceUtilities { |
| 40 | 59 |
| 41 // Get a pointer to a 8-bit lookup table that will convert color components | 60 // Get a pointer to a 8-bit lookup table that will convert color components |
| 42 // in the |srcColorSpace| to the |dstColorSpace|. | 61 // in the |srcColorSpace| to the |dstColorSpace|. |
| 43 // If the conversion cannot be performed, or is a no-op (identity transform), | 62 // If the conversion cannot be performed, or is a no-op (identity transform), |
| 44 // then 0 is returned. | 63 // then 0 is returned. |
| 45 // (Note that a round-trip - f(B,A)[f(A,B)[x]] - is not lossless in general.) | 64 // (Note that a round-trip - f(B,A)[f(A,B)[x]] - is not lossless in general.) |
| 46 const uint8_t* getConversionLUT(ColorSpace dstColorSpace, | 65 const uint8_t* getConversionLUT(ColorSpace dstColorSpace, |
| 47 ColorSpace srcColorSpace = ColorSpaceDeviceRGB); | 66 ColorSpace srcColorSpace = ColorSpaceDeviceRGB); |
| 48 | 67 |
| 49 // Convert a Color assumed to be in the |srcColorSpace| into the | 68 // Convert a Color assumed to be in the |srcColorSpace| into the |
| 50 // |dstColorSpace|. | 69 // |dstColorSpace|. |
| 51 Color convertColor(const Color& srcColor, | 70 Color convertColor(const Color& srcColor, |
| 52 ColorSpace dstColorSpace, | 71 ColorSpace dstColorSpace, |
| 53 ColorSpace srcColorSpace = ColorSpaceDeviceRGB); | 72 ColorSpace srcColorSpace = ColorSpaceDeviceRGB); |
| 54 | 73 |
| 55 // Create a color filter that will convert from |srcColorSpace| into | 74 // Create a color filter that will convert from |srcColorSpace| into |
| 56 // |dstColorSpace|. | 75 // |dstColorSpace|. |
| 57 sk_sp<SkColorFilter> createColorSpaceFilter(ColorSpace srcColorSpace, | 76 sk_sp<SkColorFilter> createColorSpaceFilter(ColorSpace srcColorSpace, |
| 58 ColorSpace dstColorSpace); | 77 ColorSpace dstColorSpace); |
| 59 | 78 |
| 79 PLATFORM_EXPORT ColorSpaceGamut getColorSpaceGamut(const WebScreenInfo&); |
| 80 ColorSpaceGamut getColorSpaceGamut(SkColorSpace*); |
| 81 |
| 60 } // namespace ColorSpaceUtilities | 82 } // namespace ColorSpaceUtilities |
| 61 | 83 |
| 62 } // namespace blink | 84 } // namespace blink |
| 63 | 85 |
| 64 #endif // ColorSpace_h | 86 #endif // ColorSpace_h |
| OLD | NEW |