OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> | 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> |
3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. |
4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 if (!buffer) // failed to allocate image | 152 if (!buffer) // failed to allocate image |
153 return 0; | 153 return 0; |
154 | 154 |
155 drawForContainer(buffer->context(), size(), 1, rect(), rect(), CompositeSour
ceOver, BlendModeNormal); | 155 drawForContainer(buffer->context(), size(), 1, rect(), rect(), CompositeSour
ceOver, BlendModeNormal); |
156 | 156 |
157 // FIXME: WK(Bug 113657): We should use DontCopyBackingStore here. | 157 // FIXME: WK(Bug 113657): We should use DontCopyBackingStore here. |
158 return buffer->copyImage(CopyBackingStore)->nativeImageForCurrentFrame(); | 158 return buffer->copyImage(CopyBackingStore)->nativeImageForCurrentFrame(); |
159 } | 159 } |
160 | 160 |
161 void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize
containerSize, float zoom, const FloatRect& srcRect, | 161 void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize
containerSize, float zoom, const FloatRect& srcRect, |
162 const FloatSize& scale, const FloatPoint& phase, CompositeOperator composite
Op, const FloatRect& dstRect) | 162 const FloatSize& scale, const FloatPoint& phase, CompositeOperator composite
Op, const FloatRect& dstRect, BlendMode blendMode) |
163 { | 163 { |
164 FloatRect zoomedContainerRect = FloatRect(FloatPoint(), containerSize); | 164 FloatRect zoomedContainerRect = FloatRect(FloatPoint(), containerSize); |
165 zoomedContainerRect.scale(zoom); | 165 zoomedContainerRect.scale(zoom); |
166 | 166 |
167 // The ImageBuffer size needs to be scaled to match the final resolution. | 167 // The ImageBuffer size needs to be scaled to match the final resolution. |
168 // FIXME: No need to get the full CTM here, we just need the scale. | 168 // FIXME: No need to get the full CTM here, we just need the scale. |
169 AffineTransform transform = context->getCTM(); | 169 AffineTransform transform = context->getCTM(); |
170 FloatSize imageBufferScale = FloatSize(transform.xScale(), transform.yScale(
)); | 170 FloatSize imageBufferScale = FloatSize(transform.xScale(), transform.yScale(
)); |
171 ASSERT(imageBufferScale.width()); | 171 ASSERT(imageBufferScale.width()); |
172 ASSERT(imageBufferScale.height()); | 172 ASSERT(imageBufferScale.height()); |
173 | 173 |
174 FloatSize scaleWithoutCTM(scale.width() / imageBufferScale.width(), scale.he
ight() / imageBufferScale.height()); | 174 FloatSize scaleWithoutCTM(scale.width() / imageBufferScale.width(), scale.he
ight() / imageBufferScale.height()); |
175 | 175 |
176 FloatRect imageBufferSize = zoomedContainerRect; | 176 FloatRect imageBufferSize = zoomedContainerRect; |
177 imageBufferSize.scale(imageBufferScale.width(), imageBufferScale.height()); | 177 imageBufferSize.scale(imageBufferScale.width(), imageBufferScale.height()); |
178 | 178 |
179 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(expandedIntSize(imageBuffer
Size.size()), 1); | 179 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(expandedIntSize(imageBuffer
Size.size()), 1); |
180 if (!buffer) // Failed to allocate buffer. | 180 if (!buffer) // Failed to allocate buffer. |
181 return; | 181 return; |
182 drawForContainer(buffer->context(), containerSize, zoom, imageBufferSize, zo
omedContainerRect, CompositeSourceOver, BlendModeNormal); | 182 drawForContainer(buffer->context(), containerSize, zoom, imageBufferSize, zo
omedContainerRect, CompositeSourceOver, BlendModeNormal); |
183 RefPtr<Image> image = buffer->copyImage(DontCopyBackingStore, Unscaled); | 183 RefPtr<Image> image = buffer->copyImage(DontCopyBackingStore, Unscaled); |
184 | 184 |
185 // Adjust the source rect and transform due to the image buffer's scaling. | 185 // Adjust the source rect and transform due to the image buffer's scaling. |
186 FloatRect scaledSrcRect = srcRect; | 186 FloatRect scaledSrcRect = srcRect; |
187 scaledSrcRect.scale(imageBufferScale.width(), imageBufferScale.height()); | 187 scaledSrcRect.scale(imageBufferScale.width(), imageBufferScale.height()); |
188 | 188 |
189 image->drawPattern(context, scaledSrcRect, scaleWithoutCTM, phase, composite
Op, dstRect); | 189 image->drawPattern(context, scaledSrcRect, scaleWithoutCTM, phase, composite
Op, dstRect, blendMode); |
190 } | 190 } |
191 | 191 |
192 void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const Fl
oatRect& srcRect, CompositeOperator compositeOp, BlendMode blendMode) | 192 void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const Fl
oatRect& srcRect, CompositeOperator compositeOp, BlendMode blendMode) |
193 { | 193 { |
194 if (!m_page) | 194 if (!m_page) |
195 return; | 195 return; |
196 | 196 |
197 FrameView* view = frameView(); | 197 FrameView* view = frameView(); |
198 | 198 |
199 GraphicsContextStateSaver stateSaver(*context); | 199 GraphicsContextStateSaver stateSaver(*context); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 return m_page; | 364 return m_page; |
365 } | 365 } |
366 | 366 |
367 String SVGImage::filenameExtension() const | 367 String SVGImage::filenameExtension() const |
368 { | 368 { |
369 return "svg"; | 369 return "svg"; |
370 } | 370 } |
371 | 371 |
372 } | 372 } |
373 | 373 |
OLD | NEW |