Skip to content

Commit

Permalink
NanovgSession : CodeReview
Browse files Browse the repository at this point in the history
  • Loading branch information
vinsentli committed Dec 5, 2024
1 parent aac07ce commit 8387a6b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
23 changes: 6 additions & 17 deletions shell/renderSessions/NanovgSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@

namespace igl::shell {

double getMilliSeconds() {
return std::chrono::duration<double>(std::chrono::time_point_cast<std::chrono::milliseconds>(
std::chrono::high_resolution_clock::now())
.time_since_epoch())
.count();
}

int NanovgSession::loadDemoData(NVGcontext* vg, DemoData* data) {
auto getImageFullPath = ([this](const std::string& name) {
#if IGL_PLATFORM_ANDROID
Expand Down Expand Up @@ -90,7 +83,7 @@ int NanovgSession::loadDemoData(NVGcontext* vg, DemoData* data) {
}

void NanovgSession::initialize() noexcept {
const CommandQueueDesc desc{CommandQueueType::Graphics};
const CommandQueueDesc desc{.type = CommandQueueType::Graphics};
commandQueue_ = getPlatform().getDevice().createCommandQueue(desc, nullptr);

renderPass_.colorAttachments.resize(1);
Expand Down Expand Up @@ -173,9 +166,7 @@ void NanovgSession::drawNanovg(float __width,
int my = mouseListener_->mouseY;
#endif

int blowup = 0;

auto start_ms = getMilliSeconds();
auto start = getSeconds();

nvgBeginFrame(vg, width, height, pxRatio);
iglu::nanovg::SetRenderCommandEncoder(
Expand All @@ -186,20 +177,18 @@ void NanovgSession::drawNanovg(float __width,

times_++;

renderDemo(vg, mx, my, width, height, times_ / 60.0f, blowup, &nvgDemoData_);
renderDemo(vg, mx, my, width, height, times_ / 60.0f, 0, &nvgDemoData_);

renderGraph(vg, 5, 5, &fps_);
renderGraph(vg, 5 + 200 + 5, 5, &cpuGraph_);
renderGraph(vg, 5 + 200 + 5 + 200 + 5, 5, &gpuGraph_);

nvgEndFrame(vg);

auto end_ms = getMilliSeconds();

updateGraph(&fps_, (start_ms - preTimestamp_));
updateGraph(&cpuGraph_, (end_ms - start_ms));
auto end = getSeconds();

preTimestamp_ = start_ms;
updateGraph(&fps_, getDeltaSeconds());
updateGraph(&cpuGraph_, (end - start));
}

} // namespace igl::shell
1 change: 0 additions & 1 deletion shell/renderSessions/NanovgSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class NanovgSession : public RenderSession {
std::shared_ptr<TouchListener> touchListener_;

PerfGraph fps_, cpuGraph_, gpuGraph_;
double preTimestamp_;
};

} // namespace igl::shell

0 comments on commit 8387a6b

Please sign in to comment.