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

Side by Side Diff: Source/core/layout/LayoutImage.cpp

Issue 1008043002: [S.P.] Don't draw frames of animated images that are offscreen. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com)
6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
8 * Copyright (C) 2010 Google Inc. All rights reserved. 8 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. 9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved.
10 * 10 *
(...skipping 22 matching lines...) Expand all
33 #include "core/fetch/ImageResource.h" 33 #include "core/fetch/ImageResource.h"
34 #include "core/fetch/ResourceLoadPriorityOptimizer.h" 34 #include "core/fetch/ResourceLoadPriorityOptimizer.h"
35 #include "core/fetch/ResourceLoader.h" 35 #include "core/fetch/ResourceLoader.h"
36 #include "core/frame/LocalFrame.h" 36 #include "core/frame/LocalFrame.h"
37 #include "core/html/HTMLAreaElement.h" 37 #include "core/html/HTMLAreaElement.h"
38 #include "core/html/HTMLImageElement.h" 38 #include "core/html/HTMLImageElement.h"
39 #include "core/html/HTMLInputElement.h" 39 #include "core/html/HTMLInputElement.h"
40 #include "core/html/HTMLMapElement.h" 40 #include "core/html/HTMLMapElement.h"
41 #include "core/layout/HitTestResult.h" 41 #include "core/layout/HitTestResult.h"
42 #include "core/layout/Layer.h" 42 #include "core/layout/Layer.h"
43 #include "core/layout/LayoutPart.h"
43 #include "core/layout/LayoutView.h" 44 #include "core/layout/LayoutView.h"
44 #include "core/layout/PaintInfo.h" 45 #include "core/layout/PaintInfo.h"
45 #include "core/layout/TextRunConstructor.h" 46 #include "core/layout/TextRunConstructor.h"
46 #include "core/page/Page.h" 47 #include "core/page/Page.h"
47 #include "core/paint/ImagePainter.h" 48 #include "core/paint/ImagePainter.h"
48 #include "core/svg/graphics/SVGImage.h" 49 #include "core/svg/graphics/SVGImage.h"
49 #include "platform/fonts/Font.h" 50 #include "platform/fonts/Font.h"
50 #include "platform/fonts/FontCache.h" 51 #include "platform/fonts/FontCache.h"
51 52
52 namespace blink { 53 namespace blink {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // early. It may be that layout hasn't even taken place once yet. 170 // early. It may be that layout hasn't even taken place once yet.
170 updateInnerContentRect(); 171 updateInnerContentRect();
171 } 172 }
172 173
173 setShouldDoFullPaintInvalidation(); 174 setShouldDoFullPaintInvalidation();
174 175
175 // Tell any potential compositing layers that the image needs updating. 176 // Tell any potential compositing layers that the image needs updating.
176 contentChanged(ImageChanged); 177 contentChanged(ImageChanged);
177 } 178 }
178 179
180 bool LayoutImage::rectIntersectsVisibleViewport(const LayoutRect& localRect)
181 {
182 LayoutRect rect = localRect;
183 LayoutView* layoutView = view();
184 while (layoutView->frame()->ownerLayoutObject())
185 layoutView = layoutView->frame()->ownerLayoutObject()->view();
186 mapRectToPaintInvalidationBacking(layoutView, rect, 0);
187 return rect.intersects(LayoutRect(layoutView->frameView()->visualViewportRec t()));
188 }
189
190 PaintInvalidationReason LayoutImage::invalidatePaintIfNeeded(const PaintInvalida tionState& paintInvalidationState, const LayoutBoxModelObject& paintInvalidation Container)
191 {
192 if (!RuntimeEnabledFeatures::slimmingPaintEnabled())
193 return LayoutReplaced::invalidatePaintIfNeeded(paintInvalidationState, p aintInvalidationContainer);
194
195 if (!imageResource() || !imageResource()->image() || !imageResource()->image ()->maybeAnimated()
196 || rectIntersectsVisibleViewport(visualOverflowRect())) {
197 return LayoutReplaced::invalidatePaintIfNeeded(paintInvalidationState, p aintInvalidationContainer);
198 }
199
200 return PaintInvalidationDelayedFull;
chrishtr 2015/03/16 23:07:41 Since this method overrides invalidatePaintIfNeede
chrishtr 2015/03/17 23:55:56 Correct. That is the intention of the CL.
201 }
202
203
179 void LayoutImage::notifyFinished(Resource* newImage) 204 void LayoutImage::notifyFinished(Resource* newImage)
180 { 205 {
181 if (!m_imageResource) 206 if (!m_imageResource)
182 return; 207 return;
183 208
184 if (documentBeingDestroyed()) 209 if (documentBeingDestroyed())
185 return; 210 return;
186 211
187 invalidateBackgroundObscurationStatus(); 212 invalidateBackgroundObscurationStatus();
188 213
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 return 0; 389 return 0;
365 390
366 ImageResource* cachedImage = m_imageResource->cachedImage(); 391 ImageResource* cachedImage = m_imageResource->cachedImage();
367 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( )) 392 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( ))
368 return toSVGImage(cachedImage->image())->embeddedContentBox(); 393 return toSVGImage(cachedImage->image())->embeddedContentBox();
369 394
370 return 0; 395 return 0;
371 } 396 }
372 397
373 } // namespace blink 398 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698