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

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

Issue 1996363003: Avoid calling updateAllLifecyclePhasesExceptPaint in SVGImage if not needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 if (!m_page) 331 if (!m_page)
332 return; 332 return;
333 333
334 drawInternal(canvas, paint, dstRect, srcRect, shouldRespectImageOrientation, clampMode, KURL()); 334 drawInternal(canvas, paint, dstRect, srcRect, shouldRespectImageOrientation, clampMode, KURL());
335 } 335 }
336 336
337 void SVGImage::drawInternal(SkCanvas* canvas, const SkPaint& paint, const FloatR ect& dstRect, const FloatRect& srcRect, 337 void SVGImage::drawInternal(SkCanvas* canvas, const SkPaint& paint, const FloatR ect& dstRect, const FloatRect& srcRect,
338 RespectImageOrientationEnum, ImageClampingMode, const KURL& url) 338 RespectImageOrientationEnum, ImageClampingMode, const KURL& url)
339 { 339 {
340 FrameView* view = frameView(); 340 FrameView* view = frameView();
341 view->resize(containerSize()); 341 bool needsLifecycleUpdateForResize = view->resize(containerSize());
342 342
343 // Always call processUrlFragment, even if the url is empty, because 343 // Always call processUrlFragment, even if the url is empty, because
344 // there may have been a previous url/fragment that needs to be reset. 344 // there may have been a previous url/fragment that needs to be reset.
345 view->processUrlFragment(url); 345 bool needsLifecycleUpdateForUrl = view->processUrlFragment(url);
346
347 bool needsLifecycleUpdate = needsLifecycleUpdateForResize || needsLifecycleU pdateForUrl;
348
349 // This is the lifecycle for the SVG document, not what HTML document might contain it.
350 if (needsLifecycleUpdate)
351 view->updateAllLifecyclePhasesExceptPaint();
fs 2016/05/23 21:25:56 Maybe add some assert too to verify lifecycle assu
346 352
347 SkPictureBuilder imagePicture(dstRect); 353 SkPictureBuilder imagePicture(dstRect);
348 { 354 {
349 ClipRecorder clipRecorder(imagePicture.context(), imagePicture, DisplayI tem::ClipNodeImage, LayoutRect(enclosingIntRect(dstRect))); 355 ClipRecorder clipRecorder(imagePicture.context(), imagePicture, DisplayI tem::ClipNodeImage, LayoutRect(enclosingIntRect(dstRect)));
350 356
351 // We can only draw the entire frame, clipped to the rect we want. So co mpute where the top left 357 // We can only draw the entire frame, clipped to the rect we want. So co mpute where the top left
352 // of the image would be if we were drawing without clipping, and transl ate accordingly. 358 // of the image would be if we were drawing without clipping, and transl ate accordingly.
353 FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / sr cRect.height()); 359 FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / sr cRect.height());
354 FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect. location().y() * scale.height()); 360 FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect. location().y() * scale.height());
355 FloatPoint destOffset = dstRect.location() - topLeftOffset; 361 FloatPoint destOffset = dstRect.location() - topLeftOffset;
356 AffineTransform transform = AffineTransform::translation(destOffset.x(), destOffset.y()); 362 AffineTransform transform = AffineTransform::translation(destOffset.x(), destOffset.y());
357 transform.scale(scale.width(), scale.height()); 363 transform.scale(scale.width(), scale.height());
358 TransformRecorder transformRecorder(imagePicture.context(), imagePicture , transform); 364 TransformRecorder transformRecorder(imagePicture.context(), imagePicture , transform);
359 365
360 view->updateAllLifecyclePhasesExceptPaint();
361 view->paint(imagePicture.context(), CullRect(enclosingIntRect(srcRect))) ; 366 view->paint(imagePicture.context(), CullRect(enclosingIntRect(srcRect))) ;
362 ASSERT(!view->needsLayout()); 367 ASSERT(!view->needsLayout());
363 } 368 }
364 369
365 { 370 {
366 SkAutoCanvasRestore ar(canvas, false); 371 SkAutoCanvasRestore ar(canvas, false);
367 if (drawNeedsLayer(paint)) { 372 if (drawNeedsLayer(paint)) {
368 SkRect layerRect = dstRect; 373 SkRect layerRect = dstRect;
369 canvas->saveLayer(&layerRect, &paint); 374 canvas->saveLayer(&layerRect, &paint);
370 } 375 }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 540
536 return m_page; 541 return m_page;
537 } 542 }
538 543
539 String SVGImage::filenameExtension() const 544 String SVGImage::filenameExtension() const
540 { 545 {
541 return "svg"; 546 return "svg";
542 } 547 }
543 548
544 } // namespace blink 549 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698