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

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

Issue 323013004: Clean up transform methods in GraphicsContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2nd Attempt Mac build fix Created 6 years, 6 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/core/rendering/svg/SVGRenderingContext.cpp ('k') | Source/platform/DragImage.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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 } 219 }
220 220
221 void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize containerSize, float zoom, const FloatRect& srcRect, 221 void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize containerSize, float zoom, const FloatRect& srcRect,
222 const FloatSize& scale, const FloatPoint& phase, CompositeOperator composite Op, const FloatRect& dstRect, blink::WebBlendMode blendMode, const IntSize& repe atSpacing) 222 const FloatSize& scale, const FloatPoint& phase, CompositeOperator composite Op, const FloatRect& dstRect, blink::WebBlendMode blendMode, const IntSize& repe atSpacing)
223 { 223 {
224 FloatRect zoomedContainerRect = FloatRect(FloatPoint(), containerSize); 224 FloatRect zoomedContainerRect = FloatRect(FloatPoint(), containerSize);
225 zoomedContainerRect.scale(zoom); 225 zoomedContainerRect.scale(zoom);
226 226
227 // The ImageBuffer size needs to be scaled to match the final resolution. 227 // The ImageBuffer size needs to be scaled to match the final resolution.
228 // FIXME: No need to get the full CTM here, we just need the scale. 228 // FIXME: No need to get the full CTM here, we just need the scale.
229 // FIXME: See crbug.com/382491. This scale does not reflect compositor appli ed
230 // scale factors, such a High DPI or device zoom.
229 AffineTransform transform = context->getCTM(); 231 AffineTransform transform = context->getCTM();
230 FloatSize imageBufferScale = FloatSize(transform.xScale(), transform.yScale( )); 232 FloatSize imageBufferScale = FloatSize(transform.xScale(), transform.yScale( ));
231 ASSERT(imageBufferScale.width()); 233 ASSERT(imageBufferScale.width());
232 ASSERT(imageBufferScale.height()); 234 ASSERT(imageBufferScale.height());
233 235
234 FloatSize scaleWithoutCTM(scale.width() / imageBufferScale.width(), scale.he ight() / imageBufferScale.height()); 236 FloatSize scaleWithoutCTM(scale.width() / imageBufferScale.width(), scale.he ight() / imageBufferScale.height());
235 237
236 FloatRect imageBufferSize = zoomedContainerRect; 238 FloatRect imageBufferSize = zoomedContainerRect;
237 imageBufferSize.scale(imageBufferScale.width(), imageBufferScale.height()); 239 imageBufferSize.scale(imageBufferScale.width(), imageBufferScale.height());
238 240
(...skipping 30 matching lines...) Expand all
269 } 271 }
270 272
271 FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / srcRec t.height()); 273 FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / srcRec t.height());
272 274
273 // We can only draw the entire frame, clipped to the rect we want. So comput e where the top left 275 // We can only draw the entire frame, clipped to the rect we want. So comput e where the top left
274 // of the image would be if we were drawing without clipping, and translate accordingly. 276 // of the image would be if we were drawing without clipping, and translate accordingly.
275 FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect.loca tion().y() * scale.height()); 277 FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect.loca tion().y() * scale.height());
276 FloatPoint destOffset = dstRect.location() - topLeftOffset; 278 FloatPoint destOffset = dstRect.location() - topLeftOffset;
277 279
278 context->translate(destOffset.x(), destOffset.y()); 280 context->translate(destOffset.x(), destOffset.y());
279 context->scale(scale); 281 context->scale(scale.width(), scale.height());
280 282
281 FrameView* view = frameView(); 283 FrameView* view = frameView();
282 view->resize(containerSize()); 284 view->resize(containerSize());
283 285
284 if (!m_url.isEmpty()) 286 if (!m_url.isEmpty())
285 view->scrollToFragment(m_url); 287 view->scrollToFragment(m_url);
286 288
287 if (view->needsLayout()) 289 if (view->needsLayout())
288 view->layout(); 290 view->layout();
289 291
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 424
423 return m_page; 425 return m_page;
424 } 426 }
425 427
426 String SVGImage::filenameExtension() const 428 String SVGImage::filenameExtension() const
427 { 429 {
428 return "svg"; 430 return "svg";
429 } 431 }
430 432
431 } 433 }
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/SVGRenderingContext.cpp ('k') | Source/platform/DragImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698