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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp

Issue 1736333002: Fix a race condition in canvas hibernation when visibility is toggled repeatedly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 bridge->hibernate(); 200 bridge->hibernate();
201 } else { 201 } else {
202 Canvas2DLayerBridge::Logger localLogger; 202 Canvas2DLayerBridge::Logger localLogger;
203 localLogger.reportHibernationEvent(Canvas2DLayerBridge::HibernationAbort edDueToDestructionWhileHibernatePending); 203 localLogger.reportHibernationEvent(Canvas2DLayerBridge::HibernationAbort edDueToDestructionWhileHibernatePending);
204 } 204 }
205 } 205 }
206 206
207 void Canvas2DLayerBridge::hibernate() 207 void Canvas2DLayerBridge::hibernate()
208 { 208 {
209 ASSERT(!isHibernating()); 209 ASSERT(!isHibernating());
210 ASSERT(m_hibernationScheduled);
211
212 m_hibernationScheduled = false;
Stephen White 2016/02/26 20:16:04 For the future, it might be worth thinking about t
210 213
211 if (m_destructionInProgress) { 214 if (m_destructionInProgress) {
212 m_logger->reportHibernationEvent(HibernationAbortedDueToPendingDestructi on); 215 m_logger->reportHibernationEvent(HibernationAbortedDueToPendingDestructi on);
213 return; 216 return;
214 } 217 }
215 218
216 if (!m_surface) { 219 if (!m_surface) {
217 m_logger->reportHibernationEvent(HibernationAbortedBecauseNoSurface); 220 m_logger->reportHibernationEvent(HibernationAbortedBecauseNoSurface);
218 return; 221 return;
219 } 222 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 m_layer->setNearestNeighbor(m_filterQuality == kNone_SkFilterQuality); 417 m_layer->setNearestNeighbor(m_filterQuality == kNone_SkFilterQuality);
415 } 418 }
416 419
417 void Canvas2DLayerBridge::setIsHidden(bool hidden) 420 void Canvas2DLayerBridge::setIsHidden(bool hidden)
418 { 421 {
419 bool newHiddenValue = hidden || m_destructionInProgress; 422 bool newHiddenValue = hidden || m_destructionInProgress;
420 if (m_isHidden == newHiddenValue) 423 if (m_isHidden == newHiddenValue)
421 return; 424 return;
422 425
423 m_isHidden = newHiddenValue; 426 m_isHidden = newHiddenValue;
424 if (m_surface && isHidden() && !m_destructionInProgress) { 427 if (m_surface && isHidden() && !m_destructionInProgress && !m_hibernationSch eduled) {
425 if (m_layer) 428 if (m_layer)
426 m_layer->clearTexture(); 429 m_layer->clearTexture();
427 m_logger->reportHibernationEvent(HibernationScheduled); 430 m_logger->reportHibernationEvent(HibernationScheduled);
431 m_hibernationScheduled = true;
428 Platform::current()->currentThread()->scheduler()->postIdleTask(BLINK_FR OM_HERE, WTF::bind<double>(&hibernateWrapper, m_weakPtrFactory.createWeakPtr())) ; 432 Platform::current()->currentThread()->scheduler()->postIdleTask(BLINK_FR OM_HERE, WTF::bind<double>(&hibernateWrapper, m_weakPtrFactory.createWeakPtr())) ;
429 } 433 }
430 if (!isHidden() && m_softwareRenderingWhileHidden) { 434 if (!isHidden() && m_softwareRenderingWhileHidden) {
431 flushRecordingOnly(); 435 flushRecordingOnly();
432 SkPaint copyPaint; 436 SkPaint copyPaint;
433 copyPaint.setXfermodeMode(SkXfermode::kSrc_Mode); 437 copyPaint.setXfermodeMode(SkXfermode::kSrc_Mode);
434 RefPtr<SkSurface> oldSurface = m_surface.release(); 438 RefPtr<SkSurface> oldSurface = m_surface.release();
435 m_softwareRenderingWhileHidden = false; 439 m_softwareRenderingWhileHidden = false;
436 SkSurface* newSurface = getOrCreateSurface(PreferAccelerationAfterVisibi lityChange); 440 SkSurface* newSurface = getOrCreateSurface(PreferAccelerationAfterVisibi lityChange);
437 if (newSurface) { 441 if (newSurface) {
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 m_parentLayerBridge = other.m_parentLayerBridge; 833 m_parentLayerBridge = other.m_parentLayerBridge;
830 } 834 }
831 835
832 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) 836 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event)
833 { 837 {
834 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib ernationEvents", HibernationEventCount)); 838 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib ernationEvents", HibernationEventCount));
835 hibernationHistogram.count(event); 839 hibernationHistogram.count(event);
836 } 840 }
837 841
838 } // namespace blink 842 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698