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

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

Issue 1652293002: Fix 2D canvas content loss while page is hidden (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 4 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 if (m_layer && !m_destructionInProgress) 513 if (m_layer && !m_destructionInProgress)
514 checkSurfaceValid(); // To ensure rate limiter is disabled if context is lost. 514 checkSurfaceValid(); // To ensure rate limiter is disabled if context is lost.
515 return m_contextProvider ? m_contextProvider->context3d() : 0; 515 return m_contextProvider ? m_contextProvider->context3d() : 0;
516 } 516 }
517 517
518 bool Canvas2DLayerBridge::checkSurfaceValid() 518 bool Canvas2DLayerBridge::checkSurfaceValid()
519 { 519 {
520 ASSERT(!m_destructionInProgress); 520 ASSERT(!m_destructionInProgress);
521 if (m_destructionInProgress) 521 if (m_destructionInProgress)
522 return false; 522 return false;
523 if (isHibernating())
524 return true;
523 if (!m_layer) 525 if (!m_layer)
524 return true; 526 return true;
525 if (!m_surface) 527 if (!m_surface)
526 return false; 528 return false;
527 if (m_contextProvider->context3d()->isContextLost()) { 529 if (m_contextProvider->context3d()->isContextLost()) {
528 m_surface.clear(); 530 m_surface.clear();
529 for (auto mailboxInfo = m_mailboxes.begin(); mailboxInfo != m_mailboxes. end(); ++mailboxInfo) { 531 for (auto mailboxInfo = m_mailboxes.begin(); mailboxInfo != m_mailboxes. end(); ++mailboxInfo) {
530 if (mailboxInfo->m_image) 532 if (mailboxInfo->m_image)
531 mailboxInfo->m_image.clear(); 533 mailboxInfo->m_image.clear();
532 } 534 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 bool Canvas2DLayerBridge::prepareMailbox(WebExternalTextureMailbox* outMailbox, WebExternalBitmap* bitmap) 577 bool Canvas2DLayerBridge::prepareMailbox(WebExternalTextureMailbox* outMailbox, WebExternalBitmap* bitmap)
576 { 578 {
577 if (m_destructionInProgress) { 579 if (m_destructionInProgress) {
578 // It can be hit in the following sequence. 580 // It can be hit in the following sequence.
579 // 1. Canvas draws something. 581 // 1. Canvas draws something.
580 // 2. The compositor begins the frame. 582 // 2. The compositor begins the frame.
581 // 3. Javascript makes a context be lost. 583 // 3. Javascript makes a context be lost.
582 // 4. Here. 584 // 4. Here.
583 return false; 585 return false;
584 } 586 }
585 ASSERT(isAccelerated() || isHibernating()); 587 ASSERT(isAccelerated() || isHibernating() || m_softwareRenderingWhileHidden) ;
586 588
587 // if hibernating but not hidden, we want to wake up from 589 // if hibernating but not hidden, we want to wake up from
588 // hibernation 590 // hibernation
589 if (isHibernating() && isHidden()) 591 if ((isHibernating() || m_softwareRenderingWhileHidden) && isHidden())
590 return false; 592 return false;
591 593
592 if (bitmap) { 594 if (bitmap) {
593 // Using accelerated 2d canvas with software renderer, which 595 // Using accelerated 2d canvas with software renderer, which
594 // should only happen in tests that use fake graphics contexts 596 // should only happen in tests that use fake graphics contexts
595 // or in Android WebView in software mode. In this case, we do 597 // or in Android WebView in software mode. In this case, we do
596 // not care about producing any results for this canvas. 598 // not care about producing any results for this canvas.
597 skipQueuedDrawCommands(); 599 skipQueuedDrawCommands();
598 m_lastImageId = 0; 600 m_lastImageId = 0;
599 return false; 601 return false;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 m_image = other.m_image; 822 m_image = other.m_image;
821 m_parentLayerBridge = other.m_parentLayerBridge; 823 m_parentLayerBridge = other.m_parentLayerBridge;
822 } 824 }
823 825
824 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) 826 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event)
825 { 827 {
826 blink::Platform::current()->histogramEnumeration("Canvas.HibernationEvents", event, HibernationEventCount); 828 blink::Platform::current()->histogramEnumeration("Canvas.HibernationEvents", event, HibernationEventCount);
827 } 829 }
828 830
829 } // namespace blink 831 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698