| OLD | NEW | 
|---|
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "cc/gl_renderer.h" | 5 #include "cc/gl_renderer.h" | 
| 6 | 6 | 
| 7 #include <set> | 7 #include <set> | 
| 8 #include <string> | 8 #include <string> | 
| 9 #include <vector> | 9 #include <vector> | 
| 10 | 10 | 
| (...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1315 } | 1315 } | 
| 1316 | 1316 | 
| 1317 void GLRenderer::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocatio
      n) | 1317 void GLRenderer::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocatio
      n) | 
| 1318 { | 1318 { | 
| 1319     // Just ignore the memory manager when it says to set the limit to zero | 1319     // Just ignore the memory manager when it says to set the limit to zero | 
| 1320     // bytes. This will happen when the memory manager thinks that the renderer | 1320     // bytes. This will happen when the memory manager thinks that the renderer | 
| 1321     // is not visible (which the renderer knows better). | 1321     // is not visible (which the renderer knows better). | 
| 1322     if (allocation.bytesLimitWhenVisible) { | 1322     if (allocation.bytesLimitWhenVisible) { | 
| 1323         ManagedMemoryPolicy policy( | 1323         ManagedMemoryPolicy policy( | 
| 1324             allocation.bytesLimitWhenVisible, | 1324             allocation.bytesLimitWhenVisible, | 
| 1325             priorityCutoffValue(allocation.priorityCutoffWhenVisible), | 1325             priorityCutoff(allocation.priorityCutoffWhenVisible), | 
| 1326             allocation.bytesLimitWhenNotVisible, | 1326             allocation.bytesLimitWhenNotVisible, | 
| 1327             priorityCutoffValue(allocation.priorityCutoffWhenNotVisible)); | 1327             priorityCutoff(allocation.priorityCutoffWhenNotVisible)); | 
| 1328 | 1328 | 
| 1329         if (allocation.enforceButDoNotKeepAsPolicy) | 1329         if (allocation.enforceButDoNotKeepAsPolicy) | 
| 1330             m_client->enforceManagedMemoryPolicy(policy); | 1330             m_client->enforceManagedMemoryPolicy(policy); | 
| 1331         else | 1331         else | 
| 1332             m_client->setManagedMemoryPolicy(policy); | 1332             m_client->setManagedMemoryPolicy(policy); | 
| 1333     } | 1333     } | 
| 1334 | 1334 | 
| 1335     bool oldDiscardBackbufferWhenNotVisible = m_discardBackbufferWhenNotVisible; | 1335     bool oldDiscardBackbufferWhenNotVisible = m_discardBackbufferWhenNotVisible; | 
| 1336     m_discardBackbufferWhenNotVisible = !allocation.suggestHaveBackbuffer; | 1336     m_discardBackbufferWhenNotVisible = !allocation.suggestHaveBackbuffer; | 
| 1337     enforceMemoryPolicy(); | 1337     enforceMemoryPolicy(); | 
| 1338     if (allocation.enforceButDoNotKeepAsPolicy) | 1338     if (allocation.enforceButDoNotKeepAsPolicy) | 
| 1339         m_discardBackbufferWhenNotVisible = oldDiscardBackbufferWhenNotVisible; | 1339         m_discardBackbufferWhenNotVisible = oldDiscardBackbufferWhenNotVisible; | 
| 1340 } | 1340 } | 
| 1341 | 1341 | 
| 1342 int GLRenderer::priorityCutoffValue(WebKit::WebGraphicsMemoryAllocation::Priorit
      yCutoff priorityCutoff) | 1342 ManagedMemoryPolicy::PriorityCutoff GLRenderer::priorityCutoff(WebKit::WebGraphi
      csMemoryAllocation::PriorityCutoff priorityCutoff) | 
| 1343 { | 1343 { | 
|  | 1344     // This is simple a 1:1 map, the names differ only because the WebKit names 
      should be to match the cc names. | 
| 1344     switch (priorityCutoff) { | 1345     switch (priorityCutoff) { | 
| 1345     case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowNothing: | 1346     case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowNothing: | 
| 1346         return PriorityCalculator::allowNothingCutoff(); | 1347         return ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING; | 
| 1347     case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleOnly: | 1348     case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleOnly: | 
| 1348         return PriorityCalculator::allowVisibleOnlyCutoff(); | 1349         return ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY; | 
| 1349     case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleAndNearb
      y: | 1350     case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleAndNearb
      y: | 
| 1350         return PriorityCalculator::allowVisibleAndNearbyCutoff(); | 1351         return ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE; | 
| 1351     case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything: | 1352     case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything: | 
| 1352         return PriorityCalculator::allowEverythingCutoff(); | 1353         return ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING; | 
| 1353     } | 1354     } | 
| 1354     NOTREACHED(); | 1355     NOTREACHED(); | 
| 1355     return 0; | 1356     return ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING; | 
| 1356 } | 1357 } | 
| 1357 | 1358 | 
| 1358 void GLRenderer::enforceMemoryPolicy() | 1359 void GLRenderer::enforceMemoryPolicy() | 
| 1359 { | 1360 { | 
| 1360     if (!m_visible) { | 1361     if (!m_visible) { | 
| 1361         TRACE_EVENT0("cc", "GLRenderer::enforceMemoryPolicy dropping resources")
      ; | 1362         TRACE_EVENT0("cc", "GLRenderer::enforceMemoryPolicy dropping resources")
      ; | 
| 1362         releaseRenderPassTextures(); | 1363         releaseRenderPassTextures(); | 
| 1363         if (m_discardBackbufferWhenNotVisible) | 1364         if (m_discardBackbufferWhenNotVisible) | 
| 1364             discardBackbuffer(); | 1365             discardBackbuffer(); | 
| 1365         GLC(m_context, m_context->flush()); | 1366         GLC(m_context, m_context->flush()); | 
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1791 | 1792 | 
| 1792     releaseRenderPassTextures(); | 1793     releaseRenderPassTextures(); | 
| 1793 } | 1794 } | 
| 1794 | 1795 | 
| 1795 bool GLRenderer::isContextLost() | 1796 bool GLRenderer::isContextLost() | 
| 1796 { | 1797 { | 
| 1797     return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 1798     return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 
| 1798 } | 1799 } | 
| 1799 | 1800 | 
| 1800 }  // namespace cc | 1801 }  // namespace cc | 
| OLD | NEW | 
|---|