Changeset 226315 in webkit
- Timestamp:
- Jan 1, 2018, 11:53:39 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r226309 r226315 1 2017-12-30 Simon Fraser <simon.fraser@apple.com> 2 3 SVG lighting colors need to be converted into linearSRGB 4 https://bugs.webkit.org/show_bug.cgi?id=181196 5 6 Reviewed by Dan Bates. 7 8 Compare a far-away green spotlight with a green flood. The bottom right pixel always 9 has the wrong color (webkit.org/b/181203), so mask it out. 10 11 * svg/filters/feSpotLight-color-expected.svg: Added. 12 * svg/filters/feSpotLight-color.svg: Added. 13 1 14 2017-12-28 Zalan Bujtas <zalan@apple.com> 2 15 -
trunk/Source/WebCore/ChangeLog
r226314 r226315 1 2017-12-30 Simon Fraser <simon.fraser@apple.com> 2 3 SVG lighting colors need to be converted into linearSRGB 4 https://bugs.webkit.org/show_bug.cgi?id=181196 5 6 Reviewed by Dan Bates. 7 8 SVG filters, like feLighting, that poke values directly into buffers rather than going 9 through CG like feFlood, need to convert colors into the operating color space. So add 10 conversion functions to go between linear and sRGB colors, and use these in feLighting, 11 and in ImageBuffer (which is only used for non-CG platforms). 12 13 Tests: svg/filters/feSpotLight-color.svg 14 15 * platform/graphics/ColorUtilities.cpp: 16 (WebCore::linearToSRGBColorComponent): 17 (WebCore::sRGBToLinearColorComponent): 18 (WebCore::linearToSRGBColor): 19 (WebCore::sRGBToLinearColor): 20 * platform/graphics/ColorUtilities.h: 21 * platform/graphics/ImageBuffer.cpp: 22 (WebCore::ImageBuffer::transformColorSpace): 23 * platform/graphics/filters/FELighting.cpp: 24 (WebCore::FELighting::drawLighting): 25 1 26 2017-12-31 Jiewen Tan <jiewen_tan@apple.com> 2 27 -
trunk/Source/WebCore/platform/graphics/ColorUtilities.cpp
r225009 r226315 27 27 #include "ColorUtilities.h" 28 28 29 #include "Color.h" 30 #include <wtf/MathExtras.h> 31 29 32 namespace WebCore { 30 33 … … 37 40 } 38 41 42 // These are the standard sRGB <-> linearRGB conversion functions (https://en.wikipedia.org/wiki/SRGB). 43 float linearToSRGBColorComponent(float c) 44 { 45 if (c < 0.0031308) 46 return 12.92 * c; 47 48 return clampTo<float>(1.055 * powf(c, 1.0 / 2.4) - 0.055, 0, 1); 49 } 50 51 float sRGBToLinearColorComponent(float c) 52 { 53 if (c <= 0.04045) 54 return c / 12.92; 55 56 return clampTo<float>(powf((c + 0.055) / 1.055, 2.4), 0, 1); 57 } 58 59 Color linearToSRGBColor(const Color& color) 60 { 61 float r, g, b, a; 62 color.getRGBA(r, g, b, a); 63 r = linearToSRGBColorComponent(r); 64 g = linearToSRGBColorComponent(g); 65 b = linearToSRGBColorComponent(b); 66 67 return Color(r, g, b, a); 68 } 69 70 Color sRGBToLinearColor(const Color& color) 71 { 72 float r, g, b, a; 73 color.getRGBA(r, g, b, a); 74 r = sRGBToLinearColorComponent(r); 75 g = sRGBToLinearColorComponent(g); 76 b = sRGBToLinearColorComponent(b); 77 78 return Color(r, g, b, a); 79 } 80 39 81 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/ColorUtilities.h
r225183 r226315 26 26 #pragma once 27 27 28 #include "Color.h" 28 29 #include <algorithm> 29 30 #include <math.h> … … 148 149 } 149 150 151 // 0-1 components, result is clamped. 152 float linearToSRGBColorComponent(float); 153 float sRGBToLinearColorComponent(float); 154 155 Color linearToSRGBColor(const Color&); 156 Color sRGBToLinearColor(const Color&); 157 150 158 } // namespace WebCore 151 159 -
trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp
r225797 r226315 29 29 #include "ImageBuffer.h" 30 30 31 #include "ColorUtilities.h" 31 32 #include "GraphicsContext.h" 32 33 #include "IntRect.h" … … 136 137 for (unsigned i = 0; i < 256; i++) { 137 138 float color = i / 255.0f; 138 color = (color <= 0.04045f ? color / 12.92f : pow((color + 0.055f) / 1.055f, 2.4f)); 139 color = std::max(0.0f, color); 140 color = std::min(1.0f, color); 139 color = sRGBToLinearColorComponent(color); 141 140 array[i] = static_cast<uint8_t>(round(color * 255)); 142 141 } … … 149 148 for (unsigned i = 0; i < 256; i++) { 150 149 float color = i / 255.0f; 151 color = (powf(color, 1.0f / 2.4f) * 1.055f) - 0.055f; 152 color = std::max(0.0f, color); 153 color = std::min(1.0f, color); 150 color = linearToSRGBColorComponent(color); 154 151 array[i] = static_cast<uint8_t>(round(color * 255)); 155 152 } -
trunk/Source/WebCore/platform/graphics/filters/FELighting.cpp
r225147 r226315 28 28 #include "FELighting.h" 29 29 30 #include "ColorUtilities.h" 30 31 #include "FELightingNEON.h" 31 32 #include <wtf/ParallelJobs.h> … … 398 399 data.widthDecreasedByOne = width - 1; 399 400 data.heightDecreasedByOne = height - 1; 400 paintingData.intialLightingData.colorVector = FloatPoint3D(m_lightingColor.red(), m_lightingColor.green(), m_lightingColor.blue()); 401 402 Color lightColor = (operatingColorSpace() == ColorSpaceLinearRGB) ? sRGBToLinearColor(m_lightingColor) : m_lightingColor; 403 paintingData.intialLightingData.colorVector = FloatPoint3D(lightColor.red(), lightColor.green(), lightColor.blue()); 401 404 m_lightSource->initPaintingData(paintingData); 402 405
Note:
See TracChangeset
for help on using the changeset viewer.