Changeset 40063 in webkit
- Timestamp:
- Jan 20, 2009 11:52:10 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 4 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r40051 r40063 1 2009-01-20 Dirk Schulze <krit@webkit.org> 2 3 Reviewed by Nikolas Zimmermann. 4 5 stroke-pattern is wrong and coords-units-01-b match the behavior of 6 batik and Firefox. 7 8 * platform/mac/svg/W3C-SVG-1.1/coords-units-01-b-expected.checksum: 9 * platform/mac/svg/W3C-SVG-1.1/coords-units-01-b-expected.png: 10 * platform/mac/svg/custom/stroked-pattern-expected.checksum: 11 * platform/mac/svg/custom/stroked-pattern-expected.png: 12 1 13 2009-01-19 Simon Fraser <simon.fraser@apple.com> 2 14 -
trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/coords-units-01-b-expected.checksum
r38121 r40063 1 eefe528f058ea5d9c1410f90d497656f 1 5bf54d0647c985b448ad2aca7aa9e389 -
trunk/LayoutTests/platform/mac/svg/custom/stroked-pattern-expected.checksum
r38008 r40063 1 05e5e91f267142becd5b7004c591cd0e 1 93364011085c58d8a5988263423f38e2 -
trunk/WebCore/ChangeLog
r40062 r40063 1 2009-01-20 Dirk Schulze <krit@webkit.org> 2 3 Reviewed by Nikolas Zimmermann. 4 5 Make SVG pattern platform independent and remove platform code. 6 7 Make SVGPattern platform independent 8 https://bugs.webkit.org/show_bug.cgi?id=21205 9 10 * GNUmakefile.am: 11 * WebCore.pro: 12 * WebCore.vcproj/WebCore.vcproj: 13 * WebCore.xcodeproj/project.pbxproj: 14 * platform/graphics/GraphicsContext.h: 15 * platform/graphics/cg/GraphicsContextCG.cpp: 16 (WebCore::GraphicsContext::applyStrokePattern): 17 (WebCore::GraphicsContext::applyFillPattern): 18 (WebCore::GraphicsContext::drawPath): 19 (WebCore::GraphicsContext::fillPath): 20 (WebCore::GraphicsContext::strokePath): 21 (WebCore::GraphicsContext::fillRect): 22 (WebCore::GraphicsContext::strokeRect): 23 * svg/graphics/SVGPaintServerPattern.cpp: 24 (WebCore::SVGPaintServerPattern::SVGPaintServerPattern): 25 (WebCore::SVGPaintServerPattern::~SVGPaintServerPattern): 26 (WebCore::SVGPaintServerPattern::setup): 27 (WebCore::SVGPaintServerPattern::renderPath): 28 (WebCore::SVGPaintServerPattern::teardown): 29 * svg/graphics/SVGPaintServerPattern.h: 30 * svg/graphics/cairo/SVGPaintServerPatternCairo.cpp: Removed. 31 * svg/graphics/cg/SVGPaintServerPatternCg.cpp: Removed. 32 * svg/graphics/qt/SVGPaintServerPatternQt.cpp: Removed. 33 * svg/graphics/skia/SVGPaintServerPatternSkia.cpp: Removed. 34 1 35 2009-01-20 Darin Fisher <darin@chromium.org> 2 36 -
trunk/WebCore/GNUmakefile.am
r40044 r40063 2837 2837 webcoregtk_sources += \ 2838 2838 WebCore/svg/graphics/cairo/SVGPaintServerCairo.cpp \ 2839 WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp \2840 2839 WebCore/svg/graphics/cairo/SVGResourceFilterCairo.cpp \ 2841 2840 WebCore/svg/graphics/cairo/SVGResourceMaskerCairo.cpp -
trunk/WebCore/WebCore.pro
r40039 r40063 1797 1797 1798 1798 SOURCES += \ 1799 svg/graphics/qt/SVGPaintServerPatternQt.cpp \1800 1799 svg/graphics/qt/SVGPaintServerQt.cpp \ 1801 1800 svg/graphics/qt/SVGResourceFilterQt.cpp \ -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r40052 r40063 15449 15449 </File> 15450 15450 <File 15451 RelativePath="..\svg\graphics\cg\SVGPaintServerPatternCg.cpp"15452 >15453 <FileConfiguration15454 Name="Debug_Cairo|Win32"15455 ExcludedFromBuild="true"15456 >15457 <Tool15458 Name="VCCLCompilerTool"15459 />15460 </FileConfiguration>15461 <FileConfiguration15462 Name="Release_Cairo|Win32"15463 ExcludedFromBuild="true"15464 >15465 <Tool15466 Name="VCCLCompilerTool"15467 />15468 </FileConfiguration>15469 </File>15470 <File15471 15451 RelativePath="..\svg\graphics\cg\SVGResourceFilterCg.cpp" 15472 15452 > … … 15670 15650 <File 15671 15651 RelativePath="..\svg\graphics\cairo\SVGPaintServerCairo.cpp" 15672 >15673 <FileConfiguration15674 Name="Debug|Win32"15675 ExcludedFromBuild="true"15676 >15677 <Tool15678 Name="VCCLCompilerTool"15679 />15680 </FileConfiguration>15681 <FileConfiguration15682 Name="Release|Win32"15683 ExcludedFromBuild="true"15684 >15685 <Tool15686 Name="VCCLCompilerTool"15687 />15688 </FileConfiguration>15689 <FileConfiguration15690 Name="Debug_Internal|Win32"15691 ExcludedFromBuild="true"15692 >15693 <Tool15694 Name="VCCLCompilerTool"15695 />15696 </FileConfiguration>15697 <FileConfiguration15698 Name="Release_PGO|Win32"15699 ExcludedFromBuild="true"15700 >15701 <Tool15702 Name="VCCLCompilerTool"15703 />15704 </FileConfiguration>15705 </File>15706 <File15707 RelativePath="..\svg\graphics\cairo\SVGPaintServerPatternCairo.cpp"15708 15652 > 15709 15653 <FileConfiguration -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r40046 r40063 3205 3205 B24055660B5BE640002A28C0 /* DOMSVGElementInstanceListInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = B24055640B5BE640002A28C0 /* DOMSVGElementInstanceListInternal.h */; }; 3206 3206 B255992F0D00D8BA00BB825C /* SVGPaintServerCg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B25598930D00D8B800BB825C /* SVGPaintServerCg.cpp */; }; 3207 B25599310D00D8BA00BB825C /* SVGPaintServerPatternCg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B25598950D00D8B800BB825C /* SVGPaintServerPatternCg.cpp */; };3208 3207 B25599350D00D8BA00BB825C /* SVGResourceFilterCg.mm in Sources */ = {isa = PBXBuildFile; fileRef = B25598990D00D8B800BB825C /* SVGResourceFilterCg.mm */; }; 3209 3208 B25599370D00D8BA00BB825C /* SVGResourceMaskerCg.mm in Sources */ = {isa = PBXBuildFile; fileRef = B255989B0D00D8B800BB825C /* SVGResourceMaskerCg.mm */; }; … … 7922 7921 B24055640B5BE640002A28C0 /* DOMSVGElementInstanceListInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMSVGElementInstanceListInternal.h; sourceTree = "<group>"; }; 7923 7922 B25598930D00D8B800BB825C /* SVGPaintServerCg.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SVGPaintServerCg.cpp; sourceTree = "<group>"; }; 7924 B25598950D00D8B800BB825C /* SVGPaintServerPatternCg.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SVGPaintServerPatternCg.cpp; sourceTree = "<group>"; };7925 7923 B25598990D00D8B800BB825C /* SVGResourceFilterCg.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = SVGResourceFilterCg.mm; sourceTree = "<group>"; }; 7926 7924 B255989B0D00D8B800BB825C /* SVGResourceMaskerCg.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = SVGResourceMaskerCg.mm; sourceTree = "<group>"; }; … … 12755 12753 children = ( 12756 12754 B25598930D00D8B800BB825C /* SVGPaintServerCg.cpp */, 12757 B25598950D00D8B800BB825C /* SVGPaintServerPatternCg.cpp */,12758 12755 B25598990D00D8B800BB825C /* SVGResourceFilterCg.mm */, 12759 12756 B255989B0D00D8B800BB825C /* SVGResourceMaskerCg.mm */, … … 18196 18193 B25599AA0D00D8BA00BB825C /* SVGPaintServerLinearGradient.cpp in Sources */, 18197 18194 B25599AC0D00D8BA00BB825C /* SVGPaintServerPattern.cpp in Sources */, 18198 B25599310D00D8BA00BB825C /* SVGPaintServerPatternCg.cpp in Sources */,18199 18195 B25599AE0D00D8BA00BB825C /* SVGPaintServerRadialGradient.cpp in Sources */, 18200 18196 B25599B00D00D8BA00BB825C /* SVGPaintServerSolid.cpp in Sources */, -
trunk/WebCore/platform/graphics/GraphicsContext.h
r40007 r40063 163 163 bool shouldAntialias() const; 164 164 165 #if PLATFORM(CG) 166 void applyStrokePattern(); 167 void applyFillPattern(); 168 #endif 169 165 170 void save(); 166 171 void restore(); -
trunk/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
r39981 r40063 390 390 } 391 391 392 static void applyStrokePattern(GraphicsContext* context, Pattern* pattern)393 { 394 CGContextRef cgContext = context->platformContext();395 396 CGPatternRef platformPattern = pattern->createPlatformPattern(context->getCTM());392 void GraphicsContext::applyStrokePattern() 393 { 394 CGContextRef cgContext = platformContext(); 395 396 CGPatternRef platformPattern = m_common->state.strokePattern.get()->createPlatformPattern(getCTM()); 397 397 if (!platformPattern) 398 398 return; … … 407 407 } 408 408 409 static void applyFillPattern(GraphicsContext* context, Pattern* pattern)410 { 411 CGContextRef cgContext = context->platformContext();412 413 CGPatternRef platformPattern = pattern->createPlatformPattern(context->getCTM());409 void GraphicsContext::applyFillPattern() 410 { 411 CGContextRef cgContext = platformContext(); 412 413 CGPatternRef platformPattern = m_common->state.fillPattern.get()->createPlatformPattern(getCTM()); 414 414 if (!platformPattern) 415 415 return; … … 467 467 468 468 if (state.fillColorSpace == PatternColorSpace) 469 applyFillPattern( this, m_common->state.fillPattern.get());469 applyFillPattern(); 470 470 if (state.strokeColorSpace == PatternColorSpace) 471 applyStrokePattern( this, m_common->state.strokePattern.get());471 applyStrokePattern(); 472 472 473 473 CGPathDrawingMode drawingMode; … … 496 496 break; 497 497 case PatternColorSpace: 498 applyFillPattern( this, m_common->state.fillPattern.get());498 applyFillPattern(); 499 499 fillPathWithFillRule(context, fillRule()); 500 500 break; … … 523 523 break; 524 524 case PatternColorSpace: 525 applyStrokePattern( this, m_common->state.strokePattern.get());525 applyStrokePattern(); 526 526 CGContextStrokePath(context); 527 527 break; … … 547 547 break; 548 548 case PatternColorSpace: 549 applyFillPattern( this, m_common->state.fillPattern.get());549 applyFillPattern(); 550 550 CGContextFillRect(context, rect); 551 551 break; … … 784 784 break; 785 785 case PatternColorSpace: 786 applyStrokePattern( this, m_common->state.strokePattern.get());786 applyStrokePattern(); 787 787 CGContextStrokeRectWithWidth(context, r, lineWidth); 788 788 break; -
trunk/WebCore/svg/graphics/SVGPaintServerPattern.cpp
r39635 r40063 1 1 /* 2 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> 3 * 2008 Dirk Schulze <krit@webkit.org> 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 29 30 #include "SVGPaintServerPattern.h" 30 31 32 #include "GraphicsContext.h" 33 #include "Image.h" 31 34 #include "ImageBuffer.h" 35 #include "Pattern.h" 36 #include "RenderObject.h" 32 37 #include "SVGPatternElement.h" 33 38 #include "SVGRenderTreeAsText.h" 39 #include "TransformationMatrix.h" 34 40 35 41 using namespace std; … … 39 45 SVGPaintServerPattern::SVGPaintServerPattern(const SVGPatternElement* owner) 40 46 : m_ownerElement(owner) 41 #if PLATFORM(CG)42 , m_patternSpace(0)43 47 , m_pattern(0) 44 #endif45 48 { 46 49 ASSERT(owner); … … 49 52 SVGPaintServerPattern::~SVGPaintServerPattern() 50 53 { 51 #if PLATFORM(CG)52 CGPatternRelease(m_pattern);53 CGColorSpaceRelease(m_patternSpace);54 #endif55 54 } 56 55 … … 97 96 } 98 97 98 bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const 99 { 100 FloatRect targetRect; 101 if (isPaintingText) { 102 IntRect textBoundary = const_cast<RenderObject*>(object)->absoluteBoundingBoxRect(); 103 targetRect = object->absoluteTransform().inverse().mapRect(textBoundary); 104 } else 105 targetRect = object->relativeBBox(false); 106 107 const SVGRenderStyle* style = object->style()->svgStyle(); 108 bool isFilled = (type & ApplyToFillTargetType) && style->hasFill(); 109 bool isStroked = (type & ApplyToStrokeTargetType) && style->hasStroke(); 110 111 ASSERT(isFilled && !isStroked || !isFilled && isStroked); 112 113 m_ownerElement->buildPattern(targetRect); 114 if (!tile()) 115 return false; 116 117 context->save(); 118 context->translate(patternBoundaries().x(), patternBoundaries().y()); 119 context->concatCTM(patternTransform()); 120 121 ASSERT(!m_pattern); 122 123 IntRect tileRect = tile()->image()->rect(); 124 if (tileRect.width() > patternBoundaries().width() || tileRect.height() > patternBoundaries().height()) { 125 // Draw the first cell of the pattern manually to support overflow="visible" on all platforms. 126 int tileWidth = static_cast<int>(patternBoundaries().width() + 0.5f); 127 int tileHeight = static_cast<int>(patternBoundaries().height() + 0.5f); 128 std::auto_ptr<ImageBuffer> tileImage = ImageBuffer::create(IntSize(tileWidth, tileHeight), false); 129 130 GraphicsContext* tileImageContext = tileImage->context(); 131 132 int numY = static_cast<int>(ceilf(tileRect.height() / tileHeight)) + 1; 133 int numX = static_cast<int>(ceilf(tileRect.width() / tileWidth)) + 1; 134 135 tileImageContext->save(); 136 tileImageContext->translate(-patternBoundaries().width() * numX, -patternBoundaries().height() * numY); 137 for (int i = numY; i > 0; i--) { 138 tileImageContext->translate(0, patternBoundaries().height()); 139 for (int j = numX; j > 0; j--) { 140 tileImageContext->translate(patternBoundaries().width(), 0); 141 tileImageContext->drawImage(tile()->image(), tileRect, tileRect); 142 } 143 tileImageContext->translate(-patternBoundaries().width() * numX, 0); 144 } 145 tileImageContext->restore(); 146 147 m_pattern = Pattern::create(tileImage->image(), true, true); 148 } 149 else 150 m_pattern = Pattern::create(tile()->image(), true, true); 151 152 if (isFilled) { 153 context->setAlpha(style->fillOpacity()); 154 context->setFillPattern(m_pattern); 155 context->setFillRule(style->fillRule()); 156 } 157 if (isStroked) { 158 context->setAlpha(style->strokeOpacity()); 159 context->setStrokePattern(m_pattern); 160 applyStrokeStyleToContext(context, object->style(), object); 161 } 162 163 if (isPaintingText) { 164 context->setTextDrawingMode(isFilled ? cTextFill : cTextStroke); 165 #if PLATFORM(CG) 166 if (isFilled) 167 context->applyFillPattern(); 168 else 169 context->applyStrokePattern(); 170 #endif 171 } 172 173 return true; 174 } 175 176 void SVGPaintServerPattern::renderPath(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const 177 { 178 const SVGRenderStyle* style = path->style()->svgStyle(); 179 180 if ((type & ApplyToFillTargetType) && style->hasFill()) 181 context->fillPath(); 182 183 if ((type & ApplyToStrokeTargetType) && style->hasStroke()) 184 context->strokePath(); 185 } 186 187 void SVGPaintServerPattern::teardown(GraphicsContext*& context, const RenderObject*, SVGPaintTargetType, bool) const 188 { 189 m_pattern = 0; 190 191 context->restore(); 192 } 193 99 194 } // namespace WebCore 100 195 -
trunk/WebCore/svg/graphics/SVGPaintServerPattern.h
r39635 r40063 31 31 #include "TransformationMatrix.h" 32 32 #include "FloatRect.h" 33 #include "Pattern.h" 33 34 #include "SVGPaintServer.h" 34 35 … … 64 65 65 66 virtual bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const; 66 #if PLATFORM(CG) || PLATFORM(QT) 67 virtual void renderPath(GraphicsContext*&, const RenderObject*, SVGPaintTargetType) const; 67 68 virtual void teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const; 68 #endif69 69 70 70 private: … … 76 76 FloatRect m_patternBoundaries; 77 77 78 #if PLATFORM(CG) 79 mutable CGColorSpaceRef m_patternSpace; 80 mutable CGPatternRef m_pattern; 81 #endif 78 mutable RefPtr<Pattern> m_pattern; 82 79 }; 83 80
Note: See TracChangeset
for help on using the changeset viewer.