Skip to content

Commit

Permalink
fix bug while task does not submit
Browse files Browse the repository at this point in the history
  • Loading branch information
Hparty committed Oct 30, 2024
1 parent aec4220 commit f191431
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/gpu/OpContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "gpu/ops/FillRectOp.h"

namespace tgfx {
static constexpr uint32_t InvalidContentVersion = 0;

void OpContext::fillWithFP(std::unique_ptr<FragmentProcessor> fp, const Matrix& uvMatrix,
bool autoResolve) {
fillRectWithFP(Rect::MakeWH(renderTargetProxy->width(), renderTargetProxy->height()),
Expand All @@ -46,8 +48,10 @@ void OpContext::addOp(std::unique_ptr<Op> 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
10 changes: 5 additions & 5 deletions test/src/LayerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit f191431

Please sign in to comment.