diff --git a/src/gpu/OpContext.cpp b/src/gpu/OpContext.cpp index d83edf0..91f2338 100644 --- a/src/gpu/OpContext.cpp +++ b/src/gpu/OpContext.cpp @@ -21,6 +21,8 @@ #include "gpu/ops/FillRectOp.h" namespace tgfx { +static constexpr uint32_t InvalidContentVersion = 0; + void OpContext::fillWithFP(std::unique_ptr fp, const Matrix& uvMatrix, bool autoResolve) { fillRectWithFP(Rect::MakeWH(renderTargetProxy->width(), renderTargetProxy->height()), @@ -46,8 +48,10 @@ void OpContext::addOp(std::unique_ptr op) { if (opsTask == nullptr || opsTask->isClosed()) { auto drawingManager = renderTargetProxy->getContext()->drawingManager(); opsTask = drawingManager->addOpsTask(renderTargetProxy); - _contentVersion++; } opsTask->addOp(std::move(op)); + do { + _contentVersion++; + } while (InvalidContentVersion == _contentVersion); } } // namespace tgfx diff --git a/test/src/LayerTest.cpp b/test/src/LayerTest.cpp index 826a050..ff7a9b7 100644 --- a/test/src/LayerTest.cpp +++ b/test/src/LayerTest.cpp @@ -683,18 +683,18 @@ TGFX_TEST(LayerTest, ContentVersion) { displayList.root()->addChild(shapeLayer); auto contentVersion = surface->contentVersion(); displayList.render(surface.get()); - ASSERT_NE(surface->contentVersion(), contentVersion); + EXPECT_NE(surface->contentVersion(), contentVersion); contentVersion = surface->contentVersion(); displayList.render(surface.get()); - ASSERT_EQ(surface->contentVersion(), contentVersion); + EXPECT_EQ(surface->contentVersion(), contentVersion); displayList.render(surface.get(), false); - ASSERT_NE(surface->contentVersion(), contentVersion); + EXPECT_NE(surface->contentVersion(), contentVersion); contentVersion = surface->contentVersion(); surface->getCanvas()->clear(); - ASSERT_NE(surface->contentVersion(), contentVersion); + EXPECT_NE(surface->contentVersion(), contentVersion); contentVersion = surface->contentVersion(); displayList.render(surface.get()); - ASSERT_NE(surface->contentVersion(), contentVersion); + EXPECT_NE(surface->contentVersion(), contentVersion); device->unlock(); }