bool LayerAndroid::needsTexture()
{
- return m_imageRef || (prepareContext()
+ return m_imageRef || (m_recordingPicture
&& m_recordingPicture->width() && m_recordingPicture->height());
}
IntRect clip(m_clippingRect.x(), m_clippingRect.y(),
m_clippingRect.width(), m_clippingRect.height());
XLOGC("%s [%d:0x%x] - %s - area (%d, %d, %d, %d) - visible (%d, %d, %d, %d) "
- "clip (%d, %d, %d, %d) %s prepareContext(%d), pic w: %d h: %d",
+ "clip (%d, %d, %d, %d) %s %s prepareContext(%x), pic w: %d h: %d",
spaces, uniqueId(), m_owningLayer,
needsTexture() ? "needs a texture" : "no texture",
tr.x(), tr.y(), tr.width(), tr.height(),
visible.x(), visible.y(), visible.width(), visible.height(),
clip.x(), clip.y(), clip.width(), clip.height(),
contentIsScrollable() ? "SCROLLABLE" : "",
- prepareContext(),
+ isFixed() ? "FIXED" : "",
+ m_recordingPicture,
m_recordingPicture ? m_recordingPicture->width() : -1,
m_recordingPicture ? m_recordingPicture->height() : -1);
#define BYTES_PER_PIXEL 4 // 8888 config
+#define LAYER_TEXTURES_DESTROY_TIMEOUT 60 // If we do not need layers for 60 seconds, free the textures
+
namespace WebCore {
GLint TilesManager::getMaxTextureSize()
TilesManager::TilesManager()
: m_layerTexturesRemain(true)
, m_maxTextureCount(0)
+ , m_maxLayerTextureCount(0)
, m_generatorReady(false)
, m_showVisualIndicator(false)
, m_invertedScreen(false)
, m_invertedScreenSwitch(false)
, m_useMinimalMemory(true)
, m_drawGLCount(1)
+ , m_lastTimeLayersUsed(0)
+ , m_hasLayerTextures(false)
{
XLOG("TilesManager ctor");
m_textures.reserveCapacity(MAX_TEXTURE_ALLOCATION);
nbTexturesAllocated++;
}
- int nbLayersTexturesToAllocate = m_maxTextureCount - m_tilesTextures.size();
+ int nbLayersTexturesToAllocate = m_maxLayerTextureCount - m_tilesTextures.size();
XLOG("%d layers tiles to allocate (%d textures planned)",
- nbLayersTexturesToAllocate, m_maxTextureCount);
+ nbLayersTexturesToAllocate, m_maxLayerTextureCount);
int nbLayersTexturesAllocated = 0;
for (int i = 0; i < nbLayersTexturesToAllocate; i++) {
BaseTileTexture* texture = new BaseTileTexture(
void TilesManager::deallocateTextures(bool allTextures)
{
const unsigned int max = m_textures.size();
- const unsigned int maxLayer = m_tilesTextures.size();
unsigned long long sparedDrawCount = ~0; // by default, spare no textures
if (!allTextures) {
sparedDrawCount = std::max(sparedDrawCount, owner->drawCount());
}
}
+ deallocateTexturesVector(sparedDrawCount, m_textures);
+ deallocateTexturesVector(sparedDrawCount, m_tilesTextures);
+}
+void TilesManager::deallocateTexturesVector(unsigned long long sparedDrawCount,
+ WTF::Vector<BaseTileTexture*>& textures)
+{
+ const unsigned int max = textures.size();
int dealloc = 0;
for (unsigned int i = 0; i < max; i++) {
- TextureOwner* owner = m_textures[i]->owner();
- if (!owner || owner->drawCount() < sparedDrawCount) {
- m_textures[i]->discardGLTexture();
- dealloc++;
- }
- }
- for (unsigned int i = 0; i < maxLayer; i++) {
- TextureOwner* owner = m_tilesTextures[i]->owner();
+ TextureOwner* owner = textures[i]->owner();
if (!owner || owner->drawCount() < sparedDrawCount) {
- m_tilesTextures[i]->discardGLTexture();
+ textures[i]->discardGLTexture();
dealloc++;
}
}
return m_maxTextureCount;
}
+int TilesManager::maxLayerTextureCount()
+{
+ android::Mutex::Autolock lock(m_texturesLock);
+ return m_maxLayerTextureCount;
+}
+
void TilesManager::setMaxTextureCount(int max)
{
XLOG("setMaxTextureCount: %d (current: %d, total:%d)",
allocateTiles();
}
+void TilesManager::setMaxLayerTextureCount(int max)
+{
+ XLOG("setMaxLayerTextureCount: %d (current: %d, total:%d)",
+ max, m_maxLayerTextureCount, MAX_TEXTURE_ALLOCATION);
+ if (!max && m_hasLayerTextures) {
+ double secondsSinceLayersUsed = WTF::currentTime() - m_lastTimeLayersUsed;
+ if (secondsSinceLayersUsed > LAYER_TEXTURES_DESTROY_TIMEOUT) {
+ unsigned long long sparedDrawCount = ~0; // by default, spare no textures
+ deallocateTexturesVector(sparedDrawCount, m_tilesTextures);
+ m_hasLayerTextures = false;
+ }
+ return;
+ }
+ m_lastTimeLayersUsed = WTF::currentTime();
+ if (m_maxLayerTextureCount == MAX_TEXTURE_ALLOCATION ||
+ max <= m_maxLayerTextureCount)
+ return;
+
+ android::Mutex::Autolock lock(m_texturesLock);
+
+ if (max < MAX_TEXTURE_ALLOCATION)
+ m_maxLayerTextureCount = max;
+ else
+ m_maxLayerTextureCount = MAX_TEXTURE_ALLOCATION;
+
+ allocateTiles();
+ m_hasLayerTextures = true;
+}
+
+
float TilesManager::tileWidth()
{
return TILE_WIDTH;
void resetTextureUsage(TiledPage* page);
int maxTextureCount();
+ int maxLayerTextureCount();
void setMaxTextureCount(int max);
+ void setMaxLayerTextureCount(int max);
static float tileWidth();
static float tileHeight();
static float layerTileWidth();
m_generatorReadyCond.wait(m_generatorLock);
}
+ void deallocateTexturesVector(unsigned long long sparedDrawCount,
+ WTF::Vector<BaseTileTexture*>& textures);
+
Vector<BaseTileTexture*> m_textures;
Vector<BaseTileTexture*> m_availableTextures;
Vector<PaintedSurface*> m_paintedSurfaces;
int m_maxTextureCount;
+ int m_maxLayerTextureCount;
bool m_generatorReady;
TilesProfiler m_profiler;
TilesTracker m_tilesTracker;
unsigned long long m_drawGLCount;
+ double m_lastTimeLayersUsed;
+ bool m_hasLayerTextures;
};
} // namespace WebCore
ret |= m_paintingTree->prepare(currentTime, viewRect,
visibleRect, scale);
+ if (m_paintingTree->countChildren()) {
+ LayerAndroid* laTree = static_cast<LayerAndroid*>(m_paintingTree->getChild(0));
+ laTree->computeTexturesAmount(texturesResultPtr);
+ }
if (/*!m_fastSwapMode && */ m_paintingTree->isReady()) {
XLOG("have painting tree %p ready, swapping!", m_paintingTree);
didTreeSwap = true;
XLOG("preparing drawing tree %p", m_drawingTree);
ret |= m_drawingTree->prepare(currentTime, viewRect,
visibleRect, scale);
+ if (m_drawingTree->countChildren()) {
+ LayerAndroid* laTree = static_cast<LayerAndroid*>(m_drawingTree->getChild(0));
+ laTree->computeTexturesAmount(texturesResultPtr);
+ }
}
if (!m_isAnimating) {
m_drawingTree, m_animationOffset, m_isAnimating);
#endif
LayerAndroid* laTree = static_cast<LayerAndroid*>(m_drawingTree->getChild(0));
- laTree->computeTexturesAmount(texturesResultPtr);
m_isAnimating = laTree->evaluateAnimations(currentTime - m_animationOffset);
if (!m_isAnimating)
m_animationOffset = 0;