namespace WebCore {
-CCTextureUpdater::CCTextureUpdater(TextureAllocator* allocator, TextureCopier* copier)
- : m_allocator(allocator)
- , m_copier(copier)
- , m_entryIndex(0)
+CCTextureUpdater::CCTextureUpdater()
+ : m_entryIndex(0)
{
- ASSERT(m_allocator);
}
CCTextureUpdater::~CCTextureUpdater()
m_copyEntries.append(copy);
}
+void CCTextureUpdater::appendManagedCopy(unsigned sourceTexture, ManagedTexture* destTexture, const IntSize& size)
+{
+ ManagedCopyEntry copy;
+ copy.sourceTexture = sourceTexture;
+ copy.destTexture = destTexture;
+ copy.size = size;
+ m_managedCopyEntries.append(copy);
+}
+
bool CCTextureUpdater::hasMoreUpdates() const
{
- return m_entries.size() || m_partialEntries.size() || m_copyEntries.size();
+ return m_entries.size() || m_partialEntries.size() || m_copyEntries.size() || m_managedCopyEntries.size();
}
-bool CCTextureUpdater::update(GraphicsContext3D* context, size_t count)
+bool CCTextureUpdater::update(GraphicsContext3D* context, TextureAllocator* allocator, TextureCopier* copier, size_t count)
{
size_t index;
size_t maxIndex = min(m_entryIndex + count, m_entries.size());
for (index = m_entryIndex; index < maxIndex; ++index) {
UpdateEntry& entry = m_entries[index];
- entry.texture->updateRect(context, m_allocator, entry.sourceRect, entry.destRect);
+ entry.texture->updateRect(context, allocator, entry.sourceRect, entry.destRect);
}
bool moreUpdates = maxIndex < m_entries.size();
for (index = 0; index < m_partialEntries.size(); ++index) {
UpdateEntry& entry = m_partialEntries[index];
- entry.texture->updateRect(context, m_allocator, entry.sourceRect, entry.destRect);
+ entry.texture->updateRect(context, allocator, entry.sourceRect, entry.destRect);
}
for (index = 0; index < m_copyEntries.size(); ++index) {
CopyEntry& copyEntry = m_copyEntries[index];
- m_copier->copyTexture(context, copyEntry.sourceTexture, copyEntry.destTexture, copyEntry.size);
+ copier->copyTexture(context, copyEntry.sourceTexture, copyEntry.destTexture, copyEntry.size);
+ }
+ for (index = 0; index < m_managedCopyEntries.size(); ++index) {
+ ManagedCopyEntry& managedCopyEntry = m_managedCopyEntries[index];
+ managedCopyEntry.destTexture->allocate(allocator);
+ copier->copyTexture(context, managedCopyEntry.sourceTexture, managedCopyEntry.destTexture->textureId(), managedCopyEntry.size);
}
// If we've performed any texture copies, we need to insert a flush here into the compositor context
// before letting the main thread proceed as it may make draw calls to the source texture of one of
// our copy operations.
- if (m_copyEntries.size())
+ if (m_copyEntries.size() || m_managedCopyEntries.size())
context->flush();
// If no entries left to process, auto-clear.
m_entries.clear();
m_partialEntries.clear();
m_copyEntries.clear();
+ m_managedCopyEntries.clear();
}
}
DebugScopedSetImplThread implThread;
OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
- FakeCCTextureUpdater updater;
+ CCTextureUpdater updater;
// The tile size is 100x100, so this invalidates and then paints two tiles.
layer->setBounds(IntSize(100, 200));
OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
TestCCOcclusionTracker occluded;
- FakeCCTextureUpdater updater;
+ CCTextureUpdater updater;
// The tile size is 100x100, so this invalidates and then paints two tiles.
layer->setBounds(IntSize(100, 200));
DebugScopedSetImplThread implThread;
OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
- FakeCCTextureUpdater updater;
+ CCTextureUpdater updater;
+ FakeTextureAllocator allocator;
+ FakeTextureCopier copier;
// The tile size is 100x100, so this invalidates and then paints two tiles.
layer->setBounds(IntSize(100, 200));
EXPECT_TRUE(layerImpl->hasTileAt(0, 0));
EXPECT_TRUE(layerImpl->hasTileAt(0, 1));
- textureManager->evictAndDeleteAllTextures(&updater.textureAllocator());
+ textureManager->evictAndDeleteAllTextures(&allocator);
textureManager->setMaxMemoryLimitBytes(4*1024*1024);
textureManager->setPreferredMemoryLimitBytes(4*1024*1024);
DebugScopedSetImplThread implThread;
OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
- FakeCCTextureUpdater updater;
+ CCTextureUpdater updater;
// The tile size is 100x100. Setup 5x5 tiles with one visible tile in the center.
IntSize contentBounds(500, 500);
RefPtr<FakeTiledLayerChromium> layer2 = adoptRef(new FakeTiledLayerChromium(textureManager.get()));
OwnPtr<FakeCCTiledLayerImpl> layerImpl2(adoptPtr(new FakeCCTiledLayerImpl(0)));
- FakeCCTextureUpdater updater;
+ CCTextureUpdater updater;
+ FakeTextureAllocator allocator;
+ FakeTextureCopier copier;
// For this test we have two layers. layer1 exhausts most texture memory, leaving room for 2 more tiles from
// layer2, but not all three tiles. First we paint layer1, and one tile from layer2. Then when we idle paint
// Commit the frame over to impl.
layer1->updateCompositorResources(0, updater);
layer2->updateCompositorResources(0, updater);
- updater.update(0, 5000);
+ updater.update(0, &allocator, &copier, 5000);
layer1->pushPropertiesTo(layerImpl1.get());
layer2->pushPropertiesTo(layerImpl2.get());
// Oh well, commit the frame and push.
layer1->updateCompositorResources(0, updater);
layer2->updateCompositorResources(0, updater);
- updater.update(0, 5000);
+ updater.update(0, &allocator, &copier, 5000);
layer1->pushPropertiesTo(layerImpl1.get());
layer2->pushPropertiesTo(layerImpl2.get());
layer1->updateCompositorResources(0, updater);
layer2->updateCompositorResources(0, updater);
- updater.update(0, 5000);
+ updater.update(0, &allocator, &copier, 5000);
layer1->pushPropertiesTo(layerImpl1.get());
layer2->pushPropertiesTo(layerImpl2.get());
OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
TestCCOcclusionTracker occluded;
- FakeCCTextureUpdater updater;
+ CCTextureUpdater updater;
// The tile size is 100x100, so this invalidates one occluded tile, culls it during paint, but prepaints it.
occluded.setOcclusion(IntRect(0, 0, 100, 100));
DebugScopedSetImplThread implThread;
OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
- FakeCCTextureUpdater updater;
+ CCTextureUpdater updater;
// The tile size is 100x100, so this invalidates and then paints two tiles.
// However, during the paint, we invalidate one of the tiles. This should
OwnPtr<FakeCCTiledLayerImpl> layer1Impl(adoptPtr(new FakeCCTiledLayerImpl(0)));
OwnPtr<FakeCCTiledLayerImpl> layer2Impl(adoptPtr(new FakeCCTiledLayerImpl(0)));
- FakeCCTextureUpdater updater;
+ CCTextureUpdater updater;
layer1->setBounds(IntSize(100, 200));
layer1->invalidateRect(IntRect(0, 0, 100, 200));
OwnPtr<FakeCCTiledLayerImpl> layer1Impl(adoptPtr(new FakeCCTiledLayerImpl(0)));
OwnPtr<FakeCCTiledLayerImpl> layer2Impl(adoptPtr(new FakeCCTiledLayerImpl(0)));
- FakeCCTextureUpdater updater;
+ CCTextureUpdater updater;
layer1->setBounds(IntSize(100, 200));
layer1->invalidateRect(IntRect(0, 0, 100, 200));
DebugScopedSetImplThread implThread;
OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
- FakeCCTextureUpdater updater;
+ CCTextureUpdater updater;
// This invalidates 9 tiles and then paints one visible tile.
layer->setBounds(contentBounds);
DebugScopedSetImplThread implThread;
OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
- FakeCCTextureUpdater updater;
+ CCTextureUpdater updater;
// The layer's bounds are empty.
IntRect contentRect;
DebugScopedSetImplThread implThread;
OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
- FakeCCTextureUpdater updater;
+ CCTextureUpdater updater;
// Pretend the layer is animating.
layer->setDrawTransformIsAnimating(true);
DebugScopedSetImplThread implThread;
OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
- FakeCCTextureUpdater updater;
+ CCTextureUpdater updater;
// Invalidate the layer but make none of it visible, so nothing paints.
IntRect visibleRect;
OwnPtr<TextureManager> textureManager = TextureManager::create(8000*8000*8, 8000*8000*4, 1024);
DebugScopedSetImplThread implThread;
- FakeCCTextureUpdater updater;
+ CCTextureUpdater updater;
int tileWidth = FakeTiledLayerChromium::tileSize().width();
int tileHeight = FakeTiledLayerChromium::tileSize().height();
DebugScopedSetImplThread implThread;
OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
- FakeCCTextureUpdater updater;
+ CCTextureUpdater updater;
// The tile size is 100x100, so this invalidates and then paints two tiles.
layer->setBounds(IntSize(100, 200));
OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024);
RefPtr<FakeTiledLayerWithScaledBounds> layer = adoptRef(new FakeTiledLayerWithScaledBounds(textureManager.get()));
- FakeCCTextureUpdater updater;
+ CCTextureUpdater updater;
IntRect layerBounds(0, 0, 300, 200);
IntRect contentBounds(0, 0, 200, 250);
DebugScopedSetImplThread implThread;
OwnPtr<FakeCCTiledLayerImpl> layerImpl(adoptPtr(new FakeCCTiledLayerImpl(0)));
- FakeCCTextureUpdater updater;
+ CCTextureUpdater updater;
// Create a layer with one tile.
layer->setBounds(IntSize(100, 100));
rootLayer->invalidateRect(contentRect);
childLayer->invalidateRect(contentRect);
- FakeCCTextureUpdater updater;
+ CCTextureUpdater updater;
ccLayerTreeHost->setRootLayer(rootLayer);
ccLayerTreeHost->setViewportSize(IntSize(300, 300));
layer->setPosition(FloatPoint(150, 150));
layer->invalidateRect(contentRect);
- FakeCCTextureUpdater updater;
+ CCTextureUpdater updater;
+ FakeTextureAllocator allocator;
+ FakeTextureCopier copier;
ccLayerTreeHost->setRootLayer(layer);
ccLayerTreeHost->setViewportSize(IntSize(300, 200));
// Full update of all 6 tiles.
ccLayerTreeHost->updateLayers();
ccLayerTreeHost->updateCompositorResources(ccLayerTreeHost->context(), updater);
- updater.update(0, 4);
+ updater.update(0, &allocator, &copier, 4);
EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount());
EXPECT_TRUE(updater.hasMoreUpdates());
layer->fakeLayerTextureUpdater()->clearUpdateCount();
- updater.update(0, 4);
+ updater.update(0, &allocator, &copier, 4);
EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount());
EXPECT_FALSE(updater.hasMoreUpdates());
layer->fakeLayerTextureUpdater()->clearUpdateCount();
layer->invalidateRect(IntRect(0, 0, 300, 150));
ccLayerTreeHost->updateLayers();
ccLayerTreeHost->updateCompositorResources(ccLayerTreeHost->context(), updater);
- updater.update(0, 4);
+ updater.update(0, &allocator, &copier, 4);
EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount());
EXPECT_TRUE(updater.hasMoreUpdates());
layer->fakeLayerTextureUpdater()->clearUpdateCount();
- updater.update(0, 4);
+ updater.update(0, &allocator, &copier, 4);
EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount());
EXPECT_FALSE(updater.hasMoreUpdates());
layer->fakeLayerTextureUpdater()->clearUpdateCount();
layer->invalidateRect(IntRect(50, 50, 200, 100));
ccLayerTreeHost->updateLayers();
ccLayerTreeHost->updateCompositorResources(ccLayerTreeHost->context(), updater);
- updater.update(0, 4);
+ updater.update(0, &allocator, &copier, 4);
EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount());
EXPECT_TRUE(updater.hasMoreUpdates());
layer->fakeLayerTextureUpdater()->clearUpdateCount();
- updater.update(0, 4);
+ updater.update(0, &allocator, &copier, 4);
EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount());
EXPECT_FALSE(updater.hasMoreUpdates());
layer->fakeLayerTextureUpdater()->clearUpdateCount();