Skip to content

Commit

Permalink
minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
wkjarosz committed Mar 24, 2024
1 parent 881d56c commit 460ec46
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
6 changes: 4 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

##

- [ ] sort image list
- [ ] left vs. right align images in image list
- [x] have spdlog output to the log window
- [x] add image and channel list filtering
- [x] load images asynchronously
Expand All @@ -13,10 +15,10 @@
- [ ] figure out how to better handle channels dropdown with channel groups and arbitrary channels
- [ ] improve statistics
- [x] compute min/max/avg ignoring infinities, and report # of infinities
- [ ] compute statistics also over selection
- [ ] account for blend mode when computing pixel hover (and statistics)
- [ ] figure our threading while considering emscripten
- [x] figure our threading while considering emscripten
- [ ] selection support
- [ ] compute statistics also over selection
- [ ] command palette/improved hotkey support
- [ ] save as support for OpenEXR
- [ ] handle multi-view EXRs better
Expand Down
7 changes: 3 additions & 4 deletions src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static const vector<std::pair<const char *, const char *>> g_help_strings = {
{"Scroll mouse/pinch", "Zoom in and out continuously"},
{"Cmd+O", "Open image"},
{"Cmd+W", "Close image"},
{"Cmd+Shift+W", "Close image"},
{"Cmd+Shift+W", "Close all images"},
{ICON_FA_ARROW_DOWN "," ICON_FA_ARROW_UP,
"Switch to previous (" ICON_FA_ARROW_UP ") or next (" ICON_FA_ARROW_DOWN ") image"},
{ICON_FA_ARROW_LEFT "," ICON_FA_ARROW_RIGHT,
Expand Down Expand Up @@ -555,13 +555,12 @@ void HDRViewApp::draw_menus()

if (ImGui::BeginMenu("Help"))
{
if (ImGui::MenuItem(ICON_FA_UP_RIGHT_FROM_SQUARE " Open HDRView github repository"))
ImmApp::BrowseToUrl("https://github.com/wkjarosz/hdrview");
ImGui::MenuItem(ICON_FA_RULER " Metrics/Debugger", nullptr, &g_show_tool_metrics);
ImGui::MenuItem(ICON_FA_TERMINAL " Debug Log", nullptr, &g_show_tool_debug_log);
ImGui::MenuItem(ICON_FA_DATABASE " ID Stack Tool", nullptr, &g_show_tool_id_stack_tool);
ImGui::MenuItem(ICON_FA_ID_CARD " ID Stack Tool", nullptr, &g_show_tool_id_stack_tool);
ImGui::MenuItem(ICON_FA_SLIDERS " Style Editor", nullptr, &g_show_tool_style_editor);
ImGui::MenuItem(ICON_FA_CIRCLE_INFO " About Dear ImGui", nullptr, &g_show_tool_about);
ImGui::Separator();
ImGui::MenuItem(ICON_FA_CIRCLE_INFO " About HDRView", nullptr, &g_show_help);
ImGui::EndMenu();
}
Expand Down
12 changes: 6 additions & 6 deletions src/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,25 @@ thread_local int Scheduler::m_thread_index = Scheduler::
int Scheduler::m_next_guest_thread_index = 0;
thread_local Scheduler::Task *Scheduler::m_thread_task = nullptr;

static Scheduler *s_singleton = nullptr;
static std::mutex s_singleton_lock;
static std::unique_ptr<Scheduler> s_singleton;
static std::mutex s_singleton_lock;

Scheduler *Scheduler::singleton()
{
std::unique_lock<std::mutex> guard(s_singleton_lock);

if (!s_singleton)
{
s_singleton = new Scheduler();
s_singleton = std::make_unique<Scheduler>();
s_singleton->start();
}

return s_singleton;
return s_singleton.get();
}

Scheduler::Scheduler() {}

Scheduler::~Scheduler() {}
Scheduler::~Scheduler() { stop(); }

static int get_nesting_level(const Scheduler::Task *task)
{
Expand Down Expand Up @@ -319,7 +319,7 @@ void Scheduler::stop()
if (m_workers.empty())
return;

// Push invalid tasks, one for each thread. The invalid task will make a thread to terminate
// Push invalid tasks, one for each thread. The invalid task will make a thread terminate
{
std::unique_lock<std::mutex> lock(m_work_mutex);
for (size_t i = 0; i < m_workers.size(); ++i)
Expand Down
9 changes: 7 additions & 2 deletions src/scheduler.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Based on the article and code at:
// https://maxliani.wordpress.com/2022/07/27/anatomy-of-a-task-scheduler/
//
// Copyright (c) 2022 Max Liani
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -12,6 +15,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//
//
//
// Modifications by Wojciech Jarosz (c) 2024, released under the same Apache License as above
// - Added ability to run tasks in serial, bypassing the thread pool
Expand All @@ -25,7 +30,7 @@
// higher-level API and allow creating tasks with lambdas containing captures Fixed a few type inconsistencies (mixing
// uint32_t with int)
// - fixed minor spelling mistakes
// - converte to snake_casing, and added some more comments.
// - converted to snake_casing, and added some more comments.
//

// scheduler.h
Expand Down Expand Up @@ -357,7 +362,7 @@ class Scheduler
\param front Insert new tasks to the front of the queue or at the back. Typically,
nested parallelism inserts at the front to complete as soon as possible, before
outer parallelism is exhausted; while new outer parallelization is pushes at the
back of the queue, to let existing workload to complete first.
back of the queue, to let existing workloads complete first.
*/
TaskTracker async(int num_units, void *data, TaskFn f, TaskFn epilogue = nullptr, int reserved_units = 0,
bool front = false);
Expand Down

0 comments on commit 460ec46

Please sign in to comment.