Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Side by Side Diff: Source/core/svg/graphics/SVGImage.cpp

Issue 104023007: Refactoring ImageBuffer to decouple it from Canvas2DLayerBridge (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase mayhem Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/svg/SVGRenderingContext.cpp ('k') | Source/platform/blink_platform.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 scaledSrc.setSize(adjustedSrcSize); 185 scaledSrc.setSize(adjustedSrcSize);
186 186
187 draw(context, dstRect, scaledSrc, compositeOp, blendMode); 187 draw(context, dstRect, scaledSrc, compositeOp, blendMode);
188 } 188 }
189 189
190 PassRefPtr<NativeImageSkia> SVGImage::nativeImageForCurrentFrame() 190 PassRefPtr<NativeImageSkia> SVGImage::nativeImageForCurrentFrame()
191 { 191 {
192 if (!m_page) 192 if (!m_page)
193 return 0; 193 return 0;
194 194
195 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(size(), 1); 195 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(size());
196 if (!buffer) // failed to allocate image 196 if (!buffer)
197 return 0; 197 return 0;
198 198
199 drawForContainer(buffer->context(), size(), 1, rect(), rect(), CompositeSour ceOver, blink::WebBlendModeNormal); 199 drawForContainer(buffer->context(), size(), 1, rect(), rect(), CompositeSour ceOver, blink::WebBlendModeNormal);
200 200
201 // FIXME: WK(Bug 113657): We should use DontCopyBackingStore here. 201 // FIXME: WK(Bug 113657): We should use DontCopyBackingStore here.
202 return buffer->copyImage(CopyBackingStore)->nativeImageForCurrentFrame(); 202 return buffer->copyImage(CopyBackingStore)->nativeImageForCurrentFrame();
203 } 203 }
204 204
205 void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize containerSize, float zoom, const FloatRect& srcRect, 205 void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize containerSize, float zoom, const FloatRect& srcRect,
206 const FloatSize& scale, const FloatPoint& phase, CompositeOperator composite Op, const FloatRect& dstRect, blink::WebBlendMode blendMode, const IntSize& repe atSpacing) 206 const FloatSize& scale, const FloatPoint& phase, CompositeOperator composite Op, const FloatRect& dstRect, blink::WebBlendMode blendMode, const IntSize& repe atSpacing)
207 { 207 {
208 FloatRect zoomedContainerRect = FloatRect(FloatPoint(), containerSize); 208 FloatRect zoomedContainerRect = FloatRect(FloatPoint(), containerSize);
209 zoomedContainerRect.scale(zoom); 209 zoomedContainerRect.scale(zoom);
210 210
211 // The ImageBuffer size needs to be scaled to match the final resolution. 211 // The ImageBuffer size needs to be scaled to match the final resolution.
212 // FIXME: No need to get the full CTM here, we just need the scale. 212 // FIXME: No need to get the full CTM here, we just need the scale.
213 AffineTransform transform = context->getCTM(); 213 AffineTransform transform = context->getCTM();
214 FloatSize imageBufferScale = FloatSize(transform.xScale(), transform.yScale( )); 214 FloatSize imageBufferScale = FloatSize(transform.xScale(), transform.yScale( ));
215 ASSERT(imageBufferScale.width()); 215 ASSERT(imageBufferScale.width());
216 ASSERT(imageBufferScale.height()); 216 ASSERT(imageBufferScale.height());
217 217
218 FloatSize scaleWithoutCTM(scale.width() / imageBufferScale.width(), scale.he ight() / imageBufferScale.height()); 218 FloatSize scaleWithoutCTM(scale.width() / imageBufferScale.width(), scale.he ight() / imageBufferScale.height());
219 219
220 FloatRect imageBufferSize = zoomedContainerRect; 220 FloatRect imageBufferSize = zoomedContainerRect;
221 imageBufferSize.scale(imageBufferScale.width(), imageBufferScale.height()); 221 imageBufferSize.scale(imageBufferScale.width(), imageBufferScale.height());
222 222
223 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(expandedIntSize(imageBuffer Size.size()), 1); 223 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(expandedIntSize(imageBuffer Size.size()));
224 if (!buffer) // Failed to allocate buffer. 224 if (!buffer) // Failed to allocate buffer.
225 return; 225 return;
226
226 drawForContainer(buffer->context(), containerSize, zoom, imageBufferSize, zo omedContainerRect, CompositeSourceOver, blink::WebBlendModeNormal); 227 drawForContainer(buffer->context(), containerSize, zoom, imageBufferSize, zo omedContainerRect, CompositeSourceOver, blink::WebBlendModeNormal);
227 RefPtr<Image> image = buffer->copyImage(DontCopyBackingStore, Unscaled); 228 RefPtr<Image> image = buffer->copyImage(DontCopyBackingStore, Unscaled);
228 229
229 // Adjust the source rect and transform due to the image buffer's scaling. 230 // Adjust the source rect and transform due to the image buffer's scaling.
230 FloatRect scaledSrcRect = srcRect; 231 FloatRect scaledSrcRect = srcRect;
231 scaledSrcRect.scale(imageBufferScale.width(), imageBufferScale.height()); 232 scaledSrcRect.scale(imageBufferScale.width(), imageBufferScale.height());
232 233
233 image->drawPattern(context, scaledSrcRect, scaleWithoutCTM, phase, composite Op, dstRect, blendMode, repeatSpacing); 234 image->drawPattern(context, scaledSrcRect, scaleWithoutCTM, phase, composite Op, dstRect, blendMode, repeatSpacing);
234 } 235 }
235 236
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 409
409 return m_page; 410 return m_page;
410 } 411 }
411 412
412 String SVGImage::filenameExtension() const 413 String SVGImage::filenameExtension() const
413 { 414 {
414 return "svg"; 415 return "svg";
415 } 416 }
416 417
417 } 418 }
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/SVGRenderingContext.cpp ('k') | Source/platform/blink_platform.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698