Chromium Code Reviews| Index: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp |
| diff --git a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp |
| index 2546e931500e2a4ca1ec38a699c8e994a770d682..a8bc1daa1d0bc57061a10d4829006d1b496cf78a 100644 |
| --- a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp |
| +++ b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp |
| @@ -126,7 +126,7 @@ CanvasRenderingContext2D::CanvasRenderingContext2D( |
| m_tryRestoreContextEventTimer( |
| this, |
| &CanvasRenderingContext2D::tryRestoreContextEvent), |
| - m_pruneLocalFontCacheScheduled(false) { |
| + m_shouldPruneLocalFontCache(false) { |
| if (document.settings() && |
| document.settings()->getAntialiasedClips2dCanvasEnabled()) |
| m_clipAntialiasing = AntiAliased; |
| @@ -141,11 +141,6 @@ void CanvasRenderingContext2D::setCanvasGetContextResult( |
| CanvasRenderingContext2D::~CanvasRenderingContext2D() {} |
| -void CanvasRenderingContext2D::dispose() { |
| - if (m_pruneLocalFontCacheScheduled) |
| - Platform::current()->currentThread()->removeTaskObserver(this); |
| -} |
| - |
| void CanvasRenderingContext2D::validateStateStack() const { |
| #if DCHECK_IS_ON() |
| if (SkCanvas* skCanvas = canvas()->existingDrawingCanvas()) { |
| @@ -353,7 +348,7 @@ void CanvasRenderingContext2D::didDraw(const SkIRect& dirtyRect) { |
| buffer->setHasExpensiveOp(); |
| } |
| - canvas()->didDraw(SkRect::Make(dirtyRect)); |
| + CanvasRenderingContext::didDraw(dirtyRect); |
| } |
| bool CanvasRenderingContext2D::stateHasFilter() { |
| @@ -481,7 +476,7 @@ void CanvasRenderingContext2D::setFont(const String& newFont) { |
| DCHECK(!m_fontLRUList.contains(newFont)); |
| m_fontLRUList.add(newFont); |
| pruneLocalFontCache(canvasFontCache->hardMaxFonts()); // hard limit |
| - schedulePruneLocalFontCacheIfNeeded(); // soft limit |
| + m_shouldPruneLocalFontCache = true; // apply soft limit |
| modifiableState().setFont( |
| fontStyle->font(), canvas()->document().styleEngine().fontSelector()); |
| } |
| @@ -499,31 +494,19 @@ void CanvasRenderingContext2D::setFont(const String& newFont) { |
| modifiableState().setUnparsedFont(newFontSafeCopy); |
| } |
| -void CanvasRenderingContext2D::schedulePruneLocalFontCacheIfNeeded() { |
| - if (m_pruneLocalFontCacheScheduled) |
| - return; |
| - m_pruneLocalFontCacheScheduled = true; |
| - Platform::current()->currentThread()->addTaskObserver(this); |
| -} |
| - |
| void CanvasRenderingContext2D::didProcessTask() { |
| - Platform::current()->currentThread()->removeTaskObserver(this); |
| - |
| + CanvasRenderingContext::didProcessTask(); |
| // This should be the only place where canvas() needs to be checked for |
| - // nullness because the circular refence with HTMLCanvasElement mean the |
| - // canvas and the context keep each other alive as long as the pair is |
| - // referenced the task observer is the only persisten refernce to this object |
| - // that is not traced, so didProcessTask() may be call at a time when the |
| + // nullness because the circular refence with HTMLCanvasElement means the |
| + // canvas and the context keep each other alive. As long as the pair is |
| + // referenced, the task observer is the only persistent refernce to this |
| + // object |
| + // that is not traced, so didProcessTask() may be called at a time when the |
| // canvas has been garbage collected but not the context. |
| - if (!canvas()) |
| - return; |
| - |
| - // The rendering surface needs to be prepared now because it will be too late |
| - // to create a layer once we are in the paint invalidation phase. |
| - canvas()->prepareSurfaceForPaintingIfNeeded(); |
|
xlai (Olivia)
2017/01/27 22:23:25
Is there any specific reason why you move this cre
Justin Novosad
2017/02/07 21:52:29
There is no change in functionality. Just a drive-
|
| - |
| - pruneLocalFontCache(canvas()->document().canvasFontCache()->maxFonts()); |
| - m_pruneLocalFontCacheScheduled = false; |
| + if (m_shouldPruneLocalFontCache && canvas()) { |
| + m_shouldPruneLocalFontCache = false; |
| + pruneLocalFontCache(canvas()->document().canvasFontCache()->maxFonts()); |
| + } |
| } |
| void CanvasRenderingContext2D::pruneLocalFontCache(size_t targetSize) { |