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

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

Issue 12314169: Merge 143541 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1410/
Patch Set: Created 7 years, 9 months 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
« no previous file with comments | « Source/WebCore/svg/graphics/SVGImage.h ('k') | Source/WebCore/svg/graphics/SVGImageCache.cpp » ('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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // Compensate for the container size rounding by adjusting the source rect. 134 // Compensate for the container size rounding by adjusting the source rect.
135 FloatSize adjustedSrcSize = scaledSrc.size(); 135 FloatSize adjustedSrcSize = scaledSrc.size();
136 adjustedSrcSize.scale(roundedContainerSize.width() / containerSize.width(), roundedContainerSize.height() / containerSize.height()); 136 adjustedSrcSize.scale(roundedContainerSize.width() / containerSize.width(), roundedContainerSize.height() / containerSize.height());
137 scaledSrc.setSize(adjustedSrcSize); 137 scaledSrc.setSize(adjustedSrcSize);
138 138
139 draw(context, dstRect, scaledSrc, colorSpace, compositeOp, blendMode); 139 draw(context, dstRect, scaledSrc, colorSpace, compositeOp, blendMode);
140 140
141 setImageObserver(observer); 141 setImageObserver(observer);
142 } 142 }
143 143
144 void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize containerSize, float pageScale, float zoom, const FloatRect& srcRect, 144 void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize containerSize, float zoom, const FloatRect& srcRect,
145 const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace colorSpace, CompositeOperator compositeOp, const FloatRect& dstRect) 145 const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace colorSpace, CompositeOperator compositeOp, const FloatRect& dstRect)
146 { 146 {
147 ASSERT(pageScale);
148
149 FloatRect zoomedContainerRect = FloatRect(FloatPoint(), containerSize); 147 FloatRect zoomedContainerRect = FloatRect(FloatPoint(), containerSize);
150 zoomedContainerRect.scale(zoom); 148 zoomedContainerRect.scale(zoom);
151 FloatRect zoomedAndScaledContainerRect = zoomedContainerRect;
152 zoomedAndScaledContainerRect.scale(pageScale);
153 149
154 // FIXME(WK110065): This should take advantage of the ImageBuffer resolution instead of scaling the buffer manually. 150 // The ImageBuffer size needs to be scaled to match the final resolution.
155 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(expandedIntSize(zoomedAndSc aledContainerRect.size()), 1); 151 AffineTransform transform = context->getCTM();
156 drawForContainer(buffer->context(), containerSize, zoom, zoomedAndScaledCont ainerRect, zoomedContainerRect, ColorSpaceDeviceRGB, CompositeSourceOver, BlendM odeNormal); 152 FloatSize imageBufferScale = FloatSize(transform.xScale(), transform.yScale( ));
153 ASSERT(imageBufferScale.width());
154 ASSERT(imageBufferScale.height());
155
156 FloatRect imageBufferSize = zoomedContainerRect;
157 imageBufferSize.scale(imageBufferScale.width(), imageBufferScale.height());
158
159 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(expandedIntSize(imageBuffer Size.size()), 1);
160 drawForContainer(buffer->context(), containerSize, zoom, imageBufferSize, zo omedContainerRect, ColorSpaceDeviceRGB, CompositeSourceOver, BlendModeNormal);
157 RefPtr<Image> image = buffer->copyImage(CopyBackingStore, Unscaled); 161 RefPtr<Image> image = buffer->copyImage(CopyBackingStore, Unscaled);
158 162
159 // Adjust the source rect and transform for image buffer scale due to pageSc ale. 163 // Adjust the source rect and transform due to the image buffer's scaling.
160 FloatRect scaledSrcRect = srcRect; 164 FloatRect scaledSrcRect = srcRect;
161 scaledSrcRect.scale(pageScale); 165 scaledSrcRect.scale(imageBufferScale.width(), imageBufferScale.height());
162 AffineTransform unscaledPatternTransform(patternTransform); 166 AffineTransform unscaledPatternTransform(patternTransform);
163 unscaledPatternTransform.scale(1 / pageScale); 167 unscaledPatternTransform.scale(1 / imageBufferScale.width(), 1 / imageBuffer Scale.height());
164 168
165 image->drawPattern(context, scaledSrcRect, unscaledPatternTransform, phase, colorSpace, compositeOp, dstRect); 169 image->drawPattern(context, scaledSrcRect, unscaledPatternTransform, phase, colorSpace, compositeOp, dstRect);
166 } 170 }
167 171
168 void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const Fl oatRect& srcRect, ColorSpace, CompositeOperator compositeOp, BlendMode) 172 void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const Fl oatRect& srcRect, ColorSpace, CompositeOperator compositeOp, BlendMode)
169 { 173 {
170 if (!m_page) 174 if (!m_page)
171 return; 175 return;
172 176
173 FrameView* view = frameView(); 177 FrameView* view = frameView();
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 { 350 {
347 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CachedResou rceImage); 351 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CachedResou rceImage);
348 Image::reportMemoryUsage(memoryObjectInfo); 352 Image::reportMemoryUsage(memoryObjectInfo);
349 info.addMember(m_chromeClient, "chromeClient"); 353 info.addMember(m_chromeClient, "chromeClient");
350 info.addMember(m_page, "page"); 354 info.addMember(m_page, "page");
351 } 355 }
352 356
353 } 357 }
354 358
355 #endif // ENABLE(SVG) 359 #endif // ENABLE(SVG)
OLDNEW
« no previous file with comments | « Source/WebCore/svg/graphics/SVGImage.h ('k') | Source/WebCore/svg/graphics/SVGImageCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698