File indexing completed on 2024-05-12 11:51:55
0001 /* 0002 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> 0003 * 0004 * Redistribution and use in source and binary forms, with or without 0005 * modification, are permitted provided that the following conditions 0006 * are met: 0007 * 1. Redistributions of source code must retain the above copyright 0008 * notice, this list of conditions and the following disclaimer. 0009 * 2. Redistributions in binary form must reproduce the above copyright 0010 * notice, this list of conditions and the following disclaimer in the 0011 * documentation and/or other materials provided with the distribution. 0012 * 0013 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 0014 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0015 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 0016 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 0017 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 0018 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 0019 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 0020 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 0021 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0022 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0023 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0024 */ 0025 0026 #if ENABLE(SVG) 0027 #include "SVGPaintServerPattern.h" 0028 0029 #include "ImageBuffer.h" 0030 #include "SVGPatternElement.h" 0031 #include "SVGRenderTreeAsText.h" 0032 0033 using namespace std; 0034 0035 namespace WebCore 0036 { 0037 0038 SVGPaintServerPattern::SVGPaintServerPattern(const SVGPatternElement *owner) 0039 : m_ownerElement(owner) 0040 #if PLATFORM(CG) 0041 , m_patternSpace(0) 0042 , m_pattern(0) 0043 #endif 0044 { 0045 ASSERT(owner); 0046 } 0047 0048 SVGPaintServerPattern::~SVGPaintServerPattern() 0049 { 0050 #if PLATFORM(CG) 0051 CGPatternRelease(m_pattern); 0052 CGColorSpaceRelease(m_patternSpace); 0053 #endif 0054 } 0055 0056 FloatRect SVGPaintServerPattern::patternBoundaries() const 0057 { 0058 return m_patternBoundaries; 0059 } 0060 0061 void SVGPaintServerPattern::setPatternBoundaries(const FloatRect &rect) 0062 { 0063 m_patternBoundaries = rect; 0064 } 0065 0066 ImageBuffer *SVGPaintServerPattern::tile() const 0067 { 0068 return m_tile.get(); 0069 } 0070 0071 void SVGPaintServerPattern::setTile(unique_ptr<ImageBuffer> tile) 0072 { 0073 m_tile.set(tile.release()); 0074 } 0075 0076 AffineTransform SVGPaintServerPattern::patternTransform() const 0077 { 0078 return m_patternTransform; 0079 } 0080 0081 void SVGPaintServerPattern::setPatternTransform(const AffineTransform &transform) 0082 { 0083 m_patternTransform = transform; 0084 } 0085 0086 TextStream &SVGPaintServerPattern::externalRepresentation(TextStream &ts) const 0087 { 0088 // Gradients/patterns aren't setup, until they are used for painting. Work around that fact. 0089 m_ownerElement->buildPattern(FloatRect(0.0f, 0.0f, 1.0f, 1.0f)); 0090 0091 ts << "[type=PATTERN]" 0092 << " [bbox=" << patternBoundaries() << "]"; 0093 if (!patternTransform().isIdentity()) { 0094 ts << " [pattern transform=" << patternTransform() << "]"; 0095 } 0096 return ts; 0097 } 0098 0099 } // namespace WebCore 0100 0101 #endif