Changeset 90676 in webkit
- Timestamp:
- Jul 8, 2011 11:05:14 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r90675 r90676 1 2011-07-08 Dirk Schulze <krit@webkit.org> 2 3 Refactoring luminance code in RenderSVGResourceMasker 4 https://bugs.webkit.org/show_bug.cgi?id=64146 5 6 Reviewed by Simon Fraser. 7 8 Moved luminance calculcation code to ImageBuffer. The code is doing pixel manipulations and can now get replaced 9 by platform specific algorithms in the ImmageBuffer*.cpp files. 10 11 No change of functionality. No new tests. 12 13 * WebCore.xcodeproj/project.pbxproj: 14 * platform/graphics/ImageBuffer.cpp: 15 (WebCore::ImageBuffer::transformColorSpace): 16 (WebCore::ImageBuffer::genericConvertToLuminanceMask): 17 (WebCore::ImageBuffer::convertToLuminanceMask): 18 * platform/graphics/ImageBuffer.h: 19 * rendering/svg/RenderSVGResourceMasker.cpp: 20 (WebCore::RenderSVGResourceMasker::drawContentIntoMaskImage): 21 1 22 2011-07-08 Simon Fraser <simon.fraser@apple.com> 2 23 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r90654 r90676 1020 1020 43B9336A13B261B1004584BF /* SVGAnimatedPointList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B9336813B261B1004584BF /* SVGAnimatedPointList.cpp */; }; 1021 1021 43C092BC12D9E4EE00A989C3 /* RenderSVGForeignObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 43C092BA12D9E4EE00A989C3 /* RenderSVGForeignObject.h */; }; 1022 43D2597713C816F400608559 /* ImageBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43D2597613C816F400608559 /* ImageBuffer.cpp */; }; 1022 1023 43F6FD9613BCD0B100224052 /* SVGAnimatedInteger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43F6FD9513BCD0B100224052 /* SVGAnimatedInteger.cpp */; }; 1023 1024 4415292E0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4415292C0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 7518 7519 43C092B912D9E4EE00A989C3 /* RenderSVGForeignObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGForeignObject.cpp; sourceTree = "<group>"; }; 7519 7520 43C092BA12D9E4EE00A989C3 /* RenderSVGForeignObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGForeignObject.h; sourceTree = "<group>"; }; 7521 43D2597613C816F400608559 /* ImageBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageBuffer.cpp; sourceTree = "<group>"; }; 7520 7522 43F6FD9513BCD0B100224052 /* SVGAnimatedInteger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedInteger.cpp; sourceTree = "<group>"; }; 7521 7523 4415292C0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLPlugInImageElement.h; sourceTree = "<group>"; }; … … 18053 18055 B27535410B053814002CE64F /* Image.cpp */, 18054 18056 B27535420B053814002CE64F /* Image.h */, 18057 43D2597613C816F400608559 /* ImageBuffer.cpp */, 18055 18058 B2A10B910B3818BD00099AA4 /* ImageBuffer.h */, 18056 18059 22BD9F7D1353625C009BD102 /* ImageBufferData.h */, … … 25872 25875 43F6FD9613BCD0B100224052 /* SVGAnimatedInteger.cpp in Sources */, 25873 25876 82889B4C13C62392009A6156 /* InspectorStyleTextEditor.cpp in Sources */, 25877 43D2597713C816F400608559 /* ImageBuffer.cpp in Sources */, 25874 25878 ); 25875 25879 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp
r84101 r90676 1 1 /* 2 2 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 3 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 27 28 #include "ImageBuffer.h" 28 29 29 #if !USE(CG) 30 31 #include <math.h> 30 #include <wtf/MathExtras.h> 32 31 33 32 namespace WebCore { 34 33 34 #if !USE(CG) 35 35 void ImageBuffer::transformColorSpace(ColorSpace srcColorSpace, ColorSpace dstColorSpace) 36 36 { … … 39 39 40 40 // only sRGB <-> linearRGB are supported at the moment 41 if ((srcColorSpace != ColorSpaceLinearRGB && srcColorSpace != ColorSpaceDeviceRGB) 41 if ((srcColorSpace != ColorSpaceLinearRGB && srcColorSpace != ColorSpaceDeviceRGB) 42 42 || (dstColorSpace != ColorSpaceLinearRGB && dstColorSpace != ColorSpaceDeviceRGB)) 43 43 return; … … 67 67 } 68 68 } 69 #endif // USE(CG) 70 71 inline void ImageBuffer::genericConvertToLuminanceMask() 72 { 73 IntRect luminanceRect(IntPoint(), size()); 74 RefPtr<ByteArray> srcPixelArray = getUnmultipliedImageData(luminanceRect); 75 76 unsigned pixelArrayLength = srcPixelArray->length(); 77 for (unsigned pixelOffset = 0; pixelOffset < pixelArrayLength; pixelOffset += 4) { 78 unsigned char a = srcPixelArray->get(pixelOffset + 3); 79 if (!a) 80 continue; 81 unsigned char r = srcPixelArray->get(pixelOffset); 82 unsigned char g = srcPixelArray->get(pixelOffset + 1); 83 unsigned char b = srcPixelArray->get(pixelOffset + 2); 84 85 double luma = (r * 0.2125 + g * 0.7154 + b * 0.0721) * ((double)a / 255.0); 86 srcPixelArray->set(pixelOffset + 3, luma); 87 } 88 putUnmultipliedImageData(srcPixelArray.get(), luminanceRect.size(), luminanceRect, IntPoint()); 89 } 90 91 void ImageBuffer::convertToLuminanceMask() 92 { 93 // Add platform specific functions with platformConvertToLuminanceMask here later. 94 genericConvertToLuminanceMask(); 95 } 69 96 70 97 } 71 72 #endif // USE(CG) -
trunk/Source/WebCore/platform/graphics/ImageBuffer.h
r85603 r90676 93 93 void putPremultipliedImageData(ByteArray*, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint); 94 94 95 void convertToLuminanceMask(); 96 95 97 String toDataURL(const String& mimeType, const double* quality = 0) const; 96 98 #if !USE(CG) … … 110 112 void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform, 111 113 const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect); 114 115 inline void genericConvertToLuminanceMask(); 116 112 117 friend class GraphicsContext; 113 118 friend class GeneratedImage; -
trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp
r84101 r90676 160 160 161 161 // Create the luminance mask. 162 IntRect maskImageRect(IntPoint(), maskerData->maskImage->size()); 163 RefPtr<ByteArray> srcPixelArray = maskerData->maskImage->getUnmultipliedImageData(maskImageRect); 164 165 unsigned pixelArrayLength = srcPixelArray->length(); 166 for (unsigned pixelOffset = 0; pixelOffset < pixelArrayLength; pixelOffset += 4) { 167 unsigned char a = srcPixelArray->get(pixelOffset + 3); 168 if (!a) 169 continue; 170 unsigned char r = srcPixelArray->get(pixelOffset); 171 unsigned char g = srcPixelArray->get(pixelOffset + 1); 172 unsigned char b = srcPixelArray->get(pixelOffset + 2); 173 174 double luma = (r * 0.2125 + g * 0.7154 + b * 0.0721) * ((double)a / 255.0); 175 srcPixelArray->set(pixelOffset + 3, luma); 176 } 177 178 maskerData->maskImage->putUnmultipliedImageData(srcPixelArray.get(), maskImageRect.size(), maskImageRect, IntPoint()); 162 maskerData->maskImage->convertToLuminanceMask(); 179 163 } 180 164
Note: See TracChangeset
for help on using the changeset viewer.