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

Unified Diff: Source/core/platform/graphics/chromium/Canvas2DLayerManagerTest.cpp

Issue 22929012: Change Canvas2DLayerBridge to stay alive until last mailbox is returned. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Trivial fix for layout test failure Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/platform/graphics/chromium/Canvas2DLayerBridgeTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/platform/graphics/chromium/Canvas2DLayerManagerTest.cpp
diff --git a/Source/core/platform/graphics/chromium/Canvas2DLayerManagerTest.cpp b/Source/core/platform/graphics/chromium/Canvas2DLayerManagerTest.cpp
index 33e9ca69642579fbfb4e04a0152811091f6e91bb..7f45ae99a17804b33affa9b33c38648501de6a8c 100644
--- a/Source/core/platform/graphics/chromium/Canvas2DLayerManagerTest.cpp
+++ b/Source/core/platform/graphics/chromium/Canvas2DLayerManagerTest.cpp
@@ -100,6 +100,11 @@ static PassOwnPtr<SkDeferredCanvas> createCanvas(GraphicsContext3D* context)
return adoptPtr(SkDeferredCanvas::Create(SkSurface::NewRaster(info)));
}
+FakeCanvas2DLayerBridge* fake(const Canvas2DLayerBridgePtr& layer)
+{
+ return static_cast<FakeCanvas2DLayerBridge*>(layer.get());
+}
+
class Canvas2DLayerManagerTest : public Test {
protected:
void storageAllocationTrackingTest()
@@ -109,22 +114,22 @@ protected:
{
RefPtr<GraphicsContext3D> context = GraphicsContext3D::createGraphicsContextFromWebContext(adoptPtr(new WebKit::FakeWebGraphicsContext3D));
OwnPtr<SkDeferredCanvas> canvas1 = createCanvas(context.get());
- FakeCanvas2DLayerBridge layer1(context, canvas1.get());
+ Canvas2DLayerBridgePtr layer1(adoptRef(new FakeCanvas2DLayerBridge(context, canvas1.get())));
EXPECT_EQ((size_t)0, manager.m_bytesAllocated);
- layer1.storageAllocatedForRecordingChanged(1);
+ layer1->storageAllocatedForRecordingChanged(1);
EXPECT_EQ((size_t)1, manager.m_bytesAllocated);
// Test allocation increase
- layer1.storageAllocatedForRecordingChanged(2);
+ layer1->storageAllocatedForRecordingChanged(2);
EXPECT_EQ((size_t)2, manager.m_bytesAllocated);
// Test allocation decrease
- layer1.storageAllocatedForRecordingChanged(1);
+ layer1->storageAllocatedForRecordingChanged(1);
EXPECT_EQ((size_t)1, manager.m_bytesAllocated);
{
OwnPtr<SkDeferredCanvas> canvas2 = createCanvas(context.get());
- FakeCanvas2DLayerBridge layer2(context, canvas2.get());
+ Canvas2DLayerBridgePtr layer2(adoptRef(new FakeCanvas2DLayerBridge(context, canvas2.get())));
EXPECT_EQ((size_t)1, manager.m_bytesAllocated);
// verify multi-layer allocation tracking
- layer2.storageAllocatedForRecordingChanged(2);
+ layer2->storageAllocatedForRecordingChanged(2);
EXPECT_EQ((size_t)3, manager.m_bytesAllocated);
}
// Verify tracking after destruction
@@ -138,15 +143,15 @@ protected:
Canvas2DLayerManager& manager = Canvas2DLayerManager::get();
manager.init(10, 5);
OwnPtr<SkDeferredCanvas> canvas = createCanvas(context.get());
- FakeCanvas2DLayerBridge layer(context, canvas.get());
- layer.fakeFreeableBytes(10);
- layer.storageAllocatedForRecordingChanged(8); // under the max
- EXPECT_EQ(0, layer.m_freeMemoryIfPossibleCount);
- layer.storageAllocatedForRecordingChanged(12); // over the max
- EXPECT_EQ(1, layer.m_freeMemoryIfPossibleCount);
- EXPECT_EQ((size_t)3, layer.m_freeableBytes);
- EXPECT_EQ(0, layer.m_flushCount); // eviction succeeded without triggering a flush
- EXPECT_EQ((size_t)5, layer.bytesAllocated());
+ Canvas2DLayerBridgePtr layer(adoptRef(new FakeCanvas2DLayerBridge(context, canvas.get())));
+ fake(layer)->fakeFreeableBytes(10);
+ layer->storageAllocatedForRecordingChanged(8); // under the max
+ EXPECT_EQ(0, fake(layer)->m_freeMemoryIfPossibleCount);
+ layer->storageAllocatedForRecordingChanged(12); // over the max
+ EXPECT_EQ(1, fake(layer)->m_freeMemoryIfPossibleCount);
+ EXPECT_EQ((size_t)3, fake(layer)->m_freeableBytes);
+ EXPECT_EQ(0, fake(layer)->m_flushCount); // eviction succeeded without triggering a flush
+ EXPECT_EQ((size_t)5, layer->bytesAllocated());
}
void flushEvictionTest()
@@ -155,16 +160,16 @@ protected:
Canvas2DLayerManager& manager = Canvas2DLayerManager::get();
manager.init(10, 5);
OwnPtr<SkDeferredCanvas> canvas = createCanvas(context.get());
- FakeCanvas2DLayerBridge layer(context, canvas.get());
- layer.fakeFreeableBytes(1); // Not enough freeable bytes, will cause aggressive eviction by flushing
- layer.storageAllocatedForRecordingChanged(8); // under the max
- EXPECT_EQ(0, layer.m_freeMemoryIfPossibleCount);
- layer.storageAllocatedForRecordingChanged(12); // over the max
- EXPECT_EQ(2, layer.m_freeMemoryIfPossibleCount); // Two tries, one before flush, one after flush
- EXPECT_EQ((size_t)0, layer.m_freeableBytes);
- EXPECT_EQ(1, layer.m_flushCount); // flush was attempted
- EXPECT_EQ((size_t)11, layer.bytesAllocated()); // flush drops the layer from manager's tracking list
- EXPECT_FALSE(manager.isInList(&layer));
+ Canvas2DLayerBridgePtr layer(adoptRef(new FakeCanvas2DLayerBridge(context, canvas.get())));
+ fake(layer)->fakeFreeableBytes(1); // Not enough freeable bytes, will cause aggressive eviction by flushing
+ layer->storageAllocatedForRecordingChanged(8); // under the max
+ EXPECT_EQ(0, fake(layer)->m_freeMemoryIfPossibleCount);
+ layer->storageAllocatedForRecordingChanged(12); // over the max
+ EXPECT_EQ(2, fake(layer)->m_freeMemoryIfPossibleCount); // Two tries, one before flush, one after flush
+ EXPECT_EQ((size_t)0, fake(layer)->m_freeableBytes);
+ EXPECT_EQ(1, fake(layer)->m_flushCount); // flush was attempted
+ EXPECT_EQ((size_t)11, layer->bytesAllocated()); // flush drops the layer from manager's tracking list
+ EXPECT_FALSE(manager.isInList(layer.get()));
}
void doDeferredFrameTestTask(FakeCanvas2DLayerBridge* layer, bool skipCommands)
@@ -205,35 +210,35 @@ protected:
RefPtr<GraphicsContext3D> context = GraphicsContext3D::createGraphicsContextFromWebContext(adoptPtr(new WebKit::FakeWebGraphicsContext3D));
Canvas2DLayerManager::get().init(10, 10);
OwnPtr<SkDeferredCanvas> canvas = createCanvas(context.get());
- FakeCanvas2DLayerBridge fakeLayer(context, canvas.get());
- WebKit::Platform::current()->currentThread()->postTask(new DeferredFrameTestTask(this, &fakeLayer, true));
+ Canvas2DLayerBridgePtr layer(adoptRef(new FakeCanvas2DLayerBridge(context, canvas.get())));
+ WebKit::Platform::current()->currentThread()->postTask(new DeferredFrameTestTask(this, fake(layer), true));
WebKit::Platform::current()->currentThread()->enterRunLoop();
// Verify that didProcessTask was called upon completion
EXPECT_FALSE(Canvas2DLayerManager::get().m_taskObserverActive);
// Verify that no flush was performed because frame is fresh
- EXPECT_EQ(0, fakeLayer.m_flushCount);
+ EXPECT_EQ(0, fake(layer)->m_flushCount);
// Verify that no flushes are triggered as long as frame are fresh
- WebKit::Platform::current()->currentThread()->postTask(new DeferredFrameTestTask(this, &fakeLayer, true));
+ WebKit::Platform::current()->currentThread()->postTask(new DeferredFrameTestTask(this, fake(layer), true));
WebKit::Platform::current()->currentThread()->enterRunLoop();
EXPECT_FALSE(Canvas2DLayerManager::get().m_taskObserverActive);
- EXPECT_EQ(0, fakeLayer.m_flushCount);
+ EXPECT_EQ(0, fake(layer)->m_flushCount);
- WebKit::Platform::current()->currentThread()->postTask(new DeferredFrameTestTask(this, &fakeLayer, true));
+ WebKit::Platform::current()->currentThread()->postTask(new DeferredFrameTestTask(this, fake(layer), true));
WebKit::Platform::current()->currentThread()->enterRunLoop();
EXPECT_FALSE(Canvas2DLayerManager::get().m_taskObserverActive);
- EXPECT_EQ(0, fakeLayer.m_flushCount);
+ EXPECT_EQ(0, fake(layer)->m_flushCount);
// Verify that a flush is triggered when queue is accumulating a multi-frame backlog.
- WebKit::Platform::current()->currentThread()->postTask(new DeferredFrameTestTask(this, &fakeLayer, false));
+ WebKit::Platform::current()->currentThread()->postTask(new DeferredFrameTestTask(this, fake(layer), false));
WebKit::Platform::current()->currentThread()->enterRunLoop();
EXPECT_FALSE(Canvas2DLayerManager::get().m_taskObserverActive);
- EXPECT_EQ(1, fakeLayer.m_flushCount);
+ EXPECT_EQ(1, fake(layer)->m_flushCount);
- WebKit::Platform::current()->currentThread()->postTask(new DeferredFrameTestTask(this, &fakeLayer, false));
+ WebKit::Platform::current()->currentThread()->postTask(new DeferredFrameTestTask(this, fake(layer), false));
WebKit::Platform::current()->currentThread()->enterRunLoop();
EXPECT_FALSE(Canvas2DLayerManager::get().m_taskObserverActive);
- EXPECT_EQ(2, fakeLayer.m_flushCount);
+ EXPECT_EQ(2, fake(layer)->m_flushCount);
}
};
« no previous file with comments | « Source/core/platform/graphics/chromium/Canvas2DLayerBridgeTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698