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

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

Issue 2368333003: Improve speed of 2D canvas hibernation unit tests (Closed)
Patch Set: Created 4 years, 2 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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 static void hibernateWrapper(WeakPtr<Canvas2DLayerBridge> bridge, double /*idleD eadline*/) 373 static void hibernateWrapper(WeakPtr<Canvas2DLayerBridge> bridge, double /*idleD eadline*/)
374 { 374 {
375 if (bridge) { 375 if (bridge) {
376 bridge->hibernate(); 376 bridge->hibernate();
377 } else { 377 } else {
378 Canvas2DLayerBridge::Logger localLogger; 378 Canvas2DLayerBridge::Logger localLogger;
379 localLogger.reportHibernationEvent(Canvas2DLayerBridge::HibernationAbort edDueToDestructionWhileHibernatePending); 379 localLogger.reportHibernationEvent(Canvas2DLayerBridge::HibernationAbort edDueToDestructionWhileHibernatePending);
380 } 380 }
381 } 381 }
382 382
383 static void hibernateWrapperForTesting(WeakPtr<Canvas2DLayerBridge> bridge)
384 {
385 hibernateWrapper(bridge, 0);
386 }
387
383 void Canvas2DLayerBridge::hibernate() 388 void Canvas2DLayerBridge::hibernate()
384 { 389 {
385 DCHECK(!isHibernating()); 390 DCHECK(!isHibernating());
386 DCHECK(m_hibernationScheduled); 391 DCHECK(m_hibernationScheduled);
387 392
388 m_hibernationScheduled = false; 393 m_hibernationScheduled = false;
389 394
390 if (m_destructionInProgress) { 395 if (m_destructionInProgress) {
391 m_logger->reportHibernationEvent(HibernationAbortedDueToPendingDestructi on); 396 m_logger->reportHibernationEvent(HibernationAbortedDueToPendingDestructi on);
392 return; 397 return;
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 bool newHiddenValue = hidden || m_destructionInProgress; 604 bool newHiddenValue = hidden || m_destructionInProgress;
600 if (m_isHidden == newHiddenValue) 605 if (m_isHidden == newHiddenValue)
601 return; 606 return;
602 607
603 m_isHidden = newHiddenValue; 608 m_isHidden = newHiddenValue;
604 if (CANVAS2D_HIBERNATION_ENABLED && m_surface && isHidden() && !m_destructio nInProgress && !m_hibernationScheduled) { 609 if (CANVAS2D_HIBERNATION_ENABLED && m_surface && isHidden() && !m_destructio nInProgress && !m_hibernationScheduled) {
605 if (m_layer) 610 if (m_layer)
606 m_layer->clearTexture(); 611 m_layer->clearTexture();
607 m_logger->reportHibernationEvent(HibernationScheduled); 612 m_logger->reportHibernationEvent(HibernationScheduled);
608 m_hibernationScheduled = true; 613 m_hibernationScheduled = true;
609 Platform::current()->currentThread()->scheduler()->postIdleTask(BLINK_FR OM_HERE, WTF::bind(&hibernateWrapper, m_weakPtrFactory.createWeakPtr())); 614 if (m_dontUseIdleSchedulingForTesting) {
615 Platform::current()->currentThread()->getWebTaskRunner()->postTask(B LINK_FROM_HERE, WTF::bind(&hibernateWrapperForTesting, m_weakPtrFactory.createWe akPtr()));
616 } else {
617 Platform::current()->currentThread()->scheduler()->postIdleTask(BLIN K_FROM_HERE, WTF::bind(&hibernateWrapper, m_weakPtrFactory.createWeakPtr()));
618 }
610 } 619 }
611 if (!isHidden() && m_softwareRenderingWhileHidden) { 620 if (!isHidden() && m_softwareRenderingWhileHidden) {
612 flushRecordingOnly(); 621 flushRecordingOnly();
613 SkPaint copyPaint; 622 SkPaint copyPaint;
614 copyPaint.setXfermodeMode(SkXfermode::kSrc_Mode); 623 copyPaint.setXfermodeMode(SkXfermode::kSrc_Mode);
615 624
616 sk_sp<SkSurface> oldSurface = std::move(m_surface); 625 sk_sp<SkSurface> oldSurface = std::move(m_surface);
617 m_surface.reset(); 626 m_surface.reset();
618 627
619 m_softwareRenderingWhileHidden = false; 628 m_softwareRenderingWhileHidden = false;
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 Canvas2DLayerBridge::MailboxInfo::MailboxInfo() = default; 1022 Canvas2DLayerBridge::MailboxInfo::MailboxInfo() = default;
1014 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) = defaul t; 1023 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) = defaul t;
1015 1024
1016 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) 1025 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event)
1017 { 1026 {
1018 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib ernationEvents", HibernationEventCount)); 1027 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib ernationEvents", HibernationEventCount));
1019 hibernationHistogram.count(event); 1028 hibernationHistogram.count(event);
1020 } 1029 }
1021 1030
1022 } // namespace blink 1031 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698