From b0fd2cbc500576e9b7421f27619562708cb545f0 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Fri, 21 Jun 2024 05:20:39 -0500 Subject: [PATCH 001/129] Create a basic outline --- CMakeLists.txt | 2 + include/gui/project/window.hpp | 101 +++++++++++++++++++++++++++++++++ src/gui/logging/window.cpp | 1 + src/gui/project/window.cpp | 31 ++++++++++ 4 files changed, 135 insertions(+) create mode 100644 include/gui/project/window.hpp create mode 100644 src/gui/project/window.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b9ebcc1c..2028e3fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,8 @@ file(GLOB TOOLBOX_SRC "include/gui/layer/*.hpp" "src/gui/pad/*.cpp" "include/gui/pad/*.hpp" + "src/gui/project/*.cpp" + "include/gui/project/*.hpp" "src/gui/widget/*.cpp" "include/gui/widget/*.hpp" "src/image/*.cpp" diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp new file mode 100644 index 00000000..76c280b4 --- /dev/null +++ b/include/gui/project/window.hpp @@ -0,0 +1,101 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "core/memory.hpp" +#include "fsystem.hpp" +#include "objlib/object.hpp" +#include "objlib/template.hpp" +#include "scene/scene.hpp" +#include "smart_resource.hpp" + +#include "core/clipboard.hpp" +#include "game/task.hpp" +#include "gui/event/event.hpp" +#include "gui/image/imagepainter.hpp" +#include "gui/window.hpp" + +#include + +namespace Toolbox::UI { + + class ProjectViewWindow final : public ImWindow { + public: + ProjectViewWindow(const std::string &name); + ~ProjectViewWindow() = default; + + protected: + void onRenderMenuBar() override; + void onRenderBody(TimeStep delta_time) override; + + void renderProjectTreeView(); + void renderProjectFolderView(); + void renderProjectFolderButton(); + void renderProjectFileButton(); + + public: + ImGuiWindowFlags flags() const override { + return ImWindow::flags() | ImGuiWindowFlags_MenuBar; + } + + const ImGuiWindowClass *windowClass() const override { + if (parent() && parent()->windowClass()) { + return parent()->windowClass(); + } + + ImGuiWindow *currentWindow = ImGui::GetCurrentWindow(); + m_window_class.ClassId = (ImGuiID)getUUID(); + m_window_class.ParentViewportId = currentWindow->ViewportId; + m_window_class.DockingAllowUnclassed = true; + m_window_class.DockingAlwaysTabBar = false; + return nullptr; + } + + std::optional minSize() const override { + return { + {600, 400} + }; + } + + [[nodiscard]] std::string context() const override { + if (!m_project_root) + return "(unknown)"; + return m_project_root->string(); + } + + [[nodiscard]] bool unsaved() const override { return false; } + + // Returns the supported file types, empty string is designed for a folder. + [[nodiscard]] std::vector extensions() const override { + return {}; + } + + [[nodiscard]] bool onLoadData(const std::filesystem::path& path) override { + m_project_root = path; + return true; + } + [[nodiscard]] bool onSaveData(std::optional path) override { + return true; + } + + void onAttach() override; + void onDetach() override; + void onImGuiUpdate(TimeStep delta_time) override; + void onContextMenuEvent(RefPtr ev) override; + void onDragEvent(RefPtr ev) override; + void onDropEvent(RefPtr ev) override; + + private: + fs_path m_project_root; + + // TODO: Have filesystem model. + std::unordered_map m_icon_map; + ImagePainter m_icon_painter; + }; + +} // namespace Toolbox::UI \ No newline at end of file diff --git a/src/gui/logging/window.cpp b/src/gui/logging/window.cpp index 261c0003..107fd413 100644 --- a/src/gui/logging/window.cpp +++ b/src/gui/logging/window.cpp @@ -2,6 +2,7 @@ #include "gui/font.hpp" #include "gui/logging/window.hpp" +#include "window.hpp" static std::string s_message_pool; diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp new file mode 100644 index 00000000..97152c90 --- /dev/null +++ b/src/gui/project/window.cpp @@ -0,0 +1,31 @@ +#include "gui/project/window.hpp" + +namespace Toolbox::UI { + + ProjectViewWindow::ProjectViewWindow(const std::string &name) : ImWindow(name) {} + + void ProjectViewWindow::onRenderMenuBar() {} + + void ProjectViewWindow::onRenderBody(TimeStep delta_time) {} + + void ProjectViewWindow::renderProjectTreeView() {} + + void ProjectViewWindow::renderProjectFolderView() {} + + void ProjectViewWindow::renderProjectFolderButton() {} + + void ProjectViewWindow::renderProjectFileButton() {} + + void ProjectViewWindow::onAttach() {} + + void ProjectViewWindow::onDetach() {} + + void ProjectViewWindow::onImGuiUpdate(TimeStep delta_time) {} + + void ProjectViewWindow::onContextMenuEvent(RefPtr ev) {} + + void ProjectViewWindow::onDragEvent(RefPtr ev) {} + + void ProjectViewWindow::onDropEvent(RefPtr ev) {} + +} // namespace Toolbox::UI \ No newline at end of file From 004a58a76796aa508bd85a7eb79a7dc0f0e5845d Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Fri, 21 Jun 2024 05:21:14 -0500 Subject: [PATCH 002/129] Context fix --- include/gui/project/window.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 76c280b4..f4c9f9ce 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -63,9 +63,7 @@ namespace Toolbox::UI { } [[nodiscard]] std::string context() const override { - if (!m_project_root) - return "(unknown)"; - return m_project_root->string(); + return m_project_root.string(); } [[nodiscard]] bool unsaved() const override { return false; } From 70867eb2218eab92ac882afb289c19f3681b04c4 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Fri, 21 Jun 2024 06:53:01 -0500 Subject: [PATCH 003/129] Create filesystem model outline --- include/model/fsmodel.hpp | 128 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 include/model/fsmodel.hpp diff --git a/include/model/fsmodel.hpp b/include/model/fsmodel.hpp new file mode 100644 index 00000000..5c7c63e7 --- /dev/null +++ b/include/model/fsmodel.hpp @@ -0,0 +1,128 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "core/mimedata/mimedata.hpp" +#include "fsystem.hpp" +#include "image/imagehandle.hpp" +#include "unique.hpp" + +namespace Toolbox { + + enum class ModelSortOrder { + SORT_ASCENDING, + SORT_DESCENDING, + }; + + class ModelIndex : public IUnique { + public: + ModelIndex() = default; + ModelIndex(int64_t row, int64_t column, UUID64 model_uuid) + : m_row(row), m_column(column), m_model_uuid(model_uuid) {} + + bool isValid() const { return m_row >= 0 && m_column >= 0 && m_model_uuid != 0; } + + template [[nodiscard]] data() const { + return reinterpret_cast(m_user_data); + } + void setData(void *data) { m_user_data = data; } + + [[nodiscard]] UUID64 getUUID() const override { return m_uuid; } + [[nodiscard]] UUID64 getModelUUID() const { return m_model_uuid; } + + private: + UUID64 m_uuid; + UUID64 m_model_uuid = 0; + + int64_t m_row = -1; + int64_t m_column = -1; + + void *m_user_data = nullptr; + }; + + class FileSystemModel { + public: + enum class Options { + DISABLE_WATCHDOG = BIT(0), + DISABLE_SYMLINKS = BIT(1), + }; + TOOLBOX_BITWISE_ENUM(Options) + + public: + FileSystemModel() = default; + ~FileSystemModel() = default; + + const fs_path &getRoot() const &; + void setRoot(const fs_path &path); + + const std::string &getFilter() const &; + void setFilter(const std::string &filter); + + Options getOptions() const; + void setOptions(Options options); + + bool isReadOnly() const; + void setReadOnly(); + + bool isDirectory(const ModelIndex &index); + bool isFile(const ModelIndex &index); + bool isArchive(const ModelIndex &index); + + size_t getFileSize(const ModelIndex &index); + size_t getDirSize(const ModelIndex &index, bool recursive); + + const ImageHandle &getIcon(const ModelIndex &index) const &; + Filesystem::file_time_type getLastModified(const ModelIndex &index) const; + Filesystem::perms getPermissions(const ModelIndex &index) const; + const Filesystem::file_status &getStatus(const ModelIndex &index) const &; + + std::string getType(const ModelIndex &index) const &; + + ModelIndex mkdir(const ModelIndex &parent, const std::string &name); + ModelIndex touch(const ModelIndex &parent, const std::string &name); + + bool rmdir(const ModelIndex &index); + bool remove(const ModelIndex &index); + + public: + const ModelIndex &getIndex(const fs_path &path) const &; + const ModelIndex &getIndex(int64_t row, int64_t column, + ModelIndex &parent = ModelIndex()) const &; + const fs_path &getPath(const ModelIndex &index) const &; + + const Modelindex &getParent(const ModelIndex &index) const &; + const ModelIndex &getSibling(int64_t row, int64_t column, const ModelIndex &index); + + size_t getColumnCount(const ModelIndex &index) const; + size_t getRowCount(const ModelIndex &index) const; + + bool hasChildren(const ModelIndex &parent = ModelIndex()) const; + + ScopePtr createMimeData(const std::vector &indexes) const; + std::vector getSupportedMimeTypes() const; + + bool canFetchMore(const ModelIndex &index); + void fetchMore(const ModelIndex &index);); + + void sort(int64_t column, ModelSortOrder order = ModelSortOrder::SORT_ASCENDING); + + protected: + void cacheIndex(ModelIndex &index); + void cacheFolder(ModelIndex &index); + void cacheFile(ModelIndex &index); + void cacheArchive(ModelIndex &index); + + const ModelIndex &getParentArchive(const ModelIndex &index); + + private: + fs_path m_root_path; + }; + +} // namespace Toolbox \ No newline at end of file From 87195701ef8f4ac4c0b375c605366b03bf405d3a Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Wed, 10 Jul 2024 00:13:31 -0500 Subject: [PATCH 004/129] Fix path issue for Dolphin integration --- src/dolphin/hook.cpp | 2 +- src/gui/logging/window.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dolphin/hook.cpp b/src/dolphin/hook.cpp index 709a7ce7..55cb5dae 100644 --- a/src/dolphin/hook.cpp +++ b/src/dolphin/hook.cpp @@ -122,7 +122,7 @@ namespace Toolbox::Dolphin { } std::string dolphin_args = - std::format("-e {}/sys/main.dol -d -c -a HLE", application.getProjectRoot().string()); + std::format("-e \"{}/sys/main.dol\" -d -c -a HLE", application.getProjectRoot().string()); auto process_result = Platform::CreateExProcess(settings.m_dolphin_path, dolphin_args); if (!process_result) { diff --git a/src/gui/logging/window.cpp b/src/gui/logging/window.cpp index 107fd413..8bf21f66 100644 --- a/src/gui/logging/window.cpp +++ b/src/gui/logging/window.cpp @@ -2,7 +2,7 @@ #include "gui/font.hpp" #include "gui/logging/window.hpp" -#include "window.hpp" +#include "gui/window.hpp" static std::string s_message_pool; From 2868efb627e5b702674b97159300154bfbab9585 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Wed, 4 Sep 2024 23:50:15 -0500 Subject: [PATCH 005/129] Current progress --- Templates/KeyChest.json | 67 ++++++++++++++++++++++++++++++++++++++++ Templates/KeyFollow.json | 67 ++++++++++++++++++++++++++++++++++++++++ src/gui/pad/recorder.cpp | 4 ++- src/gui/scene/window.cpp | 36 +++++++++++++++------ 4 files changed, 164 insertions(+), 10 deletions(-) create mode 100644 Templates/KeyChest.json create mode 100644 Templates/KeyFollow.json diff --git a/Templates/KeyChest.json b/Templates/KeyChest.json new file mode 100644 index 00000000..c5c5a7a7 --- /dev/null +++ b/Templates/KeyChest.json @@ -0,0 +1,67 @@ +{ + "Key Chest": { + "Enums": {}, + "Structs": { + "LightInfo": { + "ID": { + "Type": "INT", + "ArraySize": 1 + }, + "Name": { + "Type": "STRING", + "ArraySize": 1 + } + } + }, + "Members": { + "Transform": { + "Type": "TRANSFORM", + "ArraySize": 1 + }, + "Character": { + "Type": "STRING", + "ArraySize": 1 + }, + "LightCount": { + "Type": "U32", + "ArraySize": 1 + }, + "LightArray": { + "Type": "LightInfo", + "ArraySize": "LightCount" + }, + "Model": { + "Type": "STRING", + "ArraySize": 1 + } + }, + "Wizard": { + "Default": { + "Transform": [ + [ + 0, + 0, + 0 + ], + [ + 0, + 0, + 0 + ], + [ + 1, + 1, + 1 + ] + ], + "Character": "KeyChest キャラ", + "LightCount": 0, + "LightArray": { + "ID": 0, + "Name": "LightX" + }, + "Model": "key_chest" + } + } + } +} \ No newline at end of file diff --git a/Templates/KeyFollow.json b/Templates/KeyFollow.json new file mode 100644 index 00000000..fde51879 --- /dev/null +++ b/Templates/KeyFollow.json @@ -0,0 +1,67 @@ +{ + "Key Chest": { + "Enums": {}, + "Structs": { + "LightInfo": { + "ID": { + "Type": "INT", + "ArraySize": 1 + }, + "Name": { + "Type": "STRING", + "ArraySize": 1 + } + } + }, + "Members": { + "Transform": { + "Type": "TRANSFORM", + "ArraySize": 1 + }, + "Character": { + "Type": "STRING", + "ArraySize": 1 + }, + "LightCount": { + "Type": "U32", + "ArraySize": 1 + }, + "LightArray": { + "Type": "LightInfo", + "ArraySize": "LightCount" + }, + "Model": { + "Type": "STRING", + "ArraySize": 1 + } + }, + "Wizard": { + "Default": { + "Transform": [ + [ + 0, + 0, + 0 + ], + [ + 0, + 0, + 0 + ], + [ + 1, + 1, + 1 + ] + ], + "Character": "KeyFollow キャラ", + "LightCount": 0, + "LightArray": { + "ID": 0, + "Name": "LightX" + }, + "Model": "key_follow" + } + } + } +} \ No newline at end of file diff --git a/src/gui/pad/recorder.cpp b/src/gui/pad/recorder.cpp index 35773588..3123bac5 100644 --- a/src/gui/pad/recorder.cpp +++ b/src/gui/pad/recorder.cpp @@ -333,10 +333,12 @@ namespace Toolbox { Toolbox::Filesystem::create_directories(folder_path) .and_then([&](bool created) { + #if 0 if (!created) { return make_fs_error(std::error_code(), - {"[PAD RECORD] Failed to create folder."}); + {"[PAD RECORD] Folder already exists."}); } + #endif return saveToFolder_(folder_path); }) .and_then([&](bool success) { diff --git a/src/gui/scene/window.cpp b/src/gui/scene/window.cpp index 63f76841..fe0fde19 100644 --- a/src/gui/scene/window.cpp +++ b/src/gui/scene/window.cpp @@ -162,6 +162,11 @@ namespace Toolbox::UI { bool SceneWindow::onSaveData(std::optional path) { std::filesystem::path root_path; + if (!m_current_scene) { + TOOLBOX_ERROR("(SCENE) Failed to save the scene due to lack of a scene instance."); + return false; + } + if (!path) { auto opt_path = m_current_scene->rootPath(); if (!opt_path) { @@ -239,6 +244,10 @@ namespace Toolbox::UI { m_is_game_edit_mode = false; } + if (!m_current_scene) { + return; + } + std::vector> rendered_nodes; for (auto &rail : m_current_scene->getRailData().rails()) { if (!m_rail_visible_map[rail->getUUID()]) @@ -369,10 +378,15 @@ namespace Toolbox::UI { case SCENE_CREATE_RAIL_EVENT: { auto event = std::static_pointer_cast(ev); if (event) { - const Rail::Rail &rail = event->getRail(); - m_current_scene->getRailData().addRail(rail); - m_rail_visible_map[rail.getUUID()] = true; - ev->accept(); + if (m_current_scene) { + const Rail::Rail &rail = event->getRail(); + m_current_scene->getRailData().addRail(rail); + m_rail_visible_map[rail.getUUID()] = true; + ev->accept(); + } else { + TOOLBOX_ERROR("Failed to create rail due to lack of a scene instance."); + ev->ignore(); + } } break; } @@ -431,8 +445,8 @@ void SceneWindow::renderHierarchy() { // Render Objects - if (m_current_scene != nullptr) { - auto root = m_current_scene->getObjHierarchy().getRoot(); + if (m_current_scene) { + RefPtr root = m_current_scene->getObjHierarchy().getRoot(); renderTree(0, root); } @@ -440,8 +454,8 @@ void SceneWindow::renderHierarchy() { ImGui::Text("Scene Info"); ImGui::Separator(); - if (m_current_scene != nullptr) { - auto root = m_current_scene->getTableHierarchy().getRoot(); + if (m_current_scene) { + RefPtr root = m_current_scene->getTableHierarchy().getRoot(); renderTree(0, root); } } @@ -990,6 +1004,10 @@ void SceneWindow::reassignAllActorPtrs(u32 param) { } void SceneWindow::renderRailEditor() { + if (!m_current_scene) { + return; + } + const std::string rail_editor_str = ImWindowComponentTitle(*this, "Rail Editor"); const ImGuiTreeNodeFlags rail_flags = ImGuiTreeNodeFlags_OpenOnArrow | @@ -1215,7 +1233,7 @@ void SceneWindow::renderScene(TimeStep delta_time) { std::vector lights; // perhaps find a way to limit this so it only happens when we need to re-render? - if (m_current_scene != nullptr) { + if (m_current_scene) { if (m_update_render_objs || !settings.m_is_rendering_simple) { m_renderables.clear(); auto perform_result = m_current_scene->getObjHierarchy().getRoot()->performScene( From 8fb0202bd4eb8c4983bfd9b09eee193f38afe27c Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Sat, 7 Sep 2024 04:59:47 -0500 Subject: [PATCH 006/129] Migrate work into a ProjectManager --- CMakeLists.txt | 2 ++ include/fsystem.hpp | 2 +- include/gui/application.hpp | 10 +++--- include/model/fsmodel.hpp | 2 +- include/project/project.hpp | 35 +++++++++++++++++++ include/scene/layout.hpp | 2 +- include/scene/scene.hpp | 24 ++++++++++++- src/dolphin/hook.cpp | 3 +- src/gui/application.cpp | 17 ++-------- src/objlib/template.cpp | 52 +++++++++++++++------------- src/project/project.cpp | 46 +++++++++++++++++++++++++ src/scene/layout.cpp | 26 +++++++------- src/scene/scene.cpp | 68 ++++++++++++++++++------------------- 13 files changed, 194 insertions(+), 95 deletions(-) create mode 100644 include/project/project.hpp create mode 100644 src/project/project.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 2028e3fc..3677621b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,8 @@ file(GLOB TOOLBOX_SRC "include/pad/*.hpp" "src/platform/*.cpp" "include/platform/*.hpp" + "src/project/*.cpp" + "include/project/*.hpp" "src/rail/*.cpp" "include/rail/*.hpp" "src/rarc/*.cpp" diff --git a/include/fsystem.hpp b/include/fsystem.hpp index 1acc8225..3b217a6b 100644 --- a/include/fsystem.hpp +++ b/include/fsystem.hpp @@ -380,7 +380,7 @@ namespace Toolbox { if (result) { return result; } - if (ec) { + if (ec && ec != std::errc::no_such_file_or_directory) { return make_fs_error(ec); } return result; diff --git a/include/gui/application.hpp b/include/gui/application.hpp index 4daa078f..bb3d9349 100644 --- a/include/gui/application.hpp +++ b/include/gui/application.hpp @@ -22,6 +22,8 @@ #include "core/clipboard.hpp" #include "dolphin/process.hpp" +#include "project/project.hpp" + #include "scene/layout.hpp" using namespace Toolbox::Dolphin; @@ -116,7 +118,8 @@ namespace Toolbox { DolphinCommunicator &getDolphinCommunicator() { return m_dolphin_communicator; } Game::TaskCommunicator &getTaskCommunicator() { return m_task_communicator; } - std::filesystem::path getProjectRoot() const { return m_project_root; } + ProjectManager &getProjectManager() { return m_project_manager; } + const ProjectManager &getProjectManager() const { return m_project_manager; } void registerDolphinOverlay(UUID64 scene_uuid, const std::string &name, @@ -155,12 +158,11 @@ namespace Toolbox { TypedDataClipboard> m_rail_clipboard; TypedDataClipboard> m_rail_node_clipboard; - std::filesystem::path m_project_root = std::filesystem::current_path(); + ProjectManager m_project_manager; + std::filesystem::path m_load_path = std::filesystem::current_path(); std::filesystem::path m_save_path = std::filesystem::current_path(); - ScopePtr m_scene_layout_manager; - GLFWwindow *m_render_window; std::vector> m_windows; diff --git a/include/model/fsmodel.hpp b/include/model/fsmodel.hpp index 5c7c63e7..49d30be7 100644 --- a/include/model/fsmodel.hpp +++ b/include/model/fsmodel.hpp @@ -109,7 +109,7 @@ namespace Toolbox { std::vector getSupportedMimeTypes() const; bool canFetchMore(const ModelIndex &index); - void fetchMore(const ModelIndex &index);); + void fetchMore(const ModelIndex &index); void sort(int64_t column, ModelSortOrder order = ModelSortOrder::SORT_ASCENDING); diff --git a/include/project/project.hpp b/include/project/project.hpp new file mode 100644 index 00000000..90735e3b --- /dev/null +++ b/include/project/project.hpp @@ -0,0 +1,35 @@ +#pragma once + +#include + +#include "fsystem.hpp" +#include "scene/layout.hpp" + +namespace Toolbox { + + class ProjectManager { + public: + ProjectManager() = default; + ProjectManager(const ProjectManager &) = delete; + ProjectManager(ProjectManager &&) = default; + + ~ProjectManager() = default; + + bool isInitialized(); + bool loadProjectFolder(const fs_path &path); + + fs_path getProjectFolder() const; + Scene::SceneLayoutManager &getSceneLayoutManager(); + const Scene::SceneLayoutManager &getSceneLayoutManager() const; + + ProjectManager &operator=(const ProjectManager &) = delete; + ProjectManager &operator=(ProjectManager &&) = default; + + private: + bool m_is_initialized; + fs_path m_project_folder; + + Scene::SceneLayoutManager m_scene_layout_manager; + }; + +} // namespace Toolbox \ No newline at end of file diff --git a/include/scene/layout.hpp b/include/scene/layout.hpp index 4e88c97c..ac95a2d1 100644 --- a/include/scene/layout.hpp +++ b/include/scene/layout.hpp @@ -38,7 +38,7 @@ namespace Toolbox::Scene { bool operator==(const SceneLayoutManager &) const = default; private: - ScopePtr m_scene_layout; + ObjectHierarchy m_scene_layout; }; } // namespace Toolbox::Scene \ No newline at end of file diff --git a/include/scene/scene.hpp b/include/scene/scene.hpp index ff910de7..b3a2c155 100644 --- a/include/scene/scene.hpp +++ b/include/scene/scene.hpp @@ -55,11 +55,33 @@ namespace Toolbox { } Result serialize(Serializer &out) const override { + if (!m_root) { + return make_serial_error(out, "Root object is null"); + } return m_root->serialize(out); } Result deserialize(Deserializer &in) override { - return m_root->deserialize(in); + SerialError err = {}; + bool error = false; + + ObjectFactory::create(in) + .and_then([&](auto &&obj) { + m_root = + std::static_pointer_cast(std::move(obj)); + return Result(); + }) + .or_else([&](SerialError &&e) { + err = std::move(e); + error = true; + return Result(); + }); + + if (error) { + return std::unexpected(err); + } + + return Result(); } ScopePtr clone(bool deep) const override { diff --git a/src/dolphin/hook.cpp b/src/dolphin/hook.cpp index 55cb5dae..979a9c29 100644 --- a/src/dolphin/hook.cpp +++ b/src/dolphin/hook.cpp @@ -122,7 +122,8 @@ namespace Toolbox::Dolphin { } std::string dolphin_args = - std::format("-e \"{}/sys/main.dol\" -d -c -a HLE", application.getProjectRoot().string()); + std::format("-e \"{}/sys/main.dol\" -d -c -a HLE", + application.getProjectManager().getProjectFolder().string()); auto process_result = Platform::CreateExProcess(settings.m_dolphin_path, dolphin_args); if (!process_result) { diff --git a/src/gui/application.cpp b/src/gui/application.cpp index c157bd81..0cece844 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -429,21 +429,8 @@ namespace Toolbox { } } } else { - auto sys_path = std::filesystem::path(path) / "sys"; - auto files_path = std::filesystem::path(path) / "files"; - - auto sys_result = Toolbox::Filesystem::is_directory(sys_path); - auto files_result = Toolbox::Filesystem::is_directory(files_path); - - if ((sys_result && sys_result.value()) && - (files_result && files_result.value())) { - // TODO: Open project folder view - m_project_root = path; - - // Process the stageArc.bin - fs_path layout_path = path / "files" / "data" / "stageArc.bin"; - m_scene_layout_manager - ->loadFromPath(layout_path); + if (m_project_manager.loadProjectFolder(path)) { + TOOLBOX_INFO_V("Loaded project folder: {}", path.string()); } } } diff --git a/src/objlib/template.cpp b/src/objlib/template.cpp index 15249406..696f30a7 100644 --- a/src/objlib/template.cpp +++ b/src/objlib/template.cpp @@ -6,15 +6,17 @@ #include -#include "objlib/template.hpp" #include "color.hpp" -#include "gui/settings.hpp" #include "jsonlib.hpp" #include "magic_enum.hpp" +#include "core/log.hpp" +#include "gui/settings.hpp" #include "objlib/meta/enum.hpp" #include "objlib/meta/member.hpp" #include "objlib/meta/struct.hpp" +#include "objlib/template.hpp" #include "objlib/transform.hpp" +#include "gui/logging/errors.hpp" namespace Toolbox::Object { @@ -561,30 +563,32 @@ namespace Toolbox::Object { } } - auto &cwd = cwd_result.value(); - auto blob_path = cwd / "Templates/.cache/blob.json"; - auto cache_folder_result = Toolbox::Filesystem::is_directory(blob_path.parent_path()); - if (!cache_folder_result) { - return std::unexpected(cache_folder_result.error()); - } - - if (!cache_folder_result.value()) { - auto result = Toolbox::Filesystem::create_directory(blob_path.parent_path()); - if (!result) { - return std::unexpected(result.error()); - } - } - - std::ofstream file(blob_path, std::ios::out); - if (!file.is_open()) { - return make_fs_error(std::error_code(), - {"(TemplateFactory) failed to open cache blob!"}); - } + auto &cwd = cwd_result.value(); + auto blob_path = cwd / "Templates/.cache/blob.json"; + Toolbox::Filesystem::is_directory(blob_path.parent_path()) + .and_then([&](bool is_dir) { + if (!is_dir) { + return Toolbox::Filesystem::create_directory(blob_path.parent_path()); + } + return Result(); + }) + .and_then([&](bool result) { + std::ofstream file(blob_path, std::ios::out); + if (!file.is_open()) { + return make_fs_error(std::error_code(), + {"(TemplateFactory) failed to open cache blob!"}); + } - Serializer out(file.rdbuf()); - out.stream() << blob_json; + Serializer out(file.rdbuf()); + out.stream() << blob_json; - file.close(); + file.close(); + return Result(); + }) + .or_else([](const FSError &error) { + Toolbox::UI::LogError(error); + return Result(); + }); return {}; } diff --git a/src/project/project.cpp b/src/project/project.cpp new file mode 100644 index 00000000..7ae7cd92 --- /dev/null +++ b/src/project/project.cpp @@ -0,0 +1,46 @@ +#include "project/project.hpp" + +namespace Toolbox { + + bool ProjectManager::isInitialized() { return m_is_initialized; } + + bool ProjectManager::loadProjectFolder(const fs_path &path) { + fs_path sys_path = path / "sys"; + fs_path files_path = path / "files"; + + auto sys_result = Toolbox::Filesystem::is_directory(sys_path); + auto files_result = Toolbox::Filesystem::is_directory(files_path); + + if (!(sys_result && sys_result.value()) || !(files_result && files_result.value())) { + TOOLBOX_ERROR_V("Project folder is not valid: {}", path.string()); + return false; + } + + Toolbox::Filesystem::is_directory(path).and_then([&](bool is_dir) { + if (is_dir) { + m_project_folder = path; + + // Process the stageArc.bin + fs_path layout_path = path / "files" / "data" / "stageArc.bin"; + m_scene_layout_manager.loadFromPath(layout_path); + + m_is_initialized = true; + } else { + m_is_initialized = false; + } + + return Result(); + }); + } + + fs_path ProjectManager::getProjectFolder() const { return m_project_folder; } + + Scene::SceneLayoutManager &ProjectManager::getSceneLayoutManager() { + return m_scene_layout_manager; + } + + const Scene::SceneLayoutManager &ProjectManager::getSceneLayoutManager() const { + return m_scene_layout_manager; + } + +} // namespace Toolbox \ No newline at end of file diff --git a/src/scene/layout.cpp b/src/scene/layout.cpp index f1aa911d..5cf7ad76 100644 --- a/src/scene/layout.cpp +++ b/src/scene/layout.cpp @@ -9,7 +9,7 @@ using namespace Toolbox::UI; namespace Toolbox::Scene { size_t SceneLayoutManager::sceneCount() const { - RefPtr root = m_scene_layout->getRoot(); + RefPtr root = m_scene_layout.getRoot(); if (!root) { return 0; } @@ -17,7 +17,7 @@ namespace Toolbox::Scene { } size_t SceneLayoutManager::scenarioCount(size_t scene) const { - RefPtr root = m_scene_layout->getRoot(); + RefPtr root = m_scene_layout.getRoot(); if (!root) { return 0; } @@ -42,7 +42,7 @@ namespace Toolbox::Scene { std::ifstream file(path, std::ios::binary); Deserializer in(file.rdbuf()); - m_scene_layout->deserialize(in).or_else([&](const SerialError &error) { + m_scene_layout.deserialize(in).or_else([&](const SerialError &error) { result = false; LogError(error); return Result(); @@ -88,7 +88,7 @@ namespace Toolbox::Scene { std::ofstream file(path, std::ios::binary); Serializer out(file.rdbuf()); - m_scene_layout->serialize(out).or_else([&](const SerialError &error) { + m_scene_layout.serialize(out).or_else([&](const SerialError &error) { result = false; LogError(error); return Result(); @@ -106,7 +106,7 @@ namespace Toolbox::Scene { } std::string SceneLayoutManager::getFileName(size_t scene, size_t scenario) const { - RefPtr root = m_scene_layout->getRoot(); + RefPtr root = m_scene_layout.getRoot(); if (!root) { LogError(make_error("SCENE_LAYOUT", "stageArc.bin root doesn't exist!") .error()); @@ -156,7 +156,7 @@ namespace Toolbox::Scene { bool SceneLayoutManager::setFileName(const std::string &filename, size_t scene, size_t scenario) { - RefPtr root = m_scene_layout->getRoot(); + RefPtr root = m_scene_layout.getRoot(); if (!root) { LogError(make_error("SCENE_LAYOUT", "stageArc.bin root doesn't exist!") .error()); @@ -204,7 +204,7 @@ namespace Toolbox::Scene { bool SceneLayoutManager::getScenarioForFileName(const std::string &filename, size_t &scene_out, size_t &scenario_out) const { - RefPtr root = m_scene_layout->getRoot(); + RefPtr root = m_scene_layout.getRoot(); if (!root) { LogError(make_error("SCENE_LAYOUT", "stageArc.bin root doesn't exist!") .error()); @@ -249,7 +249,7 @@ namespace Toolbox::Scene { std::optional SceneLayoutManager::addScenario(const std::string &filename, size_t scene) { - RefPtr root = m_scene_layout->getRoot(); + RefPtr root = m_scene_layout.getRoot(); if (!root) { LogError(make_error>("SCENE_LAYOUT", "stageArc.bin root doesn't exist!") @@ -312,7 +312,7 @@ namespace Toolbox::Scene { } std::optional SceneLayoutManager::addScene() { - RefPtr root = m_scene_layout->getRoot(); + RefPtr root = m_scene_layout.getRoot(); if (!root) { LogError(make_error>("SCENE_LAYOUT", "stageArc.bin root doesn't exist!") @@ -342,7 +342,7 @@ namespace Toolbox::Scene { } bool SceneLayoutManager::moveScene(size_t src_scene, size_t dst_scene) { - RefPtr root = m_scene_layout->getRoot(); + RefPtr root = m_scene_layout.getRoot(); if (!root) { LogError(make_error>("SCENE_LAYOUT", "stageArc.bin root doesn't exist!") @@ -386,7 +386,7 @@ namespace Toolbox::Scene { bool SceneLayoutManager::moveScenario(size_t src_scene, size_t src_scenario, size_t dst_scene, size_t dst_scenario) { - RefPtr root = m_scene_layout->getRoot(); + RefPtr root = m_scene_layout.getRoot(); if (!root) { LogError(make_error>("SCENE_LAYOUT", "stageArc.bin root doesn't exist!") @@ -453,7 +453,7 @@ namespace Toolbox::Scene { } bool SceneLayoutManager::removeScene(size_t scene) { - RefPtr root = m_scene_layout->getRoot(); + RefPtr root = m_scene_layout.getRoot(); if (!root) { LogError(make_error>("SCENE_LAYOUT", "stageArc.bin root doesn't exist!") @@ -478,7 +478,7 @@ namespace Toolbox::Scene { } bool SceneLayoutManager::removeScenario(size_t scene, size_t scenario) { - RefPtr root = m_scene_layout->getRoot(); + RefPtr root = m_scene_layout.getRoot(); if (!root) { LogError(make_error>("SCENE_LAYOUT", "stageArc.bin root doesn't exist!") diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index d469b0ce..a732bf29 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -12,59 +12,59 @@ namespace Toolbox { Result, SerialError> SceneInstance::FromPath(const std::filesystem::path &root) { - ScopePtr scene = make_scoped(); - scene->m_root_path = root; + ScopePtr scene = make_scoped(); + scene->m_root_path = root; - auto scene_bin = root / "map/scene.bin"; - auto tables_bin = root / "map/tables.bin"; - auto rail_bin = root / "map/scene.ral"; - auto message_bin = root / "map/message.bmg"; + scene->m_map_objects = ObjectHierarchy("Map"); + scene->m_table_objects = ObjectHierarchy("Table"); - ObjectFactory::create_t map_root_obj; - ObjectFactory::create_t table_root_obj; + fs_path scene_bin = root / "map/scene.bin"; + fs_path tables_bin = root / "map/tables.bin"; + fs_path rail_bin = root / "map/scene.ral"; + fs_path message_bin = root / "map/message.bmg"; + // Load the scene data { std::ifstream file(scene_bin, std::ios::in | std::ios::binary); Deserializer in(file.rdbuf(), scene_bin.string()); - map_root_obj = ObjectFactory::create(in); - if (!map_root_obj) { - return std::unexpected(map_root_obj.error()); + Result result = scene->m_map_objects.deserialize(in); + if (!result) { + return std::unexpected(result.error()); } } + // Load the table data { std::ifstream file(tables_bin, std::ios::in | std::ios::binary); Deserializer in(file.rdbuf()); - table_root_obj = ObjectFactory::create(in); - if (!table_root_obj) { - return std::unexpected(table_root_obj.error()); + Result result = scene->m_table_objects.deserialize(in); + if (!result) { + return std::unexpected(result.error()); } } - RefPtr map_root_obj_ptr = - std::static_pointer_cast( - std::move(map_root_obj.value())); - RefPtr table_root_obj_ptr = - std::static_pointer_cast( - std::move(table_root_obj.value())); - - scene->m_map_objects = ObjectHierarchy("Map", map_root_obj_ptr); - scene->m_table_objects = ObjectHierarchy("Table", table_root_obj_ptr); - + // Load the rail data { std::ifstream file(rail_bin, std::ios::in | std::ios::binary); Deserializer in(file.rdbuf()); - scene->m_rail_info.deserialize(in); + Result result = scene->m_rail_info.deserialize(in); + if (!result) { + return std::unexpected(result.error()); + } } + // Load the message data { std::ifstream file(message_bin, std::ios::in | std::ios::binary); Deserializer in(file.rdbuf()); - scene->m_message_data.deserialize(in); + Result result = scene->m_message_data.deserialize(in); + if (!result) { + return std::unexpected(result.error()); + } } return scene; @@ -88,7 +88,7 @@ namespace Toolbox { std::ofstream file(scene_bin, std::ios::out | std::ios::binary); Serializer out(file.rdbuf(), scene_bin.string()); - auto result = m_map_objects.getRoot()->serialize(out); + auto result = m_map_objects.serialize(out); if (!result) { return std::unexpected(result.error()); } @@ -98,7 +98,7 @@ namespace Toolbox { std::ofstream file(tables_bin, std::ios::out | std::ios::binary); Serializer out(file.rdbuf(), scene_bin.string()); - auto result = m_table_objects.getRoot()->serialize(out); + auto result = m_table_objects.serialize(out); if (!result) { return std::unexpected(result.error()); } @@ -144,14 +144,14 @@ namespace Toolbox { } ScopePtr SceneInstance::clone(bool deep) const { - auto scene_instance = make_scoped(); + auto scene_instance = make_scoped(); scene_instance->m_root_path = m_root_path; - + if (deep) { - scene_instance->m_map_objects = *make_deep_clone(m_map_objects); + scene_instance->m_map_objects = *make_deep_clone(m_map_objects); scene_instance->m_table_objects = *make_deep_clone(m_table_objects); - scene_instance->m_rail_info = *make_deep_clone(m_rail_info); - scene_instance->m_message_data = m_message_data; + scene_instance->m_rail_info = *make_deep_clone(m_rail_info); + scene_instance->m_message_data = m_message_data; return scene_instance; } @@ -162,4 +162,4 @@ namespace Toolbox { return scene_instance; } -} // namespace Toolbox::Scene \ No newline at end of file +} // namespace Toolbox \ No newline at end of file From 7f7bc56ee9a80c39394f7b5e5ad9594cf8adecc4 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Mon, 9 Sep 2024 05:59:46 -0500 Subject: [PATCH 007/129] Much progress with seemingly functional model and proxy --- CMakeLists.txt | 2 + Images/Icons/Filesystem/fs_arc.png | Bin 0 -> 45443 bytes Images/Icons/Filesystem/fs_bas.png | Bin 0 -> 13334 bytes Images/Icons/Filesystem/fs_bck.png | Bin 0 -> 19387 bytes Images/Icons/Filesystem/fs_bdl.png | Bin 0 -> 9182 bytes Images/Icons/Filesystem/fs_blo.png | Bin 0 -> 4070 bytes Images/Icons/Filesystem/fs_bmd.png | Bin 0 -> 9182 bytes Images/Icons/Filesystem/fs_bmg.png | Bin 0 -> 26898 bytes Images/Icons/Filesystem/fs_bmt.png | Bin 0 -> 33799 bytes Images/Icons/Filesystem/fs_brk.png | Bin 0 -> 7100 bytes Images/Icons/Filesystem/fs_bti.png | Bin 0 -> 2321 bytes Images/Icons/Filesystem/fs_btk.png | Bin 0 -> 11549 bytes Images/Icons/Filesystem/fs_btp.png | Bin 0 -> 11118 bytes Images/Icons/Filesystem/fs_col.png | Bin 0 -> 18452 bytes Images/Icons/Filesystem/fs_generic_file.png | Bin 0 -> 8419 bytes Images/Icons/Filesystem/fs_generic_folder.png | Bin 0 -> 10982 bytes Images/Icons/Filesystem/fs_invalid.png | Bin 0 -> 319986 bytes Images/Icons/Filesystem/fs_jpa.png | Bin 0 -> 57806 bytes Images/Icons/Filesystem/fs_map.png | Bin 0 -> 61346 bytes Images/Icons/Filesystem/fs_me.png | Bin 0 -> 6338 bytes Images/Icons/Filesystem/fs_prm.png | Bin 0 -> 42745 bytes Images/Icons/Filesystem/fs_sb.png | Bin 0 -> 10068 bytes Images/Icons/Filesystem/fs_szs.png | Bin 0 -> 27272 bytes Images/Icons/Filesystem/fs_thp.png | Bin 0 -> 6264 bytes Images/Icons/color_picker.png | Bin 0 -> 3641 bytes include/gui/project/asset.hpp | 45 + include/gui/project/window.hpp | 20 + include/model/fsmodel.hpp | 214 +++- src/gui/application.cpp | 7 + src/gui/project/asset.cpp | 21 + src/gui/project/window.cpp | 81 +- src/model/fsmodel.cpp | 1111 +++++++++++++++++ 32 files changed, 1453 insertions(+), 48 deletions(-) create mode 100644 Images/Icons/Filesystem/fs_arc.png create mode 100644 Images/Icons/Filesystem/fs_bas.png create mode 100644 Images/Icons/Filesystem/fs_bck.png create mode 100644 Images/Icons/Filesystem/fs_bdl.png create mode 100644 Images/Icons/Filesystem/fs_blo.png create mode 100644 Images/Icons/Filesystem/fs_bmd.png create mode 100644 Images/Icons/Filesystem/fs_bmg.png create mode 100644 Images/Icons/Filesystem/fs_bmt.png create mode 100644 Images/Icons/Filesystem/fs_brk.png create mode 100644 Images/Icons/Filesystem/fs_bti.png create mode 100644 Images/Icons/Filesystem/fs_btk.png create mode 100644 Images/Icons/Filesystem/fs_btp.png create mode 100644 Images/Icons/Filesystem/fs_col.png create mode 100644 Images/Icons/Filesystem/fs_generic_file.png create mode 100644 Images/Icons/Filesystem/fs_generic_folder.png create mode 100644 Images/Icons/Filesystem/fs_invalid.png create mode 100644 Images/Icons/Filesystem/fs_jpa.png create mode 100644 Images/Icons/Filesystem/fs_map.png create mode 100644 Images/Icons/Filesystem/fs_me.png create mode 100644 Images/Icons/Filesystem/fs_prm.png create mode 100644 Images/Icons/Filesystem/fs_sb.png create mode 100644 Images/Icons/Filesystem/fs_szs.png create mode 100644 Images/Icons/Filesystem/fs_thp.png create mode 100644 Images/Icons/color_picker.png create mode 100644 include/gui/project/asset.hpp create mode 100644 src/gui/project/asset.cpp create mode 100644 src/model/fsmodel.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 3677621b..7a281c5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,8 @@ file(GLOB TOOLBOX_SRC "include/gui/widget/*.hpp" "src/image/*.cpp" "include/image/*.hpp" + "src/model/*.cpp" + "include/model/*.hpp" "src/objlib/*.cpp" "include/objlib/*.hpp" "src/pad/*.cpp" diff --git a/Images/Icons/Filesystem/fs_arc.png b/Images/Icons/Filesystem/fs_arc.png new file mode 100644 index 0000000000000000000000000000000000000000..d74040ad0c150280e09d8a4d4a7def5f7eec766e GIT binary patch literal 45443 zcmeGD=UY=>v;_+9goKWSY7m4VC@3w83Q7w_5k)|x3PO|)(os5uDk=g>mtI8asPq~I z=}oG1ln#c_0||k<`JHp#5AR=aKivI1JnXc&+FWCfIp*50bhOl27|$>Q0KlSgM@<(1 zpx`YOK+uB!a+m3A0081_r>d%BXJG*VqVJx+Yq+QK0NEO7|1s{5j;dZr=q=SCq?!eC z{wa%n%y71h5>!c&bV;yS`CdprqGIRTj=<2Fa&DM1o7&Y~x}6HO$?4c2b|1;5Mx}K3 z^hEb`nmre-t`x_B_S1K73v=#BwkFp1p1z61-@;{uTCckQ8beC7EuFot@7$(eIzssn zRWclxAJlVRK7Zx5hSww6db0s8XC{*USWCf1)<%*b9cQDi&)3$z*V5Ml44<`}lg1h< zG$hk%T`x@Q$LIzT>r& zPon(yk8W}?yIQut_S78u>TzG={+smoQtG!Bj+C^e71%yM_oU0Bc6^-<|6W5gqu)io z`L&2>;UfRzR@S=IU9E=#*@kN$h=6>G%M0Vt_jN9faDP^xA9oJ#o=V>HIAf-rC3i|e zroYCtYt=a|);Gejo#S!yv|?m?Kwl@TEUm5Z`Jf9%;0iFf+%a|s0M;ibe~`~gpX>kt z1!$-#>v@g;YhWlBCOw{^92*k-6O-knJ#&BgoHza|KZhNo54rps8ho1h6-~tHcBt^> zjyL|nDk|LF3^8FOx7mev^4;EavIv_%QIVIzFHo|t7SwU4)qh{1>!_T!vLw_>yW6Y} zkoF9AYZC&chATXGb@el%dzS<2Y71&t&4(W!&ybEyLc#w1f7k!ZW&oEev;ywnh~|o^ zC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em/fs_bdl.png b/Images/Icons/Filesystem/fs_bdl.png new file mode 100644 index 0000000000000000000000000000000000000000..0fe86b160870d1ac8a62c34f5c21fbfda80ef98f GIT binary patch literal 9182 zcmb_?cTkhvx9&~|5Sm1#iAul*f*9HKvdyZOKMviuN07$*?dZDh@U?dPaOw#>C^89h8Q9?^F zOz3f%vMzgtSs3ZzrML-2$B;vON=HpB*@eR%22YRmj$nUWa=U~=oI~AP;iMJoL`*4$ z2ss*-s_-wVFO8BtVEFS6p+j*9-pxfkkuXs9#D<6oPQx52uEi@M8R>_$Rc)MxX9doc zwR9YSTUY87%_wvboK$aeG8WJl_D;?pGN)s?H;t|(lll{?AbU`QjtNY!H&0XMt z)rYTN*Ml}^96BEVU^tv$4zH(rFm|(2Qm;Z2 z0C?9gChYpydK$kQE)EC?1Ns4g0MCC!Tt`9=cd1dRy_cvqmz(_g-zvR^04IDXeOxoG z}o&0h<(6Y_8zz|~(G^b3-J#z~{k$eiC2cwqCS~EM1yr*pD;%(Q1zIMa z&9}6ch_DyJLF7gr2gFRDejz%?YH%p1y)OR?#N`M+2L=uOtJz;?Fci~I5cx%jeDxd~ z3WP#~%n{;#^K76u&^P^zPUcs^R7VBwD=@-8RqNNQD~lalDd|rU<`DKdc(u6`J|Y0w z?K=`ZyCPc04T=0-)J6fCOYlq6?+-cd#Zi+3@~5+VbRa>Dv0O228fEWY`h)DAA-d}o zfLZeErDJ|SC)x-#`R?PN?ej}pT!OE_AmMm7sb`6nbATDS^ipHf(l zcvdec14gn_A9-A3i4n9*I@K!9*}|LP60#H6j5R%m6xL^mLpfkG#<>&HZ#UNLJtO%uQf5oi<) zGD;_)wg*__pe4?OcC>=_AL6K)jJ>=`wmC`dE>4kTg!8gn;@J_SJnRcQfZg?$a^?JiLcfP zqU2;UP_5LG8)Xs_VU0Grxzg`dM!Lz_CCXJ9OnwVMrJPr+H=ZFWZjPtwz&|Jp5+Lc{mgh0>aG# zT|4aAH9XkAmJ(O7cmbHn>umvZ1Of^Q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0 HcmV?d00001 diff --git a/Images/Icons/Filesystem/fs_bmt.png b/Images/Icons/Filesystem/fs_bmt.png new file mode 100644 index 0000000000000000000000000000000000000000..d11782d130b28be3a11f07a8ce85a3cf87e40545 GIT binary patch literal 33799 zcmce-c{tQ>_%=MYXc1`{sMmKkH_`Hb)LdyeCM-@l)?bn5(z#D8iviL=icIK4O(ko^xbR`(mo%4A@ZY& z0ZYUE@Y6R4w>qXc# zuGQ-l7f+n}$IjU+7p2y+-I6ZT&h&r8G&@V<(X9?-k_^5qq!+~%7vEA{2qHVu_R zu*LD={kU7~nU}mEJWnhmeWrT71ix`8td<`H zt=7lL3;tt#l;Mtiv#79lH?Z+@Yi!u^Y0rSckz}U7uG|*`Y8|gC7l35Yg$!VBt$fg_ zDW+Fz(`642RFI5>N#bq4pEGB!-Q4Mqfq?6t@<8YOasVG3_tdlY27x%9(0?)%LyBBL zAVHA+?VI=gC)Tr$hhDPCq9H3vdeb}q=q9Gezj__|n)5lA*2_nBg5go++^d+9(sg7b zoH=Y~+Ts@z=Q(Dd^9&pws=q_Tc!h2W9)I06uX#C1^`JPARr_|!>mY!UDkJnUG}cC8i!DL2xAZn z1MqL5uIFh5YHO05BeDdk~z&mG%xNx*U z=*bTiV+YqQVv!G>?{1r?AC}C5xA=}RnyprXEOq?kQV=?wV|53zC;?si2|!~xGia!q zkd}LzTu+aY%k6h*$a?%C`*^7VUJ$48N%&~YsaCX8_9Z>L zuEcJzeOdYS#z^oUz8Gh(6zWEH2zz`3F>?TSP$zDLRou0Cbu{8)(ZX8Ls^moqSK3&s zQKW+T^C8^e;c3ROcNCDKz}&Ot3n^r@`u;FW5GVcn;*EQ>xa=F^D*p3z5iD^ADa4go zlkvPrV!{b#qQ|Ss3v9(Us;%hOHXQ`wFDCuOQLxu2uF~3?EJRr~D?0zlMBkYosy|Fo znZk>*^`%I#n&DLAAh{t2P$dOo5fyF;6AY!Vq?NkA*CV7#)b9@EHWxfcu(gKjJ2SPV zoi`R&ndUqB?10j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EV?Kt3Kv^C&3xQ_o%{w%ezIMzDdW;ezXEa6MWT)c82 JPvh33{{uRjVi*7b literal 0 HcmV?d00001 diff --git a/Images/Icons/Filesystem/fs_brk.png b/Images/Icons/Filesystem/fs_brk.png new file mode 100644 index 0000000000000000000000000000000000000000..c43bb13307b738af3e910ab4f6d1033004134a5e GIT binary patch literal 7100 zcmb_hc{tQ-`+sI^gODv#mJz22rHL$AMp5dBX|t6O*-Dnk7G_W=+c|YmmeFZJgOEtp z5oS8pB3luekh07e%Ve4PJ?i|f^T&DL_xHZ<_4{6z%X2-;eShxzexA>LKhNAaW@RoS zv_%L2Aadle*$DuUu!#gHe)w-b()2^~$eC7LCWGVuvek-tQ5$ z+35f3Sc0kW!ToZNqR)~|&oq!NE@wVFa4R-bYR8l41k;B7fy|2x%xASqHB_`xyxupS z)zc4~0x}OIJX0CWid!Nr`OUr{;)=8yXO4i_NybsN9Yy1P59@;28>y|mqQKq)4?@D4r^aU+SAKtK4V`gKgWZrW*3xOv4yY1dPknYJ&JHB1)LH%_#J^h=izv>>kaJ`EB+ukng<-k+TgWS&UUiaMEnTDTU zuY9S>xot9Re60Az%LaHw84oAPD*$ zwhsV6?A-bvA|IFM1;A#;5wrcLLf%ae31?k$JIi2}_mcF3O-@mSWsdLKvFF~@p5vj` zQ!a047P+2>Pfv!>yJ_K#ie+=xZL98_bL>w$o-<;N4SRE9oBBnmQhj#l5|nwGDv9$WHq+g%RBymnX=BYmY!Ys%5T*k*WxQO^>LbPnB+V z(KyJTQ_CzKkHBhZA;2-^Z_$PIt2xE*^k3P~Kc=L*C-DJZ0N@G$?Lh%x0$XtNZv=n{ zTmO3KKb)=z1^!U-Z%O}ax(QtP1Jgh1Bf?RL^O%5ZF1Tk*Cbuken}V!4E5lzgynsS} z^E3C8uxmNL$#SqJxrQ4=8oTdz*X30k^6e{@SlEZq((bDPsi_5l9_h)JG6TnDliNh! zhuG;jwR?otRRvpnIIO9+?m-~IJ;#m&=6H{>pf7HDa7rYu-u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{Ry8(h^vb%{iDp)rX+?c{3{ zp{_d5yU=h?vn$})gl|~V5&%W4O^`)EV)(z_r`81=IcR0} z=2X$dA1xN=UN#)r?i6lQCmi$XhquA`ba96LFEpoGMZ8Q1d&c%rrSQy!)oV)S3MX&K zTK7bw|B_U5ug)b8$EGGNvxSEpn>KkGzkcU!R(pEIg!YT~op|TSs7^U4t-jSOHuRL# zORZX~tfY7UpJ!%Y4vza?!1bcO^zQjWg&q7Ruh#vpezmLDSm6Ux%hGkQn;bR{aQ>fM{V*?S>I_Di-qN*ic^N&=`hZik00Tn<(5Ea63<^Msk%57Ofx!XD0w#7mQY0!zm_(H62;~Sj zVG|?lPM|J?5kx6(V1NaN1H%j$ljv|kxN=B&lu&ddyoC~)4Gad1#HAOg0sn%Mn>w!6 zgxKlMK225|-zu7>Wnu6N?|l5ArBUe#Dq zw9i(Y;ihf%_nIo5HifB1vi;ZiAAdcWxn@@MM%n7c6HYzeuFj;e`}AG&`~Q}dV9 zo%Sv96|WTq#(smytw`zXzh7%CSZIk3Hf$+njJeMzW1HCoC c;DP@ihTi%l1JBp4>L90hy85}Sb4q9e0B!4@4FCWD literal 0 HcmV?d00001 diff --git a/Images/Icons/Filesystem/fs_btk.png b/Images/Icons/Filesystem/fs_btk.png new file mode 100644 index 0000000000000000000000000000000000000000..4324d09facaf6d4ef2f0b3eb05018a81c698f0ea GIT binary patch literal 11549 zcmd^lS5%W-*KOzuN>e~ODo7U<5a~fcI!Kq^1VjZC1f(TVM5H6VNI-f=YNQ5`CM`%+ zs`L&5i3uSg|C9GSwP z2?#_93@Jh9Xn|ko*AsXUh{DH1UHzeliwg)O^3m_3vfj6cm)|coM&(U1S}?!te;BRK zpsB`F_|~pW-KMil&nK(?e&YMA%c50pqt!drUL8LB!@nu^RqWi`Yai~NP!X&Px_z_m zN7oC_eTu-su`dpqV5*hU-}ZGt@3;Qwi-}gQPZzWY;FxRzYD6!9sx>Std(fh;qGCgIL^6>o2m~o0o@9?VEgd1Ns57Qj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_cJWF)xS(jW-Kv1RvEwMKo?H1|io1tF*y!aqhW|fKO5}SIppgHS z#d&h_ec)mZ>|CnMo z;9ZQhv1lzrkEuN~DA}Z*0Sp4il^@4nJTpGv=No=Q)CJMX@(X|jsweP$!Dk=QOlj*K uXVkEQv}6T@{WdX-kBs2|>SuSDL?;(_I_~NpN&bo;NJrC9qw2on+y4Th(gAe< literal 0 HcmV?d00001 diff --git a/Images/Icons/Filesystem/fs_btp.png b/Images/Icons/Filesystem/fs_btp.png new file mode 100644 index 0000000000000000000000000000000000000000..b030a61799355b2e453261e7088968c215a9c4bb GIT binary patch literal 11118 zcmdUVXH-*Nw{8Lg3L+>?DFRBb3JL8Vb`tqiSDlucl^O&B(Q0Zu(g%Ua zfFT*^A|>$W#BUq}0)agoRaKul+Sq_V0`cDQ^4dS1GDa-cN99jkF{XF#c^a)s^H`a^ zFw~+{)%<&@wns*-NmXyCIukig3vv`94RsFbS=ySX zygz;qeJ$BBrT4I3WS@SBp}2uv`{1T~TJkE{;U)KvW8g^F@CrX1U*qOss#SKs2qlER*U;g8T10A>Tk7r z^ZIkN{lr}NIYZoR5q~rJl~|a-#Cs_M=;X5l#VoVuPap`F+%!x*K_I%9q!;+BVzDC# z#0AoPq-^Lnvp0V!)5N=tcsPX4T$G^czx<=>GFNC?+=n-gpY7h}*-2k;_3rY}?yn_C zw@kSteF$~Lqng*+ZJT^5X&Nr`R$^E@$Zy=sQ+muBqR41!|FVA33@E8X^dO|!CvS$6}Y51@!qVqU3%N6oudyu zjN5Qv0w|aJl!myxw{}hFT>9BIJL2J|D+K)=d%aQLfYPmqqUc}FMajU8VJhzZ+{SCa zSvDe5IJFv2F1jb)s#qb8i0h|_UW~OY`s)GpuwXb zhim=Rv88Uqe5f8jboDX(soi8Y*PUEkQ4V=g7d6QP7viD=-m z3V)<>b;M=)(%M%4w)o8>b+ats2Alj$+CD~S;e=bnv-)an%1tko@%H^=UquSrK2tYy zuDt-Ewt>VHUL6*W#_Sp;z~Us?NcB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W=OQ3}Ba9;(5Ge&$V?G`enBi`s5Fk zf^-xqCYZhb0qit00XIqX-B_sA@tNI$0l0srrQsyMfs#Y@Wi8|A16Pk+xqj^9{-AG@ z4_{?2PzUb0=TNi+*7kw{vqS^uE>`?5lQK1G%{I+D(^j)KFfcH1Uj&X35#obCiY(jK$A?)=z07w0&dNENwV;qF&_4N-QFEodK=9|@$Mq?>oR@zw z*f4EoVA!M0)MtKQdcE0=Lz&H@uUJi2e9&0K33A!Yiws+}_Ozemmk5#UnHAu0%`LSx zyX3f?wdSV%2Y>qU{;5;A#{5CA=PBb49$`U`KRIoz>t1j5IXmO-!|C-0B4FZDIT0)!kPcf@)4#n T?AJC-2D#AF)z4*}Q$iB}j&8S8 literal 0 HcmV?d00001 diff --git a/Images/Icons/Filesystem/fs_generic_file.png b/Images/Icons/Filesystem/fs_generic_file.png new file mode 100644 index 0000000000000000000000000000000000000000..ee0ab965e3482bfc050ff22a1a30fe294c961bd0 GIT binary patch literal 8419 zcmeHMcU05a^1lHzhzP6&ECg8B70V(ZxM1kG78HmpBE2Zmq=X(IghUkCC&da#M^U7+ zbOA|lQIIB0Kw1JK5QuaLBn0yNeks0v@3+5y-ueCW&e@#9AzbFp%$++kpP4)VxTt@2 zo4{TH0Khh#bH7{yfCu`@1Nb*Xzvg^DvH?K2JDxgq(b2{RfI|gAAj;{OlNfV4Kq6OXi!zLV|A5KX>+PG#k1ZitwEl zai2jh7M=UY$j`x|j+j>`g(uY}2dJJ1;u-rpebIb^Z3A6i=S^j@bl%_=MYQ|p(<}@-^R$)Y=3=LwV}@A!QyS@52K{F zCE7-+fji7+7B9#(*^2=R{ct4Oc+~pJ@aE|Q?hVbES>6)vkAAdu#fi^gPLW!q)g6!ZlS2^&VoYs6xxQ1kj!yccmg1N75+h_X}ojOCJqJI8CKo zyz5~|!~g6fXRDB!j87y^TNjg64QjBNg8?YXtU)IlRo$p29bN7H^`m=ru}e=e#$hQE z9he@W;@z7uINQi<9}x}w@W34Ow_wXl#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v$QBqT3$w8*_9_T=d#M<4VpkHyN4nz;nnkh_||@Q=||&o;MIkN`bBGJ+wVsD z2ec+9zV{v4h&&yyo`c`OY#-NgQrTFpf4jhQu?Z^K%+=X7GK6=j zsQ$0V}2>erx`BXIOoiefR+f$YV}{_A%LO zrDA!G&ezqEKsc1oueM6y`I;!cZWpbF8~HS)`^wq9e`Gk`kL~{5MgXAUy3e68_AsEs z4;;xSLQ_FyX~XlOlZw!cV(28~y3i{>D06CqXBd9axWcO=HG?#CwDm1ARAyNEcb`865>g^Pb#Jo7wtQEubvKZG@Ota}_u7RJyZt zps~mvZWp9s&F3-Ct&K_ub^C+RG{_ajt%ip|qgK!)XUBqUz%m9XyK8Z2s&3k~X4HRpLbHp4nXBTv`Sga?*3ecee+spYO$tPP#=}Qy-Ve_C^ln!)T zW@RNf)&$l*J09yJ>ZX_#jca@PNaWk3$sAdY>jwd~pb@=tNsYz54Nn9`dDNlV*{g_L z`F&urF4Q~Vf*K18kMo+e`fm_evvxfF4>-Ok8pLNQRU7Qq=3g`>un-D}DO&_Y1nck}QKa8p4z{V8&HG+{h_xi)5x4!G&wIK zH*+v^6HjtY@z`QJI`C-(G+o^>|CZun$_FH5c5))vGuymX&1#TiuP)WZpohmC$om!i zYnWtc;N>FO#tcVGJeF0}U+FA~+p!`WCCj-%vloAd0RPd4#6|vSr{b)QO~t|cbx!O5 JlA~=M^grs-`#b;u literal 0 HcmV?d00001 diff --git a/Images/Icons/Filesystem/fs_generic_folder.png b/Images/Icons/Filesystem/fs_generic_folder.png new file mode 100644 index 0000000000000000000000000000000000000000..8ba89266bb905c68ed19a6fb30417c7d7861a06b GIT binary patch literal 10982 zcmdsc`6E>Q+y8qgq@+c;TWp^sOGS}x##Y@WS+kcch3r(e7_+oUrI3BemVKSF77a=g zl_ASy9T8(2vdzSpndh9N`+1)4_doc4&o9oI^Iop&b-k|Fb-j;ACPunKf_nu40781_ z|1kxC2fF0}0({V)rQ2Pr0LYi<{d3Cvb{~BZ8|Cber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>|4s^3roHy6(i;ws<$u zE{#sVVX4+D?;4fzF$>haLMre47-@xfOhL29fr+7&h~D8F*_U@y5#M zYwDU4nqARMnOXMGm13k`BAW4h?d0jUAwsGnjYp=%Jv^zdzUNf0h1b;b^j8H0p!(YWP%M}ggk&G;S zm;DJ@bcJ2mMBZM$;F7Q80^HLUoDd)glLEfP*z&he#}eFDQ#lPYYdP=wpBbJMIBzB~ zE}YDH#?2UX0ZOtE#XXa4`bHOJST!B{x>9?c?&-XGuxH81o*xYNd-C0B2`(clEAa*8 z?arN0`s`mu+ys6#$xJ4dnqi;bDKignRo=sw%X*uH^8yVci7gR9g{dpi{gYNlDpRcz zn<5n}S$u#m?(47S+|~Iz>U9CPV4F2-e4+w+5cl|$e&989t XXUsk?4|FWUHtU@=`ls}?!`=S^d1)+v literal 0 HcmV?d00001 diff --git a/Images/Icons/Filesystem/fs_invalid.png b/Images/Icons/Filesystem/fs_invalid.png new file mode 100644 index 0000000000000000000000000000000000000000..3015026d851d7d3b6897ea737218897e13ef4a7d GIT binary patch literal 319986 zcmeF3bySq!_wR>skW@-aT0pu)xG`4~`XPQtQse~#i67Vgb2rsn-Jn?i_c-}&FSDO! z$O78F`6<^rHC0c|cFoZL*pjVIhta6`cj1veDjP;f)R4Fxw8+)!{s!3_mB6x>j7L%|INHx%4Za6`cj z1veDjP;f)R4Fxw8+)!{s!3_mB6#T!SfS+k$^lvY~&8GZKL&8m0#tj8G6x>j7L%|IN zHx%4Za6`cj1veDjP;f)R4Fxw8+)!{s!3_mB6x>j7L%|INHx%4Za6`cj1veDjP;f)R z|Nj*1uAJ!q?FIP%;r4v+GMzGO-rxqyKQ}@oH$s20LKW=vCT19WF{%GY_ES1~7Fntj#ke~K$*DdYV zp&LwSJXJ<2W@pH8?{ZCJIsTIAjTHPIbIBUB00uP!=;$bEG{Wi(V>z+ zI3G%R&Abt)C{!PzWuo>wz=KB4`KSrKphlXu!K3L>lDFU;4tb(i{Lcy-9#5ve9-DmT zfDdhDw0-8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zC}2>)pnyREg8~Kx3>pT1_cZX7!>@k zrhwCkDHZ@khV(C)pnyREg8~Kx3?#|B~Uw{PTB${tx1hQsMvr literal 0 HcmV?d00001 diff --git a/Images/Icons/Filesystem/fs_jpa.png b/Images/Icons/Filesystem/fs_jpa.png new file mode 100644 index 0000000000000000000000000000000000000000..4f541644c9c3ba6e4dd64e0ad9fb7e1ca32d628e GIT binary patch literal 57806 zcmeEtWmjBFv~5Fh5AKkl!QG)DxDyEO?(Wi!1q<%(o&d`3qV46yWM!rJ^}zR&er1M zD%Pf^004cwd%UoGj|y(+Mx$I`quZod?+0#ANn$x)A>KF0MC|i~;9Dy<^JAV1pKqVv-J8xl zfZZl7G&<}OfB%hd{4k)m>9eK~7)S5wUY>2jk^s(EGJ58;y9d35sUFL!e1 z#A=($UHaH*;^1heX&JGgAO@cN9TzP0U)n!%kD%7MT8+JrM@GbYzjCDiw*HJX$10#+~6-allI>rT<9y`nEB z@BqWfduBfA-KGrzp?9Mh3vV%ixw8a@ffkd+Yo>a~2*ZXIW)8P9S6rsAlp zg-EJe8_H3}iJ}Hs;OWkwa;etcz((g0bXoiwD6zK#3;A;L@Ib7NYb-g>m!MM?Rhkkr zYsy@L=n0GPW%1vrsj0uh+RHRp{bW!#Kh;i7fA0+1?rq<{-``)SkHE)HPJR(9#0S2JxS5NbfrFkz$1PZ2jNu|CZqYLqQB`HEZD8@A{ptz<0CfcM&bEU-7BycaUc2 zC=P~m_)7{pfKQq_tkrXdMPRH2OzdVrSg!P4-7`tV>>Ux~VIW#n#)^E^gpJhbMsY`Q zA`YRY;qp3au{g;RW|O&oK4x3<1goy0sy5K%`SBKvO*U}wi2a7d0Z!B1gHVifNOs>9 zSslDPYC&L`_}|_4TNLk)qr)oM*YWhLdVvv-f8*PiWz3b15W6o`{(2{(`XfL;O?IuG z@7EeWvlx-64T%ev=z8F4c33HT_ee+!b?U*<`ysy}eTOK^zgY`|Y*VdH0l2)De(H4N z$k7^(U#QUP5}C}II{e^z3q8;f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7zAELBIT5{8e7GB=m7@OHfp#xe(=63or|zVeX}=3a zxBKA(i%Fl_Pl&5Bm6B&;2fo)gt9k|=$ls(2`2X@jE|Hm`2h^tv8V|w${#jSs@Ikev HP2~RoXR?7a literal 0 HcmV?d00001 diff --git a/Images/Icons/Filesystem/fs_map.png b/Images/Icons/Filesystem/fs_map.png new file mode 100644 index 0000000000000000000000000000000000000000..79c8304add6585361c6d44da107327199c5b69a9 GIT binary patch literal 61346 zcma(2by!qi)CLTn8HSQ>q#Kkj0g0hIR1^tmkd%~;8KhAfLAph0>1OCsP>_ZprMqL8 zdHFrh^ZoZ-*Zcl4*O|HIoW0Ll``&A>xL5QuT{WTybPoUkAkt7*egOdB`>$XC59j`J z=KJ>s06;DdN=nZhtgQinC($cWS_?~oGQ6`_O_}{s9jV3-70QngWd%OY4^JEum5(NE zBm`OGZ6y>wR9INE8b&?ocz_9M_)zhIh37-mXDH$|yJfpI7(eN!NC0&7XYbTw)2lI#eosy&I&XrpM+$zq~`9 zBcxr%Bf}}v_*{(Y5bu&c-BouH(-b`K;t|FbZpP%wf#Os6^b=z;H7;7k085hSYBow6-g=}_csQQ^{2yln2NT|DW0 z3U^C*s1j}JT}Qq7T({lzq7hlu{Q}^-sT+9$00H@bAJF(>FbV)z01ah@m%ej*?f7+k zM&4B32eE_4wjI}Z`KA8fN-bkpI1}n?a!!_@9aM@PPlB zJ?s_m4{h@u0OJmN zM{b>aap%6tzJ2}RrqUrEHs@JJs=T8x&FU;Ax>aA>A>f{yw!xq)(vJs;0Z7#)wYL|s z{aUXiwoYpT_c;dgm_D+H3mtmS9qM_+)ygy``%WbXW5n)%bxf%GMxpR2K`iSJ9Axs^ z+9Zgct3F&7v-zU>iQ{^qPK(JXC)6*{W#L3QX?Gv?tFDvx*UXo+K~7R0u)HDOaR5=; z5 zZb=g!g`|5`CRe0YdR}E3MuJPWs+N|X63v|eu<#8mueP}zW~b1ukq^DKT<>W>g#UZW z@hde~m0{U>g4{keH&glS+B|u^ZP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|C@NFnx%MMvKK^$SyViGvURM@LusBO$lI(2@1`fus)XuHIfa?8r zeg7-#gA+FaFJi3J`!SGX%KK5l)3S8?E*mrLwK>6bK4s%vO8=s<)uY<3#Vi=_RjKd{ zy;waHJMomvqzj7)pYT&}Qvfo&2yNv2zH};-BKy%e+IT^=T-1;ra%fnMFv&8KO?i+u zC4|4#qmHk;7T%Tz{1T{c(egQmqvJ*_?A>}eAW~5Cu6viPGEdwuUwa~KYGKiP5rTq^ za^=9fOS;-nxdTH5w#?ifbbu7m%ONv*V-NLVBdc?MFQI(Rh9G3h4kqe!ST{qQp2_}a zWM;Co8Xdp^1p$J*G^@5PBFq&<>y)!hepFfrOuvHR8SFx-&;CYmMsbB7f~c2_eZEs6 zIk&DMJm3QpHDHkR$sA+wygu)n{Pin}@_u7}-yF*-58OZrh`#Wh8F<9vsA*0w}= zM%j~-q4b(p)fd_*O4s!I{;n*I{4ooovIpu&((UbG2=}7nN0I+Mx&VPlT)lZos*XO8 zykK4teaRn zV_m1-4L%QmN5BVi>5c&Br$U71Ex$Wkz_4-Uv^Hq!UL6GZEz4qr0`Ez+DgXxJ=7EamF{)jydz zUjxXL*l=mI?BRCPPhV)q?cD_1~mMZY3WlV~3kZ zbmEy*U!^=%<6?qMCIRol{TV0A%q5)2M8X7;%}d}4y))wHbzXLQA8YmHKdolKZmb|( zyj|Mb$S~1sbCF!(D^qpcL%I`p8EO&C_>PS&cg;Op8fb-$AirMHbMkr+Az4VdhAoS6 zNSPu(3{F_jc}pG-9(SPo#2%)?a%CS=`FG0* zXJ~tq)qfAx4lsLl3QEh$Zt@E}?pI37VdMd|m2WyabV!;fV&g$<37&=hNxqg{!FMbR zKAu>J_LY9r?)}396{dFfY=8K)3lGd_O7G>X15->bJLnoZoCKvWzMF(ncpggueg--w K+HW+S;{FE&eWD8h literal 0 HcmV?d00001 diff --git a/Images/Icons/Filesystem/fs_sb.png b/Images/Icons/Filesystem/fs_sb.png new file mode 100644 index 0000000000000000000000000000000000000000..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G4?vk8mrKR9uQURhw{DRY}MsP8jZ=3Hth9(HSbM!7aG<6h0;t&d(! zEFxg$RVO}v?W(u7oU6gICzz{)zX=E0D%e7MTb*LLZr;1~eE*0UjCoxICUgvte4F3q zGea0;0R*{ctH%g~4_U!vo4P&4C!ay%XV*E#wl&m3cW>NU&ys*BU~(fpDzF zLa)ko=FqtdNi;h|Yf+6a3IJFz2X6uBefR&~iD5f9qjA0nSIXF1oK3X^lw)n>%TtZg z$LRT<-o}bjWw}~l2J233t2glcK`6xPmoJI9MSW?tCb}y;w$( zP8u1=B^Ns}P7A(hJW9h`*7~{N!9`&5_W{xKQ#J2LD!cAHul-6&u{J~zU2~~hPQ)nh z*{ck4SJ!r6?tu~+@aj}srPfp@BS{*%wQBf4rR&cV+D6?U)@g5RwrfISLPrkn^B;Lo57$v<-za;MJ7*fdVD02_TG0Ce{jO|&vm@XNEw zX3O30!-fLDUx1uXjJaOO-b3-p_dPyh(N3nVb4wAYT+HIyjGU7I$7DS~21~cye)o8htOZXXpn-9FRM{IyDINtc%qbx7R^SX_GD+W6fqGJx+AH;r>hbP}P*U=36g%5?n%ecbnk2jckKq6u+oEy17vJJM4| z1-xMbuZcv#E1UmPfH$(CVAuar{8y1+zyB)opx=M75)}DwzXJ~c#n^*>{|m|gRV3I? z^nWVZ_?Re!L5=;OZI2NoJZR%(2LG@F;Xr6CghB1# sjga^uVK6iB22gY60af{LpVKHhq?ue(q*EFL0tW!PnnpLu)bEA=AHVV)TL1t6 literal 0 HcmV?d00001 diff --git a/Images/Icons/Filesystem/fs_szs.png b/Images/Icons/Filesystem/fs_szs.png new file mode 100644 index 0000000000000000000000000000000000000000..db13dbc47e2378f2cb1b2fd139c0dee91d5c7bb4 GIT binary patch literal 27272 zcmce-g;!MF_c(lq76g%Q5D)|eqy!Nd5D=srX%M7CqU_zeI+ z9IPZIRjf=+0pLljOYBQ|bP1B67G`U2si#$hZyriWKZB?e%7+@KSjI{nO_)uI1d4oJ zz_|D8Q>1k3tEyw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&OcV+Khc}X1=cYN`;mG{36^hH{ISRIL8Qf1l=`dT#h zWSsm0TdkCIV~Y^&poxBce$`_++_!>O{^|j*%r>atR$9Bk zHT+p}G45OkmLwhg5M*WR{T&|GA?x}D?-c;!t(V)X|BRAx6`dn_8^upgLtPo&pYS}+ z^g%@-9^0Q+Dya*oZyD*GK01xK08BDTd=@fwRbNbKXnnZzn3|N$@>p@O+Oucx?^&$x zqhuH~dG{6q?F{t0FRKMs`P;M0#;bg{0v@Khzux%7P@wkiI*WF2tb>dY2Nxio5kYiW z?_7K08cQ9MIBoPx^Vn9)wm~E61(#KLFe0#rkMI-XF8+#pAkY}$UJq2`a-_WzTG_B8 zv>%gYmkwmc4mYHp^c%o{6D#V ci0q=VmT&tsu?l=y|J9%@ukp6#^}A314`;+^+5i9m literal 0 HcmV?d00001 diff --git a/Images/Icons/Filesystem/fs_thp.png b/Images/Icons/Filesystem/fs_thp.png new file mode 100644 index 0000000000000000000000000000000000000000..e0a32e37b5bdea9b03bc9516c510fe1f375a7d63 GIT binary patch literal 6264 zcmdT|cT`hbzTN?Z2q@SPX~A*<6%n}vkd`1Swtx-kf`Wh)0i`1(kimusUfMMX;fl1- zJA{%bN>M=RQiBG;5Q<0%5y+VnojY&dtTpegng8ajmG#R$XV>$6zi)s0+&^n-vO!cv z6acW{~%*+08}3PJ=QxdXtXtw_R8ew?!9G_ zCyS45jS@O)r20#QmfPc_UwfRi5AKY)rfn3F@8G!8@}5?`C=^~1ksqO`5^*m9L$}y{ zrOr`c{co)rA(-~o>eiKpQdd`l;pAxc)_4Trk$=!Xeg6gF)fEBPheU%_vSmj+EbL06?K2KN`Mm#$ypEtO9{ zj_s~>>K)SlK4Fuls9?-fx~A&$yyc#@irY!5Qby)cvo}c@c{d?)R*DQN*PnCe59Vth z!#ng+kp#OY?qQ#&Z}yfMG?>@V96VtfXa8)rx17FdxnlGawScwaUA;lj%z5Ymbkb8} zIA?1u*?3lCVc3Y{hRz+(b%~K2j8~>c5{;!3*X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rR(=s z4zw3mK~r|M1|CWuO7eS09UR4>(=;f#&(Z2>gdY)nTTeW^zaY<4U*O3>a!g) zFWFmS*Q*}>*n!BFi}}Y9rPI53Uj3??7IVCrAxO5ATQXw?ne;c1{yq<*Q zb@$Y!n6LS63r)9eHKmj*#st=uI;m={u!=IEE+cudNBHFiGh9$rl*>{OE*KL;M>A(n z%@ibdP`SFW?#=ybnex$jNcOUkbih84WC^L-^4D~@3;4r$ zsZ(q^UKm$nVmO;ZLtyhU0ZJOz&(y#MwCce0$G}=tvjMK!L1d1%2?AQH;G^?|3ox6V z=z?j)Dinc*BXf0^V?gpbAWKPwmv&&VcwaK$TxjkeovY-mLLQQ*EUka@f*1eMIJqmx s40Z@3hlOU^z35HW0&{NN+LP+pNA>hA^-pY literal 0 HcmV?d00001 diff --git a/include/gui/project/asset.hpp b/include/gui/project/asset.hpp new file mode 100644 index 00000000..cb4d306d --- /dev/null +++ b/include/gui/project/asset.hpp @@ -0,0 +1,45 @@ +#pragma once + +#include "fsystem.hpp" +#include "gui/widget/widget.hpp" +#include "model/fsmodel.hpp" +#include "gui/image/imagepainter.hpp" + +namespace Toolbox::UI { + + class ProjectAsset : public ImWidget { + public: + ProjectAsset() : ImWidget("Project Asset") {} + ~ProjectAsset() = default; + + [[nodiscard]] virtual std::optional defaultSize() const { + return { + {180, 180} + }; + } + [[nodiscard]] virtual std::optional minSize() const { + return { + {180, 180} + }; + } + [[nodiscard]] virtual std::optional maxSize() const { + return { + {180, 180} + }; + } + + + + void setModelIndex(const ModelIndex &index) { m_index = index; } + void setModel(RefPtr model) { m_model = model; } + + protected: + virtual void onRenderBody(TimeStep delta_time); + + private: + ModelIndex m_index; + RefPtr m_model; + ImagePainter m_painter; + }; + +} // namespace Toolbox::UI \ No newline at end of file diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index f4c9f9ce..34c76a19 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -19,6 +19,9 @@ #include "gui/event/event.hpp" #include "gui/image/imagepainter.hpp" #include "gui/window.hpp" +#include "gui/project/asset.hpp" + +#include "model/fsmodel.hpp" #include @@ -38,6 +41,9 @@ namespace Toolbox::UI { void renderProjectFolderButton(); void renderProjectFileButton(); + void renderFolderTree(const ModelIndex &index); + void initFolderAssets(const ModelIndex &index); + public: ImGuiWindowFlags flags() const override { return ImWindow::flags() | ImGuiWindowFlags_MenuBar; @@ -75,6 +81,12 @@ namespace Toolbox::UI { [[nodiscard]] bool onLoadData(const std::filesystem::path& path) override { m_project_root = path; + m_file_system_model = make_referable(); + m_file_system_model->setRoot(m_project_root); + m_tree_proxy.setSourceModel(m_file_system_model); + m_tree_proxy.setDirsOnly(true); + m_view_proxy.setSourceModel(m_file_system_model); + m_view_index = m_view_proxy.getIndex(0, 0); return true; } [[nodiscard]] bool onSaveData(std::optional path) override { @@ -92,6 +104,14 @@ namespace Toolbox::UI { fs_path m_project_root; // TODO: Have filesystem model. + FileSystemModelSortFilterProxy m_tree_proxy; + FileSystemModelSortFilterProxy m_view_proxy; + RefPtr m_file_system_model; + + std::vector m_selected_indices; + std::vector m_view_assets; + ModelIndex m_view_index; + std::unordered_map m_icon_map; ImagePainter m_icon_painter; }; diff --git a/include/model/fsmodel.hpp b/include/model/fsmodel.hpp index 49d30be7..ae3dbefc 100644 --- a/include/model/fsmodel.hpp +++ b/include/model/fsmodel.hpp @@ -10,6 +10,7 @@ #include #include "core/mimedata/mimedata.hpp" +#include "core/types.hpp" #include "fsystem.hpp" #include "image/imagehandle.hpp" #include "unique.hpp" @@ -21,15 +22,24 @@ namespace Toolbox { SORT_DESCENDING, }; + enum class ModelSortRole { + SORT_ROLE_NONE, + SORT_ROLE_NAME, + SORT_ROLE_SIZE, + SORT_ROLE_DATE, + }; + class ModelIndex : public IUnique { public: ModelIndex() = default; - ModelIndex(int64_t row, int64_t column, UUID64 model_uuid) - : m_row(row), m_column(column), m_model_uuid(model_uuid) {} + ModelIndex(UUID64 model_uuid) : m_model_uuid(model_uuid) {} + ModelIndex(const ModelIndex &other) + : m_uuid(other.m_uuid), m_model_uuid(other.m_model_uuid), + m_user_data(other.m_user_data) {} - bool isValid() const { return m_row >= 0 && m_column >= 0 && m_model_uuid != 0; } + bool isValid() const { return m_model_uuid != 0; } - template [[nodiscard]] data() const { + template [[nodiscard]] T *data() const { return reinterpret_cast(m_user_data); } void setData(void *data) { m_user_data = data; } @@ -37,53 +47,69 @@ namespace Toolbox { [[nodiscard]] UUID64 getUUID() const override { return m_uuid; } [[nodiscard]] UUID64 getModelUUID() const { return m_model_uuid; } + operator bool() const { return isValid(); } + + ModelIndex &operator=(const ModelIndex &other) { + m_uuid = other.m_uuid; + m_model_uuid = other.m_model_uuid; + m_user_data = other.m_user_data; + return *this; + } + + [[nodiscard]] bool operator==(const ModelIndex &other) const { + return m_uuid == other.m_uuid && m_model_uuid == other.m_model_uuid; + } + private: UUID64 m_uuid; UUID64 m_model_uuid = 0; - int64_t m_row = -1; - int64_t m_column = -1; - void *m_user_data = nullptr; }; - class FileSystemModel { + enum class FileSystemModelOptions { + NONE = 0, + DISABLE_WATCHDOG = BIT(0), + DISABLE_SYMLINKS = BIT(1), + }; + TOOLBOX_BITWISE_ENUM(FileSystemModelOptions) + + class FileSystemModel : public IUnique { public: - enum class Options { - DISABLE_WATCHDOG = BIT(0), - DISABLE_SYMLINKS = BIT(1), + struct FSTypeInfo { + std::string m_name; + ImageHandle m_icon; }; - TOOLBOX_BITWISE_ENUM(Options) public: FileSystemModel() = default; ~FileSystemModel() = default; - const fs_path &getRoot() const &; - void setRoot(const fs_path &path); + [[nodiscard]] UUID64 getUUID() const override { return m_uuid; } - const std::string &getFilter() const &; - void setFilter(const std::string &filter); + [[nodiscard]] bool validateIndex(const ModelIndex &index) const; + + [[nodiscard]] const fs_path &getRoot() const &; + void setRoot(const fs_path &path); - Options getOptions() const; - void setOptions(Options options); + [[nodiscard]] FileSystemModelOptions getOptions() const; + void setOptions(FileSystemModelOptions options); - bool isReadOnly() const; - void setReadOnly(); + [[nodiscard]] bool isReadOnly() const; + void setReadOnly(bool read_only); - bool isDirectory(const ModelIndex &index); - bool isFile(const ModelIndex &index); - bool isArchive(const ModelIndex &index); + [[nodiscard]] bool isDirectory(const ModelIndex &index) const; + [[nodiscard]] bool isFile(const ModelIndex &index) const; + [[nodiscard]] bool isArchive(const ModelIndex &index) const; - size_t getFileSize(const ModelIndex &index); - size_t getDirSize(const ModelIndex &index, bool recursive); + [[nodiscard]] size_t getFileSize(const ModelIndex &index); + [[nodiscard]] size_t getDirSize(const ModelIndex &index, bool recursive); - const ImageHandle &getIcon(const ModelIndex &index) const &; - Filesystem::file_time_type getLastModified(const ModelIndex &index) const; - Filesystem::perms getPermissions(const ModelIndex &index) const; - const Filesystem::file_status &getStatus(const ModelIndex &index) const &; + [[nodiscard]] const ImageHandle &getIcon(const ModelIndex &index) const &; + [[nodiscard]] Filesystem::file_time_type getLastModified(const ModelIndex &index) const; + [[nodiscard]] Filesystem::file_status getStatus(const ModelIndex &index) const; - std::string getType(const ModelIndex &index) const &; + [[nodiscard]] std::string getType(const ModelIndex &index) const &; ModelIndex mkdir(const ModelIndex &parent, const std::string &name); ModelIndex touch(const ModelIndex &parent, const std::string &name); @@ -92,37 +118,137 @@ namespace Toolbox { bool remove(const ModelIndex &index); public: - const ModelIndex &getIndex(const fs_path &path) const &; - const ModelIndex &getIndex(int64_t row, int64_t column, - ModelIndex &parent = ModelIndex()) const &; - const fs_path &getPath(const ModelIndex &index) const &; + [[nodiscard]] ModelIndex getIndex(const fs_path &path) const; + [[nodiscard]] ModelIndex getIndex(const UUID64 &path) const; + [[nodiscard]] ModelIndex getIndex(int64_t row, int64_t column, + const ModelIndex &parent = ModelIndex()) const; + [[nodiscard]] fs_path getPath(const ModelIndex &index) const; - const Modelindex &getParent(const ModelIndex &index) const &; - const ModelIndex &getSibling(int64_t row, int64_t column, const ModelIndex &index); + [[nodiscard]] ModelIndex getParent(const ModelIndex &index) const; + [[nodiscard]] ModelIndex getSibling(int64_t row, int64_t column, + const ModelIndex &index) const; - size_t getColumnCount(const ModelIndex &index) const; - size_t getRowCount(const ModelIndex &index) const; + [[nodiscard]] size_t getColumnCount(const ModelIndex &index) const; + [[nodiscard]] size_t getRowCount(const ModelIndex &index) const; - bool hasChildren(const ModelIndex &parent = ModelIndex()) const; + [[nodiscard]] bool hasChildren(const ModelIndex &parent = ModelIndex()) const; - ScopePtr createMimeData(const std::vector &indexes) const; - std::vector getSupportedMimeTypes() const; + [[nodiscard]] ScopePtr + createMimeData(const std::vector &indexes) const; + [[nodiscard]] std::vector getSupportedMimeTypes() const; - bool canFetchMore(const ModelIndex &index); + [[nodiscard]] bool canFetchMore(const ModelIndex &index); void fetchMore(const ModelIndex &index); - void sort(int64_t column, ModelSortOrder order = ModelSortOrder::SORT_ASCENDING); + static const ImageHandle &InvalidIcon(); + static const std::unordered_map &TypeMap(); protected: + ModelIndex makeIndex(const fs_path &path, int64_t row, const ModelIndex &parent); + void cacheIndex(ModelIndex &index); void cacheFolder(ModelIndex &index); void cacheFile(ModelIndex &index); void cacheArchive(ModelIndex &index); - const ModelIndex &getParentArchive(const ModelIndex &index); + ModelIndex getParentArchive(const ModelIndex &index) const; + + size_t pollChildren(const ModelIndex &index) const; private: + UUID64 m_uuid; + fs_path m_root_path; + + FileSystemModelOptions m_options = FileSystemModelOptions::NONE; + bool m_read_only = false; + + UUID64 m_root_index; + + mutable std::unordered_map m_index_map; + }; + + class FileSystemModelSortFilterProxy : public IUnique { + public: + FileSystemModelSortFilterProxy() = default; + ~FileSystemModelSortFilterProxy() = default; + + [[nodiscard]] UUID64 getUUID() const override { return m_uuid; } + + [[nodiscard]] bool validateIndex(const ModelIndex &index) const; + + [[nodiscard]] bool isDirsOnly() const { return m_dirs_only; } + void setDirsOnly(bool dirs_only) { m_dirs_only = true; } + + [[nodiscard]] RefPtr getSourceModel() const; + void setSourceModel(RefPtr model); + + [[nodiscard]] ModelSortOrder getSortOrder() const; + void setSortOrder(ModelSortOrder order); + + [[nodiscard]] ModelSortRole getSortRole() const; + void setSortRole(ModelSortRole role); + + [[nodiscard]] const std::string &getFilter() const &; + void setFilter(const std::string &filter); + + [[nodiscard]] bool isReadOnly() const; + void setReadOnly(bool read_only); + + [[nodiscard]] bool isDirectory(const ModelIndex &index) const; + [[nodiscard]] bool isFile(const ModelIndex &index) const; + [[nodiscard]] bool isArchive(const ModelIndex &index) const; + + [[nodiscard]] size_t getFileSize(const ModelIndex &index); + [[nodiscard]] size_t getDirSize(const ModelIndex &index, bool recursive); + + [[nodiscard]] const ImageHandle &getIcon(const ModelIndex &index) const &; + [[nodiscard]] Filesystem::file_time_type getLastModified(const ModelIndex &index) const; + [[nodiscard]] Filesystem::file_status getStatus(const ModelIndex &index) const; + + [[nodiscard]] std::string getType(const ModelIndex &index) const &; + + ModelIndex mkdir(const ModelIndex &parent, const std::string &name); + ModelIndex touch(const ModelIndex &parent, const std::string &name); + + bool rmdir(const ModelIndex &index); + bool remove(const ModelIndex &index); + + [[nodiscard]] ModelIndex getIndex(const fs_path &path) const; + [[nodiscard]] ModelIndex getIndex(const UUID64 &path) const; + [[nodiscard]] ModelIndex getIndex(int64_t row, int64_t column, + const ModelIndex &parent = ModelIndex()) const; + [[nodiscard]] fs_path getPath(const ModelIndex &index) const; + + [[nodiscard]] ModelIndex getParent(const ModelIndex &index) const; + [[nodiscard]] ModelIndex getSibling(int64_t row, int64_t column, + const ModelIndex &index) const; + + [[nodiscard]] size_t getColumnCount(const ModelIndex &index) const; + [[nodiscard]] size_t getRowCount(const ModelIndex &index) const; + + [[nodiscard]] bool hasChildren(const ModelIndex &parent = ModelIndex()) const; + + [[nodiscard]] ScopePtr + createMimeData(const std::vector &indexes) const; + [[nodiscard]] std::vector getSupportedMimeTypes() const; + + [[nodiscard]] bool canFetchMore(const ModelIndex &index); + void fetchMore(const ModelIndex &index); + + protected: + [[nodiscard]] ModelIndex toSourceIndex(const ModelIndex &index) const; + [[nodiscard]] ModelIndex toProxyIndex(const ModelIndex &index) const; + + private: + UUID64 m_uuid; + + RefPtr m_source_model = nullptr; + ModelSortOrder m_sort_order = ModelSortOrder::SORT_ASCENDING; + ModelSortRole m_sort_role = ModelSortRole::SORT_ROLE_NONE; + std::string m_filter = ""; + + bool m_dirs_only = false; }; } // namespace Toolbox \ No newline at end of file diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 0cece844..f39a8937 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -26,6 +26,7 @@ #include "gui/logging/errors.hpp" #include "gui/logging/window.hpp" #include "gui/pad/window.hpp" +#include "gui/project/window.hpp" #include "gui/scene/ImGuizmo.h" #include "gui/scene/window.hpp" #include "gui/settings/window.hpp" @@ -431,6 +432,12 @@ namespace Toolbox { } else { if (m_project_manager.loadProjectFolder(path)) { TOOLBOX_INFO_V("Loaded project folder: {}", path.string()); + RefPtr project_window = + createWindow("Project View"); + if (!project_window->onLoadData(path)) { + TOOLBOX_ERROR("Failed to open project folder view!"); + project_window->close(); + } } } } diff --git a/src/gui/project/asset.cpp b/src/gui/project/asset.cpp new file mode 100644 index 00000000..b991fa93 --- /dev/null +++ b/src/gui/project/asset.cpp @@ -0,0 +1,21 @@ +#pragma once + +#include "fsystem.hpp" +#include "gui/project/asset.hpp" +#include "model/fsmodel.hpp" + +namespace Toolbox::UI { + + void ProjectAsset::onRenderBody(TimeStep delta_time) { + // Draw the asset icon + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, {3, 3}); + + if (m_model) { + m_painter.render(m_model->getIcon(m_index)); + ImGui::Text("%s", m_model->getPath(m_index).c_str()); + } + + ImGui::PopStyleVar(); + } + +} // namespace Toolbox::UI \ No newline at end of file diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 97152c90..12df64b7 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -1,4 +1,7 @@ #include "gui/project/window.hpp" +#include "model/fsmodel.hpp" + +#include namespace Toolbox::UI { @@ -6,11 +9,56 @@ namespace Toolbox::UI { void ProjectViewWindow::onRenderMenuBar() {} - void ProjectViewWindow::onRenderBody(TimeStep delta_time) {} + void ProjectViewWindow::onRenderBody(TimeStep delta_time) { + renderProjectTreeView(); + ImGui::SameLine(); + ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical); + ImGui::SameLine(); + renderProjectFolderView(); + renderProjectFolderButton(); + renderProjectFileButton(); + } + + void ProjectViewWindow::renderProjectTreeView() { + if (ImGui::BeginChild("Tree View", {160, 0}, true, + ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { + ModelIndex index = m_tree_proxy.getIndex(0, 0); + renderFolderTree(index); + } + ImGui::EndChild(); + } + + void ProjectViewWindow::renderProjectFolderView() { + if (!m_view_index.isValid()) { + return; + } - void ProjectViewWindow::renderProjectTreeView() {} + if (ImGui::BeginChild("Folder View", { 400, 0 }, true, + ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { + if (m_view_proxy.hasChildren(m_view_index)) { + if (m_view_proxy.canFetchMore(m_view_index)) { + m_view_proxy.fetchMore(m_view_index); + } + for (size_t i = 0; i < m_view_proxy.getRowCount(m_view_index); ++i) { + ModelIndex child_index = m_view_proxy.getIndex(i, 0, m_view_index); - void ProjectViewWindow::renderProjectFolderView() {} + if (ImGui::BeginChild(child_index.getUUID(), {160, 180}, true, + ImGuiWindowFlags_ChildWindow | + ImGuiWindowFlags_NoDecoration)) { + const ImageHandle &icon = m_view_proxy.getIcon(child_index); + m_icon_painter.render(icon, {140, 140}); + + ImGui::RenderTextEllipsis( + ImGui::GetWindowDrawList(), {10, 150}, {130, 170}, 120.0f, 150.0f, + m_view_proxy.getPath(child_index).filename().string().c_str(), nullptr, + nullptr); + } + ImGui::EndChild(); + } + } + } + ImGui::EndChild(); + } void ProjectViewWindow::renderProjectFolderButton() {} @@ -28,4 +76,29 @@ namespace Toolbox::UI { void ProjectViewWindow::onDropEvent(RefPtr ev) {} -} // namespace Toolbox::UI \ No newline at end of file + void ProjectViewWindow::renderFolderTree(const ModelIndex &index) { + bool is_open = false; + if (m_tree_proxy.hasChildren(index)) { + if (m_tree_proxy.canFetchMore(index)) { + m_tree_proxy.fetchMore(index); + } + is_open = ImGui::TreeNodeEx(m_tree_proxy.getPath(index).filename().string().c_str(), + ImGuiTreeNodeFlags_OpenOnArrow); + if (is_open) { + for (size_t i = 0; i < m_tree_proxy.getRowCount(index); ++i) { + ModelIndex child_index = m_tree_proxy.getIndex(i, 0, index); + renderFolderTree(child_index); + } + ImGui::TreePop(); + } + } else { + if (ImGui::TreeNodeEx(m_tree_proxy.getPath(index).filename().string().c_str(), + ImGuiTreeNodeFlags_Leaf)) { + ImGui::TreePop(); + } + } + } + + void ProjectViewWindow::initFolderAssets(const ModelIndex &index) {} + +} // namespace Toolbox::UI \ No newline at end of file diff --git a/src/model/fsmodel.cpp b/src/model/fsmodel.cpp new file mode 100644 index 00000000..fe1ba839 --- /dev/null +++ b/src/model/fsmodel.cpp @@ -0,0 +1,1111 @@ +#include +#include +#include + +#include "model/fsmodel.hpp" + +namespace Toolbox { + + struct _FileSystemIndexData { + enum class Type { + FILE, + DIRECTORY, + ARCHIVE, + UNKNOWN, + }; + + UUID64 m_parent = 0; + std::vector m_children = {}; + + Type m_type = Type::UNKNOWN; + fs_path m_path; + size_t m_size = 0; + Filesystem::file_time_type m_date; + + bool hasChild(UUID64 uuid) const { + return std::find(m_children.begin(), m_children.end(), uuid) != m_children.end(); + } + + std::strong_ordering operator<=>(const _FileSystemIndexData &rhs) const { + return m_path <=> rhs.m_path; + } + }; + + static bool _FileSystemIndexDataIsDirLike(const _FileSystemIndexData &data) { + return data.m_type == _FileSystemIndexData::Type::DIRECTORY || + data.m_type == _FileSystemIndexData::Type::ARCHIVE; + } + + static bool _FileSystemIndexDataCompareByName(const _FileSystemIndexData &lhs, + const _FileSystemIndexData &rhs, + ModelSortOrder order) { + const bool is_lhs_dir = _FileSystemIndexDataIsDirLike(lhs); + const bool is_rhs_dir = _FileSystemIndexDataIsDirLike(rhs); + + // Folders come first + if (is_lhs_dir && !is_rhs_dir) { + return true; + } + + if (!is_lhs_dir && is_rhs_dir) { + return false; + } + + // Sort by name + if (order == ModelSortOrder::SORT_ASCENDING) { + return lhs.m_path < rhs.m_path; + } else { + return lhs.m_path > rhs.m_path; + } + } + + static bool _FileSystemIndexDataCompareBySize(const _FileSystemIndexData &lhs, + const _FileSystemIndexData &rhs, + ModelSortOrder order) { + const bool is_lhs_dir = _FileSystemIndexDataIsDirLike(lhs); + const bool is_rhs_dir = _FileSystemIndexDataIsDirLike(rhs); + + // Folders come first + if (is_lhs_dir && !is_rhs_dir) { + return true; + } + + if (!is_lhs_dir && is_rhs_dir) { + return false; + } + + // Sort by size + if (order == ModelSortOrder::SORT_ASCENDING) { + return lhs.m_size < rhs.m_size; + } else { + return lhs.m_size > rhs.m_size; + } + } + + static bool _FileSystemIndexDataCompareByDate(const _FileSystemIndexData &lhs, + const _FileSystemIndexData &rhs, + ModelSortOrder order) { + const bool is_lhs_dir = _FileSystemIndexDataIsDirLike(lhs); + const bool is_rhs_dir = _FileSystemIndexDataIsDirLike(rhs); + + // Folders come first + if (is_lhs_dir && !is_rhs_dir) { + return true; + } + + if (!is_lhs_dir && is_rhs_dir) { + return false; + } + + // Sort by date + if (order == ModelSortOrder::SORT_ASCENDING) { + return lhs.m_date < rhs.m_date; + } else { + return lhs.m_date > rhs.m_date; + } + } + + const fs_path &FileSystemModel::getRoot() const & { return m_root_path; } + + void FileSystemModel::setRoot(const fs_path &path) { + if (m_root_path == path) { + return; + } + + m_index_map.clear(); + + m_root_path = path; + m_root_index = makeIndex(path, 0, ModelIndex()).getUUID(); + } + + FileSystemModelOptions FileSystemModel::getOptions() const { return m_options; } + + void FileSystemModel::setOptions(FileSystemModelOptions options) { m_options = options; } + + bool FileSystemModel::isReadOnly() const { return m_read_only; } + + void FileSystemModel::setReadOnly(bool read_only) { m_read_only = read_only; } + + bool FileSystemModel::isDirectory(const ModelIndex &index) const { + if (!validateIndex(index)) { + return false; + } + return index.data<_FileSystemIndexData>()->m_type == _FileSystemIndexData::Type::DIRECTORY; + } + + bool FileSystemModel::isFile(const ModelIndex &index) const { + if (!validateIndex(index)) { + return false; + } + return index.data<_FileSystemIndexData>()->m_type == _FileSystemIndexData::Type::FILE; + } + + bool FileSystemModel::isArchive(const ModelIndex &index) const { + if (!validateIndex(index)) { + return false; + } + return index.data<_FileSystemIndexData>()->m_type == _FileSystemIndexData::Type::ARCHIVE; + } + + size_t FileSystemModel::getFileSize(const ModelIndex &index) { + if (!isFile(index)) { + return 0; + } + return index.data<_FileSystemIndexData>()->m_size; + } + + size_t FileSystemModel::getDirSize(const ModelIndex &index, bool recursive) { + if (!(isDirectory(index) || isArchive(index))) { + return 0; + } + return index.data<_FileSystemIndexData>()->m_size; + } + + const ImageHandle &FileSystemModel::getIcon(const ModelIndex &index) const & { + if (!validateIndex(index)) { + return TypeMap().at("_Invalid").m_icon; + } + + if (isDirectory(index)) { + return TypeMap().at("_Folder").m_icon; + } + + if (isArchive(index)) { + return TypeMap().at("_Archive").m_icon; + } + + std::string ext = index.data<_FileSystemIndexData>()->m_path.extension().string(); + if (ext.empty()) { + return TypeMap().at("_Folder").m_icon; + } + + if (TypeMap().find(ext) == TypeMap().end()) { + return TypeMap().at("_File").m_icon; + } + + return TypeMap().at(ext).m_icon; + } + + Filesystem::file_time_type FileSystemModel::getLastModified(const ModelIndex &index) const { + if (!validateIndex(index)) { + return Filesystem::file_time_type(); + } + + Filesystem::file_time_type result = Filesystem::file_time_type(); + + Filesystem::last_write_time(index.data<_FileSystemIndexData>()->m_path) + .and_then([&](Filesystem::file_time_type &&time) { + result = std::move(time); + return Result(); + }) + .or_else([&](const FSError &error) { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to get last write time: {}", + error.m_message[0]); + return Result(); + }); + + return result; + } + + Filesystem::file_status FileSystemModel::getStatus(const ModelIndex &index) const { + if (!validateIndex(index)) { + return Filesystem::file_status(); + } + + Filesystem::file_status result = Filesystem::file_status(); + + Filesystem::status(index.data<_FileSystemIndexData>()->m_path) + .and_then([&](Filesystem::file_status &&status) { + result = std::move(status); + return Result(); + }) + .or_else([&](const FSError &error) { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to get last write status: {}", + error.m_message[0]); + return Result(); + }); + + return result; + } + + std::string FileSystemModel::getType(const ModelIndex &index) const & { + if (!validateIndex(index)) { + return TypeMap().at("_Invalid").m_name; + } + + if (isDirectory(index)) { + return TypeMap().at("_Folder").m_name; + } + + if (isArchive(index)) { + return TypeMap().at("_Archive").m_name; + } + + std::string ext = index.data<_FileSystemIndexData>()->m_path.extension().string(); + if (ext.empty()) { + return TypeMap().at("_Folder").m_name; + } + + if (TypeMap().find(ext) == TypeMap().end()) { + return TypeMap().at("_File").m_name; + } + + return TypeMap().at(ext).m_name; + } + + ModelIndex FileSystemModel::mkdir(const ModelIndex &parent, const std::string &name) { + if (!validateIndex(parent)) { + return ModelIndex(); + } + + bool result = false; + + if (isDirectory(parent)) { + fs_path path = parent.data<_FileSystemIndexData>()->m_path / name; + Filesystem::create_directory(path) + .and_then([&](bool created) { + if (!created) { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to create directory: {}", + path.string()); + return Result(); + } + result = true; + return Result(); + }) + .or_else([&](const FSError &error) { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to create directory: {}", + error.m_message[0]); + return Result(); + }); + } else if (isArchive(parent)) { + TOOLBOX_ERROR("[FileSystemModel] Archive creation is unimplemented!"); + } else { + TOOLBOX_ERROR("[FileSystemModel] Parent index is not a directory!"); + } + + if (!result) { + return ModelIndex(); + } + + return makeIndex(parent.data<_FileSystemIndexData>()->m_path / name, getRowCount(parent), + parent); + } + + ModelIndex FileSystemModel::touch(const ModelIndex &parent, const std::string &name) { + if (!validateIndex(parent)) { + return ModelIndex(); + } + + bool result = false; + + if (isDirectory(parent)) { + fs_path path = parent.data<_FileSystemIndexData>()->m_path / name; + std::ofstream file(path); + if (!file.is_open()) { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to create file: {}", path.string()); + return ModelIndex(); + } + file.close(); + result = true; + } else if (isArchive(parent)) { + TOOLBOX_ERROR("[FileSystemModel] Archive creation is unimplemented!"); + } else { + TOOLBOX_ERROR("[FileSystemModel] Parent index is not a directory!"); + } + + if (!result) { + return ModelIndex(); + } + + return makeIndex(parent.data<_FileSystemIndexData>()->m_path / name, getRowCount(parent), + parent); + } + + bool FileSystemModel::rmdir(const ModelIndex &index) { + if (!validateIndex(index)) { + return false; + } + + bool result = false; + + if (isDirectory(index)) { + Filesystem::remove_all(index.data<_FileSystemIndexData>()->m_path) + .and_then([&](bool removed) { + if (!removed) { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to remove directory: {}", + index.data<_FileSystemIndexData>()->m_path.string()); + return Result(); + } + result = true; + return Result(); + }) + .or_else([&](const FSError &error) { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to remove directory: {}", + error.m_message[0]); + return Result(); + }); + } else if (isArchive(index)) { + Filesystem::remove(index.data<_FileSystemIndexData>()->m_path) + .and_then([&](bool removed) { + if (!removed) { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to remove archive: {}", + index.data<_FileSystemIndexData>()->m_path.string()); + return Result(); + } + result = true; + return Result(); + }) + .or_else([&](const FSError &error) { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to remove archive: {}", + error.m_message[0]); + return Result(); + }); + } else { + TOOLBOX_ERROR("[FileSystemModel] Index is not a directory!"); + } + + if (result) { + ModelIndex parent = getParent(index); + if (validateIndex(parent)) { + _FileSystemIndexData *parent_data = parent.data<_FileSystemIndexData>(); + parent_data->m_children.erase(std::remove(parent_data->m_children.begin(), + parent_data->m_children.end(), + index.getUUID()), + parent_data->m_children.end()); + m_index_map.erase(index.getUUID()); + } + } + + return result; + } + + bool FileSystemModel::remove(const ModelIndex &index) { + if (!validateIndex(index)) { + return false; + } + + bool result = false; + + if (isFile(index)) { + Filesystem::remove(index.data<_FileSystemIndexData>()->m_path) + .and_then([&](bool removed) { + if (!removed) { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to remove file: {}", + index.data<_FileSystemIndexData>()->m_path.string()); + return Result(); + } + result = true; + return Result(); + }) + .or_else([&](const FSError &error) { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to remove file: {}", + error.m_message[0]); + return Result(); + }); + } else if (isArchive(index)) { + TOOLBOX_ERROR("[FileSystemModel] Index is not a file!"); + } else { + TOOLBOX_ERROR("[FileSystemModel] Index is not a file!"); + } + + if (result) { + ModelIndex parent = getParent(index); + if (validateIndex(parent)) { + _FileSystemIndexData *parent_data = parent.data<_FileSystemIndexData>(); + parent_data->m_children.erase(std::remove(parent_data->m_children.begin(), + parent_data->m_children.end(), + index.getUUID()), + parent_data->m_children.end()); + m_index_map.erase(index.getUUID()); + } + } + + return result; + } + + ModelIndex FileSystemModel::getIndex(const fs_path &path) const { + if (m_index_map.empty()) { + return ModelIndex(); + } + + for (const auto &[uuid, index] : m_index_map) { + if (index.data<_FileSystemIndexData>()->m_path == path) { + return index; + } + } + + return ModelIndex(); + } + + ModelIndex FileSystemModel::getIndex(const UUID64 &uuid) const { return m_index_map.at(uuid); } + + ModelIndex FileSystemModel::getIndex(int64_t row, int64_t column, + const ModelIndex &parent) const { + if (!validateIndex(parent)) { + if (m_root_index != 0 && row == 0 && column == 0) { + return m_index_map.at(m_root_index); + } + return ModelIndex(); + } + + _FileSystemIndexData *parent_data = parent.data<_FileSystemIndexData>(); + if (row < 0 || (size_t)row >= parent_data->m_children.size()) { + return ModelIndex(); + } + + return m_index_map.at(parent_data->m_children[row]); + } + + fs_path FileSystemModel::getPath(const ModelIndex &index) const { + if (!validateIndex(index)) { + return fs_path(); + } + + return index.data<_FileSystemIndexData>()->m_path; + } + + ModelIndex FileSystemModel::getParent(const ModelIndex &index) const { + if (!validateIndex(index)) { + return ModelIndex(); + } + + const UUID64 &id = index.data<_FileSystemIndexData>()->m_parent; + if (id == 0) { + return ModelIndex(); + } + + return m_index_map.at(id); + } + + ModelIndex FileSystemModel::getSibling(int64_t row, int64_t column, + const ModelIndex &index) const { + if (!validateIndex(index)) { + return ModelIndex(); + } + + const ModelIndex &parent = getParent(index); + if (!validateIndex(parent)) { + return ModelIndex(); + } + + return getIndex(row, column, parent); + } + + size_t FileSystemModel::getColumnCount(const ModelIndex &index) const { return 1; } + + size_t FileSystemModel::getRowCount(const ModelIndex &index) const { + if (!validateIndex(index)) { + return 0; + } + + return index.data<_FileSystemIndexData>()->m_children.size(); + } + + bool FileSystemModel::hasChildren(const ModelIndex &parent) const { + return pollChildren(parent) > 0; + } + + ScopePtr + FileSystemModel::createMimeData(const std::vector &indexes) const { + TOOLBOX_ERROR("[FileSystemModel] Mimedata unimplemented!"); + return ScopePtr(); + } + + std::vector FileSystemModel::getSupportedMimeTypes() const { + return std::vector(); + } + + bool FileSystemModel::canFetchMore(const ModelIndex &index) { + if (!validateIndex(index)) { + return false; + } + + if (!isDirectory(index) && !isArchive(index)) { + return false; + } + + return index.data<_FileSystemIndexData>()->m_children.empty(); + } + + void FileSystemModel::fetchMore(const ModelIndex &index) { + if (!validateIndex(index)) { + return; + } + + if (isDirectory(index)) { + fs_path path = index.data<_FileSystemIndexData>()->m_path; + + size_t i = 0; + for (const auto &entry : Filesystem::directory_iterator(path)) { + makeIndex(entry.path(), i++, index); + } + } + } + + const ImageHandle &FileSystemModel::InvalidIcon() { + static ImageHandle s_invalid_fs_icon = ImageHandle("Images/Icons/fs_invalid.png"); + return s_invalid_fs_icon; + } + + const std::unordered_map &FileSystemModel::TypeMap() { + // clang-format off + static std::unordered_map s_type_map = { + {"_Invalid", FSTypeInfo("Invalid", ImageHandle("Images/Icons/Filesystem/fs_invalid.png"))}, + {"_Folder", FSTypeInfo("Folder", ImageHandle("Images/Icons/Filesystem/fs_generic_folder.png")) }, + {"_Archive", FSTypeInfo("Archive", ImageHandle("Images/Icons/Filesystem/fs_arc.png"))}, + {"_File", FSTypeInfo("File", ImageHandle("Images/Icons/Filesystem/fs_generic_file.png")) }, + {".txt", FSTypeInfo("Text", ImageHandle("Images/Icons/Filesystem/fs_txt.png")) }, + {".md", FSTypeInfo("Markdown", ImageHandle("Images/Icons/Filesystem/fs_md.png")) }, + {".c", FSTypeInfo("C", ImageHandle("Images/Icons/Filesystem/fs_c.png")) }, + {".h", FSTypeInfo("Header", ImageHandle("Images/Icons/Filesystem/fs_h.png")) }, + {".cpp", FSTypeInfo("C++", ImageHandle("Images/Icons/Filesystem/fs_cpp.png")) }, + {".hpp", FSTypeInfo("Header", ImageHandle("Images/Icons/Filesystem/fs_hpp.png")) }, + {".cxx", FSTypeInfo("C++", ImageHandle("Images/Icons/Filesystem/fs_cpp.png")) }, + {".hxx", FSTypeInfo("Header", ImageHandle("Images/Icons/Filesystem/fs_hpp.png")) }, + {".c++", FSTypeInfo("C++", ImageHandle("Images/Icons/Filesystem/fs_cpp.png")) }, + {".h++", FSTypeInfo("Header", ImageHandle("Images/Icons/Filesystem/fs_hpp.png")) }, + {".cc", FSTypeInfo("C++", ImageHandle("Images/Icons/Filesystem/fs_cpp.png")) }, + {".hh", FSTypeInfo("Header", ImageHandle("Images/Icons/Filesystem/fs_hpp.png")) }, + {".arc", FSTypeInfo("Archive", ImageHandle("Images/Icons/Filesystem/fs_arc.png")) }, + {".bas", FSTypeInfo("JAudio Sequence", ImageHandle("Images/Icons/Filesystem/fs_bas.png")) }, + {".bck", FSTypeInfo("J3D Bone Animation", ImageHandle("Images/Icons/Filesystem/fs_bck.png")) }, + {".bdl", FSTypeInfo("J3D Model Data", ImageHandle("Images/Icons/Filesystem/fs_bdl.png")) }, + {".blo", FSTypeInfo("J2D Screen Layout", ImageHandle("Images/Icons/Filesystem/fs_blo.png")) }, + {".bmd", FSTypeInfo("J3D Model Data", ImageHandle("Images/Icons/Filesystem/fs_bmd.png")) }, + {".bmg", FSTypeInfo("Message Data", ImageHandle("Images/Icons/Filesystem/fs_bmg.png")) }, + {".bmt", FSTypeInfo("J3D Material Table", ImageHandle("Images/Icons/Filesystem/fs_bmt.png")) }, + {".brk", FSTypeInfo("J3D Color Register Anim", ImageHandle("Images/Icons/Filesystem/fs_brk.png")) }, + {".bti", FSTypeInfo("J2D Texture Image", ImageHandle("Images/Icons/Filesystem/fs_bti.png")) }, + {".btk", FSTypeInfo("J2D Texture Animation", ImageHandle("Images/Icons/Filesystem/fs_btk.png")) }, + {".btp", FSTypeInfo("J2D Texture Pattern Anim", ImageHandle("Images/Icons/Filesystem/fs_btp.png")) }, + {".col", FSTypeInfo("SMS Collision Data", ImageHandle("Images/Icons/Filesystem/fs_col.png")) }, + {".jpa", FSTypeInfo("JParticle Data", ImageHandle("Images/Icons/Filesystem/fs_jpa.png")) }, + {".map", FSTypeInfo("Executable Symbol Map", ImageHandle("Images/Icons/Filesystem/fs_map.png")) }, + {".me", FSTypeInfo("Marked For Delete", ImageHandle("Images/Icons/Filesystem/fs_me.png")) }, + {".prm", FSTypeInfo("SMS Parameter Data", ImageHandle("Images/Icons/Filesystem/fs_prm.png")) }, + {".sb", FSTypeInfo("Sunscript", ImageHandle("Images/Icons/Filesystem/fs_sb.png")) }, + {".szs", FSTypeInfo("Yaz0 Compressed Data", ImageHandle("Images/Icons/Filesystem/fs_szs.png")) }, + {".thp", FSTypeInfo("DolphinOS Movie Data", ImageHandle("Images/Icons/Filesystem/fs_thp.png")) }, + }; + // clang-format on + return s_type_map; + } + + bool FileSystemModel::validateIndex(const ModelIndex &index) const { + return index.isValid() && index.getModelUUID() == getUUID(); + } + + ModelIndex FileSystemModel::makeIndex(const fs_path &path, int64_t row, + const ModelIndex &parent) { + _FileSystemIndexData *parent_data = nullptr; + + if (!validateIndex(parent)) { + if (row != 0) { + TOOLBOX_ERROR("[FileSystemModel] Invalid row index!"); + return ModelIndex(); + } + } else { + parent_data = parent.data<_FileSystemIndexData>(); + if (row < 0 || (size_t)row > parent_data->m_children.size()) { + TOOLBOX_ERROR("[FileSystemModel] Invalid row index!"); + return ModelIndex(); + } + } + + _FileSystemIndexData *data = new _FileSystemIndexData; + data->m_path = path; + data->m_size = 0; + + if (Filesystem::is_directory(path).value_or(false)) { + data->m_type = _FileSystemIndexData::Type::DIRECTORY; + } else if (Filesystem::is_regular_file(path).value_or(false)) { + if (false) { + data->m_type = _FileSystemIndexData::Type::ARCHIVE; + } else { + data->m_type = _FileSystemIndexData::Type::FILE; + } + } else { + TOOLBOX_ERROR_V("[FileSystemModel] Invalid path: {}", path.string()); + return ModelIndex(); + } + + Filesystem::last_write_time(data->m_path) + .and_then([&](Filesystem::file_time_type &&time) { + data->m_date = std::move(time); + return Result(); + }) + .or_else([&](const FSError &error) { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to get last write time: {}", + error.m_message[0]); + return Result(); + }); + + ModelIndex index = ModelIndex(getUUID()); + + if (!validateIndex(parent)) { + index.setData(data); + m_index_map[index.getUUID()] = std::move(index); + } else { + data->m_parent = parent.getUUID(); + index.setData(data); + + if (parent_data) { + parent_data->m_children.insert(parent_data->m_children.begin() + row, + index.getUUID()); + } + + m_index_map[index.getUUID()] = std::move(index); + } + + return index; + } + + void FileSystemModel::cacheIndex(ModelIndex &index) {} + void FileSystemModel::cacheFolder(ModelIndex &index) {} + void FileSystemModel::cacheFile(ModelIndex &index) {} + void FileSystemModel::cacheArchive(ModelIndex &index) {} + + ModelIndex FileSystemModel::getParentArchive(const ModelIndex &index) const { + ModelIndex parent = getParent(index); + do { + if (isArchive(parent)) { + return parent; + } + parent = getParent(parent); + } while (validateIndex(parent)); + + return ModelIndex(); + } + + size_t FileSystemModel::pollChildren(const ModelIndex &index) const { + if (!validateIndex(index)) { + return 0; + } + + size_t count = 0; + + if (isDirectory(index)) { + // Count the children in the filesystem + for (const auto &entry : + Filesystem::directory_iterator(index.data<_FileSystemIndexData>()->m_path)) { + count += 1; + } + } else if (isArchive(index)) { + // Count the children in the archive + TOOLBOX_ERROR("[FileSystemModel] Archive polling unimplemented!"); + } else if (isFile(index)) { + // Files have no children + count = 0; + } else { + // Invalid index + count = 0; + } + + return count; + } + + RefPtr FileSystemModelSortFilterProxy::getSourceModel() const { + return m_source_model; + } + + void FileSystemModelSortFilterProxy::setSourceModel(RefPtr model) { + m_source_model = model; + } + + ModelSortOrder FileSystemModelSortFilterProxy::getSortOrder() const { return m_sort_order; } + void FileSystemModelSortFilterProxy::setSortOrder(ModelSortOrder order) { + m_sort_order = order; + } + + ModelSortRole FileSystemModelSortFilterProxy::getSortRole() const { return m_sort_role; } + void FileSystemModelSortFilterProxy::setSortRole(ModelSortRole role) { m_sort_role = role; } + + const std::string &FileSystemModelSortFilterProxy::getFilter() const & { return m_filter; } + void FileSystemModelSortFilterProxy::setFilter(const std::string &filter) { m_filter = filter; } + + bool FileSystemModelSortFilterProxy::isReadOnly() const { + if (!m_source_model) { + return true; + } + return m_source_model->isReadOnly(); + } + + void FileSystemModelSortFilterProxy::setReadOnly(bool read_only) { + if (!m_source_model) { + return; + } + m_source_model->setReadOnly(read_only); + } + + bool FileSystemModelSortFilterProxy::isDirectory(const ModelIndex &index) const { + if (!m_source_model) { + return false; + } + + ModelIndex &&source_index = toSourceIndex(index); + return m_source_model->isDirectory(source_index); + } + + bool FileSystemModelSortFilterProxy::isFile(const ModelIndex &index) const { + if (!m_source_model) { + return false; + } + + ModelIndex &&source_index = toSourceIndex(index); + return m_source_model->isFile(source_index); + } + + bool FileSystemModelSortFilterProxy::isArchive(const ModelIndex &index) const { + if (!m_source_model) { + return false; + } + + ModelIndex &&source_index = toSourceIndex(index); + return m_source_model->isArchive(source_index); + } + + size_t FileSystemModelSortFilterProxy::getFileSize(const ModelIndex &index) { + if (!m_source_model) { + return 0; + } + + ModelIndex &&source_index = toSourceIndex(index); + return m_source_model->getFileSize(source_index); + } + + size_t FileSystemModelSortFilterProxy::getDirSize(const ModelIndex &index, bool recursive) { + if (!m_source_model) { + return 0; + } + + ModelIndex &&source_index = toSourceIndex(index); + return m_source_model->getDirSize(source_index, recursive); + } + + const ImageHandle &FileSystemModelSortFilterProxy::getIcon(const ModelIndex &index) const & { + if (!m_source_model) { + return FileSystemModel::InvalidIcon(); + } + + ModelIndex &&source_index = toSourceIndex(index); + return m_source_model->getIcon(source_index); + } + + Filesystem::file_time_type + FileSystemModelSortFilterProxy::getLastModified(const ModelIndex &index) const { + if (!m_source_model) { + return Filesystem::file_time_type(); + } + + ModelIndex &&source_index = toSourceIndex(index); + return m_source_model->getLastModified(source_index); + } + + Filesystem::file_status + FileSystemModelSortFilterProxy::getStatus(const ModelIndex &index) const { + if (!m_source_model) { + return Filesystem::file_status(); + } + + ModelIndex &&source_index = toSourceIndex(index); + return m_source_model->getStatus(source_index); + } + + std::string FileSystemModelSortFilterProxy::getType(const ModelIndex &index) const & { + if (!m_source_model) { + return "Invalid"; + } + + ModelIndex &&source_index = toSourceIndex(index); + return m_source_model->getType(source_index); + } + + ModelIndex FileSystemModelSortFilterProxy::mkdir(const ModelIndex &parent, + const std::string &name) { + if (!m_source_model) { + return ModelIndex(); + } + + ModelIndex &&source_index = toSourceIndex(parent); + return m_source_model->mkdir(source_index, name); + } + + ModelIndex FileSystemModelSortFilterProxy::touch(const ModelIndex &parent, + const std::string &name) { + if (!m_source_model) { + return ModelIndex(); + } + + ModelIndex &&source_index = toSourceIndex(parent); + return m_source_model->touch(source_index, name); + } + + bool FileSystemModelSortFilterProxy::rmdir(const ModelIndex &index) { + if (!m_source_model) { + return false; + } + + ModelIndex &&source_index = toSourceIndex(index); + return m_source_model->rmdir(source_index); + } + + bool FileSystemModelSortFilterProxy::remove(const ModelIndex &index) { + if (!m_source_model) { + return false; + } + + ModelIndex &&source_index = toSourceIndex(index); + return m_source_model->remove(source_index); + } + + ModelIndex FileSystemModelSortFilterProxy::getIndex(const fs_path &path) const { + ModelIndex index = m_source_model->getIndex(path); + if (!index.isValid()) { + return ModelIndex(); + } + + return toProxyIndex(index); + } + + ModelIndex FileSystemModelSortFilterProxy::getIndex(const UUID64 &uuid) const { + ModelIndex index = m_source_model->getIndex(uuid); + if (!index.isValid()) { + return ModelIndex(); + } + + return toProxyIndex(index); + } + + ModelIndex FileSystemModelSortFilterProxy::getIndex(int64_t row, int64_t column, + const ModelIndex &parent) const { + ModelIndex parent_src = toSourceIndex(parent); + + ModelIndex index = m_source_model->getIndex(row, column, parent_src); + if (!index.isValid()) { + return ModelIndex(); + } + + return toProxyIndex(index); + } + + fs_path FileSystemModelSortFilterProxy::getPath(const ModelIndex &index) const { + if (!m_source_model) { + return fs_path(); + } + + ModelIndex &&source_index = toSourceIndex(index); + if (!source_index.isValid()) { + return fs_path(); + } + + return m_source_model->getPath(source_index); + } + + ModelIndex FileSystemModelSortFilterProxy::getParent(const ModelIndex &index) const { + if (!m_source_model) { + return ModelIndex(); + } + + ModelIndex &&source_index = toSourceIndex(index); + if (!source_index.isValid()) { + return ModelIndex(); + } + + return toProxyIndex(m_source_model->getParent(source_index)); + } + + ModelIndex FileSystemModelSortFilterProxy::getSibling(int64_t row, int64_t column, + const ModelIndex &index) const { + if (!m_source_model) { + return ModelIndex(); + } + + ModelIndex &&source_index = toSourceIndex(index); + if (!source_index.isValid()) { + return ModelIndex(); + } + + return toProxyIndex(m_source_model->getSibling(row, column, source_index)); + } + + size_t FileSystemModelSortFilterProxy::getColumnCount(const ModelIndex &index) const { + if (!m_source_model) { + return 0; + } + + ModelIndex &&source_index = toSourceIndex(index); + if (!source_index.isValid()) { + return 0; + } + + return m_source_model->getColumnCount(source_index); + } + + size_t FileSystemModelSortFilterProxy::getRowCount(const ModelIndex &index) const { + if (!m_source_model) { + return 0; + } + + ModelIndex &&source_index = toSourceIndex(index); + if (!source_index.isValid()) { + return 0; + } + + return m_source_model->getRowCount(source_index); + } + + bool FileSystemModelSortFilterProxy::hasChildren(const ModelIndex &parent) const { + if (!m_source_model) { + return false; + } + + ModelIndex &&source_index = toSourceIndex(parent); + if (!source_index.isValid()) { + return false; + } + + return m_source_model->hasChildren(source_index); + } + + ScopePtr + FileSystemModelSortFilterProxy::createMimeData(const std::vector &indexes) const { + if (!m_source_model) { + return ScopePtr(); + } + + std::vector indexes_copy = indexes; + std::transform(indexes.begin(), indexes.end(), indexes_copy.begin(), + [&](const ModelIndex &index) { return toSourceIndex(index); }); + + return m_source_model->createMimeData(indexes); + } + + std::vector FileSystemModelSortFilterProxy::getSupportedMimeTypes() const { + if (!m_source_model) { + return std::vector(); + } + return m_source_model->getSupportedMimeTypes(); + } + + bool FileSystemModelSortFilterProxy::canFetchMore(const ModelIndex &index) { + if (!m_source_model) { + return false; + } + + ModelIndex &&source_index = toSourceIndex(index); + if (!source_index.isValid()) { + return false; + } + + return m_source_model->canFetchMore(source_index); + } + + void FileSystemModelSortFilterProxy::fetchMore(const ModelIndex &index) { + if (!m_source_model) { + return; + } + + ModelIndex &&source_index = toSourceIndex(index); + if (!source_index.isValid()) { + return; + } + + m_source_model->fetchMore(source_index); + } + + bool FileSystemModelSortFilterProxy::validateIndex(const ModelIndex &index) const { + return index.isValid() && index.getModelUUID() == getUUID(); + } + + ModelIndex FileSystemModelSortFilterProxy::toSourceIndex(const ModelIndex &index) const { + if (!m_source_model) { + return ModelIndex(); + } + + if (m_source_model->validateIndex(index)) { + return index; + } + + if (!validateIndex(index)) { + return ModelIndex(); + } + + return m_source_model->getIndex(index.data<_FileSystemIndexData>()->m_path); + } + + ModelIndex FileSystemModelSortFilterProxy::toProxyIndex(const ModelIndex &index) const { + if (!m_source_model) { + return ModelIndex(); + } + + if (validateIndex(index)) { + return index; + } + + if (!m_source_model->validateIndex(index)) { + return ModelIndex(); + } + + const ModelIndex &parent = m_source_model->getParent(index); + if (!m_source_model->validateIndex(parent)) { + ModelIndex proxy_index = ModelIndex(getUUID()); + proxy_index.setData(index.data<_FileSystemIndexData>()); + return proxy_index; + } + + std::vector children = parent.data<_FileSystemIndexData>()->m_children; + std::copy_if(children.begin(), children.end(), children.begin(), [&](const UUID64 &uuid) { + ModelIndex child_index = m_source_model->getIndex(uuid); + if (!child_index.isValid()) { + return false; + } + + if (m_dirs_only && m_source_model->isFile(child_index)) { + return false; + } + + fs_path path = child_index.data<_FileSystemIndexData>()->m_path; + return path.filename().string().starts_with(m_filter); + }); + + switch (m_sort_role) { + case ModelSortRole::SORT_ROLE_NAME: { + std::sort(children.begin(), children.end(), [&](const UUID64 &lhs, const UUID64 &rhs) { + return _FileSystemIndexDataCompareByName( + *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), + *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), m_sort_order); + }); + break; + } + case ModelSortRole::SORT_ROLE_SIZE: { + std::sort(children.begin(), children.end(), [&](const UUID64 &lhs, const UUID64 &rhs) { + return _FileSystemIndexDataCompareBySize( + *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), + *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), m_sort_order); + }); + break; + } + case ModelSortRole::SORT_ROLE_DATE: + std::sort(children.begin(), children.end(), [&](const UUID64 &lhs, const UUID64 &rhs) { + return _FileSystemIndexDataCompareByDate( + *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), + *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), m_sort_order); + }); + break; + default: + break; + } + + for (size_t i = 0; i < children.size(); i++) { + if (children[i] == index.getUUID()) { + ModelIndex proxy_index = ModelIndex(getUUID()); + proxy_index.setData(index.data<_FileSystemIndexData>()); + return proxy_index; + } + } + + // Should never reach here + return ModelIndex(); + } + +} // namespace Toolbox \ No newline at end of file From 714f99f2a56b67889e9cda4ccbd091372b65af69 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Tue, 10 Sep 2024 08:02:19 -0500 Subject: [PATCH 008/129] Push more progress --- include/model/fsmodel.hpp | 122 +++++++----------- include/model/model.hpp | 118 ++++++++++++++++++ src/gui/project/asset.cpp | 4 +- src/gui/project/window.cpp | 11 +- src/model/fsmodel.cpp | 248 ++++++++++++++++++++----------------- 5 files changed, 309 insertions(+), 194 deletions(-) create mode 100644 include/model/model.hpp diff --git a/include/model/fsmodel.hpp b/include/model/fsmodel.hpp index ae3dbefc..99b4d069 100644 --- a/include/model/fsmodel.hpp +++ b/include/model/fsmodel.hpp @@ -13,60 +13,18 @@ #include "core/types.hpp" #include "fsystem.hpp" #include "image/imagehandle.hpp" +#include "model/model.hpp" #include "unique.hpp" namespace Toolbox { - enum class ModelSortOrder { - SORT_ASCENDING, - SORT_DESCENDING, - }; - - enum class ModelSortRole { + enum class FileSystemModelSortRole { SORT_ROLE_NONE, SORT_ROLE_NAME, SORT_ROLE_SIZE, SORT_ROLE_DATE, }; - class ModelIndex : public IUnique { - public: - ModelIndex() = default; - ModelIndex(UUID64 model_uuid) : m_model_uuid(model_uuid) {} - ModelIndex(const ModelIndex &other) - : m_uuid(other.m_uuid), m_model_uuid(other.m_model_uuid), - m_user_data(other.m_user_data) {} - - bool isValid() const { return m_model_uuid != 0; } - - template [[nodiscard]] T *data() const { - return reinterpret_cast(m_user_data); - } - void setData(void *data) { m_user_data = data; } - - [[nodiscard]] UUID64 getUUID() const override { return m_uuid; } - [[nodiscard]] UUID64 getModelUUID() const { return m_model_uuid; } - - operator bool() const { return isValid(); } - - ModelIndex &operator=(const ModelIndex &other) { - m_uuid = other.m_uuid; - m_model_uuid = other.m_model_uuid; - m_user_data = other.m_user_data; - return *this; - } - - [[nodiscard]] bool operator==(const ModelIndex &other) const { - return m_uuid == other.m_uuid && m_model_uuid == other.m_model_uuid; - } - - private: - UUID64 m_uuid; - UUID64 m_model_uuid = 0; - - void *m_user_data = nullptr; - }; - enum class FileSystemModelOptions { NONE = 0, DISABLE_WATCHDOG = BIT(0), @@ -74,7 +32,13 @@ namespace Toolbox { }; TOOLBOX_BITWISE_ENUM(FileSystemModelOptions) - class FileSystemModel : public IUnique { + enum FileSystemDataRole { + FS_DATA_ROLE_DATE = ModelDataRole::DATA_ROLE_USER, + FS_DATA_ROLE_STATUS, + FS_DATA_ROLE_TYPE, + }; + + class FileSystemModel : public IDataModel { public: struct FSTypeInfo { std::string m_name; @@ -87,8 +51,6 @@ namespace Toolbox { [[nodiscard]] UUID64 getUUID() const override { return m_uuid; } - [[nodiscard]] bool validateIndex(const ModelIndex &index) const; - [[nodiscard]] const fs_path &getRoot() const &; void setRoot(const fs_path &path); @@ -102,14 +64,24 @@ namespace Toolbox { [[nodiscard]] bool isFile(const ModelIndex &index) const; [[nodiscard]] bool isArchive(const ModelIndex &index) const; - [[nodiscard]] size_t getFileSize(const ModelIndex &index); - [[nodiscard]] size_t getDirSize(const ModelIndex &index, bool recursive); + [[nodiscard]] size_t getFileSize(const ModelIndex &index) const; + [[nodiscard]] size_t getDirSize(const ModelIndex &index, bool recursive) const; - [[nodiscard]] const ImageHandle &getIcon(const ModelIndex &index) const &; - [[nodiscard]] Filesystem::file_time_type getLastModified(const ModelIndex &index) const; - [[nodiscard]] Filesystem::file_status getStatus(const ModelIndex &index) const; + [[nodiscard]] Filesystem::file_time_type getLastModified(const ModelIndex &index) const { + return std::any_cast( + getData(index, FileSystemDataRole::FS_DATA_ROLE_DATE)); + } + [[nodiscard]] Filesystem::file_status getStatus(const ModelIndex &index) const { + return std::any_cast( + getData(index, FileSystemDataRole::FS_DATA_ROLE_STATUS)); + } - [[nodiscard]] std::string getType(const ModelIndex &index) const &; + [[nodiscard]] std::string getType(const ModelIndex &index) const { + return std::any_cast( + getData(index, FileSystemDataRole::FS_DATA_ROLE_TYPE)); + } + + [[nodiscard]] std::any getData(const ModelIndex &index, int role) const override; ModelIndex mkdir(const ModelIndex &parent, const std::string &name); ModelIndex touch(const ModelIndex &parent, const std::string &name); @@ -119,32 +91,32 @@ namespace Toolbox { public: [[nodiscard]] ModelIndex getIndex(const fs_path &path) const; - [[nodiscard]] ModelIndex getIndex(const UUID64 &path) const; + [[nodiscard]] ModelIndex getIndex(const UUID64 &path) const override; [[nodiscard]] ModelIndex getIndex(int64_t row, int64_t column, - const ModelIndex &parent = ModelIndex()) const; + const ModelIndex &parent = ModelIndex()) const override; [[nodiscard]] fs_path getPath(const ModelIndex &index) const; - [[nodiscard]] ModelIndex getParent(const ModelIndex &index) const; + [[nodiscard]] ModelIndex getParent(const ModelIndex &index) const override; [[nodiscard]] ModelIndex getSibling(int64_t row, int64_t column, - const ModelIndex &index) const; + const ModelIndex &index) const override; - [[nodiscard]] size_t getColumnCount(const ModelIndex &index) const; - [[nodiscard]] size_t getRowCount(const ModelIndex &index) const; + [[nodiscard]] size_t getColumnCount(const ModelIndex &index) const override; + [[nodiscard]] size_t getRowCount(const ModelIndex &index) const override; - [[nodiscard]] bool hasChildren(const ModelIndex &parent = ModelIndex()) const; + [[nodiscard]] bool hasChildren(const ModelIndex &parent = ModelIndex()) const override; [[nodiscard]] ScopePtr - createMimeData(const std::vector &indexes) const; - [[nodiscard]] std::vector getSupportedMimeTypes() const; + createMimeData(const std::vector &indexes) const override; + [[nodiscard]] std::vector getSupportedMimeTypes() const override; - [[nodiscard]] bool canFetchMore(const ModelIndex &index); - void fetchMore(const ModelIndex &index); + [[nodiscard]] bool canFetchMore(const ModelIndex &index) override; + void fetchMore(const ModelIndex &index) override; static const ImageHandle &InvalidIcon(); static const std::unordered_map &TypeMap(); protected: - ModelIndex makeIndex(const fs_path &path, int64_t row, const ModelIndex &parent); + ModelIndex makeIndex(const fs_path &path, int64_t row, const ModelIndex &parent) override; void cacheIndex(ModelIndex &index); void cacheFolder(ModelIndex &index); @@ -168,17 +140,15 @@ namespace Toolbox { mutable std::unordered_map m_index_map; }; - class FileSystemModelSortFilterProxy : public IUnique { + class FileSystemModelSortFilterProxy : public IDataModel { public: FileSystemModelSortFilterProxy() = default; ~FileSystemModelSortFilterProxy() = default; [[nodiscard]] UUID64 getUUID() const override { return m_uuid; } - [[nodiscard]] bool validateIndex(const ModelIndex &index) const; - [[nodiscard]] bool isDirsOnly() const { return m_dirs_only; } - void setDirsOnly(bool dirs_only) { m_dirs_only = true; } + void setDirsOnly(bool dirs_only) { m_dirs_only = dirs_only; } [[nodiscard]] RefPtr getSourceModel() const; void setSourceModel(RefPtr model); @@ -186,8 +156,8 @@ namespace Toolbox { [[nodiscard]] ModelSortOrder getSortOrder() const; void setSortOrder(ModelSortOrder order); - [[nodiscard]] ModelSortRole getSortRole() const; - void setSortRole(ModelSortRole role); + [[nodiscard]] FileSystemModelSortRole getSortRole() const; + void setSortRole(FileSystemModelSortRole role); [[nodiscard]] const std::string &getFilter() const &; void setFilter(const std::string &filter); @@ -202,11 +172,11 @@ namespace Toolbox { [[nodiscard]] size_t getFileSize(const ModelIndex &index); [[nodiscard]] size_t getDirSize(const ModelIndex &index, bool recursive); - [[nodiscard]] const ImageHandle &getIcon(const ModelIndex &index) const &; [[nodiscard]] Filesystem::file_time_type getLastModified(const ModelIndex &index) const; [[nodiscard]] Filesystem::file_status getStatus(const ModelIndex &index) const; - [[nodiscard]] std::string getType(const ModelIndex &index) const &; + [[nodiscard]] std::string getType(const ModelIndex &index) const; + [[nodiscard]] std::any getData(const ModelIndex &index, int role) const override; ModelIndex mkdir(const ModelIndex &parent, const std::string &name); ModelIndex touch(const ModelIndex &parent, const std::string &name); @@ -240,12 +210,16 @@ namespace Toolbox { [[nodiscard]] ModelIndex toSourceIndex(const ModelIndex &index) const; [[nodiscard]] ModelIndex toProxyIndex(const ModelIndex &index) const; + ModelIndex makeIndex(const fs_path &path, int64_t row, const ModelIndex &parent) { + return ModelIndex(); + } + private: UUID64 m_uuid; RefPtr m_source_model = nullptr; ModelSortOrder m_sort_order = ModelSortOrder::SORT_ASCENDING; - ModelSortRole m_sort_role = ModelSortRole::SORT_ROLE_NONE; + FileSystemModelSortRole m_sort_role = FileSystemModelSortRole::SORT_ROLE_NONE; std::string m_filter = ""; bool m_dirs_only = false; diff --git a/include/model/model.hpp b/include/model/model.hpp new file mode 100644 index 00000000..c5d71059 --- /dev/null +++ b/include/model/model.hpp @@ -0,0 +1,118 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "core/mimedata/mimedata.hpp" +#include "core/types.hpp" +#include "fsystem.hpp" +#include "image/imagehandle.hpp" +#include "unique.hpp" + +namespace Toolbox { + + enum ModelSortOrder { + SORT_ASCENDING, + SORT_DESCENDING, + }; + + enum ModelDataRole { + DATA_ROLE_NONE, + DATA_ROLE_DISPLAY, + DATA_ROLE_TOOLTIP, + DATA_ROLE_DECORATION, + DATA_ROLE_USER, + }; + + class ModelIndex final : public IUnique { + public: + ModelIndex() = default; + ModelIndex(UUID64 model_uuid) : m_model_uuid(model_uuid) {} + ModelIndex(const ModelIndex &other) + : m_uuid(other.m_uuid), m_model_uuid(other.m_model_uuid), + m_user_data(other.m_user_data) {} + + bool isValid() const { return m_model_uuid != 0; } + + template [[nodiscard]] T *data() const { + return reinterpret_cast(m_user_data); + } + void setData(void *data) { m_user_data = data; } + + [[nodiscard]] UUID64 getUUID() const override { return m_uuid; } + [[nodiscard]] UUID64 getModelUUID() const { return m_model_uuid; } + + operator bool() const { return isValid(); } + + ModelIndex &operator=(const ModelIndex &other) { + m_uuid = other.m_uuid; + m_model_uuid = other.m_model_uuid; + m_user_data = other.m_user_data; + return *this; + } + + [[nodiscard]] bool operator==(const ModelIndex &other) const { + return m_uuid == other.m_uuid && m_model_uuid == other.m_model_uuid; + } + + private: + UUID64 m_uuid; + UUID64 m_model_uuid = 0; + + void *m_user_data = nullptr; + }; + + class IDataModel : public IUnique { + public: + [[nodiscard]] virtual bool validateIndex(const ModelIndex &index) const { + return index.isValid() && index.getModelUUID() == getUUID(); + } + + [[nodiscard]] virtual std::string getDisplayText(const ModelIndex &index) const { + return std::any_cast(getData(index, ModelDataRole::DATA_ROLE_DISPLAY)); + } + + [[nodiscard]] virtual std::string getToolTip(const ModelIndex &index) const { + return std::any_cast(getData(index, ModelDataRole::DATA_ROLE_TOOLTIP)); + } + + [[nodiscard]] virtual ImageHandle getDecoration(const ModelIndex &index) const { + return std::any_cast(getData(index, ModelDataRole::DATA_ROLE_DECORATION)); + } + + [[nodiscard]] virtual std::any getData(const ModelIndex &index, int role) const = 0; + + [[nodiscard]] virtual ModelIndex getIndex(const UUID64 &path) const = 0; + [[nodiscard]] virtual ModelIndex + getIndex(int64_t row, int64_t column, const ModelIndex &parent = ModelIndex()) const = 0; + + [[nodiscard]] virtual ModelIndex getParent(const ModelIndex &index) const = 0; + [[nodiscard]] virtual ModelIndex getSibling(int64_t row, int64_t column, + const ModelIndex &index) const = 0; + + [[nodiscard]] virtual size_t getColumnCount(const ModelIndex &index) const = 0; + [[nodiscard]] virtual size_t getRowCount(const ModelIndex &index) const = 0; + + [[nodiscard]] virtual bool hasChildren(const ModelIndex &parent = ModelIndex()) const = 0; + + [[nodiscard]] virtual ScopePtr + createMimeData(const std::vector &indexes) const = 0; + [[nodiscard]] virtual std::vector getSupportedMimeTypes() const = 0; + + [[nodiscard]] virtual bool canFetchMore(const ModelIndex &index) = 0; + virtual void fetchMore(const ModelIndex &index) = 0; + + protected: + virtual ModelIndex makeIndex(const fs_path &path, int64_t row, + const ModelIndex &parent) = 0; + }; + +} // namespace Toolbox \ No newline at end of file diff --git a/src/gui/project/asset.cpp b/src/gui/project/asset.cpp index b991fa93..403ef6ee 100644 --- a/src/gui/project/asset.cpp +++ b/src/gui/project/asset.cpp @@ -11,8 +11,8 @@ namespace Toolbox::UI { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, {3, 3}); if (m_model) { - m_painter.render(m_model->getIcon(m_index)); - ImGui::Text("%s", m_model->getPath(m_index).c_str()); + m_painter.render(m_model->getDecoration(m_index)); + ImGui::Text("%s", m_model->getDisplayText(m_index).c_str()); } ImGui::PopStyleVar(); diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 12df64b7..cc1a3d0f 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -33,7 +33,7 @@ namespace Toolbox::UI { return; } - if (ImGui::BeginChild("Folder View", { 400, 0 }, true, + if (ImGui::BeginChild("Folder View", {400, 0}, true, ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { if (m_view_proxy.hasChildren(m_view_index)) { if (m_view_proxy.canFetchMore(m_view_index)) { @@ -45,13 +45,12 @@ namespace Toolbox::UI { if (ImGui::BeginChild(child_index.getUUID(), {160, 180}, true, ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { - const ImageHandle &icon = m_view_proxy.getIcon(child_index); + const ImageHandle &icon = m_view_proxy.getDecoration(child_index); m_icon_painter.render(icon, {140, 140}); ImGui::RenderTextEllipsis( ImGui::GetWindowDrawList(), {10, 150}, {130, 170}, 120.0f, 150.0f, - m_view_proxy.getPath(child_index).filename().string().c_str(), nullptr, - nullptr); + m_view_proxy.getDisplayText(child_index).c_str(), nullptr, nullptr); } ImGui::EndChild(); } @@ -87,7 +86,9 @@ namespace Toolbox::UI { if (is_open) { for (size_t i = 0; i < m_tree_proxy.getRowCount(index); ++i) { ModelIndex child_index = m_tree_proxy.getIndex(i, 0, index); - renderFolderTree(child_index); + if (m_tree_proxy.validateIndex(child_index)) { + renderFolderTree(child_index); + } } ImGui::TreePop(); } diff --git a/src/model/fsmodel.cpp b/src/model/fsmodel.cpp index fe1ba839..6d811dea 100644 --- a/src/model/fsmodel.cpp +++ b/src/model/fsmodel.cpp @@ -147,110 +147,124 @@ namespace Toolbox { return index.data<_FileSystemIndexData>()->m_type == _FileSystemIndexData::Type::ARCHIVE; } - size_t FileSystemModel::getFileSize(const ModelIndex &index) { + size_t FileSystemModel::getFileSize(const ModelIndex &index) const { if (!isFile(index)) { return 0; } return index.data<_FileSystemIndexData>()->m_size; } - size_t FileSystemModel::getDirSize(const ModelIndex &index, bool recursive) { + size_t FileSystemModel::getDirSize(const ModelIndex &index, bool recursive) const { if (!(isDirectory(index) || isArchive(index))) { return 0; } return index.data<_FileSystemIndexData>()->m_size; } - const ImageHandle &FileSystemModel::getIcon(const ModelIndex &index) const & { + std::any FileSystemModel::getData(const ModelIndex &index, int role) const { if (!validateIndex(index)) { - return TypeMap().at("_Invalid").m_icon; + return {}; } - if (isDirectory(index)) { - return TypeMap().at("_Folder").m_icon; - } + switch (role) { + case ModelDataRole::DATA_ROLE_DISPLAY: + if (!validateIndex(index)) { + return "Invalid"; + } + return index.data<_FileSystemIndexData>()->m_path.filename().string(); + case ModelDataRole::DATA_ROLE_TOOLTIP: + return "Tooltip unimplemented!"; + case ModelDataRole::DATA_ROLE_DECORATION: { + if (!validateIndex(index)) { + return TypeMap().at("_Invalid").m_icon; + } - if (isArchive(index)) { - return TypeMap().at("_Archive").m_icon; - } + if (isDirectory(index)) { + return TypeMap().at("_Folder").m_icon; + } - std::string ext = index.data<_FileSystemIndexData>()->m_path.extension().string(); - if (ext.empty()) { - return TypeMap().at("_Folder").m_icon; - } + if (isArchive(index)) { + return TypeMap().at("_Archive").m_icon; + } - if (TypeMap().find(ext) == TypeMap().end()) { - return TypeMap().at("_File").m_icon; - } + std::string ext = index.data<_FileSystemIndexData>()->m_path.extension().string(); + if (ext.empty()) { + return TypeMap().at("_Folder").m_icon; + } - return TypeMap().at(ext).m_icon; - } + if (TypeMap().find(ext) == TypeMap().end()) { + return TypeMap().at("_File").m_icon; + } - Filesystem::file_time_type FileSystemModel::getLastModified(const ModelIndex &index) const { - if (!validateIndex(index)) { - return Filesystem::file_time_type(); + return TypeMap().at(ext).m_icon; } + case FileSystemDataRole::FS_DATA_ROLE_DATE: { + if (!validateIndex(index)) { + return Filesystem::file_time_type(); + } - Filesystem::file_time_type result = Filesystem::file_time_type(); + Filesystem::file_time_type result = Filesystem::file_time_type(); - Filesystem::last_write_time(index.data<_FileSystemIndexData>()->m_path) - .and_then([&](Filesystem::file_time_type &&time) { - result = std::move(time); - return Result(); - }) - .or_else([&](const FSError &error) { - TOOLBOX_ERROR_V("[FileSystemModel] Failed to get last write time: {}", - error.m_message[0]); - return Result(); - }); - - return result; - } + Filesystem::last_write_time(index.data<_FileSystemIndexData>()->m_path) + .and_then([&](Filesystem::file_time_type &&time) { + result = std::move(time); + return Result(); + }) + .or_else([&](const FSError &error) { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to get last write time: {}", + error.m_message[0]); + return Result(); + }); - Filesystem::file_status FileSystemModel::getStatus(const ModelIndex &index) const { - if (!validateIndex(index)) { - return Filesystem::file_status(); + return result; } + case FileSystemDataRole::FS_DATA_ROLE_STATUS: { + if (!validateIndex(index)) { + return Filesystem::file_status(); + } - Filesystem::file_status result = Filesystem::file_status(); - - Filesystem::status(index.data<_FileSystemIndexData>()->m_path) - .and_then([&](Filesystem::file_status &&status) { - result = std::move(status); - return Result(); - }) - .or_else([&](const FSError &error) { - TOOLBOX_ERROR_V("[FileSystemModel] Failed to get last write status: {}", - error.m_message[0]); - return Result(); - }); + Filesystem::file_status result = Filesystem::file_status(); - return result; - } + Filesystem::status(index.data<_FileSystemIndexData>()->m_path) + .and_then([&](Filesystem::file_status &&status) { + result = std::move(status); + return Result(); + }) + .or_else([&](const FSError &error) { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to get last write status: {}", + error.m_message[0]); + return Result(); + }); - std::string FileSystemModel::getType(const ModelIndex &index) const & { - if (!validateIndex(index)) { - return TypeMap().at("_Invalid").m_name; + return result; } + case FileSystemDataRole::FS_DATA_ROLE_TYPE: { + if (!validateIndex(index)) { + return TypeMap().at("_Invalid").m_name; + } - if (isDirectory(index)) { - return TypeMap().at("_Folder").m_name; - } + if (isDirectory(index)) { + return TypeMap().at("_Folder").m_name; + } - if (isArchive(index)) { - return TypeMap().at("_Archive").m_name; - } + if (isArchive(index)) { + return TypeMap().at("_Archive").m_name; + } - std::string ext = index.data<_FileSystemIndexData>()->m_path.extension().string(); - if (ext.empty()) { - return TypeMap().at("_Folder").m_name; - } + std::string ext = index.data<_FileSystemIndexData>()->m_path.extension().string(); + if (ext.empty()) { + return TypeMap().at("_Folder").m_name; + } - if (TypeMap().find(ext) == TypeMap().end()) { - return TypeMap().at("_File").m_name; - } + if (TypeMap().find(ext) == TypeMap().end()) { + return TypeMap().at("_File").m_name; + } - return TypeMap().at(ext).m_name; + return TypeMap().at(ext).m_name; + } + default: + return std::any(); + } } ModelIndex FileSystemModel::mkdir(const ModelIndex &parent, const std::string &name) { @@ -591,10 +605,6 @@ namespace Toolbox { return s_type_map; } - bool FileSystemModel::validateIndex(const ModelIndex &index) const { - return index.isValid() && index.getModelUUID() == getUUID(); - } - ModelIndex FileSystemModel::makeIndex(const fs_path &path, int64_t row, const ModelIndex &parent) { _FileSystemIndexData *parent_data = nullptr; @@ -717,8 +727,12 @@ namespace Toolbox { m_sort_order = order; } - ModelSortRole FileSystemModelSortFilterProxy::getSortRole() const { return m_sort_role; } - void FileSystemModelSortFilterProxy::setSortRole(ModelSortRole role) { m_sort_role = role; } + FileSystemModelSortRole FileSystemModelSortFilterProxy::getSortRole() const { + return m_sort_role; + } + void FileSystemModelSortFilterProxy::setSortRole(FileSystemModelSortRole role) { + m_sort_role = role; + } const std::string &FileSystemModelSortFilterProxy::getFilter() const & { return m_filter; } void FileSystemModelSortFilterProxy::setFilter(const std::string &filter) { m_filter = filter; } @@ -782,15 +796,6 @@ namespace Toolbox { return m_source_model->getDirSize(source_index, recursive); } - const ImageHandle &FileSystemModelSortFilterProxy::getIcon(const ModelIndex &index) const & { - if (!m_source_model) { - return FileSystemModel::InvalidIcon(); - } - - ModelIndex &&source_index = toSourceIndex(index); - return m_source_model->getIcon(source_index); - } - Filesystem::file_time_type FileSystemModelSortFilterProxy::getLastModified(const ModelIndex &index) const { if (!m_source_model) { @@ -811,7 +816,7 @@ namespace Toolbox { return m_source_model->getStatus(source_index); } - std::string FileSystemModelSortFilterProxy::getType(const ModelIndex &index) const & { + std::string FileSystemModelSortFilterProxy::getType(const ModelIndex &index) const { if (!m_source_model) { return "Invalid"; } @@ -820,6 +825,15 @@ namespace Toolbox { return m_source_model->getType(source_index); } + std::any FileSystemModelSortFilterProxy::getData(const ModelIndex &index, int role) const { + if (!m_source_model) { + return std::any(); + } + + ModelIndex &&source_index = toSourceIndex(index); + return m_source_model->getData(source_index, role); + } + ModelIndex FileSystemModelSortFilterProxy::mkdir(const ModelIndex &parent, const std::string &name) { if (!m_source_model) { @@ -1013,10 +1027,6 @@ namespace Toolbox { m_source_model->fetchMore(source_index); } - bool FileSystemModelSortFilterProxy::validateIndex(const ModelIndex &index) const { - return index.isValid() && index.getModelUUID() == getUUID(); - } - ModelIndex FileSystemModelSortFilterProxy::toSourceIndex(const ModelIndex &index) const { if (!m_source_model) { return ModelIndex(); @@ -1053,14 +1063,20 @@ namespace Toolbox { return proxy_index; } - std::vector children = parent.data<_FileSystemIndexData>()->m_children; - std::copy_if(children.begin(), children.end(), children.begin(), [&](const UUID64 &uuid) { + const std::vector &children = parent.data<_FileSystemIndexData>()->m_children; + if (children.empty()) { + return ModelIndex(); + } + + std::vector filtered_children(children.size()); + std::copy_if(children.begin(), children.end(), filtered_children.begin(), + [&](const UUID64 &uuid) { ModelIndex child_index = m_source_model->getIndex(uuid); if (!child_index.isValid()) { return false; } - if (m_dirs_only && m_source_model->isFile(child_index)) { + if (isDirsOnly() && m_source_model->isFile(child_index)) { return false; } @@ -1069,35 +1085,41 @@ namespace Toolbox { }); switch (m_sort_role) { - case ModelSortRole::SORT_ROLE_NAME: { - std::sort(children.begin(), children.end(), [&](const UUID64 &lhs, const UUID64 &rhs) { - return _FileSystemIndexDataCompareByName( - *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), - *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), m_sort_order); - }); + case FileSystemModelSortRole::SORT_ROLE_NAME: { + std::sort(filtered_children.begin(), filtered_children.end(), + [&](const UUID64 &lhs, const UUID64 &rhs) { + return _FileSystemIndexDataCompareByName( + *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), + *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), + m_sort_order); + }); break; } - case ModelSortRole::SORT_ROLE_SIZE: { - std::sort(children.begin(), children.end(), [&](const UUID64 &lhs, const UUID64 &rhs) { - return _FileSystemIndexDataCompareBySize( - *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), - *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), m_sort_order); - }); + case FileSystemModelSortRole::SORT_ROLE_SIZE: { + std::sort(filtered_children.begin(), filtered_children.end(), + [&](const UUID64 &lhs, const UUID64 &rhs) { + return _FileSystemIndexDataCompareBySize( + *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), + *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), + m_sort_order); + }); break; } - case ModelSortRole::SORT_ROLE_DATE: - std::sort(children.begin(), children.end(), [&](const UUID64 &lhs, const UUID64 &rhs) { - return _FileSystemIndexDataCompareByDate( - *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), - *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), m_sort_order); - }); + case FileSystemModelSortRole::SORT_ROLE_DATE: + std::sort(filtered_children.begin(), filtered_children.end(), + [&](const UUID64 &lhs, const UUID64 &rhs) { + return _FileSystemIndexDataCompareByDate( + *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), + *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), + m_sort_order); + }); break; default: break; } - for (size_t i = 0; i < children.size(); i++) { - if (children[i] == index.getUUID()) { + for (size_t i = 0; i < filtered_children.size(); i++) { + if (filtered_children[i] == index.getUUID()) { ModelIndex proxy_index = ModelIndex(getUUID()); proxy_index.setData(index.data<_FileSystemIndexData>()); return proxy_index; From fae73384cee3811f12f9c23d7420e8b6676638ef Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Wed, 11 Sep 2024 08:29:13 -0500 Subject: [PATCH 009/129] View works but has performance issues --- include/model/fsmodel.hpp | 4 +- include/model/model.hpp | 10 +- src/gui/image/imagepainter.cpp | 2 + src/gui/project/asset.cpp | 2 +- src/gui/project/window.cpp | 47 +++- src/image/imagehandle.cpp | 1 - src/model/fsmodel.cpp | 395 +++++++++++---------------------- 7 files changed, 177 insertions(+), 284 deletions(-) diff --git a/include/model/fsmodel.hpp b/include/model/fsmodel.hpp index 99b4d069..d35cd529 100644 --- a/include/model/fsmodel.hpp +++ b/include/model/fsmodel.hpp @@ -42,7 +42,7 @@ namespace Toolbox { public: struct FSTypeInfo { std::string m_name; - ImageHandle m_icon; + std::string m_image_name; }; public: @@ -210,6 +210,8 @@ namespace Toolbox { [[nodiscard]] ModelIndex toSourceIndex(const ModelIndex &index) const; [[nodiscard]] ModelIndex toProxyIndex(const ModelIndex &index) const; + [[nodiscard]] bool isFiltered(const UUID64 &uuid) const; + ModelIndex makeIndex(const fs_path &path, int64_t row, const ModelIndex &parent) { return ModelIndex(); } diff --git a/include/model/model.hpp b/include/model/model.hpp index c5d71059..3bc22f34 100644 --- a/include/model/model.hpp +++ b/include/model/model.hpp @@ -40,8 +40,6 @@ namespace Toolbox { : m_uuid(other.m_uuid), m_model_uuid(other.m_model_uuid), m_user_data(other.m_user_data) {} - bool isValid() const { return m_model_uuid != 0; } - template [[nodiscard]] T *data() const { return reinterpret_cast(m_user_data); } @@ -50,8 +48,6 @@ namespace Toolbox { [[nodiscard]] UUID64 getUUID() const override { return m_uuid; } [[nodiscard]] UUID64 getModelUUID() const { return m_model_uuid; } - operator bool() const { return isValid(); } - ModelIndex &operator=(const ModelIndex &other) { m_uuid = other.m_uuid; m_model_uuid = other.m_model_uuid; @@ -73,7 +69,7 @@ namespace Toolbox { class IDataModel : public IUnique { public: [[nodiscard]] virtual bool validateIndex(const ModelIndex &index) const { - return index.isValid() && index.getModelUUID() == getUUID(); + return index.getModelUUID() == getUUID(); } [[nodiscard]] virtual std::string getDisplayText(const ModelIndex &index) const { @@ -84,8 +80,8 @@ namespace Toolbox { return std::any_cast(getData(index, ModelDataRole::DATA_ROLE_TOOLTIP)); } - [[nodiscard]] virtual ImageHandle getDecoration(const ModelIndex &index) const { - return std::any_cast(getData(index, ModelDataRole::DATA_ROLE_DECORATION)); + [[nodiscard]] virtual RefPtr getDecoration(const ModelIndex &index) const { + return std::any_cast>(getData(index, ModelDataRole::DATA_ROLE_DECORATION)); } [[nodiscard]] virtual std::any getData(const ModelIndex &index, int role) const = 0; diff --git a/src/gui/image/imagepainter.cpp b/src/gui/image/imagepainter.cpp index 62df787c..dfb86a99 100644 --- a/src/gui/image/imagepainter.cpp +++ b/src/gui/image/imagepainter.cpp @@ -17,9 +17,11 @@ namespace Toolbox::UI { if (!image) { return false; } + ImVec2 orig_pos = ImGui::GetCursorScreenPos(); ImGui::SetCursorScreenPos(pos); ImGui::Image((ImTextureID)image.m_image_handle, size, m_uv0, m_uv1, m_tint_color, m_border_color); + ImGui::SetCursorScreenPos(orig_pos); return true; } diff --git a/src/gui/project/asset.cpp b/src/gui/project/asset.cpp index 403ef6ee..7a39201b 100644 --- a/src/gui/project/asset.cpp +++ b/src/gui/project/asset.cpp @@ -11,7 +11,7 @@ namespace Toolbox::UI { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, {3, 3}); if (m_model) { - m_painter.render(m_model->getDecoration(m_index)); + m_painter.render(*m_model->getDecoration(m_index)); ImGui::Text("%s", m_model->getDisplayText(m_index).c_str()); } diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index cc1a3d0f..87c3e890 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -2,6 +2,7 @@ #include "model/fsmodel.hpp" #include +#include namespace Toolbox::UI { @@ -20,7 +21,7 @@ namespace Toolbox::UI { } void ProjectViewWindow::renderProjectTreeView() { - if (ImGui::BeginChild("Tree View", {160, 0}, true, + if (ImGui::BeginChild("Tree View", {300, 0}, true, ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { ModelIndex index = m_tree_proxy.getIndex(0, 0); renderFolderTree(index); @@ -29,31 +30,61 @@ namespace Toolbox::UI { } void ProjectViewWindow::renderProjectFolderView() { - if (!m_view_index.isValid()) { + if (!m_view_proxy.validateIndex(m_view_index)) { return; } - if (ImGui::BeginChild("Folder View", {400, 0}, true, + if (ImGui::BeginChild("Folder View", {0, 0}, true, ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { if (m_view_proxy.hasChildren(m_view_index)) { if (m_view_proxy.canFetchMore(m_view_index)) { m_view_proxy.fetchMore(m_view_index); } + + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, {2, 2}); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f); + ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0.0f); + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, {2, 2}); + + ImVec2 size = ImGui::GetContentRegionAvail(); + + size_t x_count = (size_t)(size.x / 80); + if (x_count == 0) { + x_count = 1; + } + for (size_t i = 0; i < m_view_proxy.getRowCount(m_view_index); ++i) { ModelIndex child_index = m_view_proxy.getIndex(i, 0, m_view_index); - if (ImGui::BeginChild(child_index.getUUID(), {160, 180}, true, + if (ImGui::BeginChild(child_index.getUUID(), {76, 92}, true, ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { - const ImageHandle &icon = m_view_proxy.getDecoration(child_index); - m_icon_painter.render(icon, {140, 140}); + + m_icon_painter.render(*m_view_proxy.getDecoration(child_index), {72, 72}); + + std::string text = m_view_proxy.getDisplayText(child_index); + ImVec2 text_size = ImGui::CalcTextSize(text.c_str()); + + ImVec2 pos = ImGui::GetCursorScreenPos(); + pos.x += std::max(36.0f - (text_size.x / 2.0f), 0.0); + pos.y += 72.0f; + //pos.x += i * size.x / 4.0f; ImGui::RenderTextEllipsis( - ImGui::GetWindowDrawList(), {10, 150}, {130, 170}, 120.0f, 150.0f, - m_view_proxy.getDisplayText(child_index).c_str(), nullptr, nullptr); + ImGui::GetWindowDrawList(), pos, pos + ImVec2(72, 20), pos.x + 72.0f, + pos.x + 76.0f, m_view_proxy.getDisplayText(child_index).c_str(), + nullptr, nullptr); } ImGui::EndChild(); + + // ImGui::Text("%s", m_view_proxy.getDisplayText(child_index).c_str()); + + if ((i + 1) % x_count != 0) { + ImGui::SameLine(i * size.x / 4.0f); + } } + + ImGui::PopStyleVar(4); } } ImGui::EndChild(); diff --git a/src/image/imagehandle.cpp b/src/image/imagehandle.cpp index 1a3b1d4a..487e3041 100644 --- a/src/image/imagehandle.cpp +++ b/src/image/imagehandle.cpp @@ -118,7 +118,6 @@ namespace Toolbox { } void ImageHandle::moveGL(ImageHandle &&image) { - unloadGL(); m_image_handle = image.m_image_handle; m_image_format = image.m_image_format; m_image_width = image.m_image_width; diff --git a/src/model/fsmodel.cpp b/src/model/fsmodel.cpp index 6d811dea..389d4af9 100644 --- a/src/model/fsmodel.cpp +++ b/src/model/fsmodel.cpp @@ -2,6 +2,7 @@ #include #include +#include "gui/application.hpp" #include "model/fsmodel.hpp" namespace Toolbox { @@ -15,6 +16,7 @@ namespace Toolbox { }; UUID64 m_parent = 0; + UUID64 m_self_uuid = 0; std::vector m_children = {}; Type m_type = Type::UNKNOWN; @@ -22,6 +24,8 @@ namespace Toolbox { size_t m_size = 0; Filesystem::file_time_type m_date; + RefPtr m_icon = nullptr; + bool hasChild(UUID64 uuid) const { return std::find(m_children.begin(), m_children.end(), uuid) != m_children.end(); } @@ -166,6 +170,9 @@ namespace Toolbox { return {}; } + fs_path fs_icon_path = + GUIApplication::instance().getResourcePath("Images/Icons/Filesystem/"); + switch (role) { case ModelDataRole::DATA_ROLE_DISPLAY: if (!validateIndex(index)) { @@ -176,27 +183,9 @@ namespace Toolbox { return "Tooltip unimplemented!"; case ModelDataRole::DATA_ROLE_DECORATION: { if (!validateIndex(index)) { - return TypeMap().at("_Invalid").m_icon; - } - - if (isDirectory(index)) { - return TypeMap().at("_Folder").m_icon; + return RefPtr(nullptr); } - - if (isArchive(index)) { - return TypeMap().at("_Archive").m_icon; - } - - std::string ext = index.data<_FileSystemIndexData>()->m_path.extension().string(); - if (ext.empty()) { - return TypeMap().at("_Folder").m_icon; - } - - if (TypeMap().find(ext) == TypeMap().end()) { - return TypeMap().at("_File").m_icon; - } - - return TypeMap().at(ext).m_icon; + return index.data<_FileSystemIndexData>()->m_icon; } case FileSystemDataRole::FS_DATA_ROLE_DATE: { if (!validateIndex(index)) { @@ -516,6 +505,9 @@ namespace Toolbox { } bool FileSystemModel::hasChildren(const ModelIndex &parent) const { + if (getRowCount(parent) > 0) { + return true; + } return pollChildren(parent) > 0; } @@ -564,42 +556,42 @@ namespace Toolbox { const std::unordered_map &FileSystemModel::TypeMap() { // clang-format off static std::unordered_map s_type_map = { - {"_Invalid", FSTypeInfo("Invalid", ImageHandle("Images/Icons/Filesystem/fs_invalid.png"))}, - {"_Folder", FSTypeInfo("Folder", ImageHandle("Images/Icons/Filesystem/fs_generic_folder.png")) }, - {"_Archive", FSTypeInfo("Archive", ImageHandle("Images/Icons/Filesystem/fs_arc.png"))}, - {"_File", FSTypeInfo("File", ImageHandle("Images/Icons/Filesystem/fs_generic_file.png")) }, - {".txt", FSTypeInfo("Text", ImageHandle("Images/Icons/Filesystem/fs_txt.png")) }, - {".md", FSTypeInfo("Markdown", ImageHandle("Images/Icons/Filesystem/fs_md.png")) }, - {".c", FSTypeInfo("C", ImageHandle("Images/Icons/Filesystem/fs_c.png")) }, - {".h", FSTypeInfo("Header", ImageHandle("Images/Icons/Filesystem/fs_h.png")) }, - {".cpp", FSTypeInfo("C++", ImageHandle("Images/Icons/Filesystem/fs_cpp.png")) }, - {".hpp", FSTypeInfo("Header", ImageHandle("Images/Icons/Filesystem/fs_hpp.png")) }, - {".cxx", FSTypeInfo("C++", ImageHandle("Images/Icons/Filesystem/fs_cpp.png")) }, - {".hxx", FSTypeInfo("Header", ImageHandle("Images/Icons/Filesystem/fs_hpp.png")) }, - {".c++", FSTypeInfo("C++", ImageHandle("Images/Icons/Filesystem/fs_cpp.png")) }, - {".h++", FSTypeInfo("Header", ImageHandle("Images/Icons/Filesystem/fs_hpp.png")) }, - {".cc", FSTypeInfo("C++", ImageHandle("Images/Icons/Filesystem/fs_cpp.png")) }, - {".hh", FSTypeInfo("Header", ImageHandle("Images/Icons/Filesystem/fs_hpp.png")) }, - {".arc", FSTypeInfo("Archive", ImageHandle("Images/Icons/Filesystem/fs_arc.png")) }, - {".bas", FSTypeInfo("JAudio Sequence", ImageHandle("Images/Icons/Filesystem/fs_bas.png")) }, - {".bck", FSTypeInfo("J3D Bone Animation", ImageHandle("Images/Icons/Filesystem/fs_bck.png")) }, - {".bdl", FSTypeInfo("J3D Model Data", ImageHandle("Images/Icons/Filesystem/fs_bdl.png")) }, - {".blo", FSTypeInfo("J2D Screen Layout", ImageHandle("Images/Icons/Filesystem/fs_blo.png")) }, - {".bmd", FSTypeInfo("J3D Model Data", ImageHandle("Images/Icons/Filesystem/fs_bmd.png")) }, - {".bmg", FSTypeInfo("Message Data", ImageHandle("Images/Icons/Filesystem/fs_bmg.png")) }, - {".bmt", FSTypeInfo("J3D Material Table", ImageHandle("Images/Icons/Filesystem/fs_bmt.png")) }, - {".brk", FSTypeInfo("J3D Color Register Anim", ImageHandle("Images/Icons/Filesystem/fs_brk.png")) }, - {".bti", FSTypeInfo("J2D Texture Image", ImageHandle("Images/Icons/Filesystem/fs_bti.png")) }, - {".btk", FSTypeInfo("J2D Texture Animation", ImageHandle("Images/Icons/Filesystem/fs_btk.png")) }, - {".btp", FSTypeInfo("J2D Texture Pattern Anim", ImageHandle("Images/Icons/Filesystem/fs_btp.png")) }, - {".col", FSTypeInfo("SMS Collision Data", ImageHandle("Images/Icons/Filesystem/fs_col.png")) }, - {".jpa", FSTypeInfo("JParticle Data", ImageHandle("Images/Icons/Filesystem/fs_jpa.png")) }, - {".map", FSTypeInfo("Executable Symbol Map", ImageHandle("Images/Icons/Filesystem/fs_map.png")) }, - {".me", FSTypeInfo("Marked For Delete", ImageHandle("Images/Icons/Filesystem/fs_me.png")) }, - {".prm", FSTypeInfo("SMS Parameter Data", ImageHandle("Images/Icons/Filesystem/fs_prm.png")) }, - {".sb", FSTypeInfo("Sunscript", ImageHandle("Images/Icons/Filesystem/fs_sb.png")) }, - {".szs", FSTypeInfo("Yaz0 Compressed Data", ImageHandle("Images/Icons/Filesystem/fs_szs.png")) }, - {".thp", FSTypeInfo("DolphinOS Movie Data", ImageHandle("Images/Icons/Filesystem/fs_thp.png")) }, + {"_Invalid", FSTypeInfo("Invalid", "fs_invalid.png") }, + {"_Folder", FSTypeInfo("Folder", "fs_generic_folder.png")}, + {"_Archive", FSTypeInfo("Archive", "fs_arc.png") }, + {"_File", FSTypeInfo("File", "fs_generic_file.png") }, + {".txt", FSTypeInfo("Text", "fs_txt.png") }, + {".md", FSTypeInfo("Markdown", "fs_md.png") }, + {".c", FSTypeInfo("C", "fs_c.png") }, + {".h", FSTypeInfo("Header", "fs_h.png") }, + {".cpp", FSTypeInfo("C++", "fs_cpp.png") }, + {".hpp", FSTypeInfo("Header", "fs_hpp.png") }, + {".cxx", FSTypeInfo("C++", "fs_cpp.png") }, + {".hxx", FSTypeInfo("Header", "fs_hpp.png") }, + {".c++", FSTypeInfo("C++", "fs_cpp.png") }, + {".h++", FSTypeInfo("Header", "fs_hpp.png") }, + {".cc", FSTypeInfo("C++", "fs_cpp.png") }, + {".hh", FSTypeInfo("Header", "fs_hpp.png") }, + {".arc", FSTypeInfo("Archive", "fs_arc.png") }, + {".bas", FSTypeInfo("JAudio Sequence", "fs_bas.png") }, + {".bck", FSTypeInfo("J3D Bone Animation", "fs_bck.png") }, + {".bdl", FSTypeInfo("J3D Model Data", "fs_bdl.png") }, + {".blo", FSTypeInfo("J2D Screen Layout", "fs_blo.png") }, + {".bmd", FSTypeInfo("J3D Model Data", "fs_bmd.png") }, + {".bmg", FSTypeInfo("Message Data", "fs_bmg.png") }, + {".bmt", FSTypeInfo("J3D Material Table", "fs_bmt.png") }, + {".brk", FSTypeInfo("J3D Color Register Anim", "fs_brk.png") }, + {".bti", FSTypeInfo("J2D Texture Image", "fs_bti.png") }, + {".btk", FSTypeInfo("J2D Texture Animation", "fs_btk.png") }, + {".btp", FSTypeInfo("J2D Texture Pattern Anim", "fs_btp.png") }, + {".col", FSTypeInfo("SMS Collision Data", "fs_col.png") }, + {".jpa", FSTypeInfo("JParticle Data", "fs_jpa.png") }, + {".map", FSTypeInfo("Executable Symbol Map", "fs_map.png") }, + {".me", FSTypeInfo("Marked For Delete", "fs_me.png") }, + {".prm", FSTypeInfo("SMS Parameter Data", "fs_prm.png") }, + {".sb", FSTypeInfo("Sunscript", "fs_sb.png") }, + {".szs", FSTypeInfo("Yaz0 Compressed Data", "fs_szs.png") }, + {".thp", FSTypeInfo("DolphinOS Movie Data", "fs_thp.png") }, }; // clang-format on return s_type_map; @@ -652,6 +644,36 @@ namespace Toolbox { ModelIndex index = ModelIndex(getUUID()); + // Establish icon + { + fs_path fs_icon_path = + GUIApplication::instance().getResourcePath("Images/Icons/Filesystem/"); + + std::string ext = data->m_path.extension().string(); + + if (!validateIndex(index)) { + data->m_icon = make_referable( + fs_icon_path / TypeMap().at("_Invalid").m_image_name); + } else if (data->m_type == _FileSystemIndexData::Type::DIRECTORY) { + data->m_icon = make_referable( + fs_icon_path / TypeMap().at("_Folder").m_image_name); + } else if (data->m_type == _FileSystemIndexData::Type::ARCHIVE) { + data->m_icon = make_referable( + fs_icon_path / TypeMap().at("_Archive").m_image_name); + } else if (ext.empty()) { + data->m_icon = make_referable( + fs_icon_path / TypeMap().at("_Folder").m_image_name); + } else if (TypeMap().find(ext) == TypeMap().end()) { + data->m_icon = make_referable( + fs_icon_path / TypeMap().at("_File").m_image_name); + } else { + data->m_icon = make_referable(fs_icon_path / + TypeMap().at(ext).m_image_name); + } + } + + data->m_self_uuid = index.getUUID(); + if (!validateIndex(parent)) { index.setData(data); m_index_map[index.getUUID()] = std::move(index); @@ -737,156 +759,88 @@ namespace Toolbox { const std::string &FileSystemModelSortFilterProxy::getFilter() const & { return m_filter; } void FileSystemModelSortFilterProxy::setFilter(const std::string &filter) { m_filter = filter; } - bool FileSystemModelSortFilterProxy::isReadOnly() const { - if (!m_source_model) { - return true; - } - return m_source_model->isReadOnly(); - } + bool FileSystemModelSortFilterProxy::isReadOnly() const { return m_source_model->isReadOnly(); } void FileSystemModelSortFilterProxy::setReadOnly(bool read_only) { - if (!m_source_model) { - return; - } m_source_model->setReadOnly(read_only); } bool FileSystemModelSortFilterProxy::isDirectory(const ModelIndex &index) const { - if (!m_source_model) { - return false; - } - ModelIndex &&source_index = toSourceIndex(index); - return m_source_model->isDirectory(source_index); + return m_source_model->isDirectory(std::move(source_index)); } bool FileSystemModelSortFilterProxy::isFile(const ModelIndex &index) const { - if (!m_source_model) { - return false; - } - ModelIndex &&source_index = toSourceIndex(index); - return m_source_model->isFile(source_index); + return m_source_model->isFile(std::move(source_index)); } bool FileSystemModelSortFilterProxy::isArchive(const ModelIndex &index) const { - if (!m_source_model) { - return false; - } - ModelIndex &&source_index = toSourceIndex(index); - return m_source_model->isArchive(source_index); + return m_source_model->isArchive(std::move(source_index)); } size_t FileSystemModelSortFilterProxy::getFileSize(const ModelIndex &index) { - if (!m_source_model) { - return 0; - } - ModelIndex &&source_index = toSourceIndex(index); - return m_source_model->getFileSize(source_index); + return m_source_model->getFileSize(std::move(source_index)); } size_t FileSystemModelSortFilterProxy::getDirSize(const ModelIndex &index, bool recursive) { - if (!m_source_model) { - return 0; - } - ModelIndex &&source_index = toSourceIndex(index); - return m_source_model->getDirSize(source_index, recursive); + return m_source_model->getDirSize(std::move(source_index), recursive); } Filesystem::file_time_type FileSystemModelSortFilterProxy::getLastModified(const ModelIndex &index) const { - if (!m_source_model) { - return Filesystem::file_time_type(); - } - ModelIndex &&source_index = toSourceIndex(index); - return m_source_model->getLastModified(source_index); + return m_source_model->getLastModified(std::move(source_index)); } Filesystem::file_status FileSystemModelSortFilterProxy::getStatus(const ModelIndex &index) const { - if (!m_source_model) { - return Filesystem::file_status(); - } - ModelIndex &&source_index = toSourceIndex(index); - return m_source_model->getStatus(source_index); + return m_source_model->getStatus(std::move(source_index)); } std::string FileSystemModelSortFilterProxy::getType(const ModelIndex &index) const { - if (!m_source_model) { - return "Invalid"; - } - ModelIndex &&source_index = toSourceIndex(index); - return m_source_model->getType(source_index); + return m_source_model->getType(std::move(source_index)); } std::any FileSystemModelSortFilterProxy::getData(const ModelIndex &index, int role) const { - if (!m_source_model) { - return std::any(); - } - ModelIndex &&source_index = toSourceIndex(index); - return m_source_model->getData(source_index, role); + return m_source_model->getData(std::move(source_index), role); } ModelIndex FileSystemModelSortFilterProxy::mkdir(const ModelIndex &parent, const std::string &name) { - if (!m_source_model) { - return ModelIndex(); - } - ModelIndex &&source_index = toSourceIndex(parent); - return m_source_model->mkdir(source_index, name); + return m_source_model->mkdir(std::move(source_index), name); } ModelIndex FileSystemModelSortFilterProxy::touch(const ModelIndex &parent, const std::string &name) { - if (!m_source_model) { - return ModelIndex(); - } - ModelIndex &&source_index = toSourceIndex(parent); - return m_source_model->touch(source_index, name); + return m_source_model->touch(std::move(source_index), name); } bool FileSystemModelSortFilterProxy::rmdir(const ModelIndex &index) { - if (!m_source_model) { - return false; - } - ModelIndex &&source_index = toSourceIndex(index); - return m_source_model->rmdir(source_index); + return m_source_model->rmdir(std::move(source_index)); } bool FileSystemModelSortFilterProxy::remove(const ModelIndex &index) { - if (!m_source_model) { - return false; - } - ModelIndex &&source_index = toSourceIndex(index); - return m_source_model->remove(source_index); + return m_source_model->remove(std::move(source_index)); } ModelIndex FileSystemModelSortFilterProxy::getIndex(const fs_path &path) const { ModelIndex index = m_source_model->getIndex(path); - if (!index.isValid()) { - return ModelIndex(); - } - return toProxyIndex(index); } ModelIndex FileSystemModelSortFilterProxy::getIndex(const UUID64 &uuid) const { ModelIndex index = m_source_model->getIndex(uuid); - if (!index.isValid()) { - return ModelIndex(); - } - return toProxyIndex(index); } @@ -895,98 +849,42 @@ namespace Toolbox { ModelIndex parent_src = toSourceIndex(parent); ModelIndex index = m_source_model->getIndex(row, column, parent_src); - if (!index.isValid()) { - return ModelIndex(); - } - return toProxyIndex(index); } fs_path FileSystemModelSortFilterProxy::getPath(const ModelIndex &index) const { - if (!m_source_model) { - return fs_path(); - } - ModelIndex &&source_index = toSourceIndex(index); - if (!source_index.isValid()) { - return fs_path(); - } - - return m_source_model->getPath(source_index); + return m_source_model->getPath(std::move(source_index)); } ModelIndex FileSystemModelSortFilterProxy::getParent(const ModelIndex &index) const { - if (!m_source_model) { - return ModelIndex(); - } - ModelIndex &&source_index = toSourceIndex(index); - if (!source_index.isValid()) { - return ModelIndex(); - } - - return toProxyIndex(m_source_model->getParent(source_index)); + return toProxyIndex(m_source_model->getParent(std::move(source_index))); } ModelIndex FileSystemModelSortFilterProxy::getSibling(int64_t row, int64_t column, const ModelIndex &index) const { - if (!m_source_model) { - return ModelIndex(); - } - ModelIndex &&source_index = toSourceIndex(index); - if (!source_index.isValid()) { - return ModelIndex(); - } - return toProxyIndex(m_source_model->getSibling(row, column, source_index)); } size_t FileSystemModelSortFilterProxy::getColumnCount(const ModelIndex &index) const { - if (!m_source_model) { - return 0; - } - ModelIndex &&source_index = toSourceIndex(index); - if (!source_index.isValid()) { - return 0; - } - return m_source_model->getColumnCount(source_index); } size_t FileSystemModelSortFilterProxy::getRowCount(const ModelIndex &index) const { - if (!m_source_model) { - return 0; - } - ModelIndex &&source_index = toSourceIndex(index); - if (!source_index.isValid()) { - return 0; - } - return m_source_model->getRowCount(source_index); } bool FileSystemModelSortFilterProxy::hasChildren(const ModelIndex &parent) const { - if (!m_source_model) { - return false; - } - ModelIndex &&source_index = toSourceIndex(parent); - if (!source_index.isValid()) { - return false; - } - return m_source_model->hasChildren(source_index); } ScopePtr FileSystemModelSortFilterProxy::createMimeData(const std::vector &indexes) const { - if (!m_source_model) { - return ScopePtr(); - } - std::vector indexes_copy = indexes; std::transform(indexes.begin(), indexes.end(), indexes_copy.begin(), [&](const ModelIndex &index) { return toSourceIndex(index); }); @@ -995,43 +893,20 @@ namespace Toolbox { } std::vector FileSystemModelSortFilterProxy::getSupportedMimeTypes() const { - if (!m_source_model) { - return std::vector(); - } return m_source_model->getSupportedMimeTypes(); } bool FileSystemModelSortFilterProxy::canFetchMore(const ModelIndex &index) { - if (!m_source_model) { - return false; - } - ModelIndex &&source_index = toSourceIndex(index); - if (!source_index.isValid()) { - return false; - } - - return m_source_model->canFetchMore(source_index); + return m_source_model->canFetchMore(std::move(source_index)); } void FileSystemModelSortFilterProxy::fetchMore(const ModelIndex &index) { - if (!m_source_model) { - return; - } - ModelIndex &&source_index = toSourceIndex(index); - if (!source_index.isValid()) { - return; - } - - m_source_model->fetchMore(source_index); + m_source_model->fetchMore(std::move(source_index)); } ModelIndex FileSystemModelSortFilterProxy::toSourceIndex(const ModelIndex &index) const { - if (!m_source_model) { - return ModelIndex(); - } - if (m_source_model->validateIndex(index)) { return index; } @@ -1040,14 +915,10 @@ namespace Toolbox { return ModelIndex(); } - return m_source_model->getIndex(index.data<_FileSystemIndexData>()->m_path); + return m_source_model->getIndex(index.data<_FileSystemIndexData>()->m_self_uuid); } ModelIndex FileSystemModelSortFilterProxy::toProxyIndex(const ModelIndex &index) const { - if (!m_source_model) { - return ModelIndex(); - } - if (validateIndex(index)) { return index; } @@ -1063,63 +934,45 @@ namespace Toolbox { return proxy_index; } - const std::vector &children = parent.data<_FileSystemIndexData>()->m_children; + std::vector children = parent.data<_FileSystemIndexData>()->m_children; if (children.empty()) { return ModelIndex(); } - std::vector filtered_children(children.size()); - std::copy_if(children.begin(), children.end(), filtered_children.begin(), - [&](const UUID64 &uuid) { - ModelIndex child_index = m_source_model->getIndex(uuid); - if (!child_index.isValid()) { - return false; - } - - if (isDirsOnly() && m_source_model->isFile(child_index)) { - return false; - } - - fs_path path = child_index.data<_FileSystemIndexData>()->m_path; - return path.filename().string().starts_with(m_filter); - }); - switch (m_sort_role) { case FileSystemModelSortRole::SORT_ROLE_NAME: { - std::sort(filtered_children.begin(), filtered_children.end(), - [&](const UUID64 &lhs, const UUID64 &rhs) { - return _FileSystemIndexDataCompareByName( - *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), - *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), - m_sort_order); - }); + std::sort(children.begin(), children.end(), [&](const UUID64 &lhs, const UUID64 &rhs) { + return _FileSystemIndexDataCompareByName( + *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), + *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), m_sort_order); + }); break; } case FileSystemModelSortRole::SORT_ROLE_SIZE: { - std::sort(filtered_children.begin(), filtered_children.end(), - [&](const UUID64 &lhs, const UUID64 &rhs) { - return _FileSystemIndexDataCompareBySize( - *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), - *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), - m_sort_order); - }); + std::sort(children.begin(), children.end(), [&](const UUID64 &lhs, const UUID64 &rhs) { + return _FileSystemIndexDataCompareBySize( + *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), + *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), m_sort_order); + }); break; } case FileSystemModelSortRole::SORT_ROLE_DATE: - std::sort(filtered_children.begin(), filtered_children.end(), - [&](const UUID64 &lhs, const UUID64 &rhs) { - return _FileSystemIndexDataCompareByDate( - *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), - *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), - m_sort_order); - }); + std::sort(children.begin(), children.end(), [&](const UUID64 &lhs, const UUID64 &rhs) { + return _FileSystemIndexDataCompareByDate( + *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), + *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), m_sort_order); + }); break; default: break; } - for (size_t i = 0; i < filtered_children.size(); i++) { - if (filtered_children[i] == index.getUUID()) { + for (size_t i = 0; i < children.size(); i++) { + if (isFiltered(children[i])) { + continue; + } + + if (children[i] == index.getUUID()) { ModelIndex proxy_index = ModelIndex(getUUID()); proxy_index.setData(index.data<_FileSystemIndexData>()); return proxy_index; @@ -1130,4 +983,14 @@ namespace Toolbox { return ModelIndex(); } + bool FileSystemModelSortFilterProxy::isFiltered(const UUID64 &uuid) const { + ModelIndex child_index = m_source_model->getIndex(uuid); + if (isDirsOnly() && m_source_model->isFile(child_index)) { + return true; + } + + fs_path path = child_index.data<_FileSystemIndexData>()->m_path; + return !path.filename().string().starts_with(m_filter); + } + } // namespace Toolbox \ No newline at end of file From bd79451a08fb7c33eca1aa64d1c588ab782799f5 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Wed, 11 Sep 2024 09:05:27 -0500 Subject: [PATCH 010/129] Update imgui submodule --- lib/imgui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/imgui b/lib/imgui index e391fe2e..f63c95a0 160000 --- a/lib/imgui +++ b/lib/imgui @@ -1 +1 @@ -Subproject commit e391fe2e66eb1c96b1624ae8444dc64c23146ef4 +Subproject commit f63c95a076a401721ceaf21f30d4f12e8c40cb2c From ffc72eb1397c1e894a63b7746fec92278342d5ea Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Wed, 11 Sep 2024 11:04:55 -0500 Subject: [PATCH 011/129] Update imgui_ext and fix bugs --- include/gui/project/window.hpp | 1 + include/model/fsmodel.hpp | 2 + src/gui/application.cpp | 2 +- src/gui/imgui_ext.cpp | 645 ++++++++++++++++++--------------- src/gui/project/window.cpp | 9 +- src/model/fsmodel.cpp | 152 +++++--- 6 files changed, 463 insertions(+), 348 deletions(-) diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 34c76a19..453f9bac 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -86,6 +86,7 @@ namespace Toolbox::UI { m_tree_proxy.setSourceModel(m_file_system_model); m_tree_proxy.setDirsOnly(true); m_view_proxy.setSourceModel(m_file_system_model); + m_view_proxy.setSortRole(FileSystemModelSortRole::SORT_ROLE_NAME); m_view_index = m_view_proxy.getIndex(0, 0); return true; } diff --git a/include/model/fsmodel.hpp b/include/model/fsmodel.hpp index d35cd529..a0577a0d 100644 --- a/include/model/fsmodel.hpp +++ b/include/model/fsmodel.hpp @@ -209,6 +209,8 @@ namespace Toolbox { protected: [[nodiscard]] ModelIndex toSourceIndex(const ModelIndex &index) const; [[nodiscard]] ModelIndex toProxyIndex(const ModelIndex &index) const; + [[nodiscard]] ModelIndex toProxyIndex(int64_t row, int64_t column, + const ModelIndex &parent = ModelIndex()) const; [[nodiscard]] bool isFiltered(const UUID64 &uuid) const; diff --git a/src/gui/application.cpp b/src/gui/application.cpp index f39a8937..5316a153 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -304,7 +304,7 @@ namespace Toolbox { ImGui::SetNextWindowPos(viewport->Pos); ImGui::SetNextWindowSize(viewport->Size); ImGui::SetNextWindowViewport(viewport->ID); - m_dockspace_id = ImGui::DockSpaceOverViewport(viewport); + m_dockspace_id = ImGui::DockSpaceOverViewport(0, viewport); m_dockspace_built = ImGui::DockBuilderGetNode(m_dockspace_id); if (!m_dockspace_built) { diff --git a/src/gui/imgui_ext.cpp b/src/gui/imgui_ext.cpp index 105aa3ba..d1837e01 100644 --- a/src/gui/imgui_ext.cpp +++ b/src/gui/imgui_ext.cpp @@ -26,6 +26,7 @@ static const ImGuiDataTypeInfo GDataTypeInfo[] = { {sizeof(float), "float", "%.3f", "%f" }, // ImGuiDataType_Float (float are promoted to double in va_arg) {sizeof(double), "double", "%f", "%lf" }, // ImGuiDataType_Double + {sizeof(bool), "bool", "%d", "%d" }, // ImGuiDataType_Bool }; IM_STATIC_ASSERT(IM_ARRAYSIZE(GDataTypeInfo) == ImGuiDataType_COUNT); @@ -349,7 +350,7 @@ bool ImGui::AlignedButton(const char *label, ImVec2 size, ImGuiButtonFlags flags return ret; } -bool ImGui::SwitchButton(const char* label, bool active, ImVec2 size, ImGuiButtonFlags flags) { +bool ImGui::SwitchButton(const char *label, bool active, ImVec2 size, ImGuiButtonFlags flags) { return SwitchButton(label, active, size, flags, ImDrawFlags_RoundCornersNone); } @@ -558,6 +559,22 @@ bool ImGui::TreeNodeEx(const char *label, ImGuiTreeNodeFlags flags, bool focused return TreeNodeBehavior(window->GetID(label), flags, label, NULL, focused); } +// Store ImGuiTreeNodeStackData for just submitted node. +// Currently only supports 32 level deep and we are fine with (1 << Depth) overflowing into a zero, +// easy to increase. +static void TreeNodeStoreStackData(ImGuiTreeNodeFlags flags) { + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; + + g.TreeNodeStack.resize(g.TreeNodeStack.Size + 1); + ImGuiTreeNodeStackData *tree_node_data = &g.TreeNodeStack.back(); + tree_node_data->ID = g.LastItemData.ID; + tree_node_data->TreeFlags = flags; + tree_node_data->InFlags = g.LastItemData.InFlags; + tree_node_data->NavRect = g.LastItemData.NavRect; + window->DC.TreeHasStackDataDepthMask |= (1 << window->DC.TreeDepth); +} + bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char *label, const char *label_end, bool focused) { ImGuiWindow *window = GetCurrentWindow(); @@ -577,6 +594,13 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char *l label_end = FindRenderedTextEnd(label); const ImVec2 label_size = CalcTextSize(label, label_end, false); + const float text_offset_x = + g.FontSize + + (display_frame ? padding.x * 3 : padding.x * 2); // Collapsing arrow width + Spacing + const float text_offset_y = + ImMax(padding.y, window->DC.CurrLineTextBaseOffset); // Latch before ItemSize changes it + const float text_width = g.FontSize + label_size.x + padding.x * 2; // Include collapsing arrow + // We vertically grow up to current line height up the typical widget height. const float frame_height = ImMax(ImMin(window->DC.CurrLineSize.y, g.FontSize + style.FramePadding.y * 2), @@ -588,73 +612,70 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char *l : (flags & ImGuiTreeNodeFlags_SpanFullWidth) ? window->WorkRect.Min.x : window->DC.CursorPos.x; frame_bb.Min.y = window->DC.CursorPos.y; - frame_bb.Max.x = span_all_columns ? window->ParentWorkRect.Max.x : window->WorkRect.Max.x; + frame_bb.Max.x = span_all_columns ? window->ParentWorkRect.Max.x + : (flags & ImGuiTreeNodeFlags_SpanTextWidth) + ? window->DC.CursorPos.x + text_width + padding.x + : window->WorkRect.Max.x; frame_bb.Max.y = window->DC.CursorPos.y + frame_height; if (display_frame) { - // Framed header expand a little outside the default padding, to the edge of InnerClipRect - // (FIXME: May remove this at some point and make InnerClipRect align with WindowPadding.x - // instead of WindowPadding.x*0.5f) - frame_bb.Min.x -= IM_TRUNC(window->WindowPadding.x * 0.5f - 1.0f); - frame_bb.Max.x += IM_TRUNC(window->WindowPadding.x * 0.5f); + const float outer_extend = + IM_TRUNC(window->WindowPadding.x * + 0.5f); // Framed header expand a little outside of current limits + frame_bb.Min.x -= outer_extend; + frame_bb.Max.x += outer_extend; } - const float text_offset_x = - g.FontSize + - (display_frame ? padding.x * 3 : padding.x * 2); // Collapsing arrow width + Spacing - const float text_offset_y = - ImMax(padding.y, window->DC.CurrLineTextBaseOffset); // Latch before ItemSize changes it - const float text_width = g.FontSize + (label_size.x > 0.0f ? label_size.x + padding.x * 2 - : 0.0f); // Include collapsing ImVec2 text_pos(window->DC.CursorPos.x + text_offset_x, window->DC.CursorPos.y + text_offset_y); ItemSize(ImVec2(text_width, frame_height), padding.y); // For regular tree nodes, we arbitrary allow to click past 2 worth of ItemSpacing ImRect interact_bb = frame_bb; - if (!display_frame && - (flags & (ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_SpanFullWidth | + if ((flags & (ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_SpanAvailWidth | + ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_SpanTextWidth | ImGuiTreeNodeFlags_SpanAllColumns)) == 0) - interact_bb.Max.x = frame_bb.Min.x + text_width + style.ItemSpacing.x * 2.0f; - - // Modify ClipRect for the ItemAdd(), faster than doing a - // PushColumnsBackground/PushTableBackgroundChannel for every Selectable.. - const float backup_clip_rect_min_x = window->ClipRect.Min.x; - const float backup_clip_rect_max_x = window->ClipRect.Max.x; - if (span_all_columns) { - window->ClipRect.Min.x = window->ParentWorkRect.Min.x; - window->ClipRect.Max.x = window->ParentWorkRect.Max.x; - } + interact_bb.Max.x = + frame_bb.Min.x + text_width + (label_size.x > 0.0f ? style.ItemSpacing.x * 2.0f : 0.0f); // Compute open and multi-select states before ItemAdd() as it clear NextItem data. - bool is_open = TreeNodeUpdateNextOpen(id, flags); - bool item_add = ItemAdd(interact_bb, id); - g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HasDisplayRect; - g.LastItemData.DisplayRect = frame_bb; + ImGuiID storage_id = (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasStorageID) + ? g.NextItemData.StorageId + : id; + bool is_open = TreeNodeUpdateNextOpen(storage_id, flags); + bool is_visible; if (span_all_columns) { - window->ClipRect.Min.x = backup_clip_rect_min_x; - window->ClipRect.Max.x = backup_clip_rect_max_x; + // Modify ClipRect for the ItemAdd(), faster than doing a + // PushColumnsBackground/PushTableBackgroundChannel for every Selectable.. + const float backup_clip_rect_min_x = window->ClipRect.Min.x; + const float backup_clip_rect_max_x = window->ClipRect.Max.x; + window->ClipRect.Min.x = window->ParentWorkRect.Min.x; + window->ClipRect.Max.x = window->ParentWorkRect.Max.x; + is_visible = ItemAdd(interact_bb, id); + window->ClipRect.Min.x = backup_clip_rect_min_x; + window->ClipRect.Max.x = backup_clip_rect_max_x; + } else { + is_visible = ItemAdd(interact_bb, id); } + g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HasDisplayRect; + g.LastItemData.DisplayRect = frame_bb; // If a NavLeft request is happening and ImGuiTreeNodeFlags_NavLeftJumpsBackHere enabled: // Store data for the current depth to allow returning to this node from any child item. // For this purpose we essentially compare if g.NavIdIsAlive went from 0 to 1 between TreeNode() // and TreePop(). It will become tempting to enable ImGuiTreeNodeFlags_NavLeftJumpsBackHere by - // default or move it to ImGuiStyle. Currently only supports 32 level deep and we are fine with - // (1 << Depth) overflowing into a zero, easy to increase. - if (is_open && !g.NavIdIsAlive && (flags & ImGuiTreeNodeFlags_NavLeftJumpsBackHere) && - !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen)) - if (g.NavMoveDir == ImGuiDir_Left && g.NavWindow == window && - NavMoveRequestButNoResultYet()) { - g.NavTreeNodeStack.resize(g.NavTreeNodeStack.Size + 1); - ImGuiNavTreeNodeData *nav_tree_node_data = &g.NavTreeNodeStack.back(); - nav_tree_node_data->ID = id; - nav_tree_node_data->InFlags = g.LastItemData.InFlags; - nav_tree_node_data->NavRect = g.LastItemData.NavRect; - window->DC.TreeJumpToParentOnPopMask |= (1 << window->DC.TreeDepth); - } + // default or move it to ImGuiStyle. + bool store_tree_node_stack_data = false; + if (!(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen)) { + if ((flags & ImGuiTreeNodeFlags_NavLeftJumpsBackHere) && is_open && !g.NavIdIsAlive) + if (g.NavMoveDir == ImGuiDir_Left && g.NavWindow == window && + NavMoveRequestButNoResultYet()) + store_tree_node_stack_data = true; + } const bool is_leaf = (flags & ImGuiTreeNodeFlags_Leaf) != 0; - if (!item_add) { + if (!is_visible) { + if (store_tree_node_stack_data && is_open) + TreeNodeStoreStackData(flags); // Call before TreePushOverrideID() if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen)) TreePushOverrideID(id); IMGUI_TEST_ENGINE_ITEM_INFO(g.LastItemData.ID, label, @@ -664,8 +685,11 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char *l return is_open; } - if (span_all_columns) + if (span_all_columns) { TablePushBackgroundChannel(); + g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HasClipRect; + g.LastItemData.ClipRect = window->ClipRect; + } ImGuiButtonFlags button_flags = ImGuiTreeNodeFlags_None; if ((flags & ImGuiTreeNodeFlags_AllowOverlap) || @@ -682,8 +706,13 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char *l (text_pos.x - text_offset_x) + (g.FontSize + padding.x * 2.0f) + style.TouchExtraPadding.x; const bool is_mouse_x_over_arrow = (g.IO.MousePos.x >= arrow_hit_x1 && g.IO.MousePos.x < arrow_hit_x2); - if (window != g.HoveredWindow || !is_mouse_x_over_arrow) - button_flags |= ImGuiButtonFlags_NoKeyModifiers; + + const bool is_multi_select = (g.LastItemData.InFlags & ImGuiItemFlags_IsMultiSelect) != 0; + if (is_multi_select) // We absolutely need to distinguish open vs select so _OpenOnArrow comes + // by default + flags |= (flags & ImGuiTreeNodeFlags_OpenOnMask_) == 0 + ? ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick + : ImGuiTreeNodeFlags_OpenOnArrow; // Open behaviors can be altered with the _OpenOnArrow and _OnOnDoubleClick flags. // Some alteration have subtle effects (e.g. toggle on MouseUp vs MouseDown events) due to @@ -707,27 +736,40 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char *l bool selected = (flags & ImGuiTreeNodeFlags_Selected) != 0; const bool was_selected = selected; + // Multi-selection support (header) + if (is_multi_select) { + // Handle multi-select + alter button flags for it + MultiSelectItemHeader(id, &selected, &button_flags); + if (is_mouse_x_over_arrow) + button_flags = (button_flags | ImGuiButtonFlags_PressedOnClick) & + ~ImGuiButtonFlags_PressedOnClickRelease; + } else { + if (window != g.HoveredWindow || !is_mouse_x_over_arrow) + button_flags |= ImGuiButtonFlags_NoKeyModifiers; + } + bool hovered, held; bool pressed = ButtonBehavior(interact_bb, id, &hovered, &held, button_flags); bool toggled = false; if (!is_leaf) { if (pressed && g.DragDropHoldJustPressedId != id) { - if ((flags & (ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick)) == - 0 || - (g.NavActivateId == id)) - toggled = true; + if ((flags & ImGuiTreeNodeFlags_OpenOnMask_) == 0 || + (g.NavActivateId == id && !is_multi_select)) + toggled = true; // Single click if (flags & ImGuiTreeNodeFlags_OpenOnArrow) toggled |= is_mouse_x_over_arrow && !g.NavDisableMouseHover; // Lightweight equivalent of IsMouseHoveringRect() // since ButtonBehavior() already did the job if ((flags & ImGuiTreeNodeFlags_OpenOnDoubleClick) && g.IO.MouseClickedCount[0] == 2) - toggled = true; + toggled = true; // Double click } else if (pressed && g.DragDropHoldJustPressedId == id) { IM_ASSERT(button_flags & ImGuiButtonFlags_PressedOnDragDropHold); if (!is_open) // When using Drag and Drop "hold to open" we keep the node highlighted // after opening, but never close it again. toggled = true; + else + pressed = false; // Cancel press so it doesn't trigger selection. } if (g.NavId == id && g.NavMoveDir == ImGuiDir_Left && is_open) { @@ -746,80 +788,96 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char *l if (toggled) { is_open = !is_open; - window->DC.StateStorage->SetInt(id, is_open); + window->DC.StateStorage->SetInt(storage_id, is_open); g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_ToggledOpen; } } - // In this branch, TreeNodeBehavior() cannot toggle the selection so this will never trigger. - if (selected != was_selected) //-V547 + // Multi-selection support (footer) + if (is_multi_select) { + bool pressed_copy = pressed && !toggled; + MultiSelectItemFooter(id, &selected, &pressed_copy); + if (pressed) + SetNavID(id, window->DC.NavLayerCurrent, g.CurrentFocusScopeId, interact_bb); + } + + if (selected != was_selected) g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_ToggledSelection; // Render - const ImU32 text_col = GetColorU32(ImGuiCol_Text); - ImGuiNavHighlightFlags nav_highlight_flags = ImGuiNavHighlightFlags_Compact; - if (display_frame) { - // Framed type - const ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive - : hovered ? ImGuiCol_HeaderHovered - : ImGuiCol_Header); - RenderFrame(frame_bb.Min, frame_bb.Max, bg_col, true, style.FrameRounding); - RenderNavHighlight(frame_bb, id, nav_highlight_flags); - if (flags & ImGuiTreeNodeFlags_Bullet) - RenderBullet(window->DrawList, - ImVec2(text_pos.x - text_offset_x * 0.60f, text_pos.y + g.FontSize * 0.5f), - text_col); - else if (!is_leaf) - RenderArrow(window->DrawList, - ImVec2(text_pos.x - text_offset_x + padding.x, text_pos.y), text_col, - is_open ? ((flags & ImGuiTreeNodeFlags_UpsideDownArrow) ? ImGuiDir_Up - : ImGuiDir_Down) - : ImGuiDir_Right, - 1.0f); - else // Leaf without bullet, left-adjusted text - text_pos.x -= text_offset_x - padding.x; - if (flags & ImGuiTreeNodeFlags_ClipLabelForTrailingButton) - frame_bb.Max.x -= g.FontSize + style.FramePadding.x; - - if (g.LogEnabled) - LogSetNextTextDecoration("###", "###"); - } else { - // Unframed typed for tree nodes - if (hovered || selected || focused) { - const ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive - : hovered || focused ? ImGuiCol_HeaderHovered - : ImGuiCol_Header); - RenderFrame(frame_bb.Min, frame_bb.Max, bg_col, false); + { + const ImU32 text_col = GetColorU32(ImGuiCol_Text); + ImGuiNavHighlightFlags nav_highlight_flags = ImGuiNavHighlightFlags_Compact; + if (is_multi_select) + nav_highlight_flags |= + ImGuiNavHighlightFlags_AlwaysDraw; // Always show the nav rectangle + if (display_frame) { + // Framed type + const ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive + : hovered ? ImGuiCol_HeaderHovered + : ImGuiCol_Header); + RenderFrame(frame_bb.Min, frame_bb.Max, bg_col, true, style.FrameRounding); + RenderNavHighlight(frame_bb, id, nav_highlight_flags); + if (flags & ImGuiTreeNodeFlags_Bullet) + RenderBullet( + window->DrawList, + ImVec2(text_pos.x - text_offset_x * 0.60f, text_pos.y + g.FontSize * 0.5f), + text_col); + else if (!is_leaf) + RenderArrow(window->DrawList, + ImVec2(text_pos.x - text_offset_x + padding.x, text_pos.y), text_col, + is_open ? ((flags & ImGuiTreeNodeFlags_UpsideDownArrow) ? ImGuiDir_Up + : ImGuiDir_Down) + : ImGuiDir_Right, + 1.0f); + else // Leaf without bullet, left-adjusted text + text_pos.x -= text_offset_x - padding.x; + if (flags & ImGuiTreeNodeFlags_ClipLabelForTrailingButton) + frame_bb.Max.x -= g.FontSize + style.FramePadding.x; + if (g.LogEnabled) + LogSetNextTextDecoration("###", "###"); + } else { + // Unframed typed for tree nodes + if (hovered || selected || focused) { + const ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive + : hovered || focused ? ImGuiCol_HeaderHovered + : ImGuiCol_Header); + RenderFrame(frame_bb.Min, frame_bb.Max, bg_col, false); + } + RenderNavHighlight(frame_bb, id, nav_highlight_flags); + if (flags & ImGuiTreeNodeFlags_Bullet) + RenderBullet( + window->DrawList, + ImVec2(text_pos.x - text_offset_x * 0.5f, text_pos.y + g.FontSize * 0.5f), + text_col); + else if (!is_leaf) + RenderArrow( + window->DrawList, + ImVec2(text_pos.x - text_offset_x + padding.x, text_pos.y + g.FontSize * 0.15f), + text_col, + is_open ? ((flags & ImGuiTreeNodeFlags_UpsideDownArrow) ? ImGuiDir_Up + : ImGuiDir_Down) + : ImGuiDir_Right, + 0.70f); + if (g.LogEnabled) + LogSetNextTextDecoration(">", NULL); } - RenderNavHighlight(frame_bb, id, nav_highlight_flags); - if (flags & ImGuiTreeNodeFlags_Bullet) - RenderBullet(window->DrawList, - ImVec2(text_pos.x - text_offset_x * 0.5f, text_pos.y + g.FontSize * 0.5f), - text_col); - else if (!is_leaf) - RenderArrow( - window->DrawList, - ImVec2(text_pos.x - text_offset_x + padding.x, text_pos.y + g.FontSize * 0.15f), - text_col, - is_open - ? ((flags & ImGuiTreeNodeFlags_UpsideDownArrow) ? ImGuiDir_Up : ImGuiDir_Down) - : ImGuiDir_Right, - 0.70f); - if (g.LogEnabled) - LogSetNextTextDecoration(">", NULL); - } - if (span_all_columns) - TablePopBackgroundChannel(); + if (span_all_columns) + TablePopBackgroundChannel(); - // Label - if (display_frame) - RenderTextClipped(text_pos, frame_bb.Max, label, label_end, &label_size); - else - RenderText(text_pos, label, label_end, false); + // Label + if (display_frame) + RenderTextClipped(text_pos, frame_bb.Max, label, label_end, &label_size); + else + RenderText(text_pos, label, label_end, false); + } + if (store_tree_node_stack_data && is_open) + TreeNodeStoreStackData(flags); // Call before TreePushOverrideID() if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen)) - TreePushOverrideID(id); + TreePushOverrideID(id); // Could use TreePush(label) but this avoid computing twice + IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | (is_leaf ? 0 : ImGuiItemStatusFlags_Openable) | @@ -829,25 +887,30 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char *l bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char *label, const char *label_end, bool focused, bool *visible) { - ImGuiWindow *window = ImGui::GetCurrentWindow(); + ImGuiWindow *window = GetCurrentWindow(); if (window->SkipItems) return false; - const float row_y = ImGui::GetCursorPosY(); - ImGuiContext &g = *GImGui; const ImGuiStyle &style = g.Style; const bool display_frame = (flags & ImGuiTreeNodeFlags_Framed) != 0; - ImVec2 padding = (display_frame || (flags & ImGuiTreeNodeFlags_FramePadding)) - ? style.FramePadding - : ImVec2(style.FramePadding.x, - ImMin(window->DC.CurrLineTextBaseOffset, style.FramePadding.y)); - padding.y *= 1.2f; + const ImVec2 padding = + (display_frame || (flags & ImGuiTreeNodeFlags_FramePadding)) + ? style.FramePadding + : ImVec2(style.FramePadding.x, + ImMin(window->DC.CurrLineTextBaseOffset, style.FramePadding.y)); if (!label_end) - label_end = ImGui::FindRenderedTextEnd(label); - const ImVec2 label_size = ImGui::CalcTextSize(label, label_end, false); - const ImVec2 eye_size = ImGui::CalcTextSize(ICON_FK_EYE, nullptr, false); + label_end = FindRenderedTextEnd(label); + const ImVec2 label_size = CalcTextSize(label, label_end, false); + const ImVec2 eye_size = CalcTextSize(ICON_FK_EYE, nullptr, false); + + const float text_offset_x = + g.FontSize + + (display_frame ? padding.x * 3 : padding.x * 2); // Collapsing arrow width + Spacing + const float text_offset_y = + ImMax(padding.y, window->DC.CurrLineTextBaseOffset); // Latch before ItemSize changes it + const float text_width = g.FontSize + label_size.x + padding.x * 2; // Include collapsing arrow // We vertically grow up to current line height up the typical widget height. const float frame_height = @@ -860,87 +923,81 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char *l : (flags & ImGuiTreeNodeFlags_SpanFullWidth) ? window->WorkRect.Min.x : window->DC.CursorPos.x; frame_bb.Min.y = window->DC.CursorPos.y; - frame_bb.Max.x = span_all_columns ? window->ParentWorkRect.Max.x : window->WorkRect.Max.x; + frame_bb.Max.x = span_all_columns ? window->ParentWorkRect.Max.x + : (flags & ImGuiTreeNodeFlags_SpanTextWidth) + ? window->DC.CursorPos.x + text_width + padding.x + : window->WorkRect.Max.x; frame_bb.Max.y = window->DC.CursorPos.y + frame_height; if (display_frame) { - // Framed header expand a little outside the default padding, to the edge of - // InnerClipRect (FIXME: May remove this at some point and make InnerClipRect align with - // WindowPadding.x instead of WindowPadding.x*0.5f) - frame_bb.Min.x -= IM_TRUNC(window->WindowPadding.x * 0.5f - 1.0f); - frame_bb.Max.x += IM_TRUNC(window->WindowPadding.x * 0.5f); + const float outer_extend = + IM_TRUNC(window->WindowPadding.x * + 0.5f); // Framed header expand a little outside of current limits + frame_bb.Min.x -= outer_extend; + frame_bb.Max.x += outer_extend; } - const float text_offset_x = - g.FontSize + - (display_frame ? padding.x * 3 : padding.x * 2); // Collapsing arrow width + Spacing - const float text_offset_y = - ImMax(padding.y, window->DC.CurrLineTextBaseOffset); // Latch before ItemSize changes it - const float text_width = g.FontSize + (label_size.x > 0.0f ? label_size.x + padding.x * 2 - : 0.0f); // Include collapsing - ImVec2 text_pos(window->DC.CursorPos.x + text_offset_x + label_size.y * 1.5f, - window->DC.CursorPos.y + text_offset_y); ImVec2 eye_pos(frame_bb.Min.x + padding.x, window->DC.CursorPos.y); - ImGui::ItemSize(ImVec2(text_width, frame_height), padding.y); + ImVec2 text_pos(window->DC.CursorPos.x + text_offset_x, window->DC.CursorPos.y + text_offset_y); + ItemSize(ImVec2(text_width, frame_height), padding.y); ImRect eye_interact_bb = frame_bb; eye_interact_bb.Max.x = frame_bb.Min.x + eye_size.x + style.ItemSpacing.x; // For regular tree nodes, we arbitrary allow to click past 2 worth of ItemSpacing ImRect interact_bb = frame_bb; - if (!display_frame && - (flags & (ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_SpanFullWidth | + if ((flags & (ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_SpanAvailWidth | + ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_SpanTextWidth | ImGuiTreeNodeFlags_SpanAllColumns)) == 0) - interact_bb.Max.x = frame_bb.Min.x + text_width + style.ItemSpacing.x * 2.0f; - interact_bb.Min.x += eye_size.x + style.TouchExtraPadding.x; + interact_bb.Max.x = + frame_bb.Min.x + text_width + (label_size.x > 0.0f ? style.ItemSpacing.x * 2.0f : 0.0f); + + // Compute open and multi-select states before ItemAdd() as it clear NextItem data. + ImGuiID storage_id = (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasStorageID) + ? g.NextItemData.StorageId + : id; + bool is_open = TreeNodeUpdateNextOpen(storage_id, flags); - // Modify ClipRect for the ItemAdd(), faster than doing a - // PushColumnsBackground/PushTableBackgroundChannel for every Selectable.. - const float backup_clip_rect_min_x = window->ClipRect.Min.x; - const float backup_clip_rect_max_x = window->ClipRect.Max.x; + bool is_visible; if (span_all_columns) { - window->ClipRect.Min.x = window->ParentWorkRect.Min.x; - window->ClipRect.Max.x = window->ParentWorkRect.Max.x; + // Modify ClipRect for the ItemAdd(), faster than doing a + // PushColumnsBackground/PushTableBackgroundChannel for every Selectable.. + const float backup_clip_rect_min_x = window->ClipRect.Min.x; + const float backup_clip_rect_max_x = window->ClipRect.Max.x; + window->ClipRect.Min.x = window->ParentWorkRect.Min.x; + window->ClipRect.Max.x = window->ParentWorkRect.Max.x; + is_visible = ItemAdd(interact_bb, id); + window->ClipRect.Min.x = backup_clip_rect_min_x; + window->ClipRect.Max.x = backup_clip_rect_max_x; + } else { + is_visible = ItemAdd(interact_bb, id); } - // ImGui::SetActiveID(0, ImGui::GetCurrentWindow()); - ImGuiID eye_interact_id = ImGui::GetID("eye_button##internal"); - ImGui::ItemAdd(eye_interact_bb, eye_interact_id); + ImGuiID eye_interact_id = GetID("eye_button##internal"); + ItemAdd(eye_interact_bb, eye_interact_id); - // Compute open and multi-select states before ItemAdd() as it clear NextItem data. - bool is_open = ImGui::TreeNodeUpdateNextOpen(id, flags); - bool item_add = ImGui::ItemAdd(interact_bb, id); g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HasDisplayRect; g.LastItemData.DisplayRect = frame_bb; - if (span_all_columns) { - window->ClipRect.Min.x = backup_clip_rect_min_x; - window->ClipRect.Max.x = backup_clip_rect_max_x; - } - // If a NavLeft request is happening and ImGuiTreeNodeFlags_NavLeftJumpsBackHere enabled: // Store data for the current depth to allow returning to this node from any child item. - // For this purpose we essentially compare if g.NavIdIsAlive went from 0 to 1 between - // TreeNode() and TreePop(). It will become tempting to enable - // ImGuiTreeNodeFlags_NavLeftJumpsBackHere by default or move it to ImGuiStyle. Currently - // only supports 32 level deep and we are fine with (1 << Depth) overflowing into a zero, - // easy to increase. - if (is_open && !g.NavIdIsAlive && (flags & ImGuiTreeNodeFlags_NavLeftJumpsBackHere) && - !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen)) - if (g.NavMoveDir == ImGuiDir_Left && g.NavWindow == window && - ImGui::NavMoveRequestButNoResultYet()) { - g.NavTreeNodeStack.resize(g.NavTreeNodeStack.Size + 1); - ImGuiNavTreeNodeData *nav_tree_node_data = &g.NavTreeNodeStack.back(); - nav_tree_node_data->ID = id; - nav_tree_node_data->InFlags = g.LastItemData.InFlags; - nav_tree_node_data->NavRect = g.LastItemData.NavRect; - window->DC.TreeJumpToParentOnPopMask |= (1 << window->DC.TreeDepth); - } + // For this purpose we essentially compare if g.NavIdIsAlive went from 0 to 1 between TreeNode() + // and TreePop(). It will become tempting to enable ImGuiTreeNodeFlags_NavLeftJumpsBackHere by + // default or move it to ImGuiStyle. + bool store_tree_node_stack_data = false; + if (!(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen)) { + if ((flags & ImGuiTreeNodeFlags_NavLeftJumpsBackHere) && is_open && !g.NavIdIsAlive) + if (g.NavMoveDir == ImGuiDir_Left && g.NavWindow == window && + NavMoveRequestButNoResultYet()) + store_tree_node_stack_data = true; + } const bool is_leaf = (flags & ImGuiTreeNodeFlags_Leaf) != 0; - if (!item_add) { + if (!is_visible) { + if (store_tree_node_stack_data && is_open) + TreeNodeStoreStackData(flags); // Call before TreePushOverrideID() if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen)) - ImGui::TreePushOverrideID(id); + TreePushOverrideID(id); IMGUI_TEST_ENGINE_ITEM_INFO(g.LastItemData.ID, label, g.LastItemData.StatusFlags | (is_leaf ? 0 : ImGuiItemStatusFlags_Openable) | @@ -948,8 +1005,11 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char *l return is_open; } - if (span_all_columns) - ImGui::TablePushBackgroundChannel(); + if (span_all_columns) { + TablePushBackgroundChannel(); + g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HasClipRect; + g.LastItemData.ClipRect = window->ClipRect; + } const float eye_hit_x1 = eye_pos.x - style.TouchExtraPadding.x; const float eye_hit_x2 = eye_pos.x + (eye_size.x) + style.TouchExtraPadding.x; @@ -978,15 +1038,19 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char *l // We allow clicking on the arrow section with keyboard modifiers held, in order to easily // allow browsing a tree while preserving selection with code implementing multi-selection - // patterns. When clicking on the rest of the tree node we always disallow keyboard - // modifiers. + // patterns. When clicking on the rest of the tree node we always disallow keyboard modifiers. const float arrow_hit_x1 = (text_pos.x - text_offset_x) - style.TouchExtraPadding.x; const float arrow_hit_x2 = (text_pos.x - text_offset_x) + (g.FontSize + padding.x * 2.0f) + style.TouchExtraPadding.x; const bool is_mouse_x_over_arrow = (g.IO.MousePos.x >= arrow_hit_x1 && g.IO.MousePos.x < arrow_hit_x2); - if (window != g.HoveredWindow || !is_mouse_x_over_arrow) - button_flags |= ImGuiButtonFlags_NoKeyModifiers; + + const bool is_multi_select = (g.LastItemData.InFlags & ImGuiItemFlags_IsMultiSelect) != 0; + if (is_multi_select) // We absolutely need to distinguish open vs select so _OpenOnArrow comes + // by default + flags |= (flags & ImGuiTreeNodeFlags_OpenOnMask_) == 0 + ? ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick + : ImGuiTreeNodeFlags_OpenOnArrow; // Open behaviors can be altered with the _OpenOnArrow and _OnOnDoubleClick flags. // Some alteration have subtle effects (e.g. toggle on MouseUp vs MouseDown events) due to @@ -996,9 +1060,9 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char *l // - Single-click on arrow = Toggle on MouseDown (when _OpenOnArrow=1) // - Double-click on label = Toggle on MouseDoubleClick (when _OpenOnDoubleClick=1) // - Double-click on arrow = Toggle on MouseDoubleClick (when _OpenOnDoubleClick=1 and - // _OpenOnArrow=0) It is rather standard that arrow click react on Down rather than Up. We - // set ImGuiButtonFlags_PressedOnClickRelease on OpenOnDoubleClick because we want the item - // to be active on the initial MouseDown in order for drag and drop to work. + // _OpenOnArrow=0) It is rather standard that arrow click react on Down rather than Up. We set + // ImGuiButtonFlags_PressedOnClickRelease on OpenOnDoubleClick because we want the item to be + // active on the initial MouseDown in order for drag and drop to work. if (is_mouse_x_over_arrow) button_flags |= ImGuiButtonFlags_PressedOnClick; else if (flags & ImGuiTreeNodeFlags_OpenOnDoubleClick) @@ -1010,138 +1074,152 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char *l bool selected = (flags & ImGuiTreeNodeFlags_Selected) != 0; const bool was_selected = selected; + // Multi-selection support (header) + if (is_multi_select) { + // Handle multi-select + alter button flags for it + MultiSelectItemHeader(id, &selected, &button_flags); + if (is_mouse_x_over_arrow) + button_flags = (button_flags | ImGuiButtonFlags_PressedOnClick) & + ~ImGuiButtonFlags_PressedOnClickRelease; + } else { + if (window != g.HoveredWindow || !is_mouse_x_over_arrow) + button_flags |= ImGuiButtonFlags_NoKeyModifiers; + } + bool hovered, held; - bool pressed = ImGui::ButtonBehavior(interact_bb, id, &hovered, &held, button_flags); + bool pressed = ButtonBehavior(interact_bb, id, &hovered, &held, button_flags); bool toggled = false; if (!is_leaf) { if (pressed && g.DragDropHoldJustPressedId != id) { - if ((flags & (ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick)) == - 0 || - (g.NavActivateId == id)) - toggled = true; + if ((flags & ImGuiTreeNodeFlags_OpenOnMask_) == 0 || + (g.NavActivateId == id && !is_multi_select)) + toggled = true; // Single click if (flags & ImGuiTreeNodeFlags_OpenOnArrow) toggled |= is_mouse_x_over_arrow && !g.NavDisableMouseHover; // Lightweight equivalent of IsMouseHoveringRect() // since ButtonBehavior() already did the job if ((flags & ImGuiTreeNodeFlags_OpenOnDoubleClick) && g.IO.MouseClickedCount[0] == 2) - toggled = true; + toggled = true; // Double click } else if (pressed && g.DragDropHoldJustPressedId == id) { IM_ASSERT(button_flags & ImGuiButtonFlags_PressedOnDragDropHold); - if (!is_open) // When using Drag and Drop "hold to open" we keep the node - // highlighted after opening, but never close it again. + if (!is_open) // When using Drag and Drop "hold to open" we keep the node highlighted + // after opening, but never close it again. toggled = true; + else + pressed = false; // Cancel press so it doesn't trigger selection. } if (g.NavId == id && g.NavMoveDir == ImGuiDir_Left && is_open) { toggled = true; - ImGui::NavClearPreferredPosForAxis(ImGuiAxis_X); - ImGui::NavMoveRequestCancel(); + NavClearPreferredPosForAxis(ImGuiAxis_X); + NavMoveRequestCancel(); } if (g.NavId == id && g.NavMoveDir == ImGuiDir_Right && !is_open) // If there's something upcoming on the line we may want to give it the // priority? { toggled = true; - ImGui::NavClearPreferredPosForAxis(ImGuiAxis_X); - ImGui::NavMoveRequestCancel(); + NavClearPreferredPosForAxis(ImGuiAxis_X); + NavMoveRequestCancel(); } if (toggled) { is_open = !is_open; - window->DC.StateStorage->SetInt(id, is_open); + window->DC.StateStorage->SetInt(storage_id, is_open); g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_ToggledOpen; } } - // In this branch, TreeNodeBehavior() cannot toggle the selection so this will never - // trigger. - if (selected != was_selected) //-V547 + // Multi-selection support (footer) + if (is_multi_select) { + bool pressed_copy = pressed && !toggled; + MultiSelectItemFooter(id, &selected, &pressed_copy); + if (pressed) + SetNavID(id, window->DC.NavLayerCurrent, g.CurrentFocusScopeId, interact_bb); + } + + if (selected != was_selected) g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_ToggledSelection; // Render - const ImU32 text_col = ImGui::GetColorU32(ImGuiCol_Text); - ImGuiNavHighlightFlags nav_highlight_flags = ImGuiNavHighlightFlags_Compact; - if (display_frame) { - // Framed type - const ImU32 bg_col = ImGui::GetColorU32((held && hovered) ? ImGuiCol_HeaderActive - : hovered ? ImGuiCol_HeaderHovered - : ImGuiCol_Header); - ImGui::RenderFrame(frame_bb.Min, frame_bb.Max, bg_col, true, style.FrameRounding); - ImGui::RenderNavHighlight(frame_bb, id, nav_highlight_flags); - - if (flags & ImGuiTreeNodeFlags_Bullet) - ImGui::RenderBullet( - window->DrawList, - ImVec2(text_pos.x - text_offset_x * 0.60f, text_pos.y + g.FontSize * 0.5f), - text_col); - else if (!is_leaf) - ImGui::RenderArrow( - window->DrawList, ImVec2(text_pos.x - text_offset_x + padding.x, text_pos.y), - text_col, - is_open - ? ((flags & ImGuiTreeNodeFlags_UpsideDownArrow) ? ImGuiDir_Up : ImGuiDir_Down) - : ImGuiDir_Right, - 1.0f); - else // Leaf without bullet, left-adjusted text - text_pos.x -= text_offset_x - padding.x; - if (flags & ImGuiTreeNodeFlags_ClipLabelForTrailingButton) - frame_bb.Max.x -= g.FontSize + style.FramePadding.x; - - if (g.LogEnabled) - ImGui::LogSetNextTextDecoration("###", "###"); - } else { - // Unframed typed for tree nodes - if (hovered || selected || focused) { - const ImU32 bg_col = ImGui::GetColorU32((held && hovered) ? ImGuiCol_HeaderActive - : hovered || focused ? ImGuiCol_HeaderHovered - : ImGuiCol_Header); - ImGui::RenderFrame(frame_bb.Min, frame_bb.Max, bg_col, false); + { + const ImU32 text_col = GetColorU32(ImGuiCol_Text); + ImGuiNavHighlightFlags nav_highlight_flags = ImGuiNavHighlightFlags_Compact; + if (is_multi_select) + nav_highlight_flags |= + ImGuiNavHighlightFlags_AlwaysDraw; // Always show the nav rectangle + if (display_frame) { + // Framed type + const ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive + : hovered ? ImGuiCol_HeaderHovered + : ImGuiCol_Header); + RenderFrame(frame_bb.Min, frame_bb.Max, bg_col, true, style.FrameRounding); + RenderNavHighlight(frame_bb, id, nav_highlight_flags); + if (flags & ImGuiTreeNodeFlags_Bullet) + RenderBullet( + window->DrawList, + ImVec2(text_pos.x - text_offset_x * 0.60f, text_pos.y + g.FontSize * 0.5f), + text_col); + else if (!is_leaf) + RenderArrow(window->DrawList, + ImVec2(text_pos.x - text_offset_x + padding.x, text_pos.y), text_col, + is_open ? ((flags & ImGuiTreeNodeFlags_UpsideDownArrow) ? ImGuiDir_Up + : ImGuiDir_Down) + : ImGuiDir_Right, + 1.0f); + else // Leaf without bullet, left-adjusted text + text_pos.x -= text_offset_x - padding.x; + if (flags & ImGuiTreeNodeFlags_ClipLabelForTrailingButton) + frame_bb.Max.x -= g.FontSize + style.FramePadding.x; + if (g.LogEnabled) + LogSetNextTextDecoration("###", "###"); + } else { + // Unframed typed for tree nodes + if (hovered || selected || focused) { + const ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive + : hovered || focused ? ImGuiCol_HeaderHovered + : ImGuiCol_Header); + RenderFrame(frame_bb.Min, frame_bb.Max, bg_col, false); + } + RenderNavHighlight(frame_bb, id, nav_highlight_flags); + if (flags & ImGuiTreeNodeFlags_Bullet) + RenderBullet( + window->DrawList, + ImVec2(text_pos.x - text_offset_x * 0.5f, text_pos.y + g.FontSize * 0.5f), + text_col); + else if (!is_leaf) + RenderArrow( + window->DrawList, + ImVec2(text_pos.x - text_offset_x + padding.x, text_pos.y + g.FontSize * 0.15f), + text_col, + is_open ? ((flags & ImGuiTreeNodeFlags_UpsideDownArrow) ? ImGuiDir_Up + : ImGuiDir_Down) + : ImGuiDir_Right, + 0.70f); + if (g.LogEnabled) + LogSetNextTextDecoration(">", NULL); } - ImGui::RenderNavHighlight(frame_bb, id, nav_highlight_flags); - - if (flags & ImGuiTreeNodeFlags_Bullet) - ImGui::RenderBullet( - window->DrawList, - ImVec2(text_pos.x - text_offset_x * 0.5f, text_pos.y + g.FontSize * 0.5f), - text_col); - else if (!is_leaf) - ImGui::RenderArrow( - window->DrawList, - ImVec2(text_pos.x - text_offset_x + padding.x, text_pos.y + g.FontSize * 0.15f), - text_col, - is_open - ? ((flags & ImGuiTreeNodeFlags_UpsideDownArrow) ? ImGuiDir_Up : ImGuiDir_Down) - : ImGuiDir_Right, - 0.70f); - if (g.LogEnabled) - ImGui::LogSetNextTextDecoration(">", NULL); - } - - if (span_all_columns) - ImGui::TablePopBackgroundChannel(); - // Label - if (display_frame) - ImGui::RenderTextClipped(text_pos, frame_bb.Max, label, label_end, &label_size); - else - ImGui::RenderText(text_pos, label, label_end, false); - - ImGui::PushStyleColor(ImGuiCol_Button, {0, 0, 0, 0}); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, {0, 0, 0, 0}); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, {0, 0, 0, 0}); + if (span_all_columns) + TablePopBackgroundChannel(); - ImGui::RenderText(eye_pos, *visible ? ICON_FK_EYE : ICON_FK_EYE_SLASH, nullptr, false); - - ImGui::PopStyleColor(3); + // Label + if (display_frame) + RenderTextClipped(text_pos, frame_bb.Max, label, label_end, &label_size); + else + RenderText(text_pos, label, label_end, false); + } + if (store_tree_node_stack_data && is_open) + TreeNodeStoreStackData(flags); // Call before TreePushOverrideID() if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen)) - ImGui::TreePushOverrideID(id); + TreePushOverrideID(id); // Could use TreePush(label) but this avoid computing twice + IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | (is_leaf ? 0 : ImGuiItemStatusFlags_Openable) | (is_open ? ImGuiItemStatusFlags_Opened : 0)); - return is_open; } @@ -1325,8 +1403,8 @@ bool ImGui::IsDragDropSource(ImGuiDragDropFlags flags) { return source_drag_active; } - -void ImGui::RenderDragDropTargetRect(const ImRect &bb, const ImRect &item_clip_rect, ImGuiDropFlags flags) { +void ImGui::RenderDragDropTargetRect(const ImRect &bb, const ImRect &item_clip_rect, + ImGuiDropFlags flags) { ImGuiContext &g = *GImGui; ImGuiWindow *window = g.CurrentWindow; ImRect bb_display = bb; @@ -1339,7 +1417,8 @@ void ImGui::RenderDragDropTargetRect(const ImRect &bb, const ImRect &item_clip_r if (flags == ImGuiDropFlags_None || flags == ImGuiDropFlags_InsertChild) { window->DrawList->AddRect(bb_display.Min, bb_display.Max, - GetColorU32(ImGuiCol_DragDropTarget), 0.0f, ImDrawFlags_None, 2.0f); + GetColorU32(ImGuiCol_DragDropTarget), 0.0f, ImDrawFlags_None, + 2.0f); } else if (flags == ImGuiDropFlags_InsertBefore) { float y = bb_display.Min.y; window->DrawList->AddLine(ImVec2(bb_display.Min.x, y), ImVec2(bb_display.Max.x, y), diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 87c3e890..63bc1b1a 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -68,10 +68,9 @@ namespace Toolbox::UI { ImVec2 pos = ImGui::GetCursorScreenPos(); pos.x += std::max(36.0f - (text_size.x / 2.0f), 0.0); pos.y += 72.0f; - //pos.x += i * size.x / 4.0f; ImGui::RenderTextEllipsis( - ImGui::GetWindowDrawList(), pos, pos + ImVec2(72, 20), pos.x + 72.0f, + ImGui::GetWindowDrawList(), pos, pos + ImVec2(64, 20), pos.x + 64.0f, pos.x + 76.0f, m_view_proxy.getDisplayText(child_index).c_str(), nullptr, nullptr); } @@ -80,7 +79,7 @@ namespace Toolbox::UI { // ImGui::Text("%s", m_view_proxy.getDisplayText(child_index).c_str()); if ((i + 1) % x_count != 0) { - ImGui::SameLine(i * size.x / 4.0f); + ImGui::SameLine(); } } @@ -112,7 +111,7 @@ namespace Toolbox::UI { if (m_tree_proxy.canFetchMore(index)) { m_tree_proxy.fetchMore(index); } - is_open = ImGui::TreeNodeEx(m_tree_proxy.getPath(index).filename().string().c_str(), + is_open = ImGui::TreeNodeEx(m_tree_proxy.getDisplayText(index).c_str(), ImGuiTreeNodeFlags_OpenOnArrow); if (is_open) { for (size_t i = 0; i < m_tree_proxy.getRowCount(index); ++i) { @@ -124,7 +123,7 @@ namespace Toolbox::UI { ImGui::TreePop(); } } else { - if (ImGui::TreeNodeEx(m_tree_proxy.getPath(index).filename().string().c_str(), + if (ImGui::TreeNodeEx(m_tree_proxy.getDisplayText(index).c_str(), ImGuiTreeNodeFlags_Leaf)) { ImGui::TreePop(); } diff --git a/src/model/fsmodel.cpp b/src/model/fsmodel.cpp index 389d4af9..a83bc593 100644 --- a/src/model/fsmodel.cpp +++ b/src/model/fsmodel.cpp @@ -21,6 +21,7 @@ namespace Toolbox { Type m_type = Type::UNKNOWN; fs_path m_path; + std::string m_name; size_t m_size = 0; Filesystem::file_time_type m_date; @@ -31,7 +32,7 @@ namespace Toolbox { } std::strong_ordering operator<=>(const _FileSystemIndexData &rhs) const { - return m_path <=> rhs.m_path; + return m_self_uuid <=> rhs.m_self_uuid; } }; @@ -57,9 +58,9 @@ namespace Toolbox { // Sort by name if (order == ModelSortOrder::SORT_ASCENDING) { - return lhs.m_path < rhs.m_path; + return lhs.m_name < rhs.m_name; } else { - return lhs.m_path > rhs.m_path; + return lhs.m_name > rhs.m_name; } } @@ -178,7 +179,7 @@ namespace Toolbox { if (!validateIndex(index)) { return "Invalid"; } - return index.data<_FileSystemIndexData>()->m_path.filename().string(); + return index.data<_FileSystemIndexData>()->m_name; case ModelDataRole::DATA_ROLE_TOOLTIP: return "Tooltip unimplemented!"; case ModelDataRole::DATA_ROLE_DECORATION: { @@ -194,7 +195,8 @@ namespace Toolbox { Filesystem::file_time_type result = Filesystem::file_time_type(); - Filesystem::last_write_time(index.data<_FileSystemIndexData>()->m_path) + fs_path path = getPath(index); + Filesystem::last_write_time(path) .and_then([&](Filesystem::file_time_type &&time) { result = std::move(time); return Result(); @@ -214,7 +216,8 @@ namespace Toolbox { Filesystem::file_status result = Filesystem::file_status(); - Filesystem::status(index.data<_FileSystemIndexData>()->m_path) + fs_path path = getPath(index); + Filesystem::status(path) .and_then([&](Filesystem::file_status &&status) { result = std::move(status); return Result(); @@ -240,7 +243,12 @@ namespace Toolbox { return TypeMap().at("_Archive").m_name; } - std::string ext = index.data<_FileSystemIndexData>()->m_path.extension().string(); + std::string name = index.data<_FileSystemIndexData>()->m_name; + std::string ext = ""; + if (size_t epos = name.find('.'); epos != std::string::npos) { + ext = name.substr(epos); + } + if (ext.empty()) { return TypeMap().at("_Folder").m_name; } @@ -264,7 +272,8 @@ namespace Toolbox { bool result = false; if (isDirectory(parent)) { - fs_path path = parent.data<_FileSystemIndexData>()->m_path / name; + fs_path path = getPath(parent); + path /= name; Filesystem::create_directory(path) .and_then([&](bool created) { if (!created) { @@ -332,11 +341,11 @@ namespace Toolbox { bool result = false; if (isDirectory(index)) { - Filesystem::remove_all(index.data<_FileSystemIndexData>()->m_path) + Filesystem::remove_all(getPath(index)) .and_then([&](bool removed) { if (!removed) { TOOLBOX_ERROR_V("[FileSystemModel] Failed to remove directory: {}", - index.data<_FileSystemIndexData>()->m_path.string()); + getPath(index).string()); return Result(); } result = true; @@ -348,11 +357,11 @@ namespace Toolbox { return Result(); }); } else if (isArchive(index)) { - Filesystem::remove(index.data<_FileSystemIndexData>()->m_path) + Filesystem::remove(getPath(index)) .and_then([&](bool removed) { if (!removed) { TOOLBOX_ERROR_V("[FileSystemModel] Failed to remove archive: {}", - index.data<_FileSystemIndexData>()->m_path.string()); + getPath(index).string()); return Result(); } result = true; @@ -390,11 +399,11 @@ namespace Toolbox { bool result = false; if (isFile(index)) { - Filesystem::remove(index.data<_FileSystemIndexData>()->m_path) + Filesystem::remove(getPath(index)) .and_then([&](bool removed) { if (!removed) { TOOLBOX_ERROR_V("[FileSystemModel] Failed to remove file: {}", - index.data<_FileSystemIndexData>()->m_path.string()); + getPath(index).string()); return Result(); } result = true; @@ -432,7 +441,7 @@ namespace Toolbox { } for (const auto &[uuid, index] : m_index_map) { - if (index.data<_FileSystemIndexData>()->m_path == path) { + if (getPath(index) == path) { return index; } } @@ -440,7 +449,12 @@ namespace Toolbox { return ModelIndex(); } - ModelIndex FileSystemModel::getIndex(const UUID64 &uuid) const { return m_index_map.at(uuid); } + ModelIndex FileSystemModel::getIndex(const UUID64 &uuid) const { + if (m_index_map.find(uuid) == m_index_map.end()) { + return ModelIndex(); + } + return m_index_map.at(uuid); + } ModelIndex FileSystemModel::getIndex(int64_t row, int64_t column, const ModelIndex &parent) const { @@ -539,7 +553,7 @@ namespace Toolbox { } if (isDirectory(index)) { - fs_path path = index.data<_FileSystemIndexData>()->m_path; + fs_path path = getPath(index); size_t i = 0; for (const auto &entry : Filesystem::directory_iterator(path)) { @@ -616,7 +630,9 @@ namespace Toolbox { _FileSystemIndexData *data = new _FileSystemIndexData; data->m_path = path; + data->m_name = path.filename().string(); data->m_size = 0; + data->m_children = {}; if (Filesystem::is_directory(path).value_or(false)) { data->m_type = _FileSystemIndexData::Type::DIRECTORY; @@ -718,8 +734,7 @@ namespace Toolbox { if (isDirectory(index)) { // Count the children in the filesystem - for (const auto &entry : - Filesystem::directory_iterator(index.data<_FileSystemIndexData>()->m_path)) { + for (const auto &entry : Filesystem::directory_iterator(getPath(index))) { count += 1; } } else if (isArchive(index)) { @@ -847,9 +862,7 @@ namespace Toolbox { ModelIndex FileSystemModelSortFilterProxy::getIndex(int64_t row, int64_t column, const ModelIndex &parent) const { ModelIndex parent_src = toSourceIndex(parent); - - ModelIndex index = m_source_model->getIndex(row, column, parent_src); - return toProxyIndex(index); + return toProxyIndex(row, column, parent_src); } fs_path FileSystemModelSortFilterProxy::getPath(const ModelIndex &index) const { @@ -919,78 +932,99 @@ namespace Toolbox { } ModelIndex FileSystemModelSortFilterProxy::toProxyIndex(const ModelIndex &index) const { - if (validateIndex(index)) { - return index; - } - if (!m_source_model->validateIndex(index)) { return ModelIndex(); } - const ModelIndex &parent = m_source_model->getParent(index); - if (!m_source_model->validateIndex(parent)) { - ModelIndex proxy_index = ModelIndex(getUUID()); - proxy_index.setData(index.data<_FileSystemIndexData>()); - return proxy_index; + ModelIndex proxy_index = ModelIndex(getUUID()); + proxy_index.setData(index.data<_FileSystemIndexData>()); + return proxy_index; + } + + ModelIndex FileSystemModelSortFilterProxy::toProxyIndex(int64_t row, int64_t column, + const ModelIndex &src_parent) const { + std::vector filtered_children = {}; + + if (!m_source_model->validateIndex(src_parent)) { + size_t i = 0; + ModelIndex root_s = m_source_model->getIndex(i++, 0); + while (m_source_model->validateIndex(root_s)) { + filtered_children.push_back(root_s.getUUID()); + root_s = m_source_model->getIndex(i++, 0); + } + } else { + const std::vector &children = + src_parent.data<_FileSystemIndexData>()->m_children; + if (children.empty()) { + return ModelIndex(); + } + + filtered_children = children; } - std::vector children = parent.data<_FileSystemIndexData>()->m_children; - if (children.empty()) { + if (row >= filtered_children.size()) { return ModelIndex(); } switch (m_sort_role) { case FileSystemModelSortRole::SORT_ROLE_NAME: { - std::sort(children.begin(), children.end(), [&](const UUID64 &lhs, const UUID64 &rhs) { - return _FileSystemIndexDataCompareByName( - *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), - *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), m_sort_order); - }); + std::sort(filtered_children.begin(), filtered_children.end(), + [&](const UUID64 &lhs, const UUID64 &rhs) { + return _FileSystemIndexDataCompareByName( + *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), + *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), + m_sort_order); + }); break; } case FileSystemModelSortRole::SORT_ROLE_SIZE: { - std::sort(children.begin(), children.end(), [&](const UUID64 &lhs, const UUID64 &rhs) { - return _FileSystemIndexDataCompareBySize( - *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), - *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), m_sort_order); - }); + std::sort(filtered_children.begin(), filtered_children.end(), + [&](const UUID64 &lhs, const UUID64 &rhs) { + return _FileSystemIndexDataCompareBySize( + *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), + *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), + m_sort_order); + }); break; } case FileSystemModelSortRole::SORT_ROLE_DATE: - std::sort(children.begin(), children.end(), [&](const UUID64 &lhs, const UUID64 &rhs) { - return _FileSystemIndexDataCompareByDate( - *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), - *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), m_sort_order); - }); + std::sort(filtered_children.begin(), filtered_children.end(), + [&](const UUID64 &lhs, const UUID64 &rhs) { + return _FileSystemIndexDataCompareByDate( + *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), + *m_source_model->getIndex(rhs).data<_FileSystemIndexData>(), + m_sort_order); + }); break; default: break; } - for (size_t i = 0; i < children.size(); i++) { - if (isFiltered(children[i])) { + size_t i = 0; + for (const UUID64 &uuid : filtered_children) { + if (isFiltered(uuid)) { continue; } - - if (children[i] == index.getUUID()) { - ModelIndex proxy_index = ModelIndex(getUUID()); - proxy_index.setData(index.data<_FileSystemIndexData>()); - return proxy_index; + if (i++ == row) { + ModelIndex src_index = m_source_model->getIndex(uuid); + return toProxyIndex(src_index); } } - // Should never reach here return ModelIndex(); } bool FileSystemModelSortFilterProxy::isFiltered(const UUID64 &uuid) const { ModelIndex child_index = m_source_model->getIndex(uuid); - if (isDirsOnly() && m_source_model->isFile(child_index)) { + bool is_file = + child_index.data<_FileSystemIndexData>()->m_type == _FileSystemIndexData::Type::FILE; + + if (isDirsOnly() && is_file) { return true; } - fs_path path = child_index.data<_FileSystemIndexData>()->m_path; - return !path.filename().string().starts_with(m_filter); + const std::string &name = child_index.data<_FileSystemIndexData>()->m_name; + return !name.starts_with(m_filter); } } // namespace Toolbox \ No newline at end of file From 59534ee1878bb2644cfaecf5ee1d4c1695d3d4b1 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Thu, 12 Sep 2024 23:35:30 -0500 Subject: [PATCH 012/129] Memory leak exists in proxy model --- include/gui/project/window.hpp | 1 + include/model/fsmodel.hpp | 10 +- src/gui/project/window.cpp | 25 +++-- src/image/imagehandle.cpp | 1 + src/model/fsmodel.cpp | 191 ++++++++++++++++++++++----------- vcpkg.json | 2 +- 6 files changed, 153 insertions(+), 77 deletions(-) diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 453f9bac..95fd05a1 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -82,6 +82,7 @@ namespace Toolbox::UI { [[nodiscard]] bool onLoadData(const std::filesystem::path& path) override { m_project_root = path; m_file_system_model = make_referable(); + m_file_system_model->initialize(); m_file_system_model->setRoot(m_project_root); m_tree_proxy.setSourceModel(m_file_system_model); m_tree_proxy.setDirsOnly(true); diff --git a/include/model/fsmodel.hpp b/include/model/fsmodel.hpp index a0577a0d..4bca060d 100644 --- a/include/model/fsmodel.hpp +++ b/include/model/fsmodel.hpp @@ -49,6 +49,8 @@ namespace Toolbox { FileSystemModel() = default; ~FileSystemModel() = default; + void initialize(); + [[nodiscard]] UUID64 getUUID() const override { return m_uuid; } [[nodiscard]] const fs_path &getRoot() const &; @@ -138,6 +140,7 @@ namespace Toolbox { UUID64 m_root_index; mutable std::unordered_map m_index_map; + mutable std::unordered_map> m_icon_map; }; class FileSystemModelSortFilterProxy : public IDataModel { @@ -206,13 +209,15 @@ namespace Toolbox { [[nodiscard]] bool canFetchMore(const ModelIndex &index); void fetchMore(const ModelIndex &index); - protected: [[nodiscard]] ModelIndex toSourceIndex(const ModelIndex &index) const; [[nodiscard]] ModelIndex toProxyIndex(const ModelIndex &index) const; + + protected: [[nodiscard]] ModelIndex toProxyIndex(int64_t row, int64_t column, const ModelIndex &parent = ModelIndex()) const; [[nodiscard]] bool isFiltered(const UUID64 &uuid) const; + void cacheIndex(const ModelIndex &index) const; ModelIndex makeIndex(const fs_path &path, int64_t row, const ModelIndex &parent) { return ModelIndex(); @@ -227,6 +232,9 @@ namespace Toolbox { std::string m_filter = ""; bool m_dirs_only = false; + + mutable std::unordered_map m_filter_map; + mutable std::unordered_map> m_row_map; }; } // namespace Toolbox \ No newline at end of file diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 63bc1b1a..108f3a4a 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -1,8 +1,8 @@ #include "gui/project/window.hpp" #include "model/fsmodel.hpp" -#include #include +#include namespace Toolbox::UI { @@ -30,15 +30,15 @@ namespace Toolbox::UI { } void ProjectViewWindow::renderProjectFolderView() { - if (!m_view_proxy.validateIndex(m_view_index)) { + if (!m_file_system_model->validateIndex(m_view_index)) { return; } if (ImGui::BeginChild("Folder View", {0, 0}, true, ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { - if (m_view_proxy.hasChildren(m_view_index)) { - if (m_view_proxy.canFetchMore(m_view_index)) { - m_view_proxy.fetchMore(m_view_index); + if (m_file_system_model->hasChildren(m_view_index)) { + if (m_file_system_model->canFetchMore(m_view_index)) { + m_file_system_model->fetchMore(m_view_index); } ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, {2, 2}); @@ -53,16 +53,16 @@ namespace Toolbox::UI { x_count = 1; } - for (size_t i = 0; i < m_view_proxy.getRowCount(m_view_index); ++i) { - ModelIndex child_index = m_view_proxy.getIndex(i, 0, m_view_index); + for (size_t i = 0; i < m_file_system_model->getRowCount(m_view_index); ++i) { + ModelIndex child_index = m_file_system_model->getIndex(i, 0, m_view_index); if (ImGui::BeginChild(child_index.getUUID(), {76, 92}, true, ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { - m_icon_painter.render(*m_view_proxy.getDecoration(child_index), {72, 72}); + m_icon_painter.render(*m_file_system_model->getDecoration(child_index), {72, 72}); - std::string text = m_view_proxy.getDisplayText(child_index); + std::string text = m_file_system_model->getDisplayText(child_index); ImVec2 text_size = ImGui::CalcTextSize(text.c_str()); ImVec2 pos = ImGui::GetCursorScreenPos(); @@ -71,7 +71,7 @@ namespace Toolbox::UI { ImGui::RenderTextEllipsis( ImGui::GetWindowDrawList(), pos, pos + ImVec2(64, 20), pos.x + 64.0f, - pos.x + 76.0f, m_view_proxy.getDisplayText(child_index).c_str(), + pos.x + 76.0f, m_file_system_model->getDisplayText(child_index).c_str(), nullptr, nullptr); } ImGui::EndChild(); @@ -113,6 +113,11 @@ namespace Toolbox::UI { } is_open = ImGui::TreeNodeEx(m_tree_proxy.getDisplayText(index).c_str(), ImGuiTreeNodeFlags_OpenOnArrow); + + if (ImGui::IsItemClicked()) { + m_view_index = m_tree_proxy.toSourceIndex(index); + } + if (is_open) { for (size_t i = 0; i < m_tree_proxy.getRowCount(index); ++i) { ModelIndex child_index = m_tree_proxy.getIndex(i, 0, index); diff --git a/src/image/imagehandle.cpp b/src/image/imagehandle.cpp index 487e3041..1a3b1d4a 100644 --- a/src/image/imagehandle.cpp +++ b/src/image/imagehandle.cpp @@ -118,6 +118,7 @@ namespace Toolbox { } void ImageHandle::moveGL(ImageHandle &&image) { + unloadGL(); m_image_handle = image.m_image_handle; m_image_format = image.m_image_format; m_image_width = image.m_image_width; diff --git a/src/model/fsmodel.cpp b/src/model/fsmodel.cpp index a83bc593..ece9ba7e 100644 --- a/src/model/fsmodel.cpp +++ b/src/model/fsmodel.cpp @@ -110,6 +110,22 @@ namespace Toolbox { } } + void FileSystemModel::initialize() { + m_icon_map.clear(); + m_index_map.clear(); + m_root_path = fs_path(); + m_root_index = 0; + m_options = FileSystemModelOptions(); + m_read_only = false; + + fs_path fs_icon_path = + GUIApplication::instance().getResourcePath("Images/Icons/Filesystem/"); + + for (auto &[key, value] : TypeMap()) { + m_icon_map[key] = make_referable(fs_icon_path / value.m_image_name); + } + } + const fs_path &FileSystemModel::getRoot() const & { return m_root_path; } void FileSystemModel::setRoot(const fs_path &path) { @@ -384,8 +400,9 @@ namespace Toolbox { parent_data->m_children.end(), index.getUUID()), parent_data->m_children.end()); - m_index_map.erase(index.getUUID()); } + delete index.data<_FileSystemIndexData>(); + m_index_map.erase(index.getUUID()); } return result; @@ -428,8 +445,9 @@ namespace Toolbox { parent_data->m_children.end(), index.getUUID()), parent_data->m_children.end()); - m_index_map.erase(index.getUUID()); } + delete index.data<_FileSystemIndexData>(); + m_index_map.erase(index.getUUID()); } return result; @@ -449,12 +467,7 @@ namespace Toolbox { return ModelIndex(); } - ModelIndex FileSystemModel::getIndex(const UUID64 &uuid) const { - if (m_index_map.find(uuid) == m_index_map.end()) { - return ModelIndex(); - } - return m_index_map.at(uuid); - } + ModelIndex FileSystemModel::getIndex(const UUID64 &uuid) const { return m_index_map.at(uuid); } ModelIndex FileSystemModel::getIndex(int64_t row, int64_t column, const ModelIndex &parent) const { @@ -668,23 +681,17 @@ namespace Toolbox { std::string ext = data->m_path.extension().string(); if (!validateIndex(index)) { - data->m_icon = make_referable( - fs_icon_path / TypeMap().at("_Invalid").m_image_name); + data->m_icon = m_icon_map["_Invalid"]; } else if (data->m_type == _FileSystemIndexData::Type::DIRECTORY) { - data->m_icon = make_referable( - fs_icon_path / TypeMap().at("_Folder").m_image_name); + data->m_icon = m_icon_map["_Folder"]; } else if (data->m_type == _FileSystemIndexData::Type::ARCHIVE) { - data->m_icon = make_referable( - fs_icon_path / TypeMap().at("_Archive").m_image_name); + data->m_icon = m_icon_map["_Archive"]; } else if (ext.empty()) { - data->m_icon = make_referable( - fs_icon_path / TypeMap().at("_Folder").m_image_name); - } else if (TypeMap().find(ext) == TypeMap().end()) { - data->m_icon = make_referable( - fs_icon_path / TypeMap().at("_File").m_image_name); + data->m_icon = m_icon_map["_Folder"]; + } else if (m_icon_map.find(ext) == m_icon_map.end()) { + data->m_icon = m_icon_map["_File"]; } else { - data->m_icon = make_referable(fs_icon_path / - TypeMap().at(ext).m_image_name); + data->m_icon = m_icon_map[ext]; } } @@ -708,11 +715,6 @@ namespace Toolbox { return index; } - void FileSystemModel::cacheIndex(ModelIndex &index) {} - void FileSystemModel::cacheFolder(ModelIndex &index) {} - void FileSystemModel::cacheFile(ModelIndex &index) {} - void FileSystemModel::cacheArchive(ModelIndex &index) {} - ModelIndex FileSystemModel::getParentArchive(const ModelIndex &index) const { ModelIndex parent = getParent(index); do { @@ -866,19 +868,36 @@ namespace Toolbox { } fs_path FileSystemModelSortFilterProxy::getPath(const ModelIndex &index) const { - ModelIndex &&source_index = toSourceIndex(index); + ModelIndex source_index = toSourceIndex(index); return m_source_model->getPath(std::move(source_index)); } ModelIndex FileSystemModelSortFilterProxy::getParent(const ModelIndex &index) const { - ModelIndex &&source_index = toSourceIndex(index); + ModelIndex source_index = toSourceIndex(index); return toProxyIndex(m_source_model->getParent(std::move(source_index))); } ModelIndex FileSystemModelSortFilterProxy::getSibling(int64_t row, int64_t column, const ModelIndex &index) const { - ModelIndex &&source_index = toSourceIndex(index); - return toProxyIndex(m_source_model->getSibling(row, column, source_index)); + ModelIndex source_index = toSourceIndex(index); + ModelIndex src_parent = getParent(source_index); + const UUID64 &src_parent_uuid = src_parent.getUUID(); + + u64 map_key = src_parent_uuid; + if (!m_source_model->validateIndex(src_parent)) { + map_key = 0; + } + + if (m_row_map.find(map_key) == m_row_map.end()) { + cacheIndex(src_parent); + } + + if (row < m_row_map[map_key].size()) { + int64_t the_row = m_row_map[map_key][row]; + return toProxyIndex(m_source_model->getIndex(the_row, column, src_parent)); + } + + return ModelIndex(); } size_t FileSystemModelSortFilterProxy::getColumnCount(const ModelIndex &index) const { @@ -888,6 +907,11 @@ namespace Toolbox { size_t FileSystemModelSortFilterProxy::getRowCount(const ModelIndex &index) const { ModelIndex &&source_index = toSourceIndex(index); + + if (m_row_map.find(source_index.getUUID()) != m_row_map.end()) { + return m_row_map[source_index.getUUID()].size(); + } + return m_source_model->getRowCount(source_index); } @@ -943,32 +967,83 @@ namespace Toolbox { ModelIndex FileSystemModelSortFilterProxy::toProxyIndex(int64_t row, int64_t column, const ModelIndex &src_parent) const { - std::vector filtered_children = {}; + const UUID64 &src_parent_uuid = src_parent.getUUID(); + u64 map_key = src_parent_uuid; if (!m_source_model->validateIndex(src_parent)) { + map_key = 0; + } + + if (m_row_map.find(map_key) == m_row_map.end()) { + cacheIndex(src_parent); + } + + if (row < m_row_map[map_key].size()) { + int64_t the_row = m_row_map[map_key][row]; + return toProxyIndex(m_source_model->getIndex(the_row, column, src_parent)); + } + + return ModelIndex(); + } + + bool FileSystemModelSortFilterProxy::isFiltered(const UUID64 &uuid) const { + ModelIndex child_index = m_source_model->getIndex(uuid); + bool is_file = + child_index.data<_FileSystemIndexData>()->m_type == _FileSystemIndexData::Type::FILE; + + if (isDirsOnly() && is_file) { + return true; + } + + const std::string &name = child_index.data<_FileSystemIndexData>()->m_name; + return !name.starts_with(m_filter); + } + + void FileSystemModelSortFilterProxy::cacheIndex(const ModelIndex &dir_index) const { + std::vector orig_children = {}; + std::vector proxy_children = {}; + + const UUID64 &src_parent_uuid = dir_index.getUUID(); + + u64 map_key = src_parent_uuid; + if (!m_source_model->validateIndex(dir_index)) { + map_key = 0; + } + + if (m_row_map.find(map_key) != m_row_map.end()) { + return; + } + + if (!m_source_model->validateIndex(dir_index)) { size_t i = 0; ModelIndex root_s = m_source_model->getIndex(i++, 0); while (m_source_model->validateIndex(root_s)) { - filtered_children.push_back(root_s.getUUID()); + orig_children.push_back(root_s.getUUID()); + if (isFiltered(root_s.getUUID())) { + root_s = m_source_model->getIndex(i++, 0); + continue; + } + proxy_children.push_back(root_s.getUUID()); root_s = m_source_model->getIndex(i++, 0); } } else { - const std::vector &children = - src_parent.data<_FileSystemIndexData>()->m_children; - if (children.empty()) { - return ModelIndex(); + orig_children = dir_index.data<_FileSystemIndexData>()->m_children; + if (orig_children.empty()) { + return; } - filtered_children = children; + std::copy_if(orig_children.begin(), orig_children.end(), + std::back_inserter(proxy_children), + [&](const UUID64 &uuid) { return !isFiltered(uuid); }); } - if (row >= filtered_children.size()) { - return ModelIndex(); + if (proxy_children.empty()) { + return; } switch (m_sort_role) { case FileSystemModelSortRole::SORT_ROLE_NAME: { - std::sort(filtered_children.begin(), filtered_children.end(), + std::sort(proxy_children.begin(), proxy_children.end(), [&](const UUID64 &lhs, const UUID64 &rhs) { return _FileSystemIndexDataCompareByName( *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), @@ -978,7 +1053,7 @@ namespace Toolbox { break; } case FileSystemModelSortRole::SORT_ROLE_SIZE: { - std::sort(filtered_children.begin(), filtered_children.end(), + std::sort(proxy_children.begin(), proxy_children.end(), [&](const UUID64 &lhs, const UUID64 &rhs) { return _FileSystemIndexDataCompareBySize( *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), @@ -988,7 +1063,7 @@ namespace Toolbox { break; } case FileSystemModelSortRole::SORT_ROLE_DATE: - std::sort(filtered_children.begin(), filtered_children.end(), + std::sort(proxy_children.begin(), proxy_children.end(), [&](const UUID64 &lhs, const UUID64 &rhs) { return _FileSystemIndexDataCompareByDate( *m_source_model->getIndex(lhs).data<_FileSystemIndexData>(), @@ -1000,31 +1075,17 @@ namespace Toolbox { break; } - size_t i = 0; - for (const UUID64 &uuid : filtered_children) { - if (isFiltered(uuid)) { - continue; - } - if (i++ == row) { - ModelIndex src_index = m_source_model->getIndex(uuid); - return toProxyIndex(src_index); + // Build the row map + m_row_map[map_key] = {}; + m_row_map[map_key].resize(proxy_children.size()); + for (size_t i = 0; i < proxy_children.size(); i++) { + for (size_t j = 0; j < orig_children.size(); j++) { + if (proxy_children[i] == orig_children[j]) { + m_row_map[map_key][i] = j; + break; + } } } - - return ModelIndex(); - } - - bool FileSystemModelSortFilterProxy::isFiltered(const UUID64 &uuid) const { - ModelIndex child_index = m_source_model->getIndex(uuid); - bool is_file = - child_index.data<_FileSystemIndexData>()->m_type == _FileSystemIndexData::Type::FILE; - - if (isDirsOnly() && is_file) { - return true; - } - - const std::string &name = child_index.data<_FileSystemIndexData>()->m_name; - return !name.starts_with(m_filter); } } // namespace Toolbox \ No newline at end of file diff --git a/vcpkg.json b/vcpkg.json index a462341a..0087cda5 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -4,5 +4,5 @@ "dependencies": [ "libiconv" ], - "builtin-baseline": "5016afa7ed49f8bac5dc801555b7d6af9fe79f58" + "builtin-baseline": "036916f2ca7fbf3effec439119500da00ae478dd" } \ No newline at end of file From 7e6081118b7dd39e3f638f5f3e8c8ac28ea557ee Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Wed, 18 Sep 2024 09:21:35 -0700 Subject: [PATCH 013/129] Fix missing return on loadProjectFolder --- src/project/project.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/project/project.cpp b/src/project/project.cpp index 7ae7cd92..9fd8540b 100644 --- a/src/project/project.cpp +++ b/src/project/project.cpp @@ -31,6 +31,8 @@ namespace Toolbox { return Result(); }); + + return true; } fs_path ProjectManager::getProjectFolder() const { return m_project_folder; } From cd8383a7623b5d11e81c18d9af00496c232a0048 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Wed, 18 Sep 2024 10:32:44 -0700 Subject: [PATCH 014/129] Oops don't crash on empty dolphin paths --- src/dolphin/hook.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dolphin/hook.cpp b/src/dolphin/hook.cpp index 101e3558..42ee9dbf 100644 --- a/src/dolphin/hook.cpp +++ b/src/dolphin/hook.cpp @@ -180,8 +180,12 @@ namespace Toolbox::Dolphin { std::string dolphin_path = settings.m_dolphin_path.string(); size_t last_not_null = dolphin_path.find_last_not_of('\000'); - std::string used_substr = dolphin_path.substr(last_not_null - 5, last_not_null); - if (!used_substr.starts_with("-nogui"sv)){ + bool is_nogui = false; + if (last_not_null != std::string::npos && last_not_null > 5) { + std::string used_substr = dolphin_path.substr(last_not_null - 5, last_not_null); + is_nogui = used_substr.starts_with("-nogui"sv); + } + if (!is_nogui){ dolphin_args += "-d -c"; } #ifdef TOOLBOX_PLATFORM_LINUX From cd6bea5100edec8abd36ecf40d719deef0fd52de Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Wed, 18 Sep 2024 11:34:29 -0700 Subject: [PATCH 015/129] Type this buffer to fix some valgrind warnings --- include/core/memory.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/core/memory.hpp b/include/core/memory.hpp index c7d5e4d3..d6c7e27e 100644 --- a/include/core/memory.hpp +++ b/include/core/memory.hpp @@ -81,7 +81,7 @@ namespace Toolbox { if (m_buf && size == m_size) { return; } - void *new_buf = new u8[size]; + byte_t *new_buf = new byte_t[size]; if (m_buf && m_size > 0) { memcpy(new_buf, m_buf, std::min(size, m_size)); delete[] m_buf; @@ -98,9 +98,9 @@ namespace Toolbox { template const T *buf() const { return reinterpret_cast(m_buf); } void setBuf(void *buf, size_t size) { - if (m_buf != buf) { + if (m_buf != (byte_t*)buf) { free(); - m_buf = buf; + m_buf = (byte_t*)buf; m_owns_buf = false; } m_size = size; @@ -152,7 +152,7 @@ namespace Toolbox { bool operator==(const Buffer &other) { return m_buf == other.m_buf; } private: - void *m_buf = nullptr; + byte_t *m_buf = nullptr; size_t m_size = 0; bool m_owns_buf = true; }; From 5d5922167a8b08834ddf2ec21e860d06507499e2 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Thu, 19 Sep 2024 12:55:22 -0700 Subject: [PATCH 016/129] Fix memory leak of ModelIndex user data --- include/model/fsmodel.hpp | 2 +- src/model/fsmodel.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/model/fsmodel.hpp b/include/model/fsmodel.hpp index 4bca060d..e540e136 100644 --- a/include/model/fsmodel.hpp +++ b/include/model/fsmodel.hpp @@ -47,7 +47,7 @@ namespace Toolbox { public: FileSystemModel() = default; - ~FileSystemModel() = default; + ~FileSystemModel(); void initialize(); diff --git a/src/model/fsmodel.cpp b/src/model/fsmodel.cpp index ece9ba7e..3a4f5645 100644 --- a/src/model/fsmodel.cpp +++ b/src/model/fsmodel.cpp @@ -110,6 +110,12 @@ namespace Toolbox { } } + FileSystemModel::~FileSystemModel() { + for (auto &[key, value] : m_index_map) { + delete value.data<_FileSystemIndexData>(); + } + } + void FileSystemModel::initialize() { m_icon_map.clear(); m_index_map.clear(); From 1ddca44749d7328e6baeab84456a80842099080f Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Thu, 19 Sep 2024 13:50:37 -0700 Subject: [PATCH 017/129] Try reverting libiconv version upgrade to fix CI error --- vcpkg.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcpkg.json b/vcpkg.json index 0087cda5..a462341a 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -4,5 +4,5 @@ "dependencies": [ "libiconv" ], - "builtin-baseline": "036916f2ca7fbf3effec439119500da00ae478dd" + "builtin-baseline": "5016afa7ed49f8bac5dc801555b7d6af9fe79f58" } \ No newline at end of file From 14f182b3f8da4607e607d97816c547c6842969d3 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Fri, 20 Sep 2024 12:42:15 -0700 Subject: [PATCH 018/129] Remove dead code in fsmodel.cpp The fs_icon_path variable is never used in this function, and validateIndex is called at the top of the function and won't let the rest run if it returns false. --- src/model/fsmodel.cpp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/model/fsmodel.cpp b/src/model/fsmodel.cpp index 3a4f5645..b42dcea6 100644 --- a/src/model/fsmodel.cpp +++ b/src/model/fsmodel.cpp @@ -193,27 +193,15 @@ namespace Toolbox { return {}; } - fs_path fs_icon_path = - GUIApplication::instance().getResourcePath("Images/Icons/Filesystem/"); - switch (role) { case ModelDataRole::DATA_ROLE_DISPLAY: - if (!validateIndex(index)) { - return "Invalid"; - } return index.data<_FileSystemIndexData>()->m_name; case ModelDataRole::DATA_ROLE_TOOLTIP: return "Tooltip unimplemented!"; case ModelDataRole::DATA_ROLE_DECORATION: { - if (!validateIndex(index)) { - return RefPtr(nullptr); - } return index.data<_FileSystemIndexData>()->m_icon; } case FileSystemDataRole::FS_DATA_ROLE_DATE: { - if (!validateIndex(index)) { - return Filesystem::file_time_type(); - } Filesystem::file_time_type result = Filesystem::file_time_type(); @@ -232,9 +220,6 @@ namespace Toolbox { return result; } case FileSystemDataRole::FS_DATA_ROLE_STATUS: { - if (!validateIndex(index)) { - return Filesystem::file_status(); - } Filesystem::file_status result = Filesystem::file_status(); @@ -253,9 +238,6 @@ namespace Toolbox { return result; } case FileSystemDataRole::FS_DATA_ROLE_TYPE: { - if (!validateIndex(index)) { - return TypeMap().at("_Invalid").m_name; - } if (isDirectory(index)) { return TypeMap().at("_Folder").m_name; From 9008c951c403cf236ec478b5ef804b6858049e6c Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Fri, 20 Sep 2024 13:01:36 -0700 Subject: [PATCH 019/129] Small reuse of a variable --- src/gui/project/window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 108f3a4a..20bbe336 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -71,7 +71,7 @@ namespace Toolbox::UI { ImGui::RenderTextEllipsis( ImGui::GetWindowDrawList(), pos, pos + ImVec2(64, 20), pos.x + 64.0f, - pos.x + 76.0f, m_file_system_model->getDisplayText(child_index).c_str(), + pos.x + 76.0f, text.c_str(), nullptr, nullptr); } ImGui::EndChild(); From 115530a03a0c1143c16132af4bc71f93f4f0b248 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Fri, 20 Sep 2024 14:40:57 -0700 Subject: [PATCH 020/129] Allow entering folders through double click in folder view (project) --- include/gui/project/window.hpp | 1 + src/gui/project/window.cpp | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 95fd05a1..8bd7653f 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -41,6 +41,7 @@ namespace Toolbox::UI { void renderProjectFolderButton(); void renderProjectFileButton(); + bool isViewedAncestor(const ModelIndex &index); void renderFolderTree(const ModelIndex &index); void initFolderAssets(const ModelIndex &index); diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 20bbe336..7d9dad3c 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -68,6 +68,11 @@ namespace Toolbox::UI { ImVec2 pos = ImGui::GetCursorScreenPos(); pos.x += std::max(36.0f - (text_size.x / 2.0f), 0.0); pos.y += 72.0f; + if (ImGui::IsMouseDoubleClicked(0) && + ImGui::IsItemHovered(ImGuiHoveredFlags_None) && + m_file_system_model->isDirectory(child_index)) { + m_view_index = m_tree_proxy.toSourceIndex(child_index); + } ImGui::RenderTextEllipsis( ImGui::GetWindowDrawList(), pos, pos + ImVec2(64, 20), pos.x + 64.0f, @@ -105,14 +110,32 @@ namespace Toolbox::UI { void ProjectViewWindow::onDropEvent(RefPtr ev) {} + bool ProjectViewWindow::isViewedAncestor(const ModelIndex &index) { + if (m_view_index == m_tree_proxy.toSourceIndex(index)) { + return true; + } + for (size_t i = 0; i < m_tree_proxy.getRowCount(index); ++i) { + ModelIndex child_index = m_tree_proxy.getIndex(i, 0, index); + if (isViewedAncestor(child_index)) { + return true; + } + } + return false; + } + void ProjectViewWindow::renderFolderTree(const ModelIndex &index) { bool is_open = false; if (m_tree_proxy.hasChildren(index)) { if (m_tree_proxy.canFetchMore(index)) { m_tree_proxy.fetchMore(index); } + ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_OpenOnArrow; + + if (isViewedAncestor(index)) { + flags |= ImGuiTreeNodeFlags_DefaultOpen; + } is_open = ImGui::TreeNodeEx(m_tree_proxy.getDisplayText(index).c_str(), - ImGuiTreeNodeFlags_OpenOnArrow); + flags); if (ImGui::IsItemClicked()) { m_view_index = m_tree_proxy.toSourceIndex(index); From 73cf5eda1e013cf62f1e02d337227e6967a46ff1 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Fri, 20 Sep 2024 14:41:27 -0700 Subject: [PATCH 021/129] Add an indicator of which tree folder is open in folder view --- src/gui/project/window.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 7d9dad3c..6587863f 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -131,6 +131,9 @@ namespace Toolbox::UI { } ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_OpenOnArrow; + if (m_view_index == m_tree_proxy.toSourceIndex(index)){ + flags |= ImGuiTreeNodeFlags_Selected; + } if (isViewedAncestor(index)) { flags |= ImGuiTreeNodeFlags_DefaultOpen; } From 30bff8a9fcc014e46b47719e4b3bb68fbf470c28 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Fri, 20 Sep 2024 14:42:21 -0700 Subject: [PATCH 022/129] Add selection of items in folder view Is just visual so far though, can't do anything with it. --- include/gui/project/window.hpp | 1 + src/gui/project/window.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 8bd7653f..9c3e211e 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -114,6 +114,7 @@ namespace Toolbox::UI { std::vector m_selected_indices; std::vector m_view_assets; ModelIndex m_view_index; + ModelIndex m_selected_index; std::unordered_map m_icon_map; ImagePainter m_icon_painter; diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 6587863f..0385d61d 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -56,6 +56,13 @@ namespace Toolbox::UI { for (size_t i = 0; i < m_file_system_model->getRowCount(m_view_index); ++i) { ModelIndex child_index = m_file_system_model->getIndex(i, 0, m_view_index); + if (m_selected_index == m_tree_proxy.toSourceIndex(child_index)){ + ImGui::PushStyleColor(ImGuiCol_ChildBg, ImGui::ColorConvertFloat4ToU32(ImGui::GetStyleColorVec4(ImGuiCol_TabSelected))); + } else { + ImGui::PushStyleColor(ImGuiCol_ChildBg, + ImGui::ColorConvertFloat4ToU32(ImGui::GetStyleColorVec4(ImGuiCol_ChildBg))); + + } if (ImGui::BeginChild(child_index.getUUID(), {76, 92}, true, ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { @@ -73,6 +80,12 @@ namespace Toolbox::UI { m_file_system_model->isDirectory(child_index)) { m_view_index = m_tree_proxy.toSourceIndex(child_index); } + else if (ImGui::IsItemClicked()) { + m_selected_index = m_tree_proxy.toSourceIndex(child_index); + } else if (ImGui::IsMouseClicked(0) && + m_selected_index == m_tree_proxy.toSourceIndex(child_index)) { + m_selected_index = ModelIndex(); + } ImGui::RenderTextEllipsis( ImGui::GetWindowDrawList(), pos, pos + ImVec2(64, 20), pos.x + 64.0f, @@ -80,6 +93,7 @@ namespace Toolbox::UI { nullptr, nullptr); } ImGui::EndChild(); + ImGui::PopStyleColor(1); // ImGui::Text("%s", m_view_proxy.getDisplayText(child_index).c_str()); From 6cca6bbe9f46ba792389af491704fcabb8bbf9a9 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Fri, 20 Sep 2024 15:19:19 -0700 Subject: [PATCH 023/129] Add multi-select Also, it turns out there was already a member variable for tracking the selection, so remove the one I added and use that instead. --- include/gui/project/window.hpp | 1 - src/gui/project/window.cpp | 20 +++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 9c3e211e..8bd7653f 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -114,7 +114,6 @@ namespace Toolbox::UI { std::vector m_selected_indices; std::vector m_view_assets; ModelIndex m_view_index; - ModelIndex m_selected_index; std::unordered_map m_icon_map; ImagePainter m_icon_painter; diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 0385d61d..d9cec9ca 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -55,8 +55,12 @@ namespace Toolbox::UI { for (size_t i = 0; i < m_file_system_model->getRowCount(m_view_index); ++i) { ModelIndex child_index = m_file_system_model->getIndex(i, 0, m_view_index); + bool is_selected = + std::find(m_selected_indices.begin(), m_selected_indices.end(), + m_tree_proxy.toSourceIndex(child_index)) != + m_selected_indices.end(); - if (m_selected_index == m_tree_proxy.toSourceIndex(child_index)){ + if (is_selected) { ImGui::PushStyleColor(ImGuiCol_ChildBg, ImGui::ColorConvertFloat4ToU32(ImGui::GetStyleColorVec4(ImGuiCol_TabSelected))); } else { ImGui::PushStyleColor(ImGuiCol_ChildBg, @@ -79,12 +83,14 @@ namespace Toolbox::UI { ImGui::IsItemHovered(ImGuiHoveredFlags_None) && m_file_system_model->isDirectory(child_index)) { m_view_index = m_tree_proxy.toSourceIndex(child_index); - } - else if (ImGui::IsItemClicked()) { - m_selected_index = m_tree_proxy.toSourceIndex(child_index); - } else if (ImGui::IsMouseClicked(0) && - m_selected_index == m_tree_proxy.toSourceIndex(child_index)) { - m_selected_index = ModelIndex(); + } else if (ImGui::IsItemClicked()) { + if (!ImGui::IsKeyDown(ImGuiMod_Ctrl)) { + m_selected_indices.clear(); + } + m_selected_indices.push_back(m_tree_proxy.toSourceIndex(child_index)); + } else if (ImGui::IsMouseClicked(0) && is_selected && + !ImGui::IsKeyDown(ImGuiMod_Ctrl)) { + m_selected_indices.clear(); } ImGui::RenderTextEllipsis( From 84078df520e5bdbe8e42cd23246032e7ff7c32f1 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Sun, 22 Sep 2024 09:54:25 -0500 Subject: [PATCH 024/129] Handle a warning and optimize semantics --- src/gui/application.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 33a5f087..107af960 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -559,11 +559,11 @@ namespace Toolbox { int num_filters = 0; nfdu8filteritem_t *nfd_filters = nullptr; if (maybe_filters) { - auto filters = maybe_filters.value(); + FileDialogFilter filters = std::move(maybe_filters.value()); num_filters = filters.numFilters(); filters.copyFiltersOutU8(m_filters); nfd_filters = new nfdu8filteritem_t[num_filters]; - for (int i = 0; i < filters.numFilters(); ++i){ + for (int i = 0; i < num_filters; ++i) { nfd_filters[i] = {m_filters[i].first.c_str(), m_filters[i].second.c_str()}; } } From e5c03d1b2f42fc16cf42ab974b1e43cd2860f181 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Sun, 22 Sep 2024 10:02:24 -0500 Subject: [PATCH 025/129] Set methods to const and initialize members on construct for FileDialog --- include/gui/application.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/gui/application.hpp b/include/gui/application.hpp index 44039c33..aa31395f 100644 --- a/include/gui/application.hpp +++ b/include/gui/application.hpp @@ -211,10 +211,10 @@ namespace Toolbox { bool is_directory = false, std::optional maybe_filters = std::nullopt); - bool isAlreadyOpen() { return m_thread_running; } - bool isDone() { return !m_thread_running && !m_closed && m_thread_initialized; } - bool isOk() { return m_result == NFD_OKAY; } - std::filesystem::path getFilenameResult() { return m_selected_path; } + bool isAlreadyOpen() const { return m_thread_running; } + bool isDone() const { return !m_thread_running && !m_closed && m_thread_initialized; } + bool isOk() const { return m_result == NFD_OKAY; } + std::filesystem::path getFilenameResult() const { return m_selected_path; } void close() { m_closed = true; } private: @@ -222,8 +222,8 @@ namespace Toolbox { std::vector> m_filters; // The result of the last dialog box. - nfdu8char_t *m_selected_path; - nfdresult_t m_result; + nfdu8char_t *m_selected_path = nullptr; + nfdresult_t m_result = NFD_OKAY; // The thread that we run the dialog in. If // m_thread_initialized is true, this should be an initialized // thread object. From 2d8a9f5efa7fa69dcfe2ccd552ce506bf07948a5 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Wed, 25 Sep 2024 13:29:02 -0700 Subject: [PATCH 026/129] Clicking on the text label area also selects item --- src/gui/project/window.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index d9cec9ca..9f951bfb 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -79,19 +79,6 @@ namespace Toolbox::UI { ImVec2 pos = ImGui::GetCursorScreenPos(); pos.x += std::max(36.0f - (text_size.x / 2.0f), 0.0); pos.y += 72.0f; - if (ImGui::IsMouseDoubleClicked(0) && - ImGui::IsItemHovered(ImGuiHoveredFlags_None) && - m_file_system_model->isDirectory(child_index)) { - m_view_index = m_tree_proxy.toSourceIndex(child_index); - } else if (ImGui::IsItemClicked()) { - if (!ImGui::IsKeyDown(ImGuiMod_Ctrl)) { - m_selected_indices.clear(); - } - m_selected_indices.push_back(m_tree_proxy.toSourceIndex(child_index)); - } else if (ImGui::IsMouseClicked(0) && is_selected && - !ImGui::IsKeyDown(ImGuiMod_Ctrl)) { - m_selected_indices.clear(); - } ImGui::RenderTextEllipsis( ImGui::GetWindowDrawList(), pos, pos + ImVec2(64, 20), pos.x + 64.0f, @@ -100,6 +87,19 @@ namespace Toolbox::UI { } ImGui::EndChild(); ImGui::PopStyleColor(1); + if (ImGui::IsMouseDoubleClicked(0) && + ImGui::IsItemHovered(ImGuiHoveredFlags_None) && + m_file_system_model->isDirectory(child_index)) { + m_view_index = m_tree_proxy.toSourceIndex(child_index); + } else if (ImGui::IsItemClicked()) { + if (!ImGui::IsKeyDown(ImGuiMod_Ctrl)) { + m_selected_indices.clear(); + } + m_selected_indices.push_back(m_tree_proxy.toSourceIndex(child_index)); + } else if (ImGui::IsMouseClicked(0) && is_selected && + !ImGui::IsKeyDown(ImGuiMod_Ctrl)) { + m_selected_indices.clear(); + } // ImGui::Text("%s", m_view_proxy.getDisplayText(child_index).c_str()); From 5cc02b972b53e8691d158943db28948017eaaaa0 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Thu, 26 Sep 2024 17:24:49 -0700 Subject: [PATCH 027/129] Add ability to rename files in project manager --- include/gui/project/window.hpp | 2 ++ include/model/fsmodel.hpp | 1 + src/gui/project/window.cpp | 52 +++++++++++++++++++++++++--------- src/model/fsmodel.cpp | 28 ++++++++++++++++++ 4 files changed, 70 insertions(+), 13 deletions(-) diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 8bd7653f..81623226 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -114,6 +114,8 @@ namespace Toolbox::UI { std::vector m_selected_indices; std::vector m_view_assets; ModelIndex m_view_index; + bool m_is_renaming = false; + char m_rename_buffer[128]; std::unordered_map m_icon_map; ImagePainter m_icon_painter; diff --git a/include/model/fsmodel.hpp b/include/model/fsmodel.hpp index e540e136..2536f64d 100644 --- a/include/model/fsmodel.hpp +++ b/include/model/fsmodel.hpp @@ -87,6 +87,7 @@ namespace Toolbox { ModelIndex mkdir(const ModelIndex &parent, const std::string &name); ModelIndex touch(const ModelIndex &parent, const std::string &name); + ModelIndex rename(const ModelIndex &file, const std::string &new_name); bool rmdir(const ModelIndex &index); bool remove(const ModelIndex &index); diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 9f951bfb..d2d8d555 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -68,6 +68,8 @@ namespace Toolbox::UI { } if (ImGui::BeginChild(child_index.getUUID(), {76, 92}, true, + bool inputTextHovered = false; + ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { @@ -77,27 +79,51 @@ namespace Toolbox::UI { ImVec2 text_size = ImGui::CalcTextSize(text.c_str()); ImVec2 pos = ImGui::GetCursorScreenPos(); - pos.x += std::max(36.0f - (text_size.x / 2.0f), 0.0); - pos.y += 72.0f; - - ImGui::RenderTextEllipsis( - ImGui::GetWindowDrawList(), pos, pos + ImVec2(64, 20), pos.x + 64.0f, - pos.x + 76.0f, text.c_str(), - nullptr, nullptr); + ImVec2 newPos = pos; + newPos.x += std::max(36.0f - (text_size.x / 2.0f), 0.0); + newPos.y += 72.0f; + if (m_is_renaming && is_selected) { + ImGui::SetCursorScreenPos(newPos); + ImGui::SetKeyboardFocusHere(); + bool done = ImGui::InputText("##", m_rename_buffer, + IM_ARRAYSIZE(m_rename_buffer), + ImGuiInputTextFlags_AutoSelectAll + | ImGuiInputTextFlags_EnterReturnsTrue); + if (done) { + m_file_system_model->rename(child_index, m_rename_buffer); + } + ImGui::SetCursorScreenPos(pos); + } else { + ImGui::RenderTextEllipsis( + ImGui::GetWindowDrawList(), newPos, newPos + ImVec2(64, 20), pos.x + 64.0f, + newPos.x + 76.0f, text.c_str(), + nullptr, nullptr); + } + inputTextHovered = ImGui::IsItemHovered(); } ImGui::EndChild(); ImGui::PopStyleColor(1); + + // Handle click responses if (ImGui::IsMouseDoubleClicked(0) && - ImGui::IsItemHovered(ImGuiHoveredFlags_None) && + ImGui::IsWindowHovered(ImGuiHoveredFlags_None) && m_file_system_model->isDirectory(child_index)) { m_view_index = m_tree_proxy.toSourceIndex(child_index); - } else if (ImGui::IsItemClicked()) { - if (!ImGui::IsKeyDown(ImGuiMod_Ctrl)) { - m_selected_indices.clear(); + } else if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(0)) { + if (is_selected){ + m_is_renaming = true; + std::strncpy(m_rename_buffer, text.c_str(), + IM_ARRAYSIZE(m_rename_buffer)); + } else { + if (!ImGui::IsKeyDown(ImGuiMod_Ctrl)) { + m_selected_indices.clear(); + } + m_is_renaming = false; + m_selected_indices.push_back(m_tree_proxy.toSourceIndex(child_index)); } - m_selected_indices.push_back(m_tree_proxy.toSourceIndex(child_index)); } else if (ImGui::IsMouseClicked(0) && is_selected && - !ImGui::IsKeyDown(ImGuiMod_Ctrl)) { + !ImGui::IsKeyDown(ImGuiMod_Ctrl) && !inputTextHovered) { + m_is_renaming = false; m_selected_indices.clear(); } diff --git a/src/model/fsmodel.cpp b/src/model/fsmodel.cpp index b42dcea6..9324a5d2 100644 --- a/src/model/fsmodel.cpp +++ b/src/model/fsmodel.cpp @@ -441,6 +441,34 @@ namespace Toolbox { return result; } + ModelIndex FileSystemModel::rename(const ModelIndex &file, const std::string &new_name){ + if (!validateIndex(file)) { + return ModelIndex(); + } + if (!isDirectory(file) && !isFile(file)) { + TOOLBOX_ERROR("[FileSystemModel] Not a directory or file!"); + return ModelIndex(); + } + fs_path from = file.data<_FileSystemIndexData>()->m_path; + fs_path to = from.parent_path() / new_name; + ModelIndex parent = getParent(file); + _FileSystemIndexData *parent_data = parent.data<_FileSystemIndexData>(); + + int dest_index = + std::find(parent_data->m_children.begin(), parent_data->m_children.end(), file.getUUID()) - + parent_data->m_children.begin(); + + Filesystem::rename(from, to); + + delete file.data<_FileSystemIndexData>(); + m_index_map.erase(file.getUUID()); + parent_data->m_children.erase(std::remove(parent_data->m_children.begin(), + parent_data->m_children.end(), + file.getUUID()), + parent_data->m_children.end()); + return makeIndex(to, dest_index, parent); + } + ModelIndex FileSystemModel::getIndex(const fs_path &path) const { if (m_index_map.empty()) { return ModelIndex(); From 1b815fce55d62c5c13dc303dfe294d04f3448799 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Thu, 26 Sep 2024 17:30:08 -0700 Subject: [PATCH 028/129] Oops partial commits are hard --- src/gui/project/window.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index d2d8d555..99564a4c 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -67,15 +67,14 @@ namespace Toolbox::UI { ImGui::ColorConvertFloat4ToU32(ImGui::GetStyleColorVec4(ImGuiCol_ChildBg))); } - if (ImGui::BeginChild(child_index.getUUID(), {76, 92}, true, bool inputTextHovered = false; - + std::string text = m_file_system_model->getDisplayText(child_index); + if (ImGui::BeginChild(child_index.getUUID(), {76, 92}, true, ImGuiWindowFlags_ChildWindow | - ImGuiWindowFlags_NoDecoration)) { + ImGuiWindowFlags_NoDecoration)) { m_icon_painter.render(*m_file_system_model->getDecoration(child_index), {72, 72}); - std::string text = m_file_system_model->getDisplayText(child_index); ImVec2 text_size = ImGui::CalcTextSize(text.c_str()); ImVec2 pos = ImGui::GetCursorScreenPos(); From 6a1bb1d5460bffbf4e00e177fefccf6af5e53f13 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Thu, 26 Sep 2024 17:49:48 -0700 Subject: [PATCH 029/129] Some nicer box sizes for renaming --- src/gui/project/window.cpp | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 99564a4c..2728de3e 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -4,6 +4,15 @@ #include #include +#if defined(__linux__) +inline int max(int x, int y){ + return x < y ? y : x; +} +inline int min(int x, int y){ + return x < y ? x : y; +} +#endif + namespace Toolbox::UI { ProjectViewWindow::ProjectViewWindow(const std::string &name) : ImWindow(name) {} @@ -67,24 +76,35 @@ namespace Toolbox::UI { ImGui::ColorConvertFloat4ToU32(ImGui::GetStyleColorVec4(ImGuiCol_ChildBg))); } - bool inputTextHovered = false; + // Get the label and it's size std::string text = m_file_system_model->getDisplayText(child_index); - if (ImGui::BeginChild(child_index.getUUID(), {76, 92}, true, + ImVec2 text_size = ImGui::CalcTextSize(text.c_str()); + ImVec2 rename_size = ImGui::CalcTextSize(m_rename_buffer); + + int box_width = m_is_renaming && is_selected ? max(rename_size.x,76) : 76; + bool inputTextHovered = false; + + if (ImGui::BeginChild(child_index.getUUID(), {box_width, 92}, true, ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { + // Render the icon m_icon_painter.render(*m_file_system_model->getDecoration(child_index), {72, 72}); - ImVec2 text_size = ImGui::CalcTextSize(text.c_str()); - + // Render the label ImVec2 pos = ImGui::GetCursorScreenPos(); ImVec2 newPos = pos; - newPos.x += std::max(36.0f - (text_size.x / 2.0f), 0.0); + newPos.x += std::max( + 36.0f - + (((m_is_renaming && is_selected) ? max(rename_size.x, 40) : text_size.x) / + 2.0f), + 0.0); newPos.y += 72.0f; if (m_is_renaming && is_selected) { ImGui::SetCursorScreenPos(newPos); ImGui::SetKeyboardFocusHere(); - bool done = ImGui::InputText("##", m_rename_buffer, + ImGui::PushItemWidth(max(rename_size.x, 40)); + bool done = ImGui::InputText("##rename", m_rename_buffer, IM_ARRAYSIZE(m_rename_buffer), ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_EnterReturnsTrue); @@ -92,6 +112,7 @@ namespace Toolbox::UI { m_file_system_model->rename(child_index, m_rename_buffer); } ImGui::SetCursorScreenPos(pos); + ImGui::PopItemWidth(); } else { ImGui::RenderTextEllipsis( ImGui::GetWindowDrawList(), newPos, newPos + ImVec2(64, 20), pos.x + 64.0f, @@ -208,4 +229,4 @@ namespace Toolbox::UI { void ProjectViewWindow::initFolderAssets(const ModelIndex &index) {} -} // namespace Toolbox::UI \ No newline at end of file +} // namespace Toolbox::UI From c963954d7b5e82b21a7a362c8f096090ac301236 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Fri, 27 Sep 2024 13:37:24 -0700 Subject: [PATCH 030/129] Fix folder navigation in the presence of renaming --- src/gui/project/window.cpp | 72 +++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 28 deletions(-) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 2728de3e..85e00560 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -61,12 +61,12 @@ namespace Toolbox::UI { if (x_count == 0) { x_count = 1; } + bool any_items_hovered = false; for (size_t i = 0; i < m_file_system_model->getRowCount(m_view_index); ++i) { ModelIndex child_index = m_file_system_model->getIndex(i, 0, m_view_index); bool is_selected = - std::find(m_selected_indices.begin(), m_selected_indices.end(), - m_tree_proxy.toSourceIndex(child_index)) != + std::find(m_selected_indices.begin(), m_selected_indices.end(), child_index) != m_selected_indices.end(); if (is_selected) { @@ -82,8 +82,6 @@ namespace Toolbox::UI { ImVec2 rename_size = ImGui::CalcTextSize(m_rename_buffer); int box_width = m_is_renaming && is_selected ? max(rename_size.x,76) : 76; - bool inputTextHovered = false; - if (ImGui::BeginChild(child_index.getUUID(), {box_width, 92}, true, ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { @@ -119,33 +117,45 @@ namespace Toolbox::UI { newPos.x + 76.0f, text.c_str(), nullptr, nullptr); } - inputTextHovered = ImGui::IsItemHovered(); - } - ImGui::EndChild(); - ImGui::PopStyleColor(1); - - // Handle click responses - if (ImGui::IsMouseDoubleClicked(0) && - ImGui::IsWindowHovered(ImGuiHoveredFlags_None) && - m_file_system_model->isDirectory(child_index)) { - m_view_index = m_tree_proxy.toSourceIndex(child_index); - } else if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(0)) { - if (is_selected){ - m_is_renaming = true; - std::strncpy(m_rename_buffer, text.c_str(), - IM_ARRAYSIZE(m_rename_buffer)); - } else { - if (!ImGui::IsKeyDown(ImGuiMod_Ctrl)) { - m_selected_indices.clear(); + any_items_hovered = any_items_hovered || ImGui::IsItemHovered() || ImGui::IsWindowHovered(ImGuiHoveredFlags_None); + // Handle click responses + if (ImGui::IsWindowHovered(ImGuiHoveredFlags_None)) { + if (ImGui::IsMouseDoubleClicked(0)) { + if (m_file_system_model->isDirectory(child_index)) { + m_view_index = m_tree_proxy.toSourceIndex(child_index); + } + m_is_renaming = false; + } else if (ImGui::IsMouseClicked(0)) { + TOOLBOX_INFO("Got a click on item"); + if (is_selected){ + TOOLBOX_INFO("Item was already selected"); + if (ImGui::IsKeyDown(ImGuiMod_Ctrl)) { + m_selected_indices.erase(std::find( + m_selected_indices.begin(), m_selected_indices.end(), + child_index)); + m_is_renaming = false; + } else { + TOOLBOX_INFO("Control key is not down"); + m_is_renaming = true; + std::strncpy(m_rename_buffer, text.c_str(), + IM_ARRAYSIZE(m_rename_buffer)); + } + } else { + TOOLBOX_INFO("Item wasn't already selected, selecting now."); + TOOLBOX_INFO_V("There are {} selected indices", + m_selected_indices.size()); + if (!ImGui::IsKeyDown(ImGuiMod_Ctrl)) { + m_selected_indices.clear(); + } + m_selected_indices.push_back( + child_index); + m_is_renaming = false; + } } - m_is_renaming = false; - m_selected_indices.push_back(m_tree_proxy.toSourceIndex(child_index)); } - } else if (ImGui::IsMouseClicked(0) && is_selected && - !ImGui::IsKeyDown(ImGuiMod_Ctrl) && !inputTextHovered) { - m_is_renaming = false; - m_selected_indices.clear(); } + ImGui::EndChild(); + ImGui::PopStyleColor(1); // ImGui::Text("%s", m_view_proxy.getDisplayText(child_index).c_str()); @@ -154,6 +164,12 @@ namespace Toolbox::UI { } } + // Clearing the selection + if (!any_items_hovered && ImGui::IsMouseClicked(0)) { + TOOLBOX_INFO("No items are hovered and there was a click, clearing selection"); + m_selected_indices.clear(); + m_is_renaming = false; + } ImGui::PopStyleVar(4); } } From b509efd594e4c2f77ceef131edecf0bca078bcc1 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Fri, 27 Sep 2024 13:42:08 -0700 Subject: [PATCH 031/129] Replace custom min/max with std:: versions --- src/gui/project/window.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 85e00560..1b233ed3 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -4,15 +4,6 @@ #include #include -#if defined(__linux__) -inline int max(int x, int y){ - return x < y ? y : x; -} -inline int min(int x, int y){ - return x < y ? x : y; -} -#endif - namespace Toolbox::UI { ProjectViewWindow::ProjectViewWindow(const std::string &name) : ImWindow(name) {} @@ -81,7 +72,7 @@ namespace Toolbox::UI { ImVec2 text_size = ImGui::CalcTextSize(text.c_str()); ImVec2 rename_size = ImGui::CalcTextSize(m_rename_buffer); - int box_width = m_is_renaming && is_selected ? max(rename_size.x,76) : 76; + int box_width = m_is_renaming && is_selected ? std::max(rename_size.x,76.0f) : 76; if (ImGui::BeginChild(child_index.getUUID(), {box_width, 92}, true, ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { @@ -94,14 +85,14 @@ namespace Toolbox::UI { ImVec2 newPos = pos; newPos.x += std::max( 36.0f - - (((m_is_renaming && is_selected) ? max(rename_size.x, 40) : text_size.x) / + (((m_is_renaming && is_selected) ? std::max(rename_size.x, 40.0f) : text_size.x) / 2.0f), 0.0); newPos.y += 72.0f; if (m_is_renaming && is_selected) { ImGui::SetCursorScreenPos(newPos); ImGui::SetKeyboardFocusHere(); - ImGui::PushItemWidth(max(rename_size.x, 40)); + ImGui::PushItemWidth(std::max(rename_size.x, 40.0f)); bool done = ImGui::InputText("##rename", m_rename_buffer, IM_ARRAYSIZE(m_rename_buffer), ImGuiInputTextFlags_AutoSelectAll From f3dbb5c9e53e93cd7f1e3632a83333f10fd701ce Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Fri, 27 Sep 2024 15:58:01 -0500 Subject: [PATCH 032/129] Fix memory leak and performance issue with proxy model --- include/gui/pad/window.hpp | 2 +- include/gui/project/window.hpp | 2 ++ include/model/fsmodel.cpp | 0 include/model/fsmodel.hpp | 2 ++ include/resource/resource.hpp | 6 ++--- src/gui/application.cpp | 6 ++--- src/gui/project/window.cpp | 48 ++++++++++++++++++---------------- src/model/fsmodel.cpp | 39 ++++++++++++++++----------- src/resource/resource.cpp | 28 ++++++++++---------- 9 files changed, 75 insertions(+), 58 deletions(-) create mode 100644 include/model/fsmodel.cpp diff --git a/include/gui/pad/window.hpp b/include/gui/pad/window.hpp index 5f48e7d0..3951988c 100644 --- a/include/gui/pad/window.hpp +++ b/include/gui/pad/window.hpp @@ -153,7 +153,7 @@ namespace Toolbox::UI { CreateLinkDialog m_create_link_dialog; - RefPtr m_dolphin_logo; + RefPtr m_dolphin_logo; ImagePainter m_image_painter; }; diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 81623226..d3306dda 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -119,6 +119,8 @@ namespace Toolbox::UI { std::unordered_map m_icon_map; ImagePainter m_icon_painter; + + std::unordered_map m_text_sizes; }; } // namespace Toolbox::UI \ No newline at end of file diff --git a/include/model/fsmodel.cpp b/include/model/fsmodel.cpp new file mode 100644 index 00000000..e69de29b diff --git a/include/model/fsmodel.hpp b/include/model/fsmodel.hpp index 2536f64d..3b8a8d9d 100644 --- a/include/model/fsmodel.hpp +++ b/include/model/fsmodel.hpp @@ -213,6 +213,8 @@ namespace Toolbox { [[nodiscard]] ModelIndex toSourceIndex(const ModelIndex &index) const; [[nodiscard]] ModelIndex toProxyIndex(const ModelIndex &index) const; + [[nodiscard]] UUID64 getSourceUUID(const ModelIndex &index) const; + protected: [[nodiscard]] ModelIndex toProxyIndex(int64_t row, int64_t column, const ModelIndex &parent = ModelIndex()) const; diff --git a/include/resource/resource.hpp b/include/resource/resource.hpp index dcfa6a52..9ccf0037 100644 --- a/include/resource/resource.hpp +++ b/include/resource/resource.hpp @@ -73,9 +73,9 @@ namespace Toolbox { const UUID64 &resource_path_uuid = 0) const; [[nodiscard]] bool hasDataPath(fs_path &&path, const UUID64 &resource_path_uuid = 0) const; - [[nodiscard]] Result, FSError> + [[nodiscard]] Result, FSError> getImageHandle(const fs_path &path, const UUID64 &resource_path_uuid = 0) const; - [[nodiscard]] Result, FSError> + [[nodiscard]] Result, FSError> getImageHandle(fs_path &&path, const UUID64 &resource_path_uuid = 0) const; [[nodiscard]] Result @@ -105,7 +105,7 @@ namespace Toolbox { UUID64 m_uuid; std::vector m_resource_paths; - mutable std::unordered_map> m_image_handle_cache; + mutable std::unordered_map> m_image_handle_cache; mutable std::unordered_map m_data_preload_cache; }; diff --git a/src/gui/application.cpp b/src/gui/application.cpp index bacb619d..621de2be 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -88,7 +88,8 @@ namespace Toolbox { m_resource_manager.includeResourcePath(cwd / "Fonts", true); m_resource_manager.includeResourcePath(cwd / "Images", true); m_resource_manager.includeResourcePath(cwd / "Images", true); - m_resource_manager.includeResourcePath(cwd / fs_path("Images") / "Icons", true); + m_resource_manager.includeResourcePath(cwd / "Images/Icons", true); + m_resource_manager.includeResourcePath(cwd / "Images/Icons/Filesystem", true); m_resource_manager.includeResourcePath(cwd / "Templates", false); m_resource_manager.includeResourcePath(cwd / "Themes", true); } @@ -190,7 +191,6 @@ namespace Toolbox { m_task_communicator.tStart(false, nullptr); - createWindow("Application Log"); determineEnvironmentConflicts(); @@ -580,7 +580,7 @@ namespace Toolbox { nfdu8filteritem_t *nfd_filters = nullptr; if (maybe_filters) { FileDialogFilter filters = std::move(maybe_filters.value()); - num_filters = filters.numFilters(); + num_filters = filters.numFilters(); filters.copyFiltersOutU8(m_filters); nfd_filters = new nfdu8filteritem_t[num_filters]; for (int i = 0; i < num_filters; ++i) { diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index d2d8d555..4ecab832 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -53,32 +53,37 @@ namespace Toolbox::UI { x_count = 1; } - for (size_t i = 0; i < m_file_system_model->getRowCount(m_view_index); ++i) { - ModelIndex child_index = m_file_system_model->getIndex(i, 0, m_view_index); + ModelIndex view_index = m_view_proxy.toProxyIndex(m_view_index); + + for (size_t i = 0; i < m_view_proxy.getRowCount(m_view_index); ++i) { + ModelIndex child_index = m_view_proxy.getIndex(i, 0, view_index); bool is_selected = std::find(m_selected_indices.begin(), m_selected_indices.end(), m_tree_proxy.toSourceIndex(child_index)) != m_selected_indices.end(); if (is_selected) { - ImGui::PushStyleColor(ImGuiCol_ChildBg, ImGui::ColorConvertFloat4ToU32(ImGui::GetStyleColorVec4(ImGuiCol_TabSelected))); + ImGui::PushStyleColor(ImGuiCol_ChildBg, + ImGui::ColorConvertFloat4ToU32( + ImGui::GetStyleColorVec4(ImGuiCol_TabSelected))); } else { ImGui::PushStyleColor(ImGuiCol_ChildBg, - ImGui::ColorConvertFloat4ToU32(ImGui::GetStyleColorVec4(ImGuiCol_ChildBg))); - + ImGui::ColorConvertFloat4ToU32( + ImGui::GetStyleColorVec4(ImGuiCol_ChildBg))); } - if (ImGui::BeginChild(child_index.getUUID(), {76, 92}, true, + bool inputTextHovered = false; + std::string text = m_view_proxy.getDisplayText(child_index); + //ImVec2 text_size = ImGui::CalcTextSize(text.c_str()); + ImVec2 text_size = {50.0f, 20.0f}; + if (ImGui::BeginChild(m_view_proxy.getSourceUUID(child_index), {76, 92}, true, ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { - m_icon_painter.render(*m_file_system_model->getDecoration(child_index), {72, 72}); - - std::string text = m_file_system_model->getDisplayText(child_index); - ImVec2 text_size = ImGui::CalcTextSize(text.c_str()); + m_icon_painter.render(*m_view_proxy.getDecoration(child_index), {72, 72}); - ImVec2 pos = ImGui::GetCursorScreenPos(); + ImVec2 pos = ImGui::GetCursorScreenPos(); ImVec2 newPos = pos; newPos.x += std::max(36.0f - (text_size.x / 2.0f), 0.0); newPos.y += 72.0f; @@ -87,17 +92,17 @@ namespace Toolbox::UI { ImGui::SetKeyboardFocusHere(); bool done = ImGui::InputText("##", m_rename_buffer, IM_ARRAYSIZE(m_rename_buffer), - ImGuiInputTextFlags_AutoSelectAll - | ImGuiInputTextFlags_EnterReturnsTrue); + ImGuiInputTextFlags_AutoSelectAll | + ImGuiInputTextFlags_EnterReturnsTrue); if (done) { - m_file_system_model->rename(child_index, m_rename_buffer); + m_file_system_model->rename(m_view_proxy.toSourceIndex(child_index), + m_rename_buffer); } ImGui::SetCursorScreenPos(pos); } else { ImGui::RenderTextEllipsis( - ImGui::GetWindowDrawList(), newPos, newPos + ImVec2(64, 20), pos.x + 64.0f, - newPos.x + 76.0f, text.c_str(), - nullptr, nullptr); + ImGui::GetWindowDrawList(), newPos, newPos + ImVec2(64, 20), + pos.x + 64.0f, newPos.x + 76.0f, text.c_str(), nullptr, nullptr); } inputTextHovered = ImGui::IsItemHovered(); } @@ -107,10 +112,10 @@ namespace Toolbox::UI { // Handle click responses if (ImGui::IsMouseDoubleClicked(0) && ImGui::IsWindowHovered(ImGuiHoveredFlags_None) && - m_file_system_model->isDirectory(child_index)) { + m_view_proxy.isDirectory(child_index)) { m_view_index = m_tree_proxy.toSourceIndex(child_index); } else if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(0)) { - if (is_selected){ + if (is_selected) { m_is_renaming = true; std::strncpy(m_rename_buffer, text.c_str(), IM_ARRAYSIZE(m_rename_buffer)); @@ -177,14 +182,13 @@ namespace Toolbox::UI { } ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_OpenOnArrow; - if (m_view_index == m_tree_proxy.toSourceIndex(index)){ + if (m_view_index == m_tree_proxy.toSourceIndex(index)) { flags |= ImGuiTreeNodeFlags_Selected; } if (isViewedAncestor(index)) { flags |= ImGuiTreeNodeFlags_DefaultOpen; } - is_open = ImGui::TreeNodeEx(m_tree_proxy.getDisplayText(index).c_str(), - flags); + is_open = ImGui::TreeNodeEx(m_tree_proxy.getDisplayText(index).c_str(), flags); if (ImGui::IsItemClicked()) { m_view_index = m_tree_proxy.toSourceIndex(index); diff --git a/src/model/fsmodel.cpp b/src/model/fsmodel.cpp index 9324a5d2..79adcdb5 100644 --- a/src/model/fsmodel.cpp +++ b/src/model/fsmodel.cpp @@ -124,11 +124,16 @@ namespace Toolbox { m_options = FileSystemModelOptions(); m_read_only = false; - fs_path fs_icon_path = - GUIApplication::instance().getResourcePath("Images/Icons/Filesystem/"); + const ResourceManager &res_manager = GUIApplication::instance().getResourceManager(); + UUID64 fs_icons_uuid = res_manager.getResourcePathUUID("Images/Icons/Filesystem"); for (auto &[key, value] : TypeMap()) { - m_icon_map[key] = make_referable(fs_icon_path / value.m_image_name); + auto result = res_manager.getImageHandle(value.m_image_name, fs_icons_uuid); + if (result) { + m_icon_map[key] = result.value(); + } else { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to load icon: {}", value.m_image_name); + } } } @@ -441,7 +446,7 @@ namespace Toolbox { return result; } - ModelIndex FileSystemModel::rename(const ModelIndex &file, const std::string &new_name){ + ModelIndex FileSystemModel::rename(const ModelIndex &file, const std::string &new_name) { if (!validateIndex(file)) { return ModelIndex(); } @@ -449,22 +454,21 @@ namespace Toolbox { TOOLBOX_ERROR("[FileSystemModel] Not a directory or file!"); return ModelIndex(); } - fs_path from = file.data<_FileSystemIndexData>()->m_path; - fs_path to = from.parent_path() / new_name; - ModelIndex parent = getParent(file); + fs_path from = file.data<_FileSystemIndexData>()->m_path; + fs_path to = from.parent_path() / new_name; + ModelIndex parent = getParent(file); _FileSystemIndexData *parent_data = parent.data<_FileSystemIndexData>(); - int dest_index = - std::find(parent_data->m_children.begin(), parent_data->m_children.end(), file.getUUID()) - - parent_data->m_children.begin(); + int dest_index = std::find(parent_data->m_children.begin(), parent_data->m_children.end(), + file.getUUID()) - + parent_data->m_children.begin(); Filesystem::rename(from, to); delete file.data<_FileSystemIndexData>(); m_index_map.erase(file.getUUID()); parent_data->m_children.erase(std::remove(parent_data->m_children.begin(), - parent_data->m_children.end(), - file.getUUID()), + parent_data->m_children.end(), file.getUUID()), parent_data->m_children.end()); return makeIndex(to, dest_index, parent); } @@ -691,9 +695,6 @@ namespace Toolbox { // Establish icon { - fs_path fs_icon_path = - GUIApplication::instance().getResourcePath("Images/Icons/Filesystem/"); - std::string ext = data->m_path.extension().string(); if (!validateIndex(index)) { @@ -1002,6 +1003,14 @@ namespace Toolbox { return ModelIndex(); } + UUID64 FileSystemModelSortFilterProxy::getSourceUUID(const ModelIndex &index) const { + if (!validateIndex(index)) { + return 0; + } + + return index.data<_FileSystemIndexData>()->m_self_uuid; + } + bool FileSystemModelSortFilterProxy::isFiltered(const UUID64 &uuid) const { ModelIndex child_index = m_source_model->getIndex(uuid); bool is_file = diff --git a/src/resource/resource.cpp b/src/resource/resource.cpp index aab013fd..54e04756 100644 --- a/src/resource/resource.cpp +++ b/src/resource/resource.cpp @@ -149,14 +149,14 @@ namespace Toolbox { return result; } - Result, FSError> + Result, FSError> ResourceManager::getImageHandle(const fs_path &path, const UUID64 &resource_path_uuid) const { if (m_image_handle_cache.find(path) != m_image_handle_cache.end()) { - return Result, FSError>(m_image_handle_cache[path]); + return Result, FSError>(m_image_handle_cache[path]); } if (!hasDataPath(path, resource_path_uuid)) { - return make_fs_error>(std::error_code(), + return make_fs_error>(std::error_code(), {"Resource path not found"}); } @@ -164,10 +164,10 @@ namespace Toolbox { const ResourceData &data = m_data_preload_cache[path]; std::span data_span(static_cast(data.m_data_ptr), data.m_data_size); - RefPtr handle = make_referable(data_span); + RefPtr handle = make_referable(data_span); if (!handle->isValid()) { - return make_fs_error>(std::error_code(), + return make_fs_error>(std::error_code(), {"Failed to load image"}); } @@ -178,23 +178,23 @@ namespace Toolbox { fs_path resource_path = getResourcePath(resource_path_uuid).value_or(fs_path()); fs_path abs_path = resource_path / path; - RefPtr handle = make_referable(abs_path); + RefPtr handle = make_referable(abs_path); if (!handle->isValid()) { - return make_fs_error>(std::error_code(), {"Failed to load image"}); + return make_fs_error>(std::error_code(), {"Failed to load image"}); } m_image_handle_cache[path] = handle; return handle; } - Result, FSError> + Result, FSError> ResourceManager::getImageHandle(fs_path &&path, const UUID64 &resource_path_uuid) const { if (m_image_handle_cache.find(path) != m_image_handle_cache.end()) { - return Result, FSError>(m_image_handle_cache[path]); + return Result, FSError>(m_image_handle_cache[path]); } if (!hasDataPath(path, resource_path_uuid)) { - return make_fs_error>(std::error_code(), + return make_fs_error>(std::error_code(), {"Resource path not found"}); } @@ -202,10 +202,10 @@ namespace Toolbox { const ResourceData &data = m_data_preload_cache[path]; std::span data_span(static_cast(data.m_data_ptr), data.m_data_size); - RefPtr handle = make_referable(data_span); + RefPtr handle = make_referable(data_span); if (!handle->isValid()) { - return make_fs_error>(std::error_code(), + return make_fs_error>(std::error_code(), {"Failed to load image"}); } @@ -216,9 +216,9 @@ namespace Toolbox { fs_path resource_path = getResourcePath(resource_path_uuid).value_or(fs_path()); fs_path abs_path = resource_path / path; - RefPtr handle = make_referable(abs_path); + RefPtr handle = make_referable(abs_path); if (!handle->isValid()) { - return make_fs_error>(std::error_code(), {"Failed to load image"}); + return make_fs_error>(std::error_code(), {"Failed to load image"}); } m_image_handle_cache[path] = handle; From 575cbab62d70bda127a35e9173c8aa0ca0b6662d Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Fri, 27 Sep 2024 13:58:51 -0700 Subject: [PATCH 033/129] Oops remove debug logging --- src/gui/project/window.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 1b233ed3..34495673 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -117,24 +117,18 @@ namespace Toolbox::UI { } m_is_renaming = false; } else if (ImGui::IsMouseClicked(0)) { - TOOLBOX_INFO("Got a click on item"); if (is_selected){ - TOOLBOX_INFO("Item was already selected"); if (ImGui::IsKeyDown(ImGuiMod_Ctrl)) { m_selected_indices.erase(std::find( m_selected_indices.begin(), m_selected_indices.end(), child_index)); m_is_renaming = false; } else { - TOOLBOX_INFO("Control key is not down"); m_is_renaming = true; std::strncpy(m_rename_buffer, text.c_str(), IM_ARRAYSIZE(m_rename_buffer)); } } else { - TOOLBOX_INFO("Item wasn't already selected, selecting now."); - TOOLBOX_INFO_V("There are {} selected indices", - m_selected_indices.size()); if (!ImGui::IsKeyDown(ImGuiMod_Ctrl)) { m_selected_indices.clear(); } From 85af285863906a9a59d75640524ad2e5b84f559e Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Fri, 27 Sep 2024 13:59:58 -0700 Subject: [PATCH 034/129] Add deleting logic --- src/gui/project/window.cpp | 54 ++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 34495673..f357b44c 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -149,12 +149,56 @@ namespace Toolbox::UI { } } - // Clearing the selection - if (!any_items_hovered && ImGui::IsMouseClicked(0)) { - TOOLBOX_INFO("No items are hovered and there was a click, clearing selection"); - m_selected_indices.clear(); - m_is_renaming = false; + ImVec2 center = ImGui::GetMainViewport()->GetCenter(); + ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f)); + static bool dont_ask_for_deletes = false; + if (ImGui::BeginPopupModal("Delete?", NULL, ImGuiWindowFlags_AlwaysAutoResize)) { + std::string message = ""; + + if (m_selected_indices.size() == 1) { + message = TOOLBOX_FORMAT_FN( + "Are you sure you want to delete {}?", + m_file_system_model->getDisplayText(m_selected_indices[0])); + } else if (m_selected_indices.size() > 1) { + message = TOOLBOX_FORMAT_FN( + "Are you sure you want to delete the {} selected files?", + m_selected_indices.size()); + } else { + TOOLBOX_ERROR("Selected 0 files to delete!"); + } + ImGui::Text(message.c_str()); + ImGui::Separator(); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0)); + ImGui::Checkbox("Don't ask me next time", &dont_ask_for_deletes); + ImGui::PopStyleVar(); + if (ImGui::Button("OK", ImVec2(120, 0))) { + for (auto &item_index : m_selected_indices) { + m_file_system_model->remove(item_index); + } + ImGui::CloseCurrentPopup(); + } + ImGui::SetItemDefaultFocus(); + ImGui::SameLine(); + if (ImGui::Button("Cancel", ImVec2(120, 0))) { ImGui::CloseCurrentPopup(); } + ImGui::EndPopup(); + } else { + // Clearing the selection + if (!any_items_hovered && ImGui::IsMouseClicked(0)) { + m_selected_indices.clear(); + m_is_renaming = false; + } + // Delete stuff + if (ImGui::IsKeyPressed(ImGuiKey_Delete) && !m_selected_indices.empty()) { + if (dont_ask_for_deletes) { + for (auto &item_index : m_selected_indices) { + m_file_system_model->remove(item_index); + } + } else { + ImGui::OpenPopup("Delete?"); + } + } } + ImGui::PopStyleVar(4); } } From 37e4642c5535a1f0af4c92e435202634723b9947 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Fri, 27 Sep 2024 16:29:31 -0500 Subject: [PATCH 035/129] Fix folder navigation and force proxy indexes to match their source uuid --- include/model/fsmodel.cpp | 0 include/model/model.hpp | 4 ++++ src/gui/project/window.cpp | 10 ++++++---- src/model/fsmodel.cpp | 3 +++ 4 files changed, 13 insertions(+), 4 deletions(-) delete mode 100644 include/model/fsmodel.cpp diff --git a/include/model/fsmodel.cpp b/include/model/fsmodel.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/include/model/model.hpp b/include/model/model.hpp index 3bc22f34..76c1d46a 100644 --- a/include/model/model.hpp +++ b/include/model/model.hpp @@ -34,6 +34,8 @@ namespace Toolbox { class ModelIndex final : public IUnique { public: + friend class IDataModel; + ModelIndex() = default; ModelIndex(UUID64 model_uuid) : m_model_uuid(model_uuid) {} ModelIndex(const ModelIndex &other) @@ -109,6 +111,8 @@ namespace Toolbox { protected: virtual ModelIndex makeIndex(const fs_path &path, int64_t row, const ModelIndex &parent) = 0; + + static void setIndexUUID(ModelIndex &index, UUID64 uuid) { index.m_uuid = uuid; } }; } // namespace Toolbox \ No newline at end of file diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 72889fa9..01cf2df7 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -78,8 +78,7 @@ namespace Toolbox::UI { float box_width = m_is_renaming && is_selected ? std::max(rename_size.x, 76.0f) : 76.0f; - if (ImGui::BeginChild( - m_view_proxy.getSourceUUID(child_index), {box_width, 92.0f}, true, + if (ImGui::BeginChild(child_index.getUUID(), {box_width, 92.0f}, true, ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { m_icon_painter.render(*m_view_proxy.getDecoration(child_index), {72.0f, 72.0f}); @@ -117,10 +116,13 @@ namespace Toolbox::UI { // Handle click responses if (ImGui::IsWindowHovered(ImGuiHoveredFlags_None)) { if (ImGui::IsMouseDoubleClicked(0)) { + m_is_renaming = false; if (m_view_proxy.isDirectory(child_index)) { - m_view_index = m_tree_proxy.toSourceIndex(child_index); + m_view_index = m_view_proxy.toSourceIndex(child_index); + ImGui::EndChild(); + ImGui::PopStyleColor(1); + break; } - m_is_renaming = false; } else if (ImGui::IsMouseClicked(0)) { if (is_selected){ if (ImGui::IsKeyDown(ImGuiMod_Ctrl)) { diff --git a/src/model/fsmodel.cpp b/src/model/fsmodel.cpp index 79adcdb5..c485a367 100644 --- a/src/model/fsmodel.cpp +++ b/src/model/fsmodel.cpp @@ -979,6 +979,9 @@ namespace Toolbox { ModelIndex proxy_index = ModelIndex(getUUID()); proxy_index.setData(index.data<_FileSystemIndexData>()); + + IDataModel::setIndexUUID(proxy_index, index.getUUID()); + return proxy_index; } From 55e211d7f3517ca1e5c2e48c59ed511d11b1f60c Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Fri, 27 Sep 2024 16:38:47 -0500 Subject: [PATCH 036/129] Fix missing return --- src/gui/themes.cpp | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/gui/themes.cpp b/src/gui/themes.cpp index 5ed66710..a2efcde4 100644 --- a/src/gui/themes.cpp +++ b/src/gui/themes.cpp @@ -240,21 +240,7 @@ namespace Toolbox::UI { } } - /*return Toolbox::Filesystem::current_path().and_then([this](std::filesystem::path &&cwd) { - for (auto &subpath : Toolbox::Filesystem::directory_iterator{cwd / "Themes"}) { - try { - auto theme = make_referable(subpath.path().stem().string()); - if (theme->name() == "Default") { - theme->apply(); - m_active_theme = m_themes.size(); - } - m_themes.emplace_back(theme); - } catch (std::runtime_error &e) { - return make_fs_error(std::error_code(), {e.what()}); - } - } - return Result(); - });*/ + return {}; } } // namespace Toolbox::UI \ No newline at end of file From e70a5d60ceec6ed6704c101d2913b2ea2fad8b50 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Fri, 27 Sep 2024 19:39:01 -0500 Subject: [PATCH 037/129] Start implementation of basic watchdog --- CMakeLists.txt | 2 + include/gui/project/window.hpp | 17 +-- include/watchdog/fswatchdog.hpp | 76 ++++++++++++++ src/gui/project/window.cpp | 59 +++++++++-- src/watchdog/fswatchdog.cpp | 177 ++++++++++++++++++++++++++++++++ 5 files changed, 313 insertions(+), 18 deletions(-) create mode 100644 include/watchdog/fswatchdog.hpp create mode 100644 src/watchdog/fswatchdog.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b4723974..38a5c141 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,8 @@ file(GLOB TOOLBOX_SRC "include/window/*.hpp" "src/objlib/meta/*.cpp" "include/objlib/meta/*.hpp" + "src/watchdog/*.cpp" + "include/watchdog/*.hpp" "src/io/*.cpp" "src/gui/*.cpp" "include/gui/*.hpp" diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index d3306dda..6d451ac4 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -22,6 +22,7 @@ #include "gui/project/asset.hpp" #include "model/fsmodel.hpp" +#include "watchdog/fswatchdog.hpp" #include @@ -80,18 +81,8 @@ namespace Toolbox::UI { return {}; } - [[nodiscard]] bool onLoadData(const std::filesystem::path& path) override { - m_project_root = path; - m_file_system_model = make_referable(); - m_file_system_model->initialize(); - m_file_system_model->setRoot(m_project_root); - m_tree_proxy.setSourceModel(m_file_system_model); - m_tree_proxy.setDirsOnly(true); - m_view_proxy.setSourceModel(m_file_system_model); - m_view_proxy.setSortRole(FileSystemModelSortRole::SORT_ROLE_NAME); - m_view_index = m_view_proxy.getIndex(0, 0); - return true; - } + [[nodiscard]] bool onLoadData(const std::filesystem::path &path) override; + [[nodiscard]] bool onSaveData(std::optional path) override { return true; } @@ -106,6 +97,8 @@ namespace Toolbox::UI { private: fs_path m_project_root; + FileSystemWatchdog m_fs_watchdog; + // TODO: Have filesystem model. FileSystemModelSortFilterProxy m_tree_proxy; FileSystemModelSortFilterProxy m_view_proxy; diff --git a/include/watchdog/fswatchdog.hpp b/include/watchdog/fswatchdog.hpp new file mode 100644 index 00000000..29cdc040 --- /dev/null +++ b/include/watchdog/fswatchdog.hpp @@ -0,0 +1,76 @@ +#include +#include +#include + +#include "core/threaded.hpp" +#include "fsystem.hpp" + +namespace Toolbox { + + class FileSystemWatchdog : public Threaded { + public: + using file_added_cb = std::function; + using file_removed_cb = std::function; + using file_modified_cb = std::function; + + using dir_added_cb = std::function; + using dir_removed_cb = std::function; + using dir_modified_cb = std::function; + + FileSystemWatchdog() = default; + virtual ~FileSystemWatchdog() = default; + + void reset(); + void sleep(); + void wake(); + + void addPath(const fs_path &path); + void addPath(fs_path &&path); + + void removePath(const fs_path &path); + void removePath(fs_path &&path); + + public: + void onFileAdded(file_added_cb cb); + void onFileRemoved(file_removed_cb cb); + void onFileModified(file_modified_cb cb); + + void onDirAdded(dir_added_cb cb); + void onDirRemoved(dir_removed_cb cb); + void onDirModified(dir_modified_cb cb); + + protected: + void tRun(void *param) override; + + void observePath(const fs_path &path); + void observePathF(const fs_path &path); + + struct FileInfo { + Filesystem::file_status m_status; + Filesystem::file_time_type m_time; + size_t m_size; + bool m_is_dir; + bool m_exists; + }; + + FileInfo createFileInfo(const fs_path &path); + void signalChanges(const fs_path &path, const FileInfo &a, const FileInfo &b); + + private: + bool m_asleep = false; + + std::unordered_map m_path_infos; + std::unordered_set m_watch_paths; + + file_added_cb m_file_added_cb; + file_removed_cb m_file_removed_cb; + file_modified_cb m_file_modified_cb; + + dir_added_cb m_dir_added_cb; + dir_removed_cb m_dir_removed_cb; + dir_modified_cb m_dir_modified_cb; + + std::mutex m_mutex; + }; + +} // namespace Toolbox \ No newline at end of file diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 01cf2df7..987ad230 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -79,9 +79,11 @@ namespace Toolbox::UI { float box_width = m_is_renaming && is_selected ? std::max(rename_size.x, 76.0f) : 76.0f; if (ImGui::BeginChild(child_index.getUUID(), {box_width, 92.0f}, true, - ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { + ImGuiWindowFlags_ChildWindow | + ImGuiWindowFlags_NoDecoration)) { - m_icon_painter.render(*m_view_proxy.getDecoration(child_index), {72.0f, 72.0f}); + m_icon_painter.render(*m_view_proxy.getDecoration(child_index), + {72.0f, 72.0f}); // Render the label ImVec2 pos = ImGui::GetCursorScreenPos(); @@ -119,12 +121,13 @@ namespace Toolbox::UI { m_is_renaming = false; if (m_view_proxy.isDirectory(child_index)) { m_view_index = m_view_proxy.toSourceIndex(child_index); + m_fs_watchdog.addPath(m_file_system_model->getPath(m_view_index)); ImGui::EndChild(); ImGui::PopStyleColor(1); break; } } else if (ImGui::IsMouseClicked(0)) { - if (is_selected){ + if (is_selected) { if (ImGui::IsKeyDown(ImGuiMod_Ctrl)) { m_selected_indices.erase( std::find(m_selected_indices.begin(), @@ -185,7 +188,9 @@ namespace Toolbox::UI { } ImGui::SetItemDefaultFocus(); ImGui::SameLine(); - if (ImGui::Button("Cancel", ImVec2(120, 0))) { ImGui::CloseCurrentPopup(); } + if (ImGui::Button("Cancel", ImVec2(120, 0))) { + ImGui::CloseCurrentPopup(); + } ImGui::EndPopup(); } else { // Clearing the selection @@ -215,9 +220,50 @@ namespace Toolbox::UI { void ProjectViewWindow::renderProjectFileButton() {} - void ProjectViewWindow::onAttach() {} + bool ProjectViewWindow::onLoadData(const std::filesystem::path &path) { + m_project_root = path; + m_file_system_model = make_referable(); + m_file_system_model->initialize(); + m_file_system_model->setRoot(m_project_root); + m_tree_proxy.setSourceModel(m_file_system_model); + m_tree_proxy.setDirsOnly(true); + m_view_proxy.setSourceModel(m_file_system_model); + m_view_proxy.setSortRole(FileSystemModelSortRole::SORT_ROLE_NAME); + m_view_index = m_view_proxy.getIndex(0, 0); + m_fs_watchdog.reset(); + m_fs_watchdog.addPath(m_project_root); + m_fs_watchdog.onFileRemoved([this](const fs_path &path) { + TOOLBOX_INFO_V("File removed: {}", path.string()); + //m_file_system_model->removeIndex(m_file_system_model->getIndex(path)); + }); + m_fs_watchdog.onFileAdded( + [this](const fs_path &path) { + TOOLBOX_INFO_V("File added: {}", path.string()); + fs_path parent = path.parent_path(); + /*m_file_system_model->addIndex(;*/ + }); + m_fs_watchdog.onFileModified([this](const fs_path& path) { + TOOLBOX_INFO_V("File modified: {}", path.string()); + //m_file_system_model->updateIndex(m_file_system_model->getIndex(path)); + }); + m_fs_watchdog.onDirAdded([this](const fs_path& path) { + TOOLBOX_INFO_V("Dir added: {}", path.string()); + //m_file_system_model->addIndex(m_file_system_model->getIndex(path)); + }); + m_fs_watchdog.onDirModified([this](const fs_path& path) { + TOOLBOX_INFO_V("Dir modified: {}", path.string()); + //m_file_system_model->updateIndex(m_file_system_model->getIndex(path)); + }); + m_fs_watchdog.onDirRemoved([this](const fs_path &path) { + TOOLBOX_INFO_V("Dir removed: {}", path.string()); + //m_file_system_model->renameIndex(m_file_system_model->getIndex(old_path), new_path); + }); + return true; + } + + void ProjectViewWindow::onAttach() { m_fs_watchdog.tStart(false, nullptr); } - void ProjectViewWindow::onDetach() {} + void ProjectViewWindow::onDetach() { m_fs_watchdog.tKill(true); } void ProjectViewWindow::onImGuiUpdate(TimeStep delta_time) {} @@ -258,6 +304,7 @@ namespace Toolbox::UI { if (ImGui::IsItemClicked()) { m_view_index = m_tree_proxy.toSourceIndex(index); + m_fs_watchdog.addPath(m_file_system_model->getPath(m_view_index)); } if (is_open) { diff --git a/src/watchdog/fswatchdog.cpp b/src/watchdog/fswatchdog.cpp new file mode 100644 index 00000000..85ab6516 --- /dev/null +++ b/src/watchdog/fswatchdog.cpp @@ -0,0 +1,177 @@ +#include "watchdog/fswatchdog.hpp" + +namespace Toolbox { + + void FileSystemWatchdog::reset() { + std::scoped_lock lock(m_mutex); + m_watch_paths.clear(); + m_path_infos.clear(); + } + + void FileSystemWatchdog::sleep() { + std::scoped_lock lock(m_mutex); + m_asleep = true; + } + + void FileSystemWatchdog::wake() { + std::scoped_lock lock(m_mutex); + m_asleep = false; + } + + void FileSystemWatchdog::addPath(const fs_path &path) { + std::scoped_lock lock(m_mutex); + m_watch_paths.insert(path); + } + + void FileSystemWatchdog::addPath(fs_path &&path) { + std::scoped_lock lock(m_mutex); + m_watch_paths.emplace(std::move(path)); + } + + void FileSystemWatchdog::removePath(const fs_path &path) { + std::scoped_lock lock(m_mutex); + m_watch_paths.erase(path); + } + + void FileSystemWatchdog::removePath(fs_path &&path) { + std::scoped_lock lock(m_mutex); + m_watch_paths.erase(std::move(path)); + } + + void FileSystemWatchdog::onFileAdded(file_added_cb cb) { + std::scoped_lock lock(m_mutex); + m_file_added_cb = cb; + } + + void FileSystemWatchdog::onFileRemoved(file_removed_cb cb) { + std::scoped_lock lock(m_mutex); + m_file_removed_cb = cb; + } + + void FileSystemWatchdog::onFileModified(file_modified_cb cb) { + std::scoped_lock lock(m_mutex); + m_file_modified_cb = cb; + } + + void FileSystemWatchdog::onDirAdded(dir_added_cb cb) { + std::scoped_lock lock(m_mutex); + m_dir_added_cb = cb; + } + + void FileSystemWatchdog::onDirRemoved(dir_removed_cb cb) { + std::scoped_lock lock(m_mutex); + m_dir_removed_cb = cb; + } + + void FileSystemWatchdog::onDirModified(dir_modified_cb cb) { + std::scoped_lock lock(m_mutex); + m_dir_modified_cb = cb; + } + + void FileSystemWatchdog::tRun(void *param) { + while (!tIsSignalKill()) { + while (m_asleep) { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + + { + std::scoped_lock lock(m_mutex); + for (const auto &path : m_watch_paths) { + observePath(path); + } + } + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + } + + void FileSystemWatchdog::observePath(const fs_path &path) { + if (m_path_infos.find(path) == m_path_infos.end()) { + m_path_infos[path] = createFileInfo(path); + return; + } + + const FileInfo &old_info = m_path_infos[path]; + FileInfo new_info = createFileInfo(path); + + signalChanges(path, old_info, new_info); + + if (new_info.m_is_dir) { + for (const auto &entry : Toolbox::Filesystem::directory_iterator(path)) { + observePathF(entry.path()); + } + } + + m_path_infos[path] = new_info; + } + + void FileSystemWatchdog::observePathF(const fs_path &path) { + if (m_path_infos.find(path) == m_path_infos.end()) { + m_path_infos[path] = createFileInfo(path); + return; + } + + const FileInfo &old_info = m_path_infos[path]; + FileInfo new_info = createFileInfo(path); + + signalChanges(path, old_info, new_info); + + m_path_infos[path] = new_info; + } + + FileSystemWatchdog::FileInfo FileSystemWatchdog::createFileInfo(const fs_path &path) { + FileInfo info; + + info.m_is_dir = Toolbox::Filesystem::is_directory(path).value_or(false); + info.m_exists = Toolbox::Filesystem::exists(path).value_or(false); + info.m_time = + Toolbox::Filesystem::last_write_time(path).value_or(Filesystem::file_time_type::min()); + + if (!info.m_is_dir && info.m_exists) { + info.m_size = Toolbox::Filesystem::file_size(path).value_or(0); + } + + return info; + } + + void FileSystemWatchdog::signalChanges(const fs_path &path, const FileInfo &a, + const FileInfo &b) { + if (a.m_exists != b.m_exists) { + if (b.m_exists) { + if (b.m_is_dir) { + if (m_dir_added_cb) { + m_dir_added_cb(path); + } + } else { + if (m_file_added_cb) { + m_file_added_cb(path); + } + } + } else { + if (b.m_is_dir) { + if (m_dir_removed_cb) { + m_dir_removed_cb(path); + } + } else { + if (m_file_removed_cb) { + m_file_removed_cb(path); + } + } + } + } else { + if (b.m_exists) { + if (b.m_time != a.m_time) { + if (b.m_is_dir) { + if (m_dir_modified_cb) { + m_dir_modified_cb(path); + } + } else { + if (m_file_modified_cb) { + m_file_modified_cb(path); + } + } + } + } + } + } + +} // namespace Toolbox From f702fcb8aed32b94f6eef847b0f29bd090be13b0 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Sat, 28 Sep 2024 21:46:42 -0500 Subject: [PATCH 038/129] Watchdog works now --- include/watchdog/fswatchdog.hpp | 95 ++- lib/FileWatch.hpp | 1160 +++++++++++++++++++++++++++++++ src/gui/project/window.cpp | 22 +- src/watchdog/fswatchdog.cpp | 216 +++--- 4 files changed, 1378 insertions(+), 115 deletions(-) create mode 100644 lib/FileWatch.hpp diff --git a/include/watchdog/fswatchdog.hpp b/include/watchdog/fswatchdog.hpp index 29cdc040..a6e9b290 100644 --- a/include/watchdog/fswatchdog.hpp +++ b/include/watchdog/fswatchdog.hpp @@ -2,20 +2,67 @@ #include #include +#include + +#include "core/memory.hpp" #include "core/threaded.hpp" #include "fsystem.hpp" +#include "platform/process.hpp" namespace Toolbox { - class FileSystemWatchdog : public Threaded { + class FileSystemWatchdog; + + class PathWatcher_ { public: - using file_added_cb = std::function; - using file_removed_cb = std::function; - using file_modified_cb = std::function; + PathWatcher_(FileSystemWatchdog *watchdog, const fs_path &path); + ~PathWatcher_(); + + const fs_path &getPath() const & { return m_path; } + + bool operator==(const PathWatcher_ &other) const { return m_path == other.m_path; } + + protected: + void watchDirectory(const fs_path &path); + void watchFile(const fs_path &path); + void closeDirectory(); + void closeFile(); + + void callback_(const fs_path &path, const filewatch::Event event); + + private: + FileSystemWatchdog *m_watchdog; + fs_path m_path; + bool m_is_dir; + bool m_is_file; + bool m_is_open; + ScopePtr> m_watch; + }; + +} + - using dir_added_cb = std::function; - using dir_removed_cb = std::function; - using dir_modified_cb = std::function; + +namespace std { + + // Hash for PathWatcher + template <> struct hash { + size_t operator()(const Toolbox::PathWatcher_ &_Keyval) const noexcept { + return std::hash{}(_Keyval.getPath()); + } + }; + +} // namespace std + +namespace Toolbox { + + class FileSystemWatchdog : public Threaded { + friend class Toolbox::PathWatcher_; + + public: + using file_changed_cb = std::function; + using dir_changed_cb = std::function; + using path_changed_cb = std::function; FileSystemWatchdog() = default; virtual ~FileSystemWatchdog() = default; @@ -31,13 +78,15 @@ namespace Toolbox { void removePath(fs_path &&path); public: - void onFileAdded(file_added_cb cb); - void onFileRemoved(file_removed_cb cb); - void onFileModified(file_modified_cb cb); + void onFileAdded(file_changed_cb cb); + void onFileModified(file_changed_cb cb); - void onDirAdded(dir_added_cb cb); - void onDirRemoved(dir_removed_cb cb); - void onDirModified(dir_modified_cb cb); + void onDirAdded(dir_changed_cb cb); + void onDirModified(dir_changed_cb cb); + + void onPathRenamedSrc(path_changed_cb cb); + void onPathRenamedDst(path_changed_cb cb); + void onPathRemoved(path_changed_cb cb); protected: void tRun(void *param) override; @@ -60,17 +109,21 @@ namespace Toolbox { bool m_asleep = false; std::unordered_map m_path_infos; - std::unordered_set m_watch_paths; - file_added_cb m_file_added_cb; - file_removed_cb m_file_removed_cb; - file_modified_cb m_file_modified_cb; + std::unordered_set m_file_paths; + std::unordered_set m_dir_paths; + + file_changed_cb m_file_added_cb; + file_changed_cb m_file_modified_cb; + + dir_changed_cb m_dir_added_cb; + dir_changed_cb m_dir_modified_cb; - dir_added_cb m_dir_added_cb; - dir_removed_cb m_dir_removed_cb; - dir_modified_cb m_dir_modified_cb; + path_changed_cb m_path_renamed_src_cb; + path_changed_cb m_path_renamed_dst_cb; + path_changed_cb m_path_removed_cb; std::mutex m_mutex; }; -} // namespace Toolbox \ No newline at end of file +} // namespace Toolbox diff --git a/lib/FileWatch.hpp b/lib/FileWatch.hpp new file mode 100644 index 00000000..bee35672 --- /dev/null +++ b/lib/FileWatch.hpp @@ -0,0 +1,1160 @@ +// MIT License +// +// Copyright(c) 2017 Thomas Monkman +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#ifndef FILEWATCHER_H +#define FILEWATCHER_H + +#include +#include +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#ifndef NOMINMAX +#define NOMINMAX +#endif +// clang-format off +#include +// clang-format on +#include +#include +#include +#include +#include +#endif // WIN32 + +#if __unix__ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // __unix__ + +#ifdef __linux__ +#include +#endif + +#if defined(__APPLE__) || defined(__MACH__) +#include +#include +#include +#include +#include +#include +#define FILEWATCH_PLATFORM_MAC 1 +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef FILEWATCH_PLATFORM_MAC +extern "C" int __getdirentries64(int, char *, int, long *); +#endif // FILEWATCH_PLATFORM_MAC + +namespace filewatch { + enum class Event { added, removed, modified, renamed_old, renamed_new }; + + template struct IsWChar { + static constexpr bool value = false; + }; + + template <> struct IsWChar { + static constexpr bool value = true; + }; + + template struct Invokable { + static Fn make() { return (Fn *)0; } + + template static T defaultValue() { return *(T *)0; } + + static void call(int) { make()(defaultValue()); } + + static int call(long value); + + static constexpr bool value = std::is_same::value; + }; + +#define _FILEWATCH_TO_STRING(x) #x +#define FILEWATCH_TO_STRING(x) _FILEWATCH_TO_STRING(x) + + [[maybe_unused]] static const char *event_to_string(Event event) { + switch (event) { + case Event::added: + return FILEWATCH_TO_STRING(Event::added); + case Event::removed: + return FILEWATCH_TO_STRING(Event::removed); + case Event::modified: + return FILEWATCH_TO_STRING(Event::modified); + case Event::renamed_old: + return FILEWATCH_TO_STRING(Event : renamed_old); + case Event::renamed_new: + return FILEWATCH_TO_STRING(Event::renamed_new); + } + assert(false); + } + + template + static typename std::enable_if::value, + bool>::type + isParentOrSelfDirectory(const StringType &path) { + return path == L"." || path == L".."; + } + + template + static typename std::enable_if::value, + bool>::type + isParentOrSelfDirectory(const StringType &path) { + return path == "." || path == ".."; + } + + /** + * \class FileWatch + * + * \brief Watches a folder or file, and will notify of changes via function callback. + * + * \author Thomas Monkman + * + */ + template class FileWatch { + typedef typename StringType::value_type C; + typedef std::basic_string> UnderpinningString; + typedef std::basic_regex> UnderpinningRegex; + + public: + FileWatch(StringType path, UnderpinningRegex pattern, + std::function callback) + : _path(absolute_path_of(path)), _pattern(pattern), _callback(callback), + _directory(get_directory(path)) { + init(); + } + + FileWatch(StringType path, + std::function callback) + : FileWatch(path, UnderpinningRegex(_regex_all), callback) {} + + ~FileWatch() { destroy(); } + + FileWatch(const FileWatch &other) + : FileWatch(other._path, other._callback) {} + + FileWatch &operator=(const FileWatch &other) { + if (this == &other) { + return *this; + } + + destroy(); + _path = other._path; + _callback = other._callback; + _directory = get_directory(other._path); + init(); + return *this; + } + + // Const memeber varibles don't let me implent moves nicely, if moves are really wanted + // std::unique_ptr should be used and move that. + FileWatch(FileWatch &&) = delete; + FileWatch &operator=(FileWatch &&) & = delete; + + private: + static constexpr C _regex_all[] = {'.', '*', '\0'}; + static constexpr C _this_directory[] = {'.', '/', '\0'}; + + struct PathParts { + PathParts(StringType directory, StringType filename) + : directory(directory), filename(filename) {} + StringType directory; + StringType filename; + }; + const StringType _path; + + UnderpinningRegex _pattern; + + static constexpr std::size_t _buffer_size = {1024 * 256}; + + // only used if watch a single file + StringType _filename; + + std::function _callback; + + std::thread _watch_thread; + + std::condition_variable _cv; + std::mutex _callback_mutex; + std::vector> _callback_information; + std::thread _callback_thread; + + std::promise _running; + std::atomic _destory = {false}; + bool _watching_single_file = {false}; + +#ifdef _WIN32 + HANDLE _directory = {nullptr}; + HANDLE _close_event = {nullptr}; + + const DWORD _listen_filters = FILE_NOTIFY_CHANGE_SECURITY | FILE_NOTIFY_CHANGE_CREATION | + FILE_NOTIFY_CHANGE_LAST_ACCESS | + FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_SIZE | + FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_DIR_NAME | + FILE_NOTIFY_CHANGE_FILE_NAME; + + const std::unordered_map _event_type_mapping = { + {FILE_ACTION_ADDED, Event::added }, + {FILE_ACTION_REMOVED, Event::removed }, + {FILE_ACTION_MODIFIED, Event::modified }, + {FILE_ACTION_RENAMED_OLD_NAME, Event::renamed_old}, + {FILE_ACTION_RENAMED_NEW_NAME, Event::renamed_new} + }; +#endif // WIN32 + +#if __unix__ + struct FolderInfo { + int folder; + int watch; + }; + + FolderInfo _directory; + + const std::uint32_t _listen_filters = IN_MODIFY | IN_CREATE | IN_DELETE; + + const static std::size_t event_size = (sizeof(struct inotify_event)); +#endif // __unix__ + +#if FILEWATCH_PLATFORM_MAC + struct FileState { + int fd; + uint32_t nlink; + time_t last_modification; + + FileState(int fd, uint32_t nlink, time_t lt) + : fd(fd), nlink(nlink), last_modification(lt) {} + FileState(const FileState &) = delete; + FileState &operator=(const FileState &) = delete; + FileState(FileState &&other) + : fd(other.fd), nlink(other.nlink), last_modification(other.last_modification) { + other.fd = -1; + } + + FileState invalidate_and_clone() { + int fd = this->fd; + + this->fd = -1; + return FileState{fd, nlink, last_modification}; + } + + ~FileState() { + if (fd != -1) { + close(fd); + } + } + }; + std::unordered_map _directory_snapshot{}; + bool _previous_event_is_rename = false; + CFRunLoopRef _run_loop = nullptr; + int _file_fd = -1; + struct timespec _last_modification_time = {}; + FSEventStreamRef _directory; + // fd for single file +#endif // FILEWATCH_PLATFORM_MAC + + void init() { +#ifdef _WIN32 + _close_event = CreateEvent(NULL, TRUE, FALSE, NULL); + if (!_close_event) { + throw std::system_error(GetLastError(), std::system_category()); + } +#endif // WIN32 + + _callback_thread = std::thread([this]() { + try { + callback_thread(); + } catch (...) { + try { + _running.set_exception(std::current_exception()); + } catch (...) { + } // set_exception() may throw too + } + }); + + _watch_thread = std::thread([this]() { + try { + monitor_directory(); + } catch (...) { + try { + _running.set_exception(std::current_exception()); + } catch (...) { + } // set_exception() may throw too + } + }); + + std::future future = _running.get_future(); + future.get(); // block until the monitor_directory is up and running + } + + void destroy() { + _destory = true; + _running = std::promise(); + +#ifdef _WIN32 + SetEvent(_close_event); +#elif __unix__ + inotify_rm_watch(_directory.folder, _directory.watch); +#elif FILEWATCH_PLATFORM_MAC + if (_run_loop) { + CFRunLoopStop(_run_loop); + } +#endif // __unix__ + + _cv.notify_all(); + _watch_thread.join(); + _callback_thread.join(); + +#ifdef _WIN32 + CloseHandle(_directory); +#elif __unix__ + close(_directory.folder); +#elif FILEWATCH_PLATFORM_MAC + FSEventStreamStop(_directory); + FSEventStreamInvalidate(_directory); + FSEventStreamRelease(_directory); + _directory = nullptr; +#endif // FILEWATCH_PLATFORM_MAC + } + + const PathParts split_directory_and_file(const StringType &path) const { + const auto predict = [](C character) { +#ifdef _WIN32 + return character == C('\\') || character == C('/'); +#elif __unix__ || FILEWATCH_PLATFORM_MAC + return character == C('/'); +#endif // __unix__ + }; + + UnderpinningString path_string = path; + const auto pivot = + std::find_if(path_string.rbegin(), path_string.rend(), predict).base(); + // if the path is something like "test.txt" there will be no directory part, however we + // still need one, so insert './' + const StringType directory = [&]() { + const auto extracted_directory = UnderpinningString(path_string.begin(), pivot); + return (extracted_directory.size() > 0) ? extracted_directory + : UnderpinningString(_this_directory); + }(); + const StringType filename = UnderpinningString(pivot, path_string.end()); + return PathParts(directory, filename); + } + + bool pass_filter(const UnderpinningString &file_path) { + if (_watching_single_file) { +#if 1 + const UnderpinningString extracted_filename = [](const StringType &str) { + if constexpr (std::is_same_v) { + if constexpr (std::is_same_v) { + return UnderpinningString(str.wstring()); + } else { + return UnderpinningString(str.string()); + } + } else { + return UnderpinningString(str); + } + }(split_directory_and_file(file_path).filename); +#else + const UnderpinningString extracted_filename = { + split_directory_and_file(file_path).filename}; +#endif + // if we are watching a single file, only that file should trigger action + return extracted_filename == _filename; + } + return std::regex_match(file_path, _pattern); + } + +#ifdef _WIN32 + template DWORD GetFileAttributesX(const char *lpFileName, Args... args) { + return GetFileAttributesA(lpFileName, args...); + } + template + DWORD GetFileAttributesX(const wchar_t *lpFileName, Args... args) { + return GetFileAttributesW(lpFileName, args...); + } + + template HANDLE CreateFileX(const char *lpFileName, Args... args) { + return CreateFileA(lpFileName, args...); + } + template HANDLE CreateFileX(const wchar_t *lpFileName, Args... args) { + return CreateFileW(lpFileName, args...); + } + + HANDLE get_directory(const StringType &path) { + auto file_info = GetFileAttributesX(path.c_str()); + + if (file_info == INVALID_FILE_ATTRIBUTES) { + throw std::system_error(GetLastError(), std::system_category()); + } + _watching_single_file = (file_info & FILE_ATTRIBUTE_DIRECTORY) == false; + + const StringType watch_path = [this, &path]() { + if (_watching_single_file) { + const auto parsed_path = split_directory_and_file(path); + _filename = parsed_path.filename; + return parsed_path.directory; + } else { + return path; + } + }(); + + HANDLE directory = + CreateFileX(watch_path.c_str(), // pointer to the file name + FILE_LIST_DIRECTORY, // access (read/write) mode + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, // share mode + nullptr, // security descriptor + OPEN_EXISTING, // how to create + FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, // file attributes + HANDLE(0)); // file with attributes to copy + + if (directory == INVALID_HANDLE_VALUE) { + throw std::system_error(GetLastError(), std::system_category()); + } + return directory; + } + + void convert_wstring(const std::wstring &wstr, std::string &out) { + int size_needed = + WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL); + out.resize(size_needed, '\0'); + WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &out[0], size_needed, NULL, + NULL); + } + + void convert_wstring(const std::wstring &wstr, std::wstring &out) { out = wstr; } + + void monitor_directory() { + std::vector buffer(_buffer_size); + DWORD bytes_returned = 0; + OVERLAPPED overlapped_buffer{0}; + + overlapped_buffer.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + if (!overlapped_buffer.hEvent) { + std::cerr << "Error creating monitor event" << std::endl; + } + + std::array handles{overlapped_buffer.hEvent, _close_event}; + + auto async_pending = false; + _running.set_value(); + do { + std::vector> parsed_information; + ReadDirectoryChangesW(_directory, buffer.data(), static_cast(buffer.size()), + TRUE, _listen_filters, &bytes_returned, &overlapped_buffer, + NULL); + + async_pending = true; + + switch (WaitForMultipleObjects(2, handles.data(), FALSE, INFINITE)) { + case WAIT_OBJECT_0: { + if (!GetOverlappedResult(_directory, &overlapped_buffer, &bytes_returned, + TRUE)) { + throw std::system_error(GetLastError(), std::system_category()); + } + async_pending = false; + + if (bytes_returned == 0) { + break; + } + + FILE_NOTIFY_INFORMATION *file_information = + reinterpret_cast(&buffer[0]); + do { + std::wstring changed_file_w{file_information->FileName, + file_information->FileNameLength / + sizeof(file_information->FileName[0])}; + UnderpinningString changed_file; + convert_wstring(changed_file_w, changed_file); + if (pass_filter(changed_file)) { + parsed_information.emplace_back( + StringType{changed_file}, + _event_type_mapping.at(file_information->Action)); + } + + if (file_information->NextEntryOffset == 0) { + break; + } + + file_information = reinterpret_cast( + reinterpret_cast(file_information) + + file_information->NextEntryOffset); + } while (true); + break; + } + case WAIT_OBJECT_0 + 1: + // quit + break; + case WAIT_FAILED: + break; + } + // dispatch callbacks + { + std::lock_guard lock(_callback_mutex); + _callback_information.insert(_callback_information.end(), + parsed_information.begin(), + parsed_information.end()); + } + _cv.notify_all(); + } while (_destory == false); + + if (async_pending) { + // clean up running async io + CancelIo(_directory); + GetOverlappedResult(_directory, &overlapped_buffer, &bytes_returned, TRUE); + } + } +#endif // WIN32 + +#if __unix__ + + bool is_file(const StringType &path) const { + struct stat statbuf = {}; + if (stat(path.c_str(), &statbuf) != 0) { + throw std::system_error(errno, std::system_category()); + } + return S_ISREG(statbuf.st_mode); + } + + FolderInfo get_directory(const StringType &path) { + const auto folder = inotify_init(); + if (folder < 0) { + throw std::system_error(errno, std::system_category()); + } + + _watching_single_file = is_file(path); + + const StringType watch_path = [this, &path]() { + if (_watching_single_file) { + const auto parsed_path = split_directory_and_file(path); + _filename = parsed_path.filename; + return parsed_path.directory; + } else { + return path; + } + }(); + + const auto watch = + inotify_add_watch(folder, watch_path.c_str(), IN_MODIFY | IN_CREATE | IN_DELETE); + if (watch < 0) { + throw std::system_error(errno, std::system_category()); + } + return {folder, watch}; + } + + void monitor_directory() { + std::vector buffer(_buffer_size); + + _running.set_value(); + while (_destory == false) { + const auto length = + read(_directory.folder, static_cast(buffer.data()), buffer.size()); + if (length > 0) { + int i = 0; + std::vector> parsed_information; + while (i < length) { + struct inotify_event *event = + reinterpret_cast(&buffer[i]); // NOLINT + if (event->len) { + const UnderpinningString changed_file{event->name}; + if (pass_filter(changed_file)) { + if (event->mask & IN_CREATE) { + parsed_information.emplace_back(StringType{changed_file}, + Event::added); + } else if (event->mask & IN_DELETE) { + parsed_information.emplace_back(StringType{changed_file}, + Event::removed); + } else if (event->mask & IN_MODIFY) { + parsed_information.emplace_back(StringType{changed_file}, + Event::modified); + } + } + } + i += event_size + event->len; + } + // dispatch callbacks + { + std::lock_guard lock(_callback_mutex); + _callback_information.insert(_callback_information.end(), + parsed_information.begin(), + parsed_information.end()); + } + _cv.notify_all(); + } + } + } +#endif // __unix__ + +#if FILEWATCH_PLATFORM_MAC + static StringType absolute_path_of(const StringType &path) { + char buf[PATH_MAX]; + int fd = open((const char *)path.c_str(), O_RDONLY); + const char *str = buf; + struct stat stat; + mbstate_t state; + + assert(fd != -1); + fcntl(fd, F_GETPATH, buf); + fstat(fd, &stat); + + if (stat.st_mode & S_IFREG || stat.st_mode & S_IFLNK) { + size_t len = strlen(buf); + + for (size_t i = len - 1; i >= 0; i--) { + if (buf[i] == '/') { + buf[i] = '\0'; + break; + } + } + } + close(fd); + + if (IsWChar::value) { + size_t needed = mbsrtowcs(nullptr, &str, 0, &state) + 1; + StringType s; + + s.reserve(needed); + mbsrtowcs((wchar_t *)&s[0], &str, s.size(), &state); + return s; + } + return StringType{buf}; + } +#elif defined(__unix__) + static StringType absolute_path_of(const StringType &path) { + char buf[PATH_MAX]; + const char *str = buf; + struct stat stat; + mbstate_t state; + + realpath((const char *)path.c_str(), buf); + ::stat((const char *)path.c_str(), &stat); + + if (stat.st_mode & S_IFREG || stat.st_mode & S_IFLNK) { + size_t len = strlen(buf); + + for (size_t i = len - 1; i >= 0; i--) { + if (buf[i] == '/') { + buf[i] = '\0'; + break; + } + } + } + + if (IsWChar::value) { + size_t needed = mbsrtowcs(nullptr, &str, 0, &state) + 1; + StringType s; + + s.reserve(needed); + mbsrtowcs((wchar_t *)&s[0], &str, s.size(), &state); + return s; + } + return StringType{buf}; + } +#elif _WIN32 + static StringType absolute_path_of(const StringType &path) { + constexpr size_t size = IsWChar::value ? MAX_PATH : 32767 * sizeof(wchar_t); + char buf[size * 10] = {}; + + DWORD length = + IsWChar::value + ? GetFullPathNameW((LPCWSTR)path.c_str(), size / sizeof(TCHAR), (LPWSTR)buf, + nullptr) + : GetFullPathNameA((LPCSTR)path.c_str(), size / sizeof(TCHAR), buf, nullptr); + + UnderpinningString tmp = UnderpinningString((C *)buf, length); + + return StringType(tmp); + } +#endif + +#if FILEWATCH_PLATFORM_MAC + static StringType utf8StringToUtf32String(const char *buffer) { + mbstate_t state{}; + StringType s{}; + + size_t needed = mbsrtowcs(nullptr, &buffer, 0, &state) + 1; + s.reserve(needed); + mbsrtowcs((wchar_t *)&s[0], &buffer, s.size(), &state); + return s; + } + + template ::value>> + static void walkDirectory(const StringType &path, Fn callback) { + int fd = open(path.c_str(), O_RDONLY); + char buf[1024]; + long basep = 0; + + if (fd == -1) { + return; + } + + int ret = __getdirentries64(fd, buf, sizeof(buf), &basep); + + while (ret > 0) { + char *current = buf; + int offset = 0; + + while (offset < ret) { + struct dirent *dirent = (struct dirent *)current; + StringType name = IsWChar::value ? utf8StringToUtf32String(dirent->d_name) + : StringType(dirent->d_name); + + callback(std::move(name)); + current += dirent->d_reclen; + offset += dirent->d_reclen; + } + ret = __getdirentries64(fd, buf, sizeof(buf), &basep); + } + close(fd); + } + + static StringType nameofFd(int fd) { + size_t len = 0; + char buf[MAXPATHLEN]; + + if (fcntl(fd, F_GETPATH, buf) == -1) { + return StringType{}; + } + if (IsWChar::value) { + return utf8StringToUtf32String(buf); + } + + len = strnlen(buf, MAXPATHLEN); + for (int i = len - 1; i >= 0; i--) { + if (buf[i] == '/') { + return StringType{buf + i + 1, len - i - 1}; + } + } + return StringType{buf, len}; + } + + static StringType fullPathOfFd(int fd) { + char buf[MAXPATHLEN]; + + if (fcntl(fd, F_GETPATH, buf) == -1) { + return StringType{}; + } + if (IsWChar::value) { + return utf8StringToUtf32String(buf); + } + return StringType{(C *)buf}; + } + + static StringType pathOfFd(int fd) { + size_t len = 0; + char buf[MAXPATHLEN]; + + if (fcntl(fd, F_GETPATH, buf) == -1) { + return StringType{}; + } + if (IsWChar::value) { + return utf8StringToUtf32String(buf); + } + + len = strnlen(buf, MAXPATHLEN); + for (int i = len - 1; i >= 0; i--) { + if (buf[i] == '/') { + return StringType{buf, static_cast(i)}; + } + } + return StringType{buf, len}; + } + + static bool fdIsRemoved(int fd) { + char buf[MAXPATHLEN]; + return fcntl(fd, F_GETPATH, buf) == -1; + } + + FileState makeFileState(const StringType &path) { + int fd = openFile(path); + struct stat stat; + + fstat(fd, &stat); + + return FileState{openFile(path), stat.st_nlink, stat.st_mtimespec.tv_sec}; + } + + static StringType filenameOf(const StringType &file) { + for (int i = file.size() - 1; i >= 0; i--) { + if (file[i] == '/') { + return file.substr(i + 1); + } + } + return file; + } + + static bool isInDirectory(const StringType &file, const StringType &path) { + if (file.size() < path.size()) { + return false; + } + return strncmp(file.data(), path.data(), path.size()) == 0; + } + + PathParts splitPath(const StringType &path) { + PathParts split = split_directory_and_file(path); + + if (split.directory.size() > 0 && split.directory[split.directory.size() - 1] == '/') { + split.directory.erase(split.directory.size() - 1); + } + return split; + } + + StringType fullPathOf(const StringType &file) { return _path + '/' + file; } + + int openFile(const StringType &file) { + int fd = open(fullPathOf(file).c_str(), O_RDONLY); + assert(fd != -1); + return fd; + } + + void walkAndSeeChanges() { + struct RenamedPair { + StringType old; + StringType current; + }; + struct EventInfo { + StringType file; + struct timespec time; + Event event; + }; + std::unordered_map newSnapshot{}; + std::vector events{}; + + for (auto &entry : _directory_snapshot) { + struct stat stat; + + fstat(entry.second.fd, &stat); + if (fdIsRemoved(entry.second.fd)) { + events.push_back(EventInfo{ + .event = Event::removed, .file = entry.first, .time = stat.st_ctimespec}); + continue; + } + + StringType fullPath = fullPathOfFd(entry.second.fd); + PathParts pathPair = splitPath(fullPath); + + if (pathPair.directory != _path) { + events.push_back(EventInfo{ + .event = Event::removed, .file = entry.first, .time = stat.st_ctimespec}); + continue; + } + if (entry.first != pathPair.filename) { + events.push_back(EventInfo{.event = Event::renamed_old, + .file = entry.first, + .time = stat.st_ctimespec}); + events.push_back(EventInfo{.event = Event::renamed_new, + .file = pathPair.filename, + .time = stat.st_ctimespec}); + } else { + if (stat.st_mtimespec.tv_sec > entry.second.last_modification) { + entry.second.last_modification = stat.st_mtimespec.tv_sec; + events.push_back(EventInfo{.event = Event::modified, + .file = pathPair.filename, + .time = stat.st_mtimespec}); + } + } + newSnapshot.insert(std::make_pair(std::move(pathPair.filename), + std::move(entry.second.invalidate_and_clone()))); + } + + walkDirectory(_path, [&](StringType file) { + if (isParentOrSelfDirectory(file) || !std::regex_match(file, _pattern)) { + return; + } + if (newSnapshot.count(file) == 0) { + FileState state = makeFileState(file); + struct stat stat; + + fstat(state.fd, &stat); + events.push_back( + EventInfo{.event = Event::added, .file = file, .time = stat.st_mtimespec}); + newSnapshot.insert(std::make_pair(file, std::move(state))); + } + }); + + std::swap(_directory_snapshot, newSnapshot); + + std::sort(events.begin(), events.end(), [](const EventInfo &a, EventInfo &b) { + if (a.time.tv_sec == b.time.tv_sec) { + return a.time.tv_nsec < b.time.tv_nsec; + } + return a.time.tv_sec < b.time.tv_sec; + }); + + { + std::lock_guard lock(_callback_mutex); + + for (const auto &event : events) { + _callback_information.push_back(std::make_pair(event.file, event.event)); + } + } + _cv.notify_all(); + } + + void seeSingleFileChanges() { + struct EventInfo { + StringType file; + Event event; + }; + + int eventCount = 1; + EventInfo eventInfos[2]; + + if (fdIsRemoved(_file_fd)) { + eventInfos[0].event = Event::removed; + eventInfos[0].file = _filename; + } else { + StringType absPath = pathOfFd(_file_fd); + PathParts split = splitPath(absPath); + + if (split.directory != _path) { + eventInfos[0].event = Event::removed; + eventInfos[0].file = _filename; + } else if (split.filename != _filename) { + eventInfos[0].event = Event::renamed_old; + eventInfos[0].file = std::move(_filename); + eventInfos[1].event = Event::renamed_new; + eventInfos[1].file = split.filename; + eventCount = 2; + _filename = std::move(split.filename); + } else { + struct stat stat; + + fstat(_file_fd, &stat); + + if (stat.st_mtimespec.tv_sec > _last_modification_time.tv_sec) { + eventInfos[0].event = Event::modified; + eventInfos[0].file = _filename; + _last_modification_time = stat.st_mtimespec; + } else if (stat.st_mtimespec.tv_nsec > _last_modification_time.tv_nsec) { + eventInfos[0].event = Event::modified; + eventInfos[0].file = _filename; + _last_modification_time = stat.st_mtimespec; + } else { + return; + } + } + } + + { + std::lock_guard lock(_callback_mutex); + for (int i = 0; i < eventCount; i++) { + _callback_information.push_back( + std::make_pair(eventInfos[i].file, eventInfos[i].event)); + } + } + _cv.notify_all(); + } + + void notify(CFStringRef path, const FSEventStreamEventFlags flags) { + CFIndex pathLength = CFStringGetLength(path); + CFIndex written = 0; + char buffer[PATH_MAX + 1]; + + CFStringGetBytes(path, + CFRange{ + .location = 0, + .length = pathLength, + }, + IsWChar::value ? kCFStringEncodingUTF32 : kCFStringEncodingUTF8, 0, + false, (UInt8 *)buffer, PATH_MAX, &written); + + buffer[written] = 0; + + StringType absolutePath{(const C *)buffer, static_cast(pathLength)}; + PathParts pathPair = splitPath(absolutePath); + + if (_watching_single_file && pathPair.filename != _filename) { + return; + } + if (pathPair.directory != _path || !std::regex_match(pathPair.filename, _pattern)) { + return; + } + + Event event = Event::modified; + if (_previous_event_is_rename) { + event = Event::renamed_new; + _directory_snapshot.insert( + std::make_pair(pathPair.filename, std::move(makeFileState(pathPair.filename)))); + _previous_event_is_rename = false; + } else if (flags & kFSEventStreamEventFlagItemRenamed) { + const auto state = _directory_snapshot.find(pathPair.filename); + assert(state != _directory_snapshot.end()); + StringType fdPath = pathOfFd(state->second.fd); + + // moved/delete to Trash folder + if (!isInDirectory(absolutePath, fdPath)) { + event = Event::removed; + _directory_snapshot.erase(pathPair.filename); + } else { + event = Event::renamed_old; + _previous_event_is_rename = true; + } + } else if (flags & kFSEventStreamEventFlagItemCreated) { + _directory_snapshot.insert( + std::make_pair(pathPair.filename, std::move(makeFileState(pathPair.filename)))); + event = Event::added; + } else if (flags & kFSEventStreamEventFlagItemRemoved) { + _directory_snapshot.erase(pathPair.filename); + event = Event::removed; + } + + { + std::lock_guard lock(_callback_mutex); + _callback_information.push_back( + std::make_pair(std::move(pathPair.filename), event)); + } + _cv.notify_all(); + } + + static void handleFsEvent(__attribute__((unused)) ConstFSEventStreamRef streamFef, + void *clientCallBackInfo, size_t numEvents, CFArrayRef eventPaths, + const FSEventStreamEventFlags *eventFlags, + __attribute__((unused)) const FSEventStreamEventId *eventIds) { + FileWatch *self = (FileWatch *)clientCallBackInfo; + + for (size_t i = 0; i < numEvents; i++) { + FSEventStreamEventFlags flag = eventFlags[i]; + CFStringRef path = (CFStringRef)CFArrayGetValueAtIndex(eventPaths, i); + + if (self->_watching_single_file) { + self->seeSingleFileChanges(); + } else if (flag & kFSEventStreamEventFlagMustScanSubDirs) { + self->walkAndSeeChanges(); + } else { + self->notify(path, flag); + } + } + } + + FSEventStreamRef openStream(const StringType &directory) { + CFStringEncoding encoding = IsWChar::value ? kCFStringEncodingUTF32 + : kCFStringEncodingASCII; + CFStringRef path = + CFStringCreateWithBytes(kCFAllocatorDefault, (const UInt8 *)directory.data(), + directory.size(), encoding, false); + CFArrayRef paths = CFArrayCreate(kCFAllocatorDefault, (const void **)&path, 1, nullptr); + FSEventStreamContext context{.info = (void *)this}; + FSEventStreamRef event = FSEventStreamCreate( + kCFAllocatorDefault, (FSEventStreamCallback)handleFsEvent, &context, paths, + kFSEventStreamEventIdSinceNow, 0, + kFSEventStreamCreateFlagNoDefer | kFSEventStreamCreateFlagFileEvents | + kFSEventStreamCreateFlagUseCFTypes); + + CFRelease(path); + CFRelease(paths); + return event; + } + + FSEventStreamRef openStreamForDirectory(const StringType &directory) { + FSEventStreamRef stream = openStream(directory); + walkDirectory(directory, [this](StringType path) mutable { + if (!isParentOrSelfDirectory(path) && std::regex_match(path, _pattern)) { + _directory_snapshot.insert( + std::make_pair(std::move(path), std::move(makeFileState(path)))); + } + }); + return stream; + } + + FSEventStreamRef openStreamForFile(const StringType &file) { + PathParts split = splitPath(file); + + _watching_single_file = true; + _filename = std::move(split.filename); + _file_fd = openFile(file); + return openStreamForDirectory(split.directory); + } + + FSEventStreamRef get_directory(const StringType &directory) { + struct stat stat; + + ::stat((const char *)directory.c_str(), &stat); + if (stat.st_mode & S_IFDIR) { + return openStreamForDirectory(directory); + } + _last_modification_time = stat.st_mtimespec; + return openStreamForFile(directory); + } + + void monitor_directory() { + _run_loop = CFRunLoopGetCurrent(); + FSEventStreamScheduleWithRunLoop(_directory, _run_loop, kCFRunLoopDefaultMode); + FSEventStreamStart(_directory); + _running.set_value(); + CFRunLoopRun(); + } +#endif // FILEWATCH_PLATFORM_MAC + + void callback_thread() { + while (_destory == false) { + std::unique_lock lock(_callback_mutex); + if (_callback_information.empty() && _destory == false) { + _cv.wait(lock, [this] { return _callback_information.size() > 0 || _destory; }); + } + decltype(_callback_information) callback_information = {}; + std::swap(callback_information, _callback_information); + lock.unlock(); + + for (const auto &file : callback_information) { + if (_callback) { + try { + _callback(file.first, file.second); + } catch (const std::exception &) { + } + } + } + } + } + }; + + template + constexpr typename FileWatch::C FileWatch::_regex_all[]; + template + constexpr typename FileWatch::C FileWatch::_this_directory[]; +} // namespace filewatch +#endif \ No newline at end of file diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 987ad230..8db91c64 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -121,7 +121,7 @@ namespace Toolbox::UI { m_is_renaming = false; if (m_view_proxy.isDirectory(child_index)) { m_view_index = m_view_proxy.toSourceIndex(child_index); - m_fs_watchdog.addPath(m_file_system_model->getPath(m_view_index)); + //m_fs_watchdog.addPath(m_file_system_model->getPath(m_view_index)); ImGui::EndChild(); ImGui::PopStyleColor(1); break; @@ -232,10 +232,6 @@ namespace Toolbox::UI { m_view_index = m_view_proxy.getIndex(0, 0); m_fs_watchdog.reset(); m_fs_watchdog.addPath(m_project_root); - m_fs_watchdog.onFileRemoved([this](const fs_path &path) { - TOOLBOX_INFO_V("File removed: {}", path.string()); - //m_file_system_model->removeIndex(m_file_system_model->getIndex(path)); - }); m_fs_watchdog.onFileAdded( [this](const fs_path &path) { TOOLBOX_INFO_V("File added: {}", path.string()); @@ -254,9 +250,17 @@ namespace Toolbox::UI { TOOLBOX_INFO_V("Dir modified: {}", path.string()); //m_file_system_model->updateIndex(m_file_system_model->getIndex(path)); }); - m_fs_watchdog.onDirRemoved([this](const fs_path &path) { - TOOLBOX_INFO_V("Dir removed: {}", path.string()); - //m_file_system_model->renameIndex(m_file_system_model->getIndex(old_path), new_path); + m_fs_watchdog.onPathRenamedSrc([this](const fs_path &path) { + TOOLBOX_INFO_V("Path renamed from: {}", path.string()); + // m_file_system_model->updateIndex(m_file_system_model->getIndex(path)); + }); + m_fs_watchdog.onPathRenamedDst([this](const fs_path &path) { + TOOLBOX_INFO_V("Path renamed to: {}", path.string()); + // m_file_system_model->updateIndex(m_file_system_model->getIndex(path)); + }); + m_fs_watchdog.onPathRemoved([this](const fs_path &path) { + TOOLBOX_INFO_V("Path removed: {}", path.string()); + // m_file_system_model->updateIndex(m_file_system_model->getIndex(path)); }); return true; } @@ -304,7 +308,7 @@ namespace Toolbox::UI { if (ImGui::IsItemClicked()) { m_view_index = m_tree_proxy.toSourceIndex(index); - m_fs_watchdog.addPath(m_file_system_model->getPath(m_view_index)); + //m_fs_watchdog.addPath(m_file_system_model->getPath(m_view_index)); } if (is_open) { diff --git a/src/watchdog/fswatchdog.cpp b/src/watchdog/fswatchdog.cpp index 85ab6516..69dea6ba 100644 --- a/src/watchdog/fswatchdog.cpp +++ b/src/watchdog/fswatchdog.cpp @@ -1,10 +1,15 @@ +#include +#include + +#include "core/core.hpp" #include "watchdog/fswatchdog.hpp" namespace Toolbox { void FileSystemWatchdog::reset() { std::scoped_lock lock(m_mutex); - m_watch_paths.clear(); + m_dir_paths.clear(); + m_file_paths.clear(); m_path_infos.clear(); } @@ -20,52 +25,91 @@ namespace Toolbox { void FileSystemWatchdog::addPath(const fs_path &path) { std::scoped_lock lock(m_mutex); - m_watch_paths.insert(path); + if (Toolbox::Filesystem::is_directory(path).value_or(false)) { + m_dir_paths.emplace(this, path); + } else { + m_file_paths.emplace(this, path); + } } void FileSystemWatchdog::addPath(fs_path &&path) { std::scoped_lock lock(m_mutex); - m_watch_paths.emplace(std::move(path)); + if (Toolbox::Filesystem::is_directory(path).value_or(false)) { + m_dir_paths.emplace(this, std::move(path)); + } else { + m_file_paths.emplace(this, std::move(path)); + } } void FileSystemWatchdog::removePath(const fs_path &path) { std::scoped_lock lock(m_mutex); - m_watch_paths.erase(path); + + for (auto it = m_dir_paths.begin(); it != m_dir_paths.end(); ++it) { + if (it->getPath() == path) { + m_dir_paths.erase(it); + return; + } + } + + for (auto it = m_file_paths.begin(); it != m_file_paths.end(); ++it) { + if (it->getPath() == path) { + m_file_paths.erase(it); + return; + } + } } void FileSystemWatchdog::removePath(fs_path &&path) { std::scoped_lock lock(m_mutex); - m_watch_paths.erase(std::move(path)); + + for (auto it = m_dir_paths.begin(); it != m_dir_paths.end(); ++it) { + if (it->getPath() == path) { + m_dir_paths.erase(it); + return; + } + } + + for (auto it = m_file_paths.begin(); it != m_file_paths.end(); ++it) { + if (it->getPath() == path) { + m_file_paths.erase(it); + return; + } + } } - void FileSystemWatchdog::onFileAdded(file_added_cb cb) { + void FileSystemWatchdog::onFileAdded(file_changed_cb cb) { std::scoped_lock lock(m_mutex); m_file_added_cb = cb; } - void FileSystemWatchdog::onFileRemoved(file_removed_cb cb) { + void FileSystemWatchdog::onFileModified(file_changed_cb cb) { std::scoped_lock lock(m_mutex); - m_file_removed_cb = cb; + m_file_modified_cb = cb; } - void FileSystemWatchdog::onFileModified(file_modified_cb cb) { + void FileSystemWatchdog::onDirAdded(dir_changed_cb cb) { std::scoped_lock lock(m_mutex); - m_file_modified_cb = cb; + m_dir_added_cb = cb; } - void FileSystemWatchdog::onDirAdded(dir_added_cb cb) { + void FileSystemWatchdog::onDirModified(dir_changed_cb cb) { std::scoped_lock lock(m_mutex); - m_dir_added_cb = cb; + m_dir_modified_cb = cb; } - void FileSystemWatchdog::onDirRemoved(dir_removed_cb cb) { + void FileSystemWatchdog::onPathRenamedSrc(path_changed_cb cb) { std::scoped_lock lock(m_mutex); - m_dir_removed_cb = cb; + m_path_renamed_src_cb = cb; } - void FileSystemWatchdog::onDirModified(dir_modified_cb cb) { + void FileSystemWatchdog::onPathRenamedDst(path_changed_cb cb) { std::scoped_lock lock(m_mutex); - m_dir_modified_cb = cb; + m_path_renamed_dst_cb = cb; + } + + void FileSystemWatchdog::onPathRemoved(file_changed_cb cb) { + std::scoped_lock lock(m_mutex); + m_path_removed_cb = cb; } void FileSystemWatchdog::tRun(void *param) { @@ -74,103 +118,105 @@ namespace Toolbox { std::this_thread::sleep_for(std::chrono::milliseconds(100)); } +#if 0 { std::scoped_lock lock(m_mutex); - for (const auto &path : m_watch_paths) { + for (const auto &path : m_file_paths) { + observePathF(path); + } + for (const auto &path : m_dir_paths) { observePath(path); } } +#endif std::this_thread::sleep_for(std::chrono::milliseconds(100)); } } - void FileSystemWatchdog::observePath(const fs_path &path) { - if (m_path_infos.find(path) == m_path_infos.end()) { - m_path_infos[path] = createFileInfo(path); - return; - } - - const FileInfo &old_info = m_path_infos[path]; - FileInfo new_info = createFileInfo(path); + PathWatcher_::PathWatcher_(FileSystemWatchdog *watchdog, const fs_path &path) { + m_watchdog = watchdog; + m_path = path; + m_is_dir = Toolbox::Filesystem::is_directory(path).value_or(false); + m_is_file = !m_is_dir; + m_is_open = false; - signalChanges(path, old_info, new_info); - - if (new_info.m_is_dir) { - for (const auto &entry : Toolbox::Filesystem::directory_iterator(path)) { - observePathF(entry.path()); - } + if (m_is_dir) { + watchDirectory(path); + } else { + watchFile(path); } - - m_path_infos[path] = new_info; } - void FileSystemWatchdog::observePathF(const fs_path &path) { - if (m_path_infos.find(path) == m_path_infos.end()) { - m_path_infos[path] = createFileInfo(path); - return; + PathWatcher_::~PathWatcher_() { + if (m_is_dir) { + closeDirectory(); + } else { + closeFile(); } + } - const FileInfo &old_info = m_path_infos[path]; - FileInfo new_info = createFileInfo(path); - - signalChanges(path, old_info, new_info); + void PathWatcher_::watchDirectory(const fs_path &path) { + m_watch = + make_scoped>(path, TOOLBOX_BIND_EVENT_FN(callback_)); + } - m_path_infos[path] = new_info; + void PathWatcher_::watchFile(const fs_path &path) { + m_watch = + make_scoped>(path, TOOLBOX_BIND_EVENT_FN(callback_)); } - FileSystemWatchdog::FileInfo FileSystemWatchdog::createFileInfo(const fs_path &path) { - FileInfo info; + void PathWatcher_::closeDirectory() { m_watch.reset(); } - info.m_is_dir = Toolbox::Filesystem::is_directory(path).value_or(false); - info.m_exists = Toolbox::Filesystem::exists(path).value_or(false); - info.m_time = - Toolbox::Filesystem::last_write_time(path).value_or(Filesystem::file_time_type::min()); + void PathWatcher_::closeFile() { m_watch.reset(); } - if (!info.m_is_dir && info.m_exists) { - info.m_size = Toolbox::Filesystem::file_size(path).value_or(0); + void PathWatcher_::callback_(const fs_path &path, const filewatch::Event event) { + std::scoped_lock lock(m_watchdog->m_mutex); + + if (m_watchdog->m_asleep) { + return; } - return info; - } - - void FileSystemWatchdog::signalChanges(const fs_path &path, const FileInfo &a, - const FileInfo &b) { - if (a.m_exists != b.m_exists) { - if (b.m_exists) { - if (b.m_is_dir) { - if (m_dir_added_cb) { - m_dir_added_cb(path); - } - } else { - if (m_file_added_cb) { - m_file_added_cb(path); - } + fs_path abs_path = m_path / path; + bool is_dir = Filesystem::is_directory(abs_path).value_or(false); + + switch (event) { + case filewatch::Event::added: + if (is_dir) { + if (m_watchdog->m_dir_added_cb) { + m_watchdog->m_dir_added_cb(abs_path); } } else { - if (b.m_is_dir) { - if (m_dir_removed_cb) { - m_dir_removed_cb(path); - } - } else { - if (m_file_removed_cb) { - m_file_removed_cb(path); - } + if (m_watchdog->m_file_added_cb) { + m_watchdog->m_file_added_cb(abs_path); } } - } else { - if (b.m_exists) { - if (b.m_time != a.m_time) { - if (b.m_is_dir) { - if (m_dir_modified_cb) { - m_dir_modified_cb(path); - } - } else { - if (m_file_modified_cb) { - m_file_modified_cb(path); - } - } + break; + case filewatch::Event::modified: + if (is_dir) { + if (m_watchdog->m_dir_modified_cb) { + m_watchdog->m_dir_modified_cb(abs_path); + } + } else { + if (m_watchdog->m_file_modified_cb) { + m_watchdog->m_file_modified_cb(abs_path); } } + break; + case filewatch::Event::removed: + if (m_watchdog->m_path_removed_cb) { + m_watchdog->m_path_removed_cb(abs_path); + } + break; + case filewatch::Event::renamed_old: + if (m_watchdog->m_path_renamed_src_cb) { + m_watchdog->m_path_renamed_src_cb(abs_path); + } + break; + case filewatch::Event::renamed_new: + if (m_watchdog->m_path_renamed_dst_cb) { + m_watchdog->m_path_renamed_dst_cb(abs_path); + } + break; } } From 4579be27454442afcff1dd7781e095086696dcd5 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Sat, 28 Sep 2024 23:59:57 -0500 Subject: [PATCH 039/129] Integrate watchdog updates into fs model --- include/gui/project/window.hpp | 3 - include/model/fsmodel.hpp | 87 ++++- include/watchdog/fswatchdog.hpp | 2 + src/gui/project/window.cpp | 45 +-- src/model/fsmodel.cpp | 622 +++++++++++++++++++++++++------- 5 files changed, 590 insertions(+), 169 deletions(-) diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 6d451ac4..3aa25906 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -22,7 +22,6 @@ #include "gui/project/asset.hpp" #include "model/fsmodel.hpp" -#include "watchdog/fswatchdog.hpp" #include @@ -97,8 +96,6 @@ namespace Toolbox::UI { private: fs_path m_project_root; - FileSystemWatchdog m_fs_watchdog; - // TODO: Have filesystem model. FileSystemModelSortFilterProxy m_tree_proxy; FileSystemModelSortFilterProxy m_view_proxy; diff --git a/include/model/fsmodel.hpp b/include/model/fsmodel.hpp index 3b8a8d9d..619278c5 100644 --- a/include/model/fsmodel.hpp +++ b/include/model/fsmodel.hpp @@ -16,6 +16,8 @@ #include "model/model.hpp" #include "unique.hpp" +#include "watchdog/fswatchdog.hpp" + namespace Toolbox { enum class FileSystemModelSortRole { @@ -32,6 +34,22 @@ namespace Toolbox { }; TOOLBOX_BITWISE_ENUM(FileSystemModelOptions) + enum class FileSystemModelEventFlags { + NONE = 0, + EVENT_FILE_ADDED = BIT(0), + EVENT_FILE_MODIFIED = BIT(1), + EVENT_FOLDER_ADDED = BIT(2), + EVENT_FOLDER_MODIFIED = BIT(3), + EVENT_PATH_RENAMED = BIT(4), + EVENT_PATH_REMOVED = BIT(5), + EVENT_FILE_ANY = + EVENT_FILE_ADDED | EVENT_FILE_MODIFIED | EVENT_PATH_RENAMED | EVENT_PATH_REMOVED, + EVENT_FOLDER_ANY = + EVENT_FOLDER_ADDED | EVENT_FOLDER_MODIFIED | EVENT_PATH_RENAMED | EVENT_PATH_REMOVED, + EVENT_ANY = EVENT_FILE_ANY | EVENT_FOLDER_ANY, + }; + TOOLBOX_BITWISE_ENUM(FileSystemModelEventFlags) + enum FileSystemDataRole { FS_DATA_ROLE_DATE = ModelDataRole::DATA_ROLE_USER, FS_DATA_ROLE_STATUS, @@ -46,7 +64,7 @@ namespace Toolbox { }; public: - FileSystemModel() = default; + FileSystemModel() = default; ~FileSystemModel(); void initialize(); @@ -115,24 +133,77 @@ namespace Toolbox { [[nodiscard]] bool canFetchMore(const ModelIndex &index) override; void fetchMore(const ModelIndex &index) override; + using event_listener_t = std::function; + void addEventListener(UUID64 uuid, event_listener_t listener, FileSystemModelEventFlags flags); + void removeEventListener(UUID64 uuid); + static const ImageHandle &InvalidIcon(); static const std::unordered_map &TypeMap(); protected: - ModelIndex makeIndex(const fs_path &path, int64_t row, const ModelIndex &parent) override; + [[nodiscard]] bool isDirectory_(const ModelIndex &index) const; + [[nodiscard]] bool isFile_(const ModelIndex &index) const; + [[nodiscard]] bool isArchive_(const ModelIndex &index) const; + + [[nodiscard]] size_t getFileSize_(const ModelIndex &index) const; + [[nodiscard]] size_t getDirSize_(const ModelIndex &index, bool recursive) const; + + // Implementation of public API for mutex locking reasons + [[nodiscard]] std::any getData_(const ModelIndex &index, int role) const; + + ModelIndex mkdir_(const ModelIndex &parent, const std::string &name); + ModelIndex touch_(const ModelIndex &parent, const std::string &name); + ModelIndex rename_(const ModelIndex &file, const std::string &new_name); + + bool rmdir_(const ModelIndex &index); + bool remove_(const ModelIndex &index); + + [[nodiscard]] ModelIndex getIndex_(const fs_path &path) const; + [[nodiscard]] ModelIndex getIndex_(const UUID64 &path) const; + [[nodiscard]] ModelIndex getIndex_(int64_t row, int64_t column, + const ModelIndex &parent = ModelIndex()) const; + [[nodiscard]] fs_path getPath_(const ModelIndex &index) const; + + [[nodiscard]] ModelIndex getParent_(const ModelIndex &index) const; + [[nodiscard]] ModelIndex getSibling_(int64_t row, int64_t column, + const ModelIndex &index) const; + + [[nodiscard]] size_t getColumnCount_(const ModelIndex &index) const; + [[nodiscard]] size_t getRowCount_(const ModelIndex &index) const; - void cacheIndex(ModelIndex &index); - void cacheFolder(ModelIndex &index); - void cacheFile(ModelIndex &index); - void cacheArchive(ModelIndex &index); + [[nodiscard]] bool hasChildren_(const ModelIndex &parent = ModelIndex()) const; + + [[nodiscard]] ScopePtr + createMimeData_(const std::vector &indexes) const; + + [[nodiscard]] bool canFetchMore_(const ModelIndex &index); + void fetchMore_(const ModelIndex &index); + // -- END -- // + + ModelIndex makeIndex(const fs_path &path, int64_t row, const ModelIndex &parent) override; ModelIndex getParentArchive(const ModelIndex &index) const; size_t pollChildren(const ModelIndex &index) const; + void folderAdded(const fs_path &path); + void folderModified(const fs_path &path); + + void fileAdded(const fs_path &path); + void fileModified(const fs_path &path); + + void pathRenamedSrc(const fs_path &old_path); + void pathRenamedDst(const fs_path &new_path); + + void pathRemoved(const fs_path &path); + private: UUID64 m_uuid; + mutable std::mutex m_mutex; + FileSystemWatchdog m_watchdog; + std::unordered_map> m_listeners; + fs_path m_root_path; FileSystemModelOptions m_options = FileSystemModelOptions::NONE; @@ -142,6 +213,8 @@ namespace Toolbox { mutable std::unordered_map m_index_map; mutable std::unordered_map> m_icon_map; + + fs_path m_rename_src; }; class FileSystemModelSortFilterProxy : public IDataModel { @@ -226,6 +299,8 @@ namespace Toolbox { return ModelIndex(); } + void fsUpdateEvent(const fs_path &path, FileSystemModelEventFlags flags); + private: UUID64 m_uuid; diff --git a/include/watchdog/fswatchdog.hpp b/include/watchdog/fswatchdog.hpp index a6e9b290..064eb54e 100644 --- a/include/watchdog/fswatchdog.hpp +++ b/include/watchdog/fswatchdog.hpp @@ -1,3 +1,5 @@ +#pragma once + #include #include #include diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 8db91c64..f6de6489 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -58,6 +58,11 @@ namespace Toolbox::UI { for (size_t i = 0; i < m_view_proxy.getRowCount(m_view_index); ++i) { ModelIndex child_index = m_view_proxy.getIndex(i, 0, view_index); + if (!m_view_proxy.validateIndex(child_index)) { + TOOLBOX_DEBUG_LOG_V("Invalid index: {}", i); + continue; + } + bool is_selected = std::find(m_selected_indices.begin(), m_selected_indices.end(), child_index) != m_selected_indices.end(); @@ -121,7 +126,7 @@ namespace Toolbox::UI { m_is_renaming = false; if (m_view_proxy.isDirectory(child_index)) { m_view_index = m_view_proxy.toSourceIndex(child_index); - //m_fs_watchdog.addPath(m_file_system_model->getPath(m_view_index)); + // m_fs_watchdog.addPath(m_file_system_model->getPath(m_view_index)); ImGui::EndChild(); ImGui::PopStyleColor(1); break; @@ -230,44 +235,12 @@ namespace Toolbox::UI { m_view_proxy.setSourceModel(m_file_system_model); m_view_proxy.setSortRole(FileSystemModelSortRole::SORT_ROLE_NAME); m_view_index = m_view_proxy.getIndex(0, 0); - m_fs_watchdog.reset(); - m_fs_watchdog.addPath(m_project_root); - m_fs_watchdog.onFileAdded( - [this](const fs_path &path) { - TOOLBOX_INFO_V("File added: {}", path.string()); - fs_path parent = path.parent_path(); - /*m_file_system_model->addIndex(;*/ - }); - m_fs_watchdog.onFileModified([this](const fs_path& path) { - TOOLBOX_INFO_V("File modified: {}", path.string()); - //m_file_system_model->updateIndex(m_file_system_model->getIndex(path)); - }); - m_fs_watchdog.onDirAdded([this](const fs_path& path) { - TOOLBOX_INFO_V("Dir added: {}", path.string()); - //m_file_system_model->addIndex(m_file_system_model->getIndex(path)); - }); - m_fs_watchdog.onDirModified([this](const fs_path& path) { - TOOLBOX_INFO_V("Dir modified: {}", path.string()); - //m_file_system_model->updateIndex(m_file_system_model->getIndex(path)); - }); - m_fs_watchdog.onPathRenamedSrc([this](const fs_path &path) { - TOOLBOX_INFO_V("Path renamed from: {}", path.string()); - // m_file_system_model->updateIndex(m_file_system_model->getIndex(path)); - }); - m_fs_watchdog.onPathRenamedDst([this](const fs_path &path) { - TOOLBOX_INFO_V("Path renamed to: {}", path.string()); - // m_file_system_model->updateIndex(m_file_system_model->getIndex(path)); - }); - m_fs_watchdog.onPathRemoved([this](const fs_path &path) { - TOOLBOX_INFO_V("Path removed: {}", path.string()); - // m_file_system_model->updateIndex(m_file_system_model->getIndex(path)); - }); return true; } - void ProjectViewWindow::onAttach() { m_fs_watchdog.tStart(false, nullptr); } + void ProjectViewWindow::onAttach() {} - void ProjectViewWindow::onDetach() { m_fs_watchdog.tKill(true); } + void ProjectViewWindow::onDetach() {} void ProjectViewWindow::onImGuiUpdate(TimeStep delta_time) {} @@ -308,7 +281,7 @@ namespace Toolbox::UI { if (ImGui::IsItemClicked()) { m_view_index = m_tree_proxy.toSourceIndex(index); - //m_fs_watchdog.addPath(m_file_system_model->getPath(m_view_index)); + // m_fs_watchdog.addPath(m_file_system_model->getPath(m_view_index)); } if (is_open) { diff --git a/src/model/fsmodel.cpp b/src/model/fsmodel.cpp index c485a367..5a36fbc5 100644 --- a/src/model/fsmodel.cpp +++ b/src/model/fsmodel.cpp @@ -114,6 +114,7 @@ namespace Toolbox { for (auto &[key, value] : m_index_map) { delete value.data<_FileSystemIndexData>(); } + m_watchdog.tKill(true); } void FileSystemModel::initialize() { @@ -135,6 +136,16 @@ namespace Toolbox { TOOLBOX_ERROR_V("[FileSystemModel] Failed to load icon: {}", value.m_image_name); } } + + m_watchdog.onDirAdded(TOOLBOX_BIND_EVENT_FN(folderAdded)); + m_watchdog.onDirModified(TOOLBOX_BIND_EVENT_FN(folderModified)); + m_watchdog.onFileAdded(TOOLBOX_BIND_EVENT_FN(fileAdded)); + m_watchdog.onFileModified(TOOLBOX_BIND_EVENT_FN(fileModified)); + m_watchdog.onPathRemoved(TOOLBOX_BIND_EVENT_FN(pathRemoved)); + m_watchdog.onPathRenamedSrc(TOOLBOX_BIND_EVENT_FN(pathRenamedSrc)); + m_watchdog.onPathRenamedDst(TOOLBOX_BIND_EVENT_FN(pathRenamedDst)); + + m_watchdog.tStart(false, nullptr); } const fs_path &FileSystemModel::getRoot() const & { return m_root_path; } @@ -144,10 +155,17 @@ namespace Toolbox { return; } - m_index_map.clear(); + { + std::scoped_lock lock(m_mutex); + + m_watchdog.reset(); + m_watchdog.addPath(path); + + m_index_map.clear(); - m_root_path = path; - m_root_index = makeIndex(path, 0, ModelIndex()).getUUID(); + m_root_path = path; + m_root_index = makeIndex(path, 0, ModelIndex()).getUUID(); + } } FileSystemModelOptions FileSystemModel::getOptions() const { return m_options; } @@ -159,41 +177,219 @@ namespace Toolbox { void FileSystemModel::setReadOnly(bool read_only) { m_read_only = read_only; } bool FileSystemModel::isDirectory(const ModelIndex &index) const { + std::scoped_lock lock(m_mutex); + return isDirectory_(index); + } + + bool FileSystemModel::isFile(const ModelIndex &index) const { + std::scoped_lock lock(m_mutex); + return isFile_(index); + } + + bool FileSystemModel::isArchive(const ModelIndex &index) const { + std::scoped_lock lock(m_mutex); + return isArchive_(index); + } + + size_t FileSystemModel::getFileSize(const ModelIndex &index) const { + std::scoped_lock lock(m_mutex); + return getFileSize_(index); + } + + size_t FileSystemModel::getDirSize(const ModelIndex &index, bool recursive) const { + std::scoped_lock lock(m_mutex); + return getDirSize_(index, recursive); + } + + std::any FileSystemModel::getData(const ModelIndex &index, int role) const { + std::scoped_lock lock(m_mutex); + return getData_(index, role); + } + + ModelIndex FileSystemModel::mkdir(const ModelIndex &parent, const std::string &name) { + std::scoped_lock lock(m_mutex); + return mkdir_(parent, name); + } + + ModelIndex FileSystemModel::touch(const ModelIndex &parent, const std::string &name) { + std::scoped_lock lock(m_mutex); + return touch_(parent, name); + } + + bool FileSystemModel::rmdir(const ModelIndex &index) { + std::scoped_lock lock(m_mutex); + return rmdir_(index); + } + + bool FileSystemModel::remove(const ModelIndex &index) { + std::scoped_lock lock(m_mutex); + return remove_(index); + } + + ModelIndex FileSystemModel::rename(const ModelIndex &file, const std::string &new_name) { + std::scoped_lock lock(m_mutex); + return rename_(file, new_name); + } + + ModelIndex FileSystemModel::getIndex(const fs_path &path) const { + std::scoped_lock lock(m_mutex); + return getIndex_(path); + } + + ModelIndex FileSystemModel::getIndex(const UUID64 &uuid) const { + std::scoped_lock lock(m_mutex); + return getIndex_(uuid); + } + + ModelIndex FileSystemModel::getIndex(int64_t row, int64_t column, + const ModelIndex &parent) const { + std::scoped_lock lock(m_mutex); + return getIndex_(row, column, parent); + } + + fs_path FileSystemModel::getPath(const ModelIndex &index) const { + std::scoped_lock lock(m_mutex); + return getPath_(index); + } + + ModelIndex FileSystemModel::getParent(const ModelIndex &index) const { + std::scoped_lock lock(m_mutex); + return getParent_(index); + } + + ModelIndex FileSystemModel::getSibling(int64_t row, int64_t column, + const ModelIndex &index) const { + std::scoped_lock lock(m_mutex); + return getSibling_(row, column, index); + } + + size_t FileSystemModel::getColumnCount(const ModelIndex &index) const { + std::scoped_lock lock(m_mutex); + return getColumnCount_(index); + } + + size_t FileSystemModel::getRowCount(const ModelIndex &index) const { + std::scoped_lock lock(m_mutex); + return getRowCount_(index); + } + + bool FileSystemModel::hasChildren(const ModelIndex &parent) const { + std::scoped_lock lock(m_mutex); + return hasChildren_(parent); + } + + ScopePtr + FileSystemModel::createMimeData(const std::vector &indexes) const { + std::scoped_lock lock(m_mutex); + return createMimeData_(indexes); + } + + std::vector FileSystemModel::getSupportedMimeTypes() const { + return std::vector(); + } + + bool FileSystemModel::canFetchMore(const ModelIndex &index) { + std::scoped_lock lock(m_mutex); + return canFetchMore_(index); + } + + void FileSystemModel::fetchMore(const ModelIndex &index) { + std::scoped_lock lock(m_mutex); + return fetchMore_(index); + } + + void FileSystemModel::addEventListener(UUID64 uuid, event_listener_t listener, + FileSystemModelEventFlags flags) { + m_listeners[uuid] = {listener, flags}; + } + + void FileSystemModel::removeEventListener(UUID64 uuid) { m_listeners.erase(uuid); } + + const ImageHandle &FileSystemModel::InvalidIcon() { + static ImageHandle s_invalid_fs_icon = ImageHandle("Images/Icons/fs_invalid.png"); + return s_invalid_fs_icon; + } + + const std::unordered_map &FileSystemModel::TypeMap() { + // clang-format off + static std::unordered_map s_type_map = { + {"_Invalid", FSTypeInfo("Invalid", "fs_invalid.png") }, + {"_Folder", FSTypeInfo("Folder", "fs_generic_folder.png")}, + {"_Archive", FSTypeInfo("Archive", "fs_arc.png") }, + {"_File", FSTypeInfo("File", "fs_generic_file.png") }, + {".txt", FSTypeInfo("Text", "fs_txt.png") }, + {".md", FSTypeInfo("Markdown", "fs_md.png") }, + {".c", FSTypeInfo("C", "fs_c.png") }, + {".h", FSTypeInfo("Header", "fs_h.png") }, + {".cpp", FSTypeInfo("C++", "fs_cpp.png") }, + {".hpp", FSTypeInfo("Header", "fs_hpp.png") }, + {".cxx", FSTypeInfo("C++", "fs_cpp.png") }, + {".hxx", FSTypeInfo("Header", "fs_hpp.png") }, + {".c++", FSTypeInfo("C++", "fs_cpp.png") }, + {".h++", FSTypeInfo("Header", "fs_hpp.png") }, + {".cc", FSTypeInfo("C++", "fs_cpp.png") }, + {".hh", FSTypeInfo("Header", "fs_hpp.png") }, + {".arc", FSTypeInfo("Archive", "fs_arc.png") }, + {".bas", FSTypeInfo("JAudio Sequence", "fs_bas.png") }, + {".bck", FSTypeInfo("J3D Bone Animation", "fs_bck.png") }, + {".bdl", FSTypeInfo("J3D Model Data", "fs_bdl.png") }, + {".blo", FSTypeInfo("J2D Screen Layout", "fs_blo.png") }, + {".bmd", FSTypeInfo("J3D Model Data", "fs_bmd.png") }, + {".bmg", FSTypeInfo("Message Data", "fs_bmg.png") }, + {".bmt", FSTypeInfo("J3D Material Table", "fs_bmt.png") }, + {".brk", FSTypeInfo("J3D Color Register Anim", "fs_brk.png") }, + {".bti", FSTypeInfo("J2D Texture Image", "fs_bti.png") }, + {".btk", FSTypeInfo("J2D Texture Animation", "fs_btk.png") }, + {".btp", FSTypeInfo("J2D Texture Pattern Anim", "fs_btp.png") }, + {".col", FSTypeInfo("SMS Collision Data", "fs_col.png") }, + {".jpa", FSTypeInfo("JParticle Data", "fs_jpa.png") }, + {".map", FSTypeInfo("Executable Symbol Map", "fs_map.png") }, + {".me", FSTypeInfo("Marked For Delete", "fs_me.png") }, + {".prm", FSTypeInfo("SMS Parameter Data", "fs_prm.png") }, + {".sb", FSTypeInfo("Sunscript", "fs_sb.png") }, + {".szs", FSTypeInfo("Yaz0 Compressed Data", "fs_szs.png") }, + {".thp", FSTypeInfo("DolphinOS Movie Data", "fs_thp.png") }, + }; + // clang-format on + return s_type_map; + } + + bool FileSystemModel::isDirectory_(const ModelIndex &index) const { if (!validateIndex(index)) { return false; } return index.data<_FileSystemIndexData>()->m_type == _FileSystemIndexData::Type::DIRECTORY; } - bool FileSystemModel::isFile(const ModelIndex &index) const { + bool FileSystemModel::isFile_(const ModelIndex &index) const { if (!validateIndex(index)) { return false; } return index.data<_FileSystemIndexData>()->m_type == _FileSystemIndexData::Type::FILE; } - bool FileSystemModel::isArchive(const ModelIndex &index) const { + bool FileSystemModel::isArchive_(const ModelIndex &index) const { if (!validateIndex(index)) { return false; } return index.data<_FileSystemIndexData>()->m_type == _FileSystemIndexData::Type::ARCHIVE; } - size_t FileSystemModel::getFileSize(const ModelIndex &index) const { - if (!isFile(index)) { + size_t FileSystemModel::getFileSize_(const ModelIndex &index) const { + if (!isFile_(index)) { return 0; } return index.data<_FileSystemIndexData>()->m_size; } - size_t FileSystemModel::getDirSize(const ModelIndex &index, bool recursive) const { - if (!(isDirectory(index) || isArchive(index))) { + size_t FileSystemModel::getDirSize_(const ModelIndex &index, bool recursive) const { + if (!(isDirectory_(index) || isArchive_(index))) { return 0; } return index.data<_FileSystemIndexData>()->m_size; } - std::any FileSystemModel::getData(const ModelIndex &index, int role) const { + std::any FileSystemModel::getData_(const ModelIndex &index, int role) const { if (!validateIndex(index)) { return {}; } @@ -210,7 +406,7 @@ namespace Toolbox { Filesystem::file_time_type result = Filesystem::file_time_type(); - fs_path path = getPath(index); + fs_path path = getPath_(index); Filesystem::last_write_time(path) .and_then([&](Filesystem::file_time_type &&time) { result = std::move(time); @@ -228,7 +424,7 @@ namespace Toolbox { Filesystem::file_status result = Filesystem::file_status(); - fs_path path = getPath(index); + fs_path path = getPath_(index); Filesystem::status(path) .and_then([&](Filesystem::file_status &&status) { result = std::move(status); @@ -244,11 +440,11 @@ namespace Toolbox { } case FileSystemDataRole::FS_DATA_ROLE_TYPE: { - if (isDirectory(index)) { + if (isDirectory_(index)) { return TypeMap().at("_Folder").m_name; } - if (isArchive(index)) { + if (isArchive_(index)) { return TypeMap().at("_Archive").m_name; } @@ -273,15 +469,15 @@ namespace Toolbox { } } - ModelIndex FileSystemModel::mkdir(const ModelIndex &parent, const std::string &name) { + ModelIndex FileSystemModel::mkdir_(const ModelIndex &parent, const std::string &name) { if (!validateIndex(parent)) { return ModelIndex(); } bool result = false; - if (isDirectory(parent)) { - fs_path path = getPath(parent); + if (isDirectory_(parent)) { + fs_path path = getPath_(parent); path /= name; Filesystem::create_directory(path) .and_then([&](bool created) { @@ -298,7 +494,7 @@ namespace Toolbox { error.m_message[0]); return Result(); }); - } else if (isArchive(parent)) { + } else if (isArchive_(parent)) { TOOLBOX_ERROR("[FileSystemModel] Archive creation is unimplemented!"); } else { TOOLBOX_ERROR("[FileSystemModel] Parent index is not a directory!"); @@ -312,14 +508,14 @@ namespace Toolbox { parent); } - ModelIndex FileSystemModel::touch(const ModelIndex &parent, const std::string &name) { + ModelIndex FileSystemModel::touch_(const ModelIndex &parent, const std::string &name) { if (!validateIndex(parent)) { return ModelIndex(); } bool result = false; - if (isDirectory(parent)) { + if (isDirectory_(parent)) { fs_path path = parent.data<_FileSystemIndexData>()->m_path / name; std::ofstream file(path); if (!file.is_open()) { @@ -328,7 +524,7 @@ namespace Toolbox { } file.close(); result = true; - } else if (isArchive(parent)) { + } else if (isArchive_(parent)) { TOOLBOX_ERROR("[FileSystemModel] Archive creation is unimplemented!"); } else { TOOLBOX_ERROR("[FileSystemModel] Parent index is not a directory!"); @@ -342,15 +538,15 @@ namespace Toolbox { parent); } - bool FileSystemModel::rmdir(const ModelIndex &index) { + bool FileSystemModel::rmdir_(const ModelIndex &index) { if (!validateIndex(index)) { return false; } bool result = false; - if (isDirectory(index)) { - Filesystem::remove_all(getPath(index)) + if (isDirectory_(index)) { + Filesystem::remove_all(getPath_(index)) .and_then([&](bool removed) { if (!removed) { TOOLBOX_ERROR_V("[FileSystemModel] Failed to remove directory: {}", @@ -365,8 +561,8 @@ namespace Toolbox { error.m_message[0]); return Result(); }); - } else if (isArchive(index)) { - Filesystem::remove(getPath(index)) + } else if (isArchive_(index)) { + Filesystem::remove(getPath_(index)) .and_then([&](bool removed) { if (!removed) { TOOLBOX_ERROR_V("[FileSystemModel] Failed to remove archive: {}", @@ -386,7 +582,7 @@ namespace Toolbox { } if (result) { - ModelIndex parent = getParent(index); + ModelIndex parent = getParent_(index); if (validateIndex(parent)) { _FileSystemIndexData *parent_data = parent.data<_FileSystemIndexData>(); parent_data->m_children.erase(std::remove(parent_data->m_children.begin(), @@ -401,19 +597,19 @@ namespace Toolbox { return result; } - bool FileSystemModel::remove(const ModelIndex &index) { + bool FileSystemModel::remove_(const ModelIndex &index) { if (!validateIndex(index)) { return false; } bool result = false; - if (isFile(index)) { - Filesystem::remove(getPath(index)) + if (isFile_(index)) { + Filesystem::remove(getPath_(index)) .and_then([&](bool removed) { if (!removed) { TOOLBOX_ERROR_V("[FileSystemModel] Failed to remove file: {}", - getPath(index).string()); + getPath_(index).string()); return Result(); } result = true; @@ -424,14 +620,14 @@ namespace Toolbox { error.m_message[0]); return Result(); }); - } else if (isArchive(index)) { + } else if (isArchive_(index)) { TOOLBOX_ERROR("[FileSystemModel] Index is not a file!"); } else { TOOLBOX_ERROR("[FileSystemModel] Index is not a file!"); } if (result) { - ModelIndex parent = getParent(index); + ModelIndex parent = getParent_(index); if (validateIndex(parent)) { _FileSystemIndexData *parent_data = parent.data<_FileSystemIndexData>(); parent_data->m_children.erase(std::remove(parent_data->m_children.begin(), @@ -446,17 +642,17 @@ namespace Toolbox { return result; } - ModelIndex FileSystemModel::rename(const ModelIndex &file, const std::string &new_name) { + ModelIndex FileSystemModel::rename_(const ModelIndex &file, const std::string &new_name) { if (!validateIndex(file)) { return ModelIndex(); } - if (!isDirectory(file) && !isFile(file)) { + if (!isDirectory_(file) && !isFile_(file)) { TOOLBOX_ERROR("[FileSystemModel] Not a directory or file!"); return ModelIndex(); } fs_path from = file.data<_FileSystemIndexData>()->m_path; fs_path to = from.parent_path() / new_name; - ModelIndex parent = getParent(file); + ModelIndex parent = getParent_(file); _FileSystemIndexData *parent_data = parent.data<_FileSystemIndexData>(); int dest_index = std::find(parent_data->m_children.begin(), parent_data->m_children.end(), @@ -473,13 +669,13 @@ namespace Toolbox { return makeIndex(to, dest_index, parent); } - ModelIndex FileSystemModel::getIndex(const fs_path &path) const { + ModelIndex FileSystemModel::getIndex_(const fs_path &path) const { if (m_index_map.empty()) { return ModelIndex(); } for (const auto &[uuid, index] : m_index_map) { - if (getPath(index) == path) { + if (getPath_(index) == path) { return index; } } @@ -487,10 +683,10 @@ namespace Toolbox { return ModelIndex(); } - ModelIndex FileSystemModel::getIndex(const UUID64 &uuid) const { return m_index_map.at(uuid); } + ModelIndex FileSystemModel::getIndex_(const UUID64 &uuid) const { return m_index_map.at(uuid); } - ModelIndex FileSystemModel::getIndex(int64_t row, int64_t column, - const ModelIndex &parent) const { + ModelIndex FileSystemModel::getIndex_(int64_t row, int64_t column, + const ModelIndex &parent) const { if (!validateIndex(parent)) { if (m_root_index != 0 && row == 0 && column == 0) { return m_index_map.at(m_root_index); @@ -506,7 +702,7 @@ namespace Toolbox { return m_index_map.at(parent_data->m_children[row]); } - fs_path FileSystemModel::getPath(const ModelIndex &index) const { + fs_path FileSystemModel::getPath_(const ModelIndex &index) const { if (!validateIndex(index)) { return fs_path(); } @@ -514,7 +710,7 @@ namespace Toolbox { return index.data<_FileSystemIndexData>()->m_path; } - ModelIndex FileSystemModel::getParent(const ModelIndex &index) const { + ModelIndex FileSystemModel::getParent_(const ModelIndex &index) const { if (!validateIndex(index)) { return ModelIndex(); } @@ -527,23 +723,23 @@ namespace Toolbox { return m_index_map.at(id); } - ModelIndex FileSystemModel::getSibling(int64_t row, int64_t column, - const ModelIndex &index) const { + ModelIndex FileSystemModel::getSibling_(int64_t row, int64_t column, + const ModelIndex &index) const { if (!validateIndex(index)) { return ModelIndex(); } - const ModelIndex &parent = getParent(index); + const ModelIndex &parent = getParent_(index); if (!validateIndex(parent)) { return ModelIndex(); } - return getIndex(row, column, parent); + return getIndex_(row, column, parent); } - size_t FileSystemModel::getColumnCount(const ModelIndex &index) const { return 1; } + size_t FileSystemModel::getColumnCount_(const ModelIndex &index) const { return 1; } - size_t FileSystemModel::getRowCount(const ModelIndex &index) const { + size_t FileSystemModel::getRowCount_(const ModelIndex &index) const { if (!validateIndex(index)) { return 0; } @@ -551,42 +747,38 @@ namespace Toolbox { return index.data<_FileSystemIndexData>()->m_children.size(); } - bool FileSystemModel::hasChildren(const ModelIndex &parent) const { - if (getRowCount(parent) > 0) { + bool FileSystemModel::hasChildren_(const ModelIndex &parent) const { + if (getRowCount_(parent) > 0) { return true; } return pollChildren(parent) > 0; } ScopePtr - FileSystemModel::createMimeData(const std::vector &indexes) const { + FileSystemModel::createMimeData_(const std::vector &indexes) const { TOOLBOX_ERROR("[FileSystemModel] Mimedata unimplemented!"); return ScopePtr(); } - std::vector FileSystemModel::getSupportedMimeTypes() const { - return std::vector(); - } - - bool FileSystemModel::canFetchMore(const ModelIndex &index) { + bool FileSystemModel::canFetchMore_(const ModelIndex &index) { if (!validateIndex(index)) { return false; } - if (!isDirectory(index) && !isArchive(index)) { + if (!isDirectory_(index) && !isArchive_(index)) { return false; } return index.data<_FileSystemIndexData>()->m_children.empty(); } - void FileSystemModel::fetchMore(const ModelIndex &index) { + void FileSystemModel::fetchMore_(const ModelIndex &index) { if (!validateIndex(index)) { return; } - if (isDirectory(index)) { - fs_path path = getPath(index); + if (isDirectory_(index)) { + fs_path path = getPath_(index); size_t i = 0; for (const auto &entry : Filesystem::directory_iterator(path)) { @@ -595,55 +787,6 @@ namespace Toolbox { } } - const ImageHandle &FileSystemModel::InvalidIcon() { - static ImageHandle s_invalid_fs_icon = ImageHandle("Images/Icons/fs_invalid.png"); - return s_invalid_fs_icon; - } - - const std::unordered_map &FileSystemModel::TypeMap() { - // clang-format off - static std::unordered_map s_type_map = { - {"_Invalid", FSTypeInfo("Invalid", "fs_invalid.png") }, - {"_Folder", FSTypeInfo("Folder", "fs_generic_folder.png")}, - {"_Archive", FSTypeInfo("Archive", "fs_arc.png") }, - {"_File", FSTypeInfo("File", "fs_generic_file.png") }, - {".txt", FSTypeInfo("Text", "fs_txt.png") }, - {".md", FSTypeInfo("Markdown", "fs_md.png") }, - {".c", FSTypeInfo("C", "fs_c.png") }, - {".h", FSTypeInfo("Header", "fs_h.png") }, - {".cpp", FSTypeInfo("C++", "fs_cpp.png") }, - {".hpp", FSTypeInfo("Header", "fs_hpp.png") }, - {".cxx", FSTypeInfo("C++", "fs_cpp.png") }, - {".hxx", FSTypeInfo("Header", "fs_hpp.png") }, - {".c++", FSTypeInfo("C++", "fs_cpp.png") }, - {".h++", FSTypeInfo("Header", "fs_hpp.png") }, - {".cc", FSTypeInfo("C++", "fs_cpp.png") }, - {".hh", FSTypeInfo("Header", "fs_hpp.png") }, - {".arc", FSTypeInfo("Archive", "fs_arc.png") }, - {".bas", FSTypeInfo("JAudio Sequence", "fs_bas.png") }, - {".bck", FSTypeInfo("J3D Bone Animation", "fs_bck.png") }, - {".bdl", FSTypeInfo("J3D Model Data", "fs_bdl.png") }, - {".blo", FSTypeInfo("J2D Screen Layout", "fs_blo.png") }, - {".bmd", FSTypeInfo("J3D Model Data", "fs_bmd.png") }, - {".bmg", FSTypeInfo("Message Data", "fs_bmg.png") }, - {".bmt", FSTypeInfo("J3D Material Table", "fs_bmt.png") }, - {".brk", FSTypeInfo("J3D Color Register Anim", "fs_brk.png") }, - {".bti", FSTypeInfo("J2D Texture Image", "fs_bti.png") }, - {".btk", FSTypeInfo("J2D Texture Animation", "fs_btk.png") }, - {".btp", FSTypeInfo("J2D Texture Pattern Anim", "fs_btp.png") }, - {".col", FSTypeInfo("SMS Collision Data", "fs_col.png") }, - {".jpa", FSTypeInfo("JParticle Data", "fs_jpa.png") }, - {".map", FSTypeInfo("Executable Symbol Map", "fs_map.png") }, - {".me", FSTypeInfo("Marked For Delete", "fs_me.png") }, - {".prm", FSTypeInfo("SMS Parameter Data", "fs_prm.png") }, - {".sb", FSTypeInfo("Sunscript", "fs_sb.png") }, - {".szs", FSTypeInfo("Yaz0 Compressed Data", "fs_szs.png") }, - {".thp", FSTypeInfo("DolphinOS Movie Data", "fs_thp.png") }, - }; - // clang-format on - return s_type_map; - } - ModelIndex FileSystemModel::makeIndex(const fs_path &path, int64_t row, const ModelIndex &parent) { _FileSystemIndexData *parent_data = nullptr; @@ -664,7 +807,6 @@ namespace Toolbox { _FileSystemIndexData *data = new _FileSystemIndexData; data->m_path = path; data->m_name = path.filename().string(); - data->m_size = 0; data->m_children = {}; if (Filesystem::is_directory(path).value_or(false)) { @@ -691,6 +833,21 @@ namespace Toolbox { return Result(); }); + if (data->m_type == _FileSystemIndexData::Type::FILE) { + Filesystem::file_size(data->m_path) + .and_then([&](size_t size) { + data->m_size = size; + return Result(); + }) + .or_else([&](const FSError &error) { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to get file size: {}", + error.m_message[0]); + return Result(); + }); + } else { + data->m_size = 0; + } + ModelIndex index = ModelIndex(getUUID()); // Establish icon @@ -733,12 +890,12 @@ namespace Toolbox { } ModelIndex FileSystemModel::getParentArchive(const ModelIndex &index) const { - ModelIndex parent = getParent(index); + ModelIndex parent = getParent_(index); do { - if (isArchive(parent)) { + if (isArchive_(parent)) { return parent; } - parent = getParent(parent); + parent = getParent_(parent); } while (validateIndex(parent)); return ModelIndex(); @@ -751,15 +908,15 @@ namespace Toolbox { size_t count = 0; - if (isDirectory(index)) { + if (isDirectory_(index)) { // Count the children in the filesystem - for (const auto &entry : Filesystem::directory_iterator(getPath(index))) { + for (const auto &entry : Filesystem::directory_iterator(getPath_(index))) { count += 1; } - } else if (isArchive(index)) { + } else if (isArchive_(index)) { // Count the children in the archive TOOLBOX_ERROR("[FileSystemModel] Archive polling unimplemented!"); - } else if (isFile(index)) { + } else if (isFile_(index)) { // Files have no children count = 0; } else { @@ -770,12 +927,220 @@ namespace Toolbox { return count; } + void FileSystemModel::folderAdded(const fs_path &path) { + { + std::scoped_lock lock(m_mutex); + + ModelIndex parent = getIndex_(path.parent_path()); + if (!validateIndex(parent)) { + return; + } + + makeIndex(path, getRowCount_(parent), parent); + } + + for (const auto &[key, listener] : m_listeners) { + if ((listener.second & FileSystemModelEventFlags::EVENT_FOLDER_ADDED) != + FileSystemModelEventFlags::NONE) { + listener.first(path, FileSystemModelEventFlags::EVENT_FOLDER_ADDED); + } + } + } + + void FileSystemModel::folderModified(const fs_path &path) { + { + std::scoped_lock lock(m_mutex); + + ModelIndex index = getIndex_(path); + if (!validateIndex(index)) { + return; + } + + _FileSystemIndexData *data = index.data<_FileSystemIndexData>(); + + Filesystem::last_write_time(data->m_path) + .and_then([&](Filesystem::file_time_type &&time) { + data->m_date = std::move(time); + return Result(); + }) + .or_else([&](const FSError &error) { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to get last write time: {}", + error.m_message[0]); + return Result(); + }); + } + + for (const auto &[key, listener] : m_listeners) { + if ((listener.second & FileSystemModelEventFlags::EVENT_FOLDER_MODIFIED) != + FileSystemModelEventFlags::NONE) { + listener.first(path, FileSystemModelEventFlags::EVENT_FOLDER_MODIFIED); + } + } + } + + void FileSystemModel::fileAdded(const fs_path &path) { + { + std::scoped_lock lock(m_mutex); + + ModelIndex parent = getIndex_(path.parent_path()); + if (!validateIndex(parent)) { + return; + } + + makeIndex(path, getRowCount_(parent), parent); + } + + for (const auto &[key, listener] : m_listeners) { + if ((listener.second & FileSystemModelEventFlags::EVENT_FILE_ADDED) != + FileSystemModelEventFlags::NONE) { + listener.first(path, FileSystemModelEventFlags::EVENT_FILE_ADDED); + } + } + } + + void FileSystemModel::fileModified(const fs_path &path) { + { + std::scoped_lock lock(m_mutex); + + ModelIndex index = getIndex_(path); + if (!validateIndex(index)) { + return; + } + + _FileSystemIndexData *data = index.data<_FileSystemIndexData>(); + + Filesystem::last_write_time(data->m_path) + .and_then([&](Filesystem::file_time_type &&time) { + data->m_date = std::move(time); + return Result(); + }) + .or_else([&](const FSError &error) { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to get last write time: {}", + error.m_message[0]); + return Result(); + }); + + Filesystem::file_size(data->m_path) + .and_then([&](size_t size) { + data->m_size = size; + return Result(); + }) + .or_else([&](const FSError &error) { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to get file size: {}", + error.m_message[0]); + return Result(); + }); + } + + for (const auto &[key, listener] : m_listeners) { + if ((listener.second & FileSystemModelEventFlags::EVENT_FILE_MODIFIED) != + FileSystemModelEventFlags::NONE) { + listener.first(path, FileSystemModelEventFlags::EVENT_FILE_MODIFIED); + } + } + } + + void FileSystemModel::pathRenamedSrc(const fs_path &old_path) { + std::scoped_lock lock(m_mutex); + m_rename_src = old_path; + } + + void FileSystemModel::pathRenamedDst(const fs_path &new_path) { + { + std::scoped_lock lock(m_mutex); + + ModelIndex index = getIndex_(m_rename_src); + if (!validateIndex(index)) { + return; + } + + _FileSystemIndexData *data = index.data<_FileSystemIndexData>(); + data->m_path = new_path; + data->m_name = new_path.filename().string(); + + // Reparent index if necessary + ModelIndex parent = getParent_(index); + if (!validateIndex(parent)) { + return; + } + + if (parent.data<_FileSystemIndexData>()->m_path != new_path.parent_path()) { + _FileSystemIndexData *old_parent_data = parent.data<_FileSystemIndexData>(); + old_parent_data->m_children.erase(std::remove(old_parent_data->m_children.begin(), + old_parent_data->m_children.end(), + index.getUUID()), + old_parent_data->m_children.end()); + + ModelIndex new_parent = getIndex_(new_path.parent_path()); + if (!validateIndex(new_parent)) { + return; + } + + _FileSystemIndexData *new_parent_data = new_parent.data<_FileSystemIndexData>(); + new_parent_data->m_children.push_back(index.getUUID()); + } + } + + for (const auto &[key, listener] : m_listeners) { + if ((listener.second & FileSystemModelEventFlags::EVENT_PATH_RENAMED) != + FileSystemModelEventFlags::NONE) { + listener.first(new_path, FileSystemModelEventFlags::EVENT_PATH_RENAMED); + } + } + } + + void FileSystemModel::pathRemoved(const fs_path &path) { + { + std::scoped_lock lock(m_mutex); + + ModelIndex index = getIndex_(path); + if (!validateIndex(index)) { + return; + } + + ModelIndex parent = getParent_(index); + if (!validateIndex(parent)) { + return; + } + + { + _FileSystemIndexData *parent_data = parent.data<_FileSystemIndexData>(); + parent_data->m_children.erase(std::remove(parent_data->m_children.begin(), + parent_data->m_children.end(), + index.getUUID()), + parent_data->m_children.end()); + delete index.data<_FileSystemIndexData>(); + m_index_map.erase(index.getUUID()); + } + } + + for (const auto &[key, listener] : m_listeners) { + if ((listener.second & FileSystemModelEventFlags::EVENT_PATH_REMOVED) != + FileSystemModelEventFlags::NONE) { + listener.first(path, FileSystemModelEventFlags::EVENT_PATH_REMOVED); + } + } + } + RefPtr FileSystemModelSortFilterProxy::getSourceModel() const { return m_source_model; } void FileSystemModelSortFilterProxy::setSourceModel(RefPtr model) { + if (m_source_model == model) { + return; + } + + if (m_source_model) { + m_source_model->removeEventListener(getUUID()); + } + m_source_model = model; + + if (m_source_model) { + m_source_model->addEventListener(getUUID(), TOOLBOX_BIND_EVENT_FN(fsUpdateEvent), + FileSystemModelEventFlags::EVENT_ANY); + } } ModelSortOrder FileSystemModelSortFilterProxy::getSortOrder() const { return m_sort_order; } @@ -924,11 +1289,6 @@ namespace Toolbox { size_t FileSystemModelSortFilterProxy::getRowCount(const ModelIndex &index) const { ModelIndex &&source_index = toSourceIndex(index); - - if (m_row_map.find(source_index.getUUID()) != m_row_map.end()) { - return m_row_map[source_index.getUUID()].size(); - } - return m_source_model->getRowCount(source_index); } @@ -979,7 +1339,7 @@ namespace Toolbox { ModelIndex proxy_index = ModelIndex(getUUID()); proxy_index.setData(index.data<_FileSystemIndexData>()); - + IDataModel::setIndexUUID(proxy_index, index.getUUID()); return proxy_index; @@ -1116,4 +1476,18 @@ namespace Toolbox { } } + void FileSystemModelSortFilterProxy::fsUpdateEvent(const fs_path &path, + FileSystemModelEventFlags flags) { + if ((flags & FileSystemModelEventFlags::EVENT_ANY) == FileSystemModelEventFlags::NONE) { + return; + } + + if ((flags & FileSystemModelEventFlags::EVENT_PATH_RENAMED) != + FileSystemModelEventFlags::NONE) { + m_filter_map.clear(); + } + + m_row_map.clear(); + } + } // namespace Toolbox \ No newline at end of file From 018db646f8d3bb3cfc7faf990409a8cfbc44a27a Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Sun, 29 Sep 2024 12:45:47 -0500 Subject: [PATCH 040/129] Fix race condition in filter proxy --- include/model/fsmodel.hpp | 9 +++++++-- src/model/fsmodel.cpp | 25 +++++++++++++++++-------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/include/model/fsmodel.hpp b/include/model/fsmodel.hpp index 619278c5..346d3fcc 100644 --- a/include/model/fsmodel.hpp +++ b/include/model/fsmodel.hpp @@ -134,7 +134,8 @@ namespace Toolbox { void fetchMore(const ModelIndex &index) override; using event_listener_t = std::function; - void addEventListener(UUID64 uuid, event_listener_t listener, FileSystemModelEventFlags flags); + void addEventListener(UUID64 uuid, event_listener_t listener, + FileSystemModelEventFlags flags); void removeEventListener(UUID64 uuid); static const ImageHandle &InvalidIcon(); @@ -202,7 +203,8 @@ namespace Toolbox { mutable std::mutex m_mutex; FileSystemWatchdog m_watchdog; - std::unordered_map> m_listeners; + std::unordered_map> + m_listeners; fs_path m_root_path; @@ -293,7 +295,9 @@ namespace Toolbox { const ModelIndex &parent = ModelIndex()) const; [[nodiscard]] bool isFiltered(const UUID64 &uuid) const; + void cacheIndex(const ModelIndex &index) const; + void cacheIndex_(const ModelIndex &index) const; ModelIndex makeIndex(const fs_path &path, int64_t row, const ModelIndex &parent) { return ModelIndex(); @@ -311,6 +315,7 @@ namespace Toolbox { bool m_dirs_only = false; + mutable std::mutex m_cache_mutex; mutable std::unordered_map m_filter_map; mutable std::unordered_map> m_row_map; }; diff --git a/src/model/fsmodel.cpp b/src/model/fsmodel.cpp index 5a36fbc5..3d79d0a3 100644 --- a/src/model/fsmodel.cpp +++ b/src/model/fsmodel.cpp @@ -1139,7 +1139,7 @@ namespace Toolbox { if (m_source_model) { m_source_model->addEventListener(getUUID(), TOOLBOX_BIND_EVENT_FN(fsUpdateEvent), - FileSystemModelEventFlags::EVENT_ANY); + FileSystemModelEventFlags::EVENT_ANY); } } @@ -1261,6 +1261,8 @@ namespace Toolbox { ModelIndex FileSystemModelSortFilterProxy::getSibling(int64_t row, int64_t column, const ModelIndex &index) const { + std::unique_lock lock(m_cache_mutex); + ModelIndex source_index = toSourceIndex(index); ModelIndex src_parent = getParent(source_index); const UUID64 &src_parent_uuid = src_parent.getUUID(); @@ -1271,7 +1273,7 @@ namespace Toolbox { } if (m_row_map.find(map_key) == m_row_map.end()) { - cacheIndex(src_parent); + cacheIndex_(src_parent); } if (row < m_row_map[map_key].size()) { @@ -1346,7 +1348,9 @@ namespace Toolbox { } ModelIndex FileSystemModelSortFilterProxy::toProxyIndex(int64_t row, int64_t column, - const ModelIndex &src_parent) const { + const ModelIndex &src_parent) const { + std::unique_lock lock(m_cache_mutex); + const UUID64 &src_parent_uuid = src_parent.getUUID(); u64 map_key = src_parent_uuid; @@ -1355,7 +1359,7 @@ namespace Toolbox { } if (m_row_map.find(map_key) == m_row_map.end()) { - cacheIndex(src_parent); + cacheIndex_(src_parent); } if (row < m_row_map[map_key].size()) { @@ -1388,6 +1392,11 @@ namespace Toolbox { } void FileSystemModelSortFilterProxy::cacheIndex(const ModelIndex &dir_index) const { + std::unique_lock lock(m_cache_mutex); + cacheIndex_(dir_index); + } + + void FileSystemModelSortFilterProxy::cacheIndex_(const ModelIndex &dir_index) const { std::vector orig_children = {}; std::vector proxy_children = {}; @@ -1482,12 +1491,12 @@ namespace Toolbox { return; } - if ((flags & FileSystemModelEventFlags::EVENT_PATH_RENAMED) != - FileSystemModelEventFlags::NONE) { + { + std::scoped_lock lock(m_cache_mutex); + m_filter_map.clear(); + m_row_map.clear(); } - - m_row_map.clear(); } } // namespace Toolbox \ No newline at end of file From 67d613cf8613305d573fea57e9957534f80a9562 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Sun, 29 Sep 2024 16:12:26 -0500 Subject: [PATCH 041/129] Start implementing context menu --- include/gui/context_menu.hpp | 24 ++++- include/gui/project/window.hpp | 22 +++-- src/gui/project/window.cpp | 168 ++++++++++++++++++++++++++++----- src/model/fsmodel.cpp | 4 +- 4 files changed, 181 insertions(+), 37 deletions(-) diff --git a/include/gui/context_menu.hpp b/include/gui/context_menu.hpp index 6bc500c9..b2c221a3 100644 --- a/include/gui/context_menu.hpp +++ b/include/gui/context_menu.hpp @@ -22,8 +22,9 @@ namespace Toolbox::UI { template class ContextMenu { public: - using operator_t = std::function; - using condition_t = std::function; + using operator_t = std::function; + using condition_t = std::function; + using open_event_t = std::function; struct ContextOp { std::string m_name; @@ -45,12 +46,16 @@ namespace Toolbox::UI { void render(std::optional label, _DataT ctx); + void onOpen(open_event_t open) { m_open_event = open; } + protected: void processKeybinds(_DataT ctx); private: std::vector m_options; std::set m_dividers; + open_event_t m_open_event; + bool m_was_open = false; }; template @@ -81,8 +86,17 @@ namespace Toolbox::UI { inline void ContextMenu<_DataT>::render(std::optional label, _DataT ctx) { processKeybinds(ctx); - if (!ImGui::BeginPopupContextItem(label ? label->c_str() : nullptr)) + if (!ImGui::BeginPopupContextItem(label ? label->c_str() : nullptr)) { + m_was_open = false; return; + } + + if (!m_was_open && m_open_event) { + m_open_event(ctx); + } + m_was_open = true; + + size_t prev_opt_index = 0; for (size_t i = 0; i < m_options.size(); ++i) { ContextOp &option = m_options.at(i); @@ -90,9 +104,10 @@ namespace Toolbox::UI { continue; } - if (m_dividers.find(i) != m_dividers.end()) { + if (prev_opt_index > 0 && m_dividers.find(prev_opt_index + 1) != m_dividers.end()) { ImGui::Separator(); } + prev_opt_index = i; std::string keybind_name = option.m_keybind.toString(); @@ -117,6 +132,7 @@ namespace Toolbox::UI { bool keybind_pressed = option.m_keybind.isInputMatching(); if (keybind_pressed && !option.m_keybind_used) { + m_open_event(ctx); option.m_keybind_used = true; option.m_op(ctx); } diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 3aa25906..8bea3b42 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -16,10 +16,11 @@ #include "core/clipboard.hpp" #include "game/task.hpp" +#include "gui/context_menu.hpp" #include "gui/event/event.hpp" #include "gui/image/imagepainter.hpp" -#include "gui/window.hpp" #include "gui/project/asset.hpp" +#include "gui/window.hpp" #include "model/fsmodel.hpp" @@ -69,16 +70,12 @@ namespace Toolbox::UI { }; } - [[nodiscard]] std::string context() const override { - return m_project_root.string(); - } + [[nodiscard]] std::string context() const override { return m_project_root.string(); } [[nodiscard]] bool unsaved() const override { return false; } // Returns the supported file types, empty string is designed for a folder. - [[nodiscard]] std::vector extensions() const override { - return {}; - } + [[nodiscard]] std::vector extensions() const override { return {}; } [[nodiscard]] bool onLoadData(const std::filesystem::path &path) override; @@ -93,6 +90,12 @@ namespace Toolbox::UI { void onDragEvent(RefPtr ev) override; void onDropEvent(RefPtr ev) override; + void buildContextMenu(); + + // Selection actions + void actionDeleteIndexes(std::vector &indices); + void actionOpenIndexes(const std::vector &indices); + private: fs_path m_project_root; @@ -110,7 +113,10 @@ namespace Toolbox::UI { std::unordered_map m_icon_map; ImagePainter m_icon_painter; - std::unordered_map m_text_sizes; + ContextMenu m_context_menu; + std::vector m_selected_indices_ctx; + bool m_delete_without_request = false; + bool m_delete_requested = false; }; } // namespace Toolbox::UI \ No newline at end of file diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index f6de6489..f4d5c2c6 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -18,6 +18,7 @@ namespace Toolbox::UI { renderProjectFolderView(); renderProjectFolderButton(); renderProjectFileButton(); + m_context_menu.render("Project View", m_view_index); } void ProjectViewWindow::renderProjectTreeView() { @@ -63,9 +64,11 @@ namespace Toolbox::UI { continue; } + ModelIndex source_child_index = m_view_proxy.toSourceIndex(child_index); + bool is_selected = std::find(m_selected_indices.begin(), m_selected_indices.end(), - child_index) != m_selected_indices.end(); + source_child_index) != m_selected_indices.end(); if (is_selected) { ImGui::PushStyleColor(ImGuiCol_ChildBg, @@ -126,7 +129,6 @@ namespace Toolbox::UI { m_is_renaming = false; if (m_view_proxy.isDirectory(child_index)) { m_view_index = m_view_proxy.toSourceIndex(child_index); - // m_fs_watchdog.addPath(m_file_system_model->getPath(m_view_index)); ImGui::EndChild(); ImGui::PopStyleColor(1); break; @@ -134,9 +136,9 @@ namespace Toolbox::UI { } else if (ImGui::IsMouseClicked(0)) { if (is_selected) { if (ImGui::IsKeyDown(ImGuiMod_Ctrl)) { - m_selected_indices.erase( - std::find(m_selected_indices.begin(), - m_selected_indices.end(), child_index)); + m_selected_indices.erase(std::find( + m_selected_indices.begin(), m_selected_indices.end(), + source_child_index)); m_is_renaming = false; } else { m_is_renaming = true; @@ -147,7 +149,7 @@ namespace Toolbox::UI { if (!ImGui::IsKeyDown(ImGuiMod_Ctrl)) { m_selected_indices.clear(); } - m_selected_indices.push_back(child_index); + m_selected_indices.push_back(source_child_index); m_is_renaming = false; } } @@ -165,30 +167,28 @@ namespace Toolbox::UI { ImVec2 center = ImGui::GetMainViewport()->GetCenter(); ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f)); - static bool dont_ask_for_deletes = false; + if (ImGui::BeginPopupModal("Delete?", NULL, ImGuiWindowFlags_AlwaysAutoResize)) { std::string message = ""; - if (m_selected_indices.size() == 1) { + if (m_selected_indices_ctx.size() == 1) { message = TOOLBOX_FORMAT_FN( "Are you sure you want to delete {}?", m_file_system_model->getDisplayText(m_selected_indices[0])); - } else if (m_selected_indices.size() > 1) { + } else if (m_selected_indices_ctx.size() > 1) { message = TOOLBOX_FORMAT_FN( "Are you sure you want to delete the {} selected files?", - m_selected_indices.size()); + m_selected_indices_ctx.size()); } else { TOOLBOX_ERROR("Selected 0 files to delete!"); } ImGui::Text(message.c_str()); ImGui::Separator(); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0)); - ImGui::Checkbox("Don't ask me next time", &dont_ask_for_deletes); + ImGui::Checkbox("Don't ask me next time", &m_delete_without_request); ImGui::PopStyleVar(); if (ImGui::Button("OK", ImVec2(120, 0))) { - for (auto &item_index : m_selected_indices) { - m_file_system_model->remove(item_index); - } + actionDeleteIndexes(m_selected_indices_ctx); ImGui::CloseCurrentPopup(); } ImGui::SetItemDefaultFocus(); @@ -204,14 +204,9 @@ namespace Toolbox::UI { m_is_renaming = false; } // Delete stuff - if (ImGui::IsKeyPressed(ImGuiKey_Delete) && !m_selected_indices.empty()) { - if (dont_ask_for_deletes) { - for (auto &item_index : m_selected_indices) { - m_file_system_model->remove(item_index); - } - } else { - ImGui::OpenPopup("Delete?"); - } + if (m_delete_requested) { + ImGui::OpenPopup("Delete?"); + m_delete_requested = false; } } @@ -238,7 +233,7 @@ namespace Toolbox::UI { return true; } - void ProjectViewWindow::onAttach() {} + void ProjectViewWindow::onAttach() { buildContextMenu(); } void ProjectViewWindow::onDetach() {} @@ -250,6 +245,133 @@ namespace Toolbox::UI { void ProjectViewWindow::onDropEvent(RefPtr ev) {} + void ProjectViewWindow::buildContextMenu() { + m_context_menu = ContextMenu(); + + m_context_menu.onOpen( + [this](const ModelIndex &index) { m_selected_indices_ctx = m_selected_indices; }); + + m_context_menu.addOption( + "Open", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_O}), + [this]() { + return m_selected_indices_ctx.size() > 0 && + std::all_of(m_selected_indices_ctx.begin(), m_selected_indices_ctx.end(), + [this](const ModelIndex &index) { + return m_file_system_model->isFile(index); + }); + }, + [this](auto) { actionOpenIndexes(m_selected_indices_ctx); }); + + m_context_menu.addOption( + "Open in Explorer", + KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_LEFTSHIFT, KeyCode::KEY_O}), + [this]() { + return std::all_of( + m_selected_indices_ctx.begin(), m_selected_indices_ctx.end(), + [this](const ModelIndex &index) { return m_file_system_model->isFile(index); }); + }, + [this](auto) { + if (m_selected_indices_ctx.size() == 0) { + // TODO: Implement this interface + // Toolbox::Platform::OpenFileExplorer(path); + } else { + std::set paths; + for (const ModelIndex &item_index : m_selected_indices_ctx) { + fs_path path = m_file_system_model->getPath(item_index); + if (m_file_system_model->isDirectory(item_index)) { + paths.insert(path); + } else { + paths.insert(path.parent_path()); + } + } + for (const fs_path &path : paths) { + // TODO: Implement this interface + // Toolbox::Platform::OpenFileExplorer(path); + } + } + }); + + m_context_menu.addDivider(); + + m_context_menu.addOption( + "Copy Path", + KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_LEFTSHIFT, KeyCode::KEY_C}), + [this]() { return true; }, + [this](auto) { + std::string paths; + if (m_selected_indices_ctx.size() == 0) { + paths = m_file_system_model->getPath(m_view_index).string(); + } else { + for (const ModelIndex &item_index : m_selected_indices_ctx) { + fs_path path = m_file_system_model->getPath(item_index); + paths += path.string() + "\n"; + } + } + ImGui::SetClipboardText(paths.c_str()); + }); + + m_context_menu.addDivider(); + + m_context_menu.addOption( + "Cut", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_X}), + [this]() { return m_selected_indices_ctx.size() > 0; }, [this](auto) {}); + + m_context_menu.addOption( + "Copy", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_C}), + [this]() { return m_selected_indices_ctx.size() > 0; }, [this](auto) {}); + + m_context_menu.addDivider(); + + m_context_menu.addOption( + "Delete", KeyBind({KeyCode::KEY_DELETE}), + [this]() { return m_selected_indices_ctx.size() > 0; }, + [this](auto) { + if (m_delete_without_request) { + actionDeleteIndexes(m_selected_indices_ctx); + } else { + m_delete_requested = true; + } + }); + + m_context_menu.addOption( + "Rename", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_R}), + [this]() { return m_selected_indices_ctx.size() == 1; }, + [this](auto) { + m_is_renaming = true; + std::strncpy(m_rename_buffer, + m_file_system_model->getDisplayText(m_selected_indices_ctx[0]).c_str(), + IM_ARRAYSIZE(m_rename_buffer)); + }); + + m_context_menu.addDivider(); + + m_context_menu.addOption( + "New...", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_N}), + [this]() { return m_selected_indices_ctx.size() == 0; }, + [this](const ModelIndex &view_index) { + // TODO: Open a dialog that gives the user different file types to create. + }); + } + + void ProjectViewWindow::actionDeleteIndexes(std::vector &indices) { + for (auto &item_index : indices) { + m_file_system_model->remove(item_index); + } + indices.clear(); + } + + void ProjectViewWindow::actionOpenIndexes(const std::vector &indices) { + for (auto &item_index : indices) { + if (m_file_system_model->isDirectory(item_index)) { + m_view_index = item_index; + continue; + } + + // TODO: Open files based on extension. Can be either internal or external + // depending on the file type. + } + } + bool ProjectViewWindow::isViewedAncestor(const ModelIndex &index) { if (m_view_index == m_tree_proxy.toSourceIndex(index)) { return true; diff --git a/src/model/fsmodel.cpp b/src/model/fsmodel.cpp index 3d79d0a3..ac6a7103 100644 --- a/src/model/fsmodel.cpp +++ b/src/model/fsmodel.cpp @@ -339,7 +339,7 @@ namespace Toolbox { {".bmt", FSTypeInfo("J3D Material Table", "fs_bmt.png") }, {".brk", FSTypeInfo("J3D Color Register Anim", "fs_brk.png") }, {".bti", FSTypeInfo("J2D Texture Image", "fs_bti.png") }, - {".btk", FSTypeInfo("J2D Texture Animation", "fs_btk.png") }, + {".btk", FSTypeInfo("J2D Texture UV Anim", "fs_btk.png") }, {".btp", FSTypeInfo("J2D Texture Pattern Anim", "fs_btp.png") }, {".col", FSTypeInfo("SMS Collision Data", "fs_col.png") }, {".jpa", FSTypeInfo("JParticle Data", "fs_jpa.png") }, @@ -1348,7 +1348,7 @@ namespace Toolbox { } ModelIndex FileSystemModelSortFilterProxy::toProxyIndex(int64_t row, int64_t column, - const ModelIndex &src_parent) const { + const ModelIndex &src_parent) const { std::unique_lock lock(m_cache_mutex); const UUID64 &src_parent_uuid = src_parent.getUUID(); From 400835aa704fedb1f9f5b9ad8ccb806eaad5dccd Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Sun, 29 Sep 2024 15:02:50 -0700 Subject: [PATCH 042/129] Fix FileWatch.hpp to build on Unix platforms --- lib/FileWatch.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/FileWatch.hpp b/lib/FileWatch.hpp index bee35672..8df7621e 100644 --- a/lib/FileWatch.hpp +++ b/lib/FileWatch.hpp @@ -88,6 +88,7 @@ #include #include #include +#include #ifdef FILEWATCH_PLATFORM_MAC extern "C" int __getdirentries64(int, char *, int, long *); @@ -686,7 +687,7 @@ namespace filewatch { if (IsWChar::value) { size_t needed = mbsrtowcs(nullptr, &str, 0, &state) + 1; - StringType s; + UnderpinningString s; s.reserve(needed); mbsrtowcs((wchar_t *)&s[0], &str, s.size(), &state); From e6af82344df43e54cfc95cd8f2f09b2d89ee6da1 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Mon, 30 Sep 2024 10:34:08 -0500 Subject: [PATCH 043/129] Stablize visuals and stuff --- include/gui/project/window.hpp | 7 +- src/gui/project/window.cpp | 150 ++++++++++++++++++--------------- 2 files changed, 89 insertions(+), 68 deletions(-) diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 8bea3b42..66652298 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -95,6 +95,7 @@ namespace Toolbox::UI { // Selection actions void actionDeleteIndexes(std::vector &indices); void actionOpenIndexes(const std::vector &indices); + void actionRenameIndex(const ModelIndex &index); private: fs_path m_project_root; @@ -107,14 +108,16 @@ namespace Toolbox::UI { std::vector m_selected_indices; std::vector m_view_assets; ModelIndex m_view_index; - bool m_is_renaming = false; - char m_rename_buffer[128]; std::unordered_map m_icon_map; ImagePainter m_icon_painter; ContextMenu m_context_menu; std::vector m_selected_indices_ctx; + + bool m_is_renaming = false; + char m_rename_buffer[128]; + bool m_delete_without_request = false; bool m_delete_requested = false; }; diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index f4d5c2c6..de1ea520 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -35,6 +35,8 @@ namespace Toolbox::UI { return; } + const ImGuiStyle &style = ImGui::GetStyle(); + if (ImGui::BeginChild("Folder View", {0, 0}, true, ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { if (m_file_system_model->hasChildren(m_view_index)) { @@ -46,6 +48,7 @@ namespace Toolbox::UI { ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f); ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0.0f); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, {2, 2}); + ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 3.0f); ImVec2 size = ImGui::GetContentRegionAvail(); @@ -79,87 +82,101 @@ namespace Toolbox::UI { ImGui::ColorConvertFloat4ToU32( ImGui::GetStyleColorVec4(ImGuiCol_ChildBg))); } + const bool is_selected_rename = m_is_renaming && is_selected; + // Get the label and it's size std::string text = m_view_proxy.getDisplayText(child_index); ImVec2 text_size = ImGui::CalcTextSize(text.c_str()); ImVec2 rename_size = ImGui::CalcTextSize(m_rename_buffer); - float box_width = m_is_renaming && is_selected ? std::max(rename_size.x, 76.0f) - : 76.0f; - if (ImGui::BeginChild(child_index.getUUID(), {box_width, 92.0f}, true, + const float box_width = 76.0f; + const float label_width = box_width - style.WindowPadding.x * 4.0f; + const float text_width = is_selected_rename + ? std::min(rename_size.x, label_width) + : std::min(text_size.x, label_width); + + if (ImGui::BeginChild(child_index.getUUID(), {box_width, 100.0f}, true, ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { - - m_icon_painter.render(*m_view_proxy.getDecoration(child_index), - {72.0f, 72.0f}); + ImVec2 pos = ImGui::GetCursorScreenPos() + style.WindowPadding; + ImVec2 icon_size = ImVec2(box_width - style.WindowPadding.x * 2.0f, + box_width - style.WindowPadding.x * 2.0f); + m_icon_painter.render(*m_view_proxy.getDecoration(child_index), pos, + icon_size); // Render the label - ImVec2 pos = ImGui::GetCursorScreenPos(); - ImVec2 newPos = pos; - newPos.x += std::max(36.0f - (((m_is_renaming && is_selected) - ? std::max(rename_size.x, 40.0f) - : text_size.x) / - 2.0f), - 0.0); - newPos.y += 72.0f; - if (m_is_renaming && is_selected) { - ImGui::SetCursorScreenPos(newPos); - ImGui::SetKeyboardFocusHere(); - ImGui::PushItemWidth(std::max(rename_size.x, 40.0f)); - bool done = ImGui::InputText("##rename", m_rename_buffer, - IM_ARRAYSIZE(m_rename_buffer), - ImGuiInputTextFlags_AutoSelectAll | - ImGuiInputTextFlags_EnterReturnsTrue); - if (done) { - m_file_system_model->rename(m_view_proxy.toSourceIndex(child_index), - m_rename_buffer); + { + if (m_is_renaming && is_selected) { + ImVec2 rename_pos = + pos + ImVec2(style.WindowPadding.x, + icon_size.y + style.ItemInnerSpacing.y - + style.FramePadding.y); + + ImGui::SetCursorScreenPos(rename_pos); + ImGui::SetKeyboardFocusHere(); + + ImGui::PushItemWidth(label_width); + bool done = ImGui::InputText( + "##rename", m_rename_buffer, IM_ARRAYSIZE(m_rename_buffer), + ImGuiInputTextFlags_AutoSelectAll | + ImGuiInputTextFlags_EnterReturnsTrue); + if (done) { + m_file_system_model->rename( + m_view_proxy.toSourceIndex(child_index), m_rename_buffer); + } + ImGui::SetCursorScreenPos(pos); + ImGui::PopItemWidth(); + } else { + ImVec2 text_pos = + pos + ImVec2(style.WindowPadding.x, + icon_size.y + style.ItemInnerSpacing.y); + text_pos.x += + std::max((label_width / 2.0f) - (text_width / 2.0f), 0.0f); + + float ellipsis_max = text_pos.x + label_width; + ImVec2 text_clip_max = + ImVec2(ellipsis_max - 8.0f, text_pos.y + 20.0f); + ImGui::RenderTextEllipsis(ImGui::GetWindowDrawList(), text_pos, + text_clip_max, ellipsis_max, ellipsis_max, + text.c_str(), nullptr, nullptr); } - ImGui::SetCursorScreenPos(pos); - ImGui::PopItemWidth(); - } else { - ImGui::RenderTextEllipsis( - ImGui::GetWindowDrawList(), newPos, newPos + ImVec2(64, 20), - pos.x + 64.0f, newPos.x + 76.0f, text.c_str(), nullptr, nullptr); } - any_items_hovered = any_items_hovered || ImGui::IsItemHovered() || - ImGui::IsWindowHovered(ImGuiHoveredFlags_None); + // Handle click responses - if (ImGui::IsWindowHovered(ImGuiHoveredFlags_None)) { - if (ImGui::IsMouseDoubleClicked(0)) { - m_is_renaming = false; - if (m_view_proxy.isDirectory(child_index)) { - m_view_index = m_view_proxy.toSourceIndex(child_index); - ImGui::EndChild(); - ImGui::PopStyleColor(1); - break; - } - } else if (ImGui::IsMouseClicked(0)) { - if (is_selected) { + { + any_items_hovered = any_items_hovered || ImGui::IsItemHovered() || + ImGui::IsWindowHovered(ImGuiHoveredFlags_None); + if (ImGui::IsWindowHovered(ImGuiHoveredFlags_None)) { + if (ImGui::IsMouseDoubleClicked(0)) { + m_is_renaming = false; + if (m_view_proxy.isDirectory(child_index)) { + m_view_index = m_view_proxy.toSourceIndex(child_index); + ImGui::EndChild(); + ImGui::PopStyleColor(1); + break; + } + } else if (ImGui::IsMouseClicked(0)) { + m_is_renaming = false; if (ImGui::IsKeyDown(ImGuiMod_Ctrl)) { - m_selected_indices.erase(std::find( - m_selected_indices.begin(), m_selected_indices.end(), - source_child_index)); - m_is_renaming = false; + if (is_selected) { + m_selected_indices.erase(std::remove( + m_selected_indices.begin(), + m_selected_indices.end(), source_child_index)); + } else { + m_selected_indices.push_back(source_child_index); + } } else { - m_is_renaming = true; - std::strncpy(m_rename_buffer, text.c_str(), - IM_ARRAYSIZE(m_rename_buffer)); - } - } else { - if (!ImGui::IsKeyDown(ImGuiMod_Ctrl)) { m_selected_indices.clear(); + m_selected_indices.push_back(source_child_index); } - m_selected_indices.push_back(source_child_index); - m_is_renaming = false; } } } } + ImGui::EndChild(); ImGui::PopStyleColor(1); - // ImGui::Text("%s", m_view_proxy.getDisplayText(child_index).c_str()); - if ((i + 1) % x_count != 0) { ImGui::SameLine(); } @@ -210,7 +227,7 @@ namespace Toolbox::UI { } } - ImGui::PopStyleVar(4); + ImGui::PopStyleVar(5); } } ImGui::EndChild(); @@ -336,14 +353,9 @@ namespace Toolbox::UI { m_context_menu.addOption( "Rename", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_R}), [this]() { return m_selected_indices_ctx.size() == 1; }, - [this](auto) { - m_is_renaming = true; - std::strncpy(m_rename_buffer, - m_file_system_model->getDisplayText(m_selected_indices_ctx[0]).c_str(), - IM_ARRAYSIZE(m_rename_buffer)); - }); + [this](auto) { actionRenameIndex(m_selected_indices_ctx[0]); }); - m_context_menu.addDivider(); + m_context_menu.addDivider(); m_context_menu.addOption( "New...", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_N}), @@ -372,6 +384,12 @@ namespace Toolbox::UI { } } + void ProjectViewWindow::actionRenameIndex(const ModelIndex &index) { + m_is_renaming = true; + std::string file_name = m_file_system_model->getDisplayText(index); + std::strncpy(m_rename_buffer, file_name.c_str(), IM_ARRAYSIZE(m_rename_buffer)); + } + bool ProjectViewWindow::isViewedAncestor(const ModelIndex &index) { if (m_view_index == m_tree_proxy.toSourceIndex(index)) { return true; From eff39f70fe25ab2bdd91df4f3c0de16bf4f388bf Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Mon, 30 Sep 2024 11:15:19 -0500 Subject: [PATCH 044/129] Add support for shift-click range selection --- include/gui/project/window.hpp | 1 + include/model/fsmodel.hpp | 35 +++++++++------ include/model/model.hpp | 3 ++ src/gui/project/window.cpp | 32 +++++++++++++- src/model/fsmodel.cpp | 81 ++++++++++++++++++++++++++++++---- 5 files changed, 128 insertions(+), 24 deletions(-) diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 66652298..5217a9df 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -105,6 +105,7 @@ namespace Toolbox::UI { FileSystemModelSortFilterProxy m_view_proxy; RefPtr m_file_system_model; + ModelIndex m_last_selected_index; std::vector m_selected_indices; std::vector m_view_assets; ModelIndex m_view_index; diff --git a/include/model/fsmodel.hpp b/include/model/fsmodel.hpp index 346d3fcc..a005e9b2 100644 --- a/include/model/fsmodel.hpp +++ b/include/model/fsmodel.hpp @@ -124,6 +124,9 @@ namespace Toolbox { [[nodiscard]] size_t getColumnCount(const ModelIndex &index) const override; [[nodiscard]] size_t getRowCount(const ModelIndex &index) const override; + [[nodiscard]] int64_t getColumn(const ModelIndex &index) const override; + [[nodiscard]] int64_t getRow(const ModelIndex &index) const override; + [[nodiscard]] bool hasChildren(const ModelIndex &parent = ModelIndex()) const override; [[nodiscard]] ScopePtr @@ -172,6 +175,9 @@ namespace Toolbox { [[nodiscard]] size_t getColumnCount_(const ModelIndex &index) const; [[nodiscard]] size_t getRowCount_(const ModelIndex &index) const; + [[nodiscard]] int64_t getColumn_(const ModelIndex &index) const; + [[nodiscard]] int64_t getRow_(const ModelIndex &index) const; + [[nodiscard]] bool hasChildren_(const ModelIndex &parent = ModelIndex()) const; [[nodiscard]] ScopePtr @@ -264,32 +270,33 @@ namespace Toolbox { bool remove(const ModelIndex &index); [[nodiscard]] ModelIndex getIndex(const fs_path &path) const; - [[nodiscard]] ModelIndex getIndex(const UUID64 &path) const; + [[nodiscard]] ModelIndex getIndex(const UUID64 &path) const override; [[nodiscard]] ModelIndex getIndex(int64_t row, int64_t column, - const ModelIndex &parent = ModelIndex()) const; + const ModelIndex &parent = ModelIndex()) const override; [[nodiscard]] fs_path getPath(const ModelIndex &index) const; - [[nodiscard]] ModelIndex getParent(const ModelIndex &index) const; + [[nodiscard]] ModelIndex getParent(const ModelIndex &index) const override; [[nodiscard]] ModelIndex getSibling(int64_t row, int64_t column, - const ModelIndex &index) const; + const ModelIndex &index) const override; - [[nodiscard]] size_t getColumnCount(const ModelIndex &index) const; - [[nodiscard]] size_t getRowCount(const ModelIndex &index) const; + [[nodiscard]] size_t getColumnCount(const ModelIndex &index) const override; + [[nodiscard]] size_t getRowCount(const ModelIndex &index) const override; - [[nodiscard]] bool hasChildren(const ModelIndex &parent = ModelIndex()) const; + [[nodiscard]] int64_t getColumn(const ModelIndex &index) const override; + [[nodiscard]] int64_t getRow(const ModelIndex &index) const override; + + [[nodiscard]] bool hasChildren(const ModelIndex &parent = ModelIndex()) const override; [[nodiscard]] ScopePtr - createMimeData(const std::vector &indexes) const; - [[nodiscard]] std::vector getSupportedMimeTypes() const; + createMimeData(const std::vector &indexes) const override; + [[nodiscard]] std::vector getSupportedMimeTypes() const override; - [[nodiscard]] bool canFetchMore(const ModelIndex &index); - void fetchMore(const ModelIndex &index); + [[nodiscard]] bool canFetchMore(const ModelIndex &index) override; + void fetchMore(const ModelIndex &index) override; [[nodiscard]] ModelIndex toSourceIndex(const ModelIndex &index) const; [[nodiscard]] ModelIndex toProxyIndex(const ModelIndex &index) const; - [[nodiscard]] UUID64 getSourceUUID(const ModelIndex &index) const; - protected: [[nodiscard]] ModelIndex toProxyIndex(int64_t row, int64_t column, const ModelIndex &parent = ModelIndex()) const; @@ -299,7 +306,7 @@ namespace Toolbox { void cacheIndex(const ModelIndex &index) const; void cacheIndex_(const ModelIndex &index) const; - ModelIndex makeIndex(const fs_path &path, int64_t row, const ModelIndex &parent) { + ModelIndex makeIndex(const fs_path &path, int64_t row, const ModelIndex &parent) override { return ModelIndex(); } diff --git a/include/model/model.hpp b/include/model/model.hpp index 76c1d46a..11fb3c8c 100644 --- a/include/model/model.hpp +++ b/include/model/model.hpp @@ -99,6 +99,9 @@ namespace Toolbox { [[nodiscard]] virtual size_t getColumnCount(const ModelIndex &index) const = 0; [[nodiscard]] virtual size_t getRowCount(const ModelIndex &index) const = 0; + [[nodiscard]] virtual int64_t getColumn(const ModelIndex &index) const = 0; + [[nodiscard]] virtual int64_t getRow(const ModelIndex &index) const = 0; + [[nodiscard]] virtual bool hasChildren(const ModelIndex &parent = ModelIndex()) const = 0; [[nodiscard]] virtual ScopePtr diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index de1ea520..37cedab4 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -157,17 +157,47 @@ namespace Toolbox::UI { } } else if (ImGui::IsMouseClicked(0)) { m_is_renaming = false; - if (ImGui::IsKeyDown(ImGuiMod_Ctrl)) { + if (Input::GetKey(KeyCode::KEY_LEFTCONTROL) || + Input::GetKey(KeyCode::KEY_RIGHTCONTROL)) { if (is_selected) { m_selected_indices.erase(std::remove( m_selected_indices.begin(), m_selected_indices.end(), source_child_index)); + m_last_selected_index = ModelIndex(); } else { m_selected_indices.push_back(source_child_index); + m_last_selected_index = source_child_index; } + } else if (Input::GetKey(KeyCode::KEY_LEFTSHIFT) || + Input::GetKey(KeyCode::KEY_RIGHTSHIFT)) { + if (m_file_system_model->validateIndex( + m_last_selected_index)) { + int64_t this_row = m_view_proxy.getRow(child_index); + int64_t last_row = m_view_proxy.getRow( + m_view_proxy.toProxyIndex(m_last_selected_index)); + if (this_row > last_row) { + for (int64_t i = last_row + 1; i <= this_row; ++i) { + ModelIndex span_index = + m_view_proxy.getIndex(i, 0, view_index); + m_selected_indices.push_back( + m_view_proxy.toSourceIndex(span_index)); + } + } else if (this_row < last_row) { + for (int64_t i = this_row; i < last_row; ++i) { + ModelIndex span_index = + m_view_proxy.getIndex(i, 0, view_index); + m_selected_indices.push_back( + m_view_proxy.toSourceIndex(span_index)); + } + } + } else { + m_selected_indices.push_back(source_child_index); + } + m_last_selected_index = source_child_index; } else { m_selected_indices.clear(); m_selected_indices.push_back(source_child_index); + m_last_selected_index = source_child_index; } } } diff --git a/src/model/fsmodel.cpp b/src/model/fsmodel.cpp index ac6a7103..4801feb7 100644 --- a/src/model/fsmodel.cpp +++ b/src/model/fsmodel.cpp @@ -273,6 +273,16 @@ namespace Toolbox { return getRowCount_(index); } + int64_t FileSystemModel::getColumn(const ModelIndex &index) const { + std::scoped_lock lock(m_mutex); + return getColumn_(index); + } + + int64_t FileSystemModel::getRow(const ModelIndex &index) const { + std::scoped_lock lock(m_mutex); + return getRow_(index); + } + bool FileSystemModel::hasChildren(const ModelIndex &parent) const { std::scoped_lock lock(m_mutex); return hasChildren_(parent); @@ -747,6 +757,32 @@ namespace Toolbox { return index.data<_FileSystemIndexData>()->m_children.size(); } + int64_t FileSystemModel::getColumn_(const ModelIndex &index) const { + return validateIndex(index) ? 0 : -1; + } + + int64_t FileSystemModel::getRow_(const ModelIndex &index) const { + if (!validateIndex(index)) { + return -1; + } + + ModelIndex parent = getParent_(index); + if (!validateIndex(parent)) { + return 0; + } + + _FileSystemIndexData *parent_data = parent.data<_FileSystemIndexData>(); + int64_t row = 0; + for (const UUID64 &uuid : parent_data->m_children) { + if (uuid == index.getUUID()) { + return row; + } + ++row; + } + + return -1; + } + bool FileSystemModel::hasChildren_(const ModelIndex &parent) const { if (getRowCount_(parent) > 0) { return true; @@ -1264,7 +1300,7 @@ namespace Toolbox { std::unique_lock lock(m_cache_mutex); ModelIndex source_index = toSourceIndex(index); - ModelIndex src_parent = getParent(source_index); + ModelIndex src_parent = m_source_model->getParent(source_index); const UUID64 &src_parent_uuid = src_parent.getUUID(); u64 map_key = src_parent_uuid; @@ -1294,6 +1330,41 @@ namespace Toolbox { return m_source_model->getRowCount(source_index); } + int64_t FileSystemModelSortFilterProxy::getColumn(const ModelIndex &index) const { + ModelIndex &&source_index = toSourceIndex(index); + return m_source_model->getColumn(source_index); + } + + int64_t FileSystemModelSortFilterProxy::getRow(const ModelIndex &index) const { + + ModelIndex &&source_index = toSourceIndex(index); + ModelIndex src_parent = m_source_model->getParent(source_index); + const UUID64 &src_parent_uuid = src_parent.getUUID(); + + u64 map_key = src_parent_uuid; + if (!m_source_model->validateIndex(src_parent)) { + map_key = 0; + } + + if (m_row_map.find(map_key) == m_row_map.end()) { + cacheIndex_(src_parent); + } + + int64_t src_row = m_source_model->getRow(source_index); + if (src_row == -1) { + return src_row; + } + + const std::vector &row_map = m_row_map[map_key]; + for (size_t i = 0; i < row_map.size(); ++i) { + if (src_row == row_map[i]) { + return i; + } + } + + return -1; + } + bool FileSystemModelSortFilterProxy::hasChildren(const ModelIndex &parent) const { ModelIndex &&source_index = toSourceIndex(parent); return m_source_model->hasChildren(source_index); @@ -1370,14 +1441,6 @@ namespace Toolbox { return ModelIndex(); } - UUID64 FileSystemModelSortFilterProxy::getSourceUUID(const ModelIndex &index) const { - if (!validateIndex(index)) { - return 0; - } - - return index.data<_FileSystemIndexData>()->m_self_uuid; - } - bool FileSystemModelSortFilterProxy::isFiltered(const UUID64 &uuid) const { ModelIndex child_index = m_source_model->getIndex(uuid); bool is_file = From deb5cfbd276a1a9a7cc116f351a0ae4523d62b4f Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Mon, 30 Sep 2024 14:22:49 -0500 Subject: [PATCH 045/129] Adjust shift-click span selection logic to better match Windows --- src/gui/project/window.cpp | 53 ++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 37cedab4..74762479 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -168,36 +168,39 @@ namespace Toolbox::UI { m_selected_indices.push_back(source_child_index); m_last_selected_index = source_child_index; } - } else if (Input::GetKey(KeyCode::KEY_LEFTSHIFT) || - Input::GetKey(KeyCode::KEY_RIGHTSHIFT)) { - if (m_file_system_model->validateIndex( - m_last_selected_index)) { - int64_t this_row = m_view_proxy.getRow(child_index); - int64_t last_row = m_view_proxy.getRow( - m_view_proxy.toProxyIndex(m_last_selected_index)); - if (this_row > last_row) { - for (int64_t i = last_row + 1; i <= this_row; ++i) { - ModelIndex span_index = - m_view_proxy.getIndex(i, 0, view_index); - m_selected_indices.push_back( - m_view_proxy.toSourceIndex(span_index)); - } - } else if (this_row < last_row) { - for (int64_t i = this_row; i < last_row; ++i) { - ModelIndex span_index = - m_view_proxy.getIndex(i, 0, view_index); - m_selected_indices.push_back( - m_view_proxy.toSourceIndex(span_index)); + } else { + m_selected_indices.clear(); + if (Input::GetKey(KeyCode::KEY_LEFTSHIFT) || + Input::GetKey(KeyCode::KEY_RIGHTSHIFT)) { + if (m_file_system_model->validateIndex( + m_last_selected_index)) { + int64_t this_row = m_view_proxy.getRow(child_index); + int64_t last_row = + m_view_proxy.getRow(m_view_proxy.toProxyIndex( + m_last_selected_index)); + if (this_row > last_row) { + for (int64_t i = last_row; i <= this_row; + ++i) { + ModelIndex span_index = + m_view_proxy.getIndex(i, 0, view_index); + m_selected_indices.push_back( + m_view_proxy.toSourceIndex(span_index)); + } + } else { + for (int64_t i = this_row; i <= last_row; ++i) { + ModelIndex span_index = + m_view_proxy.getIndex(i, 0, view_index); + m_selected_indices.push_back( + m_view_proxy.toSourceIndex(span_index)); + } } + } else { + m_selected_indices.push_back(source_child_index); } } else { m_selected_indices.push_back(source_child_index); + m_last_selected_index = source_child_index; } - m_last_selected_index = source_child_index; - } else { - m_selected_indices.clear(); - m_selected_indices.push_back(source_child_index); - m_last_selected_index = source_child_index; } } } From ac4d95caa11c688be9549feeb2b5dd5e6818a5dd Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Mon, 30 Sep 2024 18:37:54 -0500 Subject: [PATCH 046/129] More polish on context menu and such --- include/gui/context_menu.hpp | 10 ++- include/gui/imgui_ext.hpp | 3 +- include/gui/project/window.hpp | 7 +- src/gui/imgui_ext.cpp | 18 ++++ src/gui/project/window.cpp | 146 +++++++++++++++++---------------- 5 files changed, 106 insertions(+), 78 deletions(-) diff --git a/include/gui/context_menu.hpp b/include/gui/context_menu.hpp index b2c221a3..0edcb6c0 100644 --- a/include/gui/context_menu.hpp +++ b/include/gui/context_menu.hpp @@ -12,6 +12,7 @@ #include "IconsForkAwesome.h" #include +#include "imgui_ext.hpp" #include "core/input/input.hpp" #include "core/keybind/keybind.hpp" @@ -44,7 +45,8 @@ namespace Toolbox::UI { void addDivider(); - void render(std::optional label, _DataT ctx); + void render(std::optional label, _DataT ctx, + ImGuiHoveredFlags hover_flags = ImGuiHoveredFlags_AllowWhenBlockedByPopup); void onOpen(open_event_t open) { m_open_event = open; } @@ -83,10 +85,10 @@ namespace Toolbox::UI { } template - inline void ContextMenu<_DataT>::render(std::optional label, _DataT ctx) { + inline void ContextMenu<_DataT>::render(std::optional label, _DataT ctx, ImGuiHoveredFlags hover_flags) { processKeybinds(ctx); - if (!ImGui::BeginPopupContextItem(label ? label->c_str() : nullptr)) { + if (!ImGui::BeginPopupContextItem(label ? label->c_str() : nullptr, 1, hover_flags)) { m_was_open = false; return; } @@ -96,7 +98,7 @@ namespace Toolbox::UI { } m_was_open = true; - size_t prev_opt_index = 0; + size_t prev_opt_index = 0; for (size_t i = 0; i < m_options.size(); ++i) { ContextOp &option = m_options.at(i); diff --git a/include/gui/imgui_ext.hpp b/include/gui/imgui_ext.hpp index e3f547c1..37195f09 100644 --- a/include/gui/imgui_ext.hpp +++ b/include/gui/imgui_ext.hpp @@ -65,7 +65,8 @@ namespace ImGui { const char *label_end, bool focused); bool TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char *label, const char *label_end, bool focused, bool *visible); - + bool BeginPopupContextItem(const char *str_id, ImGuiPopupFlags popup_flags, + ImGuiHoveredFlags hover_flags); bool DrawCircle(const ImVec2 ¢er, float radius, ImU32 color, ImU32 fill_color = IM_COL32_BLACK_TRANS, float thickness = 1.0f); bool DrawSquare(const ImVec2 ¢er, float size, ImU32 color, diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 5217a9df..901485f2 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -96,6 +96,8 @@ namespace Toolbox::UI { void actionDeleteIndexes(std::vector &indices); void actionOpenIndexes(const std::vector &indices); void actionRenameIndex(const ModelIndex &index); + void actionLeftClickIndex(const ModelIndex &view_index, const ModelIndex &child_index, + bool is_selected); private: fs_path m_project_root; @@ -113,14 +115,15 @@ namespace Toolbox::UI { std::unordered_map m_icon_map; ImagePainter m_icon_painter; - ContextMenu m_context_menu; + ContextMenu m_folder_view_context_menu; + ContextMenu m_tree_view_context_menu; std::vector m_selected_indices_ctx; bool m_is_renaming = false; char m_rename_buffer[128]; bool m_delete_without_request = false; - bool m_delete_requested = false; + bool m_delete_requested = false; }; } // namespace Toolbox::UI \ No newline at end of file diff --git a/src/gui/imgui_ext.cpp b/src/gui/imgui_ext.cpp index b74429c5..922fe296 100644 --- a/src/gui/imgui_ext.cpp +++ b/src/gui/imgui_ext.cpp @@ -1227,6 +1227,24 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char *l return is_open; } +bool ImGui::BeginPopupContextItem(const char *str_id, ImGuiPopupFlags popup_flags, ImGuiHoveredFlags hover_flags) { + ImGuiContext &g = *GImGui; + ImGuiWindow *window = g.CurrentWindow; + if (window->SkipItems) + return false; + ImGuiID id = + str_id ? window->GetID(str_id) + : g.LastItemData.ID; // If user hasn't passed an ID, we can use the LastItemID. + // Using LastItemID as a Popup ID won't conflict! + IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a + // Text() item) + int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_); + if (IsMouseReleased(mouse_button) && IsItemHovered(hover_flags)) + OpenPopupEx(id, popup_flags); + return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | + ImGuiWindowFlags_NoSavedSettings); +} + bool ImGui::DrawCircle(const ImVec2 ¢er, float radius, ImU32 color, ImU32 fill_color, float thickness) { ImVec2 window_pos = ImGui::GetWindowPos(); diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 74762479..124ff7ed 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -18,7 +18,6 @@ namespace Toolbox::UI { renderProjectFolderView(); renderProjectFolderButton(); renderProjectFileButton(); - m_context_menu.render("Project View", m_view_index); } void ProjectViewWindow::renderProjectTreeView() { @@ -37,6 +36,10 @@ namespace Toolbox::UI { const ImGuiStyle &style = ImGui::GetStyle(); + bool is_left_click = Input::GetMouseButtonDown(MouseButton::BUTTON_LEFT); + bool is_double_left_click = ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left); + bool is_right_click = Input::GetMouseButtonDown(MouseButton::BUTTON_RIGHT); + if (ImGui::BeginChild("Folder View", {0, 0}, true, ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { if (m_file_system_model->hasChildren(m_view_index)) { @@ -50,9 +53,12 @@ namespace Toolbox::UI { ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, {2, 2}); ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 3.0f); + const float box_width = 76.0f; + const float label_width = box_width - style.WindowPadding.x * 4.0f; + ImVec2 size = ImGui::GetContentRegionAvail(); - size_t x_count = (size_t)(size.x / 80); + size_t x_count = (size_t)(size.x / (box_width + style.ItemSpacing.x) + 0.1f); if (x_count == 0) { x_count = 1; } @@ -89,11 +95,9 @@ namespace Toolbox::UI { ImVec2 text_size = ImGui::CalcTextSize(text.c_str()); ImVec2 rename_size = ImGui::CalcTextSize(m_rename_buffer); - const float box_width = 76.0f; - const float label_width = box_width - style.WindowPadding.x * 4.0f; - const float text_width = is_selected_rename - ? std::min(rename_size.x, label_width) - : std::min(text_size.x, label_width); + const float text_width = is_selected_rename + ? std::min(rename_size.x, label_width) + : std::min(text_size.x, label_width); if (ImGui::BeginChild(child_index.getUUID(), {box_width, 100.0f}, true, ImGuiWindowFlags_ChildWindow | @@ -106,7 +110,7 @@ namespace Toolbox::UI { // Render the label { - if (m_is_renaming && is_selected) { + if (is_selected_rename) { ImVec2 rename_pos = pos + ImVec2(style.WindowPadding.x, icon_size.y + style.ItemInnerSpacing.y - @@ -144,10 +148,10 @@ namespace Toolbox::UI { // Handle click responses { - any_items_hovered = any_items_hovered || ImGui::IsItemHovered() || - ImGui::IsWindowHovered(ImGuiHoveredFlags_None); + any_items_hovered |= ImGui::IsItemHovered() || + ImGui::IsWindowHovered(ImGuiHoveredFlags_None); if (ImGui::IsWindowHovered(ImGuiHoveredFlags_None)) { - if (ImGui::IsMouseDoubleClicked(0)) { + if (is_double_left_click) { m_is_renaming = false; if (m_view_proxy.isDirectory(child_index)) { m_view_index = m_view_proxy.toSourceIndex(child_index); @@ -155,53 +159,9 @@ namespace Toolbox::UI { ImGui::PopStyleColor(1); break; } - } else if (ImGui::IsMouseClicked(0)) { + } else if (is_left_click) { m_is_renaming = false; - if (Input::GetKey(KeyCode::KEY_LEFTCONTROL) || - Input::GetKey(KeyCode::KEY_RIGHTCONTROL)) { - if (is_selected) { - m_selected_indices.erase(std::remove( - m_selected_indices.begin(), - m_selected_indices.end(), source_child_index)); - m_last_selected_index = ModelIndex(); - } else { - m_selected_indices.push_back(source_child_index); - m_last_selected_index = source_child_index; - } - } else { - m_selected_indices.clear(); - if (Input::GetKey(KeyCode::KEY_LEFTSHIFT) || - Input::GetKey(KeyCode::KEY_RIGHTSHIFT)) { - if (m_file_system_model->validateIndex( - m_last_selected_index)) { - int64_t this_row = m_view_proxy.getRow(child_index); - int64_t last_row = - m_view_proxy.getRow(m_view_proxy.toProxyIndex( - m_last_selected_index)); - if (this_row > last_row) { - for (int64_t i = last_row; i <= this_row; - ++i) { - ModelIndex span_index = - m_view_proxy.getIndex(i, 0, view_index); - m_selected_indices.push_back( - m_view_proxy.toSourceIndex(span_index)); - } - } else { - for (int64_t i = this_row; i <= last_row; ++i) { - ModelIndex span_index = - m_view_proxy.getIndex(i, 0, view_index); - m_selected_indices.push_back( - m_view_proxy.toSourceIndex(span_index)); - } - } - } else { - m_selected_indices.push_back(source_child_index); - } - } else { - m_selected_indices.push_back(source_child_index); - m_last_selected_index = source_child_index; - } - } + actionLeftClickIndex(view_index, child_index, is_selected); } } } @@ -264,6 +224,10 @@ namespace Toolbox::UI { } } ImGui::EndChild(); + + m_folder_view_context_menu.render("Project View", m_view_index, + ImGuiHoveredFlags_AllowWhenBlockedByPopup | + ImGuiHoveredFlags_AllowWhenOverlapped); } void ProjectViewWindow::renderProjectFolderButton() {} @@ -296,12 +260,12 @@ namespace Toolbox::UI { void ProjectViewWindow::onDropEvent(RefPtr ev) {} void ProjectViewWindow::buildContextMenu() { - m_context_menu = ContextMenu(); + m_folder_view_context_menu = ContextMenu(); - m_context_menu.onOpen( + m_folder_view_context_menu.onOpen( [this](const ModelIndex &index) { m_selected_indices_ctx = m_selected_indices; }); - m_context_menu.addOption( + m_folder_view_context_menu.addOption( "Open", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_O}), [this]() { return m_selected_indices_ctx.size() > 0 && @@ -312,7 +276,7 @@ namespace Toolbox::UI { }, [this](auto) { actionOpenIndexes(m_selected_indices_ctx); }); - m_context_menu.addOption( + m_folder_view_context_menu.addOption( "Open in Explorer", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_LEFTSHIFT, KeyCode::KEY_O}), [this]() { @@ -341,9 +305,9 @@ namespace Toolbox::UI { } }); - m_context_menu.addDivider(); + m_folder_view_context_menu.addDivider(); - m_context_menu.addOption( + m_folder_view_context_menu.addOption( "Copy Path", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_LEFTSHIFT, KeyCode::KEY_C}), [this]() { return true; }, @@ -360,19 +324,19 @@ namespace Toolbox::UI { ImGui::SetClipboardText(paths.c_str()); }); - m_context_menu.addDivider(); + m_folder_view_context_menu.addDivider(); - m_context_menu.addOption( + m_folder_view_context_menu.addOption( "Cut", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_X}), [this]() { return m_selected_indices_ctx.size() > 0; }, [this](auto) {}); - m_context_menu.addOption( + m_folder_view_context_menu.addOption( "Copy", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_C}), [this]() { return m_selected_indices_ctx.size() > 0; }, [this](auto) {}); - m_context_menu.addDivider(); + m_folder_view_context_menu.addDivider(); - m_context_menu.addOption( + m_folder_view_context_menu.addOption( "Delete", KeyBind({KeyCode::KEY_DELETE}), [this]() { return m_selected_indices_ctx.size() > 0; }, [this](auto) { @@ -383,14 +347,14 @@ namespace Toolbox::UI { } }); - m_context_menu.addOption( + m_folder_view_context_menu.addOption( "Rename", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_R}), [this]() { return m_selected_indices_ctx.size() == 1; }, [this](auto) { actionRenameIndex(m_selected_indices_ctx[0]); }); - m_context_menu.addDivider(); + m_folder_view_context_menu.addDivider(); - m_context_menu.addOption( + m_folder_view_context_menu.addOption( "New...", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_N}), [this]() { return m_selected_indices_ctx.size() == 0; }, [this](const ModelIndex &view_index) { @@ -423,6 +387,46 @@ namespace Toolbox::UI { std::strncpy(m_rename_buffer, file_name.c_str(), IM_ARRAYSIZE(m_rename_buffer)); } + void ProjectViewWindow::actionLeftClickIndex(const ModelIndex &view_index, + const ModelIndex &child_index, bool is_selected) { + ModelIndex source_child_index = m_view_proxy.toSourceIndex(child_index); + if (Input::GetKey(KeyCode::KEY_LEFTCONTROL) || Input::GetKey(KeyCode::KEY_RIGHTCONTROL)) { + if (is_selected) { + m_selected_indices.erase(std::remove(m_selected_indices.begin(), + m_selected_indices.end(), source_child_index)); + m_last_selected_index = ModelIndex(); + } else { + m_selected_indices.push_back(source_child_index); + m_last_selected_index = source_child_index; + } + } else { + m_selected_indices.clear(); + if (Input::GetKey(KeyCode::KEY_LEFTSHIFT) || Input::GetKey(KeyCode::KEY_RIGHTSHIFT)) { + if (m_file_system_model->validateIndex(m_last_selected_index)) { + int64_t this_row = m_view_proxy.getRow(child_index); + int64_t last_row = + m_view_proxy.getRow(m_view_proxy.toProxyIndex(m_last_selected_index)); + if (this_row > last_row) { + for (int64_t i = last_row; i <= this_row; ++i) { + ModelIndex span_index = m_view_proxy.getIndex(i, 0, view_index); + m_selected_indices.push_back(m_view_proxy.toSourceIndex(span_index)); + } + } else { + for (int64_t i = this_row; i <= last_row; ++i) { + ModelIndex span_index = m_view_proxy.getIndex(i, 0, view_index); + m_selected_indices.push_back(m_view_proxy.toSourceIndex(span_index)); + } + } + } else { + m_selected_indices.push_back(source_child_index); + } + } else { + m_selected_indices.push_back(source_child_index); + m_last_selected_index = source_child_index; + } + } + } + bool ProjectViewWindow::isViewedAncestor(const ModelIndex &index) { if (m_view_index == m_tree_proxy.toSourceIndex(index)) { return true; From 5ba29d89b484e69a3f4c6f06cd06517790224ab5 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Mon, 30 Sep 2024 18:11:36 -0700 Subject: [PATCH 047/129] Allow copy-pasting files into JT on Linux --- include/core/clipboard.hpp | 3 + include/model/fsmodel.hpp | 4 + src/core/mimedata/mimedata.cpp | 12 ++- src/gui/clipboard.cpp | 129 ++++++++++++++++++++++++++++++++- src/gui/project/window.cpp | 47 ++++++++++++ src/model/fsmodel.cpp | 24 ++++++ 6 files changed, 215 insertions(+), 4 deletions(-) diff --git a/include/core/clipboard.hpp b/include/core/clipboard.hpp index 152459e4..15cf5eb8 100644 --- a/include/core/clipboard.hpp +++ b/include/core/clipboard.hpp @@ -5,6 +5,7 @@ #include #include "core/error.hpp" +#include "core/mimedata/mimedata.hpp" #include "tristate.hpp" namespace Toolbox { @@ -37,6 +38,8 @@ namespace Toolbox { Result getText(); Result setText(const std::string &text); + Result, ClipboardError> possibleContentTypes(); + Result getContent(const std::string &type); }; class DataClipboard { diff --git a/include/model/fsmodel.hpp b/include/model/fsmodel.hpp index a005e9b2..7400dea7 100644 --- a/include/model/fsmodel.hpp +++ b/include/model/fsmodel.hpp @@ -106,6 +106,8 @@ namespace Toolbox { ModelIndex mkdir(const ModelIndex &parent, const std::string &name); ModelIndex touch(const ModelIndex &parent, const std::string &name); ModelIndex rename(const ModelIndex &file, const std::string &new_name); + ModelIndex copy(const fs_path &file_path, const ModelIndex &new_parent, + const std::string &new_name); bool rmdir(const ModelIndex &index); bool remove(const ModelIndex &index); @@ -158,6 +160,8 @@ namespace Toolbox { ModelIndex mkdir_(const ModelIndex &parent, const std::string &name); ModelIndex touch_(const ModelIndex &parent, const std::string &name); ModelIndex rename_(const ModelIndex &file, const std::string &new_name); + ModelIndex copy_(const fs_path &file_path, const ModelIndex &new_parent, + const std::string &new_name); bool rmdir_(const ModelIndex &index); bool remove_(const ModelIndex &index); diff --git a/src/core/mimedata/mimedata.cpp b/src/core/mimedata/mimedata.cpp index e9874d27..bde8a1f1 100644 --- a/src/core/mimedata/mimedata.cpp +++ b/src/core/mimedata/mimedata.cpp @@ -112,12 +112,18 @@ namespace Toolbox { } [[nodiscard]] std::optional MimeData::get_urls() const { - TOOLBOX_DEBUG_LOG("URL mimedata unsupported"); - return {}; + if (!has_urls()) { + return std::nullopt; + } + const Buffer &data_buf = m_data_map["text/uri-list"]; + return std::string(data_buf.buf(), data_buf.size()); } void MimeData::set_urls(std::string_view data) { - TOOLBOX_DEBUG_LOG("URL mimedata unsupported"); + Buffer _tmp; + _tmp.alloc(data.size()); + std::memcpy(_tmp.buf(), data.data(), data.size()); + set_data("text/uri-list", std::move(_tmp)); } void MimeData::clear() { m_data_map.clear(); } diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index c4f5a711..65bdc1b3 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -2,6 +2,9 @@ #ifdef WIN32 #include +#elif defined(TOOLBOX_PLATFORM_LINUX) +#include +#include #endif namespace Toolbox { @@ -75,4 +78,128 @@ namespace Toolbox { return {}; } -} // namespace Toolbox::UI \ No newline at end of file + Result, ClipboardError> SystemClipboard::possibleContentTypes(){ +#ifdef TOOLBOX_PLATFORM_LINUX + Display *dpy = XOpenDisplay(nullptr); + if (!dpy) { + return make_clipboard_error>("Could not open X display"); + } + Atom sel = XInternAtom(dpy, "CLIPBOARD", False); + Atom targets = XInternAtom(dpy, "TARGETS", False); + Atom target_property = XInternAtom(dpy, "CLIP_TYPES", False); + Window root_window = RootWindow(dpy, DefaultScreen(dpy)); + Window target_window = XCreateSimpleWindow(dpy, root_window, -10, -10, 1, 1, 0, 0, 0); + XConvertSelection(dpy, sel, targets, target_property, target_window, + CurrentTime); + + XEvent ev; + XSelectionEvent *sev; + // This looks pretty dangerous but this is how glfw does it, + // and how the examples online do it, so :shrug: + while(true){ + XNextEvent(dpy, &ev); + switch (ev.type) + { + case SelectionNotify: + sev = (XSelectionEvent*)&ev.xselection; + if (sev->property == None) + { + return make_clipboard_error>("Conversion could not be performed.\n"); + } + else + { + std::vector types; + unsigned long nitems; + unsigned char *prop_ret = nullptr; + // We won't use these. + Atom _type; + int _di; + unsigned long _dul; + XGetWindowProperty(dpy, target_window, target_property, 0, + 1024 * sizeof(Atom), False, XA_ATOM, + &_type, &_di, &nitems, &_dul, &prop_ret); + + Atom *targets = (Atom*)prop_ret; + for(int i = 0; i < nitems; ++i) { + char* an = XGetAtomName(dpy, targets[i]); + types.push_back(std::string(an)); + if (an) + XFree(an); + } + XFree(prop_ret); + XDeleteProperty(dpy, target_window, target_property); + return types; + } + break; + } + } +#endif + return {}; + } + Result SystemClipboard::getContent(const std::string &type){ +#ifdef TOOLBOX_PLATFORM_LINUX + Display *dpy = XOpenDisplay(nullptr); + if (!dpy) { + return make_clipboard_error("Could not open X display"); + } + Atom requested_type = XInternAtom(dpy, type.c_str(), False); + Atom sel = XInternAtom(dpy, "CLIPBOARD", False); + Window clipboard_owner = XGetSelectionOwner(dpy, sel); + if (clipboard_owner == None) { + return make_clipboard_error("Clipboard isn't owned by anyone"); + } + Window root = RootWindow(dpy, DefaultScreen(dpy)); + Window target_window = XCreateSimpleWindow(dpy, root, -10, -10, 1, 1, 0, 0, 0); + Atom target_property = XInternAtom(dpy, "CLIP_CONTENTS", False); + XConvertSelection(dpy, sel, requested_type, target_property, target_window, CurrentTime); + XEvent ev; + XSelectionEvent *sev; + // This looks pretty dangerous but this is how glfw does it, + // and how the examples online do it, so :shrug: + while(true){ + XNextEvent(dpy, &ev); + switch (ev.type) + { + case SelectionNotify: + sev = (XSelectionEvent*)&ev.xselection; + if (sev->property == None) { + return make_clipboard_error("Conversion could not be performed."); + } else { + Atom type_received; + unsigned long size; + unsigned char *prop_ret = nullptr; + // These are unused + int _di; + unsigned long _dul; + Atom _da; + + XGetWindowProperty(dpy, target_window, target_property, 0, 0, False, + AnyPropertyType, &type_received, &_di, &_dul, &size, &prop_ret); + XFree(prop_ret); + + Atom incr = XInternAtom(dpy, "INCR", False); + if (type_received == incr) { + return make_clipboard_error("Data over 256kb, this isn't supported yet"); + } + XGetWindowProperty(dpy, target_window, target_property, 0, size, False, + AnyPropertyType, &_da, &_di, &_dul, &_dul, &prop_ret); + Buffer data_buffer; + if (!data_buffer.alloc(size)) { + return make_clipboard_error( + "Couldn't allocate buffer of big enough size"); + } + std::memcpy(data_buffer.buf(), prop_ret, size); + XFree(prop_ret); + XDeleteProperty(dpy, target_window, target_property); + + MimeData result; + result.set_data(type, std::move(data_buffer)); + return result; + } + } + } +#endif + return {}; + } + +} // namespace Toolbox::UI diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 124ff7ed..f752fbda 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -259,6 +259,22 @@ namespace Toolbox::UI { void ProjectViewWindow::onDropEvent(RefPtr ev) {} + std::vector splitLines(std::string_view s) { + std::vector result; + size_t last_pos = 0; + size_t next_newline_pos = s.find('\n', 0); + while (next_newline_pos != std::string::npos) { + if (s[last_pos + next_newline_pos - 1] == '\r'){ + result.push_back(s.substr(last_pos, next_newline_pos - 1)); + } else { + result.push_back(s.substr(last_pos, next_newline_pos)); + } + last_pos = next_newline_pos + 1; + next_newline_pos = s.find('\n', last_pos); + } + return result; + } + void ProjectViewWindow::buildContextMenu() { m_folder_view_context_menu = ContextMenu(); @@ -351,6 +367,37 @@ namespace Toolbox::UI { "Rename", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_R}), [this]() { return m_selected_indices_ctx.size() == 1; }, [this](auto) { actionRenameIndex(m_selected_indices_ctx[0]); }); + m_folder_view_context_menu.addOption( + "Paste", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_V}), + [this]() { return m_selected_indices_ctx.size() == 0; }, + [this](auto) { + auto content_types = SystemClipboard::instance().possibleContentTypes(); + if (!content_types) { + TOOLBOX_ERROR("Couldn't get content types"); + return; + } + if (std::find(content_types.value().begin(), content_types.value().end(), + std::string("text/uri-list")) != content_types.value().end()) { + auto content = SystemClipboard::instance().getContent("text/uri-list"); + if (!content) { + TOOLBOX_ERROR("Failed to get content as uri list"); + return; + } + auto text = content.value().get_urls(); + if (!text) { + TOOLBOX_ERROR("Mime data wouldn't return uri list"); + return; + } + + for (std::string_view src_path_str : splitLines(text.value())) { + if (src_path_str.substr(0, 7) != "file://") { + TOOLBOX_ERROR_V("Can't copy non-local uri {}", src_path_str); + } + fs_path src_path = src_path_str.substr(7); + m_file_system_model->copy(src_path, m_view_index, src_path.filename()); + } + } + }); m_folder_view_context_menu.addDivider(); diff --git a/src/model/fsmodel.cpp b/src/model/fsmodel.cpp index 4801feb7..2550aa1d 100644 --- a/src/model/fsmodel.cpp +++ b/src/model/fsmodel.cpp @@ -230,6 +230,11 @@ namespace Toolbox { std::scoped_lock lock(m_mutex); return rename_(file, new_name); } + ModelIndex FileSystemModel::copy(const fs_path &file, const ModelIndex &new_parent, + const std::string &new_name) { + std::scoped_lock lock(m_mutex); + return copy_(file, new_parent, new_name); + } ModelIndex FileSystemModel::getIndex(const fs_path &path) const { std::scoped_lock lock(m_mutex); @@ -678,6 +683,25 @@ namespace Toolbox { parent_data->m_children.end()); return makeIndex(to, dest_index, parent); } + ModelIndex FileSystemModel::copy_(const fs_path &file, const ModelIndex &new_parent, + const std::string &new_name) { + if (!validateIndex(new_parent)) { + TOOLBOX_ERROR("[FileSystemModel] New parent isn't a valid index!"); + return ModelIndex(); + } + if (!Filesystem::exists(file)) { + TOOLBOX_ERROR_V("[FileSystemModel] \"{}\" is not a directory or file!", + file.string()); + return ModelIndex(); + } + fs_path to = new_parent.data<_FileSystemIndexData>()->m_path / new_name; + + int dest_index = getRowCount_(new_parent); + + Filesystem::copy(file, to); + + return makeIndex(to, dest_index, new_parent); + } ModelIndex FileSystemModel::getIndex_(const fs_path &path) const { if (m_index_map.empty()) { From 85f8363f6a33d72be71cf2f9d771a45af7104b17 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Mon, 30 Sep 2024 18:32:55 -0700 Subject: [PATCH 048/129] get index on copy instead of trying to make a new one --- src/model/fsmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/model/fsmodel.cpp b/src/model/fsmodel.cpp index 2550aa1d..0a65ddde 100644 --- a/src/model/fsmodel.cpp +++ b/src/model/fsmodel.cpp @@ -700,7 +700,7 @@ namespace Toolbox { Filesystem::copy(file, to); - return makeIndex(to, dest_index, new_parent); + return getIndex_(to); } ModelIndex FileSystemModel::getIndex_(const fs_path &path) const { From 5588e1d12ac53fb664f9bd49f1030acb59c2e2e7 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Mon, 30 Sep 2024 20:52:13 -0500 Subject: [PATCH 049/129] Implement Windows open in explorer --- include/platform/process.hpp | 6 +++++- src/gui/project/window.cpp | 4 ++-- src/platform/process.cpp | 9 +++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/platform/process.hpp b/include/platform/process.hpp index 75cc8d9a..80b4e8e6 100644 --- a/include/platform/process.hpp +++ b/include/platform/process.hpp @@ -5,6 +5,8 @@ #include #include +#include "fsystem.hpp" + #ifdef TOOLBOX_PLATFORM_WINDOWS #include #elif defined(TOOLBOX_PLATFORM_LINUX) @@ -36,7 +38,7 @@ namespace Toolbox::Platform { ProcessID m_thread_id = std::numeric_limits::max(); }; - Result CreateExProcess(const std::filesystem::path &program_path, + Result CreateExProcess(const fs_path &program_path, std::string_view cmdargs); Result KillExProcess(const ProcessInformation &process, size_t max_wait = std::numeric_limits::max()); @@ -52,4 +54,6 @@ namespace Toolbox::Platform { bool SetWindowTransparency(LowWindow window, uint8_t alpha); + bool OpenFileExplorer(const fs_path &path); + } // namespace Toolbox::Platform \ No newline at end of file diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 124ff7ed..85bc6f90 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -287,7 +287,7 @@ namespace Toolbox::UI { [this](auto) { if (m_selected_indices_ctx.size() == 0) { // TODO: Implement this interface - // Toolbox::Platform::OpenFileExplorer(path); + Toolbox::Platform::OpenFileExplorer(m_file_system_model->getPath(m_view_index)); } else { std::set paths; for (const ModelIndex &item_index : m_selected_indices_ctx) { @@ -300,7 +300,7 @@ namespace Toolbox::UI { } for (const fs_path &path : paths) { // TODO: Implement this interface - // Toolbox::Platform::OpenFileExplorer(path); + Toolbox::Platform::OpenFileExplorer(path); } } }); diff --git a/src/platform/process.cpp b/src/platform/process.cpp index edb7647e..add53d62 100644 --- a/src/platform/process.cpp +++ b/src/platform/process.cpp @@ -51,7 +51,7 @@ namespace Toolbox::Platform { } } - Result CreateExProcess(const std::filesystem::path &program_path, + Result CreateExProcess(const fs_path &program_path, std::string_view cmdargs) { std::string true_cmdargs = std::format("\"{}\" {}", program_path.string().c_str(), cmdargs.data()); @@ -187,10 +187,15 @@ namespace Toolbox::Platform { return UpdateWindow(window); } + bool OpenFileExplorer(const fs_path &path) { + std::wstring path_str = path.wstring(); + return (int)ShellExecuteW(NULL, L"open", L"explorer.exe", path_str.c_str(), NULL, SW_SHOW) > 32; + } + #elif defined(TOOLBOX_PLATFORM_LINUX) std::string GetLastErrorMessage() { return strerror(errno); } - Result CreateExProcess(const std::filesystem::path &program_path, + Result CreateExProcess(const fs_path &program_path, std::string_view cmdargs) { ProcessID pid = fork(); // Fork the current process if (pid == -1) { From 29c874dd1009f449f125b214803735ab38e9c489 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Mon, 30 Sep 2024 21:21:53 -0500 Subject: [PATCH 050/129] Fix missing .string() call --- src/gui/project/window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index d09f06c2..90955f5f 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -394,7 +394,7 @@ namespace Toolbox::UI { TOOLBOX_ERROR_V("Can't copy non-local uri {}", src_path_str); } fs_path src_path = src_path_str.substr(7); - m_file_system_model->copy(src_path, m_view_index, src_path.filename()); + m_file_system_model->copy(src_path, m_view_index, src_path.filename().string()); } } }); From 4e51b42df32b1bc4ab8edb3353e6e922e4e1d084 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Tue, 1 Oct 2024 11:29:59 -0700 Subject: [PATCH 051/129] Fix build on linux by stubbing out file explorer --- src/platform/process.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/platform/process.cpp b/src/platform/process.cpp index add53d62..324fb7ad 100644 --- a/src/platform/process.cpp +++ b/src/platform/process.cpp @@ -363,5 +363,9 @@ namespace Toolbox::Platform { } } } + bool OpenFileExplorer(const fs_path &path) { + TOOLBOX_ERROR("Open file explorer currently unsupported on linux"); + return false; + } #endif } // namespace Toolbox::Platform From 3ddfeac7563c4636520662a549eca4d98ee378c2 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Tue, 1 Oct 2024 18:01:23 -0500 Subject: [PATCH 052/129] Add ability to open scene folders from a project folder --- include/gui/application.hpp | 19 ++++++-- include/gui/project/window.hpp | 4 ++ src/gui/application.cpp | 19 ++++++++ src/gui/project/window.cpp | 82 +++++++++++++++++++++++++++++++--- 4 files changed, 115 insertions(+), 9 deletions(-) diff --git a/include/gui/application.hpp b/include/gui/application.hpp index 201c7b42..6bc3c99a 100644 --- a/include/gui/application.hpp +++ b/include/gui/application.hpp @@ -55,13 +55,21 @@ namespace Toolbox { virtual void onExit() override; void addWindow(RefPtr window) { - addLayer(window); - m_windows.push_back(window); + if (!m_windows_processing) { + addLayer(window); + m_windows.push_back(window); + } else { + m_windows_to_add.push(window); + } } void removeWindow(RefPtr window) { - removeLayer(window); - std::erase(m_windows, window); + if (!m_windows_processing) { + removeLayer(window); + std::erase(m_windows, window); + } else { + m_windows_to_gc.push(window); + } } const std::vector> &getWindows() const & { return m_windows; } @@ -179,6 +187,9 @@ namespace Toolbox { GLFWwindow *m_render_window; std::vector> m_windows; + std::queue> m_windows_to_gc; + std::queue> m_windows_to_add; + bool m_windows_processing = false; std::unordered_map m_docked_map; ImGuiID m_dockspace_id; diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 901485f2..2bc0b1c3 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -99,6 +99,10 @@ namespace Toolbox::UI { void actionLeftClickIndex(const ModelIndex &view_index, const ModelIndex &child_index, bool is_selected); + bool actionOpenScene(const ModelIndex &index); + + bool isPathForScene(const ModelIndex &index) const; + private: fs_path m_project_root; diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 621de2be..8d67258f 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -357,7 +357,26 @@ namespace Toolbox { // UPDATE LOOP: We update layers here so the ImGui dockspaces can take effect first. { + m_windows_processing = true; CoreApplication::onUpdate(delta_time); + m_windows_processing = false; + + for (size_t i = 0; i < m_windows_to_add.size(); ++i) { + RefPtr window = m_windows_to_add.front(); + m_windows_to_add.pop(); + + addLayer(window); + m_windows.push_back(window); + } + + for (size_t i = 0; i < m_windows_to_gc.size(); ++i) { + RefPtr window = m_windows_to_gc.front(); + m_windows_to_gc.pop(); + + removeLayer(window); + std::erase(m_windows, window); + } + gcClosedWindows(); } diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 90955f5f..8b070165 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -1,4 +1,5 @@ #include "gui/project/window.hpp" +#include "gui/application.hpp" #include "model/fsmodel.hpp" #include @@ -261,15 +262,15 @@ namespace Toolbox::UI { std::vector splitLines(std::string_view s) { std::vector result; - size_t last_pos = 0; + size_t last_pos = 0; size_t next_newline_pos = s.find('\n', 0); while (next_newline_pos != std::string::npos) { - if (s[last_pos + next_newline_pos - 1] == '\r'){ + if (s[last_pos + next_newline_pos - 1] == '\r') { result.push_back(s.substr(last_pos, next_newline_pos - 1)); } else { result.push_back(s.substr(last_pos, next_newline_pos)); } - last_pos = next_newline_pos + 1; + last_pos = next_newline_pos + 1; next_newline_pos = s.find('\n', last_pos); } return result; @@ -287,7 +288,7 @@ namespace Toolbox::UI { return m_selected_indices_ctx.size() > 0 && std::all_of(m_selected_indices_ctx.begin(), m_selected_indices_ctx.end(), [this](const ModelIndex &index) { - return m_file_system_model->isFile(index); + return m_file_system_model->isFile(index) || isPathForScene(index); }); }, [this](auto) { actionOpenIndexes(m_selected_indices_ctx); }); @@ -394,7 +395,8 @@ namespace Toolbox::UI { TOOLBOX_ERROR_V("Can't copy non-local uri {}", src_path_str); } fs_path src_path = src_path_str.substr(7); - m_file_system_model->copy(src_path, m_view_index, src_path.filename().string()); + m_file_system_model->copy(src_path, m_view_index, + src_path.filename().string()); } } }); @@ -418,11 +420,16 @@ namespace Toolbox::UI { void ProjectViewWindow::actionOpenIndexes(const std::vector &indices) { for (auto &item_index : indices) { + if (actionOpenScene(item_index)) { + continue; + } + if (m_file_system_model->isDirectory(item_index)) { m_view_index = item_index; continue; } + // TODO: Open files based on extension. Can be either internal or external // depending on the file type. } @@ -474,6 +481,71 @@ namespace Toolbox::UI { } } + bool ProjectViewWindow::actionOpenScene(const ModelIndex &index) { + if (!m_file_system_model->validateIndex(index)) { + return false; + } + + GUIApplication &app = GUIApplication::instance(); + + if (m_file_system_model->isDirectory(index)) { + // ./scene/ + fs_path scene_path = m_file_system_model->getPath(index); + + RefPtr window = app.createWindow("Scene Editor"); + if (!window->onLoadData(scene_path)) { + app.removeWindow(window); + return false; + } + + return true; + } else if (m_file_system_model->isArchive(index)) { + TOOLBOX_ERROR("[PROJECT] Archives are not supported yet"); + } else if (m_file_system_model->isFile(index)) { + // ./scene/map/scene.bin + fs_path scene_path = m_file_system_model->getPath(index); + if (scene_path.filename().string() != "scene.bin") { + return false; + } + + fs_path scene_folder = scene_path.parent_path().parent_path(); + if (scene_folder.filename().string() != "scene") { + return false; + } + + RefPtr window = app.createWindow("Scene Editor"); + if (!window->onLoadData(scene_folder)) { + app.removeWindow(window); + return false; + } + + return true; + } + } + + bool ProjectViewWindow::isPathForScene(const ModelIndex &index) const { + if (!m_file_system_model->validateIndex(index)) { + return false; + } + + if (m_file_system_model->isDirectory(index)) { + fs_path scene_path = m_file_system_model->getPath(index); + if (scene_path.filename().string() == "scene") { + return true; + } + } else if (m_file_system_model->isFile(index)) { + fs_path scene_path = m_file_system_model->getPath(index); + if (scene_path.filename().string() == "scene.bin") { + fs_path scene_folder = scene_path.parent_path().parent_path(); + if (scene_folder.filename().string() == "scene") { + return true; + } + } + } + + return false; + } + bool ProjectViewWindow::isViewedAncestor(const ModelIndex &index) { if (m_view_index == m_tree_proxy.toSourceIndex(index)) { return true; From e095a47668bddbd1a8d556376582ce9dc4f2f2f6 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Tue, 1 Oct 2024 18:48:18 -0500 Subject: [PATCH 053/129] Remove scene open from application open, and optimize otherwise --- src/gui/application.cpp | 32 +++++++++----------------------- src/gui/project/window.cpp | 17 +++++++++++++++-- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 8d67258f..36be765b 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -266,7 +266,7 @@ namespace Toolbox { const std::string &context) { auto it = std::find_if(m_windows.begin(), m_windows.end(), [&title, &context](const auto &window) { - return window->title() == title && window->context() == context; + return window->name() == title && window->context() == context; }); return it != m_windows.end() ? *it : nullptr; } @@ -360,7 +360,7 @@ namespace Toolbox { m_windows_processing = true; CoreApplication::onUpdate(delta_time); m_windows_processing = false; - + for (size_t i = 0; i < m_windows_to_add.size(); ++i) { RefPtr window = m_windows_to_add.front(); m_windows_to_add.pop(); @@ -450,27 +450,13 @@ namespace Toolbox { FileDialog::instance()->close(); if (FileDialog::instance()->isOk()) { std::filesystem::path selected_path = FileDialog::instance()->getFilenameResult(); - if (selected_path.filename() == "scene") { - RefPtr existing_editor = - findWindow("Scene Editor", selected_path.string()); - if (existing_editor) { - existing_editor->focus(); - } else { - RefPtr scene_window = - createWindow("Scene Editor"); - if (!scene_window->onLoadData(selected_path)) { - scene_window->close(); - } - } - } else { - if (m_project_manager.loadProjectFolder(selected_path)) { - TOOLBOX_INFO_V("Loaded project folder: {}", selected_path.string()); - RefPtr project_window = - createWindow("Project View"); - if (!project_window->onLoadData(selected_path)) { - TOOLBOX_ERROR("Failed to open project folder view!"); - project_window->close(); - } + if (m_project_manager.loadProjectFolder(selected_path)) { + TOOLBOX_INFO_V("Loaded project folder: {}", selected_path.string()); + RefPtr project_window = + createWindow("Project View"); + if (!project_window->onLoadData(selected_path)) { + TOOLBOX_ERROR("Failed to open project folder view!"); + project_window->close(); } } } diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 8b070165..3426098a 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -288,7 +288,8 @@ namespace Toolbox::UI { return m_selected_indices_ctx.size() > 0 && std::all_of(m_selected_indices_ctx.begin(), m_selected_indices_ctx.end(), [this](const ModelIndex &index) { - return m_file_system_model->isFile(index) || isPathForScene(index); + return m_file_system_model->isFile(index) || + isPathForScene(index); }); }, [this](auto) { actionOpenIndexes(m_selected_indices_ctx); }); @@ -429,7 +430,6 @@ namespace Toolbox::UI { continue; } - // TODO: Open files based on extension. Can be either internal or external // depending on the file type. } @@ -492,6 +492,12 @@ namespace Toolbox::UI { // ./scene/ fs_path scene_path = m_file_system_model->getPath(index); + RefPtr existing_editor = app.findWindow("Scene Editor", scene_path.string()); + if (existing_editor) { + existing_editor->focus(); + return true; + } + RefPtr window = app.createWindow("Scene Editor"); if (!window->onLoadData(scene_path)) { app.removeWindow(window); @@ -513,6 +519,13 @@ namespace Toolbox::UI { return false; } + RefPtr existing_editor = + app.findWindow("Scene Editor", scene_folder.string()); + if (existing_editor) { + existing_editor->focus(); + return true; + } + RefPtr window = app.createWindow("Scene Editor"); if (!window->onLoadData(scene_folder)) { app.removeWindow(window); From 059915cd0568ec532e6749993bfedbdb1e90d26d Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Tue, 1 Oct 2024 21:03:58 -0500 Subject: [PATCH 054/129] Allow opening pad folders from project system --- include/gui/project/window.hpp | 1 + src/gui/project/window.cpp | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 2bc0b1c3..5bb91445 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -100,6 +100,7 @@ namespace Toolbox::UI { bool is_selected); bool actionOpenScene(const ModelIndex &index); + bool actionOpenPad(const ModelIndex &index); bool isPathForScene(const ModelIndex &index) const; diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 3426098a..6c62415e 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -421,6 +421,10 @@ namespace Toolbox::UI { void ProjectViewWindow::actionOpenIndexes(const std::vector &indices) { for (auto &item_index : indices) { + if (actionOpenPad(item_index)) { + continue; + } + if (actionOpenScene(item_index)) { continue; } @@ -536,6 +540,34 @@ namespace Toolbox::UI { } } + bool ProjectViewWindow::actionOpenPad(const ModelIndex &index) { + if (!m_file_system_model->isDirectory(index)) { + return false; + } + + GUIApplication &app = GUIApplication::instance(); + + // ./scene/map/map/pad/ + fs_path pad_path = m_file_system_model->getPath(index); + if (pad_path.filename().string() != "pad") { + return false; + } + + RefPtr existing_editor = app.findWindow("Pad Recorder", pad_path.string()); + if (existing_editor) { + existing_editor->focus(); + return true; + } + + RefPtr window = app.createWindow("Pad Recorder"); + if (!window->onLoadData(pad_path)) { + app.removeWindow(window); + return false; + } + + return true; + } + bool ProjectViewWindow::isPathForScene(const ModelIndex &index) const { if (!m_file_system_model->validateIndex(index)) { return false; From 2deee8dde791e851d934eb4fa9470c5b8fa4b40b Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Thu, 3 Oct 2024 05:44:19 -0500 Subject: [PATCH 055/129] Windows clipboard support progress --- include/core/clipboard.hpp | 18 +- include/core/mimedata/mimedata.hpp | 9 - src/core/mimedata/mimedata.cpp | 55 +---- src/gui/clipboard.cpp | 338 +++++++++++++++++++++++++---- src/gui/project/window.cpp | 14 +- 5 files changed, 322 insertions(+), 112 deletions(-) diff --git a/include/core/clipboard.hpp b/include/core/clipboard.hpp index 15cf5eb8..6e495d94 100644 --- a/include/core/clipboard.hpp +++ b/include/core/clipboard.hpp @@ -28,7 +28,7 @@ namespace Toolbox { ~SystemClipboard(); SystemClipboard(const SystemClipboard &) = delete; - SystemClipboard(SystemClipboard &&) = delete; + SystemClipboard(SystemClipboard &&) = delete; public: static SystemClipboard &instance() { @@ -40,6 +40,20 @@ namespace Toolbox { Result setText(const std::string &text); Result, ClipboardError> possibleContentTypes(); Result getContent(const std::string &type); + +#ifdef TOOLBOX_PLATFORM_WINDOWS + protected: + static UINT FormatForMime(std::string_view mimetype); + static std::string MimeForFormat(UINT format); + + private: + std::unordered_map m_mime_to_format; +#elif defined(TOOLBOX_PLATFORM_LINUX) + protected: + static std::string UTIForMime(std::string_view mimetype); + static std::string MimeForUTI(std::string_view uti); +#endif + }; class DataClipboard { @@ -137,4 +151,4 @@ namespace Toolbox { std::vector<_DataT> m_data = {}; }; -} // namespace Toolbox::UI \ No newline at end of file +} // namespace Toolbox \ No newline at end of file diff --git a/include/core/mimedata/mimedata.hpp b/include/core/mimedata/mimedata.hpp index eca76d21..02b99175 100644 --- a/include/core/mimedata/mimedata.hpp +++ b/include/core/mimedata/mimedata.hpp @@ -66,15 +66,6 @@ namespace Toolbox { return *this; } - protected: -#ifdef TOOLBOX_PLATFORM_WINDOWS - static FORMATETC FormatForMime(std::string_view mimetype); - static std::string MimeForFormat(FORMATETC format); -#elif defined(TOOLBOX_PLATFORM_LINUX) - static std::string UTIForMime(std::string_view mimetype); - static std::string MimeForUTI(std::string_view uti); -#endif - private: mutable std::unordered_map m_data_map; }; diff --git a/src/core/mimedata/mimedata.cpp b/src/core/mimedata/mimedata.cpp index bde8a1f1..939df19e 100644 --- a/src/core/mimedata/mimedata.cpp +++ b/src/core/mimedata/mimedata.cpp @@ -59,10 +59,11 @@ namespace Toolbox { Buffer &data_buf = m_data_map["application/x-color"]; Color::RGBAShader rgba_color; - TRY(Deserializer::BytesToObject(data_buf, rgba_color)).error([&rgba_color](const BaseError &error) { - UI::LogError(error); - rgba_color.setColor(0.0f, 0.0f, 0.0f); - }); + TRY(Deserializer::BytesToObject(data_buf, rgba_color)) + .error([&rgba_color](const BaseError &error) { + UI::LogError(error); + rgba_color.setColor(0.0f, 0.0f, 0.0f); + }); return rgba_color; } @@ -128,50 +129,4 @@ namespace Toolbox { void MimeData::clear() { m_data_map.clear(); } -#ifdef TOOLBOX_PLATFORM_WINDOWS - - /* TODO: Change NULL to HTML */ - static std::unordered_map s_format_to_mime = { - {CF_UNICODETEXT, "text/plain" }, - {CF_TEXT, "text/plain" }, - {CF_NULL, "text/html" }, - {CF_HDROP, "text/uri-list" }, - {CF_DIB, "application/x-qt-image"} - }; - - static std::unordered_map s_mime_to_format = { - {"text/plain", CF_TEXT }, - {"text/html", CF_NULL }, - {"text/uri-list", CF_HDROP}, - {"application/x-qt-image", CF_DIB }, - }; - - FORMATETC MimeData::FormatForMime(std::string_view mimetype) { return FORMATETC(); } - - std::string MimeData::MimeForFormat(FORMATETC format) { return std::string(); } -#elif defined(TOOLBOX_PLATFORM_LINUX) - static std::unordered_map s_uti_to_mime = { - {"public.utf8-plain-text", "text/plain" }, - {"public.utf16-plain-text", "text/plain" }, - {"public.text", "text/plain" }, - {"public.html", "text/html" }, - {"public.url", "text/uri-list" }, - {"public.file-url", "text/uri-list" }, - {"public.tiff", "application/x-qt-image"}, - {"public.vcard", "text/plain" }, - {"com.apple.traditional-mac-plain-text", "text/plain" }, - {"com.apple.pict", "application/x-qt-image"}, - }; - - static std::unordered_map s_mime_to_uti = { - {"text/plain", "public.text"}, - {"text/html", "public.html"}, - {"text/uri-list", "public.url" }, - {"application/x-qt-image", "public.tiff"}, - }; - - std::string MimeData::UTIForMime(std::string_view mimetype) { return s_mime_to_uti[std::string(mimetype)]; } - std::string MimeData::MimeForUTI(std::string_view uti) { return s_uti_to_mime[std::string(uti)]; } -#endif - } // namespace Toolbox \ No newline at end of file diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index 65bdc1b3..17159302 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -1,10 +1,11 @@ #include "core/clipboard.hpp" +#include "core/core.hpp" -#ifdef WIN32 +#ifdef TOOLBOX_PLATFORM_WINDOWS #include #elif defined(TOOLBOX_PLATFORM_LINUX) -#include #include +#include #endif namespace Toolbox { @@ -12,8 +13,8 @@ namespace Toolbox { SystemClipboard::SystemClipboard() {} SystemClipboard::~SystemClipboard() {} +#ifdef TOOLBOX_PLATFORM_WINDOWS Result SystemClipboard::getText() { -#ifdef WIN32 if (!OpenClipboard(nullptr)) { return make_clipboard_error("Failed to open the clipboard!"); } @@ -25,7 +26,8 @@ namespace Toolbox { const char *text_data = static_cast(GlobalLock(clipboard_data)); if (!text_data) { - return make_clipboard_error("Failed to retrieve the buffer from the handle!"); + return make_clipboard_error( + "Failed to retrieve the buffer from the handle!"); } std::string result = text_data; @@ -39,11 +41,15 @@ namespace Toolbox { } return result; -#else -#endif } +#elif defined(TOOLBOX_PLATFORM_LINUX) + Result SystemClipboard::getText() { + return make_clipboard_error("Not implemented yet"); + } +#endif + +#ifdef TOOLBOX_PLATFORM_WINDOWS Result SystemClipboard::setText(const std::string &text) { -#ifdef WIN32 if (!OpenClipboard(nullptr)) { return make_clipboard_error("Failed to open the clipboard!"); } @@ -52,7 +58,7 @@ namespace Toolbox { return make_clipboard_error("Failed to clear the clipboard!"); } - HANDLE data_handle = GlobalAlloc(GMEM_DDESHARE, text.size()+1); + HANDLE data_handle = GlobalAlloc(GMEM_DDESHARE, text.size() + 1); if (!data_handle) { return make_clipboard_error("Failed to alloc new data handle!"); } @@ -62,7 +68,7 @@ namespace Toolbox { return make_clipboard_error("Failed to retrieve the buffer from the handle!"); } - strncpy_s(data_buffer, text.size()+1, text.c_str(), text.size()+1); + strncpy_s(data_buffer, text.size() + 1, text.c_str(), text.size() + 1); if (!GlobalUnlock(data_handle)) { return make_clipboard_error("Failed to unlock the data handle!"); @@ -73,41 +79,71 @@ namespace Toolbox { if (!CloseClipboard()) { return make_clipboard_error("Failed to close the clipboard!"); } -#else -#endif return {}; } +#elif defined(TOOLBOX_PLATFORM_LINUX) + Result SystemClipboard::setText(const std::string &text) { + return make_clipboard_error("Not implemented yet"); + } +#endif + +#ifdef TOOLBOX_PLATFORM_WINDOWS + Result, ClipboardError> SystemClipboard::possibleContentTypes() { + if (!OpenClipboard(nullptr)) { + return make_clipboard_error>("Failed to open the clipboard!"); + } + + std::vector types; + UINT format = 0; + while ((format = EnumClipboardFormats(format)) != CF_NULL) { + std::string the_format = ""; + + for (const auto &[mime, custom_fmt] : m_mime_to_format) { + if (format == custom_fmt) { + the_format = mime; + break; + } + } + + if (the_format.empty()) { + the_format = MimeForFormat(format); + } + + types.push_back(the_format); + } + + if (!CloseClipboard()) { + return make_clipboard_error>("Failed to close the clipboard!"); + } - Result, ClipboardError> SystemClipboard::possibleContentTypes(){ -#ifdef TOOLBOX_PLATFORM_LINUX + return types; + } +#elif defined(TOOLBOX_PLATFORM_LINUX) + Result, ClipboardError> SystemClipboard::possibleContentTypes() { Display *dpy = XOpenDisplay(nullptr); if (!dpy) { return make_clipboard_error>("Could not open X display"); } - Atom sel = XInternAtom(dpy, "CLIPBOARD", False); - Atom targets = XInternAtom(dpy, "TARGETS", False); + Atom sel = XInternAtom(dpy, "CLIPBOARD", False); + Atom targets = XInternAtom(dpy, "TARGETS", False); Atom target_property = XInternAtom(dpy, "CLIP_TYPES", False); - Window root_window = RootWindow(dpy, DefaultScreen(dpy)); + Window root_window = RootWindow(dpy, DefaultScreen(dpy)); Window target_window = XCreateSimpleWindow(dpy, root_window, -10, -10, 1, 1, 0, 0, 0); - XConvertSelection(dpy, sel, targets, target_property, target_window, - CurrentTime); + XConvertSelection(dpy, sel, targets, target_property, target_window, CurrentTime); XEvent ev; XSelectionEvent *sev; // This looks pretty dangerous but this is how glfw does it, // and how the examples online do it, so :shrug: - while(true){ + while (true) { XNextEvent(dpy, &ev); - switch (ev.type) - { + switch (ev.type) { case SelectionNotify: - sev = (XSelectionEvent*)&ev.xselection; - if (sev->property == None) - { - return make_clipboard_error>("Conversion could not be performed.\n"); - } - else - { + sev = (XSelectionEvent *)&ev.xselection; + if (sev->property == None) { + return make_clipboard_error>( + "Conversion could not be performed.\n"); + } else { std::vector types; unsigned long nitems; unsigned char *prop_ret = nullptr; @@ -115,13 +151,12 @@ namespace Toolbox { Atom _type; int _di; unsigned long _dul; - XGetWindowProperty(dpy, target_window, target_property, 0, - 1024 * sizeof(Atom), False, XA_ATOM, - &_type, &_di, &nitems, &_dul, &prop_ret); + XGetWindowProperty(dpy, target_window, target_property, 0, 1024 * sizeof(Atom), + False, XA_ATOM, &_type, &_di, &nitems, &_dul, &prop_ret); - Atom *targets = (Atom*)prop_ret; - for(int i = 0; i < nitems; ++i) { - char* an = XGetAtomName(dpy, targets[i]); + Atom *targets = (Atom *)prop_ret; + for (int i = 0; i < nitems; ++i) { + char *an = XGetAtomName(dpy, targets[i]); types.push_back(std::string(an)); if (an) XFree(an); @@ -133,22 +168,117 @@ namespace Toolbox { break; } } -#endif return {}; } - Result SystemClipboard::getContent(const std::string &type){ -#ifdef TOOLBOX_PLATFORM_LINUX +#endif + +#ifdef TOOLBOX_PLATFORM_WINDOWS + Result SystemClipboard::getContent(const std::string &type) { + if (!OpenClipboard(nullptr)) { + return make_clipboard_error("Failed to open the clipboard!"); + } + + UINT format = CF_NULL; + if (m_mime_to_format.find(type) == m_mime_to_format.end()) { + format = FormatForMime(type); + if (format == CF_NULL) { + m_mime_to_format[type] = RegisterClipboardFormat(type.c_str()); + format = m_mime_to_format[type]; + } + } else { + format = m_mime_to_format[type]; + } + + if (format == CF_NULL) { + return make_clipboard_error("Failed to register the clipboard format!"); + } + + HANDLE clipboard_data = GetClipboardData(format); + if (!clipboard_data) { + return make_clipboard_error("Failed to retrieve the data handle!"); + } + + HANDLE data_handle = static_cast(GlobalLock(clipboard_data)); + if (!data_handle) { + return make_clipboard_error("Failed to retrieve the buffer from the handle!"); + } + + if (format == CF_TEXT) { + const char *text_data = static_cast(data_handle); + std::string result = text_data; + + if (!GlobalUnlock(clipboard_data)) { + return make_clipboard_error("Failed to unlock the data handle!"); + } + + if (!CloseClipboard()) { + return make_clipboard_error("Failed to close the clipboard!"); + } + + MimeData mime_data; + mime_data.set_text(result); + return mime_data; + } + + if (format == CF_HDROP) { + HDROP hdrop = static_cast(data_handle); + UINT num_files = DragQueryFile(hdrop, 0xFFFFFFFF, nullptr, 0); + std::string uri_list; + for (UINT i = 0; i < num_files; ++i) { + UINT size = DragQueryFile(hdrop, i, nullptr, 0); + std::string file(size, '\0'); + DragQueryFile(hdrop, i, file.data(), size + 1); + uri_list += std::format("file:///{}", file); + if (i != num_files - 1) { + uri_list += "\r\n"; + } + } + + if (!GlobalUnlock(clipboard_data)) { + return make_clipboard_error("Failed to unlock the data handle!"); + } + + if (!CloseClipboard()) { + return make_clipboard_error("Failed to close the clipboard!"); + } + + MimeData mime_data; + mime_data.set_urls(uri_list); + return mime_data; + } + + if (format == CF_UNICODETEXT) { + const wchar_t *text_data = static_cast(data_handle); + std::wstring result = text_data; + + if (!GlobalUnlock(clipboard_data)) { + return make_clipboard_error("Failed to unlock the data handle!"); + } + + if (!CloseClipboard()) { + return make_clipboard_error("Failed to close the clipboard!"); + } + + MimeData mime_data; + mime_data.set_text(std::string(result.begin(), result.end())); + return mime_data; + } + + return make_clipboard_error("Unimplemented MIME type!"); + } +#elif defined(TOOLBOX_PLATFORM_LINUX) + Result SystemClipboard::getContent(const std::string &type) { Display *dpy = XOpenDisplay(nullptr); if (!dpy) { return make_clipboard_error("Could not open X display"); } - Atom requested_type = XInternAtom(dpy, type.c_str(), False); - Atom sel = XInternAtom(dpy, "CLIPBOARD", False); + Atom requested_type = XInternAtom(dpy, type.c_str(), False); + Atom sel = XInternAtom(dpy, "CLIPBOARD", False); Window clipboard_owner = XGetSelectionOwner(dpy, sel); if (clipboard_owner == None) { return make_clipboard_error("Clipboard isn't owned by anyone"); } - Window root = RootWindow(dpy, DefaultScreen(dpy)); + Window root = RootWindow(dpy, DefaultScreen(dpy)); Window target_window = XCreateSimpleWindow(dpy, root, -10, -10, 1, 1, 0, 0, 0); Atom target_property = XInternAtom(dpy, "CLIP_CONTENTS", False); XConvertSelection(dpy, sel, requested_type, target_property, target_window, CurrentTime); @@ -156,12 +286,11 @@ namespace Toolbox { XSelectionEvent *sev; // This looks pretty dangerous but this is how glfw does it, // and how the examples online do it, so :shrug: - while(true){ + while (true) { XNextEvent(dpy, &ev); - switch (ev.type) - { + switch (ev.type) { case SelectionNotify: - sev = (XSelectionEvent*)&ev.xselection; + sev = (XSelectionEvent *)&ev.xselection; if (sev->property == None) { return make_clipboard_error("Conversion could not be performed."); } else { @@ -174,12 +303,14 @@ namespace Toolbox { Atom _da; XGetWindowProperty(dpy, target_window, target_property, 0, 0, False, - AnyPropertyType, &type_received, &_di, &_dul, &size, &prop_ret); + AnyPropertyType, &type_received, &_di, &_dul, &size, + &prop_ret); XFree(prop_ret); Atom incr = XInternAtom(dpy, "INCR", False); if (type_received == incr) { - return make_clipboard_error("Data over 256kb, this isn't supported yet"); + return make_clipboard_error( + "Data over 256kb, this isn't supported yet"); } XGetWindowProperty(dpy, target_window, target_property, 0, size, False, AnyPropertyType, &_da, &_di, &_dul, &_dul, &prop_ret); @@ -198,8 +329,119 @@ namespace Toolbox { } } } -#endif return {}; } +#endif + +#ifdef TOOLBOX_PLATFORM_WINDOWS + + UINT SystemClipboard::FormatForMime(std::string_view mimetype) { + if (mimetype == "text/plain") { + return CF_TEXT; + } + + if (mimetype == "image/bmp") { + return CF_BITMAP; + } + + if (mimetype == "image/x-wmf") { + return CF_METAFILEPICT; + } + + if (mimetype == "application/vnd.ms-excel") { + return CF_SYLK; + } + + if (mimetype == "image/tiff") { + return CF_TIFF; + } + + if (mimetype == "audio/riff") { + return CF_RIFF; + } + + if (mimetype == "audio/wav") { + return CF_WAVE; + } + + if (mimetype == "text/uri-list") { + return CF_HDROP; + } + + return CF_NULL; + } + + std::string SystemClipboard::MimeForFormat(UINT format) { + switch (format) { + case CF_TEXT: + return "text/plain"; + case CF_BITMAP: + return "image/bmp"; + case CF_METAFILEPICT: + return "image/x-wmf"; + case CF_SYLK: + return "application/vnd.ms-excel"; + case CF_DIF: + return "application/vnd.ms-excel"; + case CF_TIFF: + return "image/tiff"; + case CF_OEMTEXT: + return "text/plain"; + case CF_DIB: + return ""; + case CF_PALETTE: + return ""; + case CF_PENDATA: + return ""; + case CF_RIFF: + return "audio/riff"; + case CF_WAVE: + return "audio/wav"; + case CF_UNICODETEXT: + return "text/plain"; + case CF_ENHMETAFILE: + return ""; +#if (WINVER >= 0x0400) + case CF_HDROP: + return "text/uri-list"; + case CF_LOCALE: + return ""; +#endif /* WINVER >= 0x0400 */ +#if (WINVER >= 0x0500) + case CF_DIBV5: + return ""; +#endif /* WINVER >= 0x0500 */ + default: + return ""; + } + } +#elif defined(TOOLBOX_PLATFORM_LINUX) + static std::unordered_map s_uti_to_mime = { + {"public.utf8-plain-text", "text/plain" }, + {"public.utf16-plain-text", "text/plain" }, + {"public.text", "text/plain" }, + {"public.html", "text/html" }, + {"public.url", "text/uri-list" }, + {"public.file-url", "text/uri-list" }, + {"public.tiff", "application/x-qt-image"}, + {"public.vcard", "text/plain" }, + {"com.apple.traditional-mac-plain-text", "text/plain" }, + {"com.apple.pict", "application/x-qt-image"}, + }; + + static std::unordered_map s_mime_to_uti = { + {"text/plain", "public.text"}, + {"text/html", "public.html"}, + {"text/uri-list", "public.url" }, + {"application/x-qt-image", "public.tiff"}, + }; + + std::string MimeData::UTIForMime(std::string_view mimetype) { + return s_mime_to_uti[std::string(mimetype)]; + } + std::string MimeData::MimeForUTI(std::string_view uti) { + return s_uti_to_mime[std::string(uti)]; + } +#endif -} // namespace Toolbox::UI +} // namespace Toolbox diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 6c62415e..4bb00ff7 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -265,7 +265,7 @@ namespace Toolbox::UI { size_t last_pos = 0; size_t next_newline_pos = s.find('\n', 0); while (next_newline_pos != std::string::npos) { - if (s[last_pos + next_newline_pos - 1] == '\r') { + if (s[next_newline_pos - 1] == '\r') { result.push_back(s.substr(last_pos, next_newline_pos - 1)); } else { result.push_back(s.substr(last_pos, next_newline_pos)); @@ -392,10 +392,18 @@ namespace Toolbox::UI { } for (std::string_view src_path_str : splitLines(text.value())) { - if (src_path_str.substr(0, 7) != "file://") { + if (src_path_str.starts_with("file:/")) { + if (src_path_str.starts_with("file:///")) { + src_path_str = src_path_str.substr(8); + } else { + src_path_str = src_path_str.substr(7); + } + } else { TOOLBOX_ERROR_V("Can't copy non-local uri {}", src_path_str); + continue; } - fs_path src_path = src_path_str.substr(7); + + fs_path src_path = src_path_str; m_file_system_model->copy(src_path, m_view_index, src_path.filename().string()); } From ed5adb75453c83df881bfcbd8eefabba55065db6 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Thu, 3 Oct 2024 06:14:48 -0500 Subject: [PATCH 056/129] Fix lil' bugs --- src/gui/project/window.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 4bb00ff7..ddb4c1c2 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -273,6 +273,9 @@ namespace Toolbox::UI { last_pos = next_newline_pos + 1; next_newline_pos = s.find('\n', last_pos); } + if (last_pos < s.size()) { + result.push_back(s.substr(last_pos)); + } return result; } @@ -391,7 +394,8 @@ namespace Toolbox::UI { return; } - for (std::string_view src_path_str : splitLines(text.value())) { + std::vector urls = splitLines(text.value()); + for (std::string_view src_path_str : urls) { if (src_path_str.starts_with("file:/")) { if (src_path_str.starts_with("file:///")) { src_path_str = src_path_str.substr(8); From 7b9d93381ffabc50bc99dc1fda3c5eaf89d5d01a Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Thu, 3 Oct 2024 10:56:21 -0500 Subject: [PATCH 057/129] Allow for pasting of files on windows and some misc changes --- include/core/clipboard.hpp | 5 +- src/core/mimedata/mimedata.cpp | 3 +- src/gui/clipboard.cpp | 398 ++++++++++++++++++++------------- src/gui/project/window.cpp | 19 +- 4 files changed, 265 insertions(+), 160 deletions(-) diff --git a/include/core/clipboard.hpp b/include/core/clipboard.hpp index 6e495d94..ccf50fbd 100644 --- a/include/core/clipboard.hpp +++ b/include/core/clipboard.hpp @@ -36,10 +36,13 @@ namespace Toolbox { return s_clipboard; } + Result, ClipboardError> getAvailableContentFormats() const; + Result getText(); Result setText(const std::string &text); - Result, ClipboardError> possibleContentTypes(); + Result getContent(const std::string &type); + Result setContent(const std::string &type, const MimeData &mimedata); #ifdef TOOLBOX_PLATFORM_WINDOWS protected: diff --git a/src/core/mimedata/mimedata.cpp b/src/core/mimedata/mimedata.cpp index 939df19e..d26378d3 100644 --- a/src/core/mimedata/mimedata.cpp +++ b/src/core/mimedata/mimedata.cpp @@ -122,8 +122,9 @@ namespace Toolbox { void MimeData::set_urls(std::string_view data) { Buffer _tmp; - _tmp.alloc(data.size()); + _tmp.alloc(data.size() + 1); std::memcpy(_tmp.buf(), data.data(), data.size()); + _tmp.get(data.size()) = '\0'; set_data("text/uri-list", std::move(_tmp)); } diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index 17159302..0ba51beb 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -3,6 +3,7 @@ #ifdef TOOLBOX_PLATFORM_WINDOWS #include +#include #elif defined(TOOLBOX_PLATFORM_LINUX) #include #include @@ -14,6 +15,41 @@ namespace Toolbox { SystemClipboard::~SystemClipboard() {} #ifdef TOOLBOX_PLATFORM_WINDOWS + + Result, ClipboardError> + SystemClipboard::getAvailableContentFormats() const { + if (!OpenClipboard(nullptr)) { + return make_clipboard_error>("Failed to open the clipboard!"); + } + + std::vector types; + UINT format = 0; + while ((format = EnumClipboardFormats(format)) != CF_NULL) { + std::string the_format = ""; + + for (const auto &[mime, custom_fmt] : m_mime_to_format) { + if (format == custom_fmt) { + the_format = mime; + break; + } + } + + if (the_format.empty()) { + the_format = MimeForFormat(format); + } + + if (!the_format.empty()) { + types.push_back(the_format); + } + } + + if (!CloseClipboard()) { + return make_clipboard_error>("Failed to close the clipboard!"); + } + + return types; + } + Result SystemClipboard::getText() { if (!OpenClipboard(nullptr)) { return make_clipboard_error("Failed to open the clipboard!"); @@ -42,13 +78,7 @@ namespace Toolbox { return result; } -#elif defined(TOOLBOX_PLATFORM_LINUX) - Result SystemClipboard::getText() { - return make_clipboard_error("Not implemented yet"); - } -#endif -#ifdef TOOLBOX_PLATFORM_WINDOWS Result SystemClipboard::setText(const std::string &text) { if (!OpenClipboard(nullptr)) { return make_clipboard_error("Failed to open the clipboard!"); @@ -81,98 +111,7 @@ namespace Toolbox { } return {}; } -#elif defined(TOOLBOX_PLATFORM_LINUX) - Result SystemClipboard::setText(const std::string &text) { - return make_clipboard_error("Not implemented yet"); - } -#endif - -#ifdef TOOLBOX_PLATFORM_WINDOWS - Result, ClipboardError> SystemClipboard::possibleContentTypes() { - if (!OpenClipboard(nullptr)) { - return make_clipboard_error>("Failed to open the clipboard!"); - } - - std::vector types; - UINT format = 0; - while ((format = EnumClipboardFormats(format)) != CF_NULL) { - std::string the_format = ""; - - for (const auto &[mime, custom_fmt] : m_mime_to_format) { - if (format == custom_fmt) { - the_format = mime; - break; - } - } - - if (the_format.empty()) { - the_format = MimeForFormat(format); - } - - types.push_back(the_format); - } - - if (!CloseClipboard()) { - return make_clipboard_error>("Failed to close the clipboard!"); - } - - return types; - } -#elif defined(TOOLBOX_PLATFORM_LINUX) - Result, ClipboardError> SystemClipboard::possibleContentTypes() { - Display *dpy = XOpenDisplay(nullptr); - if (!dpy) { - return make_clipboard_error>("Could not open X display"); - } - Atom sel = XInternAtom(dpy, "CLIPBOARD", False); - Atom targets = XInternAtom(dpy, "TARGETS", False); - Atom target_property = XInternAtom(dpy, "CLIP_TYPES", False); - Window root_window = RootWindow(dpy, DefaultScreen(dpy)); - Window target_window = XCreateSimpleWindow(dpy, root_window, -10, -10, 1, 1, 0, 0, 0); - XConvertSelection(dpy, sel, targets, target_property, target_window, CurrentTime); - - XEvent ev; - XSelectionEvent *sev; - // This looks pretty dangerous but this is how glfw does it, - // and how the examples online do it, so :shrug: - while (true) { - XNextEvent(dpy, &ev); - switch (ev.type) { - case SelectionNotify: - sev = (XSelectionEvent *)&ev.xselection; - if (sev->property == None) { - return make_clipboard_error>( - "Conversion could not be performed.\n"); - } else { - std::vector types; - unsigned long nitems; - unsigned char *prop_ret = nullptr; - // We won't use these. - Atom _type; - int _di; - unsigned long _dul; - XGetWindowProperty(dpy, target_window, target_property, 0, 1024 * sizeof(Atom), - False, XA_ATOM, &_type, &_di, &nitems, &_dul, &prop_ret); - - Atom *targets = (Atom *)prop_ret; - for (int i = 0; i < nitems; ++i) { - char *an = XGetAtomName(dpy, targets[i]); - types.push_back(std::string(an)); - if (an) - XFree(an); - } - XFree(prop_ret); - XDeleteProperty(dpy, target_window, target_property); - return types; - } - break; - } - } - return {}; - } -#endif -#ifdef TOOLBOX_PLATFORM_WINDOWS Result SystemClipboard::getContent(const std::string &type) { if (!OpenClipboard(nullptr)) { return make_clipboard_error("Failed to open the clipboard!"); @@ -266,74 +205,94 @@ namespace Toolbox { return make_clipboard_error("Unimplemented MIME type!"); } -#elif defined(TOOLBOX_PLATFORM_LINUX) - Result SystemClipboard::getContent(const std::string &type) { - Display *dpy = XOpenDisplay(nullptr); - if (!dpy) { - return make_clipboard_error("Could not open X display"); + + Result SystemClipboard::setContent(const std::string &type, + const MimeData &mimedata) { + if (!OpenClipboard(nullptr)) { + return make_clipboard_error("Failed to open the clipboard!"); } - Atom requested_type = XInternAtom(dpy, type.c_str(), False); - Atom sel = XInternAtom(dpy, "CLIPBOARD", False); - Window clipboard_owner = XGetSelectionOwner(dpy, sel); - if (clipboard_owner == None) { - return make_clipboard_error("Clipboard isn't owned by anyone"); + + if (!EmptyClipboard()) { + return make_clipboard_error("Failed to clear the clipboard!"); } - Window root = RootWindow(dpy, DefaultScreen(dpy)); - Window target_window = XCreateSimpleWindow(dpy, root, -10, -10, 1, 1, 0, 0, 0); - Atom target_property = XInternAtom(dpy, "CLIP_CONTENTS", False); - XConvertSelection(dpy, sel, requested_type, target_property, target_window, CurrentTime); - XEvent ev; - XSelectionEvent *sev; - // This looks pretty dangerous but this is how glfw does it, - // and how the examples online do it, so :shrug: - while (true) { - XNextEvent(dpy, &ev); - switch (ev.type) { - case SelectionNotify: - sev = (XSelectionEvent *)&ev.xselection; - if (sev->property == None) { - return make_clipboard_error("Conversion could not be performed."); - } else { - Atom type_received; - unsigned long size; - unsigned char *prop_ret = nullptr; - // These are unused - int _di; - unsigned long _dul; - Atom _da; - XGetWindowProperty(dpy, target_window, target_property, 0, 0, False, - AnyPropertyType, &type_received, &_di, &_dul, &size, - &prop_ret); - XFree(prop_ret); + std::optional result = mimedata.get_data(type); + if (!result) { + return make_clipboard_error( + std::format("Failed to find MIME data type \"{}\"", type)); + } - Atom incr = XInternAtom(dpy, "INCR", False); - if (type_received == incr) { - return make_clipboard_error( - "Data over 256kb, this isn't supported yet"); - } - XGetWindowProperty(dpy, target_window, target_property, 0, size, False, - AnyPropertyType, &_da, &_di, &_dul, &_dul, &prop_ret); - Buffer data_buffer; - if (!data_buffer.alloc(size)) { - return make_clipboard_error( - "Couldn't allocate buffer of big enough size"); - } - std::memcpy(data_buffer.buf(), prop_ret, size); - XFree(prop_ret); - XDeleteProperty(dpy, target_window, target_property); + Buffer data_buf = std::move(result.value()); - MimeData result; - result.set_data(type, std::move(data_buffer)); - return result; + UINT format = CF_NULL; + if (m_mime_to_format.find(type) == m_mime_to_format.end()) { + format = FormatForMime(type); + if (format == CF_NULL) { + m_mime_to_format[type] = RegisterClipboardFormat(type.c_str()); + format = m_mime_to_format[type]; + } + } else { + format = m_mime_to_format[type]; + } + + if (format == CF_NULL) { + return make_clipboard_error("Failed to register the clipboard format!"); + } + + size_t dest_buf_size = data_buf.size(); + if (format == CF_HDROP) { + dest_buf_size *= 2; + dest_buf_size += sizeof(DROPFILES); + } else if (format == CF_TEXT) { + dest_buf_size *= 2; + } + + HANDLE data_handle = GlobalAlloc(GMEM_DDESHARE | GMEM_ZEROINIT, dest_buf_size); + if (!data_handle) { + return make_clipboard_error("Failed to alloc new data handle!"); + } + + void *data_buffer = static_cast(GlobalLock(data_handle)); + if (!data_buffer) { + return make_clipboard_error("Failed to retrieve the buffer from the handle!"); + } + + if (format == CF_HDROP) { + DROPFILES *drop_files_buf = static_cast(data_buffer); + drop_files_buf->fWide = TRUE; + drop_files_buf->pFiles = sizeof(DROPFILES); + + wchar_t *path_list_ptr = (wchar_t *)((char *)data_buffer + sizeof(DROPFILES)); + std::mbstowcs(path_list_ptr, data_buf.buf(), data_buf.size()); + + for (size_t i = 0; i < data_buf.size(); ++i) { + wchar_t &wchr = path_list_ptr[i]; + if (wchr == L'\n') { + wchr = L'\0'; } } + + path_list_ptr[data_buf.size()] = L'\0'; + } else if (format == CF_TEXT) { + wchar_t *path_list_ptr = (wchar_t *)data_buffer; + std::mbstowcs(path_list_ptr, data_buf.buf(), data_buf.size()); + path_list_ptr[data_buf.size()] = L'\0'; + } else { + std::memcpy(data_buffer, data_buf.buf(), data_buf.size()); } - return {}; - } -#endif -#ifdef TOOLBOX_PLATFORM_WINDOWS + if (!GlobalUnlock(data_handle)) { + return make_clipboard_error("Failed to unlock the data handle!"); + } + + SetClipboardData(format, data_handle); + + if (!CloseClipboard()) { + return make_clipboard_error("Failed to close the clipboard!"); + } + + return Result(); + } UINT SystemClipboard::FormatForMime(std::string_view mimetype) { if (mimetype == "text/plain") { @@ -415,7 +374,134 @@ namespace Toolbox { return ""; } } + #elif defined(TOOLBOX_PLATFORM_LINUX) + Result, ClipboardError> + SystemClipboard::getAvailableContentFormats() const { + Display *dpy = XOpenDisplay(nullptr); + if (!dpy) { + return make_clipboard_error>("Could not open X display"); + } + Atom sel = XInternAtom(dpy, "CLIPBOARD", False); + Atom targets = XInternAtom(dpy, "TARGETS", False); + Atom target_property = XInternAtom(dpy, "CLIP_TYPES", False); + Window root_window = RootWindow(dpy, DefaultScreen(dpy)); + Window target_window = XCreateSimpleWindow(dpy, root_window, -10, -10, 1, 1, 0, 0, 0); + XConvertSelection(dpy, sel, targets, target_property, target_window, CurrentTime); + + XEvent ev; + XSelectionEvent *sev; + // This looks pretty dangerous but this is how glfw does it, + // and how the examples online do it, so :shrug: + while (true) { + XNextEvent(dpy, &ev); + switch (ev.type) { + case SelectionNotify: + sev = (XSelectionEvent *)&ev.xselection; + if (sev->property == None) { + return make_clipboard_error>( + "Conversion could not be performed.\n"); + } else { + std::vector types; + unsigned long nitems; + unsigned char *prop_ret = nullptr; + // We won't use these. + Atom _type; + int _di; + unsigned long _dul; + XGetWindowProperty(dpy, target_window, target_property, 0, 1024 * sizeof(Atom), + False, XA_ATOM, &_type, &_di, &nitems, &_dul, &prop_ret); + + Atom *targets = (Atom *)prop_ret; + for (int i = 0; i < nitems; ++i) { + char *an = XGetAtomName(dpy, targets[i]); + types.push_back(std::string(an)); + if (an) + XFree(an); + } + XFree(prop_ret); + XDeleteProperty(dpy, target_window, target_property); + return types; + } + break; + } + } + return {}; + } + + Result SystemClipboard::getText() { + return make_clipboard_error("Not implemented yet"); + } + + Result SystemClipboard::setText(const std::string &text) { + return make_clipboard_error("Not implemented yet"); + } + + Result SystemClipboard::getContent(const std::string &type) { + Display *dpy = XOpenDisplay(nullptr); + if (!dpy) { + return make_clipboard_error("Could not open X display"); + } + Atom requested_type = XInternAtom(dpy, type.c_str(), False); + Atom sel = XInternAtom(dpy, "CLIPBOARD", False); + Window clipboard_owner = XGetSelectionOwner(dpy, sel); + if (clipboard_owner == None) { + return make_clipboard_error("Clipboard isn't owned by anyone"); + } + Window root = RootWindow(dpy, DefaultScreen(dpy)); + Window target_window = XCreateSimpleWindow(dpy, root, -10, -10, 1, 1, 0, 0, 0); + Atom target_property = XInternAtom(dpy, "CLIP_CONTENTS", False); + XConvertSelection(dpy, sel, requested_type, target_property, target_window, CurrentTime); + XEvent ev; + XSelectionEvent *sev; + // This looks pretty dangerous but this is how glfw does it, + // and how the examples online do it, so :shrug: + while (true) { + XNextEvent(dpy, &ev); + switch (ev.type) { + case SelectionNotify: + sev = (XSelectionEvent *)&ev.xselection; + if (sev->property == None) { + return make_clipboard_error("Conversion could not be performed."); + } else { + Atom type_received; + unsigned long size; + unsigned char *prop_ret = nullptr; + // These are unused + int _di; + unsigned long _dul; + Atom _da; + + XGetWindowProperty(dpy, target_window, target_property, 0, 0, False, + AnyPropertyType, &type_received, &_di, &_dul, &size, + &prop_ret); + XFree(prop_ret); + + Atom incr = XInternAtom(dpy, "INCR", False); + if (type_received == incr) { + return make_clipboard_error( + "Data over 256kb, this isn't supported yet"); + } + XGetWindowProperty(dpy, target_window, target_property, 0, size, False, + AnyPropertyType, &_da, &_di, &_dul, &_dul, &prop_ret); + Buffer data_buffer; + if (!data_buffer.alloc(size)) { + return make_clipboard_error( + "Couldn't allocate buffer of big enough size"); + } + std::memcpy(data_buffer.buf(), prop_ret, size); + XFree(prop_ret); + XDeleteProperty(dpy, target_window, target_property); + + MimeData result; + result.set_data(type, std::move(data_buffer)); + return result; + } + } + } + return {}; + } + static std::unordered_map s_uti_to_mime = { {"public.utf8-plain-text", "text/plain" }, {"public.utf16-plain-text", "text/plain" }, diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index ddb4c1c2..7747f035 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -353,7 +353,22 @@ namespace Toolbox::UI { m_folder_view_context_menu.addOption( "Copy", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_C}), - [this]() { return m_selected_indices_ctx.size() > 0; }, [this](auto) {}); + [this]() { return m_selected_indices_ctx.size() > 0; }, + [this](auto) { + std::string copied_paths; + for (const ModelIndex &index : m_selected_indices_ctx) { + copied_paths += m_file_system_model->getPath(index).string(); + copied_paths += "\n"; + } + + MimeData data; + data.set_urls(copied_paths); + + auto result = SystemClipboard::instance().setContent("text/uri-list", data); + if (!result) { + TOOLBOX_ERROR("[PROJECT] Failed to set contents of clipboard"); + } + }); m_folder_view_context_menu.addDivider(); @@ -376,7 +391,7 @@ namespace Toolbox::UI { "Paste", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_V}), [this]() { return m_selected_indices_ctx.size() == 0; }, [this](auto) { - auto content_types = SystemClipboard::instance().possibleContentTypes(); + auto content_types = SystemClipboard::instance().getAvailableContentFormats(); if (!content_types) { TOOLBOX_ERROR("Couldn't get content types"); return; From ddfdb95c999a6330e302f9478243721bdd729777 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Thu, 3 Oct 2024 10:42:51 -0700 Subject: [PATCH 058/129] Crappy implementation of pasting out that blocks the main thread indefinitely --- include/core/clipboard.hpp | 1 + src/gui/clipboard.cpp | 100 +++++++++++++++++++++++++++++++++++++ src/gui/project/window.cpp | 15 +++++- 3 files changed, 115 insertions(+), 1 deletion(-) diff --git a/include/core/clipboard.hpp b/include/core/clipboard.hpp index 15cf5eb8..03cd91b7 100644 --- a/include/core/clipboard.hpp +++ b/include/core/clipboard.hpp @@ -40,6 +40,7 @@ namespace Toolbox { Result setText(const std::string &text); Result, ClipboardError> possibleContentTypes(); Result getContent(const std::string &type); + Result setContent(const MimeData &content); }; class DataClipboard { diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index 65bdc1b3..03eb64d3 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -198,6 +198,106 @@ namespace Toolbox { } } } + Result SystemClipboard::setContent(const MimeData &content) { +#ifdef TOOLBOX_PLATFORM_LINUX + Display *dpy = XOpenDisplay(nullptr); + Atom TIMESTAMP = XInternAtom(dpy, "TIMESTAMP", False); + Atom TARGETS = XInternAtom(dpy, "TARGETS", False); + Atom CLIPBOARD = XInternAtom(dpy, "CLIPBOARD", False); + Atom TEXT_URI = XInternAtom(dpy, "text/uri-list", False); + Atom APP_KDE4_URILIST = XInternAtom(dpy, "application/x-kde4-urilist", False); + Atom APP_VND = XInternAtom(dpy, "application/vnd.portal.filetransfer", False); + Atom MULT = XInternAtom(dpy, "MULTIPLE", False); + Atom UTF8 = XInternAtom(dpy, "UTF8_STRING", False); + Atom APP_SRCID = XInternAtom(dpy, "application/x-kde-source-id", False); + Window root = RootWindow(dpy, DefaultScreen(dpy)); + Window target_window = XCreateSimpleWindow(dpy, root, -10, -10, 1, 1, 0, 0, 0); + + XSetSelectionOwner(dpy, CLIPBOARD, target_window, CurrentTime); + + while (true) { + XEvent event; + std::cout << "Waiting on X event... " << std::endl; + XNextEvent(dpy, &event); + switch (event.type) { + case SelectionClear: + std::cout << "Lost selection ownership" << std::endl; + return {}; + case SelectionRequest: { + XSelectionRequestEvent *request = &event.xselectionrequest; + std::cout << "Requestor: " << request->requestor << std::endl; + char *target_type = XGetAtomName(dpy, request->target); + std::cout << "Target Type: " << target_type << std::endl; + char *target_property = XGetAtomName(dpy, request->property); + std::cout << "Target Property: " << target_property << std::endl; + // const Atom targets[] = {TARGETS, MULT, UTF8, XA_STRING}; + // const Atom targets[] = {TIMESTAMP, TARGETS, TEXT_URI, + // APP_KDE4_URILIST, APP_VND, APP_SRCID}; + const Atom targets[] = {TARGETS, TEXT_URI}; + if (request->target == TARGETS) { + std::cout << "Responding with targets:" << std::endl; + for (const Atom &targ : targets) { + char *target = XGetAtomName(dpy, targ); + std::cout << target << std::endl; + if (target) + XFree(target); + } + XChangeProperty(dpy, request->requestor, request->property, XA_ATOM, 32, + PropModeReplace, + reinterpret_cast(targets), + sizeof(targets) / sizeof(targets[0])); + XSelectionEvent response; + response.type = SelectionNotify; + response.requestor = request->requestor; + response.selection = request->selection; + response.target = request->target; + response.property = request->property; + response.time = request->time; + + XSendEvent(dpy, request->requestor, True, NoEventMask, + reinterpret_cast(&response)); + continue; + } else if (request->target == TEXT_URI) { + std::string urls = content.get_urls().value(); + std::cout << "Responding with urls: " << urls << std::endl; + XChangeProperty( + dpy, request->requestor, request->property, TEXT_URI, 8, PropModeReplace, + reinterpret_cast(urls.c_str()), urls.length()); + + XSelectionEvent response; + response.type = SelectionNotify; + response.requestor = request->requestor; + response.selection = request->selection; + response.target = request->target; + response.property = request->property; + response.time = request->time; + + XSendEvent(dpy, request->requestor, True, NoEventMask, + reinterpret_cast(&response)); + // return {}; + } else if (request->target == UTF8) { + std::string test_string = "something"; + XChangeProperty( + dpy, request->requestor, request->property, UTF8, 8, PropModeReplace, + reinterpret_cast(test_string.c_str()), test_string.length()); + + XSelectionEvent response; + response.type = SelectionNotify; + response.requestor = request->requestor; + response.selection = request->selection; + response.target = request->target; + response.property = request->property; + response.time = request->time; + + XSendEvent(dpy, request->requestor, True, NoEventMask, + reinterpret_cast(&response)); + } else { + TOOLBOX_ERROR("Unrecognized request"); + return {}; + } + } + } + } #endif return {}; } diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 90955f5f..2ea6d3c9 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -348,7 +348,20 @@ namespace Toolbox::UI { m_folder_view_context_menu.addOption( "Copy", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_C}), - [this]() { return m_selected_indices_ctx.size() > 0; }, [this](auto) {}); + [this]() { return m_selected_indices_ctx.size() > 0; }, [this](auto) { + std::string paths; + if (m_selected_indices_ctx.size() == 0) { + paths = m_file_system_model->getPath(m_view_index).string(); + } else { + for (const ModelIndex &item_index : m_selected_indices_ctx) { + fs_path path = m_file_system_model->getPath(item_index); + paths += "file://" + path.string() + "\r\n"; + } + } + MimeData data; + data.set_urls(paths); + SystemClipboard::instance().setContent(data); + }); m_folder_view_context_menu.addDivider(); From 31b250668f4157841a4afb91b49a5924a428a781 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Thu, 3 Oct 2024 10:45:24 -0700 Subject: [PATCH 059/129] Some clang format stuff on my code --- src/gui/clipboard.cpp | 66 ++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index 03eb64d3..51333a8c 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -78,36 +78,29 @@ namespace Toolbox { return {}; } - Result, ClipboardError> SystemClipboard::possibleContentTypes(){ + Result, ClipboardError> SystemClipboard::possibleContentTypes() { #ifdef TOOLBOX_PLATFORM_LINUX - Display *dpy = XOpenDisplay(nullptr); - if (!dpy) { - return make_clipboard_error>("Could not open X display"); - } - Atom sel = XInternAtom(dpy, "CLIPBOARD", False); - Atom targets = XInternAtom(dpy, "TARGETS", False); + Display *dpy = XOpenDisplay(nullptr); + Atom sel = XInternAtom(dpy, "CLIPBOARD", False); + Atom targets = XInternAtom(dpy, "TARGETS", False); Atom target_property = XInternAtom(dpy, "CLIP_TYPES", False); - Window root_window = RootWindow(dpy, DefaultScreen(dpy)); + Window root_window = RootWindow(dpy, DefaultScreen(dpy)); Window target_window = XCreateSimpleWindow(dpy, root_window, -10, -10, 1, 1, 0, 0, 0); - XConvertSelection(dpy, sel, targets, target_property, target_window, - CurrentTime); + XConvertSelection(dpy, sel, targets, target_property, target_window, CurrentTime); XEvent ev; XSelectionEvent *sev; // This looks pretty dangerous but this is how glfw does it, // and how the examples online do it, so :shrug: - while(true){ + while (true) { XNextEvent(dpy, &ev); - switch (ev.type) - { + switch (ev.type) { case SelectionNotify: - sev = (XSelectionEvent*)&ev.xselection; - if (sev->property == None) - { - return make_clipboard_error>("Conversion could not be performed.\n"); - } - else - { + sev = (XSelectionEvent *)&ev.xselection; + if (sev->property == None) { + return make_clipboard_error>( + "Conversion could not be performed.\n"); + } else { std::vector types; unsigned long nitems; unsigned char *prop_ret = nullptr; @@ -115,13 +108,12 @@ namespace Toolbox { Atom _type; int _di; unsigned long _dul; - XGetWindowProperty(dpy, target_window, target_property, 0, - 1024 * sizeof(Atom), False, XA_ATOM, - &_type, &_di, &nitems, &_dul, &prop_ret); + XGetWindowProperty(dpy, target_window, target_property, 0, 1024 * sizeof(Atom), + False, XA_ATOM, &_type, &_di, &nitems, &_dul, &prop_ret); - Atom *targets = (Atom*)prop_ret; - for(int i = 0; i < nitems; ++i) { - char* an = XGetAtomName(dpy, targets[i]); + Atom *targets = (Atom *)prop_ret; + for (int i = 0; i < nitems; ++i) { + char *an = XGetAtomName(dpy, targets[i]); types.push_back(std::string(an)); if (an) XFree(an); @@ -136,19 +128,19 @@ namespace Toolbox { #endif return {}; } - Result SystemClipboard::getContent(const std::string &type){ + Result SystemClipboard::getContent(const std::string &type) { #ifdef TOOLBOX_PLATFORM_LINUX Display *dpy = XOpenDisplay(nullptr); if (!dpy) { return make_clipboard_error("Could not open X display"); } - Atom requested_type = XInternAtom(dpy, type.c_str(), False); - Atom sel = XInternAtom(dpy, "CLIPBOARD", False); + Atom requested_type = XInternAtom(dpy, type.c_str(), False); + Atom sel = XInternAtom(dpy, "CLIPBOARD", False); Window clipboard_owner = XGetSelectionOwner(dpy, sel); if (clipboard_owner == None) { return make_clipboard_error("Clipboard isn't owned by anyone"); } - Window root = RootWindow(dpy, DefaultScreen(dpy)); + Window root = RootWindow(dpy, DefaultScreen(dpy)); Window target_window = XCreateSimpleWindow(dpy, root, -10, -10, 1, 1, 0, 0, 0); Atom target_property = XInternAtom(dpy, "CLIP_CONTENTS", False); XConvertSelection(dpy, sel, requested_type, target_property, target_window, CurrentTime); @@ -156,12 +148,11 @@ namespace Toolbox { XSelectionEvent *sev; // This looks pretty dangerous but this is how glfw does it, // and how the examples online do it, so :shrug: - while(true){ + while (true) { XNextEvent(dpy, &ev); - switch (ev.type) - { + switch (ev.type) { case SelectionNotify: - sev = (XSelectionEvent*)&ev.xselection; + sev = (XSelectionEvent *)&ev.xselection; if (sev->property == None) { return make_clipboard_error("Conversion could not be performed."); } else { @@ -174,12 +165,14 @@ namespace Toolbox { Atom _da; XGetWindowProperty(dpy, target_window, target_property, 0, 0, False, - AnyPropertyType, &type_received, &_di, &_dul, &size, &prop_ret); + AnyPropertyType, &type_received, &_di, &_dul, &size, + &prop_ret); XFree(prop_ret); Atom incr = XInternAtom(dpy, "INCR", False); if (type_received == incr) { - return make_clipboard_error("Data over 256kb, this isn't supported yet"); + return make_clipboard_error( + "Data over 256kb, this isn't supported yet"); } XGetWindowProperty(dpy, target_window, target_property, 0, size, False, AnyPropertyType, &_da, &_di, &_dul, &_dul, &prop_ret); @@ -198,6 +191,7 @@ namespace Toolbox { } } } +#endif Result SystemClipboard::setContent(const MimeData &content) { #ifdef TOOLBOX_PLATFORM_LINUX Display *dpy = XOpenDisplay(nullptr); From c6a544b7c4cf157499f10b0a38d9638ef7ea08c5 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Thu, 3 Oct 2024 10:46:01 -0700 Subject: [PATCH 060/129] Clean up resources properly --- src/gui/clipboard.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index 51333a8c..f54226a1 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -98,6 +98,8 @@ namespace Toolbox { case SelectionNotify: sev = (XSelectionEvent *)&ev.xselection; if (sev->property == None) { + XDestroyWindow(dpy, target_window); + XCloseDisplay(dpy); return make_clipboard_error>( "Conversion could not be performed.\n"); } else { @@ -120,11 +122,14 @@ namespace Toolbox { } XFree(prop_ret); XDeleteProperty(dpy, target_window, target_property); + XDestroyWindow(dpy, target_window); + XCloseDisplay(dpy); return types; } break; } } + XCloseDisplay(dpy); #endif return {}; } @@ -154,6 +159,7 @@ namespace Toolbox { case SelectionNotify: sev = (XSelectionEvent *)&ev.xselection; if (sev->property == None) { + XCloseDisplay(dpy); return make_clipboard_error("Conversion could not be performed."); } else { Atom type_received; @@ -178,6 +184,7 @@ namespace Toolbox { AnyPropertyType, &_da, &_di, &_dul, &_dul, &prop_ret); Buffer data_buffer; if (!data_buffer.alloc(size)) { + XCloseDisplay(dpy); return make_clipboard_error( "Couldn't allocate buffer of big enough size"); } @@ -187,11 +194,16 @@ namespace Toolbox { MimeData result; result.set_data(type, std::move(data_buffer)); + XCloseDisplay(dpy); return result; } } } + XCloseDisplay(dpy); #endif + return {}; + } + Result SystemClipboard::setContent(const MimeData &content) { #ifdef TOOLBOX_PLATFORM_LINUX Display *dpy = XOpenDisplay(nullptr); @@ -292,6 +304,8 @@ namespace Toolbox { } } } + XDestroyWindow(dpy, target_window); + XCloseDisplay(dpy); #endif return {}; } From e3615d091e41dca9c4e9d690b396808cee3ed223 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Thu, 3 Oct 2024 13:07:41 -0700 Subject: [PATCH 061/129] Pasting without blocking using glfw hooks But it's suuuuper hacky right now, needs cleanup --- include/core/clipboard.hpp | 4 +++ lib/glfw | 2 +- src/gui/application.cpp | 1 + src/gui/clipboard.cpp | 74 +++++++++++++++++++++++++++++++++++++- 4 files changed, 79 insertions(+), 2 deletions(-) diff --git a/include/core/clipboard.hpp b/include/core/clipboard.hpp index 03cd91b7..b401a593 100644 --- a/include/core/clipboard.hpp +++ b/include/core/clipboard.hpp @@ -41,7 +41,11 @@ namespace Toolbox { Result, ClipboardError> possibleContentTypes(); Result getContent(const std::string &type); Result setContent(const MimeData &content); +#ifdef TOOLBOX_PLATFORM_LINUX + MimeData m_clipboard_contents; +#endif }; + void hookClipboardIntoGLFW(void) ; class DataClipboard { public: diff --git a/lib/glfw b/lib/glfw index 8e6c8d7e..70d10e61 160000 --- a/lib/glfw +++ b/lib/glfw @@ -1 +1 @@ -Subproject commit 8e6c8d7effc54f8aecd30eda17069588298f4ada +Subproject commit 70d10e617a664237c14c6b8fd9993aa391522dd8 diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 621de2be..61b0537d 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -194,6 +194,7 @@ namespace Toolbox { createWindow("Application Log"); determineEnvironmentConflicts(); + hookClipboardIntoGLFW(); } void GUIApplication::onUpdate(TimeStep delta_time) { diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index f54226a1..215e1429 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -3,8 +3,13 @@ #ifdef WIN32 #include #elif defined(TOOLBOX_PLATFORM_LINUX) -#include +#include #include +#include +#define GLFW_EXPOSE_NATIVE_X11 +#include +#include + #endif namespace Toolbox { @@ -78,6 +83,67 @@ namespace Toolbox { return {}; } +#ifdef TOOLBOX_PLATFORM_LINUX + void (*glfwSelectionRequestHandler)(XEvent *); + void handleSelectionRequest(XEvent *event) { + std::cout << "Handling a selection request from hook" << std::endl; + const XSelectionRequestEvent* request = &event->xselectionrequest; + Display* dpy = getGLFWDisplay(); + Atom TEXT_URI = XInternAtom(dpy, "text/uri-list", False); + Atom TARGETS = XInternAtom(dpy, "TARGETS", False); + const Atom targets[] = {TARGETS, TEXT_URI}; + if (request->target == TARGETS) { + std::cout << "Responding with targets:" << std::endl; + for (const Atom &targ : targets) { + char *target = XGetAtomName(dpy, targ); + std::cout << target << std::endl; + if (target) + XFree(target); + } + XChangeProperty(dpy, request->requestor, request->property, XA_ATOM, 32, + PropModeReplace, + reinterpret_cast(targets), + sizeof(targets) / sizeof(targets[0])); + XSelectionEvent response; + response.type = SelectionNotify; + response.requestor = request->requestor; + response.selection = request->selection; + response.target = request->target; + response.property = request->property; + response.time = request->time; + + XSendEvent(dpy, request->requestor, True, NoEventMask, + reinterpret_cast(&response)); + } else if (request->target == TEXT_URI) { + std::string urls = SystemClipboard::instance().m_clipboard_contents.get_urls().value(); + std::cout << "Responding with urls: " << urls << std::endl; + XChangeProperty( + dpy, request->requestor, request->property, TEXT_URI, 8, PropModeReplace, + reinterpret_cast(urls.c_str()), urls.length()); + + XSelectionEvent response; + response.type = SelectionNotify; + response.requestor = request->requestor; + response.selection = request->selection; + response.target = request->target; + response.property = request->property; + response.time = request->time; + + XSendEvent(dpy, request->requestor, True, NoEventMask, + reinterpret_cast(&response)); + } else { + glfwSelectionRequestHandler(event); + } + } + void hookClipboardIntoGLFW(void) { + std::cout << "Setting handlers" << std::endl; + glfwSelectionRequestHandler = getSelectionRequestHandler(); + setSelectionRequestHandler(handleSelectionRequest); + } +#else + void hookClipboardIntoGLFW(void) {} +#endif + Result, ClipboardError> SystemClipboard::possibleContentTypes() { #ifdef TOOLBOX_PLATFORM_LINUX Display *dpy = XOpenDisplay(nullptr); @@ -220,6 +286,12 @@ namespace Toolbox { Window target_window = XCreateSimpleWindow(dpy, root, -10, -10, 1, 1, 0, 0, 0); XSetSelectionOwner(dpy, CLIPBOARD, target_window, CurrentTime); + Atom CLIPBOARD = XInternAtom(clipboard_display, "CLIPBOARD", False); + m_clipboard_contents = content; + std::cout << "Setting ourselves as clipboard owners" << std::endl; + XSetSelectionOwner(clipboard_display, CLIPBOARD, clipboard_helper_window, CurrentTime); + ImGui::SetClipboardText(""); + return {}; while (true) { XEvent event; From f85749fe527f6a73c7a1d91ef88ae4e16fe49d0e Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Thu, 3 Oct 2024 13:14:00 -0700 Subject: [PATCH 062/129] Use glfw display but fresh window for copying in too --- src/gui/clipboard.cpp | 150 ++++++------------------------------------ 1 file changed, 20 insertions(+), 130 deletions(-) diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index 215e1429..b34d2faf 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -14,8 +14,20 @@ namespace Toolbox { +#ifdef WIN32 SystemClipboard::SystemClipboard() {} SystemClipboard::~SystemClipboard() {} +#elif defined(TOOLBOX_PLATFORM_LINUX) + Window clipboard_helper_window; + SystemClipboard::SystemClipboard() { + Display* dpy = getGLFWDisplay(); + Window root_window = RootWindow(dpy, DefaultScreen(dpy)); + clipboard_helper_window = XCreateSimpleWindow(dpy, root_window, -10, -10, 1, 1, 0, 0, 0); + } + SystemClipboard::~SystemClipboard() { + XDestroyWindow(getGLFWDisplay(), clipboard_helper_window); + } +#endif Result SystemClipboard::getText() { #ifdef WIN32 @@ -86,20 +98,12 @@ namespace Toolbox { #ifdef TOOLBOX_PLATFORM_LINUX void (*glfwSelectionRequestHandler)(XEvent *); void handleSelectionRequest(XEvent *event) { - std::cout << "Handling a selection request from hook" << std::endl; const XSelectionRequestEvent* request = &event->xselectionrequest; Display* dpy = getGLFWDisplay(); Atom TEXT_URI = XInternAtom(dpy, "text/uri-list", False); Atom TARGETS = XInternAtom(dpy, "TARGETS", False); const Atom targets[] = {TARGETS, TEXT_URI}; if (request->target == TARGETS) { - std::cout << "Responding with targets:" << std::endl; - for (const Atom &targ : targets) { - char *target = XGetAtomName(dpy, targ); - std::cout << target << std::endl; - if (target) - XFree(target); - } XChangeProperty(dpy, request->requestor, request->property, XA_ATOM, 32, PropModeReplace, reinterpret_cast(targets), @@ -116,7 +120,6 @@ namespace Toolbox { reinterpret_cast(&response)); } else if (request->target == TEXT_URI) { std::string urls = SystemClipboard::instance().m_clipboard_contents.get_urls().value(); - std::cout << "Responding with urls: " << urls << std::endl; XChangeProperty( dpy, request->requestor, request->property, TEXT_URI, 8, PropModeReplace, reinterpret_cast(urls.c_str()), urls.length()); @@ -136,7 +139,6 @@ namespace Toolbox { } } void hookClipboardIntoGLFW(void) { - std::cout << "Setting handlers" << std::endl; glfwSelectionRequestHandler = getSelectionRequestHandler(); setSelectionRequestHandler(handleSelectionRequest); } @@ -146,12 +148,11 @@ namespace Toolbox { Result, ClipboardError> SystemClipboard::possibleContentTypes() { #ifdef TOOLBOX_PLATFORM_LINUX - Display *dpy = XOpenDisplay(nullptr); + Display *dpy = getGLFWDisplay(); Atom sel = XInternAtom(dpy, "CLIPBOARD", False); Atom targets = XInternAtom(dpy, "TARGETS", False); Atom target_property = XInternAtom(dpy, "CLIP_TYPES", False); - Window root_window = RootWindow(dpy, DefaultScreen(dpy)); - Window target_window = XCreateSimpleWindow(dpy, root_window, -10, -10, 1, 1, 0, 0, 0); + Window target_window = clipboard_helper_window; XConvertSelection(dpy, sel, targets, target_property, target_window, CurrentTime); XEvent ev; @@ -164,8 +165,6 @@ namespace Toolbox { case SelectionNotify: sev = (XSelectionEvent *)&ev.xselection; if (sev->property == None) { - XDestroyWindow(dpy, target_window); - XCloseDisplay(dpy); return make_clipboard_error>( "Conversion could not be performed.\n"); } else { @@ -187,9 +186,7 @@ namespace Toolbox { XFree(an); } XFree(prop_ret); - XDeleteProperty(dpy, target_window, target_property); - XDestroyWindow(dpy, target_window); - XCloseDisplay(dpy); + XDeleteProperty(dpy, clipboard_helper_window, target_property); return types; } break; @@ -201,18 +198,14 @@ namespace Toolbox { } Result SystemClipboard::getContent(const std::string &type) { #ifdef TOOLBOX_PLATFORM_LINUX - Display *dpy = XOpenDisplay(nullptr); - if (!dpy) { - return make_clipboard_error("Could not open X display"); - } + Display *dpy = getGLFWDisplay(); Atom requested_type = XInternAtom(dpy, type.c_str(), False); Atom sel = XInternAtom(dpy, "CLIPBOARD", False); Window clipboard_owner = XGetSelectionOwner(dpy, sel); if (clipboard_owner == None) { return make_clipboard_error("Clipboard isn't owned by anyone"); } - Window root = RootWindow(dpy, DefaultScreen(dpy)); - Window target_window = XCreateSimpleWindow(dpy, root, -10, -10, 1, 1, 0, 0, 0); + Window target_window = clipboard_helper_window; Atom target_property = XInternAtom(dpy, "CLIP_CONTENTS", False); XConvertSelection(dpy, sel, requested_type, target_property, target_window, CurrentTime); XEvent ev; @@ -225,7 +218,6 @@ namespace Toolbox { case SelectionNotify: sev = (XSelectionEvent *)&ev.xselection; if (sev->property == None) { - XCloseDisplay(dpy); return make_clipboard_error("Conversion could not be performed."); } else { Atom type_received; @@ -250,7 +242,6 @@ namespace Toolbox { AnyPropertyType, &_da, &_di, &_dul, &_dul, &prop_ret); Buffer data_buffer; if (!data_buffer.alloc(size)) { - XCloseDisplay(dpy); return make_clipboard_error( "Couldn't allocate buffer of big enough size"); } @@ -260,126 +251,25 @@ namespace Toolbox { MimeData result; result.set_data(type, std::move(data_buffer)); - XCloseDisplay(dpy); return result; } } } - XCloseDisplay(dpy); #endif return {}; } Result SystemClipboard::setContent(const MimeData &content) { #ifdef TOOLBOX_PLATFORM_LINUX - Display *dpy = XOpenDisplay(nullptr); - Atom TIMESTAMP = XInternAtom(dpy, "TIMESTAMP", False); - Atom TARGETS = XInternAtom(dpy, "TARGETS", False); + Display* dpy = getGLFWDisplay(); Atom CLIPBOARD = XInternAtom(dpy, "CLIPBOARD", False); - Atom TEXT_URI = XInternAtom(dpy, "text/uri-list", False); - Atom APP_KDE4_URILIST = XInternAtom(dpy, "application/x-kde4-urilist", False); - Atom APP_VND = XInternAtom(dpy, "application/vnd.portal.filetransfer", False); - Atom MULT = XInternAtom(dpy, "MULTIPLE", False); - Atom UTF8 = XInternAtom(dpy, "UTF8_STRING", False); - Atom APP_SRCID = XInternAtom(dpy, "application/x-kde-source-id", False); - Window root = RootWindow(dpy, DefaultScreen(dpy)); - Window target_window = XCreateSimpleWindow(dpy, root, -10, -10, 1, 1, 0, 0, 0); - - XSetSelectionOwner(dpy, CLIPBOARD, target_window, CurrentTime); - Atom CLIPBOARD = XInternAtom(clipboard_display, "CLIPBOARD", False); m_clipboard_contents = content; - std::cout << "Setting ourselves as clipboard owners" << std::endl; - XSetSelectionOwner(clipboard_display, CLIPBOARD, clipboard_helper_window, CurrentTime); + XSetSelectionOwner(dpy, CLIPBOARD, clipboard_helper_window, CurrentTime); ImGui::SetClipboardText(""); return {}; - while (true) { - XEvent event; - std::cout << "Waiting on X event... " << std::endl; - XNextEvent(dpy, &event); - switch (event.type) { - case SelectionClear: - std::cout << "Lost selection ownership" << std::endl; - return {}; - case SelectionRequest: { - XSelectionRequestEvent *request = &event.xselectionrequest; - std::cout << "Requestor: " << request->requestor << std::endl; - char *target_type = XGetAtomName(dpy, request->target); - std::cout << "Target Type: " << target_type << std::endl; - char *target_property = XGetAtomName(dpy, request->property); - std::cout << "Target Property: " << target_property << std::endl; - // const Atom targets[] = {TARGETS, MULT, UTF8, XA_STRING}; - // const Atom targets[] = {TIMESTAMP, TARGETS, TEXT_URI, - // APP_KDE4_URILIST, APP_VND, APP_SRCID}; - const Atom targets[] = {TARGETS, TEXT_URI}; - if (request->target == TARGETS) { - std::cout << "Responding with targets:" << std::endl; - for (const Atom &targ : targets) { - char *target = XGetAtomName(dpy, targ); - std::cout << target << std::endl; - if (target) - XFree(target); - } - XChangeProperty(dpy, request->requestor, request->property, XA_ATOM, 32, - PropModeReplace, - reinterpret_cast(targets), - sizeof(targets) / sizeof(targets[0])); - XSelectionEvent response; - response.type = SelectionNotify; - response.requestor = request->requestor; - response.selection = request->selection; - response.target = request->target; - response.property = request->property; - response.time = request->time; - - XSendEvent(dpy, request->requestor, True, NoEventMask, - reinterpret_cast(&response)); - continue; - } else if (request->target == TEXT_URI) { - std::string urls = content.get_urls().value(); - std::cout << "Responding with urls: " << urls << std::endl; - XChangeProperty( - dpy, request->requestor, request->property, TEXT_URI, 8, PropModeReplace, - reinterpret_cast(urls.c_str()), urls.length()); - - XSelectionEvent response; - response.type = SelectionNotify; - response.requestor = request->requestor; - response.selection = request->selection; - response.target = request->target; - response.property = request->property; - response.time = request->time; - - XSendEvent(dpy, request->requestor, True, NoEventMask, - reinterpret_cast(&response)); - // return {}; - } else if (request->target == UTF8) { - std::string test_string = "something"; - XChangeProperty( - dpy, request->requestor, request->property, UTF8, 8, PropModeReplace, - reinterpret_cast(test_string.c_str()), test_string.length()); - - XSelectionEvent response; - response.type = SelectionNotify; - response.requestor = request->requestor; - response.selection = request->selection; - response.target = request->target; - response.property = request->property; - response.time = request->time; - - XSendEvent(dpy, request->requestor, True, NoEventMask, - reinterpret_cast(&response)); - } else { - TOOLBOX_ERROR("Unrecognized request"); - return {}; - } - } - } - } - XDestroyWindow(dpy, target_window); - XCloseDisplay(dpy); #endif return {}; } -} // namespace Toolbox::UI +} // namespace Toolbox From 059382fc7634e3f515de6a998ff81b1f361a1767 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Thu, 3 Oct 2024 16:03:59 -0700 Subject: [PATCH 063/129] Don't rely on a false copy to own selection --- src/gui/clipboard.cpp | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index b34d2faf..1f91b439 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -14,20 +14,8 @@ namespace Toolbox { -#ifdef WIN32 SystemClipboard::SystemClipboard() {} SystemClipboard::~SystemClipboard() {} -#elif defined(TOOLBOX_PLATFORM_LINUX) - Window clipboard_helper_window; - SystemClipboard::SystemClipboard() { - Display* dpy = getGLFWDisplay(); - Window root_window = RootWindow(dpy, DefaultScreen(dpy)); - clipboard_helper_window = XCreateSimpleWindow(dpy, root_window, -10, -10, 1, 1, 0, 0, 0); - } - SystemClipboard::~SystemClipboard() { - XDestroyWindow(getGLFWDisplay(), clipboard_helper_window); - } -#endif Result SystemClipboard::getText() { #ifdef WIN32 @@ -152,7 +140,7 @@ namespace Toolbox { Atom sel = XInternAtom(dpy, "CLIPBOARD", False); Atom targets = XInternAtom(dpy, "TARGETS", False); Atom target_property = XInternAtom(dpy, "CLIP_TYPES", False); - Window target_window = clipboard_helper_window; + Window target_window = getGLFWHelperWindow(); XConvertSelection(dpy, sel, targets, target_property, target_window, CurrentTime); XEvent ev; @@ -186,7 +174,7 @@ namespace Toolbox { XFree(an); } XFree(prop_ret); - XDeleteProperty(dpy, clipboard_helper_window, target_property); + XDeleteProperty(dpy, target_window, target_property); return types; } break; @@ -205,7 +193,7 @@ namespace Toolbox { if (clipboard_owner == None) { return make_clipboard_error("Clipboard isn't owned by anyone"); } - Window target_window = clipboard_helper_window; + Window target_window = getGLFWHelperWindow(); Atom target_property = XInternAtom(dpy, "CLIP_CONTENTS", False); XConvertSelection(dpy, sel, requested_type, target_property, target_window, CurrentTime); XEvent ev; @@ -262,12 +250,10 @@ namespace Toolbox { Result SystemClipboard::setContent(const MimeData &content) { #ifdef TOOLBOX_PLATFORM_LINUX Display* dpy = getGLFWDisplay(); + Window target_window = getGLFWHelperWindow(); Atom CLIPBOARD = XInternAtom(dpy, "CLIPBOARD", False); m_clipboard_contents = content; - XSetSelectionOwner(dpy, CLIPBOARD, clipboard_helper_window, CurrentTime); - ImGui::SetClipboardText(""); - return {}; - + XSetSelectionOwner(dpy, CLIPBOARD, target_window, CurrentTime); #endif return {}; } From 9e30f6f7271ab7593f7d3496f38d2c6f3b00723c Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Thu, 3 Oct 2024 16:10:25 -0700 Subject: [PATCH 064/129] Const some methods --- include/core/clipboard.hpp | 4 ++-- src/gui/clipboard.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/core/clipboard.hpp b/include/core/clipboard.hpp index b401a593..b4b696f5 100644 --- a/include/core/clipboard.hpp +++ b/include/core/clipboard.hpp @@ -38,8 +38,8 @@ namespace Toolbox { Result getText(); Result setText(const std::string &text); - Result, ClipboardError> possibleContentTypes(); - Result getContent(const std::string &type); + Result, ClipboardError> possibleContentTypes() const; + Result getContent(const std::string &type) const; Result setContent(const MimeData &content); #ifdef TOOLBOX_PLATFORM_LINUX MimeData m_clipboard_contents; diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index 1f91b439..a9a7c26c 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -134,7 +134,7 @@ namespace Toolbox { void hookClipboardIntoGLFW(void) {} #endif - Result, ClipboardError> SystemClipboard::possibleContentTypes() { + Result, ClipboardError> SystemClipboard::possibleContentTypes() const { #ifdef TOOLBOX_PLATFORM_LINUX Display *dpy = getGLFWDisplay(); Atom sel = XInternAtom(dpy, "CLIPBOARD", False); @@ -184,7 +184,7 @@ namespace Toolbox { #endif return {}; } - Result SystemClipboard::getContent(const std::string &type) { + Result SystemClipboard::getContent(const std::string &type) const { #ifdef TOOLBOX_PLATFORM_LINUX Display *dpy = getGLFWDisplay(); Atom requested_type = XInternAtom(dpy, type.c_str(), False); From b30cb3fef8fdc031dfed7bac3801e2e316135bad Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Thu, 3 Oct 2024 16:44:15 -0700 Subject: [PATCH 065/129] Refactor an allow pasting any mime type --- include/core/mimedata/mimedata.hpp | 8 ++++ src/gui/clipboard.cpp | 71 +++++++++++++++--------------- 2 files changed, 44 insertions(+), 35 deletions(-) diff --git a/include/core/mimedata/mimedata.hpp b/include/core/mimedata/mimedata.hpp index eca76d21..7a7ab897 100644 --- a/include/core/mimedata/mimedata.hpp +++ b/include/core/mimedata/mimedata.hpp @@ -29,6 +29,14 @@ namespace Toolbox { [[nodiscard]] bool has_format(std::string_view type) const { return m_data_map.contains(std::string(type)); } + std::vector get_all_formats() const { + std::vector formats; + formats.reserve(m_data_map.size()); + for (auto &[k, v] : m_data_map) { + formats.push_back(k); + } + return formats; + } [[nodiscard]] bool has_color() const; [[nodiscard]] bool has_html() const; diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index a9a7c26c..c18e99a9 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -85,45 +85,46 @@ namespace Toolbox { #ifdef TOOLBOX_PLATFORM_LINUX void (*glfwSelectionRequestHandler)(XEvent *); + void sendRequestNotify(XSelecctionRequestEvent *request) { + XSelectionEvent response; + response.type = SelectionNotify; + response.requestor = request->requestor; + response.selection = request->selection; + response.target = request->target; + response.property = request->property; + response.time = request->time; + + XSendEvent(dpy, request->requestor, True, NoEventMask, + reinterpret_cast(&response)); + } void handleSelectionRequest(XEvent *event) { - const XSelectionRequestEvent* request = &event->xselectionrequest; - Display* dpy = getGLFWDisplay(); - Atom TEXT_URI = XInternAtom(dpy, "text/uri-list", False); - Atom TARGETS = XInternAtom(dpy, "TARGETS", False); - const Atom targets[] = {TARGETS, TEXT_URI}; + MimeData clipboard_contents = SystemClipboard::instance().m_clipboard_contents; + const XSelectionRequestEvent *request = &event->xselectionrequest; + Display *dpy = getGLFWDisplay(); + Atom TARGETS = XInternAtom(dpy, "TARGETS", False); + std::vector targets = {TARGETS}; + for (auto &string_format : clipboardContents.get_all_formats()) { + Atom format_atom = XInternAtom(dpy, format.c_str(), False); + targets.push_back(format_atom); + } if (request->target == TARGETS) { XChangeProperty(dpy, request->requestor, request->property, XA_ATOM, 32, - PropModeReplace, - reinterpret_cast(targets), - sizeof(targets) / sizeof(targets[0])); - XSelectionEvent response; - response.type = SelectionNotify; - response.requestor = request->requestor; - response.selection = request->selection; - response.target = request->target; - response.property = request->property; - response.time = request->time; - - XSendEvent(dpy, request->requestor, True, NoEventMask, - reinterpret_cast(&response)); - } else if (request->target == TEXT_URI) { - std::string urls = SystemClipboard::instance().m_clipboard_contents.get_urls().value(); - XChangeProperty( - dpy, request->requestor, request->property, TEXT_URI, 8, PropModeReplace, - reinterpret_cast(urls.c_str()), urls.length()); - - XSelectionEvent response; - response.type = SelectionNotify; - response.requestor = request->requestor; - response.selection = request->selection; - response.target = request->target; - response.property = request->property; - response.time = request->time; - - XSendEvent(dpy, request->requestor, True, NoEventMask, - reinterpret_cast(&response)); + PropModeReplace, reinterpret_cast(targets.data()), + targets.size()); + sendRequestNotify(request); } else { - glfwSelectionRequestHandler(event); + char* requested_target = XGetAtomName(dpy, request->target); + auto data = clipboard_contents.get_data(requested_target); + if (data && request->property != None) { + XChangeProperty(dpy, request->requestor, request->property, request->target, + 8 /* is this ever wrong? */, PropModeReplace, + reinterpret_castdata.buf(), + data.size); + } else { + glfwSelectionRequestHandler(event); + } + sendRequestNotify(request); + XFree(requested_target); } } void hookClipboardIntoGLFW(void) { From cb6e37ed900447a7f2931c46868d877fced899df Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Thu, 3 Oct 2024 16:44:37 -0700 Subject: [PATCH 066/129] Some clangformat stuff --- src/gui/clipboard.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index c18e99a9..9aa14180 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -187,7 +187,7 @@ namespace Toolbox { } Result SystemClipboard::getContent(const std::string &type) const { #ifdef TOOLBOX_PLATFORM_LINUX - Display *dpy = getGLFWDisplay(); + Display *dpy = getGLFWDisplay(); Atom requested_type = XInternAtom(dpy, type.c_str(), False); Atom sel = XInternAtom(dpy, "CLIPBOARD", False); Window clipboard_owner = XGetSelectionOwner(dpy, sel); @@ -250,9 +250,9 @@ namespace Toolbox { Result SystemClipboard::setContent(const MimeData &content) { #ifdef TOOLBOX_PLATFORM_LINUX - Display* dpy = getGLFWDisplay(); + Display *dpy = getGLFWDisplay(); Window target_window = getGLFWHelperWindow(); - Atom CLIPBOARD = XInternAtom(dpy, "CLIPBOARD", False); + Atom CLIPBOARD = XInternAtom(dpy, "CLIPBOARD", False); m_clipboard_contents = content; XSetSelectionOwner(dpy, CLIPBOARD, target_window, CurrentTime); #endif From 43d3547f6b2e9c675b3dbadf5169c5443c2286b5 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Fri, 4 Oct 2024 02:31:53 -0500 Subject: [PATCH 067/129] Mild refactoring --- include/gui/project/window.hpp | 3 + src/gui/clipboard.cpp | 3 +- src/gui/project/window.cpp | 121 ++++++++++++++++++--------------- 3 files changed, 73 insertions(+), 54 deletions(-) diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 5bb91445..3430e276 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -96,6 +96,9 @@ namespace Toolbox::UI { void actionDeleteIndexes(std::vector &indices); void actionOpenIndexes(const std::vector &indices); void actionRenameIndex(const ModelIndex &index); + void actionPasteIntoIndex(const ModelIndex &index); + void actionCopyIndexes(const std::vector &indices); + void actionLeftClickIndex(const ModelIndex &view_index, const ModelIndex &child_index, bool is_selected); diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index 0ba51beb..f5d6b96e 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -242,7 +242,7 @@ namespace Toolbox { size_t dest_buf_size = data_buf.size(); if (format == CF_HDROP) { dest_buf_size *= 2; - dest_buf_size += sizeof(DROPFILES); + dest_buf_size += sizeof(DROPFILES) + sizeof(wchar_t); } else if (format == CF_TEXT) { dest_buf_size *= 2; } @@ -273,6 +273,7 @@ namespace Toolbox { } path_list_ptr[data_buf.size()] = L'\0'; + path_list_ptr[data_buf.size() + 1] = L'\0'; } else if (format == CF_TEXT) { wchar_t *path_list_ptr = (wchar_t *)data_buffer; std::mbstowcs(path_list_ptr, data_buf.buf(), data_buf.size()); diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 7747f035..a3005a32 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -223,6 +223,13 @@ namespace Toolbox::UI { ImGui::PopStyleVar(5); } + + /*std::vector formats = + SystemClipboard::instance().getAvailableContentFormats().value_or( + std::vector()); + if (std::find(formats.begin(), formats.end(), "text/uri-list") != formats.end()) { + + }*/ } ImGui::EndChild(); @@ -354,21 +361,7 @@ namespace Toolbox::UI { m_folder_view_context_menu.addOption( "Copy", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_C}), [this]() { return m_selected_indices_ctx.size() > 0; }, - [this](auto) { - std::string copied_paths; - for (const ModelIndex &index : m_selected_indices_ctx) { - copied_paths += m_file_system_model->getPath(index).string(); - copied_paths += "\n"; - } - - MimeData data; - data.set_urls(copied_paths); - - auto result = SystemClipboard::instance().setContent("text/uri-list", data); - if (!result) { - TOOLBOX_ERROR("[PROJECT] Failed to set contents of clipboard"); - } - }); + [this](auto) { actionCopyIndexes(m_selected_indices_ctx); }); m_folder_view_context_menu.addDivider(); @@ -387,47 +380,11 @@ namespace Toolbox::UI { "Rename", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_R}), [this]() { return m_selected_indices_ctx.size() == 1; }, [this](auto) { actionRenameIndex(m_selected_indices_ctx[0]); }); + m_folder_view_context_menu.addOption( "Paste", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_V}), [this]() { return m_selected_indices_ctx.size() == 0; }, - [this](auto) { - auto content_types = SystemClipboard::instance().getAvailableContentFormats(); - if (!content_types) { - TOOLBOX_ERROR("Couldn't get content types"); - return; - } - if (std::find(content_types.value().begin(), content_types.value().end(), - std::string("text/uri-list")) != content_types.value().end()) { - auto content = SystemClipboard::instance().getContent("text/uri-list"); - if (!content) { - TOOLBOX_ERROR("Failed to get content as uri list"); - return; - } - auto text = content.value().get_urls(); - if (!text) { - TOOLBOX_ERROR("Mime data wouldn't return uri list"); - return; - } - - std::vector urls = splitLines(text.value()); - for (std::string_view src_path_str : urls) { - if (src_path_str.starts_with("file:/")) { - if (src_path_str.starts_with("file:///")) { - src_path_str = src_path_str.substr(8); - } else { - src_path_str = src_path_str.substr(7); - } - } else { - TOOLBOX_ERROR_V("Can't copy non-local uri {}", src_path_str); - continue; - } - - fs_path src_path = src_path_str; - m_file_system_model->copy(src_path, m_view_index, - src_path.filename().string()); - } - } - }); + [this](auto) { actionPasteIntoIndex(m_view_index); }); m_folder_view_context_menu.addDivider(); @@ -472,6 +429,64 @@ namespace Toolbox::UI { std::strncpy(m_rename_buffer, file_name.c_str(), IM_ARRAYSIZE(m_rename_buffer)); } + void ProjectViewWindow::actionPasteIntoIndex(const ModelIndex &index) { + auto content_types = SystemClipboard::instance().getAvailableContentFormats(); + if (!content_types) { + TOOLBOX_ERROR("Couldn't get content types"); + return; + } + + if (std::find(content_types.value().begin(), content_types.value().end(), + std::string("text/uri-list")) == content_types.value().end()) { + return; + } + + auto content = SystemClipboard::instance().getContent("text/uri-list"); + if (!content) { + TOOLBOX_ERROR("Failed to get content as uri list"); + return; + } + + auto text = content.value().get_urls(); + if (!text) { + TOOLBOX_ERROR("Mime data wouldn't return uri list"); + return; + } + + std::vector urls = splitLines(text.value()); + for (std::string_view src_path_str : urls) { + if (src_path_str.starts_with("file:/")) { + if (src_path_str.starts_with("file:///")) { + src_path_str = src_path_str.substr(8); + } else { + src_path_str = src_path_str.substr(7); + } + } else { + TOOLBOX_ERROR_V("Can't copy non-local uri {}", src_path_str); + continue; + } + + fs_path src_path = src_path_str; + m_file_system_model->copy(src_path, index, src_path.filename().string()); + } + } + + void ProjectViewWindow::actionCopyIndexes(const std::vector &indices) { + std::string copied_paths; + for (const ModelIndex &index : indices) { + copied_paths += m_file_system_model->getPath(index).string(); + copied_paths += "\n"; + } + + MimeData data; + data.set_urls(copied_paths); + + auto result = SystemClipboard::instance().setContent("text/uri-list", data); + if (!result) { + TOOLBOX_ERROR("[PROJECT] Failed to set contents of clipboard"); + } + } + void ProjectViewWindow::actionLeftClickIndex(const ModelIndex &view_index, const ModelIndex &child_index, bool is_selected) { ModelIndex source_child_index = m_view_proxy.toSourceIndex(child_index); From d75e6991f75147487813facf123bc75e7af9c3d9 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Fri, 4 Oct 2024 11:48:45 -0500 Subject: [PATCH 068/129] Enable drag and drop of files from explorer to project view --- include/core/input/input.hpp | 2 +- include/gui/event/dropevent.hpp | 12 ++++++--- include/gui/project/window.hpp | 2 +- include/gui/window.hpp | 2 ++ src/core/mimedata/mimedata.cpp | 8 +++--- src/gui/event/dropevent.cpp | 7 +++-- src/gui/project/window.cpp | 47 +++++++++++++++++---------------- src/gui/window.cpp | 32 ++++++++++++++++++++-- 8 files changed, 76 insertions(+), 36 deletions(-) diff --git a/include/core/input/input.hpp b/include/core/input/input.hpp index f0ceaca1..f85bc6b2 100644 --- a/include/core/input/input.hpp +++ b/include/core/input/input.hpp @@ -23,7 +23,7 @@ namespace Toolbox::Input { bool GetMouseButtonDown(MouseButton button); bool GetMouseButtonUp(MouseButton button); - void GetMouseViewportPosition(float &x, float &y); + void GetMouseViewportPosition(double &x, double &y); void SetMousePosition(double x, double y, bool overwrite_delta = true); void GetMouseDelta(double &x, double &y); diff --git a/include/gui/event/dropevent.hpp b/include/gui/event/dropevent.hpp index e1a9c4fd..3889820d 100644 --- a/include/gui/event/dropevent.hpp +++ b/include/gui/event/dropevent.hpp @@ -9,15 +9,19 @@ namespace Toolbox::UI { private: DropEvent() = default; + protected: + friend class ImWindow; + public: DropEvent(const DropEvent &) = default; DropEvent(DropEvent &&) noexcept = default; DropEvent(const ImVec2 &pos, DropType drop_type, const DragAction &action); - [[nodiscard]] ImVec2 getGlobalPoint() const noexcept { - return m_screen_pos; - } + DropEvent(const ImVec2 &pos, DropType drop_type, UUID64 source_uuid, UUID64 target_uuid, + MimeData &&data); + + [[nodiscard]] ImVec2 getGlobalPoint() const noexcept { return m_screen_pos; } [[nodiscard]] const MimeData &getMimeData() const noexcept { return m_mime_data; } [[nodiscard]] DropType getDropType() const noexcept { return m_drop_type; } @@ -30,7 +34,7 @@ namespace Toolbox::UI { private: ImVec2 m_screen_pos; - DropType m_drop_type; + DropType m_drop_type = DropType::ACTION_NONE; MimeData m_mime_data; UUID64 m_source_id; }; diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 3430e276..5c9f6f39 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -96,7 +96,7 @@ namespace Toolbox::UI { void actionDeleteIndexes(std::vector &indices); void actionOpenIndexes(const std::vector &indices); void actionRenameIndex(const ModelIndex &index); - void actionPasteIntoIndex(const ModelIndex &index); + void actionPasteIntoIndex(const ModelIndex &index, const MimeData &data); void actionCopyIndexes(const std::vector &indices); void actionLeftClickIndex(const ModelIndex &view_index, const ModelIndex &child_index, diff --git a/include/gui/window.hpp b/include/gui/window.hpp index eab5e9bd..4cfc759d 100644 --- a/include/gui/window.hpp +++ b/include/gui/window.hpp @@ -116,6 +116,8 @@ namespace Toolbox::UI { void setLayerSize(const ImVec2 &size) noexcept { ImProcessLayer::setSize(size); } void setLayerPos(const ImVec2 &pos) noexcept { ImProcessLayer::setPos(pos); } + static void privDropCallback(GLFWwindow *window, int path_count, const char *paths[]); + UUID64 m_UUID64; ImGuiID m_sibling_id = 0; diff --git a/src/core/mimedata/mimedata.cpp b/src/core/mimedata/mimedata.cpp index d26378d3..4bef8d12 100644 --- a/src/core/mimedata/mimedata.cpp +++ b/src/core/mimedata/mimedata.cpp @@ -22,6 +22,7 @@ namespace Toolbox { "image/bmp", "image/jpeg", "image/png", + "image/tiff", "image/x-portable-bitmap", "image/x-portable-graymap", "image/x-portable-pixmap", @@ -102,13 +103,14 @@ namespace Toolbox { return std::nullopt; } const Buffer &data_buf = m_data_map["text/plain"]; - return std::string(data_buf.buf(), data_buf.size()); + return std::string(data_buf.buf(), data_buf.size() - 1); } void MimeData::set_text(std::string_view data) { Buffer _tmp; - _tmp.alloc(data.size()); + _tmp.alloc(data.size() + 1); std::memcpy(_tmp.buf(), data.data(), data.size()); + _tmp.get(data.size()) = '\0'; set_data("text/plain", std::move(_tmp)); } @@ -117,7 +119,7 @@ namespace Toolbox { return std::nullopt; } const Buffer &data_buf = m_data_map["text/uri-list"]; - return std::string(data_buf.buf(), data_buf.size()); + return std::string(data_buf.buf(), data_buf.size() - 1); } void MimeData::set_urls(std::string_view data) { diff --git a/src/gui/event/dropevent.cpp b/src/gui/event/dropevent.cpp index facf9a55..f74df1c1 100644 --- a/src/gui/event/dropevent.cpp +++ b/src/gui/event/dropevent.cpp @@ -1,9 +1,12 @@ #include "gui/event/dropevent.hpp" namespace Toolbox::UI { + DropEvent::DropEvent(const ImVec2 &pos, DropType drop_type, UUID64 source_uuid, + UUID64 target_uuid, MimeData &&data) + : BaseEvent(target_uuid, EVENT_DROP), m_screen_pos(pos), + m_drop_type(drop_type), m_source_id(source_uuid), m_mime_data(std::move(data)) {} - DropEvent::DropEvent(const ImVec2 &pos, DropType drop_type, - const DragAction &action) + DropEvent::DropEvent(const ImVec2 &pos, DropType drop_type, const DragAction &action) : BaseEvent(action.getTargetUUID().value(), EVENT_DROP), m_screen_pos(pos), m_drop_type(drop_type), m_source_id(action.getSourceUUID()) {} diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index a3005a32..a5be77b0 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -265,7 +265,9 @@ namespace Toolbox::UI { void ProjectViewWindow::onDragEvent(RefPtr ev) {} - void ProjectViewWindow::onDropEvent(RefPtr ev) {} + void ProjectViewWindow::onDropEvent(RefPtr ev) { + actionPasteIntoIndex(m_view_index, ev->getMimeData()); + } std::vector splitLines(std::string_view s) { std::vector result; @@ -273,9 +275,9 @@ namespace Toolbox::UI { size_t next_newline_pos = s.find('\n', 0); while (next_newline_pos != std::string::npos) { if (s[next_newline_pos - 1] == '\r') { - result.push_back(s.substr(last_pos, next_newline_pos - 1)); + result.push_back(s.substr(last_pos, next_newline_pos - last_pos - 1)); } else { - result.push_back(s.substr(last_pos, next_newline_pos)); + result.push_back(s.substr(last_pos, next_newline_pos - last_pos)); } last_pos = next_newline_pos + 1; next_newline_pos = s.find('\n', last_pos); @@ -384,7 +386,23 @@ namespace Toolbox::UI { m_folder_view_context_menu.addOption( "Paste", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_V}), [this]() { return m_selected_indices_ctx.size() == 0; }, - [this](auto) { actionPasteIntoIndex(m_view_index); }); + [this](auto) { + auto content_types = SystemClipboard::instance().getAvailableContentFormats(); + if (!content_types) { + TOOLBOX_ERROR("Couldn't get content types"); + return; + } + + if (std::find(content_types.value().begin(), content_types.value().end(), + std::string("text/uri-list")) == content_types.value().end()) { + return; + } + + MimeData data = + SystemClipboard::instance().getContent("text/uri-list").value_or(MimeData()); + + actionPasteIntoIndex(m_view_index, data); + }); m_folder_view_context_menu.addDivider(); @@ -429,25 +447,8 @@ namespace Toolbox::UI { std::strncpy(m_rename_buffer, file_name.c_str(), IM_ARRAYSIZE(m_rename_buffer)); } - void ProjectViewWindow::actionPasteIntoIndex(const ModelIndex &index) { - auto content_types = SystemClipboard::instance().getAvailableContentFormats(); - if (!content_types) { - TOOLBOX_ERROR("Couldn't get content types"); - return; - } - - if (std::find(content_types.value().begin(), content_types.value().end(), - std::string("text/uri-list")) == content_types.value().end()) { - return; - } - - auto content = SystemClipboard::instance().getContent("text/uri-list"); - if (!content) { - TOOLBOX_ERROR("Failed to get content as uri list"); - return; - } - - auto text = content.value().get_urls(); + void ProjectViewWindow::actionPasteIntoIndex(const ModelIndex &index, const MimeData &data) { + std::optional text = data.get_urls(); if (!text) { TOOLBOX_ERROR("Mime data wouldn't return uri list"); return; diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 64375170..a79832bd 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -1,5 +1,6 @@ #include "gui/window.hpp" #include "gui/application.hpp" +#include "gui/event/dropevent.hpp" #include "gui/util.hpp" #include @@ -41,8 +42,8 @@ namespace Toolbox::UI { // Load image data { - stbi_uc *data = - stbi_load_from_memory(result.value().data(), result.value().size(), &width, &height, &channels, 4); + stbi_uc *data = stbi_load_from_memory(result.value().data(), result.value().size(), + &width, &height, &channels, 4); data_buf.alloc(static_cast(width * height * channels)); std::memcpy(data_buf.buf(), data, data_buf.size()); @@ -179,6 +180,13 @@ namespace Toolbox::UI { // Render the window if (ImGui::Begin(window_name.c_str(), &is_open, flags_)) { ImGuiViewport *viewport = ImGui::GetCurrentWindow()->Viewport; + GLFWwindow *window = static_cast(viewport->PlatformHandle); + if (window) { + TOOLBOX_DEBUG_LOG("Setting window callbacks"); + glfwSetWindowUserPointer(window, this); + glfwSetDropCallback(static_cast(viewport->PlatformHandle), + privDropCallback); + } if ((flags_ & ImGuiWindowFlags_NoBackground)) { viewport->Flags |= ImGuiViewportFlags_TransparentFrameBuffer; @@ -251,4 +259,24 @@ namespace Toolbox::UI { return t; } + void ImWindow::privDropCallback(GLFWwindow *window, int path_count, const char *paths[]) { + ImWindow *self = static_cast(glfwGetWindowUserPointer(window)); + if (!self) { + TOOLBOX_ERROR("[ImWindow] Attempted drop operation on NULL user pointer!"); + } + + std::string uri_list; + for (int i = 0; i < path_count; ++i) { + uri_list += std::format("file:///{}\n", paths[i]); + } + + double mouse_x, mouse_y; + Input::GetMouseViewportPosition(mouse_x, mouse_y); + + MimeData &&data = MimeData(); + data.set_urls(uri_list); + GUIApplication::instance().dispatchEvent( + ImVec2(mouse_x, mouse_y), DropType::ACTION_COPY, 0, self->getUUID(), std::move(data)); + } + } // namespace Toolbox::UI \ No newline at end of file From 4da8577eb4413e79496f86a663ab23a1dffbe54f Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Fri, 4 Oct 2024 10:31:36 -0700 Subject: [PATCH 069/129] Add comments to copying-out code --- src/gui/clipboard.cpp | 95 +++++++++++++++++++++++++++++++++---------- 1 file changed, 73 insertions(+), 22 deletions(-) diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index 9aa14180..238c5074 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -84,8 +84,12 @@ namespace Toolbox { } #ifdef TOOLBOX_PLATFORM_LINUX + // Storage for a function pointer to the original handler, so that + // we can call it if we don't want to handle the event ourselves. void (*glfwSelectionRequestHandler)(XEvent *); - void sendRequestNotify(XSelecctionRequestEvent *request) { + // Sends a notification that we're done responding to a given + // request. + void sendRequestNotify(Display* dpy, const XSelectionRequestEvent *request) { XSelectionEvent response; response.type = SelectionNotify; response.requestor = request->requestor; @@ -97,44 +101,82 @@ namespace Toolbox { XSendEvent(dpy, request->requestor, True, NoEventMask, reinterpret_cast(&response)); } + // Our hook into the GLFW selection event handling code. When we + // receive a selection event, either return a list of formats we + // support or return the data in our clipboard. void handleSelectionRequest(XEvent *event) { - MimeData clipboard_contents = SystemClipboard::instance().m_clipboard_contents; - const XSelectionRequestEvent *request = &event->xselectionrequest; + // Pull the contents of the clipboard from the clipboard + // instance. This function can't be a method on that object + // because we're going to be passing it as a function pointer + // into GLFW, so we have to do everything externally. + MimeData clipboard_contents = SystemClipboard::instance().m_clipboard_contents; + // Get the display object from GLFW so we can intern our + // strings in its namespace. Display *dpy = getGLFWDisplay(); + // Pull out the specific event from the general one. + const XSelectionRequestEvent *request = &event->xselectionrequest; + // Start our targets array with just the "TARGET" target, + // since we'll generate the rest in a loop. Atom TARGETS = XInternAtom(dpy, "TARGETS", False); - std::vector targets = {TARGETS}; - for (auto &string_format : clipboardContents.get_all_formats()) { - Atom format_atom = XInternAtom(dpy, format.c_str(), False); - targets.push_back(format_atom); - } + // If they if (request->target == TARGETS) { - XChangeProperty(dpy, request->requestor, request->property, XA_ATOM, 32, - PropModeReplace, reinterpret_cast(targets.data()), - targets.size()); - sendRequestNotify(request); + std::vector targets = {TARGETS}; + // For each format the selection data supports, intern it into + // an atom and add it to the targets array. + for (auto &string_format : clipboard_contents.get_all_formats()) { + Atom format_atom = XInternAtom(dpy, string_format.c_str(), False); + targets.push_back(format_atom); + } + // Put this data as the requested property on the + // requested window. XAtoms are 32 bits wide, so specify + // that. + XChangeProperty( + dpy, request->requestor, request->property, XA_ATOM, 32, PropModeReplace, + reinterpret_cast(targets.data()), targets.size()); + // Send a notification that we did the thing. + sendRequestNotify(dpy, request); } else { - char* requested_target = XGetAtomName(dpy, request->target); - auto data = clipboard_contents.get_data(requested_target); + // If they request anything but TARGETS, assume its a data + // format from the clipboard data. Get the string name of + // the format, and ask for it from the clipboard contents + // mime type. + char *requested_target = XGetAtomName(dpy, request->target); + auto data = clipboard_contents.get_data(requested_target); + // If the mime data recognized and gave us a response, and + // also we have a property to put the response on... if (data && request->property != None) { + // Then set the property, and notify of a response. XChangeProperty(dpy, request->requestor, request->property, request->target, 8 /* is this ever wrong? */, PropModeReplace, - reinterpret_castdata.buf(), - data.size); + reinterpret_cast(data.value().buf()), data.value().size()); + sendRequestNotify(dpy, request); } else { + // If we don't recognize the data, or it's a legacy + // client without a property target, then let GLFW + // complain about it. glfwSelectionRequestHandler(event); } - sendRequestNotify(request); + // Make sure to free the string that represents the + // format. XFree(requested_target); } } + // Called on initialization to hook our code into the GLFW + // selection code. void hookClipboardIntoGLFW(void) { + // Get the old handler so that we can invoke it when our + // handler doesn't know what to do. glfwSelectionRequestHandler = getSelectionRequestHandler(); + // Set our handler as the new handler. setSelectionRequestHandler(handleSelectionRequest); } #else + // On windows we don't need to hook into GLFW for clipboard + // functionality, so do nothing. void hookClipboardIntoGLFW(void) {} #endif + // Get all possible content types for the system clipboard. Result, ClipboardError> SystemClipboard::possibleContentTypes() const { #ifdef TOOLBOX_PLATFORM_LINUX Display *dpy = getGLFWDisplay(); @@ -146,8 +188,9 @@ namespace Toolbox { XEvent ev; XSelectionEvent *sev; - // This looks pretty dangerous but this is how glfw does it, - // and how the examples online do it, so :shrug: + // This unconditional while loop looks pretty dangerous but + // this is how glfw does it, and how the examples online do + // it, so :shrug: while (true) { XNextEvent(dpy, &ev); switch (ev.type) { @@ -185,6 +228,7 @@ namespace Toolbox { #endif return {}; } + // Get the contents of the system clipboard. Result SystemClipboard::getContent(const std::string &type) const { #ifdef TOOLBOX_PLATFORM_LINUX Display *dpy = getGLFWDisplay(); @@ -199,8 +243,9 @@ namespace Toolbox { XConvertSelection(dpy, sel, requested_type, target_property, target_window, CurrentTime); XEvent ev; XSelectionEvent *sev; - // This looks pretty dangerous but this is how glfw does it, - // and how the examples online do it, so :shrug: + // This unconditional while loop looks pretty dangerous but + // this is how glfw does it, and how the examples online do + // it, so :shrug: while (true) { XNextEvent(dpy, &ev); switch (ev.type) { @@ -248,12 +293,18 @@ namespace Toolbox { return {}; } + // Set the contents of the system clipboard. Result SystemClipboard::setContent(const MimeData &content) { #ifdef TOOLBOX_PLATFORM_LINUX + // Get the display and helper window from GLFW using our custom hooks. Display *dpy = getGLFWDisplay(); Window target_window = getGLFWHelperWindow(); - Atom CLIPBOARD = XInternAtom(dpy, "CLIPBOARD", False); + // Copy the content into the contents member variable. m_clipboard_contents = content; + // Set ourselves as the owner of the clipboard. We'll do all + // the actual data transfer once someone asks us for data, in + // our event handling hook. + Atom CLIPBOARD = XInternAtom(dpy, "CLIPBOARD", False); XSetSelectionOwner(dpy, CLIPBOARD, target_window, CurrentTime); #endif return {}; From 297e123a681550f57ac7924d0ae4b5a39ad20b9d Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Fri, 4 Oct 2024 10:31:58 -0700 Subject: [PATCH 070/129] OOps don't try to close the GLFW display --- src/gui/clipboard.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index 238c5074..76026033 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -224,7 +224,6 @@ namespace Toolbox { break; } } - XCloseDisplay(dpy); #endif return {}; } From 5b803ec63f0bc823674ef8360454652b2b261da6 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Fri, 4 Oct 2024 12:15:54 -0700 Subject: [PATCH 071/129] Don't print "Setting window callbacks" every frame. --- src/gui/window.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/window.cpp b/src/gui/window.cpp index a79832bd..8ecb176e 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -182,7 +182,6 @@ namespace Toolbox::UI { ImGuiViewport *viewport = ImGui::GetCurrentWindow()->Viewport; GLFWwindow *window = static_cast(viewport->PlatformHandle); if (window) { - TOOLBOX_DEBUG_LOG("Setting window callbacks"); glfwSetWindowUserPointer(window, this); glfwSetDropCallback(static_cast(viewport->PlatformHandle), privDropCallback); From 195abc02ea4d3aefad1cad020b17d3f9dac5b3bb Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Fri, 4 Oct 2024 14:17:01 -0500 Subject: [PATCH 072/129] Drag/drop start work --- include/gui/dragdrop/dragaction.hpp | 7 ++++--- src/gui/dragdrop/dragdropmanager.cpp | 19 +++++-------------- src/gui/project/window.cpp | 7 ------- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/include/gui/dragdrop/dragaction.hpp b/include/gui/dragdrop/dragaction.hpp index c7ea154c..db25bca2 100644 --- a/include/gui/dragdrop/dragaction.hpp +++ b/include/gui/dragdrop/dragaction.hpp @@ -22,7 +22,7 @@ namespace Toolbox::UI { [[nodiscard]] ImVec2 getHotSpot() const { return m_hot_spot; } [[nodiscard]] const ImageHandle &getImage() { return m_image_handle; } - [[nodiscard]] const ImGuiPayload *getPayload() const { return m_imgui_payload; } + [[nodiscard]] const MimeData &getPayload() const { return m_mime_data; } [[nodiscard]] DropType getDefaultDropType() const { m_default_drop_type; } [[nodiscard]] DropTypes getSupportedDropTypes() const { return m_supported_drop_types; } @@ -31,13 +31,14 @@ namespace Toolbox::UI { void setHotSpot(const ImVec2 &absp) { m_hot_spot = absp; } void setImage(const ImageHandle &image) { m_image_handle = image; } - void setPayload(const ImGuiPayload *payload) { m_imgui_payload = payload; } + void setPayload(const MimeData &data) { m_mime_data = data; } + void setTargetUUID(const UUID64 &uuid) { m_target_uuid = uuid; } private: ImVec2 m_hot_spot; ImageHandle m_image_handle; - const ImGuiPayload *m_imgui_payload; + MimeData m_mime_data; DropType m_default_drop_type; DropType m_supported_drop_types; diff --git a/src/gui/dragdrop/dragdropmanager.cpp b/src/gui/dragdrop/dragdropmanager.cpp index fb0318ea..d5bdbae3 100644 --- a/src/gui/dragdrop/dragdropmanager.cpp +++ b/src/gui/dragdrop/dragdropmanager.cpp @@ -4,23 +4,14 @@ #include "core/mimedata/mimedata.hpp" #include "gui/dragdrop/dragaction.hpp" #include "gui/dragdrop/dropaction.hpp" +#include "gui/dragdrop/dragdropmanager.hpp" namespace Toolbox::UI { - - class DragDropManager { - public: - static DragDropManager &instance() { - static DragDropManager _instance; - return _instance; - } - - void initialize(); - RefPtr createDragAction(); - + RefPtr DragDropManager::createDragAction() { + return make_referable(); + } - protected: - DragDropManager() = default; - }; + void DragDropManager::initialize() {} } // namespace Toolbox::UI \ No newline at end of file diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index a5be77b0..e88f1b73 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -223,13 +223,6 @@ namespace Toolbox::UI { ImGui::PopStyleVar(5); } - - /*std::vector formats = - SystemClipboard::instance().getAvailableContentFormats().value_or( - std::vector()); - if (std::find(formats.begin(), formats.end(), "text/uri-list") != formats.end()) { - - }*/ } ImGui::EndChild(); From 34103758b1160270fdb59adc6d6a72d56d177e9f Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Fri, 4 Oct 2024 12:19:28 -0700 Subject: [PATCH 073/129] Oops update remote and commit for glfw for our hooks --- .gitmodules | 2 +- lib/glfw | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index e818526c..338c7e3e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -11,7 +11,7 @@ url = https://github.com/aiekick/ImGuiFileDialog.git [submodule "lib/glfw"] path = lib/glfw - url = https://github.com/glfw/glfw.git + url = https://github.com/HazardousPeach/glfw.git [submodule "lib/libbti"] path = lib/libbti url = https://github.com/HazardousPeach/libbti.git diff --git a/lib/glfw b/lib/glfw index 70d10e61..1014db47 160000 --- a/lib/glfw +++ b/lib/glfw @@ -1 +1 @@ -Subproject commit 70d10e617a664237c14c6b8fd9993aa391522dd8 +Subproject commit 1014db47dc27708d3f71f790579bc67b79ea4ea5 From af85b3f9a952a95c5d596b64a95190a0872fa993 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Fri, 4 Oct 2024 13:12:52 -0700 Subject: [PATCH 074/129] Implement text clipboard on linux --- src/gui/clipboard.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index 56183593..03995385 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -521,11 +521,17 @@ namespace Toolbox { return {}; } Result SystemClipboard::getText() const { - return make_clipboard_error("Not implemented yet"); + auto data = getContent("text/plain"); + if (!data || !data.value().has_text()) { + return make_clipboard_error("No text in clipboard!"); + } + return data.value().get_text().value(); } Result SystemClipboard::setText(const std::string &text) { - return make_clipboard_error("Not implemented yet"); + MimeData data; + data.set_text(text); + return setContent("text/plain", data); } // Get the contents of the system clipboard. From 31121b0c8107b407e7900016cabd8d316cadc858 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Sat, 5 Oct 2024 11:43:29 -0500 Subject: [PATCH 075/129] Current progress --- include/core/application/application.hpp | 2 +- include/core/clipboard.hpp | 2 +- include/gui/application.hpp | 2 + include/gui/dragdrop/dragaction.hpp | 7 +- include/gui/dragdrop/dragdropmanager.hpp | 28 +- include/gui/dragdrop/dropaction.hpp | 1 + include/gui/dragdrop/target.hpp | 30 ++ include/gui/event/dragevent.hpp | 8 +- include/gui/event/dropevent.hpp | 19 +- include/gui/window.hpp | 42 ++- src/gui/application.cpp | 13 + src/gui/clipboard.cpp | 5 +- src/gui/dragdrop/dragdropmanager.cpp | 149 +++++++++- src/gui/dragdrop/target.cpp | 353 +++++++++++++++++++++++ src/gui/event/dragevent.cpp | 6 +- src/gui/event/dropevent.cpp | 10 +- src/gui/project/window.cpp | 3 +- src/gui/window.cpp | 11 +- 18 files changed, 639 insertions(+), 52 deletions(-) create mode 100644 include/gui/dragdrop/target.hpp create mode 100644 src/gui/dragdrop/target.cpp diff --git a/include/core/application/application.hpp b/include/core/application/application.hpp index d7a7fc2a..97138190 100644 --- a/include/core/application/application.hpp +++ b/include/core/application/application.hpp @@ -59,7 +59,7 @@ namespace Toolbox { // ------------------------------------------------------ - virtual void onEvent(RefPtr ev) override final; + virtual void onEvent(RefPtr ev) override; template void dispatchEvent(_Args &&...args) { diff --git a/include/core/clipboard.hpp b/include/core/clipboard.hpp index e6c97a5a..468b1b1c 100644 --- a/include/core/clipboard.hpp +++ b/include/core/clipboard.hpp @@ -50,7 +50,7 @@ namespace Toolbox { static std::string MimeForFormat(UINT format); private: - std::unordered_map m_mime_to_format; + mutable std::unordered_map m_mime_to_format; #elif defined(TOOLBOX_PLATFORM_LINUX) // The reason this isn't private/protected is actually kind of // dumb. It needs to be accessed by handleSelectionRequest, diff --git a/include/gui/application.hpp b/include/gui/application.hpp index 6bc3c99a..2f985241 100644 --- a/include/gui/application.hpp +++ b/include/gui/application.hpp @@ -54,6 +54,8 @@ namespace Toolbox { virtual void onUpdate(TimeStep delta_time) override; virtual void onExit() override; + void onEvent(RefPtr ev) override; + void addWindow(RefPtr window) { if (!m_windows_processing) { addLayer(window); diff --git a/include/gui/dragdrop/dragaction.hpp b/include/gui/dragdrop/dragaction.hpp index db25bca2..1c88210b 100644 --- a/include/gui/dragdrop/dragaction.hpp +++ b/include/gui/dragdrop/dragaction.hpp @@ -27,20 +27,21 @@ namespace Toolbox::UI { [[nodiscard]] DropTypes getSupportedDropTypes() const { return m_supported_drop_types; } [[nodiscard]] UUID64 getSourceUUID() const { return m_source_uuid; } - [[nodiscard]] std::optional getTargetUUID() const { return m_source_uuid; } + [[nodiscard]] std::optional getTargetUUID() const { return m_target_uuid; } void setHotSpot(const ImVec2 &absp) { m_hot_spot = absp; } void setImage(const ImageHandle &image) { m_image_handle = image; } void setPayload(const MimeData &data) { m_mime_data = data; } void setTargetUUID(const UUID64 &uuid) { m_target_uuid = uuid; } + void setSupportedDropTypes(DropTypes types) { m_supported_drop_types = types; } private: ImVec2 m_hot_spot; ImageHandle m_image_handle; MimeData m_mime_data; - DropType m_default_drop_type; - DropType m_supported_drop_types; + DropType m_default_drop_type = DropType::ACTION_MOVE; + DropTypes m_supported_drop_types = DropType::ACTION_COPY | DropType::ACTION_MOVE; UUID64 m_source_uuid; std::optional m_target_uuid; diff --git a/include/gui/dragdrop/dragdropmanager.hpp b/include/gui/dragdrop/dragdropmanager.hpp index fb0318ea..3ff69423 100644 --- a/include/gui/dragdrop/dragdropmanager.hpp +++ b/include/gui/dragdrop/dragdropmanager.hpp @@ -5,6 +5,14 @@ #include "gui/dragdrop/dragaction.hpp" #include "gui/dragdrop/dropaction.hpp" +#ifdef TOOLBOX_PLATFORM_WINDOWS +#include +#include +#include +#include +#elif defined(TOOLBOX_PLATFORM_LINUX) +#endif + namespace Toolbox::UI { class DragDropManager { @@ -14,13 +22,27 @@ namespace Toolbox::UI { return _instance; } - void initialize(); + bool initialize(); + void shutdown(); - RefPtr createDragAction(); - + RefPtr createDragAction(UUID64 source_uuid, MimeData &&data); + RefPtr getCurrentDragAction() const { return m_current_drag_action; } + void destroyDragAction(RefPtr action); protected: DragDropManager() = default; + + Result createSystemDragDropSource(MimeData &&data); + Result destroySystemDragDropSource(); + + private: +#ifdef TOOLBOX_PLATFORM_WINDOWS + IDataObject *m_data_object = nullptr; + IDropSource *m_drop_source = nullptr; +#elif defined(TOOLBOX_PLATFORM_LINUX) +#endif + + RefPtr m_current_drag_action; }; } // namespace Toolbox::UI \ No newline at end of file diff --git a/include/gui/dragdrop/dropaction.hpp b/include/gui/dragdrop/dropaction.hpp index 8b33a906..b38c8f1f 100644 --- a/include/gui/dragdrop/dropaction.hpp +++ b/include/gui/dragdrop/dropaction.hpp @@ -14,6 +14,7 @@ namespace Toolbox::UI { // Windows only ACTION_TARGET_MOVE = 0x8002, }; + TOOLBOX_BITWISE_ENUM(DropType); using DropTypes = DropType; diff --git a/include/gui/dragdrop/target.hpp b/include/gui/dragdrop/target.hpp new file mode 100644 index 00000000..76ca2a70 --- /dev/null +++ b/include/gui/dragdrop/target.hpp @@ -0,0 +1,30 @@ +#pragma once + +#include "gui/dragdrop/dragaction.hpp" +#include "gui/dragdrop/dropaction.hpp" +#include "platform/process.hpp" + +namespace Toolbox::UI { + + class IDragDropTargetDelegate { + public: + virtual ~IDragDropTargetDelegate() = default; + + // void * for circular ref + virtual void setImWindow(void *window) = 0; + + virtual void onDragEnter(RefPtr action) = 0; + virtual void onDragLeave(RefPtr action) = 0; + virtual void onDragMove(RefPtr action) = 0; + virtual void onDrop(RefPtr action) = 0; + + virtual bool initializeForWindow(Platform::LowWindow window) = 0; + virtual void shutdownForWindow(Platform::LowWindow window) = 0; + }; + + class DragDropTargetFactory { + public: + static RefPtr createDragDropTargetDelegate(); + }; + +} // namespace Toolbox::UI \ No newline at end of file diff --git a/include/gui/event/dragevent.hpp b/include/gui/event/dragevent.hpp index 76a67fcd..258036fd 100644 --- a/include/gui/event/dragevent.hpp +++ b/include/gui/event/dragevent.hpp @@ -13,15 +13,15 @@ namespace Toolbox::UI { DragEvent(const DragEvent &) = default; DragEvent(DragEvent &&) noexcept = default; - DragEvent(TypeID type, float pos_x, float pos_y, DragAction &&action); + DragEvent(TypeID type, float pos_x, float pos_y, RefPtr action); [[nodiscard]] void getGlobalPoint(float &x, float &y) const noexcept { x = m_screen_pos_x; y = m_screen_pos_y; } - [[nodiscard]] DragAction &getDragAction() noexcept { return m_drag_action; } - [[nodiscard]] UUID64 getSourceId() const noexcept { return m_drag_action.getSourceUUID(); } + [[nodiscard]] RefPtr getDragAction() const noexcept { return m_drag_action; } + [[nodiscard]] UUID64 getSourceId() const noexcept { return m_drag_action->getSourceUUID(); } ScopePtr clone(bool deep) const override; @@ -31,7 +31,7 @@ namespace Toolbox::UI { private: float m_screen_pos_x; float m_screen_pos_y; - DragAction m_drag_action; + RefPtr m_drag_action; }; } // namespace Toolbox::UI \ No newline at end of file diff --git a/include/gui/event/dropevent.hpp b/include/gui/event/dropevent.hpp index 3889820d..5db48e99 100644 --- a/include/gui/event/dropevent.hpp +++ b/include/gui/event/dropevent.hpp @@ -16,16 +16,17 @@ namespace Toolbox::UI { DropEvent(const DropEvent &) = default; DropEvent(DropEvent &&) noexcept = default; - DropEvent(const ImVec2 &pos, DropType drop_type, const DragAction &action); - - DropEvent(const ImVec2 &pos, DropType drop_type, UUID64 source_uuid, UUID64 target_uuid, - MimeData &&data); + DropEvent(const ImVec2 &pos, RefPtr action); [[nodiscard]] ImVec2 getGlobalPoint() const noexcept { return m_screen_pos; } - [[nodiscard]] const MimeData &getMimeData() const noexcept { return m_mime_data; } - [[nodiscard]] DropType getDropType() const noexcept { return m_drop_type; } - [[nodiscard]] UUID64 getSourceId() const noexcept { return m_source_id; } + [[nodiscard]] const MimeData &getMimeData() const noexcept { return m_drag_action->getPayload(); } + [[nodiscard]] DropTypes getSupportedDropTypes() const noexcept { + return m_drag_action->getSupportedDropTypes() != DropType::ACTION_NONE + ? m_drag_action->getSupportedDropTypes() + : m_drag_action->getDefaultDropType(); + } + [[nodiscard]] UUID64 getSourceId() const noexcept { return m_drag_action->getSourceUUID(); } ScopePtr clone(bool deep) const override; @@ -34,9 +35,7 @@ namespace Toolbox::UI { private: ImVec2 m_screen_pos; - DropType m_drop_type = DropType::ACTION_NONE; - MimeData m_mime_data; - UUID64 m_source_id; + RefPtr m_drag_action; }; } // namespace Toolbox::UI \ No newline at end of file diff --git a/include/gui/window.hpp b/include/gui/window.hpp index 4cfc759d..087b6b90 100644 --- a/include/gui/window.hpp +++ b/include/gui/window.hpp @@ -16,9 +16,11 @@ #include "serial.hpp" #include "smart_resource.hpp" #include "unique.hpp" + #include #include +#include "gui/dragdrop/target.hpp" #include "gui/layer/imlayer.hpp" namespace Toolbox::UI { @@ -31,26 +33,44 @@ namespace Toolbox::UI { virtual void onRenderBody(TimeStep delta_time) {} public: - explicit ImWindow(const std::string &name) : ImProcessLayer(name) {} + explicit ImWindow(const std::string &name) : ImProcessLayer(name) { + m_drop_delegate = DragDropTargetFactory::createDragDropTargetDelegate(); + m_drop_delegate->setImWindow(this); + } ImWindow(const std::string &name, std::optional default_size) - : ImProcessLayer(name), m_default_size(default_size) {} + : ImProcessLayer(name), m_default_size(default_size) { + m_drop_delegate = DragDropTargetFactory::createDragDropTargetDelegate(); + m_drop_delegate->setImWindow(this); + } ImWindow(const std::string &name, std::optional min_size, std::optional max_size) - : ImProcessLayer(name), m_min_size(min_size), m_max_size(max_size) {} + : ImProcessLayer(name), m_min_size(min_size), m_max_size(max_size) { + m_drop_delegate = DragDropTargetFactory::createDragDropTargetDelegate(); + m_drop_delegate->setImWindow(this); + } ImWindow(const std::string &name, std::optional default_size, std::optional min_size, std::optional max_size) : ImProcessLayer(name), m_default_size(default_size), m_min_size(min_size), - m_max_size(max_size) {} + m_max_size(max_size) { + m_drop_delegate = DragDropTargetFactory::createDragDropTargetDelegate(); + m_drop_delegate->setImWindow(this); + } ImWindow(const std::string &name, std::optional default_size, std::optional min_size, std::optional max_size, ImGuiWindowClass window_class) : ImProcessLayer(name), m_default_size(default_size), m_min_size(min_size), - m_max_size(max_size), m_window_class(window_class) {} + m_max_size(max_size), m_window_class(window_class) { + m_drop_delegate = DragDropTargetFactory::createDragDropTargetDelegate(); + m_drop_delegate->setImWindow(this); + } ImWindow(const std::string &name, std::optional default_size, std::optional min_size, std::optional max_size, ImGuiWindowClass window_class, ImGuiWindowFlags flags) : ImProcessLayer(name), m_default_size(default_size), m_min_size(min_size), - m_max_size(max_size), m_window_class(window_class), m_flags(flags) {} + m_max_size(max_size), m_window_class(window_class), m_flags(flags) { + m_drop_delegate = DragDropTargetFactory::createDragDropTargetDelegate(); + m_drop_delegate->setImWindow(this); + } virtual ~ImWindow() = default; @@ -132,18 +152,20 @@ namespace Toolbox::UI { std::optional m_max_size = {}; private: - ImGuiID m_dockspace_id = std::numeric_limits::max(); + ImGuiID m_dockspace_id = std::numeric_limits::max(); bool m_is_docking_set_up = false; bool m_is_resized = false; bool m_is_repositioned = false; - bool m_is_new_icon = false; - ImVec2 m_icon_size = {}; - Buffer m_icon_data = {}; + bool m_is_new_icon = false; + ImVec2 m_icon_size = {}; + Buffer m_icon_data = {}; ImVec2 m_next_size = {}; ImVec2 m_next_pos = {}; + + RefPtr m_drop_delegate = nullptr; }; inline std::string ImWindowComponentTitle(const ImWindow &window_layer, diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 1e3b129f..98d90db7 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -22,6 +22,7 @@ #include "core/input/input.hpp" #include "dolphin/hook.hpp" #include "gui/application.hpp" +#include "gui/dragdrop/dragdropmanager.hpp" #include "gui/font.hpp" #include "gui/imgui_ext.hpp" #include "gui/logging/errors.hpp" @@ -169,6 +170,8 @@ namespace Toolbox { platform_io.Platform_CreateWindow = ImGui_ImplGlfw_CreateWindow_Ex; platform_io.Renderer_RenderWindow = ImGui_ImplOpenGL3_RenderWindow_Ex; + DragDropManager::instance().initialize(); + if (!m_settings_manager.initialize()) { TOOLBOX_ERROR("[INIT] Failed to initialize settings manager!"); } @@ -254,9 +257,19 @@ namespace Toolbox { m_dolphin_communicator.tKill(true); m_task_communicator.tKill(true); + DragDropManager::instance().shutdown(); + NFD_Quit(); } + void GUIApplication::onEvent(RefPtr ev) { + CoreApplication::onEvent(ev); + if (ev->getType() == EVENT_DROP) { + DragDropManager::instance().destroyDragAction( + DragDropManager::instance().getCurrentDragAction()); + } + } + RefPtr GUIApplication::findWindow(UUID64 uuid) { auto it = std::find_if(m_windows.begin(), m_windows.end(), [&uuid](const auto &window) { return window->getUUID() == uuid; }); diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index 56183593..1c802c5a 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -10,7 +10,6 @@ #include #define GLFW_EXPOSE_NATIVE_X11 #include - #endif namespace Toolbox { @@ -54,7 +53,7 @@ namespace Toolbox { return types; } - Result SystemClipboard::getText() { + Result SystemClipboard::getText() const { if (!OpenClipboard(nullptr)) { return make_clipboard_error("Failed to open the clipboard!"); } @@ -116,7 +115,7 @@ namespace Toolbox { return {}; } - Result SystemClipboard::getContent(const std::string &type) { + Result SystemClipboard::getContent(const std::string &type) const { if (!OpenClipboard(nullptr)) { return make_clipboard_error("Failed to open the clipboard!"); } diff --git a/src/gui/dragdrop/dragdropmanager.cpp b/src/gui/dragdrop/dragdropmanager.cpp index d5bdbae3..5b9a238d 100644 --- a/src/gui/dragdrop/dragdropmanager.cpp +++ b/src/gui/dragdrop/dragdropmanager.cpp @@ -1,17 +1,156 @@ #pragma once +#include "gui/dragdrop/dragdropmanager.hpp" +#include "core/clipboard.hpp" #include "core/memory.hpp" #include "core/mimedata/mimedata.hpp" #include "gui/dragdrop/dragaction.hpp" #include "gui/dragdrop/dropaction.hpp" -#include "gui/dragdrop/dragdropmanager.hpp" + +#ifdef TOOLBOX_PLATFORM_WINDOWS +#include +#include +#include +#include +#elif defined(TOOLBOX_PLATFORM_LINUX) +#endif + +static std::vector splitLines(std::string_view s) { + std::vector result; + size_t last_pos = 0; + size_t next_newline_pos = s.find('\n', 0); + while (next_newline_pos != std::string::npos) { + if (s[next_newline_pos - 1] == '\r') { + result.push_back(s.substr(last_pos, next_newline_pos - last_pos - 1)); + } else { + result.push_back(s.substr(last_pos, next_newline_pos - last_pos)); + } + last_pos = next_newline_pos + 1; + next_newline_pos = s.find('\n', last_pos); + } + if (last_pos < s.size()) { + if (s[s.size() - 1] == '\r') { + result.push_back(s.substr(last_pos, s.size() - last_pos - 1)); + } else { + result.push_back(s.substr(last_pos)); + } + } + return result; +} namespace Toolbox::UI { - - RefPtr DragDropManager::createDragAction() { - return make_referable(); + + RefPtr DragDropManager::createDragAction(UUID64 source_uuid, MimeData &&data) { + m_current_drag_action = make_referable(source_uuid); + m_current_drag_action->setPayload(data); + return m_current_drag_action; + } + + void DragDropManager::destroyDragAction(RefPtr action) { + m_current_drag_action.reset(); + } + +#ifdef TOOLBOX_PLATFORM_WINDOWS + bool DragDropManager::initialize() { return OleInitialize(nullptr) >= 0; } + + void DragDropManager::shutdown() { OleUninitialize(); } + + Result DragDropManager::createSystemDragDropSource(MimeData &&data) { + std::vector formats = + SystemClipboard::instance().getAvailableContentFormats().value_or( + std::vector()); + + if (std::find(formats.begin(), formats.end(), "text/uri-list") == formats.end()) { + return make_error("DRAG_DROP", "No paths available in mimedata"); + } + + std::string paths = data.get_urls().value_or(""); + + std::vector pidls; + std::vector lines = splitLines(paths); + + size_t next_newline_pos = 0; + for (const std::string_view &line : lines) { + if (line.empty()) { + continue; + } + + std::wstring wpath = std::wstring(line.begin(), line.end()); + + PIDLIST_ABSOLUTE pidl = ILCreateFromPathW(wpath.c_str()); + if (pidl == NULL) { + for (PIDLIST_ABSOLUTE pidl : pidls) { + ILFree(pidl); + } + return make_error("DRAG_DROP", "Failed to create PIDL from path"); + } + + pidls.push_back(pidl); + } + + IDataObject *data_object = nullptr; + { + HRESULT hr = SHCreateDataObject(NULL, static_cast(pidls.size()), (PCIDLIST_ABSOLUTE *)pidls.data(), + nullptr, IID_IDataObject, (void **)&data_object); + + for (PIDLIST_ABSOLUTE pidl : pidls) { + ILFree(pidl); + } + + if (FAILED(hr)) { + return make_error("DRAG_DROP", "Failed to create data object"); + } + } + + IDropSource *drop_source = nullptr; + { + HRESULT hr = CoCreateInstance(CLSID_DragDropHelper, nullptr, CLSCTX_INPROC_SERVER, + IID_IDropSource, (void **)&drop_source); + if (FAILED(hr)) { + data_object->Release(); + return make_error("DRAG_DROP", "Failed to create drop source"); + } + } + + DWORD effect; + { + HRESULT hr = DoDragDrop(data_object, drop_source, DROPEFFECT_COPY, &effect); + if (FAILED(hr)) { + drop_source->Release(); + data_object->Release(); + return make_error("DRAG_DROP", "Failed to perform drag drop operation"); + } + } + + m_data_object = data_object; + m_drop_source = drop_source; + return {}; + } + + Result DragDropManager::destroySystemDragDropSource() { + if (m_data_object) { + m_data_object->Release(); + } + if (m_drop_source) { + m_drop_source->Release(); + } + return {}; + } + +#elif defined(TOOLBOX_PLATFORM_LINUX) + + bool DragDropManager::initialize() { return false; } + + void DragDropManager::shutdown() {} + + Result DragDropManager::createSystemDragDropSource(MimeData &&data) { + return {}; + } + + Result DragDropManager::destroySystemDragDropSource() { + return {}; } - void DragDropManager::initialize() {} +#endif } // namespace Toolbox::UI \ No newline at end of file diff --git a/src/gui/dragdrop/target.cpp b/src/gui/dragdrop/target.cpp new file mode 100644 index 00000000..85ef9d9e --- /dev/null +++ b/src/gui/dragdrop/target.cpp @@ -0,0 +1,353 @@ +#include "gui/dragdrop/target.hpp" +#include "gui/application.hpp" +#include "gui/dragdrop/dragdropmanager.hpp" +#include "gui/event/dragevent.hpp" +#include "gui/event/dropevent.hpp" +#include "gui/window.hpp" + +namespace Toolbox::UI { + +#ifdef TOOLBOX_PLATFORM_WINDOWS + +#include +#include +#include +#include + + static MimeData createMimeDataFromDataObject(IDataObject *pDataObj) { + IEnumFORMATETC *enum_format_etc = nullptr; + { + HRESULT hr = pDataObj->EnumFormatEtc(DATADIR_GET, &enum_format_etc); + if (FAILED(hr)) { + TOOLBOX_ERROR_V("Failed to enumerate data formats: {}", hr); + return MimeData(); + } + } + + MimeData mime_data; + + FORMATETC format_etc; + while (enum_format_etc->Next(1, &format_etc, nullptr) == S_OK) { + if (format_etc.cfFormat == CF_HDROP) { + STGMEDIUM stg_medium; + { + HRESULT hr = pDataObj->GetData(&format_etc, &stg_medium); + if (FAILED(hr)) { + TOOLBOX_ERROR_V("Failed to get data for format: {}", hr); + return MimeData(); + } + } + + std::string uri_paths; + + HDROP hdrop = (HDROP)GlobalLock(stg_medium.hGlobal); + + if (hdrop) { + UINT num_files = DragQueryFile(hdrop, 0xFFFFFFFF, nullptr, 0); + for (UINT i = 0; i < num_files; ++i) { + TCHAR file_path[MAX_PATH]; + if (UINT length = DragQueryFile(hdrop, i, file_path, MAX_PATH)) { + uri_paths += + std::format("file:///{}\n", std::string(file_path, length)); + } + } + } + + GlobalUnlock(stg_medium.hGlobal); + + mime_data.set_urls(uri_paths); + } else if (format_etc.cfFormat == CF_UNICODETEXT) { + STGMEDIUM stg_medium; + { + HRESULT hr = pDataObj->GetData(&format_etc, &stg_medium); + if (FAILED(hr)) { + TOOLBOX_ERROR_V("Failed to get data for format: {}", hr); + return MimeData(); + } + } + + std::string text_data; + + if ((format_etc.tymed & TYMED_HGLOBAL) == TYMED_HGLOBAL) { + LPWSTR text = (LPWSTR)GlobalLock(stg_medium.hGlobal); + if (text) { + std::wstring wdata = std::wstring(text); + text_data = std::string(wdata.begin(), wdata.end()); + GlobalUnlock(stg_medium.hGlobal); + } + } + + mime_data.set_text(text_data); + } else if (format_etc.cfFormat == CF_TEXT) { + STGMEDIUM stg_medium; + { + HRESULT hr = pDataObj->GetData(&format_etc, &stg_medium); + if (FAILED(hr)) { + TOOLBOX_ERROR_V("Failed to get data for format: {}", hr); + return MimeData(); + } + } + + std::string text_data; + + if (format_etc.tymed == TYMED_HGLOBAL) { + LPSTR text = (LPSTR)GlobalLock(stg_medium.hGlobal); + if (text) { + text_data = text; + GlobalUnlock(stg_medium.hGlobal); + } + } + + mime_data.set_text(text_data); + } + } + + return mime_data; + } + + class WindowsDragDropTargetDelegate; + + class WindowsDragDropTarget : public IDropTarget { + public: + WindowsDragDropTarget(WindowsDragDropTargetDelegate *delegate) + : m_delegate(delegate), m_refCount() {} + + ~WindowsDragDropTarget() = default; + + // IUnknown Methods + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject) override { + if (riid == IID_IUnknown || riid == IID_IDropTarget) { + *ppvObject = static_cast(this); + AddRef(); + return S_OK; + } + *ppvObject = nullptr; + return E_NOINTERFACE; + } + + ULONG STDMETHODCALLTYPE AddRef() override { return InterlockedIncrement(&m_refCount); } + + ULONG STDMETHODCALLTYPE Release() override { + ULONG refCount = InterlockedDecrement(&m_refCount); + if (refCount == 0) { + delete this; + } + return refCount; + } + + // IDropTarget + HRESULT STDMETHODCALLTYPE DragEnter(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, + DWORD *pdwEffect) override; + HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect) override; + HRESULT STDMETHODCALLTYPE DragLeave() override; + HRESULT STDMETHODCALLTYPE Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, + DWORD *pdwEffect) override; + + private: + WindowsDragDropTargetDelegate *m_delegate = nullptr; + LONG m_refCount; // Reference count for COM object + }; + + class WindowsDragDropTargetDelegate : public IDragDropTargetDelegate { + public: + friend class WindowsDragDropTarget; + + WindowsDragDropTargetDelegate() = default; + ~WindowsDragDropTargetDelegate() override { delete m_target; } + + void setImWindow(void *window) override { m_window = static_cast(window); } + + void onDragEnter(RefPtr action) override; + void onDragLeave(RefPtr action) override; + void onDragMove(RefPtr action) override; + void onDrop(RefPtr action) override; + + bool initializeForWindow(Platform::LowWindow window) override; + void shutdownForWindow(Platform::LowWindow window) override; + + private: + Platform::LowWindow m_window_handle = nullptr; + ImWindow *m_window = nullptr; + WindowsDragDropTarget *m_target = nullptr; + }; + +#elif defined(TOOLBOX_PLATFORM_LINUX) + class LinuxDragDropTargetDelegate : public IDragDropTargetDelegate { + public: + LinuxDragDropTargetDelegate() {} + ~LinuxDragDropTargetDelegate() override = default; + + void setImWindow(void *window) override { m_window = static_cast(window); } + + void onDragEnter(RefPtr action) override; + void onDragLeave(RefPtr action) override; + void onDragMove(RefPtr action) override; + void onDrop(RefPtr action) override; + + bool initializeForWindow(Platform::LowWindow window) override; + void shutdownForWindow(Platform::LowWindow window) override; + + private: + Platform::LowWindow m_window_handle = nullptr; + ImWindow *m_window = nullptr; + }; +#endif + + RefPtr DragDropTargetFactory::createDragDropTargetDelegate() { +#ifdef TOOLBOX_PLATFORM_WINDOWS + return make_referable(); +#elif defined(TOOLBOX_PLATFORM_LINUX) + return make_referable(); +#else + return nullptr; +#endif + } + +#ifdef TOOLBOX_PLATFORM_WINDOWS + + HRESULT __stdcall WindowsDragDropTarget::DragEnter(IDataObject *pDataObj, DWORD grfKeyState, + POINTL pt, DWORD *pdwEffect) { + RefPtr action = DragDropManager::instance().getCurrentDragAction(); + if (!action) { + MimeData mime_data = createMimeDataFromDataObject(pDataObj); + action = DragDropManager::instance().createDragAction(0, + std::move(mime_data)); + } + + action->setHotSpot(ImVec2(pt.x, pt.y)); + action->setTargetUUID(m_delegate->m_window->getUUID()); + + DropTypes supported_drop_types = DropType::ACTION_NONE; + if ((*pdwEffect & DROPEFFECT_COPY)) { + supported_drop_types |= DropType::ACTION_COPY; + } + if ((*pdwEffect & DROPEFFECT_MOVE)) { + supported_drop_types |= DropType::ACTION_MOVE; + } + if ((*pdwEffect & DROPEFFECT_LINK)) { + supported_drop_types |= DropType::ACTION_LINK; + } + action->setSupportedDropTypes(supported_drop_types); + + m_delegate->onDragEnter(action); + return S_OK; + } + + HRESULT __stdcall WindowsDragDropTarget::DragOver(DWORD grfKeyState, POINTL pt, + DWORD *pdwEffect) { + RefPtr action = DragDropManager::instance().getCurrentDragAction(); + action->setHotSpot(ImVec2(pt.x, pt.y)); + action->setTargetUUID(m_delegate->m_window->getUUID()); + m_delegate->onDragMove(action); + return S_OK; + } + + HRESULT __stdcall WindowsDragDropTarget::DragLeave() { + RefPtr action = DragDropManager::instance().getCurrentDragAction(); + action->setTargetUUID(0); + m_delegate->onDragLeave(action); + return S_OK; + } + + HRESULT __stdcall WindowsDragDropTarget::Drop(IDataObject *pDataObj, DWORD grfKeyState, + POINTL pt, DWORD *pdwEffect) { + RefPtr action = DragDropManager::instance().getCurrentDragAction(); + if (!action) { + MimeData mime_data = createMimeDataFromDataObject(pDataObj); + action = DragDropManager::instance().createDragAction(0, std::move(mime_data)); + } + + action->setHotSpot(ImVec2(pt.x, pt.y)); + action->setTargetUUID(m_delegate->m_window->getUUID()); + + DropTypes supported_drop_types = DropType::ACTION_NONE; + if ((*pdwEffect & DROPEFFECT_COPY)) { + supported_drop_types |= DropType::ACTION_COPY; + } + if ((*pdwEffect & DROPEFFECT_MOVE)) { + supported_drop_types |= DropType::ACTION_MOVE; + } + if ((*pdwEffect & DROPEFFECT_LINK)) { + supported_drop_types |= DropType::ACTION_LINK; + } + action->setSupportedDropTypes(supported_drop_types); + + m_delegate->onDrop(action); + return S_OK; + } + + void WindowsDragDropTargetDelegate::onDragEnter(RefPtr action) { + double mouse_x, mouse_y; + Input::GetMouseViewportPosition(mouse_x, mouse_y); + + GUIApplication::instance().dispatchEvent(EVENT_DRAG_ENTER, mouse_x, + mouse_y, action); + } + + void WindowsDragDropTargetDelegate::onDragLeave(RefPtr action) { + double mouse_x, mouse_y; + Input::GetMouseViewportPosition(mouse_x, mouse_y); + + GUIApplication::instance().dispatchEvent(EVENT_DRAG_LEAVE, mouse_x, + mouse_y, action); + } + + void WindowsDragDropTargetDelegate::onDragMove(RefPtr action) { + double mouse_x, mouse_y; + Input::GetMouseViewportPosition(mouse_x, mouse_y); + + GUIApplication::instance().dispatchEvent(EVENT_DRAG_MOVE, mouse_x, mouse_y, + action); + } + + void WindowsDragDropTargetDelegate::onDrop(RefPtr action) { + double mouse_x, mouse_y; + Input::GetMouseViewportPosition(mouse_x, mouse_y); + + GUIApplication::instance().dispatchEvent(ImVec2(mouse_x, mouse_y), action); + } + + bool WindowsDragDropTargetDelegate::initializeForWindow(Platform::LowWindow window) { + if (window == m_window_handle) { + return window != NULL; + } + + if (m_window_handle != NULL) { + RevokeDragDrop(m_window_handle); + } + + m_target = new WindowsDragDropTarget(this); + + HRESULT hr = RegisterDragDrop(window, m_target); + if (FAILED(hr)) { + TOOLBOX_ERROR("Failed to register drag drop target"); + return false; + } + + m_window_handle = window; + return true; + } + + void WindowsDragDropTargetDelegate::shutdownForWindow(Platform::LowWindow window) { + if (!window) { + return; + } + + RevokeDragDrop(window); + } + +#elif defined(TOOLBOX_PLATFORM_LINUX) + + void LinuxDragDropTargetDelegate::onDragEnter(RefPtr action) {} + + void LinuxDragDropTargetDelegate::onDragLeave(RefPtr action) {} + + void LinuxDragDropTargetDelegate::onDragMove(RefPtr action) {} + + void LinuxDragDropTargetDelegate::onDrop(RefPtr action) {} + + bool LinuxDragDropTargetDelegate::initializeWindow(Platform::LowWindow window) { return false; } + +#endif + +} // namespace Toolbox::UI \ No newline at end of file diff --git a/src/gui/event/dragevent.cpp b/src/gui/event/dragevent.cpp index 7f5611b3..0b5ef8f5 100644 --- a/src/gui/event/dragevent.cpp +++ b/src/gui/event/dragevent.cpp @@ -2,9 +2,9 @@ namespace Toolbox::UI { - DragEvent::DragEvent(TypeID type, float pos_x, float pos_y, DragAction &&action) - : BaseEvent(action.getTargetUUID().value(), type), m_screen_pos_x(pos_x), - m_screen_pos_y(pos_y), m_drag_action(std::move(action)) {} + DragEvent::DragEvent(TypeID type, float pos_x, float pos_y, RefPtr action) + : BaseEvent(action->getTargetUUID().value(), type), m_screen_pos_x(pos_x), + m_screen_pos_y(pos_y), m_drag_action(action) {} ScopePtr DragEvent::clone(bool deep) const { return make_scoped(*this); diff --git a/src/gui/event/dropevent.cpp b/src/gui/event/dropevent.cpp index f74df1c1..ebbed48d 100644 --- a/src/gui/event/dropevent.cpp +++ b/src/gui/event/dropevent.cpp @@ -1,14 +1,10 @@ #include "gui/event/dropevent.hpp" namespace Toolbox::UI { - DropEvent::DropEvent(const ImVec2 &pos, DropType drop_type, UUID64 source_uuid, - UUID64 target_uuid, MimeData &&data) - : BaseEvent(target_uuid, EVENT_DROP), m_screen_pos(pos), - m_drop_type(drop_type), m_source_id(source_uuid), m_mime_data(std::move(data)) {} - DropEvent::DropEvent(const ImVec2 &pos, DropType drop_type, const DragAction &action) - : BaseEvent(action.getTargetUUID().value(), EVENT_DROP), m_screen_pos(pos), - m_drop_type(drop_type), m_source_id(action.getSourceUUID()) {} + DropEvent::DropEvent(const ImVec2 &pos, RefPtr action) + : BaseEvent(action->getTargetUUID().value(), EVENT_DROP), m_screen_pos(pos), + m_drag_action(action) {} ScopePtr DropEvent::clone(bool deep) const { return make_scoped(*this); diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index e25854f2..0d487e56 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -260,6 +260,7 @@ namespace Toolbox::UI { void ProjectViewWindow::onDropEvent(RefPtr ev) { actionPasteIntoIndex(m_view_index, ev->getMimeData()); + ev->accept(); } std::vector splitLines(std::string_view s) { @@ -479,7 +480,7 @@ namespace Toolbox::UI { #ifdef TOOLBOX_PLATFORM_LINUX copied_paths += "file://"; #elif defined TOOLBOX_PLATFORM_WINDOWS - copied_paths += "file:///" + copied_paths += "file:///"; #endif copied_paths += m_file_system_model->getPath(index).string(); #ifdef TOOLBOX_PLATFORM_LINUX diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 8ecb176e..695a4230 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -1,5 +1,6 @@ #include "gui/window.hpp" #include "gui/application.hpp" +#include "gui/dragdrop/dragdropmanager.hpp" #include "gui/event/dropevent.hpp" #include "gui/util.hpp" @@ -12,6 +13,9 @@ #include #include +#define GLFW_EXPOSE_NATIVE_WIN32 +#include + namespace Toolbox::UI { void ImWindow::onRenderDockspace() { @@ -185,6 +189,7 @@ namespace Toolbox::UI { glfwSetWindowUserPointer(window, this); glfwSetDropCallback(static_cast(viewport->PlatformHandle), privDropCallback); + m_drop_delegate->initializeForWindow((Platform::LowWindow)glfwGetWin32Window(window)); } if ((flags_ & ImGuiWindowFlags_NoBackground)) { @@ -262,6 +267,7 @@ namespace Toolbox::UI { ImWindow *self = static_cast(glfwGetWindowUserPointer(window)); if (!self) { TOOLBOX_ERROR("[ImWindow] Attempted drop operation on NULL user pointer!"); + return; } std::string uri_list; @@ -274,8 +280,11 @@ namespace Toolbox::UI { MimeData &&data = MimeData(); data.set_urls(uri_list); + + RefPtr action = DragDropManager::instance().createDragAction(self->getUUID(), std::move(data)); + GUIApplication::instance().dispatchEvent( - ImVec2(mouse_x, mouse_y), DropType::ACTION_COPY, 0, self->getUUID(), std::move(data)); + ImVec2(mouse_x, mouse_y), action); } } // namespace Toolbox::UI \ No newline at end of file From c713484853af8d7236a462c4d739190fea90aa50 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Sat, 5 Oct 2024 12:21:47 -0500 Subject: [PATCH 076/129] More progress, gotta fix size and position updates --- include/gui/application.hpp | 4 ++ include/gui/dragdrop/target.hpp | 5 +- include/gui/window.hpp | 32 ++-------- src/gui/application.cpp | 9 +++ src/gui/dragdrop/target.cpp | 102 ++++++++++++++++++++------------ src/gui/window.cpp | 6 +- 6 files changed, 88 insertions(+), 70 deletions(-) diff --git a/include/gui/application.hpp b/include/gui/application.hpp index 2f985241..aceaf1da 100644 --- a/include/gui/application.hpp +++ b/include/gui/application.hpp @@ -138,6 +138,8 @@ namespace Toolbox { ProjectManager &getProjectManager() { return m_project_manager; } const ProjectManager &getProjectManager() const { return m_project_manager; } + bool registerDragDropTarget(Platform::LowWindow window); + void deregisterDragDropTarget(Platform::LowWindow window); void registerDolphinOverlay(UUID64 scene_uuid, const std::string &name, SceneWindow::render_layer_cb cb); @@ -193,6 +195,8 @@ namespace Toolbox { std::queue> m_windows_to_add; bool m_windows_processing = false; + ScopePtr m_drag_drop_target_delegate; + std::unordered_map m_docked_map; ImGuiID m_dockspace_id; bool m_dockspace_built; diff --git a/include/gui/dragdrop/target.hpp b/include/gui/dragdrop/target.hpp index 76ca2a70..25192404 100644 --- a/include/gui/dragdrop/target.hpp +++ b/include/gui/dragdrop/target.hpp @@ -10,9 +10,6 @@ namespace Toolbox::UI { public: virtual ~IDragDropTargetDelegate() = default; - // void * for circular ref - virtual void setImWindow(void *window) = 0; - virtual void onDragEnter(RefPtr action) = 0; virtual void onDragLeave(RefPtr action) = 0; virtual void onDragMove(RefPtr action) = 0; @@ -24,7 +21,7 @@ namespace Toolbox::UI { class DragDropTargetFactory { public: - static RefPtr createDragDropTargetDelegate(); + static ScopePtr createDragDropTargetDelegate(); }; } // namespace Toolbox::UI \ No newline at end of file diff --git a/include/gui/window.hpp b/include/gui/window.hpp index 087b6b90..7ab8559f 100644 --- a/include/gui/window.hpp +++ b/include/gui/window.hpp @@ -33,44 +33,26 @@ namespace Toolbox::UI { virtual void onRenderBody(TimeStep delta_time) {} public: - explicit ImWindow(const std::string &name) : ImProcessLayer(name) { - m_drop_delegate = DragDropTargetFactory::createDragDropTargetDelegate(); - m_drop_delegate->setImWindow(this); - } + explicit ImWindow(const std::string &name) : ImProcessLayer(name) {} ImWindow(const std::string &name, std::optional default_size) - : ImProcessLayer(name), m_default_size(default_size) { - m_drop_delegate = DragDropTargetFactory::createDragDropTargetDelegate(); - m_drop_delegate->setImWindow(this); - } + : ImProcessLayer(name), m_default_size(default_size) {} ImWindow(const std::string &name, std::optional min_size, std::optional max_size) - : ImProcessLayer(name), m_min_size(min_size), m_max_size(max_size) { - m_drop_delegate = DragDropTargetFactory::createDragDropTargetDelegate(); - m_drop_delegate->setImWindow(this); - } + : ImProcessLayer(name), m_min_size(min_size), m_max_size(max_size) {} ImWindow(const std::string &name, std::optional default_size, std::optional min_size, std::optional max_size) : ImProcessLayer(name), m_default_size(default_size), m_min_size(min_size), - m_max_size(max_size) { - m_drop_delegate = DragDropTargetFactory::createDragDropTargetDelegate(); - m_drop_delegate->setImWindow(this); - } + m_max_size(max_size) {} ImWindow(const std::string &name, std::optional default_size, std::optional min_size, std::optional max_size, ImGuiWindowClass window_class) : ImProcessLayer(name), m_default_size(default_size), m_min_size(min_size), - m_max_size(max_size), m_window_class(window_class) { - m_drop_delegate = DragDropTargetFactory::createDragDropTargetDelegate(); - m_drop_delegate->setImWindow(this); - } + m_max_size(max_size), m_window_class(window_class) {} ImWindow(const std::string &name, std::optional default_size, std::optional min_size, std::optional max_size, ImGuiWindowClass window_class, ImGuiWindowFlags flags) : ImProcessLayer(name), m_default_size(default_size), m_min_size(min_size), - m_max_size(max_size), m_window_class(window_class), m_flags(flags) { - m_drop_delegate = DragDropTargetFactory::createDragDropTargetDelegate(); - m_drop_delegate->setImWindow(this); - } + m_max_size(max_size), m_window_class(window_class), m_flags(flags) {} virtual ~ImWindow() = default; @@ -164,8 +146,6 @@ namespace Toolbox::UI { ImVec2 m_next_size = {}; ImVec2 m_next_pos = {}; - - RefPtr m_drop_delegate = nullptr; }; inline std::string ImWindowComponentTitle(const ImWindow &window_layer, diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 98d90db7..4bdef572 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -171,6 +171,7 @@ namespace Toolbox { platform_io.Renderer_RenderWindow = ImGui_ImplOpenGL3_RenderWindow_Ex; DragDropManager::instance().initialize(); + m_drag_drop_target_delegate = DragDropTargetFactory::createDragDropTargetDelegate(); if (!m_settings_manager.initialize()) { TOOLBOX_ERROR("[INIT] Failed to initialize settings manager!"); @@ -292,6 +293,14 @@ namespace Toolbox { return result; } + bool GUIApplication::registerDragDropTarget(Platform::LowWindow window) { + return m_drag_drop_target_delegate->initializeForWindow(window); + } + + void GUIApplication::deregisterDragDropTarget(Platform::LowWindow window) { + m_drag_drop_target_delegate->shutdownForWindow(window); + } + void GUIApplication::registerDolphinOverlay(UUID64 scene_uuid, const std::string &name, SceneWindow::render_layer_cb cb) { RefPtr scene_window = ref_cast(findWindow(scene_uuid)); diff --git a/src/gui/dragdrop/target.cpp b/src/gui/dragdrop/target.cpp index 85ef9d9e..714ec20c 100644 --- a/src/gui/dragdrop/target.cpp +++ b/src/gui/dragdrop/target.cpp @@ -7,6 +7,19 @@ namespace Toolbox::UI { + static UUID64 searchDropTarget(const ImVec2 &mouse_pos) { + std::vector> windows = GUIApplication::instance().getWindows(); + + for (RefPtr window : windows) { + ImRect rect = {window->getPos(), window->getPos() + window->getSize()}; + if (rect.Contains(mouse_pos)) { + return window->getUUID(); + } + } + + return 0; + } + #ifdef TOOLBOX_PLATFORM_WINDOWS #include @@ -90,7 +103,7 @@ namespace Toolbox::UI { std::string text_data; - if (format_etc.tymed == TYMED_HGLOBAL) { + if ((format_etc.tymed & TYMED_HGLOBAL) == TYMED_HGLOBAL) { LPSTR text = (LPSTR)GlobalLock(stg_medium.hGlobal); if (text) { text_data = text; @@ -109,11 +122,16 @@ namespace Toolbox::UI { class WindowsDragDropTarget : public IDropTarget { public: - WindowsDragDropTarget(WindowsDragDropTargetDelegate *delegate) - : m_delegate(delegate), m_refCount() {} + WindowsDragDropTarget(WindowsDragDropTargetDelegate *delegate, Platform::LowWindow window) + : m_delegate(delegate), m_window_handle(window), m_refCount() {} ~WindowsDragDropTarget() = default; + Platform::LowWindow GetWindowHandle() const { return m_window_handle; } + + HRESULT Initialize() { return RegisterDragDrop(m_window_handle, this); } + HRESULT Shutdown() { return RevokeDragDrop(m_window_handle); } + // IUnknown Methods HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject) override { if (riid == IID_IUnknown || riid == IID_IDropTarget) { @@ -145,6 +163,7 @@ namespace Toolbox::UI { private: WindowsDragDropTargetDelegate *m_delegate = nullptr; + Platform::LowWindow m_window_handle = nullptr; LONG m_refCount; // Reference count for COM object }; @@ -152,10 +171,8 @@ namespace Toolbox::UI { public: friend class WindowsDragDropTarget; - WindowsDragDropTargetDelegate() = default; - ~WindowsDragDropTargetDelegate() override { delete m_target; } - - void setImWindow(void *window) override { m_window = static_cast(window); } + WindowsDragDropTargetDelegate() = default; + ~WindowsDragDropTargetDelegate() override { m_targets.clear(); } void onDragEnter(RefPtr action) override; void onDragLeave(RefPtr action) override; @@ -166,9 +183,7 @@ namespace Toolbox::UI { void shutdownForWindow(Platform::LowWindow window) override; private: - Platform::LowWindow m_window_handle = nullptr; - ImWindow *m_window = nullptr; - WindowsDragDropTarget *m_target = nullptr; + std::vector m_targets = {}; }; #elif defined(TOOLBOX_PLATFORM_LINUX) @@ -177,8 +192,6 @@ namespace Toolbox::UI { LinuxDragDropTargetDelegate() {} ~LinuxDragDropTargetDelegate() override = default; - void setImWindow(void *window) override { m_window = static_cast(window); } - void onDragEnter(RefPtr action) override; void onDragLeave(RefPtr action) override; void onDragMove(RefPtr action) override; @@ -189,15 +202,14 @@ namespace Toolbox::UI { private: Platform::LowWindow m_window_handle = nullptr; - ImWindow *m_window = nullptr; }; #endif - RefPtr DragDropTargetFactory::createDragDropTargetDelegate() { + ScopePtr DragDropTargetFactory::createDragDropTargetDelegate() { #ifdef TOOLBOX_PLATFORM_WINDOWS - return make_referable(); + return make_scoped(); #elif defined(TOOLBOX_PLATFORM_LINUX) - return make_referable(); + return make_scoped(); #else return nullptr; #endif @@ -210,12 +222,10 @@ namespace Toolbox::UI { RefPtr action = DragDropManager::instance().getCurrentDragAction(); if (!action) { MimeData mime_data = createMimeDataFromDataObject(pDataObj); - action = DragDropManager::instance().createDragAction(0, - std::move(mime_data)); + action = DragDropManager::instance().createDragAction(0, std::move(mime_data)); } action->setHotSpot(ImVec2(pt.x, pt.y)); - action->setTargetUUID(m_delegate->m_window->getUUID()); DropTypes supported_drop_types = DropType::ACTION_NONE; if ((*pdwEffect & DROPEFFECT_COPY)) { @@ -237,14 +247,12 @@ namespace Toolbox::UI { DWORD *pdwEffect) { RefPtr action = DragDropManager::instance().getCurrentDragAction(); action->setHotSpot(ImVec2(pt.x, pt.y)); - action->setTargetUUID(m_delegate->m_window->getUUID()); m_delegate->onDragMove(action); return S_OK; } HRESULT __stdcall WindowsDragDropTarget::DragLeave() { RefPtr action = DragDropManager::instance().getCurrentDragAction(); - action->setTargetUUID(0); m_delegate->onDragLeave(action); return S_OK; } @@ -258,7 +266,6 @@ namespace Toolbox::UI { } action->setHotSpot(ImVec2(pt.x, pt.y)); - action->setTargetUUID(m_delegate->m_window->getUUID()); DropTypes supported_drop_types = DropType::ACTION_NONE; if ((*pdwEffect & DROPEFFECT_COPY)) { @@ -280,6 +287,9 @@ namespace Toolbox::UI { double mouse_x, mouse_y; Input::GetMouseViewportPosition(mouse_x, mouse_y); + ImVec2 mouse_pos = ImVec2(mouse_x, mouse_y); + action->setTargetUUID(searchDropTarget(mouse_pos)); + GUIApplication::instance().dispatchEvent(EVENT_DRAG_ENTER, mouse_x, mouse_y, action); } @@ -288,6 +298,9 @@ namespace Toolbox::UI { double mouse_x, mouse_y; Input::GetMouseViewportPosition(mouse_x, mouse_y); + ImVec2 mouse_pos = ImVec2(mouse_x, mouse_y); + action->setTargetUUID(searchDropTarget(mouse_pos)); + GUIApplication::instance().dispatchEvent(EVENT_DRAG_LEAVE, mouse_x, mouse_y, action); } @@ -296,6 +309,9 @@ namespace Toolbox::UI { double mouse_x, mouse_y; Input::GetMouseViewportPosition(mouse_x, mouse_y); + ImVec2 mouse_pos = ImVec2(mouse_x, mouse_y); + action->setTargetUUID(searchDropTarget(mouse_pos)); + GUIApplication::instance().dispatchEvent(EVENT_DRAG_MOVE, mouse_x, mouse_y, action); } @@ -304,36 +320,48 @@ namespace Toolbox::UI { double mouse_x, mouse_y; Input::GetMouseViewportPosition(mouse_x, mouse_y); - GUIApplication::instance().dispatchEvent(ImVec2(mouse_x, mouse_y), action); + ImVec2 mouse_pos = ImVec2(mouse_x, mouse_y); + action->setTargetUUID(searchDropTarget(mouse_pos)); + + GUIApplication::instance().dispatchEvent(mouse_pos, action); } bool WindowsDragDropTargetDelegate::initializeForWindow(Platform::LowWindow window) { - if (window == m_window_handle) { - return window != NULL; + if (std::find_if(m_targets.begin(), m_targets.end(), + [window](WindowsDragDropTarget *target) { + return target->GetWindowHandle() == window; + }) != m_targets.end()) { + return true; } - if (m_window_handle != NULL) { - RevokeDragDrop(m_window_handle); - } - - m_target = new WindowsDragDropTarget(this); - - HRESULT hr = RegisterDragDrop(window, m_target); - if (FAILED(hr)) { - TOOLBOX_ERROR("Failed to register drag drop target"); + WindowsDragDropTarget *target = new WindowsDragDropTarget(this, window); + if (FAILED(target->Initialize())) { + TOOLBOX_ERROR("Failed to initialize drag drop target"); + delete target; return false; } - m_window_handle = window; + m_targets.push_back(target); return true; } void WindowsDragDropTargetDelegate::shutdownForWindow(Platform::LowWindow window) { - if (!window) { + + auto target_it = std::find_if(m_targets.begin(), m_targets.end(), + [window](WindowsDragDropTarget *target) { + return target->GetWindowHandle() == window; + }); + if (target_it == m_targets.end()) { return; } - RevokeDragDrop(window); + WindowsDragDropTarget *target = *target_it; + if (FAILED(target->Shutdown())) { + TOOLBOX_ERROR("Failed to shutdown drag drop target"); + } + + m_targets.erase(target_it); + delete target; } #elif defined(TOOLBOX_PLATFORM_LINUX) diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 695a4230..158a2cef 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -187,9 +187,9 @@ namespace Toolbox::UI { GLFWwindow *window = static_cast(viewport->PlatformHandle); if (window) { glfwSetWindowUserPointer(window, this); - glfwSetDropCallback(static_cast(viewport->PlatformHandle), - privDropCallback); - m_drop_delegate->initializeForWindow((Platform::LowWindow)glfwGetWin32Window(window)); + /*glfwSetDropCallback(static_cast(viewport->PlatformHandle), + privDropCallback);*/ + GUIApplication::instance().registerDragDropTarget((Platform::LowWindow)glfwGetWin32Window(window)); } if ((flags_ & ImGuiWindowFlags_NoBackground)) { From 608daaa8b49021fa4d6a44ee3de54fded95dff46 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Sat, 5 Oct 2024 16:22:34 -0500 Subject: [PATCH 077/129] Fix compile errors --- include/core/clipboard.hpp | 2 +- src/gui/clipboard.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/core/clipboard.hpp b/include/core/clipboard.hpp index e6c97a5a..468b1b1c 100644 --- a/include/core/clipboard.hpp +++ b/include/core/clipboard.hpp @@ -50,7 +50,7 @@ namespace Toolbox { static std::string MimeForFormat(UINT format); private: - std::unordered_map m_mime_to_format; + mutable std::unordered_map m_mime_to_format; #elif defined(TOOLBOX_PLATFORM_LINUX) // The reason this isn't private/protected is actually kind of // dumb. It needs to be accessed by handleSelectionRequest, diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index 03995385..d15f6f01 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -54,7 +54,7 @@ namespace Toolbox { return types; } - Result SystemClipboard::getText() { + Result SystemClipboard::getText() const { if (!OpenClipboard(nullptr)) { return make_clipboard_error("Failed to open the clipboard!"); } @@ -116,7 +116,7 @@ namespace Toolbox { return {}; } - Result SystemClipboard::getContent(const std::string &type) { + Result SystemClipboard::getContent(const std::string &type) const { if (!OpenClipboard(nullptr)) { return make_clipboard_error("Failed to open the clipboard!"); } From 9ae5a8ad7bb1d88cff7113b8663b48c46fe17695 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Sat, 5 Oct 2024 23:05:01 -0500 Subject: [PATCH 078/129] Improve size/pos update logic and practically finish windows integration --- include/gui/window.hpp | 15 ++++---- src/gui/dragdrop/target.cpp | 4 +++ src/gui/project/window.cpp | 9 +++-- src/gui/window.cpp | 68 ++++++++++++++++++++++++++----------- 4 files changed, 65 insertions(+), 31 deletions(-) diff --git a/include/gui/window.hpp b/include/gui/window.hpp index 7ab8559f..221ddff1 100644 --- a/include/gui/window.hpp +++ b/include/gui/window.hpp @@ -73,14 +73,8 @@ namespace Toolbox::UI { return flags_; } - [[nodiscard]] void setSize(const ImVec2 &size) noexcept override { - m_next_size = size; - m_is_resized = true; - } - [[nodiscard]] void setPos(const ImVec2 &pos) noexcept override { - m_next_pos = pos; - m_is_repositioned = true; - } + void setSize(const ImVec2 &size) noexcept override; + void setPos(const ImVec2 &pos) noexcept override; void setIcon(const std::string &icon_name); void setIcon(Buffer &&icon_data, const ImVec2 &icon_size); @@ -144,8 +138,13 @@ namespace Toolbox::UI { ImVec2 m_icon_size = {}; Buffer m_icon_data = {}; + ImVec2 m_prev_size = {}; + ImVec2 m_prev_pos = {}; + ImVec2 m_next_size = {}; ImVec2 m_next_pos = {}; + + bool m_first_render = true; }; inline std::string ImWindowComponentTitle(const ImWindow &window_layer, diff --git a/src/gui/dragdrop/target.cpp b/src/gui/dragdrop/target.cpp index 714ec20c..3b41eff8 100644 --- a/src/gui/dragdrop/target.cpp +++ b/src/gui/dragdrop/target.cpp @@ -41,6 +41,10 @@ namespace Toolbox::UI { FORMATETC format_etc; while (enum_format_etc->Next(1, &format_etc, nullptr) == S_OK) { + if ((format_etc.dwAspect & DVASPECT_CONTENT) == 0) { + continue; + } + if (format_etc.cfFormat == CF_HDROP) { STGMEDIUM stg_medium; { diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 0d487e56..f922eb58 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -248,9 +248,12 @@ namespace Toolbox::UI { return true; } - void ProjectViewWindow::onAttach() { buildContextMenu(); } + void ProjectViewWindow::onAttach() { + ImWindow::onAttach(); + buildContextMenu(); + } - void ProjectViewWindow::onDetach() {} + void ProjectViewWindow::onDetach() { ImWindow::onDetach(); } void ProjectViewWindow::onImGuiUpdate(TimeStep delta_time) {} @@ -277,7 +280,7 @@ namespace Toolbox::UI { next_newline_pos = s.find('\n', last_pos); } if (last_pos < s.size()) { - if (s[s.size()-1] == '\r') { + if (s[s.size() - 1] == '\r') { result.push_back(s.substr(last_pos, s.size() - last_pos - 1)); } else { result.push_back(s.substr(last_pos)); diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 158a2cef..70eb4a29 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -32,6 +32,21 @@ namespace Toolbox::UI { } } + void ImWindow::setSize(const ImVec2 &size) noexcept { + if (size == getSize()) { + return; + } + GUIApplication::instance().dispatchEvent(getUUID(), EVENT_WINDOW_RESIZE, + size); + } + void ImWindow::setPos(const ImVec2 &pos) noexcept { + if (pos == getPos()) { + return; + } + GUIApplication::instance().dispatchEvent(getUUID(), EVENT_WINDOW_MOVE, + pos); + } + void ImWindow::setIcon(const std::string &icon_name) { ResourceManager &res_manager = GUIApplication::instance().getResourceManager(); UUID64 icon_dir = res_manager.getResourcePathUUID("Images/Icons"); @@ -140,8 +155,8 @@ namespace Toolbox::UI { bool was_open = is_open; if (is_open) { - ImVec2 pos = getPos(); - ImVec2 size = getSize(); + m_prev_pos = getPos(); + m_prev_size = getSize(); ImVec2 default_min = {0, 0}; ImVec2 default_max = {FLT_MAX, FLT_MAX}; @@ -159,30 +174,20 @@ namespace Toolbox::UI { flags_ |= ImGuiWindowFlags_UnsavedDocument; } - // Establish window constraints - if (window) { - if (size != m_next_size && m_is_resized) { - if (m_next_size.x >= 0.0f && m_next_size.y >= 0.0f) { - ImGui::SetNextWindowSize(size); - GUIApplication::instance().dispatchEvent( - getUUID(), EVENT_WINDOW_RESIZE, m_next_size); - } - m_is_resized = false; - } - if (pos != m_next_pos && m_is_repositioned) { - ImGui::SetNextWindowPos(m_next_pos); - GUIApplication::instance().dispatchEvent( - getUUID(), EVENT_WINDOW_MOVE, m_next_pos); - m_is_repositioned = false; - } - } - if ((flags_ & ImGuiWindowFlags_NoBackground)) { ImGui::SetNextWindowBgAlpha(0.0f); } // Render the window if (ImGui::Begin(window_name.c_str(), &is_open, flags_)) { + if (m_first_render) { + m_prev_pos = ImGui::GetWindowPos(); + m_prev_size = ImGui::GetWindowSize(); + setSize(m_prev_size); + setPos(m_prev_pos); + m_first_render = false; + } + ImGuiViewport *viewport = ImGui::GetCurrentWindow()->Viewport; GLFWwindow *window = static_cast(viewport->PlatformHandle); if (window) { @@ -208,6 +213,23 @@ namespace Toolbox::UI { ImGui::End(); } + // Establish window constraints + if (window) { + if (window->Size != m_prev_size) { + if (m_next_size.x >= 0.0f && m_next_size.y >= 0.0f) { + GUIApplication::instance().dispatchEvent( + getUUID(), EVENT_WINDOW_RESIZE, window->Size); + } + ImGui::SetWindowSize(window, m_prev_size, ImGuiCond_Always); + } + + if (window->Pos != m_prev_pos) { + GUIApplication::instance().dispatchEvent( + getUUID(), EVENT_WINDOW_MOVE, window->Pos); + ImGui::SetWindowPos(window, m_prev_pos, ImGuiCond_Always); + } + } + // Handle open/close and focus/defocus if (is_open) { if (!was_open) { @@ -233,6 +255,12 @@ namespace Toolbox::UI { void ImWindow::onWindowEvent(RefPtr ev) { ImProcessLayer::onWindowEvent(ev); switch (ev->getType()) { + case EVENT_WINDOW_MOVE: { + ImVec2 win_pos = ev->getGlobalPoint(); + setLayerPos(win_pos); + ev->accept(); + break; + } case EVENT_WINDOW_RESIZE: { ImVec2 win_size = ev->getSize(); if (m_min_size) { From d69f01ec856f1fce9a118881f80c4d5ec485b595 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Sun, 6 Oct 2024 22:05:26 -0500 Subject: [PATCH 079/129] Stablize much of drag/drop functionality --- include/core/input/input.hpp | 9 +- include/gui/dragdrop/dragaction.hpp | 6 +- include/gui/dragdrop/dragdropmanager.hpp | 5 +- include/gui/layer/imlayer.hpp | 8 +- include/gui/window.hpp | 8 +- include/platform/process.hpp | 1 + src/core/input/input.cpp | 116 +++++++++++++++++------ src/gui/application.cpp | 30 ++++++ src/gui/dragdrop/target.cpp | 90 +++++++++++++----- src/gui/event/dragevent.cpp | 2 +- src/gui/event/dropevent.cpp | 2 +- src/gui/project/window.cpp | 16 +++- src/gui/window.cpp | 38 ++------ src/platform/process.cpp | 45 +++++++++ 14 files changed, 280 insertions(+), 96 deletions(-) diff --git a/include/core/input/input.hpp b/include/core/input/input.hpp index f85bc6b2..2e069b3e 100644 --- a/include/core/input/input.hpp +++ b/include/core/input/input.hpp @@ -19,11 +19,14 @@ namespace Toolbox::Input { bool GetKeyUp(KeyCode key); MouseButtons GetPressedMouseButtons(); - bool GetMouseButton(MouseButton button); - bool GetMouseButtonDown(MouseButton button); - bool GetMouseButtonUp(MouseButton button); + bool GetMouseButton(MouseButton button, bool include_external = false); + bool GetMouseButtonDown(MouseButton button, bool include_external = false); + bool GetMouseButtonUp(MouseButton button, bool include_external = false); + // This gets the mouse position only when within a GLFW window void GetMouseViewportPosition(double &x, double &y); + // This gets the mouse position even when outside the window + void GetMousePosition(double &x, double &y); void SetMousePosition(double x, double y, bool overwrite_delta = true); void GetMouseDelta(double &x, double &y); diff --git a/include/gui/dragdrop/dragaction.hpp b/include/gui/dragdrop/dragaction.hpp index 1c88210b..68193bae 100644 --- a/include/gui/dragdrop/dragaction.hpp +++ b/include/gui/dragdrop/dragaction.hpp @@ -27,7 +27,7 @@ namespace Toolbox::UI { [[nodiscard]] DropTypes getSupportedDropTypes() const { return m_supported_drop_types; } [[nodiscard]] UUID64 getSourceUUID() const { return m_source_uuid; } - [[nodiscard]] std::optional getTargetUUID() const { return m_target_uuid; } + [[nodiscard]] UUID64 getTargetUUID() const { return m_target_uuid; } void setHotSpot(const ImVec2 &absp) { m_hot_spot = absp; } void setImage(const ImageHandle &image) { m_image_handle = image; } @@ -43,8 +43,8 @@ namespace Toolbox::UI { DropType m_default_drop_type = DropType::ACTION_MOVE; DropTypes m_supported_drop_types = DropType::ACTION_COPY | DropType::ACTION_MOVE; - UUID64 m_source_uuid; - std::optional m_target_uuid; + UUID64 m_source_uuid = 0; + UUID64 m_target_uuid = 0; }; } // namespace Toolbox::UI \ No newline at end of file diff --git a/include/gui/dragdrop/dragdropmanager.hpp b/include/gui/dragdrop/dragdropmanager.hpp index 3ff69423..130aca77 100644 --- a/include/gui/dragdrop/dragdropmanager.hpp +++ b/include/gui/dragdrop/dragdropmanager.hpp @@ -25,6 +25,8 @@ namespace Toolbox::UI { bool initialize(); void shutdown(); + void setSystemAction(bool is_system) { m_is_system_action = is_system; } + RefPtr createDragAction(UUID64 source_uuid, MimeData &&data); RefPtr getCurrentDragAction() const { return m_current_drag_action; } void destroyDragAction(RefPtr action); @@ -42,7 +44,8 @@ namespace Toolbox::UI { #elif defined(TOOLBOX_PLATFORM_LINUX) #endif - RefPtr m_current_drag_action; + RefPtr m_current_drag_action; + bool m_is_system_action = false; }; } // namespace Toolbox::UI \ No newline at end of file diff --git a/include/gui/layer/imlayer.hpp b/include/gui/layer/imlayer.hpp index 0b67d2a1..312d59c2 100644 --- a/include/gui/layer/imlayer.hpp +++ b/include/gui/layer/imlayer.hpp @@ -49,11 +49,11 @@ namespace Toolbox::UI { virtual void onImGuiPostUpdate(TimeStep delta_time) {} // Event callbacks - virtual void onContextMenuEvent(RefPtr ev) {} - virtual void onDragEvent(RefPtr ev) {} - virtual void onDropEvent(RefPtr ev) {} + virtual void onContextMenuEvent(RefPtr ev) { ev->ignore(); } + virtual void onDragEvent(RefPtr ev) { ev->ignore(); } + virtual void onDropEvent(RefPtr ev) { ev->ignore(); } virtual void onFocusEvent(RefPtr ev); - virtual void onMouseEvent(RefPtr ev) {} + virtual void onMouseEvent(RefPtr ev) { ev->ignore(); } virtual void onWindowEvent(RefPtr ev); private: diff --git a/include/gui/window.hpp b/include/gui/window.hpp index 221ddff1..ffc8693f 100644 --- a/include/gui/window.hpp +++ b/include/gui/window.hpp @@ -89,6 +89,9 @@ namespace Toolbox::UI { // Returns the supported file type, or empty if designed for a folder. [[nodiscard]] virtual std::vector extensions() const { return {}; } + int getZOrder() const { return m_z_order; } + int getImOrder() const { return m_im_order; } + void close(); void defocus(); void focus(); @@ -112,8 +115,6 @@ namespace Toolbox::UI { void setLayerSize(const ImVec2 &size) noexcept { ImProcessLayer::setSize(size); } void setLayerPos(const ImVec2 &pos) noexcept { ImProcessLayer::setPos(pos); } - static void privDropCallback(GLFWwindow *window, int path_count, const char *paths[]); - UUID64 m_UUID64; ImGuiID m_sibling_id = 0; @@ -145,6 +146,9 @@ namespace Toolbox::UI { ImVec2 m_next_pos = {}; bool m_first_render = true; + + int m_z_order = -1; + int m_im_order = -1; }; inline std::string ImWindowComponentTitle(const ImWindow &window_layer, diff --git a/include/platform/process.hpp b/include/platform/process.hpp index 80b4e8e6..2e0e9dbe 100644 --- a/include/platform/process.hpp +++ b/include/platform/process.hpp @@ -48,6 +48,7 @@ namespace Toolbox::Platform { std::string GetWindowTitle(LowWindow window); bool GetWindowClientRect(LowWindow window, int &x, int &y, int &width, int &height); + bool GetWindowZOrder(LowWindow window, int &zorder); bool ForceWindowToFront(LowWindow window); bool ForceWindowToFront(LowWindow window, LowWindow target); diff --git a/src/core/input/input.cpp b/src/core/input/input.cpp index 5d03cf37..537d4082 100644 --- a/src/core/input/input.cpp +++ b/src/core/input/input.cpp @@ -10,6 +10,7 @@ #include #include +#include "core/core.hpp" #include "core/input/input.hpp" // Internals @@ -23,6 +24,9 @@ namespace { using namespace Toolbox::Input; + static double s_mouse_position_glfw_x = 0; + static double s_mouse_position_glfw_y = 0; + static double s_mouse_position_x = 0; static double s_mouse_position_y = 0; @@ -40,17 +44,21 @@ namespace { static bool s_keys_down[c_keys_max] = {false}; static bool s_prev_keys_down[c_keys_max] = {false}; + static bool s_mouse_buttons_down_glfw[c_buttons_max] = {false}; + static bool s_prev_mouse_buttons_down_glfw[c_buttons_max] = {false}; + static bool s_mouse_buttons_down[c_buttons_max] = {false}; static bool s_prev_mouse_buttons_down[c_buttons_max] = {false}; - static bool GetKeyState(Toolbox::Input::KeyCode key) { return s_keys_down[raw_enum(key)]; } - static void SetKeyState(Toolbox::Input::KeyCode key, bool state) { s_keys_down[raw_enum(key)] = state; } - - static bool GetMouseButtonState(MouseButton button) { - return s_mouse_buttons_down[raw_enum(button)]; + static void SetKeyState(Toolbox::Input::KeyCode key, bool state) { + s_keys_down[raw_enum(key)] = state; } - static void SetMouseButtonState(MouseButton button, bool state) { + + static void SetMouseButtonState(MouseButton button, bool state, bool as_external) { s_mouse_buttons_down[raw_enum(button)] = state; + if (!as_external) { + s_mouse_buttons_down_glfw[raw_enum(button)] = state; + } } } // namespace @@ -98,8 +106,7 @@ namespace Toolbox::Input { bool GetKey(KeyCode key) { return s_keys_down[raw_enum(key)]; } bool GetKeyDown(KeyCode key) { - bool is_down = - s_keys_down[raw_enum(key)] && !s_prev_keys_down[raw_enum(key)]; + bool is_down = s_keys_down[raw_enum(key)] && !s_prev_keys_down[raw_enum(key)]; return is_down; } @@ -117,19 +124,37 @@ namespace Toolbox::Input { return buttons; } - bool GetMouseButton(MouseButton button) { return s_mouse_buttons_down[raw_enum(button)]; } + bool GetMouseButton(MouseButton button, bool include_external) { + return include_external ? s_mouse_buttons_down[raw_enum(button)] + : s_mouse_buttons_down_glfw[raw_enum(button)]; + } - bool GetMouseButtonDown(MouseButton button) { - return s_mouse_buttons_down[raw_enum(button)] && - !s_prev_mouse_buttons_down[raw_enum(button)]; + bool GetMouseButtonDown(MouseButton button, bool include_external) { + if (include_external) { + return s_mouse_buttons_down[raw_enum(button)] && + !s_prev_mouse_buttons_down[raw_enum(button)]; + } else { + return s_mouse_buttons_down_glfw[raw_enum(button)] && + !s_prev_mouse_buttons_down_glfw[raw_enum(button)]; + } } - bool GetMouseButtonUp(MouseButton button) { - return s_prev_mouse_buttons_down[raw_enum(button)] && - !s_mouse_buttons_down[raw_enum(button)]; + bool GetMouseButtonUp(MouseButton button, bool include_external) { + if (include_external) { + return s_prev_mouse_buttons_down[raw_enum(button)] && + !s_mouse_buttons_down[raw_enum(button)]; + } else { + return s_prev_mouse_buttons_down_glfw[raw_enum(button)] && + !s_mouse_buttons_down_glfw[raw_enum(button)]; + } } void GetMouseViewportPosition(double &x, double &y) { + x = s_mouse_position_glfw_x; + y = s_mouse_position_glfw_y; + } + + void GetMousePosition(double &x, double &y) { x = s_mouse_position_x; y = s_mouse_position_y; } @@ -150,9 +175,9 @@ namespace Toolbox::Input { if (!overwrite_delta) { SetMouseWrapped(true); } -#if WIN32 +#ifdef TOOLBOX_PLATFORM_WINDOWS SetCursorPos((int)pos_x, (int)pos_y); -#elif __linux__ +#elif defined(TOOLBOX_PLATFORM_LINUX) Display *display = XOpenDisplay(0); if (display == nullptr) return; @@ -171,6 +196,38 @@ namespace Toolbox::Input { void SetMouseWrapped(bool wrapped) { s_mouse_wrapped = wrapped; } void UpdateInputState() { +#ifdef TOOLBOX_PLATFORM_WINDOWS + POINT point; + GetCursorPos(&point); + s_mouse_position_x = point.x; + s_mouse_position_y = point.y; + + // Poll mouse inputs + for (int i = 0; i < c_buttons_max; i++) { + int states[3] = {VK_LBUTTON, VK_RBUTTON, VK_MBUTTON}; + s_mouse_buttons_down[i] = GetAsyncKeyState(states[i]) & 0x8000; + } +#elif defined(TOOLBOX_PLATFORM_LINUX) + // TODO: Check that this actually works + + Display *display = XOpenDisplay(0); + if (display == nullptr) + return; + + Window root = DefaultRootWindow(display); + Window child; + int root_x, root_y, win_x, win_y; + unsigned int mask; + XQueryPointer(display, root, &root, &child, &root_x, &root_y, &win_x, &win_y, &mask); + + s_mouse_position_x = win_x; + s_mouse_position_y = win_y; + + // Poll mouse inputs + for (int i = 0; i < c_buttons_max; i++) { + } +#endif + if (!s_mouse_wrapped) { s_mouse_delta_x = s_mouse_position_x - s_prev_mouse_position_x; s_mouse_delta_y = s_mouse_position_y - s_prev_mouse_position_y; @@ -180,10 +237,14 @@ namespace Toolbox::Input { } void PostUpdateInputState() { - for (int i = 0; i < c_keys_max; i++) - s_prev_keys_down[i] = s_keys_down[i]; - for (int i = 0; i < c_buttons_max; i++) - s_prev_mouse_buttons_down[i] = s_mouse_buttons_down[i]; + /*TOOLBOX_DEBUG_LOG_V("PostUpdateInputState: LBUT: [P {}, N {}], LBUT_GLFW: [P {}, N {}]", + s_prev_mouse_buttons_down[0], s_mouse_buttons_down[0], + s_prev_mouse_buttons_down_glfw[0], s_mouse_buttons_down_glfw[0]);*/ + + std::memcpy(s_prev_mouse_buttons_down_glfw, s_mouse_buttons_down_glfw, + sizeof(s_mouse_buttons_down_glfw)); + std::memcpy(s_prev_mouse_buttons_down, s_mouse_buttons_down, sizeof(s_mouse_buttons_down)); + std::memcpy(s_prev_keys_down, s_keys_down, sizeof(s_keys_down)); s_prev_mouse_position_x = s_mouse_position_x; s_prev_mouse_position_y = s_mouse_position_y; @@ -208,8 +269,8 @@ namespace Toolbox::Input { int win_x, win_y; glfwGetWindowPos(window, &win_x, &win_y); - s_mouse_position_x = win_x + xpos; - s_mouse_position_y = win_y + ypos; + s_mouse_position_glfw_x = xpos; + s_mouse_position_glfw_y = ypos; ImGui_ImplGlfw_CursorPosCallback(window, xpos, ypos); } @@ -218,10 +279,11 @@ namespace Toolbox::Input { if (button >= c_buttons_max) return; - if (action == GLFW_PRESS) - s_mouse_buttons_down[button] = true; - else if (action == GLFW_RELEASE) - s_mouse_buttons_down[button] = false; + if (action == GLFW_PRESS) { + SetMouseButtonState(static_cast(button), true, false); + } else if (action == GLFW_RELEASE) { + SetMouseButtonState(static_cast(button), false, false); + } ImGui_ImplGlfw_MouseButtonCallback(window, button, action, mods); } diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 4bdef572..68bc09a9 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -265,9 +265,39 @@ namespace Toolbox { void GUIApplication::onEvent(RefPtr ev) { CoreApplication::onEvent(ev); + if (ev->getType() == EVENT_DROP) { DragDropManager::instance().destroyDragAction( DragDropManager::instance().getCurrentDragAction()); + } else if (ev->getType() == EVENT_DRAG_MOVE || ev->getType() == EVENT_DRAG_ENTER || + ev->getType() == EVENT_DRAG_LEAVE) { + if (!Input::GetMouseButton(MouseButton::BUTTON_LEFT, true)) { + DragDropManager::instance().destroyDragAction( + DragDropManager::instance().getCurrentDragAction()); + } + } + + switch (ev->getType()) { + case EVENT_DRAG_ENTER: + case EVENT_DRAG_MOVE: { + if (!Input::GetMouseButton(MouseButton::BUTTON_LEFT, true)) { + DragDropManager::instance().destroyDragAction( + DragDropManager::instance().getCurrentDragAction()); + } + break; + } + case EVENT_DRAG_LEAVE: { + if (!Input::GetMouseButton(MouseButton::BUTTON_LEFT, true)) { + DragDropManager::instance().destroyDragAction( + DragDropManager::instance().getCurrentDragAction()); + } else { + RefPtr action = DragDropManager::instance().getCurrentDragAction(); + if (action) { + action->setTargetUUID(0); + } + } + break; + } } } diff --git a/src/gui/dragdrop/target.cpp b/src/gui/dragdrop/target.cpp index 3b41eff8..bb1f6d44 100644 --- a/src/gui/dragdrop/target.cpp +++ b/src/gui/dragdrop/target.cpp @@ -10,14 +10,27 @@ namespace Toolbox::UI { static UUID64 searchDropTarget(const ImVec2 &mouse_pos) { std::vector> windows = GUIApplication::instance().getWindows(); + UUID64 target_uuid = 0; + int target_z_order = std::numeric_limits::max(); + int target_im_index = std::numeric_limits::min(); + for (RefPtr window : windows) { ImRect rect = {window->getPos(), window->getPos() + window->getSize()}; if (rect.Contains(mouse_pos)) { - return window->getUUID(); + if (window->getZOrder() < target_z_order) { + target_uuid = window->getUUID(); + target_z_order = window->getZOrder(); + target_im_index = window->getImOrder(); + } else if (window->getZOrder() == target_z_order) { + if (window->getImOrder() >= target_im_index) { + target_uuid = window->getUUID(); + target_im_index = window->getImOrder(); + } + } } } - return 0; + return target_uuid; } #ifdef TOOLBOX_PLATFORM_WINDOWS @@ -188,6 +201,8 @@ namespace Toolbox::UI { private: std::vector m_targets = {}; + + bool m_block_implicit_drag_events = false; }; #elif defined(TOOLBOX_PLATFORM_LINUX) @@ -225,8 +240,10 @@ namespace Toolbox::UI { POINTL pt, DWORD *pdwEffect) { RefPtr action = DragDropManager::instance().getCurrentDragAction(); if (!action) { + DragDropManager::instance().setSystemAction(true); MimeData mime_data = createMimeDataFromDataObject(pDataObj); action = DragDropManager::instance().createDragAction(0, std::move(mime_data)); + DragDropManager::instance().setSystemAction(false); } action->setHotSpot(ImVec2(pt.x, pt.y)); @@ -288,46 +305,69 @@ namespace Toolbox::UI { } void WindowsDragDropTargetDelegate::onDragEnter(RefPtr action) { - double mouse_x, mouse_y; - Input::GetMouseViewportPosition(mouse_x, mouse_y); + ImVec2 mouse_pos = action->getHotSpot(); + UUID64 prev_uuid = action->getTargetUUID(); + UUID64 new_uuid = searchDropTarget(mouse_pos); - ImVec2 mouse_pos = ImVec2(mouse_x, mouse_y); - action->setTargetUUID(searchDropTarget(mouse_pos)); + if (prev_uuid != new_uuid && prev_uuid != 0) { + GUIApplication::instance().dispatchEvent(EVENT_DRAG_LEAVE, mouse_pos.x, + mouse_pos.y, action); + } + + action->setTargetUUID(new_uuid); - GUIApplication::instance().dispatchEvent(EVENT_DRAG_ENTER, mouse_x, - mouse_y, action); + if (new_uuid != 0) { + GUIApplication::instance().dispatchEvent(EVENT_DRAG_ENTER, mouse_pos.x, + mouse_pos.y, action); + } } void WindowsDragDropTargetDelegate::onDragLeave(RefPtr action) { - double mouse_x, mouse_y; - Input::GetMouseViewportPosition(mouse_x, mouse_y); + ImVec2 mouse_pos = action->getHotSpot(); - ImVec2 mouse_pos = ImVec2(mouse_x, mouse_y); - action->setTargetUUID(searchDropTarget(mouse_pos)); + if (action->getTargetUUID() != 0) { + GUIApplication::instance().dispatchEvent(EVENT_DRAG_LEAVE, mouse_pos.x, + mouse_pos.y, action); + } - GUIApplication::instance().dispatchEvent(EVENT_DRAG_LEAVE, mouse_x, - mouse_y, action); + m_block_implicit_drag_events = true; } void WindowsDragDropTargetDelegate::onDragMove(RefPtr action) { - double mouse_x, mouse_y; - Input::GetMouseViewportPosition(mouse_x, mouse_y); + ImVec2 mouse_pos = action->getHotSpot(); + UUID64 prev_uuid = action->getTargetUUID(); + UUID64 new_uuid = searchDropTarget(mouse_pos); + + if (prev_uuid != new_uuid) { + if (!m_block_implicit_drag_events && prev_uuid != 0) { + GUIApplication::instance().dispatchEvent( + EVENT_DRAG_LEAVE, mouse_pos.x, mouse_pos.y, action); + } - ImVec2 mouse_pos = ImVec2(mouse_x, mouse_y); - action->setTargetUUID(searchDropTarget(mouse_pos)); + m_block_implicit_drag_events = false; + action->setTargetUUID(new_uuid); - GUIApplication::instance().dispatchEvent(EVENT_DRAG_MOVE, mouse_x, mouse_y, - action); + if (new_uuid != 0) { + GUIApplication::instance().dispatchEvent( + EVENT_DRAG_ENTER, mouse_pos.x, mouse_pos.y, action); + } + } + + if (new_uuid != 0) { + GUIApplication::instance().dispatchEvent(EVENT_DRAG_MOVE, mouse_pos.x, + mouse_pos.y, action); + } } void WindowsDragDropTargetDelegate::onDrop(RefPtr action) { - double mouse_x, mouse_y; - Input::GetMouseViewportPosition(mouse_x, mouse_y); + ImVec2 mouse_pos = action->getHotSpot(); - ImVec2 mouse_pos = ImVec2(mouse_x, mouse_y); - action->setTargetUUID(searchDropTarget(mouse_pos)); + UUID64 new_uuid = searchDropTarget(mouse_pos); + action->setTargetUUID(new_uuid); - GUIApplication::instance().dispatchEvent(mouse_pos, action); + if (new_uuid != 0) { + GUIApplication::instance().dispatchEvent(mouse_pos, action); + } } bool WindowsDragDropTargetDelegate::initializeForWindow(Platform::LowWindow window) { diff --git a/src/gui/event/dragevent.cpp b/src/gui/event/dragevent.cpp index 0b5ef8f5..fd9f2dd4 100644 --- a/src/gui/event/dragevent.cpp +++ b/src/gui/event/dragevent.cpp @@ -3,7 +3,7 @@ namespace Toolbox::UI { DragEvent::DragEvent(TypeID type, float pos_x, float pos_y, RefPtr action) - : BaseEvent(action->getTargetUUID().value(), type), m_screen_pos_x(pos_x), + : BaseEvent(action->getTargetUUID(), type), m_screen_pos_x(pos_x), m_screen_pos_y(pos_y), m_drag_action(action) {} ScopePtr DragEvent::clone(bool deep) const { diff --git a/src/gui/event/dropevent.cpp b/src/gui/event/dropevent.cpp index ebbed48d..cc733117 100644 --- a/src/gui/event/dropevent.cpp +++ b/src/gui/event/dropevent.cpp @@ -3,7 +3,7 @@ namespace Toolbox::UI { DropEvent::DropEvent(const ImVec2 &pos, RefPtr action) - : BaseEvent(action->getTargetUUID().value(), EVENT_DROP), m_screen_pos(pos), + : BaseEvent(action->getTargetUUID(), EVENT_DROP), m_screen_pos(pos), m_drag_action(action) {} ScopePtr DropEvent::clone(bool deep) const { diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index f922eb58..e0e3db1f 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -259,7 +259,21 @@ namespace Toolbox::UI { void ProjectViewWindow::onContextMenuEvent(RefPtr ev) {} - void ProjectViewWindow::onDragEvent(RefPtr ev) {} + void ProjectViewWindow::onDragEvent(RefPtr ev) { + float x, y; + ev->getGlobalPoint(x, y); + + if (ev->getType() == EVENT_DRAG_ENTER) { + TOOLBOX_DEBUG_LOG("Drag enter"); + ev->accept(); + } else if (ev->getType() == EVENT_DRAG_LEAVE) { + TOOLBOX_DEBUG_LOG("Drag leave"); + ev->accept(); + } else if (ev->getType() == EVENT_DRAG_MOVE) { + TOOLBOX_DEBUG_LOG_V("Drag move ({}, {})", x, y); + ev->accept(); + } + } void ProjectViewWindow::onDropEvent(RefPtr ev) { actionPasteIntoIndex(m_view_index, ev->getMimeData()); diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 70eb4a29..5d8f8bbf 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -13,9 +13,6 @@ #include #include -#define GLFW_EXPOSE_NATIVE_WIN32 -#include - namespace Toolbox::UI { void ImWindow::onRenderDockspace() { @@ -180,6 +177,11 @@ namespace Toolbox::UI { // Render the window if (ImGui::Begin(window_name.c_str(), &is_open, flags_)) { + ImGuiWindow *im_window = ImGui::GetCurrentWindow(); + if (im_window) { + m_im_order = im_window->BeginOrderWithinContext; + } + if (m_first_render) { m_prev_pos = ImGui::GetWindowPos(); m_prev_size = ImGui::GetWindowSize(); @@ -194,7 +196,11 @@ namespace Toolbox::UI { glfwSetWindowUserPointer(window, this); /*glfwSetDropCallback(static_cast(viewport->PlatformHandle), privDropCallback);*/ - GUIApplication::instance().registerDragDropTarget((Platform::LowWindow)glfwGetWin32Window(window)); + Platform::LowWindow low_window = (Platform::LowWindow)viewport->PlatformHandleRaw; + if (!Platform::GetWindowZOrder(low_window, m_z_order)) { + m_z_order = -1; + } + GUIApplication::instance().registerDragDropTarget(low_window); } if ((flags_ & ImGuiWindowFlags_NoBackground)) { @@ -291,28 +297,4 @@ namespace Toolbox::UI { return t; } - void ImWindow::privDropCallback(GLFWwindow *window, int path_count, const char *paths[]) { - ImWindow *self = static_cast(glfwGetWindowUserPointer(window)); - if (!self) { - TOOLBOX_ERROR("[ImWindow] Attempted drop operation on NULL user pointer!"); - return; - } - - std::string uri_list; - for (int i = 0; i < path_count; ++i) { - uri_list += std::format("file:///{}\n", paths[i]); - } - - double mouse_x, mouse_y; - Input::GetMouseViewportPosition(mouse_x, mouse_y); - - MimeData &&data = MimeData(); - data.set_urls(uri_list); - - RefPtr action = DragDropManager::instance().createDragAction(self->getUUID(), std::move(data)); - - GUIApplication::instance().dispatchEvent( - ImVec2(mouse_x, mouse_y), action); - } - } // namespace Toolbox::UI \ No newline at end of file diff --git a/src/platform/process.cpp b/src/platform/process.cpp index 324fb7ad..17538a08 100644 --- a/src/platform/process.cpp +++ b/src/platform/process.cpp @@ -168,6 +168,48 @@ namespace Toolbox::Platform { return true; } + // Structure to store child windows and their z-order + struct WindowInfo { + HWND hwnd; + int zOrder; + }; + + BOOL CALLBACK EnumWindowsForZProc(HWND hwnd, LPARAM lParam) { + std::vector *windows = reinterpret_cast *>(lParam); + + // Add the child window to the vector + WindowInfo info; + info.hwnd = hwnd; + info.zOrder = windows->size(); // The index represents the Z-order among child windows + windows->push_back(info); + + return TRUE; // Continue enumeration + } + + bool GetWindowZOrder(LowWindow window, int &zorder) { + std::vector windows; + windows.reserve(1024); + + // Get the parent window of the window + HWND parent = GetParent(window); + if (parent == NULL) { + EnumWindows(EnumWindowsForZProc, reinterpret_cast(&windows)); + } else { + // Enumerate the child windows of the parent window + EnumChildWindows(parent, EnumWindowsForZProc, reinterpret_cast(&windows)); + } + + // Find the Z-order of the window among the child windows + for (size_t i = 0; i < windows.size(); i++) { + if (windows[i].hwnd == window) { + zorder = windows[i].zOrder; + return true; + } + } + + return false; + } + bool ForceWindowToFront(LowWindow window) { return SetWindowPos(window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); @@ -287,6 +329,9 @@ namespace Toolbox::Platform { XFreeStringList(stringList); return stringList[0]; } + bool GetWindowZOrder(LowWindow window, int &zorder) { + return false; + } bool ForceWindowToFront(LowWindow window) { Display* display = XOpenDisplay(0); return XRaiseWindow(display, (Window)window); From c2bd344f11841c86e3c2923cefca007aaab440b7 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Mon, 7 Oct 2024 00:27:10 -0500 Subject: [PATCH 080/129] Establish a very basic drag render --- .gitignore | 3 +- include/gui/application.hpp | 2 + include/gui/dragdrop/dragaction.hpp | 8 +-- include/gui/dragdrop/dragdropmanager.hpp | 2 +- include/gui/image/imagepainter.hpp | 2 + include/platform/process.hpp | 1 + src/gui/application.cpp | 62 ++++++++++++++++++++++++ src/gui/dragdrop/target.cpp | 52 ++++++++++++++++---- src/gui/image/imagepainter.cpp | 11 +++++ src/platform/process.cpp | 14 +++++- 10 files changed, 140 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index a460bf85..470633de 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,5 @@ # Visual Studio .vs/* -out/* \ No newline at end of file +out/* +/enc_temp_folder diff --git a/include/gui/application.hpp b/include/gui/application.hpp index aceaf1da..b9d882e5 100644 --- a/include/gui/application.hpp +++ b/include/gui/application.hpp @@ -196,6 +196,8 @@ namespace Toolbox { bool m_windows_processing = false; ScopePtr m_drag_drop_target_delegate; + ImGuiViewport *m_drag_drop_viewport = nullptr; + bool m_await_drag_drop_destroy = false; std::unordered_map m_docked_map; ImGuiID m_dockspace_id; diff --git a/include/gui/dragdrop/dragaction.hpp b/include/gui/dragdrop/dragaction.hpp index 68193bae..a23fe281 100644 --- a/include/gui/dragdrop/dragaction.hpp +++ b/include/gui/dragdrop/dragaction.hpp @@ -19,8 +19,8 @@ namespace Toolbox::UI { DragAction(const DragAction &) = default; DragAction(DragAction &&) = default; - [[nodiscard]] ImVec2 getHotSpot() const { return m_hot_spot; } - [[nodiscard]] const ImageHandle &getImage() { return m_image_handle; } + [[nodiscard]] const ImVec2 &getHotSpot() const { return m_hot_spot; } + [[nodiscard]] RefPtr getImage() { return m_image_handle; } [[nodiscard]] const MimeData &getPayload() const { return m_mime_data; } [[nodiscard]] DropType getDefaultDropType() const { m_default_drop_type; } @@ -30,14 +30,14 @@ namespace Toolbox::UI { [[nodiscard]] UUID64 getTargetUUID() const { return m_target_uuid; } void setHotSpot(const ImVec2 &absp) { m_hot_spot = absp; } - void setImage(const ImageHandle &image) { m_image_handle = image; } + void setImage(RefPtr image) { m_image_handle = image; } void setPayload(const MimeData &data) { m_mime_data = data; } void setTargetUUID(const UUID64 &uuid) { m_target_uuid = uuid; } void setSupportedDropTypes(DropTypes types) { m_supported_drop_types = types; } private: ImVec2 m_hot_spot; - ImageHandle m_image_handle; + RefPtr m_image_handle; MimeData m_mime_data; DropType m_default_drop_type = DropType::ACTION_MOVE; diff --git a/include/gui/dragdrop/dragdropmanager.hpp b/include/gui/dragdrop/dragdropmanager.hpp index 130aca77..e698686d 100644 --- a/include/gui/dragdrop/dragdropmanager.hpp +++ b/include/gui/dragdrop/dragdropmanager.hpp @@ -24,7 +24,7 @@ namespace Toolbox::UI { bool initialize(); void shutdown(); - + void setSystemAction(bool is_system) { m_is_system_action = is_system; } RefPtr createDragAction(UUID64 source_uuid, MimeData &&data); diff --git a/include/gui/image/imagepainter.hpp b/include/gui/image/imagepainter.hpp index dad78b0c..9f9d0247 100644 --- a/include/gui/image/imagepainter.hpp +++ b/include/gui/image/imagepainter.hpp @@ -24,6 +24,8 @@ namespace Toolbox::UI { bool render(const ImageHandle &image, const ImVec2 &size) const; bool render(const ImageHandle &image, const ImVec2 &pos, const ImVec2 &size) const; + bool renderOverlay(const ImageHandle &image, const ImVec2 &pos, const ImVec2 &size) const; + private: ImVec2 m_uv0 = {0, 0}; ImVec2 m_uv1 = {1, 1}; diff --git a/include/platform/process.hpp b/include/platform/process.hpp index 2e0e9dbe..d3e3e52d 100644 --- a/include/platform/process.hpp +++ b/include/platform/process.hpp @@ -54,6 +54,7 @@ namespace Toolbox::Platform { bool ForceWindowToFront(LowWindow window, LowWindow target); bool SetWindowTransparency(LowWindow window, uint8_t alpha); + bool SetWindowClickThrough(LowWindow window, bool click_through); bool OpenFileExplorer(const fs_path &path); diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 68bc09a9..01e5ae84 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -433,6 +433,68 @@ namespace Toolbox { gcClosedWindows(); } + // Render drag icon + { + if (m_await_drag_drop_destroy) { + DragDropManager::instance().destroyDragAction( + DragDropManager::instance().getCurrentDragAction()); + m_await_drag_drop_destroy = false; + } + + if (DragDropManager::instance().getCurrentDragAction() && + Input::GetMouseButtonUp(MouseButton::BUTTON_LEFT, true)) { + m_await_drag_drop_destroy = true; + } + + if (RefPtr action = DragDropManager::instance().getCurrentDragAction()) { + double x, y; + Input::GetMousePosition(x, y); + + action->setHotSpot({(float)x, (float)y}); + + if (RefPtr image = action->getImage()) { + const ImVec2 &hotspot = action->getHotSpot(); + + ImGuiViewportP *viewport = + ImGui::FindHoveredViewportFromPlatformWindowStack(hotspot); + if (viewport) { + const ImVec2 size = {96, 96}; + const ImVec2 pos = {hotspot.x - size.x / 2.0f, hotspot.y - size.y / 1.1f}; + + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); + // ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 5.0f); + ImGui::PushStyleColor(ImGuiCol_WindowBg, + ImGui::GetStyleColorVec4(ImGuiCol_HeaderHovered)); + + ImGui::SetNextWindowBgAlpha(1.0f); + ImGui::SetNextWindowPos(pos); + ImGui::SetNextWindowSize(size); + if (ImGui::Begin("###Drag Icon", nullptr, + ImGuiWindowFlags_NoDecoration | + ImGuiWindowFlags_NoInputs)) { + ImagePainter painter; + painter.renderOverlay(*action->getImage(), pos, size); + + if (ImGuiWindow *win = ImGui::GetCurrentWindow()) { + if (win->Viewport != ImGui::GetMainViewport()) { + Platform::SetWindowClickThrough( + (Platform::LowWindow)win->Viewport->PlatformHandleRaw, + true); + m_drag_drop_viewport = win->Viewport; + } else { + m_drag_drop_viewport = nullptr; + } + } + } + ImGui::End(); + + ImGui::PopStyleColor(1); + ImGui::PopStyleVar(1); + } + } + } + } + // Render imgui frame { ImGui::Render(); diff --git a/src/gui/dragdrop/target.cpp b/src/gui/dragdrop/target.cpp index bb1f6d44..8f8f0f8c 100644 --- a/src/gui/dragdrop/target.cpp +++ b/src/gui/dragdrop/target.cpp @@ -309,23 +309,41 @@ namespace Toolbox::UI { UUID64 prev_uuid = action->getTargetUUID(); UUID64 new_uuid = searchDropTarget(mouse_pos); - if (prev_uuid != new_uuid && prev_uuid != 0) { - GUIApplication::instance().dispatchEvent(EVENT_DRAG_LEAVE, mouse_pos.x, - mouse_pos.y, action); - } + ResourceManager &resource_manager = GUIApplication::instance().getResourceManager(); + RefPtr image = + resource_manager + .getImageHandle("toolbox.png", resource_manager.getResourcePathUUID("Images/Icons")) + .value_or(nullptr); + action->setImage(image); - action->setTargetUUID(new_uuid); + if (prev_uuid != new_uuid) { + if (prev_uuid != 0) { + GUIApplication::instance().dispatchEvent( + EVENT_DRAG_LEAVE, mouse_pos.x, mouse_pos.y, action); + } - if (new_uuid != 0) { - GUIApplication::instance().dispatchEvent(EVENT_DRAG_ENTER, mouse_pos.x, - mouse_pos.y, action); + action->setTargetUUID(new_uuid); + + if (new_uuid != 0) { + GUIApplication::instance().dispatchEvent( + EVENT_DRAG_ENTER, mouse_pos.x, mouse_pos.y, action); + } } } void WindowsDragDropTargetDelegate::onDragLeave(RefPtr action) { ImVec2 mouse_pos = action->getHotSpot(); + UUID64 prev_uuid = action->getTargetUUID(); + UUID64 new_uuid = searchDropTarget(mouse_pos); - if (action->getTargetUUID() != 0) { + ResourceManager &resource_manager = GUIApplication::instance().getResourceManager(); + RefPtr image = + resource_manager + .getImageHandle("toolbox.png", resource_manager.getResourcePathUUID("Images/Icons")) + .value_or(nullptr); + action->setImage(image); + + if (prev_uuid != new_uuid && prev_uuid != 0) { GUIApplication::instance().dispatchEvent(EVENT_DRAG_LEAVE, mouse_pos.x, mouse_pos.y, action); } @@ -336,7 +354,14 @@ namespace Toolbox::UI { void WindowsDragDropTargetDelegate::onDragMove(RefPtr action) { ImVec2 mouse_pos = action->getHotSpot(); UUID64 prev_uuid = action->getTargetUUID(); - UUID64 new_uuid = searchDropTarget(mouse_pos); + UUID64 new_uuid = searchDropTarget(mouse_pos); + + ResourceManager &resource_manager = GUIApplication::instance().getResourceManager(); + RefPtr image = + resource_manager + .getImageHandle("toolbox.png", resource_manager.getResourcePathUUID("Images/Icons")) + .value_or(nullptr); + action->setImage(image); if (prev_uuid != new_uuid) { if (!m_block_implicit_drag_events && prev_uuid != 0) { @@ -362,6 +387,13 @@ namespace Toolbox::UI { void WindowsDragDropTargetDelegate::onDrop(RefPtr action) { ImVec2 mouse_pos = action->getHotSpot(); + ResourceManager &resource_manager = GUIApplication::instance().getResourceManager(); + RefPtr image = + resource_manager + .getImageHandle("toolbox.png", resource_manager.getResourcePathUUID("Images/Icons")) + .value_or(nullptr); + action->setImage(image); + UUID64 new_uuid = searchDropTarget(mouse_pos); action->setTargetUUID(new_uuid); diff --git a/src/gui/image/imagepainter.cpp b/src/gui/image/imagepainter.cpp index dfb86a99..64cc8aa0 100644 --- a/src/gui/image/imagepainter.cpp +++ b/src/gui/image/imagepainter.cpp @@ -25,4 +25,15 @@ namespace Toolbox::UI { return true; } + bool ImagePainter::renderOverlay(const ImageHandle &image, const ImVec2 &pos, + const ImVec2 &size) const { + if (!image) { + return false; + } + ImDrawList *draw_list = ImGui::GetForegroundDrawList(); + draw_list->AddImage((ImTextureID)image.m_image_handle, pos, pos + size, m_uv0, m_uv1, + ImGui::ColorConvertFloat4ToU32(m_border_color)); + return true; + } + } // namespace Toolbox::UI \ No newline at end of file diff --git a/src/platform/process.cpp b/src/platform/process.cpp index 17538a08..5cf6b5b0 100644 --- a/src/platform/process.cpp +++ b/src/platform/process.cpp @@ -221,7 +221,7 @@ namespace Toolbox::Platform { } bool SetWindowTransparency(LowWindow window, uint8_t alpha) { - SetWindowLongPtr(window, GWL_STYLE, WS_EX_LAYERED); + SetWindowLongPtr(window, GWL_STYLE, GetWindowLongPtr(window, GWL_STYLE) | WS_EX_LAYERED); SetLayeredWindowAttributes(window, RGB(0, 0, 0), 255, LWA_ALPHA); if (!ShowWindow(window, SW_SHOW)) { return false; @@ -229,6 +229,18 @@ namespace Toolbox::Platform { return UpdateWindow(window); } + bool SetWindowClickThrough(LowWindow window, bool click_through) { + LONG_PTR style = GetWindowLongPtr(window, GWL_EXSTYLE); + if (click_through) { + style |= WS_EX_LAYERED; + style |= WS_EX_TRANSPARENT; + } else { + style &= ~WS_EX_LAYERED; + style &= ~WS_EX_TRANSPARENT; + } + return SetWindowLongPtr(window, GWL_EXSTYLE, style) >= 0; + } + bool OpenFileExplorer(const fs_path &path) { std::wstring path_str = path.wstring(); return (int)ShellExecuteW(NULL, L"open", L"explorer.exe", path_str.c_str(), NULL, SW_SHOW) > 32; From 046c91c2c73ecd0b9a870c5f079ff23454d26466 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Mon, 7 Oct 2024 00:47:07 -0500 Subject: [PATCH 081/129] Fix include problems --- src/core/input/input.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/core/input/input.cpp b/src/core/input/input.cpp index 537d4082..2438cc70 100644 --- a/src/core/input/input.cpp +++ b/src/core/input/input.cpp @@ -1,17 +1,20 @@ -#if WIN32 +#include "core/core.hpp" +#include "core/input/input.hpp" + +#include +#include +#include + +#include + +#ifdef TOOLBOX_PLATFORM_WINDOWS #include -#elif __linux__ +#elif defined(TOOLBOX_PLATFORM_LINUX) #include #include #else #error "Unsupported OS" #endif -#include -#include -#include - -#include "core/core.hpp" -#include "core/input/input.hpp" // Internals From 808ab5e9791a3c58b7bf75cd49e0675544bb24f9 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Mon, 7 Oct 2024 01:17:41 -0500 Subject: [PATCH 082/129] Fix declaration errors --- src/gui/dragdrop/target.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/dragdrop/target.cpp b/src/gui/dragdrop/target.cpp index 8f8f0f8c..c8e943e1 100644 --- a/src/gui/dragdrop/target.cpp +++ b/src/gui/dragdrop/target.cpp @@ -450,7 +450,9 @@ namespace Toolbox::UI { void LinuxDragDropTargetDelegate::onDrop(RefPtr action) {} - bool LinuxDragDropTargetDelegate::initializeWindow(Platform::LowWindow window) { return false; } + bool LinuxDragDropTargetDelegate::initializeForWindow(Platform::LowWindow window) { return false; } + + void LinuxDragDropTargetDelegate::shutdownForWindow(Platform::LowWindow window) {} #endif From 24e3a2c3e2958237c978e1758b12cca36293a4df Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Mon, 7 Oct 2024 01:35:55 -0500 Subject: [PATCH 083/129] Provide stub implementations for Linux --- src/platform/process.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/platform/process.cpp b/src/platform/process.cpp index 5cf6b5b0..7d17f783 100644 --- a/src/platform/process.cpp +++ b/src/platform/process.cpp @@ -353,6 +353,11 @@ namespace Toolbox::Platform { // target, but I don't know how to do that. return ForceWindowToFront(window); } + + bool SetWindowTransparency(LowWindow window, uint8_t alpha) { return false; } + + bool SetWindowClickThrough(LowWindow window, bool click_through) { return false; } + bool GetWindowClientRect(LowWindow window, int &x, int &y, int &width, int &height) { XWindowAttributes attribs; Display* display = XOpenDisplay(0); From ce69974fbe0994d8b152f505d72e0dd93068b22e Mon Sep 17 00:00:00 2001 From: JoshuaMK <60854312+JoshuaMKW@users.noreply.github.com> Date: Tue, 8 Oct 2024 20:22:14 -0500 Subject: [PATCH 084/129] Basic image manipulation algorithms (#35) --- include/core/memory.hpp | 2 + include/gui/stb_image.h | 7987 --------------------- include/image/imagebuilder.hpp | 33 + include/image/imagedata.hpp | 56 + include/image/imagehandle.hpp | 4 + include/resource/resource.hpp | 5 + lib/stb/stb_image.h | 8509 +++++++++++++++++++++++ lib/stb/stb_image_resize2.h | 11576 +++++++++++++++++++++++++++++++ lib/stb/stb_image_write.h | 2398 +++++++ src/gui/application.cpp | 6 +- src/gui/dragdrop/target.cpp | 36 +- src/gui/pad/window.cpp | 2 +- src/gui/scene/billboard.cpp | 2 +- src/image/imagebuilder.cpp | 353 + src/image/imagedata.cpp | 52 + src/image/imagehandle.cpp | 12 +- src/resource/resource.cpp | 66 + 17 files changed, 23072 insertions(+), 8027 deletions(-) delete mode 100644 include/gui/stb_image.h create mode 100644 include/image/imagebuilder.hpp create mode 100644 include/image/imagedata.hpp create mode 100644 lib/stb/stb_image.h create mode 100644 lib/stb/stb_image_resize2.h create mode 100644 lib/stb/stb_image_write.h create mode 100644 src/image/imagebuilder.cpp create mode 100644 src/image/imagedata.cpp diff --git a/include/core/memory.hpp b/include/core/memory.hpp index d6c7e27e..877bece2 100644 --- a/include/core/memory.hpp +++ b/include/core/memory.hpp @@ -73,6 +73,8 @@ namespace Toolbox { void free() { if (m_buf && m_owns_buf) { delete[] m_buf; + m_buf = nullptr; + m_owns_buf = false; } m_size = 0; } diff --git a/include/gui/stb_image.h b/include/gui/stb_image.h deleted file mode 100644 index 5e807a0a..00000000 --- a/include/gui/stb_image.h +++ /dev/null @@ -1,7987 +0,0 @@ -/* stb_image - v2.28 - public domain image loader - http://nothings.org/stb - no warranty implied; use at your own risk - - Do this: - #define STB_IMAGE_IMPLEMENTATION - before you include this file in *one* C or C++ file to create the implementation. - - // i.e. it should look like this: - #include ... - #include ... - #include ... - #define STB_IMAGE_IMPLEMENTATION - #include "stb_image.h" - - You can #define STBI_ASSERT(x) before the #include to avoid using assert.h. - And #define STBI_MALLOC, STBI_REALLOC, and STBI_FREE to avoid using malloc,realloc,free - - - QUICK NOTES: - Primarily of interest to game developers and other people who can - avoid problematic images and only need the trivial interface - - JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib) - PNG 1/2/4/8/16-bit-per-channel - - TGA (not sure what subset, if a subset) - BMP non-1bpp, non-RLE - PSD (composited view only, no extra channels, 8/16 bit-per-channel) - - GIF (*comp always reports as 4-channel) - HDR (radiance rgbE format) - PIC (Softimage PIC) - PNM (PPM and PGM binary only) - - Animated GIF still needs a proper API, but here's one way to do it: - http://gist.github.com/urraka/685d9a6340b26b830d49 - - - decode from memory or through FILE (define STBI_NO_STDIO to remove code) - - decode from arbitrary I/O callbacks - - SIMD acceleration on x86/x64 (SSE2) and ARM (NEON) - - Full documentation under "DOCUMENTATION" below. - - -LICENSE - - See end of file for license information. - -RECENT REVISION HISTORY: - - 2.28 (2023-01-29) many error fixes, security errors, just tons of stuff - 2.27 (2021-07-11) document stbi_info better, 16-bit PNM support, bug fixes - 2.26 (2020-07-13) many minor fixes - 2.25 (2020-02-02) fix warnings - 2.24 (2020-02-02) fix warnings; thread-local failure_reason and flip_vertically - 2.23 (2019-08-11) fix clang static analysis warning - 2.22 (2019-03-04) gif fixes, fix warnings - 2.21 (2019-02-25) fix typo in comment - 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs - 2.19 (2018-02-11) fix warning - 2.18 (2018-01-30) fix warnings - 2.17 (2018-01-29) bugfix, 1-bit BMP, 16-bitness query, fix warnings - 2.16 (2017-07-23) all functions have 16-bit variants; optimizations; bugfixes - 2.15 (2017-03-18) fix png-1,2,4; all Imagenet JPGs; no runtime SSE detection on GCC - 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs - 2.13 (2016-12-04) experimental 16-bit API, only for PNG so far; fixes - 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes - 2.11 (2016-04-02) 16-bit PNGS; enable SSE2 in non-gcc x64 - RGB-format JPEG; remove white matting in PSD; - allocate large structures on the stack; - correct channel count for PNG & BMP - 2.10 (2016-01-22) avoid warning introduced in 2.09 - 2.09 (2016-01-16) 16-bit TGA; comments in PNM files; STBI_REALLOC_SIZED - - See end of file for full revision history. - - - ============================ Contributors ========================= - - Image formats Extensions, features - Sean Barrett (jpeg, png, bmp) Jetro Lauha (stbi_info) - Nicolas Schulz (hdr, psd) Martin "SpartanJ" Golini (stbi_info) - Jonathan Dummer (tga) James "moose2000" Brown (iPhone PNG) - Jean-Marc Lienher (gif) Ben "Disch" Wenger (io callbacks) - Tom Seddon (pic) Omar Cornut (1/2/4-bit PNG) - Thatcher Ulrich (psd) Nicolas Guillemot (vertical flip) - Ken Miller (pgm, ppm) Richard Mitton (16-bit PSD) - github:urraka (animated gif) Junggon Kim (PNM comments) - Christopher Forseth (animated gif) Daniel Gibson (16-bit TGA) - socks-the-fox (16-bit PNG) - Jeremy Sawicki (handle all ImageNet JPGs) - Optimizations & bugfixes Mikhail Morozov (1-bit BMP) - Fabian "ryg" Giesen Anael Seghezzi (is-16-bit query) - Arseny Kapoulkine Simon Breuss (16-bit PNM) - John-Mark Allen - Carmelo J Fdez-Aguera - - Bug & warning fixes - Marc LeBlanc David Woo Guillaume George Martins Mozeiko - Christpher Lloyd Jerry Jansson Joseph Thomson Blazej Dariusz Roszkowski - Phil Jordan Dave Moore Roy Eltham - Hayaki Saito Nathan Reed Won Chun - Luke Graham Johan Duparc Nick Verigakis the Horde3D community - Thomas Ruf Ronny Chevalier github:rlyeh - Janez Zemva John Bartholomew Michal Cichon github:romigrou - Jonathan Blow Ken Hamada Tero Hanninen github:svdijk - Eugene Golushkov Laurent Gomila Cort Stratton github:snagar - Aruelien Pocheville Sergio Gonzalez Thibault Reuille github:Zelex - Cass Everitt Ryamond Barbiero github:grim210 - Paul Du Bois Engin Manap Aldo Culquicondor github:sammyhw - Philipp Wiesemann Dale Weiler Oriol Ferrer Mesia github:phprus - Josh Tobin Neil Bickford Matthew Gregan github:poppolopoppo - Julian Raschke Gregory Mullen Christian Floisand github:darealshinji - Baldur Karlsson Kevin Schmidt JR Smith github:Michaelangel007 - Brad Weinberger Matvey Cherevko github:mosra - Luca Sas Alexander Veselov Zack Middleton [reserved] - Ryan C. Gordon [reserved] [reserved] - DO NOT ADD YOUR NAME HERE - - Jacko Dirks - - To add your name to the credits, pick a random blank space in the middle and fill it. - 80% of merge conflicts on stb PRs are due to people adding their name at the end - of the credits. -*/ - -#ifndef STBI_INCLUDE_STB_IMAGE_H -#define STBI_INCLUDE_STB_IMAGE_H - -// DOCUMENTATION -// -// Limitations: -// - no 12-bit-per-channel JPEG -// - no JPEGs with arithmetic coding -// - GIF always returns *comp=4 -// -// Basic usage (see HDR discussion below for HDR usage): -// int x,y,n; -// unsigned char *data = stbi_load(filename, &x, &y, &n, 0); -// // ... process data if not NULL ... -// // ... x = width, y = height, n = # 8-bit components per pixel ... -// // ... replace '0' with '1'..'4' to force that many components per pixel -// // ... but 'n' will always be the number that it would have been if you said 0 -// stbi_image_free(data); -// -// Standard parameters: -// int *x -- outputs image width in pixels -// int *y -- outputs image height in pixels -// int *channels_in_file -- outputs # of image components in image file -// int desired_channels -- if non-zero, # of image components requested in result -// -// The return value from an image loader is an 'unsigned char *' which points -// to the pixel data, or NULL on an allocation failure or if the image is -// corrupt or invalid. The pixel data consists of *y scanlines of *x pixels, -// with each pixel consisting of N interleaved 8-bit components; the first -// pixel pointed to is top-left-most in the image. There is no padding between -// image scanlines or between pixels, regardless of format. The number of -// components N is 'desired_channels' if desired_channels is non-zero, or -// *channels_in_file otherwise. If desired_channels is non-zero, -// *channels_in_file has the number of components that _would_ have been -// output otherwise. E.g. if you set desired_channels to 4, you will always -// get RGBA output, but you can check *channels_in_file to see if it's trivially -// opaque because e.g. there were only 3 channels in the source image. -// -// An output image with N components has the following components interleaved -// in this order in each pixel: -// -// N=#comp components -// 1 grey -// 2 grey, alpha -// 3 red, green, blue -// 4 red, green, blue, alpha -// -// If image loading fails for any reason, the return value will be NULL, -// and *x, *y, *channels_in_file will be unchanged. The function -// stbi_failure_reason() can be queried for an extremely brief, end-user -// unfriendly explanation of why the load failed. Define STBI_NO_FAILURE_STRINGS -// to avoid compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly -// more user-friendly ones. -// -// Paletted PNG, BMP, GIF, and PIC images are automatically depalettized. -// -// To query the width, height and component count of an image without having to -// decode the full file, you can use the stbi_info family of functions: -// -// int x,y,n,ok; -// ok = stbi_info(filename, &x, &y, &n); -// // returns ok=1 and sets x, y, n if image is a supported format, -// // 0 otherwise. -// -// Note that stb_image pervasively uses ints in its public API for sizes, -// including sizes of memory buffers. This is now part of the API and thus -// hard to change without causing breakage. As a result, the various image -// loaders all have certain limits on image size; these differ somewhat -// by format but generally boil down to either just under 2GB or just under -// 1GB. When the decoded image would be larger than this, stb_image decoding -// will fail. -// -// Additionally, stb_image will reject image files that have any of their -// dimensions set to a larger value than the configurable STBI_MAX_DIMENSIONS, -// which defaults to 2**24 = 16777216 pixels. Due to the above memory limit, -// the only way to have an image with such dimensions load correctly -// is for it to have a rather extreme aspect ratio. Either way, the -// assumption here is that such larger images are likely to be malformed -// or malicious. If you do need to load an image with individual dimensions -// larger than that, and it still fits in the overall size limit, you can -// #define STBI_MAX_DIMENSIONS on your own to be something larger. -// -// =========================================================================== -// -// UNICODE: -// -// If compiling for Windows and you wish to use Unicode filenames, compile -// with -// #define STBI_WINDOWS_UTF8 -// and pass utf8-encoded filenames. Call stbi_convert_wchar_to_utf8 to convert -// Windows wchar_t filenames to utf8. -// -// =========================================================================== -// -// Philosophy -// -// stb libraries are designed with the following priorities: -// -// 1. easy to use -// 2. easy to maintain -// 3. good performance -// -// Sometimes I let "good performance" creep up in priority over "easy to maintain", -// and for best performance I may provide less-easy-to-use APIs that give higher -// performance, in addition to the easy-to-use ones. Nevertheless, it's important -// to keep in mind that from the standpoint of you, a client of this library, -// all you care about is #1 and #3, and stb libraries DO NOT emphasize #3 above all. -// -// Some secondary priorities arise directly from the first two, some of which -// provide more explicit reasons why performance can't be emphasized. -// -// - Portable ("ease of use") -// - Small source code footprint ("easy to maintain") -// - No dependencies ("ease of use") -// -// =========================================================================== -// -// I/O callbacks -// -// I/O callbacks allow you to read from arbitrary sources, like packaged -// files or some other source. Data read from callbacks are processed -// through a small internal buffer (currently 128 bytes) to try to reduce -// overhead. -// -// The three functions you must define are "read" (reads some bytes of data), -// "skip" (skips some bytes of data), "eof" (reports if the stream is at the end). -// -// =========================================================================== -// -// SIMD support -// -// The JPEG decoder will try to automatically use SIMD kernels on x86 when -// supported by the compiler. For ARM Neon support, you must explicitly -// request it. -// -// (The old do-it-yourself SIMD API is no longer supported in the current -// code.) -// -// On x86, SSE2 will automatically be used when available based on a run-time -// test; if not, the generic C versions are used as a fall-back. On ARM targets, -// the typical path is to have separate builds for NEON and non-NEON devices -// (at least this is true for iOS and Android). Therefore, the NEON support is -// toggled by a build flag: define STBI_NEON to get NEON loops. -// -// If for some reason you do not want to use any of SIMD code, or if -// you have issues compiling it, you can disable it entirely by -// defining STBI_NO_SIMD. -// -// =========================================================================== -// -// HDR image support (disable by defining STBI_NO_HDR) -// -// stb_image supports loading HDR images in general, and currently the Radiance -// .HDR file format specifically. You can still load any file through the existing -// interface; if you attempt to load an HDR file, it will be automatically remapped -// to LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1; -// both of these constants can be reconfigured through this interface: -// -// stbi_hdr_to_ldr_gamma(2.2f); -// stbi_hdr_to_ldr_scale(1.0f); -// -// (note, do not use _inverse_ constants; stbi_image will invert them -// appropriately). -// -// Additionally, there is a new, parallel interface for loading files as -// (linear) floats to preserve the full dynamic range: -// -// float *data = stbi_loadf(filename, &x, &y, &n, 0); -// -// If you load LDR images through this interface, those images will -// be promoted to floating point values, run through the inverse of -// constants corresponding to the above: -// -// stbi_ldr_to_hdr_scale(1.0f); -// stbi_ldr_to_hdr_gamma(2.2f); -// -// Finally, given a filename (or an open file or memory block--see header -// file for details) containing image data, you can query for the "most -// appropriate" interface to use (that is, whether the image is HDR or -// not), using: -// -// stbi_is_hdr(char *filename); -// -// =========================================================================== -// -// iPhone PNG support: -// -// We optionally support converting iPhone-formatted PNGs (which store -// premultiplied BGRA) back to RGB, even though they're internally encoded -// differently. To enable this conversion, call -// stbi_convert_iphone_png_to_rgb(1). -// -// Call stbi_set_unpremultiply_on_load(1) as well to force a divide per -// pixel to remove any premultiplied alpha *only* if the image file explicitly -// says there's premultiplied data (currently only happens in iPhone images, -// and only if iPhone convert-to-rgb processing is on). -// -// =========================================================================== -// -// ADDITIONAL CONFIGURATION -// -// - You can suppress implementation of any of the decoders to reduce -// your code footprint by #defining one or more of the following -// symbols before creating the implementation. -// -// STBI_NO_JPEG -// STBI_NO_PNG -// STBI_NO_BMP -// STBI_NO_PSD -// STBI_NO_TGA -// STBI_NO_GIF -// STBI_NO_HDR -// STBI_NO_PIC -// STBI_NO_PNM (.ppm and .pgm) -// -// - You can request *only* certain decoders and suppress all other ones -// (this will be more forward-compatible, as addition of new decoders -// doesn't require you to disable them explicitly): -// -// STBI_ONLY_JPEG -// STBI_ONLY_PNG -// STBI_ONLY_BMP -// STBI_ONLY_PSD -// STBI_ONLY_TGA -// STBI_ONLY_GIF -// STBI_ONLY_HDR -// STBI_ONLY_PIC -// STBI_ONLY_PNM (.ppm and .pgm) -// -// - If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still -// want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB -// -// - If you define STBI_MAX_DIMENSIONS, stb_image will reject images greater -// than that size (in either width or height) without further processing. -// This is to let programs in the wild set an upper bound to prevent -// denial-of-service attacks on untrusted data, as one could generate a -// valid image of gigantic dimensions and force stb_image to allocate a -// huge block of memory and spend disproportionate time decoding it. By -// default this is set to (1 << 24), which is 16777216, but that's still -// very big. - -#ifndef STBI_NO_STDIO -#include -#endif // STBI_NO_STDIO - -#define STBI_VERSION 1 - -enum -{ - STBI_default = 0, // only used for desired_channels - - STBI_grey = 1, - STBI_grey_alpha = 2, - STBI_rgb = 3, - STBI_rgb_alpha = 4 -}; - -#include -typedef unsigned char stbi_uc; -typedef unsigned short stbi_us; - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef STBIDEF -#ifdef STB_IMAGE_STATIC -#define STBIDEF static -#else -#define STBIDEF extern -#endif -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// PRIMARY API - works on images of any type -// - -// -// load image by filename, open file, or memory buffer -// - -typedef struct -{ - int (*read) (void *user,char *data,int size); // fill 'data' with 'size' bytes. return number of bytes actually read - void (*skip) (void *user,int n); // skip the next 'n' bytes, or 'unget' the last -n bytes if negative - int (*eof) (void *user); // returns nonzero if we are at end of file/data -} stbi_io_callbacks; - -//////////////////////////////////// -// -// 8-bits-per-channel interface -// - -STBIDEF stbi_uc *stbi_load_from_memory (stbi_uc const *buffer, int len , int *x, int *y, int *channels_in_file, int desired_channels); -STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk , void *user, int *x, int *y, int *channels_in_file, int desired_channels); - -#ifndef STBI_NO_STDIO -STBIDEF stbi_uc *stbi_load (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); -STBIDEF stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); -// for stbi_load_from_file, file pointer is left pointing immediately after image -#endif - -#ifndef STBI_NO_GIF -STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp); -#endif - -#ifdef STBI_WINDOWS_UTF8 -STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input); -#endif - -//////////////////////////////////// -// -// 16-bits-per-channel interface -// - -STBIDEF stbi_us *stbi_load_16_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); -STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); - -#ifndef STBI_NO_STDIO -STBIDEF stbi_us *stbi_load_16 (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); -STBIDEF stbi_us *stbi_load_from_file_16(FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); -#endif - -//////////////////////////////////// -// -// float-per-channel interface -// -#ifndef STBI_NO_LINEAR - STBIDEF float *stbi_loadf_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); - STBIDEF float *stbi_loadf_from_callbacks (stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); - - #ifndef STBI_NO_STDIO - STBIDEF float *stbi_loadf (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); - STBIDEF float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); - #endif -#endif - -#ifndef STBI_NO_HDR - STBIDEF void stbi_hdr_to_ldr_gamma(float gamma); - STBIDEF void stbi_hdr_to_ldr_scale(float scale); -#endif // STBI_NO_HDR - -#ifndef STBI_NO_LINEAR - STBIDEF void stbi_ldr_to_hdr_gamma(float gamma); - STBIDEF void stbi_ldr_to_hdr_scale(float scale); -#endif // STBI_NO_LINEAR - -// stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR -STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user); -STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len); -#ifndef STBI_NO_STDIO -STBIDEF int stbi_is_hdr (char const *filename); -STBIDEF int stbi_is_hdr_from_file(FILE *f); -#endif // STBI_NO_STDIO - - -// get a VERY brief reason for failure -// on most compilers (and ALL modern mainstream compilers) this is threadsafe -STBIDEF const char *stbi_failure_reason (void); - -// free the loaded image -- this is just free() -STBIDEF void stbi_image_free (void *retval_from_stbi_load); - -// get image dimensions & components without fully decoding -STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); -STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp); -STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len); -STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *clbk, void *user); - -#ifndef STBI_NO_STDIO -STBIDEF int stbi_info (char const *filename, int *x, int *y, int *comp); -STBIDEF int stbi_info_from_file (FILE *f, int *x, int *y, int *comp); -STBIDEF int stbi_is_16_bit (char const *filename); -STBIDEF int stbi_is_16_bit_from_file(FILE *f); -#endif - - - -// for image formats that explicitly notate that they have premultiplied alpha, -// we just return the colors as stored in the file. set this flag to force -// unpremultiplication. results are undefined if the unpremultiply overflow. -STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply); - -// indicate whether we should process iphone images back to canonical format, -// or just pass them through "as-is" -STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert); - -// flip the image vertically, so the first pixel in the output array is the bottom left -STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip); - -// as above, but only applies to images loaded on the thread that calls the function -// this function is only available if your compiler supports thread-local variables; -// calling it will fail to link if your compiler doesn't -STBIDEF void stbi_set_unpremultiply_on_load_thread(int flag_true_if_should_unpremultiply); -STBIDEF void stbi_convert_iphone_png_to_rgb_thread(int flag_true_if_should_convert); -STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip); - -// ZLIB client - used by PNG, available for other purposes - -STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen); -STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header); -STBIDEF char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen); -STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); - -STBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen); -STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); - - -#ifdef __cplusplus -} -#endif - -// -// -//// end header file ///////////////////////////////////////////////////// -#endif // STBI_INCLUDE_STB_IMAGE_H - -#ifdef STB_IMAGE_IMPLEMENTATION - -#if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) \ - || defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) \ - || defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) \ - || defined(STBI_ONLY_ZLIB) - #ifndef STBI_ONLY_JPEG - #define STBI_NO_JPEG - #endif - #ifndef STBI_ONLY_PNG - #define STBI_NO_PNG - #endif - #ifndef STBI_ONLY_BMP - #define STBI_NO_BMP - #endif - #ifndef STBI_ONLY_PSD - #define STBI_NO_PSD - #endif - #ifndef STBI_ONLY_TGA - #define STBI_NO_TGA - #endif - #ifndef STBI_ONLY_GIF - #define STBI_NO_GIF - #endif - #ifndef STBI_ONLY_HDR - #define STBI_NO_HDR - #endif - #ifndef STBI_ONLY_PIC - #define STBI_NO_PIC - #endif - #ifndef STBI_ONLY_PNM - #define STBI_NO_PNM - #endif -#endif - -#if defined(STBI_NO_PNG) && !defined(STBI_SUPPORT_ZLIB) && !defined(STBI_NO_ZLIB) -#define STBI_NO_ZLIB -#endif - - -#include -#include // ptrdiff_t on osx -#include -#include -#include - -#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) -#include // ldexp, pow -#endif - -#ifndef STBI_NO_STDIO -#include -#endif - -#ifndef STBI_ASSERT -#include -#define STBI_ASSERT(x) assert(x) -#endif - -#ifdef __cplusplus -#define STBI_EXTERN extern "C" -#else -#define STBI_EXTERN extern -#endif - - -#ifndef _MSC_VER - #ifdef __cplusplus - #define stbi_inline inline - #else - #define stbi_inline - #endif -#else - #define stbi_inline __forceinline -#endif - -#ifndef STBI_NO_THREAD_LOCALS - #if defined(__cplusplus) && __cplusplus >= 201103L - #define STBI_THREAD_LOCAL thread_local - #elif defined(__GNUC__) && __GNUC__ < 5 - #define STBI_THREAD_LOCAL __thread - #elif defined(_MSC_VER) - #define STBI_THREAD_LOCAL __declspec(thread) - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__) - #define STBI_THREAD_LOCAL _Thread_local - #endif - - #ifndef STBI_THREAD_LOCAL - #if defined(__GNUC__) - #define STBI_THREAD_LOCAL __thread - #endif - #endif -#endif - -#if defined(_MSC_VER) || defined(__SYMBIAN32__) -typedef unsigned short stbi__uint16; -typedef signed short stbi__int16; -typedef unsigned int stbi__uint32; -typedef signed int stbi__int32; -#else -#include -typedef uint16_t stbi__uint16; -typedef int16_t stbi__int16; -typedef uint32_t stbi__uint32; -typedef int32_t stbi__int32; -#endif - -// should produce compiler error if size is wrong -typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; - -#ifdef _MSC_VER -#define STBI_NOTUSED(v) (void)(v) -#else -#define STBI_NOTUSED(v) (void)sizeof(v) -#endif - -#ifdef _MSC_VER -#define STBI_HAS_LROTL -#endif - -#ifdef STBI_HAS_LROTL - #define stbi_lrot(x,y) _lrotl(x,y) -#else - #define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (-(y) & 31))) -#endif - -#if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED)) -// ok -#elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC) && !defined(STBI_REALLOC_SIZED) -// ok -#else -#error "Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC (or STBI_REALLOC_SIZED)." -#endif - -#ifndef STBI_MALLOC -#define STBI_MALLOC(sz) malloc(sz) -#define STBI_REALLOC(p,newsz) realloc(p,newsz) -#define STBI_FREE(p) free(p) -#endif - -#ifndef STBI_REALLOC_SIZED -#define STBI_REALLOC_SIZED(p,oldsz,newsz) STBI_REALLOC(p,newsz) -#endif - -// x86/x64 detection -#if defined(__x86_64__) || defined(_M_X64) -#define STBI__X64_TARGET -#elif defined(__i386) || defined(_M_IX86) -#define STBI__X86_TARGET -#endif - -#if defined(__GNUC__) && defined(STBI__X86_TARGET) && !defined(__SSE2__) && !defined(STBI_NO_SIMD) -// gcc doesn't support sse2 intrinsics unless you compile with -msse2, -// which in turn means it gets to use SSE2 everywhere. This is unfortunate, -// but previous attempts to provide the SSE2 functions with runtime -// detection caused numerous issues. The way architecture extensions are -// exposed in GCC/Clang is, sadly, not really suited for one-file libs. -// New behavior: if compiled with -msse2, we use SSE2 without any -// detection; if not, we don't use it at all. -#define STBI_NO_SIMD -#endif - -#if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD) -// Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET -// -// 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the -// Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant. -// As a result, enabling SSE2 on 32-bit MinGW is dangerous when not -// simultaneously enabling "-mstackrealign". -// -// See https://github.com/nothings/stb/issues/81 for more information. -// -// So default to no SSE2 on 32-bit MinGW. If you've read this far and added -// -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2. -#define STBI_NO_SIMD -#endif - -#if !defined(STBI_NO_SIMD) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) -#define STBI_SSE2 -#include - -#ifdef _MSC_VER - -#if _MSC_VER >= 1400 // not VC6 -#include // __cpuid -static int stbi__cpuid3(void) -{ - int info[4]; - __cpuid(info,1); - return info[3]; -} -#else -static int stbi__cpuid3(void) -{ - int res; - __asm { - mov eax,1 - cpuid - mov res,edx - } - return res; -} -#endif - -#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name - -#if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) -static int stbi__sse2_available(void) -{ - int info3 = stbi__cpuid3(); - return ((info3 >> 26) & 1) != 0; -} -#endif - -#else // assume GCC-style if not VC++ -#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) - -#if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) -static int stbi__sse2_available(void) -{ - // If we're even attempting to compile this on GCC/Clang, that means - // -msse2 is on, which means the compiler is allowed to use SSE2 - // instructions at will, and so are we. - return 1; -} -#endif - -#endif -#endif - -// ARM NEON -#if defined(STBI_NO_SIMD) && defined(STBI_NEON) -#undef STBI_NEON -#endif - -#ifdef STBI_NEON -#include -#ifdef _MSC_VER -#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name -#else -#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) -#endif -#endif - -#ifndef STBI_SIMD_ALIGN -#define STBI_SIMD_ALIGN(type, name) type name -#endif - -#ifndef STBI_MAX_DIMENSIONS -#define STBI_MAX_DIMENSIONS (1 << 24) -#endif - -/////////////////////////////////////////////// -// -// stbi__context struct and start_xxx functions - -// stbi__context structure is our basic context used by all images, so it -// contains all the IO context, plus some basic image information -typedef struct -{ - stbi__uint32 img_x, img_y; - int img_n, img_out_n; - - stbi_io_callbacks io; - void *io_user_data; - - int read_from_callbacks; - int buflen; - stbi_uc buffer_start[128]; - int callback_already_read; - - stbi_uc *img_buffer, *img_buffer_end; - stbi_uc *img_buffer_original, *img_buffer_original_end; -} stbi__context; - - -static void stbi__refill_buffer(stbi__context *s); - -// initialize a memory-decode context -static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len) -{ - s->io.read = NULL; - s->read_from_callbacks = 0; - s->callback_already_read = 0; - s->img_buffer = s->img_buffer_original = (stbi_uc *) buffer; - s->img_buffer_end = s->img_buffer_original_end = (stbi_uc *) buffer+len; -} - -// initialize a callback-based context -static void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, void *user) -{ - s->io = *c; - s->io_user_data = user; - s->buflen = sizeof(s->buffer_start); - s->read_from_callbacks = 1; - s->callback_already_read = 0; - s->img_buffer = s->img_buffer_original = s->buffer_start; - stbi__refill_buffer(s); - s->img_buffer_original_end = s->img_buffer_end; -} - -#ifndef STBI_NO_STDIO - -static int stbi__stdio_read(void *user, char *data, int size) -{ - return (int) fread(data,1,size,(FILE*) user); -} - -static void stbi__stdio_skip(void *user, int n) -{ - int ch; - fseek((FILE*) user, n, SEEK_CUR); - ch = fgetc((FILE*) user); /* have to read a byte to reset feof()'s flag */ - if (ch != EOF) { - ungetc(ch, (FILE *) user); /* push byte back onto stream if valid. */ - } -} - -static int stbi__stdio_eof(void *user) -{ - return feof((FILE*) user) || ferror((FILE *) user); -} - -static stbi_io_callbacks stbi__stdio_callbacks = -{ - stbi__stdio_read, - stbi__stdio_skip, - stbi__stdio_eof, -}; - -static void stbi__start_file(stbi__context *s, FILE *f) -{ - stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *) f); -} - -//static void stop_file(stbi__context *s) { } - -#endif // !STBI_NO_STDIO - -static void stbi__rewind(stbi__context *s) -{ - // conceptually rewind SHOULD rewind to the beginning of the stream, - // but we just rewind to the beginning of the initial buffer, because - // we only use it after doing 'test', which only ever looks at at most 92 bytes - s->img_buffer = s->img_buffer_original; - s->img_buffer_end = s->img_buffer_original_end; -} - -enum -{ - STBI_ORDER_RGB, - STBI_ORDER_BGR -}; - -typedef struct -{ - int bits_per_channel; - int num_channels; - int channel_order; -} stbi__result_info; - -#ifndef STBI_NO_JPEG -static int stbi__jpeg_test(stbi__context *s); -static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -#ifndef STBI_NO_PNG -static int stbi__png_test(stbi__context *s); -static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp); -static int stbi__png_is16(stbi__context *s); -#endif - -#ifndef STBI_NO_BMP -static int stbi__bmp_test(stbi__context *s); -static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -#ifndef STBI_NO_TGA -static int stbi__tga_test(stbi__context *s); -static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -#ifndef STBI_NO_PSD -static int stbi__psd_test(stbi__context *s); -static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc); -static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp); -static int stbi__psd_is16(stbi__context *s); -#endif - -#ifndef STBI_NO_HDR -static int stbi__hdr_test(stbi__context *s); -static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -#ifndef STBI_NO_PIC -static int stbi__pic_test(stbi__context *s); -static void *stbi__pic_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -#ifndef STBI_NO_GIF -static int stbi__gif_test(stbi__context *s); -static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp); -static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -#ifndef STBI_NO_PNM -static int stbi__pnm_test(stbi__context *s); -static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp); -static int stbi__pnm_is16(stbi__context *s); -#endif - -static -#ifdef STBI_THREAD_LOCAL -STBI_THREAD_LOCAL -#endif -const char *stbi__g_failure_reason; - -STBIDEF const char *stbi_failure_reason(void) -{ - return stbi__g_failure_reason; -} - -#ifndef STBI_NO_FAILURE_STRINGS -static int stbi__err(const char *str) -{ - stbi__g_failure_reason = str; - return 0; -} -#endif - -static void *stbi__malloc(size_t size) -{ - return STBI_MALLOC(size); -} - -// stb_image uses ints pervasively, including for offset calculations. -// therefore the largest decoded image size we can support with the -// current code, even on 64-bit targets, is INT_MAX. this is not a -// significant limitation for the intended use case. -// -// we do, however, need to make sure our size calculations don't -// overflow. hence a few helper functions for size calculations that -// multiply integers together, making sure that they're non-negative -// and no overflow occurs. - -// return 1 if the sum is valid, 0 on overflow. -// negative terms are considered invalid. -static int stbi__addsizes_valid(int a, int b) -{ - if (b < 0) return 0; - // now 0 <= b <= INT_MAX, hence also - // 0 <= INT_MAX - b <= INTMAX. - // And "a + b <= INT_MAX" (which might overflow) is the - // same as a <= INT_MAX - b (no overflow) - return a <= INT_MAX - b; -} - -// returns 1 if the product is valid, 0 on overflow. -// negative factors are considered invalid. -static int stbi__mul2sizes_valid(int a, int b) -{ - if (a < 0 || b < 0) return 0; - if (b == 0) return 1; // mul-by-0 is always safe - // portable way to check for no overflows in a*b - return a <= INT_MAX/b; -} - -#if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR) -// returns 1 if "a*b + add" has no negative terms/factors and doesn't overflow -static int stbi__mad2sizes_valid(int a, int b, int add) -{ - return stbi__mul2sizes_valid(a, b) && stbi__addsizes_valid(a*b, add); -} -#endif - -// returns 1 if "a*b*c + add" has no negative terms/factors and doesn't overflow -static int stbi__mad3sizes_valid(int a, int b, int c, int add) -{ - return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && - stbi__addsizes_valid(a*b*c, add); -} - -// returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow -#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) || !defined(STBI_NO_PNM) -static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add) -{ - return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && - stbi__mul2sizes_valid(a*b*c, d) && stbi__addsizes_valid(a*b*c*d, add); -} -#endif - -#if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR) -// mallocs with size overflow checking -static void *stbi__malloc_mad2(int a, int b, int add) -{ - if (!stbi__mad2sizes_valid(a, b, add)) return NULL; - return stbi__malloc(a*b + add); -} -#endif - -static void *stbi__malloc_mad3(int a, int b, int c, int add) -{ - if (!stbi__mad3sizes_valid(a, b, c, add)) return NULL; - return stbi__malloc(a*b*c + add); -} - -#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) || !defined(STBI_NO_PNM) -static void *stbi__malloc_mad4(int a, int b, int c, int d, int add) -{ - if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL; - return stbi__malloc(a*b*c*d + add); -} -#endif - -// returns 1 if the sum of two signed ints is valid (between -2^31 and 2^31-1 inclusive), 0 on overflow. -static int stbi__addints_valid(int a, int b) -{ - if ((a >= 0) != (b >= 0)) return 1; // a and b have different signs, so no overflow - if (a < 0 && b < 0) return a >= INT_MIN - b; // same as a + b >= INT_MIN; INT_MIN - b cannot overflow since b < 0. - return a <= INT_MAX - b; -} - -// returns 1 if the product of two signed shorts is valid, 0 on overflow. -static int stbi__mul2shorts_valid(short a, short b) -{ - if (b == 0 || b == -1) return 1; // multiplication by 0 is always 0; check for -1 so SHRT_MIN/b doesn't overflow - if ((a >= 0) == (b >= 0)) return a <= SHRT_MAX/b; // product is positive, so similar to mul2sizes_valid - if (b < 0) return a <= SHRT_MIN / b; // same as a * b >= SHRT_MIN - return a >= SHRT_MIN / b; -} - -// stbi__err - error -// stbi__errpf - error returning pointer to float -// stbi__errpuc - error returning pointer to unsigned char - -#ifdef STBI_NO_FAILURE_STRINGS - #define stbi__err(x,y) 0 -#elif defined(STBI_FAILURE_USERMSG) - #define stbi__err(x,y) stbi__err(y) -#else - #define stbi__err(x,y) stbi__err(x) -#endif - -#define stbi__errpf(x,y) ((float *)(size_t) (stbi__err(x,y)?NULL:NULL)) -#define stbi__errpuc(x,y) ((unsigned char *)(size_t) (stbi__err(x,y)?NULL:NULL)) - -STBIDEF void stbi_image_free(void *retval_from_stbi_load) -{ - STBI_FREE(retval_from_stbi_load); -} - -#ifndef STBI_NO_LINEAR -static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp); -#endif - -#ifndef STBI_NO_HDR -static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp); -#endif - -static int stbi__vertically_flip_on_load_global = 0; - -STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip) -{ - stbi__vertically_flip_on_load_global = flag_true_if_should_flip; -} - -#ifndef STBI_THREAD_LOCAL -#define stbi__vertically_flip_on_load stbi__vertically_flip_on_load_global -#else -static STBI_THREAD_LOCAL int stbi__vertically_flip_on_load_local, stbi__vertically_flip_on_load_set; - -STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip) -{ - stbi__vertically_flip_on_load_local = flag_true_if_should_flip; - stbi__vertically_flip_on_load_set = 1; -} - -#define stbi__vertically_flip_on_load (stbi__vertically_flip_on_load_set \ - ? stbi__vertically_flip_on_load_local \ - : stbi__vertically_flip_on_load_global) -#endif // STBI_THREAD_LOCAL - -static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) -{ - memset(ri, 0, sizeof(*ri)); // make sure it's initialized if we add new fields - ri->bits_per_channel = 8; // default is 8 so most paths don't have to be changed - ri->channel_order = STBI_ORDER_RGB; // all current input & output are this, but this is here so we can add BGR order - ri->num_channels = 0; - - // test the formats with a very explicit header first (at least a FOURCC - // or distinctive magic number first) - #ifndef STBI_NO_PNG - if (stbi__png_test(s)) return stbi__png_load(s,x,y,comp,req_comp, ri); - #endif - #ifndef STBI_NO_BMP - if (stbi__bmp_test(s)) return stbi__bmp_load(s,x,y,comp,req_comp, ri); - #endif - #ifndef STBI_NO_GIF - if (stbi__gif_test(s)) return stbi__gif_load(s,x,y,comp,req_comp, ri); - #endif - #ifndef STBI_NO_PSD - if (stbi__psd_test(s)) return stbi__psd_load(s,x,y,comp,req_comp, ri, bpc); - #else - STBI_NOTUSED(bpc); - #endif - #ifndef STBI_NO_PIC - if (stbi__pic_test(s)) return stbi__pic_load(s,x,y,comp,req_comp, ri); - #endif - - // then the formats that can end up attempting to load with just 1 or 2 - // bytes matching expectations; these are prone to false positives, so - // try them later - #ifndef STBI_NO_JPEG - if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp, ri); - #endif - #ifndef STBI_NO_PNM - if (stbi__pnm_test(s)) return stbi__pnm_load(s,x,y,comp,req_comp, ri); - #endif - - #ifndef STBI_NO_HDR - if (stbi__hdr_test(s)) { - float *hdr = stbi__hdr_load(s, x,y,comp,req_comp, ri); - return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); - } - #endif - - #ifndef STBI_NO_TGA - // test tga last because it's a crappy test! - if (stbi__tga_test(s)) - return stbi__tga_load(s,x,y,comp,req_comp, ri); - #endif - - return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt"); -} - -static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, int channels) -{ - int i; - int img_len = w * h * channels; - stbi_uc *reduced; - - reduced = (stbi_uc *) stbi__malloc(img_len); - if (reduced == NULL) return stbi__errpuc("outofmem", "Out of memory"); - - for (i = 0; i < img_len; ++i) - reduced[i] = (stbi_uc)((orig[i] >> 8) & 0xFF); // top half of each byte is sufficient approx of 16->8 bit scaling - - STBI_FREE(orig); - return reduced; -} - -static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, int channels) -{ - int i; - int img_len = w * h * channels; - stbi__uint16 *enlarged; - - enlarged = (stbi__uint16 *) stbi__malloc(img_len*2); - if (enlarged == NULL) return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); - - for (i = 0; i < img_len; ++i) - enlarged[i] = (stbi__uint16)((orig[i] << 8) + orig[i]); // replicate to high and low byte, maps 0->0, 255->0xffff - - STBI_FREE(orig); - return enlarged; -} - -static void stbi__vertical_flip(void *image, int w, int h, int bytes_per_pixel) -{ - int row; - size_t bytes_per_row = (size_t)w * bytes_per_pixel; - stbi_uc temp[2048]; - stbi_uc *bytes = (stbi_uc *)image; - - for (row = 0; row < (h>>1); row++) { - stbi_uc *row0 = bytes + row*bytes_per_row; - stbi_uc *row1 = bytes + (h - row - 1)*bytes_per_row; - // swap row0 with row1 - size_t bytes_left = bytes_per_row; - while (bytes_left) { - size_t bytes_copy = (bytes_left < sizeof(temp)) ? bytes_left : sizeof(temp); - memcpy(temp, row0, bytes_copy); - memcpy(row0, row1, bytes_copy); - memcpy(row1, temp, bytes_copy); - row0 += bytes_copy; - row1 += bytes_copy; - bytes_left -= bytes_copy; - } - } -} - -#ifndef STBI_NO_GIF -static void stbi__vertical_flip_slices(void *image, int w, int h, int z, int bytes_per_pixel) -{ - int slice; - int slice_size = w * h * bytes_per_pixel; - - stbi_uc *bytes = (stbi_uc *)image; - for (slice = 0; slice < z; ++slice) { - stbi__vertical_flip(bytes, w, h, bytes_per_pixel); - bytes += slice_size; - } -} -#endif - -static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) -{ - stbi__result_info ri; - void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 8); - - if (result == NULL) - return NULL; - - // it is the responsibility of the loaders to make sure we get either 8 or 16 bit. - STBI_ASSERT(ri.bits_per_channel == 8 || ri.bits_per_channel == 16); - - if (ri.bits_per_channel != 8) { - result = stbi__convert_16_to_8((stbi__uint16 *) result, *x, *y, req_comp == 0 ? *comp : req_comp); - ri.bits_per_channel = 8; - } - - // @TODO: move stbi__convert_format to here - - if (stbi__vertically_flip_on_load) { - int channels = req_comp ? req_comp : *comp; - stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi_uc)); - } - - return (unsigned char *) result; -} - -static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) -{ - stbi__result_info ri; - void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 16); - - if (result == NULL) - return NULL; - - // it is the responsibility of the loaders to make sure we get either 8 or 16 bit. - STBI_ASSERT(ri.bits_per_channel == 8 || ri.bits_per_channel == 16); - - if (ri.bits_per_channel != 16) { - result = stbi__convert_8_to_16((stbi_uc *) result, *x, *y, req_comp == 0 ? *comp : req_comp); - ri.bits_per_channel = 16; - } - - // @TODO: move stbi__convert_format16 to here - // @TODO: special case RGB-to-Y (and RGBA-to-YA) for 8-bit-to-16-bit case to keep more precision - - if (stbi__vertically_flip_on_load) { - int channels = req_comp ? req_comp : *comp; - stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi__uint16)); - } - - return (stbi__uint16 *) result; -} - -#if !defined(STBI_NO_HDR) && !defined(STBI_NO_LINEAR) -static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, int req_comp) -{ - if (stbi__vertically_flip_on_load && result != NULL) { - int channels = req_comp ? req_comp : *comp; - stbi__vertical_flip(result, *x, *y, channels * sizeof(float)); - } -} -#endif - -#ifndef STBI_NO_STDIO - -#if defined(_WIN32) && defined(STBI_WINDOWS_UTF8) -STBI_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide); -STBI_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default); -#endif - -#if defined(_WIN32) && defined(STBI_WINDOWS_UTF8) -STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input) -{ - return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL); -} -#endif - -static FILE *stbi__fopen(char const *filename, char const *mode) -{ - FILE *f; -#if defined(_WIN32) && defined(STBI_WINDOWS_UTF8) - wchar_t wMode[64]; - wchar_t wFilename[1024]; - if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename)/sizeof(*wFilename))) - return 0; - - if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode)/sizeof(*wMode))) - return 0; - -#if defined(_MSC_VER) && _MSC_VER >= 1400 - if (0 != _wfopen_s(&f, wFilename, wMode)) - f = 0; -#else - f = _wfopen(wFilename, wMode); -#endif - -#elif defined(_MSC_VER) && _MSC_VER >= 1400 - if (0 != fopen_s(&f, filename, mode)) - f=0; -#else - f = fopen(filename, mode); -#endif - return f; -} - - -STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - FILE *f = stbi__fopen(filename, "rb"); - unsigned char *result; - if (!f) return stbi__errpuc("can't fopen", "Unable to open file"); - result = stbi_load_from_file(f,x,y,comp,req_comp); - fclose(f); - return result; -} - -STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - unsigned char *result; - stbi__context s; - stbi__start_file(&s,f); - result = stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); - if (result) { - // need to 'unget' all the characters in the IO buffer - fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); - } - return result; -} - -STBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - stbi__uint16 *result; - stbi__context s; - stbi__start_file(&s,f); - result = stbi__load_and_postprocess_16bit(&s,x,y,comp,req_comp); - if (result) { - // need to 'unget' all the characters in the IO buffer - fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); - } - return result; -} - -STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - FILE *f = stbi__fopen(filename, "rb"); - stbi__uint16 *result; - if (!f) return (stbi_us *) stbi__errpuc("can't fopen", "Unable to open file"); - result = stbi_load_from_file_16(f,x,y,comp,req_comp); - fclose(f); - return result; -} - - -#endif //!STBI_NO_STDIO - -STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels) -{ - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); -} - -STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels) -{ - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); - return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); -} - -STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); -} - -STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) -{ - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); - return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); -} - -#ifndef STBI_NO_GIF -STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp) -{ - unsigned char *result; - stbi__context s; - stbi__start_mem(&s,buffer,len); - - result = (unsigned char*) stbi__load_gif_main(&s, delays, x, y, z, comp, req_comp); - if (stbi__vertically_flip_on_load) { - stbi__vertical_flip_slices( result, *x, *y, *z, *comp ); - } - - return result; -} -#endif - -#ifndef STBI_NO_LINEAR -static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) -{ - unsigned char *data; - #ifndef STBI_NO_HDR - if (stbi__hdr_test(s)) { - stbi__result_info ri; - float *hdr_data = stbi__hdr_load(s,x,y,comp,req_comp, &ri); - if (hdr_data) - stbi__float_postprocess(hdr_data,x,y,comp,req_comp); - return hdr_data; - } - #endif - data = stbi__load_and_postprocess_8bit(s, x, y, comp, req_comp); - if (data) - return stbi__ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); - return stbi__errpf("unknown image type", "Image not of any known type, or corrupt"); -} - -STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__loadf_main(&s,x,y,comp,req_comp); -} - -STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) -{ - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); - return stbi__loadf_main(&s,x,y,comp,req_comp); -} - -#ifndef STBI_NO_STDIO -STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - float *result; - FILE *f = stbi__fopen(filename, "rb"); - if (!f) return stbi__errpf("can't fopen", "Unable to open file"); - result = stbi_loadf_from_file(f,x,y,comp,req_comp); - fclose(f); - return result; -} - -STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - stbi__context s; - stbi__start_file(&s,f); - return stbi__loadf_main(&s,x,y,comp,req_comp); -} -#endif // !STBI_NO_STDIO - -#endif // !STBI_NO_LINEAR - -// these is-hdr-or-not is defined independent of whether STBI_NO_LINEAR is -// defined, for API simplicity; if STBI_NO_LINEAR is defined, it always -// reports false! - -STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len) -{ - #ifndef STBI_NO_HDR - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__hdr_test(&s); - #else - STBI_NOTUSED(buffer); - STBI_NOTUSED(len); - return 0; - #endif -} - -#ifndef STBI_NO_STDIO -STBIDEF int stbi_is_hdr (char const *filename) -{ - FILE *f = stbi__fopen(filename, "rb"); - int result=0; - if (f) { - result = stbi_is_hdr_from_file(f); - fclose(f); - } - return result; -} - -STBIDEF int stbi_is_hdr_from_file(FILE *f) -{ - #ifndef STBI_NO_HDR - long pos = ftell(f); - int res; - stbi__context s; - stbi__start_file(&s,f); - res = stbi__hdr_test(&s); - fseek(f, pos, SEEK_SET); - return res; - #else - STBI_NOTUSED(f); - return 0; - #endif -} -#endif // !STBI_NO_STDIO - -STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user) -{ - #ifndef STBI_NO_HDR - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); - return stbi__hdr_test(&s); - #else - STBI_NOTUSED(clbk); - STBI_NOTUSED(user); - return 0; - #endif -} - -#ifndef STBI_NO_LINEAR -static float stbi__l2h_gamma=2.2f, stbi__l2h_scale=1.0f; - -STBIDEF void stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; } -STBIDEF void stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; } -#endif - -static float stbi__h2l_gamma_i=1.0f/2.2f, stbi__h2l_scale_i=1.0f; - -STBIDEF void stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1/gamma; } -STBIDEF void stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1/scale; } - - -////////////////////////////////////////////////////////////////////////////// -// -// Common code used by all image loaders -// - -enum -{ - STBI__SCAN_load=0, - STBI__SCAN_type, - STBI__SCAN_header -}; - -static void stbi__refill_buffer(stbi__context *s) -{ - int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen); - s->callback_already_read += (int) (s->img_buffer - s->img_buffer_original); - if (n == 0) { - // at end of file, treat same as if from memory, but need to handle case - // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file - s->read_from_callbacks = 0; - s->img_buffer = s->buffer_start; - s->img_buffer_end = s->buffer_start+1; - *s->img_buffer = 0; - } else { - s->img_buffer = s->buffer_start; - s->img_buffer_end = s->buffer_start + n; - } -} - -stbi_inline static stbi_uc stbi__get8(stbi__context *s) -{ - if (s->img_buffer < s->img_buffer_end) - return *s->img_buffer++; - if (s->read_from_callbacks) { - stbi__refill_buffer(s); - return *s->img_buffer++; - } - return 0; -} - -#if defined(STBI_NO_JPEG) && defined(STBI_NO_HDR) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) -// nothing -#else -stbi_inline static int stbi__at_eof(stbi__context *s) -{ - if (s->io.read) { - if (!(s->io.eof)(s->io_user_data)) return 0; - // if feof() is true, check if buffer = end - // special case: we've only got the special 0 character at the end - if (s->read_from_callbacks == 0) return 1; - } - - return s->img_buffer >= s->img_buffer_end; -} -#endif - -#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) -// nothing -#else -static void stbi__skip(stbi__context *s, int n) -{ - if (n == 0) return; // already there! - if (n < 0) { - s->img_buffer = s->img_buffer_end; - return; - } - if (s->io.read) { - int blen = (int) (s->img_buffer_end - s->img_buffer); - if (blen < n) { - s->img_buffer = s->img_buffer_end; - (s->io.skip)(s->io_user_data, n - blen); - return; - } - } - s->img_buffer += n; -} -#endif - -#if defined(STBI_NO_PNG) && defined(STBI_NO_TGA) && defined(STBI_NO_HDR) && defined(STBI_NO_PNM) -// nothing -#else -static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n) -{ - if (s->io.read) { - int blen = (int) (s->img_buffer_end - s->img_buffer); - if (blen < n) { - int res, count; - - memcpy(buffer, s->img_buffer, blen); - - count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen); - res = (count == (n-blen)); - s->img_buffer = s->img_buffer_end; - return res; - } - } - - if (s->img_buffer+n <= s->img_buffer_end) { - memcpy(buffer, s->img_buffer, n); - s->img_buffer += n; - return 1; - } else - return 0; -} -#endif - -#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC) -// nothing -#else -static int stbi__get16be(stbi__context *s) -{ - int z = stbi__get8(s); - return (z << 8) + stbi__get8(s); -} -#endif - -#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC) -// nothing -#else -static stbi__uint32 stbi__get32be(stbi__context *s) -{ - stbi__uint32 z = stbi__get16be(s); - return (z << 16) + stbi__get16be(s); -} -#endif - -#if defined(STBI_NO_BMP) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) -// nothing -#else -static int stbi__get16le(stbi__context *s) -{ - int z = stbi__get8(s); - return z + (stbi__get8(s) << 8); -} -#endif - -#ifndef STBI_NO_BMP -static stbi__uint32 stbi__get32le(stbi__context *s) -{ - stbi__uint32 z = stbi__get16le(s); - z += (stbi__uint32)stbi__get16le(s) << 16; - return z; -} -#endif - -#define STBI__BYTECAST(x) ((stbi_uc) ((x) & 255)) // truncate int to byte without warnings - -#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) -// nothing -#else -////////////////////////////////////////////////////////////////////////////// -// -// generic converter from built-in img_n to req_comp -// individual types do this automatically as much as possible (e.g. jpeg -// does all cases internally since it needs to colorspace convert anyway, -// and it never has alpha, so very few cases ). png can automatically -// interleave an alpha=255 channel, but falls back to this for other cases -// -// assume data buffer is malloced, so malloc a new one and free that one -// only failure mode is malloc failing - -static stbi_uc stbi__compute_y(int r, int g, int b) -{ - return (stbi_uc) (((r*77) + (g*150) + (29*b)) >> 8); -} -#endif - -#if defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) -// nothing -#else -static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y) -{ - int i,j; - unsigned char *good; - - if (req_comp == img_n) return data; - STBI_ASSERT(req_comp >= 1 && req_comp <= 4); - - good = (unsigned char *) stbi__malloc_mad3(req_comp, x, y, 0); - if (good == NULL) { - STBI_FREE(data); - return stbi__errpuc("outofmem", "Out of memory"); - } - - for (j=0; j < (int) y; ++j) { - unsigned char *src = data + j * x * img_n ; - unsigned char *dest = good + j * x * req_comp; - - #define STBI__COMBO(a,b) ((a)*8+(b)) - #define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) - // convert source image with img_n components to one with req_comp components; - // avoid switch per pixel, so use switch per scanline and massive macros - switch (STBI__COMBO(img_n, req_comp)) { - STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=255; } break; - STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; - STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=255; } break; - STBI__CASE(2,1) { dest[0]=src[0]; } break; - STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; - STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1]; } break; - STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=255; } break; - STBI__CASE(3,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break; - STBI__CASE(3,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = 255; } break; - STBI__CASE(4,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break; - STBI__CASE(4,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = src[3]; } break; - STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2]; } break; - default: STBI_ASSERT(0); STBI_FREE(data); STBI_FREE(good); return stbi__errpuc("unsupported", "Unsupported format conversion"); - } - #undef STBI__CASE - } - - STBI_FREE(data); - return good; -} -#endif - -#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) -// nothing -#else -static stbi__uint16 stbi__compute_y_16(int r, int g, int b) -{ - return (stbi__uint16) (((r*77) + (g*150) + (29*b)) >> 8); -} -#endif - -#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) -// nothing -#else -static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y) -{ - int i,j; - stbi__uint16 *good; - - if (req_comp == img_n) return data; - STBI_ASSERT(req_comp >= 1 && req_comp <= 4); - - good = (stbi__uint16 *) stbi__malloc(req_comp * x * y * 2); - if (good == NULL) { - STBI_FREE(data); - return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); - } - - for (j=0; j < (int) y; ++j) { - stbi__uint16 *src = data + j * x * img_n ; - stbi__uint16 *dest = good + j * x * req_comp; - - #define STBI__COMBO(a,b) ((a)*8+(b)) - #define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) - // convert source image with img_n components to one with req_comp components; - // avoid switch per pixel, so use switch per scanline and massive macros - switch (STBI__COMBO(img_n, req_comp)) { - STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=0xffff; } break; - STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; - STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=0xffff; } break; - STBI__CASE(2,1) { dest[0]=src[0]; } break; - STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; - STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1]; } break; - STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=0xffff; } break; - STBI__CASE(3,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break; - STBI__CASE(3,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = 0xffff; } break; - STBI__CASE(4,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break; - STBI__CASE(4,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = src[3]; } break; - STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2]; } break; - default: STBI_ASSERT(0); STBI_FREE(data); STBI_FREE(good); return (stbi__uint16*) stbi__errpuc("unsupported", "Unsupported format conversion"); - } - #undef STBI__CASE - } - - STBI_FREE(data); - return good; -} -#endif - -#ifndef STBI_NO_LINEAR -static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp) -{ - int i,k,n; - float *output; - if (!data) return NULL; - output = (float *) stbi__malloc_mad4(x, y, comp, sizeof(float), 0); - if (output == NULL) { STBI_FREE(data); return stbi__errpf("outofmem", "Out of memory"); } - // compute number of non-alpha components - if (comp & 1) n = comp; else n = comp-1; - for (i=0; i < x*y; ++i) { - for (k=0; k < n; ++k) { - output[i*comp + k] = (float) (pow(data[i*comp+k]/255.0f, stbi__l2h_gamma) * stbi__l2h_scale); - } - } - if (n < comp) { - for (i=0; i < x*y; ++i) { - output[i*comp + n] = data[i*comp + n]/255.0f; - } - } - STBI_FREE(data); - return output; -} -#endif - -#ifndef STBI_NO_HDR -#define stbi__float2int(x) ((int) (x)) -static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp) -{ - int i,k,n; - stbi_uc *output; - if (!data) return NULL; - output = (stbi_uc *) stbi__malloc_mad3(x, y, comp, 0); - if (output == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); } - // compute number of non-alpha components - if (comp & 1) n = comp; else n = comp-1; - for (i=0; i < x*y; ++i) { - for (k=0; k < n; ++k) { - float z = (float) pow(data[i*comp+k]*stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f; - if (z < 0) z = 0; - if (z > 255) z = 255; - output[i*comp + k] = (stbi_uc) stbi__float2int(z); - } - if (k < comp) { - float z = data[i*comp+k] * 255 + 0.5f; - if (z < 0) z = 0; - if (z > 255) z = 255; - output[i*comp + k] = (stbi_uc) stbi__float2int(z); - } - } - STBI_FREE(data); - return output; -} -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// "baseline" JPEG/JFIF decoder -// -// simple implementation -// - doesn't support delayed output of y-dimension -// - simple interface (only one output format: 8-bit interleaved RGB) -// - doesn't try to recover corrupt jpegs -// - doesn't allow partial loading, loading multiple at once -// - still fast on x86 (copying globals into locals doesn't help x86) -// - allocates lots of intermediate memory (full size of all components) -// - non-interleaved case requires this anyway -// - allows good upsampling (see next) -// high-quality -// - upsampled channels are bilinearly interpolated, even across blocks -// - quality integer IDCT derived from IJG's 'slow' -// performance -// - fast huffman; reasonable integer IDCT -// - some SIMD kernels for common paths on targets with SSE2/NEON -// - uses a lot of intermediate memory, could cache poorly - -#ifndef STBI_NO_JPEG - -// huffman decoding acceleration -#define FAST_BITS 9 // larger handles more cases; smaller stomps less cache - -typedef struct -{ - stbi_uc fast[1 << FAST_BITS]; - // weirdly, repacking this into AoS is a 10% speed loss, instead of a win - stbi__uint16 code[256]; - stbi_uc values[256]; - stbi_uc size[257]; - unsigned int maxcode[18]; - int delta[17]; // old 'firstsymbol' - old 'firstcode' -} stbi__huffman; - -typedef struct -{ - stbi__context *s; - stbi__huffman huff_dc[4]; - stbi__huffman huff_ac[4]; - stbi__uint16 dequant[4][64]; - stbi__int16 fast_ac[4][1 << FAST_BITS]; - -// sizes for components, interleaved MCUs - int img_h_max, img_v_max; - int img_mcu_x, img_mcu_y; - int img_mcu_w, img_mcu_h; - -// definition of jpeg image component - struct - { - int id; - int h,v; - int tq; - int hd,ha; - int dc_pred; - - int x,y,w2,h2; - stbi_uc *data; - void *raw_data, *raw_coeff; - stbi_uc *linebuf; - short *coeff; // progressive only - int coeff_w, coeff_h; // number of 8x8 coefficient blocks - } img_comp[4]; - - stbi__uint32 code_buffer; // jpeg entropy-coded buffer - int code_bits; // number of valid bits - unsigned char marker; // marker seen while filling entropy buffer - int nomore; // flag if we saw a marker so must stop - - int progressive; - int spec_start; - int spec_end; - int succ_high; - int succ_low; - int eob_run; - int jfif; - int app14_color_transform; // Adobe APP14 tag - int rgb; - - int scan_n, order[4]; - int restart_interval, todo; - -// kernels - void (*idct_block_kernel)(stbi_uc *out, int out_stride, short data[64]); - void (*YCbCr_to_RGB_kernel)(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step); - stbi_uc *(*resample_row_hv_2_kernel)(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs); -} stbi__jpeg; - -static int stbi__build_huffman(stbi__huffman *h, int *count) -{ - int i,j,k=0; - unsigned int code; - // build size list for each symbol (from JPEG spec) - for (i=0; i < 16; ++i) { - for (j=0; j < count[i]; ++j) { - h->size[k++] = (stbi_uc) (i+1); - if(k >= 257) return stbi__err("bad size list","Corrupt JPEG"); - } - } - h->size[k] = 0; - - // compute actual symbols (from jpeg spec) - code = 0; - k = 0; - for(j=1; j <= 16; ++j) { - // compute delta to add to code to compute symbol id - h->delta[j] = k - code; - if (h->size[k] == j) { - while (h->size[k] == j) - h->code[k++] = (stbi__uint16) (code++); - if (code-1 >= (1u << j)) return stbi__err("bad code lengths","Corrupt JPEG"); - } - // compute largest code + 1 for this size, preshifted as needed later - h->maxcode[j] = code << (16-j); - code <<= 1; - } - h->maxcode[j] = 0xffffffff; - - // build non-spec acceleration table; 255 is flag for not-accelerated - memset(h->fast, 255, 1 << FAST_BITS); - for (i=0; i < k; ++i) { - int s = h->size[i]; - if (s <= FAST_BITS) { - int c = h->code[i] << (FAST_BITS-s); - int m = 1 << (FAST_BITS-s); - for (j=0; j < m; ++j) { - h->fast[c+j] = (stbi_uc) i; - } - } - } - return 1; -} - -// build a table that decodes both magnitude and value of small ACs in -// one go. -static void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h) -{ - int i; - for (i=0; i < (1 << FAST_BITS); ++i) { - stbi_uc fast = h->fast[i]; - fast_ac[i] = 0; - if (fast < 255) { - int rs = h->values[fast]; - int run = (rs >> 4) & 15; - int magbits = rs & 15; - int len = h->size[fast]; - - if (magbits && len + magbits <= FAST_BITS) { - // magnitude code followed by receive_extend code - int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits); - int m = 1 << (magbits - 1); - if (k < m) k += (~0U << magbits) + 1; - // if the result is small enough, we can fit it in fast_ac table - if (k >= -128 && k <= 127) - fast_ac[i] = (stbi__int16) ((k * 256) + (run * 16) + (len + magbits)); - } - } - } -} - -static void stbi__grow_buffer_unsafe(stbi__jpeg *j) -{ - do { - unsigned int b = j->nomore ? 0 : stbi__get8(j->s); - if (b == 0xff) { - int c = stbi__get8(j->s); - while (c == 0xff) c = stbi__get8(j->s); // consume fill bytes - if (c != 0) { - j->marker = (unsigned char) c; - j->nomore = 1; - return; - } - } - j->code_buffer |= b << (24 - j->code_bits); - j->code_bits += 8; - } while (j->code_bits <= 24); -} - -// (1 << n) - 1 -static const stbi__uint32 stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; - -// decode a jpeg huffman value from the bitstream -stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) -{ - unsigned int temp; - int c,k; - - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); - - // look at the top FAST_BITS and determine what symbol ID it is, - // if the code is <= FAST_BITS - c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); - k = h->fast[c]; - if (k < 255) { - int s = h->size[k]; - if (s > j->code_bits) - return -1; - j->code_buffer <<= s; - j->code_bits -= s; - return h->values[k]; - } - - // naive test is to shift the code_buffer down so k bits are - // valid, then test against maxcode. To speed this up, we've - // preshifted maxcode left so that it has (16-k) 0s at the - // end; in other words, regardless of the number of bits, it - // wants to be compared against something shifted to have 16; - // that way we don't need to shift inside the loop. - temp = j->code_buffer >> 16; - for (k=FAST_BITS+1 ; ; ++k) - if (temp < h->maxcode[k]) - break; - if (k == 17) { - // error! code not found - j->code_bits -= 16; - return -1; - } - - if (k > j->code_bits) - return -1; - - // convert the huffman code to the symbol id - c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k]; - if(c < 0 || c >= 256) // symbol id out of bounds! - return -1; - STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]); - - // convert the id to a symbol - j->code_bits -= k; - j->code_buffer <<= k; - return h->values[c]; -} - -// bias[n] = (-1<code_bits < n) stbi__grow_buffer_unsafe(j); - if (j->code_bits < n) return 0; // ran out of bits from stream, return 0s intead of continuing - - sgn = j->code_buffer >> 31; // sign bit always in MSB; 0 if MSB clear (positive), 1 if MSB set (negative) - k = stbi_lrot(j->code_buffer, n); - j->code_buffer = k & ~stbi__bmask[n]; - k &= stbi__bmask[n]; - j->code_bits -= n; - return k + (stbi__jbias[n] & (sgn - 1)); -} - -// get some unsigned bits -stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n) -{ - unsigned int k; - if (j->code_bits < n) stbi__grow_buffer_unsafe(j); - if (j->code_bits < n) return 0; // ran out of bits from stream, return 0s intead of continuing - k = stbi_lrot(j->code_buffer, n); - j->code_buffer = k & ~stbi__bmask[n]; - k &= stbi__bmask[n]; - j->code_bits -= n; - return k; -} - -stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j) -{ - unsigned int k; - if (j->code_bits < 1) stbi__grow_buffer_unsafe(j); - if (j->code_bits < 1) return 0; // ran out of bits from stream, return 0s intead of continuing - k = j->code_buffer; - j->code_buffer <<= 1; - --j->code_bits; - return k & 0x80000000; -} - -// given a value that's at position X in the zigzag stream, -// where does it appear in the 8x8 matrix coded as row-major? -static const stbi_uc stbi__jpeg_dezigzag[64+15] = -{ - 0, 1, 8, 16, 9, 2, 3, 10, - 17, 24, 32, 25, 18, 11, 4, 5, - 12, 19, 26, 33, 40, 48, 41, 34, - 27, 20, 13, 6, 7, 14, 21, 28, - 35, 42, 49, 56, 57, 50, 43, 36, - 29, 22, 15, 23, 30, 37, 44, 51, - 58, 59, 52, 45, 38, 31, 39, 46, - 53, 60, 61, 54, 47, 55, 62, 63, - // let corrupt input sample past end - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63 -}; - -// decode one 64-entry block-- -static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi__uint16 *dequant) -{ - int diff,dc,k; - int t; - - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); - t = stbi__jpeg_huff_decode(j, hdc); - if (t < 0 || t > 15) return stbi__err("bad huffman code","Corrupt JPEG"); - - // 0 all the ac values now so we can do it 32-bits at a time - memset(data,0,64*sizeof(data[0])); - - diff = t ? stbi__extend_receive(j, t) : 0; - if (!stbi__addints_valid(j->img_comp[b].dc_pred, diff)) return stbi__err("bad delta","Corrupt JPEG"); - dc = j->img_comp[b].dc_pred + diff; - j->img_comp[b].dc_pred = dc; - if (!stbi__mul2shorts_valid(dc, dequant[0])) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); - data[0] = (short) (dc * dequant[0]); - - // decode AC components, see JPEG spec - k = 1; - do { - unsigned int zig; - int c,r,s; - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); - c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); - r = fac[c]; - if (r) { // fast-AC path - k += (r >> 4) & 15; // run - s = r & 15; // combined length - if (s > j->code_bits) return stbi__err("bad huffman code", "Combined length longer than code bits available"); - j->code_buffer <<= s; - j->code_bits -= s; - // decode into unzigzag'd location - zig = stbi__jpeg_dezigzag[k++]; - data[zig] = (short) ((r >> 8) * dequant[zig]); - } else { - int rs = stbi__jpeg_huff_decode(j, hac); - if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); - s = rs & 15; - r = rs >> 4; - if (s == 0) { - if (rs != 0xf0) break; // end block - k += 16; - } else { - k += r; - // decode into unzigzag'd location - zig = stbi__jpeg_dezigzag[k++]; - data[zig] = (short) (stbi__extend_receive(j,s) * dequant[zig]); - } - } - } while (k < 64); - return 1; -} - -static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b) -{ - int diff,dc; - int t; - if (j->spec_end != 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); - - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); - - if (j->succ_high == 0) { - // first scan for DC coefficient, must be first - memset(data,0,64*sizeof(data[0])); // 0 all the ac values now - t = stbi__jpeg_huff_decode(j, hdc); - if (t < 0 || t > 15) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); - diff = t ? stbi__extend_receive(j, t) : 0; - - if (!stbi__addints_valid(j->img_comp[b].dc_pred, diff)) return stbi__err("bad delta", "Corrupt JPEG"); - dc = j->img_comp[b].dc_pred + diff; - j->img_comp[b].dc_pred = dc; - if (!stbi__mul2shorts_valid(dc, 1 << j->succ_low)) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); - data[0] = (short) (dc * (1 << j->succ_low)); - } else { - // refinement scan for DC coefficient - if (stbi__jpeg_get_bit(j)) - data[0] += (short) (1 << j->succ_low); - } - return 1; -} - -// @OPTIMIZE: store non-zigzagged during the decode passes, -// and only de-zigzag when dequantizing -static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, stbi__int16 *fac) -{ - int k; - if (j->spec_start == 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); - - if (j->succ_high == 0) { - int shift = j->succ_low; - - if (j->eob_run) { - --j->eob_run; - return 1; - } - - k = j->spec_start; - do { - unsigned int zig; - int c,r,s; - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); - c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); - r = fac[c]; - if (r) { // fast-AC path - k += (r >> 4) & 15; // run - s = r & 15; // combined length - if (s > j->code_bits) return stbi__err("bad huffman code", "Combined length longer than code bits available"); - j->code_buffer <<= s; - j->code_bits -= s; - zig = stbi__jpeg_dezigzag[k++]; - data[zig] = (short) ((r >> 8) * (1 << shift)); - } else { - int rs = stbi__jpeg_huff_decode(j, hac); - if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); - s = rs & 15; - r = rs >> 4; - if (s == 0) { - if (r < 15) { - j->eob_run = (1 << r); - if (r) - j->eob_run += stbi__jpeg_get_bits(j, r); - --j->eob_run; - break; - } - k += 16; - } else { - k += r; - zig = stbi__jpeg_dezigzag[k++]; - data[zig] = (short) (stbi__extend_receive(j,s) * (1 << shift)); - } - } - } while (k <= j->spec_end); - } else { - // refinement scan for these AC coefficients - - short bit = (short) (1 << j->succ_low); - - if (j->eob_run) { - --j->eob_run; - for (k = j->spec_start; k <= j->spec_end; ++k) { - short *p = &data[stbi__jpeg_dezigzag[k]]; - if (*p != 0) - if (stbi__jpeg_get_bit(j)) - if ((*p & bit)==0) { - if (*p > 0) - *p += bit; - else - *p -= bit; - } - } - } else { - k = j->spec_start; - do { - int r,s; - int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast path here, advance-by-r is so slow, eh - if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); - s = rs & 15; - r = rs >> 4; - if (s == 0) { - if (r < 15) { - j->eob_run = (1 << r) - 1; - if (r) - j->eob_run += stbi__jpeg_get_bits(j, r); - r = 64; // force end of block - } else { - // r=15 s=0 should write 16 0s, so we just do - // a run of 15 0s and then write s (which is 0), - // so we don't have to do anything special here - } - } else { - if (s != 1) return stbi__err("bad huffman code", "Corrupt JPEG"); - // sign bit - if (stbi__jpeg_get_bit(j)) - s = bit; - else - s = -bit; - } - - // advance by r - while (k <= j->spec_end) { - short *p = &data[stbi__jpeg_dezigzag[k++]]; - if (*p != 0) { - if (stbi__jpeg_get_bit(j)) - if ((*p & bit)==0) { - if (*p > 0) - *p += bit; - else - *p -= bit; - } - } else { - if (r == 0) { - *p = (short) s; - break; - } - --r; - } - } - } while (k <= j->spec_end); - } - } - return 1; -} - -// take a -128..127 value and stbi__clamp it and convert to 0..255 -stbi_inline static stbi_uc stbi__clamp(int x) -{ - // trick to use a single test to catch both cases - if ((unsigned int) x > 255) { - if (x < 0) return 0; - if (x > 255) return 255; - } - return (stbi_uc) x; -} - -#define stbi__f2f(x) ((int) (((x) * 4096 + 0.5))) -#define stbi__fsh(x) ((x) * 4096) - -// derived from jidctint -- DCT_ISLOW -#define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ - int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ - p2 = s2; \ - p3 = s6; \ - p1 = (p2+p3) * stbi__f2f(0.5411961f); \ - t2 = p1 + p3*stbi__f2f(-1.847759065f); \ - t3 = p1 + p2*stbi__f2f( 0.765366865f); \ - p2 = s0; \ - p3 = s4; \ - t0 = stbi__fsh(p2+p3); \ - t1 = stbi__fsh(p2-p3); \ - x0 = t0+t3; \ - x3 = t0-t3; \ - x1 = t1+t2; \ - x2 = t1-t2; \ - t0 = s7; \ - t1 = s5; \ - t2 = s3; \ - t3 = s1; \ - p3 = t0+t2; \ - p4 = t1+t3; \ - p1 = t0+t3; \ - p2 = t1+t2; \ - p5 = (p3+p4)*stbi__f2f( 1.175875602f); \ - t0 = t0*stbi__f2f( 0.298631336f); \ - t1 = t1*stbi__f2f( 2.053119869f); \ - t2 = t2*stbi__f2f( 3.072711026f); \ - t3 = t3*stbi__f2f( 1.501321110f); \ - p1 = p5 + p1*stbi__f2f(-0.899976223f); \ - p2 = p5 + p2*stbi__f2f(-2.562915447f); \ - p3 = p3*stbi__f2f(-1.961570560f); \ - p4 = p4*stbi__f2f(-0.390180644f); \ - t3 += p1+p4; \ - t2 += p2+p3; \ - t1 += p2+p4; \ - t0 += p1+p3; - -static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64]) -{ - int i,val[64],*v=val; - stbi_uc *o; - short *d = data; - - // columns - for (i=0; i < 8; ++i,++d, ++v) { - // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing - if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0 - && d[40]==0 && d[48]==0 && d[56]==0) { - // no shortcut 0 seconds - // (1|2|3|4|5|6|7)==0 0 seconds - // all separate -0.047 seconds - // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds - int dcterm = d[0]*4; - v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; - } else { - STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56]) - // constants scaled things up by 1<<12; let's bring them back - // down, but keep 2 extra bits of precision - x0 += 512; x1 += 512; x2 += 512; x3 += 512; - v[ 0] = (x0+t3) >> 10; - v[56] = (x0-t3) >> 10; - v[ 8] = (x1+t2) >> 10; - v[48] = (x1-t2) >> 10; - v[16] = (x2+t1) >> 10; - v[40] = (x2-t1) >> 10; - v[24] = (x3+t0) >> 10; - v[32] = (x3-t0) >> 10; - } - } - - for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { - // no fast case since the first 1D IDCT spread components out - STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) - // constants scaled things up by 1<<12, plus we had 1<<2 from first - // loop, plus horizontal and vertical each scale by sqrt(8) so together - // we've got an extra 1<<3, so 1<<17 total we need to remove. - // so we want to round that, which means adding 0.5 * 1<<17, - // aka 65536. Also, we'll end up with -128 to 127 that we want - // to encode as 0..255 by adding 128, so we'll add that before the shift - x0 += 65536 + (128<<17); - x1 += 65536 + (128<<17); - x2 += 65536 + (128<<17); - x3 += 65536 + (128<<17); - // tried computing the shifts into temps, or'ing the temps to see - // if any were out of range, but that was slower - o[0] = stbi__clamp((x0+t3) >> 17); - o[7] = stbi__clamp((x0-t3) >> 17); - o[1] = stbi__clamp((x1+t2) >> 17); - o[6] = stbi__clamp((x1-t2) >> 17); - o[2] = stbi__clamp((x2+t1) >> 17); - o[5] = stbi__clamp((x2-t1) >> 17); - o[3] = stbi__clamp((x3+t0) >> 17); - o[4] = stbi__clamp((x3-t0) >> 17); - } -} - -#ifdef STBI_SSE2 -// sse2 integer IDCT. not the fastest possible implementation but it -// produces bit-identical results to the generic C version so it's -// fully "transparent". -static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) -{ - // This is constructed to match our regular (generic) integer IDCT exactly. - __m128i row0, row1, row2, row3, row4, row5, row6, row7; - __m128i tmp; - - // dot product constant: even elems=x, odd elems=y - #define dct_const(x,y) _mm_setr_epi16((x),(y),(x),(y),(x),(y),(x),(y)) - - // out(0) = c0[even]*x + c0[odd]*y (c0, x, y 16-bit, out 32-bit) - // out(1) = c1[even]*x + c1[odd]*y - #define dct_rot(out0,out1, x,y,c0,c1) \ - __m128i c0##lo = _mm_unpacklo_epi16((x),(y)); \ - __m128i c0##hi = _mm_unpackhi_epi16((x),(y)); \ - __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \ - __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \ - __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \ - __m128i out1##_h = _mm_madd_epi16(c0##hi, c1) - - // out = in << 12 (in 16-bit, out 32-bit) - #define dct_widen(out, in) \ - __m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \ - __m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4) - - // wide add - #define dct_wadd(out, a, b) \ - __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \ - __m128i out##_h = _mm_add_epi32(a##_h, b##_h) - - // wide sub - #define dct_wsub(out, a, b) \ - __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \ - __m128i out##_h = _mm_sub_epi32(a##_h, b##_h) - - // butterfly a/b, add bias, then shift by "s" and pack - #define dct_bfly32o(out0, out1, a,b,bias,s) \ - { \ - __m128i abiased_l = _mm_add_epi32(a##_l, bias); \ - __m128i abiased_h = _mm_add_epi32(a##_h, bias); \ - dct_wadd(sum, abiased, b); \ - dct_wsub(dif, abiased, b); \ - out0 = _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \ - out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \ - } - - // 8-bit interleave step (for transposes) - #define dct_interleave8(a, b) \ - tmp = a; \ - a = _mm_unpacklo_epi8(a, b); \ - b = _mm_unpackhi_epi8(tmp, b) - - // 16-bit interleave step (for transposes) - #define dct_interleave16(a, b) \ - tmp = a; \ - a = _mm_unpacklo_epi16(a, b); \ - b = _mm_unpackhi_epi16(tmp, b) - - #define dct_pass(bias,shift) \ - { \ - /* even part */ \ - dct_rot(t2e,t3e, row2,row6, rot0_0,rot0_1); \ - __m128i sum04 = _mm_add_epi16(row0, row4); \ - __m128i dif04 = _mm_sub_epi16(row0, row4); \ - dct_widen(t0e, sum04); \ - dct_widen(t1e, dif04); \ - dct_wadd(x0, t0e, t3e); \ - dct_wsub(x3, t0e, t3e); \ - dct_wadd(x1, t1e, t2e); \ - dct_wsub(x2, t1e, t2e); \ - /* odd part */ \ - dct_rot(y0o,y2o, row7,row3, rot2_0,rot2_1); \ - dct_rot(y1o,y3o, row5,row1, rot3_0,rot3_1); \ - __m128i sum17 = _mm_add_epi16(row1, row7); \ - __m128i sum35 = _mm_add_epi16(row3, row5); \ - dct_rot(y4o,y5o, sum17,sum35, rot1_0,rot1_1); \ - dct_wadd(x4, y0o, y4o); \ - dct_wadd(x5, y1o, y5o); \ - dct_wadd(x6, y2o, y5o); \ - dct_wadd(x7, y3o, y4o); \ - dct_bfly32o(row0,row7, x0,x7,bias,shift); \ - dct_bfly32o(row1,row6, x1,x6,bias,shift); \ - dct_bfly32o(row2,row5, x2,x5,bias,shift); \ - dct_bfly32o(row3,row4, x3,x4,bias,shift); \ - } - - __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f)); - __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f)); - __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f)); - __m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f)); - __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f)); - __m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f)); - __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f)); - __m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f)); - - // rounding biases in column/row passes, see stbi__idct_block for explanation. - __m128i bias_0 = _mm_set1_epi32(512); - __m128i bias_1 = _mm_set1_epi32(65536 + (128<<17)); - - // load - row0 = _mm_load_si128((const __m128i *) (data + 0*8)); - row1 = _mm_load_si128((const __m128i *) (data + 1*8)); - row2 = _mm_load_si128((const __m128i *) (data + 2*8)); - row3 = _mm_load_si128((const __m128i *) (data + 3*8)); - row4 = _mm_load_si128((const __m128i *) (data + 4*8)); - row5 = _mm_load_si128((const __m128i *) (data + 5*8)); - row6 = _mm_load_si128((const __m128i *) (data + 6*8)); - row7 = _mm_load_si128((const __m128i *) (data + 7*8)); - - // column pass - dct_pass(bias_0, 10); - - { - // 16bit 8x8 transpose pass 1 - dct_interleave16(row0, row4); - dct_interleave16(row1, row5); - dct_interleave16(row2, row6); - dct_interleave16(row3, row7); - - // transpose pass 2 - dct_interleave16(row0, row2); - dct_interleave16(row1, row3); - dct_interleave16(row4, row6); - dct_interleave16(row5, row7); - - // transpose pass 3 - dct_interleave16(row0, row1); - dct_interleave16(row2, row3); - dct_interleave16(row4, row5); - dct_interleave16(row6, row7); - } - - // row pass - dct_pass(bias_1, 17); - - { - // pack - __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7 - __m128i p1 = _mm_packus_epi16(row2, row3); - __m128i p2 = _mm_packus_epi16(row4, row5); - __m128i p3 = _mm_packus_epi16(row6, row7); - - // 8bit 8x8 transpose pass 1 - dct_interleave8(p0, p2); // a0e0a1e1... - dct_interleave8(p1, p3); // c0g0c1g1... - - // transpose pass 2 - dct_interleave8(p0, p1); // a0c0e0g0... - dct_interleave8(p2, p3); // b0d0f0h0... - - // transpose pass 3 - dct_interleave8(p0, p2); // a0b0c0d0... - dct_interleave8(p1, p3); // a4b4c4d4... - - // store - _mm_storel_epi64((__m128i *) out, p0); out += out_stride; - _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p0, 0x4e)); out += out_stride; - _mm_storel_epi64((__m128i *) out, p2); out += out_stride; - _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p2, 0x4e)); out += out_stride; - _mm_storel_epi64((__m128i *) out, p1); out += out_stride; - _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p1, 0x4e)); out += out_stride; - _mm_storel_epi64((__m128i *) out, p3); out += out_stride; - _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p3, 0x4e)); - } - -#undef dct_const -#undef dct_rot -#undef dct_widen -#undef dct_wadd -#undef dct_wsub -#undef dct_bfly32o -#undef dct_interleave8 -#undef dct_interleave16 -#undef dct_pass -} - -#endif // STBI_SSE2 - -#ifdef STBI_NEON - -// NEON integer IDCT. should produce bit-identical -// results to the generic C version. -static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) -{ - int16x8_t row0, row1, row2, row3, row4, row5, row6, row7; - - int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f)); - int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f)); - int16x4_t rot0_2 = vdup_n_s16(stbi__f2f( 0.765366865f)); - int16x4_t rot1_0 = vdup_n_s16(stbi__f2f( 1.175875602f)); - int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f)); - int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f)); - int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f)); - int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f)); - int16x4_t rot3_0 = vdup_n_s16(stbi__f2f( 0.298631336f)); - int16x4_t rot3_1 = vdup_n_s16(stbi__f2f( 2.053119869f)); - int16x4_t rot3_2 = vdup_n_s16(stbi__f2f( 3.072711026f)); - int16x4_t rot3_3 = vdup_n_s16(stbi__f2f( 1.501321110f)); - -#define dct_long_mul(out, inq, coeff) \ - int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \ - int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff) - -#define dct_long_mac(out, acc, inq, coeff) \ - int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \ - int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff) - -#define dct_widen(out, inq) \ - int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \ - int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12) - -// wide add -#define dct_wadd(out, a, b) \ - int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \ - int32x4_t out##_h = vaddq_s32(a##_h, b##_h) - -// wide sub -#define dct_wsub(out, a, b) \ - int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \ - int32x4_t out##_h = vsubq_s32(a##_h, b##_h) - -// butterfly a/b, then shift using "shiftop" by "s" and pack -#define dct_bfly32o(out0,out1, a,b,shiftop,s) \ - { \ - dct_wadd(sum, a, b); \ - dct_wsub(dif, a, b); \ - out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \ - out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \ - } - -#define dct_pass(shiftop, shift) \ - { \ - /* even part */ \ - int16x8_t sum26 = vaddq_s16(row2, row6); \ - dct_long_mul(p1e, sum26, rot0_0); \ - dct_long_mac(t2e, p1e, row6, rot0_1); \ - dct_long_mac(t3e, p1e, row2, rot0_2); \ - int16x8_t sum04 = vaddq_s16(row0, row4); \ - int16x8_t dif04 = vsubq_s16(row0, row4); \ - dct_widen(t0e, sum04); \ - dct_widen(t1e, dif04); \ - dct_wadd(x0, t0e, t3e); \ - dct_wsub(x3, t0e, t3e); \ - dct_wadd(x1, t1e, t2e); \ - dct_wsub(x2, t1e, t2e); \ - /* odd part */ \ - int16x8_t sum15 = vaddq_s16(row1, row5); \ - int16x8_t sum17 = vaddq_s16(row1, row7); \ - int16x8_t sum35 = vaddq_s16(row3, row5); \ - int16x8_t sum37 = vaddq_s16(row3, row7); \ - int16x8_t sumodd = vaddq_s16(sum17, sum35); \ - dct_long_mul(p5o, sumodd, rot1_0); \ - dct_long_mac(p1o, p5o, sum17, rot1_1); \ - dct_long_mac(p2o, p5o, sum35, rot1_2); \ - dct_long_mul(p3o, sum37, rot2_0); \ - dct_long_mul(p4o, sum15, rot2_1); \ - dct_wadd(sump13o, p1o, p3o); \ - dct_wadd(sump24o, p2o, p4o); \ - dct_wadd(sump23o, p2o, p3o); \ - dct_wadd(sump14o, p1o, p4o); \ - dct_long_mac(x4, sump13o, row7, rot3_0); \ - dct_long_mac(x5, sump24o, row5, rot3_1); \ - dct_long_mac(x6, sump23o, row3, rot3_2); \ - dct_long_mac(x7, sump14o, row1, rot3_3); \ - dct_bfly32o(row0,row7, x0,x7,shiftop,shift); \ - dct_bfly32o(row1,row6, x1,x6,shiftop,shift); \ - dct_bfly32o(row2,row5, x2,x5,shiftop,shift); \ - dct_bfly32o(row3,row4, x3,x4,shiftop,shift); \ - } - - // load - row0 = vld1q_s16(data + 0*8); - row1 = vld1q_s16(data + 1*8); - row2 = vld1q_s16(data + 2*8); - row3 = vld1q_s16(data + 3*8); - row4 = vld1q_s16(data + 4*8); - row5 = vld1q_s16(data + 5*8); - row6 = vld1q_s16(data + 6*8); - row7 = vld1q_s16(data + 7*8); - - // add DC bias - row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0)); - - // column pass - dct_pass(vrshrn_n_s32, 10); - - // 16bit 8x8 transpose - { -// these three map to a single VTRN.16, VTRN.32, and VSWP, respectively. -// whether compilers actually get this is another story, sadly. -#define dct_trn16(x, y) { int16x8x2_t t = vtrnq_s16(x, y); x = t.val[0]; y = t.val[1]; } -#define dct_trn32(x, y) { int32x4x2_t t = vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); x = vreinterpretq_s16_s32(t.val[0]); y = vreinterpretq_s16_s32(t.val[1]); } -#define dct_trn64(x, y) { int16x8_t x0 = x; int16x8_t y0 = y; x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); } - - // pass 1 - dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6 - dct_trn16(row2, row3); - dct_trn16(row4, row5); - dct_trn16(row6, row7); - - // pass 2 - dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4 - dct_trn32(row1, row3); - dct_trn32(row4, row6); - dct_trn32(row5, row7); - - // pass 3 - dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0 - dct_trn64(row1, row5); - dct_trn64(row2, row6); - dct_trn64(row3, row7); - -#undef dct_trn16 -#undef dct_trn32 -#undef dct_trn64 - } - - // row pass - // vrshrn_n_s32 only supports shifts up to 16, we need - // 17. so do a non-rounding shift of 16 first then follow - // up with a rounding shift by 1. - dct_pass(vshrn_n_s32, 16); - - { - // pack and round - uint8x8_t p0 = vqrshrun_n_s16(row0, 1); - uint8x8_t p1 = vqrshrun_n_s16(row1, 1); - uint8x8_t p2 = vqrshrun_n_s16(row2, 1); - uint8x8_t p3 = vqrshrun_n_s16(row3, 1); - uint8x8_t p4 = vqrshrun_n_s16(row4, 1); - uint8x8_t p5 = vqrshrun_n_s16(row5, 1); - uint8x8_t p6 = vqrshrun_n_s16(row6, 1); - uint8x8_t p7 = vqrshrun_n_s16(row7, 1); - - // again, these can translate into one instruction, but often don't. -#define dct_trn8_8(x, y) { uint8x8x2_t t = vtrn_u8(x, y); x = t.val[0]; y = t.val[1]; } -#define dct_trn8_16(x, y) { uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); x = vreinterpret_u8_u16(t.val[0]); y = vreinterpret_u8_u16(t.val[1]); } -#define dct_trn8_32(x, y) { uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); x = vreinterpret_u8_u32(t.val[0]); y = vreinterpret_u8_u32(t.val[1]); } - - // sadly can't use interleaved stores here since we only write - // 8 bytes to each scan line! - - // 8x8 8-bit transpose pass 1 - dct_trn8_8(p0, p1); - dct_trn8_8(p2, p3); - dct_trn8_8(p4, p5); - dct_trn8_8(p6, p7); - - // pass 2 - dct_trn8_16(p0, p2); - dct_trn8_16(p1, p3); - dct_trn8_16(p4, p6); - dct_trn8_16(p5, p7); - - // pass 3 - dct_trn8_32(p0, p4); - dct_trn8_32(p1, p5); - dct_trn8_32(p2, p6); - dct_trn8_32(p3, p7); - - // store - vst1_u8(out, p0); out += out_stride; - vst1_u8(out, p1); out += out_stride; - vst1_u8(out, p2); out += out_stride; - vst1_u8(out, p3); out += out_stride; - vst1_u8(out, p4); out += out_stride; - vst1_u8(out, p5); out += out_stride; - vst1_u8(out, p6); out += out_stride; - vst1_u8(out, p7); - -#undef dct_trn8_8 -#undef dct_trn8_16 -#undef dct_trn8_32 - } - -#undef dct_long_mul -#undef dct_long_mac -#undef dct_widen -#undef dct_wadd -#undef dct_wsub -#undef dct_bfly32o -#undef dct_pass -} - -#endif // STBI_NEON - -#define STBI__MARKER_none 0xff -// if there's a pending marker from the entropy stream, return that -// otherwise, fetch from the stream and get a marker. if there's no -// marker, return 0xff, which is never a valid marker value -static stbi_uc stbi__get_marker(stbi__jpeg *j) -{ - stbi_uc x; - if (j->marker != STBI__MARKER_none) { x = j->marker; j->marker = STBI__MARKER_none; return x; } - x = stbi__get8(j->s); - if (x != 0xff) return STBI__MARKER_none; - while (x == 0xff) - x = stbi__get8(j->s); // consume repeated 0xff fill bytes - return x; -} - -// in each scan, we'll have scan_n components, and the order -// of the components is specified by order[] -#define STBI__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) - -// after a restart interval, stbi__jpeg_reset the entropy decoder and -// the dc prediction -static void stbi__jpeg_reset(stbi__jpeg *j) -{ - j->code_bits = 0; - j->code_buffer = 0; - j->nomore = 0; - j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = j->img_comp[3].dc_pred = 0; - j->marker = STBI__MARKER_none; - j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; - j->eob_run = 0; - // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, - // since we don't even allow 1<<30 pixels -} - -static int stbi__parse_entropy_coded_data(stbi__jpeg *z) -{ - stbi__jpeg_reset(z); - if (!z->progressive) { - if (z->scan_n == 1) { - int i,j; - STBI_SIMD_ALIGN(short, data[64]); - int n = z->order[0]; - // non-interleaved data, we just need to process one block at a time, - // in trivial scanline order - // number of blocks to do just depends on how many actual "pixels" this - // component has, independent of interleaved MCU blocking and such - int w = (z->img_comp[n].x+7) >> 3; - int h = (z->img_comp[n].y+7) >> 3; - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) { - int ha = z->img_comp[n].ha; - if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; - z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); - // every data block is an MCU, so countdown the restart interval - if (--z->todo <= 0) { - if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); - // if it's NOT a restart, then just bail, so we get corrupt data - // rather than no data - if (!STBI__RESTART(z->marker)) return 1; - stbi__jpeg_reset(z); - } - } - } - return 1; - } else { // interleaved - int i,j,k,x,y; - STBI_SIMD_ALIGN(short, data[64]); - for (j=0; j < z->img_mcu_y; ++j) { - for (i=0; i < z->img_mcu_x; ++i) { - // scan an interleaved mcu... process scan_n components in order - for (k=0; k < z->scan_n; ++k) { - int n = z->order[k]; - // scan out an mcu's worth of this component; that's just determined - // by the basic H and V specified for the component - for (y=0; y < z->img_comp[n].v; ++y) { - for (x=0; x < z->img_comp[n].h; ++x) { - int x2 = (i*z->img_comp[n].h + x)*8; - int y2 = (j*z->img_comp[n].v + y)*8; - int ha = z->img_comp[n].ha; - if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; - z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data); - } - } - } - // after all interleaved components, that's an interleaved MCU, - // so now count down the restart interval - if (--z->todo <= 0) { - if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); - if (!STBI__RESTART(z->marker)) return 1; - stbi__jpeg_reset(z); - } - } - } - return 1; - } - } else { - if (z->scan_n == 1) { - int i,j; - int n = z->order[0]; - // non-interleaved data, we just need to process one block at a time, - // in trivial scanline order - // number of blocks to do just depends on how many actual "pixels" this - // component has, independent of interleaved MCU blocking and such - int w = (z->img_comp[n].x+7) >> 3; - int h = (z->img_comp[n].y+7) >> 3; - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) { - short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); - if (z->spec_start == 0) { - if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) - return 0; - } else { - int ha = z->img_comp[n].ha; - if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha])) - return 0; - } - // every data block is an MCU, so countdown the restart interval - if (--z->todo <= 0) { - if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); - if (!STBI__RESTART(z->marker)) return 1; - stbi__jpeg_reset(z); - } - } - } - return 1; - } else { // interleaved - int i,j,k,x,y; - for (j=0; j < z->img_mcu_y; ++j) { - for (i=0; i < z->img_mcu_x; ++i) { - // scan an interleaved mcu... process scan_n components in order - for (k=0; k < z->scan_n; ++k) { - int n = z->order[k]; - // scan out an mcu's worth of this component; that's just determined - // by the basic H and V specified for the component - for (y=0; y < z->img_comp[n].v; ++y) { - for (x=0; x < z->img_comp[n].h; ++x) { - int x2 = (i*z->img_comp[n].h + x); - int y2 = (j*z->img_comp[n].v + y); - short *data = z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w); - if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) - return 0; - } - } - } - // after all interleaved components, that's an interleaved MCU, - // so now count down the restart interval - if (--z->todo <= 0) { - if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); - if (!STBI__RESTART(z->marker)) return 1; - stbi__jpeg_reset(z); - } - } - } - return 1; - } - } -} - -static void stbi__jpeg_dequantize(short *data, stbi__uint16 *dequant) -{ - int i; - for (i=0; i < 64; ++i) - data[i] *= dequant[i]; -} - -static void stbi__jpeg_finish(stbi__jpeg *z) -{ - if (z->progressive) { - // dequantize and idct the data - int i,j,n; - for (n=0; n < z->s->img_n; ++n) { - int w = (z->img_comp[n].x+7) >> 3; - int h = (z->img_comp[n].y+7) >> 3; - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) { - short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); - stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]); - z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); - } - } - } - } -} - -static int stbi__process_marker(stbi__jpeg *z, int m) -{ - int L; - switch (m) { - case STBI__MARKER_none: // no marker found - return stbi__err("expected marker","Corrupt JPEG"); - - case 0xDD: // DRI - specify restart interval - if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len","Corrupt JPEG"); - z->restart_interval = stbi__get16be(z->s); - return 1; - - case 0xDB: // DQT - define quantization table - L = stbi__get16be(z->s)-2; - while (L > 0) { - int q = stbi__get8(z->s); - int p = q >> 4, sixteen = (p != 0); - int t = q & 15,i; - if (p != 0 && p != 1) return stbi__err("bad DQT type","Corrupt JPEG"); - if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG"); - - for (i=0; i < 64; ++i) - z->dequant[t][stbi__jpeg_dezigzag[i]] = (stbi__uint16)(sixteen ? stbi__get16be(z->s) : stbi__get8(z->s)); - L -= (sixteen ? 129 : 65); - } - return L==0; - - case 0xC4: // DHT - define huffman table - L = stbi__get16be(z->s)-2; - while (L > 0) { - stbi_uc *v; - int sizes[16],i,n=0; - int q = stbi__get8(z->s); - int tc = q >> 4; - int th = q & 15; - if (tc > 1 || th > 3) return stbi__err("bad DHT header","Corrupt JPEG"); - for (i=0; i < 16; ++i) { - sizes[i] = stbi__get8(z->s); - n += sizes[i]; - } - if(n > 256) return stbi__err("bad DHT header","Corrupt JPEG"); // Loop over i < n would write past end of values! - L -= 17; - if (tc == 0) { - if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0; - v = z->huff_dc[th].values; - } else { - if (!stbi__build_huffman(z->huff_ac+th, sizes)) return 0; - v = z->huff_ac[th].values; - } - for (i=0; i < n; ++i) - v[i] = stbi__get8(z->s); - if (tc != 0) - stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th); - L -= n; - } - return L==0; - } - - // check for comment block or APP blocks - if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { - L = stbi__get16be(z->s); - if (L < 2) { - if (m == 0xFE) - return stbi__err("bad COM len","Corrupt JPEG"); - else - return stbi__err("bad APP len","Corrupt JPEG"); - } - L -= 2; - - if (m == 0xE0 && L >= 5) { // JFIF APP0 segment - static const unsigned char tag[5] = {'J','F','I','F','\0'}; - int ok = 1; - int i; - for (i=0; i < 5; ++i) - if (stbi__get8(z->s) != tag[i]) - ok = 0; - L -= 5; - if (ok) - z->jfif = 1; - } else if (m == 0xEE && L >= 12) { // Adobe APP14 segment - static const unsigned char tag[6] = {'A','d','o','b','e','\0'}; - int ok = 1; - int i; - for (i=0; i < 6; ++i) - if (stbi__get8(z->s) != tag[i]) - ok = 0; - L -= 6; - if (ok) { - stbi__get8(z->s); // version - stbi__get16be(z->s); // flags0 - stbi__get16be(z->s); // flags1 - z->app14_color_transform = stbi__get8(z->s); // color transform - L -= 6; - } - } - - stbi__skip(z->s, L); - return 1; - } - - return stbi__err("unknown marker","Corrupt JPEG"); -} - -// after we see SOS -static int stbi__process_scan_header(stbi__jpeg *z) -{ - int i; - int Ls = stbi__get16be(z->s); - z->scan_n = stbi__get8(z->s); - if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) return stbi__err("bad SOS component count","Corrupt JPEG"); - if (Ls != 6+2*z->scan_n) return stbi__err("bad SOS len","Corrupt JPEG"); - for (i=0; i < z->scan_n; ++i) { - int id = stbi__get8(z->s), which; - int q = stbi__get8(z->s); - for (which = 0; which < z->s->img_n; ++which) - if (z->img_comp[which].id == id) - break; - if (which == z->s->img_n) return 0; // no match - z->img_comp[which].hd = q >> 4; if (z->img_comp[which].hd > 3) return stbi__err("bad DC huff","Corrupt JPEG"); - z->img_comp[which].ha = q & 15; if (z->img_comp[which].ha > 3) return stbi__err("bad AC huff","Corrupt JPEG"); - z->order[i] = which; - } - - { - int aa; - z->spec_start = stbi__get8(z->s); - z->spec_end = stbi__get8(z->s); // should be 63, but might be 0 - aa = stbi__get8(z->s); - z->succ_high = (aa >> 4); - z->succ_low = (aa & 15); - if (z->progressive) { - if (z->spec_start > 63 || z->spec_end > 63 || z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13) - return stbi__err("bad SOS", "Corrupt JPEG"); - } else { - if (z->spec_start != 0) return stbi__err("bad SOS","Corrupt JPEG"); - if (z->succ_high != 0 || z->succ_low != 0) return stbi__err("bad SOS","Corrupt JPEG"); - z->spec_end = 63; - } - } - - return 1; -} - -static int stbi__free_jpeg_components(stbi__jpeg *z, int ncomp, int why) -{ - int i; - for (i=0; i < ncomp; ++i) { - if (z->img_comp[i].raw_data) { - STBI_FREE(z->img_comp[i].raw_data); - z->img_comp[i].raw_data = NULL; - z->img_comp[i].data = NULL; - } - if (z->img_comp[i].raw_coeff) { - STBI_FREE(z->img_comp[i].raw_coeff); - z->img_comp[i].raw_coeff = 0; - z->img_comp[i].coeff = 0; - } - if (z->img_comp[i].linebuf) { - STBI_FREE(z->img_comp[i].linebuf); - z->img_comp[i].linebuf = NULL; - } - } - return why; -} - -static int stbi__process_frame_header(stbi__jpeg *z, int scan) -{ - stbi__context *s = z->s; - int Lf,p,i,q, h_max=1,v_max=1,c; - Lf = stbi__get16be(s); if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG - p = stbi__get8(s); if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline - s->img_y = stbi__get16be(s); if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG - s->img_x = stbi__get16be(s); if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires - if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); - if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); - c = stbi__get8(s); - if (c != 3 && c != 1 && c != 4) return stbi__err("bad component count","Corrupt JPEG"); - s->img_n = c; - for (i=0; i < c; ++i) { - z->img_comp[i].data = NULL; - z->img_comp[i].linebuf = NULL; - } - - if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG"); - - z->rgb = 0; - for (i=0; i < s->img_n; ++i) { - static const unsigned char rgb[3] = { 'R', 'G', 'B' }; - z->img_comp[i].id = stbi__get8(s); - if (s->img_n == 3 && z->img_comp[i].id == rgb[i]) - ++z->rgb; - q = stbi__get8(s); - z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG"); - z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG"); - z->img_comp[i].tq = stbi__get8(s); if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG"); - } - - if (scan != STBI__SCAN_load) return 1; - - if (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) return stbi__err("too large", "Image too large to decode"); - - for (i=0; i < s->img_n; ++i) { - if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; - if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; - } - - // check that plane subsampling factors are integer ratios; our resamplers can't deal with fractional ratios - // and I've never seen a non-corrupted JPEG file actually use them - for (i=0; i < s->img_n; ++i) { - if (h_max % z->img_comp[i].h != 0) return stbi__err("bad H","Corrupt JPEG"); - if (v_max % z->img_comp[i].v != 0) return stbi__err("bad V","Corrupt JPEG"); - } - - // compute interleaved mcu info - z->img_h_max = h_max; - z->img_v_max = v_max; - z->img_mcu_w = h_max * 8; - z->img_mcu_h = v_max * 8; - // these sizes can't be more than 17 bits - z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w; - z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h; - - for (i=0; i < s->img_n; ++i) { - // number of effective pixels (e.g. for non-interleaved MCU) - z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max; - z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max; - // to simplify generation, we'll allocate enough memory to decode - // the bogus oversized data from using interleaved MCUs and their - // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't - // discard the extra data until colorspace conversion - // - // img_mcu_x, img_mcu_y: <=17 bits; comp[i].h and .v are <=4 (checked earlier) - // so these muls can't overflow with 32-bit ints (which we require) - z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; - z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; - z->img_comp[i].coeff = 0; - z->img_comp[i].raw_coeff = 0; - z->img_comp[i].linebuf = NULL; - z->img_comp[i].raw_data = stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15); - if (z->img_comp[i].raw_data == NULL) - return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); - // align blocks for idct using mmx/sse - z->img_comp[i].data = (stbi_uc*) (((size_t) z->img_comp[i].raw_data + 15) & ~15); - if (z->progressive) { - // w2, h2 are multiples of 8 (see above) - z->img_comp[i].coeff_w = z->img_comp[i].w2 / 8; - z->img_comp[i].coeff_h = z->img_comp[i].h2 / 8; - z->img_comp[i].raw_coeff = stbi__malloc_mad3(z->img_comp[i].w2, z->img_comp[i].h2, sizeof(short), 15); - if (z->img_comp[i].raw_coeff == NULL) - return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); - z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15); - } - } - - return 1; -} - -// use comparisons since in some cases we handle more than one case (e.g. SOF) -#define stbi__DNL(x) ((x) == 0xdc) -#define stbi__SOI(x) ((x) == 0xd8) -#define stbi__EOI(x) ((x) == 0xd9) -#define stbi__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) -#define stbi__SOS(x) ((x) == 0xda) - -#define stbi__SOF_progressive(x) ((x) == 0xc2) - -static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) -{ - int m; - z->jfif = 0; - z->app14_color_transform = -1; // valid values are 0,1,2 - z->marker = STBI__MARKER_none; // initialize cached marker to empty - m = stbi__get_marker(z); - if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG"); - if (scan == STBI__SCAN_type) return 1; - m = stbi__get_marker(z); - while (!stbi__SOF(m)) { - if (!stbi__process_marker(z,m)) return 0; - m = stbi__get_marker(z); - while (m == STBI__MARKER_none) { - // some files have extra padding after their blocks, so ok, we'll scan - if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG"); - m = stbi__get_marker(z); - } - } - z->progressive = stbi__SOF_progressive(m); - if (!stbi__process_frame_header(z, scan)) return 0; - return 1; -} - -static int stbi__skip_jpeg_junk_at_end(stbi__jpeg *j) -{ - // some JPEGs have junk at end, skip over it but if we find what looks - // like a valid marker, resume there - while (!stbi__at_eof(j->s)) { - int x = stbi__get8(j->s); - while (x == 255) { // might be a marker - if (stbi__at_eof(j->s)) return STBI__MARKER_none; - x = stbi__get8(j->s); - if (x != 0x00 && x != 0xff) { - // not a stuffed zero or lead-in to another marker, looks - // like an actual marker, return it - return x; - } - // stuffed zero has x=0 now which ends the loop, meaning we go - // back to regular scan loop. - // repeated 0xff keeps trying to read the next byte of the marker. - } - } - return STBI__MARKER_none; -} - -// decode image to YCbCr format -static int stbi__decode_jpeg_image(stbi__jpeg *j) -{ - int m; - for (m = 0; m < 4; m++) { - j->img_comp[m].raw_data = NULL; - j->img_comp[m].raw_coeff = NULL; - } - j->restart_interval = 0; - if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0; - m = stbi__get_marker(j); - while (!stbi__EOI(m)) { - if (stbi__SOS(m)) { - if (!stbi__process_scan_header(j)) return 0; - if (!stbi__parse_entropy_coded_data(j)) return 0; - if (j->marker == STBI__MARKER_none ) { - j->marker = stbi__skip_jpeg_junk_at_end(j); - // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0 - } - m = stbi__get_marker(j); - if (STBI__RESTART(m)) - m = stbi__get_marker(j); - } else if (stbi__DNL(m)) { - int Ld = stbi__get16be(j->s); - stbi__uint32 NL = stbi__get16be(j->s); - if (Ld != 4) return stbi__err("bad DNL len", "Corrupt JPEG"); - if (NL != j->s->img_y) return stbi__err("bad DNL height", "Corrupt JPEG"); - m = stbi__get_marker(j); - } else { - if (!stbi__process_marker(j, m)) return 1; - m = stbi__get_marker(j); - } - } - if (j->progressive) - stbi__jpeg_finish(j); - return 1; -} - -// static jfif-centered resampling (across block boundaries) - -typedef stbi_uc *(*resample_row_func)(stbi_uc *out, stbi_uc *in0, stbi_uc *in1, - int w, int hs); - -#define stbi__div4(x) ((stbi_uc) ((x) >> 2)) - -static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - STBI_NOTUSED(out); - STBI_NOTUSED(in_far); - STBI_NOTUSED(w); - STBI_NOTUSED(hs); - return in_near; -} - -static stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - // need to generate two samples vertically for every one in input - int i; - STBI_NOTUSED(hs); - for (i=0; i < w; ++i) - out[i] = stbi__div4(3*in_near[i] + in_far[i] + 2); - return out; -} - -static stbi_uc* stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - // need to generate two samples horizontally for every one in input - int i; - stbi_uc *input = in_near; - - if (w == 1) { - // if only one sample, can't do any interpolation - out[0] = out[1] = input[0]; - return out; - } - - out[0] = input[0]; - out[1] = stbi__div4(input[0]*3 + input[1] + 2); - for (i=1; i < w-1; ++i) { - int n = 3*input[i]+2; - out[i*2+0] = stbi__div4(n+input[i-1]); - out[i*2+1] = stbi__div4(n+input[i+1]); - } - out[i*2+0] = stbi__div4(input[w-2]*3 + input[w-1] + 2); - out[i*2+1] = input[w-1]; - - STBI_NOTUSED(in_far); - STBI_NOTUSED(hs); - - return out; -} - -#define stbi__div16(x) ((stbi_uc) ((x) >> 4)) - -static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - // need to generate 2x2 samples for every one in input - int i,t0,t1; - if (w == 1) { - out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); - return out; - } - - t1 = 3*in_near[0] + in_far[0]; - out[0] = stbi__div4(t1+2); - for (i=1; i < w; ++i) { - t0 = t1; - t1 = 3*in_near[i]+in_far[i]; - out[i*2-1] = stbi__div16(3*t0 + t1 + 8); - out[i*2 ] = stbi__div16(3*t1 + t0 + 8); - } - out[w*2-1] = stbi__div4(t1+2); - - STBI_NOTUSED(hs); - - return out; -} - -#if defined(STBI_SSE2) || defined(STBI_NEON) -static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - // need to generate 2x2 samples for every one in input - int i=0,t0,t1; - - if (w == 1) { - out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); - return out; - } - - t1 = 3*in_near[0] + in_far[0]; - // process groups of 8 pixels for as long as we can. - // note we can't handle the last pixel in a row in this loop - // because we need to handle the filter boundary conditions. - for (; i < ((w-1) & ~7); i += 8) { -#if defined(STBI_SSE2) - // load and perform the vertical filtering pass - // this uses 3*x + y = 4*x + (y - x) - __m128i zero = _mm_setzero_si128(); - __m128i farb = _mm_loadl_epi64((__m128i *) (in_far + i)); - __m128i nearb = _mm_loadl_epi64((__m128i *) (in_near + i)); - __m128i farw = _mm_unpacklo_epi8(farb, zero); - __m128i nearw = _mm_unpacklo_epi8(nearb, zero); - __m128i diff = _mm_sub_epi16(farw, nearw); - __m128i nears = _mm_slli_epi16(nearw, 2); - __m128i curr = _mm_add_epi16(nears, diff); // current row - - // horizontal filter works the same based on shifted vers of current - // row. "prev" is current row shifted right by 1 pixel; we need to - // insert the previous pixel value (from t1). - // "next" is current row shifted left by 1 pixel, with first pixel - // of next block of 8 pixels added in. - __m128i prv0 = _mm_slli_si128(curr, 2); - __m128i nxt0 = _mm_srli_si128(curr, 2); - __m128i prev = _mm_insert_epi16(prv0, t1, 0); - __m128i next = _mm_insert_epi16(nxt0, 3*in_near[i+8] + in_far[i+8], 7); - - // horizontal filter, polyphase implementation since it's convenient: - // even pixels = 3*cur + prev = cur*4 + (prev - cur) - // odd pixels = 3*cur + next = cur*4 + (next - cur) - // note the shared term. - __m128i bias = _mm_set1_epi16(8); - __m128i curs = _mm_slli_epi16(curr, 2); - __m128i prvd = _mm_sub_epi16(prev, curr); - __m128i nxtd = _mm_sub_epi16(next, curr); - __m128i curb = _mm_add_epi16(curs, bias); - __m128i even = _mm_add_epi16(prvd, curb); - __m128i odd = _mm_add_epi16(nxtd, curb); - - // interleave even and odd pixels, then undo scaling. - __m128i int0 = _mm_unpacklo_epi16(even, odd); - __m128i int1 = _mm_unpackhi_epi16(even, odd); - __m128i de0 = _mm_srli_epi16(int0, 4); - __m128i de1 = _mm_srli_epi16(int1, 4); - - // pack and write output - __m128i outv = _mm_packus_epi16(de0, de1); - _mm_storeu_si128((__m128i *) (out + i*2), outv); -#elif defined(STBI_NEON) - // load and perform the vertical filtering pass - // this uses 3*x + y = 4*x + (y - x) - uint8x8_t farb = vld1_u8(in_far + i); - uint8x8_t nearb = vld1_u8(in_near + i); - int16x8_t diff = vreinterpretq_s16_u16(vsubl_u8(farb, nearb)); - int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2)); - int16x8_t curr = vaddq_s16(nears, diff); // current row - - // horizontal filter works the same based on shifted vers of current - // row. "prev" is current row shifted right by 1 pixel; we need to - // insert the previous pixel value (from t1). - // "next" is current row shifted left by 1 pixel, with first pixel - // of next block of 8 pixels added in. - int16x8_t prv0 = vextq_s16(curr, curr, 7); - int16x8_t nxt0 = vextq_s16(curr, curr, 1); - int16x8_t prev = vsetq_lane_s16(t1, prv0, 0); - int16x8_t next = vsetq_lane_s16(3*in_near[i+8] + in_far[i+8], nxt0, 7); - - // horizontal filter, polyphase implementation since it's convenient: - // even pixels = 3*cur + prev = cur*4 + (prev - cur) - // odd pixels = 3*cur + next = cur*4 + (next - cur) - // note the shared term. - int16x8_t curs = vshlq_n_s16(curr, 2); - int16x8_t prvd = vsubq_s16(prev, curr); - int16x8_t nxtd = vsubq_s16(next, curr); - int16x8_t even = vaddq_s16(curs, prvd); - int16x8_t odd = vaddq_s16(curs, nxtd); - - // undo scaling and round, then store with even/odd phases interleaved - uint8x8x2_t o; - o.val[0] = vqrshrun_n_s16(even, 4); - o.val[1] = vqrshrun_n_s16(odd, 4); - vst2_u8(out + i*2, o); -#endif - - // "previous" value for next iter - t1 = 3*in_near[i+7] + in_far[i+7]; - } - - t0 = t1; - t1 = 3*in_near[i] + in_far[i]; - out[i*2] = stbi__div16(3*t1 + t0 + 8); - - for (++i; i < w; ++i) { - t0 = t1; - t1 = 3*in_near[i]+in_far[i]; - out[i*2-1] = stbi__div16(3*t0 + t1 + 8); - out[i*2 ] = stbi__div16(3*t1 + t0 + 8); - } - out[w*2-1] = stbi__div4(t1+2); - - STBI_NOTUSED(hs); - - return out; -} -#endif - -static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - // resample with nearest-neighbor - int i,j; - STBI_NOTUSED(in_far); - for (i=0; i < w; ++i) - for (j=0; j < hs; ++j) - out[i*hs+j] = in_near[i]; - return out; -} - -// this is a reduced-precision calculation of YCbCr-to-RGB introduced -// to make sure the code produces the same results in both SIMD and scalar -#define stbi__float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8) -static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step) -{ - int i; - for (i=0; i < count; ++i) { - int y_fixed = (y[i] << 20) + (1<<19); // rounding - int r,g,b; - int cr = pcr[i] - 128; - int cb = pcb[i] - 128; - r = y_fixed + cr* stbi__float2fixed(1.40200f); - g = y_fixed + (cr*-stbi__float2fixed(0.71414f)) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); - b = y_fixed + cb* stbi__float2fixed(1.77200f); - r >>= 20; - g >>= 20; - b >>= 20; - if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } - if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } - if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } - out[0] = (stbi_uc)r; - out[1] = (stbi_uc)g; - out[2] = (stbi_uc)b; - out[3] = 255; - out += step; - } -} - -#if defined(STBI_SSE2) || defined(STBI_NEON) -static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step) -{ - int i = 0; - -#ifdef STBI_SSE2 - // step == 3 is pretty ugly on the final interleave, and i'm not convinced - // it's useful in practice (you wouldn't use it for textures, for example). - // so just accelerate step == 4 case. - if (step == 4) { - // this is a fairly straightforward implementation and not super-optimized. - __m128i signflip = _mm_set1_epi8(-0x80); - __m128i cr_const0 = _mm_set1_epi16( (short) ( 1.40200f*4096.0f+0.5f)); - __m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f)); - __m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f)); - __m128i cb_const1 = _mm_set1_epi16( (short) ( 1.77200f*4096.0f+0.5f)); - __m128i y_bias = _mm_set1_epi8((char) (unsigned char) 128); - __m128i xw = _mm_set1_epi16(255); // alpha channel - - for (; i+7 < count; i += 8) { - // load - __m128i y_bytes = _mm_loadl_epi64((__m128i *) (y+i)); - __m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr+i)); - __m128i cb_bytes = _mm_loadl_epi64((__m128i *) (pcb+i)); - __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128 - __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128 - - // unpack to short (and left-shift cr, cb by 8) - __m128i yw = _mm_unpacklo_epi8(y_bias, y_bytes); - __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased); - __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased); - - // color transform - __m128i yws = _mm_srli_epi16(yw, 4); - __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw); - __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw); - __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1); - __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1); - __m128i rws = _mm_add_epi16(cr0, yws); - __m128i gwt = _mm_add_epi16(cb0, yws); - __m128i bws = _mm_add_epi16(yws, cb1); - __m128i gws = _mm_add_epi16(gwt, cr1); - - // descale - __m128i rw = _mm_srai_epi16(rws, 4); - __m128i bw = _mm_srai_epi16(bws, 4); - __m128i gw = _mm_srai_epi16(gws, 4); - - // back to byte, set up for transpose - __m128i brb = _mm_packus_epi16(rw, bw); - __m128i gxb = _mm_packus_epi16(gw, xw); - - // transpose to interleave channels - __m128i t0 = _mm_unpacklo_epi8(brb, gxb); - __m128i t1 = _mm_unpackhi_epi8(brb, gxb); - __m128i o0 = _mm_unpacklo_epi16(t0, t1); - __m128i o1 = _mm_unpackhi_epi16(t0, t1); - - // store - _mm_storeu_si128((__m128i *) (out + 0), o0); - _mm_storeu_si128((__m128i *) (out + 16), o1); - out += 32; - } - } -#endif - -#ifdef STBI_NEON - // in this version, step=3 support would be easy to add. but is there demand? - if (step == 4) { - // this is a fairly straightforward implementation and not super-optimized. - uint8x8_t signflip = vdup_n_u8(0x80); - int16x8_t cr_const0 = vdupq_n_s16( (short) ( 1.40200f*4096.0f+0.5f)); - int16x8_t cr_const1 = vdupq_n_s16( - (short) ( 0.71414f*4096.0f+0.5f)); - int16x8_t cb_const0 = vdupq_n_s16( - (short) ( 0.34414f*4096.0f+0.5f)); - int16x8_t cb_const1 = vdupq_n_s16( (short) ( 1.77200f*4096.0f+0.5f)); - - for (; i+7 < count; i += 8) { - // load - uint8x8_t y_bytes = vld1_u8(y + i); - uint8x8_t cr_bytes = vld1_u8(pcr + i); - uint8x8_t cb_bytes = vld1_u8(pcb + i); - int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip)); - int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip)); - - // expand to s16 - int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4)); - int16x8_t crw = vshll_n_s8(cr_biased, 7); - int16x8_t cbw = vshll_n_s8(cb_biased, 7); - - // color transform - int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0); - int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0); - int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1); - int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1); - int16x8_t rws = vaddq_s16(yws, cr0); - int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1); - int16x8_t bws = vaddq_s16(yws, cb1); - - // undo scaling, round, convert to byte - uint8x8x4_t o; - o.val[0] = vqrshrun_n_s16(rws, 4); - o.val[1] = vqrshrun_n_s16(gws, 4); - o.val[2] = vqrshrun_n_s16(bws, 4); - o.val[3] = vdup_n_u8(255); - - // store, interleaving r/g/b/a - vst4_u8(out, o); - out += 8*4; - } - } -#endif - - for (; i < count; ++i) { - int y_fixed = (y[i] << 20) + (1<<19); // rounding - int r,g,b; - int cr = pcr[i] - 128; - int cb = pcb[i] - 128; - r = y_fixed + cr* stbi__float2fixed(1.40200f); - g = y_fixed + cr*-stbi__float2fixed(0.71414f) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); - b = y_fixed + cb* stbi__float2fixed(1.77200f); - r >>= 20; - g >>= 20; - b >>= 20; - if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } - if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } - if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } - out[0] = (stbi_uc)r; - out[1] = (stbi_uc)g; - out[2] = (stbi_uc)b; - out[3] = 255; - out += step; - } -} -#endif - -// set up the kernels -static void stbi__setup_jpeg(stbi__jpeg *j) -{ - j->idct_block_kernel = stbi__idct_block; - j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row; - j->resample_row_hv_2_kernel = stbi__resample_row_hv_2; - -#ifdef STBI_SSE2 - if (stbi__sse2_available()) { - j->idct_block_kernel = stbi__idct_simd; - j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; - j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; - } -#endif - -#ifdef STBI_NEON - j->idct_block_kernel = stbi__idct_simd; - j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; - j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; -#endif -} - -// clean up the temporary component buffers -static void stbi__cleanup_jpeg(stbi__jpeg *j) -{ - stbi__free_jpeg_components(j, j->s->img_n, 0); -} - -typedef struct -{ - resample_row_func resample; - stbi_uc *line0,*line1; - int hs,vs; // expansion factor in each axis - int w_lores; // horizontal pixels pre-expansion - int ystep; // how far through vertical expansion we are - int ypos; // which pre-expansion row we're on -} stbi__resample; - -// fast 0..255 * 0..255 => 0..255 rounded multiplication -static stbi_uc stbi__blinn_8x8(stbi_uc x, stbi_uc y) -{ - unsigned int t = x*y + 128; - return (stbi_uc) ((t + (t >>8)) >> 8); -} - -static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) -{ - int n, decode_n, is_rgb; - z->s->img_n = 0; // make stbi__cleanup_jpeg safe - - // validate req_comp - if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); - - // load a jpeg image from whichever source, but leave in YCbCr format - if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; } - - // determine actual number of components to generate - n = req_comp ? req_comp : z->s->img_n >= 3 ? 3 : 1; - - is_rgb = z->s->img_n == 3 && (z->rgb == 3 || (z->app14_color_transform == 0 && !z->jfif)); - - if (z->s->img_n == 3 && n < 3 && !is_rgb) - decode_n = 1; - else - decode_n = z->s->img_n; - - // nothing to do if no components requested; check this now to avoid - // accessing uninitialized coutput[0] later - if (decode_n <= 0) { stbi__cleanup_jpeg(z); return NULL; } - - // resample and color-convert - { - int k; - unsigned int i,j; - stbi_uc *output; - stbi_uc *coutput[4] = { NULL, NULL, NULL, NULL }; - - stbi__resample res_comp[4]; - - for (k=0; k < decode_n; ++k) { - stbi__resample *r = &res_comp[k]; - - // allocate line buffer big enough for upsampling off the edges - // with upsample factor of 4 - z->img_comp[k].linebuf = (stbi_uc *) stbi__malloc(z->s->img_x + 3); - if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } - - r->hs = z->img_h_max / z->img_comp[k].h; - r->vs = z->img_v_max / z->img_comp[k].v; - r->ystep = r->vs >> 1; - r->w_lores = (z->s->img_x + r->hs-1) / r->hs; - r->ypos = 0; - r->line0 = r->line1 = z->img_comp[k].data; - - if (r->hs == 1 && r->vs == 1) r->resample = resample_row_1; - else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2; - else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2; - else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel; - else r->resample = stbi__resample_row_generic; - } - - // can't error after this so, this is safe - output = (stbi_uc *) stbi__malloc_mad3(n, z->s->img_x, z->s->img_y, 1); - if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } - - // now go ahead and resample - for (j=0; j < z->s->img_y; ++j) { - stbi_uc *out = output + n * z->s->img_x * j; - for (k=0; k < decode_n; ++k) { - stbi__resample *r = &res_comp[k]; - int y_bot = r->ystep >= (r->vs >> 1); - coutput[k] = r->resample(z->img_comp[k].linebuf, - y_bot ? r->line1 : r->line0, - y_bot ? r->line0 : r->line1, - r->w_lores, r->hs); - if (++r->ystep >= r->vs) { - r->ystep = 0; - r->line0 = r->line1; - if (++r->ypos < z->img_comp[k].y) - r->line1 += z->img_comp[k].w2; - } - } - if (n >= 3) { - stbi_uc *y = coutput[0]; - if (z->s->img_n == 3) { - if (is_rgb) { - for (i=0; i < z->s->img_x; ++i) { - out[0] = y[i]; - out[1] = coutput[1][i]; - out[2] = coutput[2][i]; - out[3] = 255; - out += n; - } - } else { - z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); - } - } else if (z->s->img_n == 4) { - if (z->app14_color_transform == 0) { // CMYK - for (i=0; i < z->s->img_x; ++i) { - stbi_uc m = coutput[3][i]; - out[0] = stbi__blinn_8x8(coutput[0][i], m); - out[1] = stbi__blinn_8x8(coutput[1][i], m); - out[2] = stbi__blinn_8x8(coutput[2][i], m); - out[3] = 255; - out += n; - } - } else if (z->app14_color_transform == 2) { // YCCK - z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); - for (i=0; i < z->s->img_x; ++i) { - stbi_uc m = coutput[3][i]; - out[0] = stbi__blinn_8x8(255 - out[0], m); - out[1] = stbi__blinn_8x8(255 - out[1], m); - out[2] = stbi__blinn_8x8(255 - out[2], m); - out += n; - } - } else { // YCbCr + alpha? Ignore the fourth channel for now - z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); - } - } else - for (i=0; i < z->s->img_x; ++i) { - out[0] = out[1] = out[2] = y[i]; - out[3] = 255; // not used if n==3 - out += n; - } - } else { - if (is_rgb) { - if (n == 1) - for (i=0; i < z->s->img_x; ++i) - *out++ = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); - else { - for (i=0; i < z->s->img_x; ++i, out += 2) { - out[0] = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); - out[1] = 255; - } - } - } else if (z->s->img_n == 4 && z->app14_color_transform == 0) { - for (i=0; i < z->s->img_x; ++i) { - stbi_uc m = coutput[3][i]; - stbi_uc r = stbi__blinn_8x8(coutput[0][i], m); - stbi_uc g = stbi__blinn_8x8(coutput[1][i], m); - stbi_uc b = stbi__blinn_8x8(coutput[2][i], m); - out[0] = stbi__compute_y(r, g, b); - out[1] = 255; - out += n; - } - } else if (z->s->img_n == 4 && z->app14_color_transform == 2) { - for (i=0; i < z->s->img_x; ++i) { - out[0] = stbi__blinn_8x8(255 - coutput[0][i], coutput[3][i]); - out[1] = 255; - out += n; - } - } else { - stbi_uc *y = coutput[0]; - if (n == 1) - for (i=0; i < z->s->img_x; ++i) out[i] = y[i]; - else - for (i=0; i < z->s->img_x; ++i) { *out++ = y[i]; *out++ = 255; } - } - } - } - stbi__cleanup_jpeg(z); - *out_x = z->s->img_x; - *out_y = z->s->img_y; - if (comp) *comp = z->s->img_n >= 3 ? 3 : 1; // report original components, not output - return output; - } -} - -static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - unsigned char* result; - stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg)); - if (!j) return stbi__errpuc("outofmem", "Out of memory"); - memset(j, 0, sizeof(stbi__jpeg)); - STBI_NOTUSED(ri); - j->s = s; - stbi__setup_jpeg(j); - result = load_jpeg_image(j, x,y,comp,req_comp); - STBI_FREE(j); - return result; -} - -static int stbi__jpeg_test(stbi__context *s) -{ - int r; - stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg)); - if (!j) return stbi__err("outofmem", "Out of memory"); - memset(j, 0, sizeof(stbi__jpeg)); - j->s = s; - stbi__setup_jpeg(j); - r = stbi__decode_jpeg_header(j, STBI__SCAN_type); - stbi__rewind(s); - STBI_FREE(j); - return r; -} - -static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp) -{ - if (!stbi__decode_jpeg_header(j, STBI__SCAN_header)) { - stbi__rewind( j->s ); - return 0; - } - if (x) *x = j->s->img_x; - if (y) *y = j->s->img_y; - if (comp) *comp = j->s->img_n >= 3 ? 3 : 1; - return 1; -} - -static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp) -{ - int result; - stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg))); - if (!j) return stbi__err("outofmem", "Out of memory"); - memset(j, 0, sizeof(stbi__jpeg)); - j->s = s; - result = stbi__jpeg_info_raw(j, x, y, comp); - STBI_FREE(j); - return result; -} -#endif - -// public domain zlib decode v0.2 Sean Barrett 2006-11-18 -// simple implementation -// - all input must be provided in an upfront buffer -// - all output is written to a single output buffer (can malloc/realloc) -// performance -// - fast huffman - -#ifndef STBI_NO_ZLIB - -// fast-way is faster to check than jpeg huffman, but slow way is slower -#define STBI__ZFAST_BITS 9 // accelerate all cases in default tables -#define STBI__ZFAST_MASK ((1 << STBI__ZFAST_BITS) - 1) -#define STBI__ZNSYMS 288 // number of symbols in literal/length alphabet - -// zlib-style huffman encoding -// (jpegs packs from left, zlib from right, so can't share code) -typedef struct -{ - stbi__uint16 fast[1 << STBI__ZFAST_BITS]; - stbi__uint16 firstcode[16]; - int maxcode[17]; - stbi__uint16 firstsymbol[16]; - stbi_uc size[STBI__ZNSYMS]; - stbi__uint16 value[STBI__ZNSYMS]; -} stbi__zhuffman; - -stbi_inline static int stbi__bitreverse16(int n) -{ - n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1); - n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2); - n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4); - n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); - return n; -} - -stbi_inline static int stbi__bit_reverse(int v, int bits) -{ - STBI_ASSERT(bits <= 16); - // to bit reverse n bits, reverse 16 and shift - // e.g. 11 bits, bit reverse and shift away 5 - return stbi__bitreverse16(v) >> (16-bits); -} - -static int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, int num) -{ - int i,k=0; - int code, next_code[16], sizes[17]; - - // DEFLATE spec for generating codes - memset(sizes, 0, sizeof(sizes)); - memset(z->fast, 0, sizeof(z->fast)); - for (i=0; i < num; ++i) - ++sizes[sizelist[i]]; - sizes[0] = 0; - for (i=1; i < 16; ++i) - if (sizes[i] > (1 << i)) - return stbi__err("bad sizes", "Corrupt PNG"); - code = 0; - for (i=1; i < 16; ++i) { - next_code[i] = code; - z->firstcode[i] = (stbi__uint16) code; - z->firstsymbol[i] = (stbi__uint16) k; - code = (code + sizes[i]); - if (sizes[i]) - if (code-1 >= (1 << i)) return stbi__err("bad codelengths","Corrupt PNG"); - z->maxcode[i] = code << (16-i); // preshift for inner loop - code <<= 1; - k += sizes[i]; - } - z->maxcode[16] = 0x10000; // sentinel - for (i=0; i < num; ++i) { - int s = sizelist[i]; - if (s) { - int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s]; - stbi__uint16 fastv = (stbi__uint16) ((s << 9) | i); - z->size [c] = (stbi_uc ) s; - z->value[c] = (stbi__uint16) i; - if (s <= STBI__ZFAST_BITS) { - int j = stbi__bit_reverse(next_code[s],s); - while (j < (1 << STBI__ZFAST_BITS)) { - z->fast[j] = fastv; - j += (1 << s); - } - } - ++next_code[s]; - } - } - return 1; -} - -// zlib-from-memory implementation for PNG reading -// because PNG allows splitting the zlib stream arbitrarily, -// and it's annoying structurally to have PNG call ZLIB call PNG, -// we require PNG read all the IDATs and combine them into a single -// memory buffer - -typedef struct -{ - stbi_uc *zbuffer, *zbuffer_end; - int num_bits; - stbi__uint32 code_buffer; - - char *zout; - char *zout_start; - char *zout_end; - int z_expandable; - - stbi__zhuffman z_length, z_distance; -} stbi__zbuf; - -stbi_inline static int stbi__zeof(stbi__zbuf *z) -{ - return (z->zbuffer >= z->zbuffer_end); -} - -stbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z) -{ - return stbi__zeof(z) ? 0 : *z->zbuffer++; -} - -static void stbi__fill_bits(stbi__zbuf *z) -{ - do { - if (z->code_buffer >= (1U << z->num_bits)) { - z->zbuffer = z->zbuffer_end; /* treat this as EOF so we fail. */ - return; - } - z->code_buffer |= (unsigned int) stbi__zget8(z) << z->num_bits; - z->num_bits += 8; - } while (z->num_bits <= 24); -} - -stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n) -{ - unsigned int k; - if (z->num_bits < n) stbi__fill_bits(z); - k = z->code_buffer & ((1 << n) - 1); - z->code_buffer >>= n; - z->num_bits -= n; - return k; -} - -static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z) -{ - int b,s,k; - // not resolved by fast table, so compute it the slow way - // use jpeg approach, which requires MSbits at top - k = stbi__bit_reverse(a->code_buffer, 16); - for (s=STBI__ZFAST_BITS+1; ; ++s) - if (k < z->maxcode[s]) - break; - if (s >= 16) return -1; // invalid code! - // code size is s, so: - b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s]; - if (b >= STBI__ZNSYMS) return -1; // some data was corrupt somewhere! - if (z->size[b] != s) return -1; // was originally an assert, but report failure instead. - a->code_buffer >>= s; - a->num_bits -= s; - return z->value[b]; -} - -stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z) -{ - int b,s; - if (a->num_bits < 16) { - if (stbi__zeof(a)) { - return -1; /* report error for unexpected end of data. */ - } - stbi__fill_bits(a); - } - b = z->fast[a->code_buffer & STBI__ZFAST_MASK]; - if (b) { - s = b >> 9; - a->code_buffer >>= s; - a->num_bits -= s; - return b & 511; - } - return stbi__zhuffman_decode_slowpath(a, z); -} - -static int stbi__zexpand(stbi__zbuf *z, char *zout, int n) // need to make room for n bytes -{ - char *q; - unsigned int cur, limit, old_limit; - z->zout = zout; - if (!z->z_expandable) return stbi__err("output buffer limit","Corrupt PNG"); - cur = (unsigned int) (z->zout - z->zout_start); - limit = old_limit = (unsigned) (z->zout_end - z->zout_start); - if (UINT_MAX - cur < (unsigned) n) return stbi__err("outofmem", "Out of memory"); - while (cur + n > limit) { - if(limit > UINT_MAX / 2) return stbi__err("outofmem", "Out of memory"); - limit *= 2; - } - q = (char *) STBI_REALLOC_SIZED(z->zout_start, old_limit, limit); - STBI_NOTUSED(old_limit); - if (q == NULL) return stbi__err("outofmem", "Out of memory"); - z->zout_start = q; - z->zout = q + cur; - z->zout_end = q + limit; - return 1; -} - -static const int stbi__zlength_base[31] = { - 3,4,5,6,7,8,9,10,11,13, - 15,17,19,23,27,31,35,43,51,59, - 67,83,99,115,131,163,195,227,258,0,0 }; - -static const int stbi__zlength_extra[31]= -{ 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; - -static const int stbi__zdist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, -257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; - -static const int stbi__zdist_extra[32] = -{ 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; - -static int stbi__parse_huffman_block(stbi__zbuf *a) -{ - char *zout = a->zout; - for(;;) { - int z = stbi__zhuffman_decode(a, &a->z_length); - if (z < 256) { - if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); // error in huffman codes - if (zout >= a->zout_end) { - if (!stbi__zexpand(a, zout, 1)) return 0; - zout = a->zout; - } - *zout++ = (char) z; - } else { - stbi_uc *p; - int len,dist; - if (z == 256) { - a->zout = zout; - return 1; - } - if (z >= 286) return stbi__err("bad huffman code","Corrupt PNG"); // per DEFLATE, length codes 286 and 287 must not appear in compressed data - z -= 257; - len = stbi__zlength_base[z]; - if (stbi__zlength_extra[z]) len += stbi__zreceive(a, stbi__zlength_extra[z]); - z = stbi__zhuffman_decode(a, &a->z_distance); - if (z < 0 || z >= 30) return stbi__err("bad huffman code","Corrupt PNG"); // per DEFLATE, distance codes 30 and 31 must not appear in compressed data - dist = stbi__zdist_base[z]; - if (stbi__zdist_extra[z]) dist += stbi__zreceive(a, stbi__zdist_extra[z]); - if (zout - a->zout_start < dist) return stbi__err("bad dist","Corrupt PNG"); - if (zout + len > a->zout_end) { - if (!stbi__zexpand(a, zout, len)) return 0; - zout = a->zout; - } - p = (stbi_uc *) (zout - dist); - if (dist == 1) { // run of one byte; common in images. - stbi_uc v = *p; - if (len) { do *zout++ = v; while (--len); } - } else { - if (len) { do *zout++ = *p++; while (--len); } - } - } - } -} - -static int stbi__compute_huffman_codes(stbi__zbuf *a) -{ - static const stbi_uc length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; - stbi__zhuffman z_codelength; - stbi_uc lencodes[286+32+137];//padding for maximum single op - stbi_uc codelength_sizes[19]; - int i,n; - - int hlit = stbi__zreceive(a,5) + 257; - int hdist = stbi__zreceive(a,5) + 1; - int hclen = stbi__zreceive(a,4) + 4; - int ntot = hlit + hdist; - - memset(codelength_sizes, 0, sizeof(codelength_sizes)); - for (i=0; i < hclen; ++i) { - int s = stbi__zreceive(a,3); - codelength_sizes[length_dezigzag[i]] = (stbi_uc) s; - } - if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0; - - n = 0; - while (n < ntot) { - int c = stbi__zhuffman_decode(a, &z_codelength); - if (c < 0 || c >= 19) return stbi__err("bad codelengths", "Corrupt PNG"); - if (c < 16) - lencodes[n++] = (stbi_uc) c; - else { - stbi_uc fill = 0; - if (c == 16) { - c = stbi__zreceive(a,2)+3; - if (n == 0) return stbi__err("bad codelengths", "Corrupt PNG"); - fill = lencodes[n-1]; - } else if (c == 17) { - c = stbi__zreceive(a,3)+3; - } else if (c == 18) { - c = stbi__zreceive(a,7)+11; - } else { - return stbi__err("bad codelengths", "Corrupt PNG"); - } - if (ntot - n < c) return stbi__err("bad codelengths", "Corrupt PNG"); - memset(lencodes+n, fill, c); - n += c; - } - } - if (n != ntot) return stbi__err("bad codelengths","Corrupt PNG"); - if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) return 0; - if (!stbi__zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0; - return 1; -} - -static int stbi__parse_uncompressed_block(stbi__zbuf *a) -{ - stbi_uc header[4]; - int len,nlen,k; - if (a->num_bits & 7) - stbi__zreceive(a, a->num_bits & 7); // discard - // drain the bit-packed data into header - k = 0; - while (a->num_bits > 0) { - header[k++] = (stbi_uc) (a->code_buffer & 255); // suppress MSVC run-time check - a->code_buffer >>= 8; - a->num_bits -= 8; - } - if (a->num_bits < 0) return stbi__err("zlib corrupt","Corrupt PNG"); - // now fill header the normal way - while (k < 4) - header[k++] = stbi__zget8(a); - len = header[1] * 256 + header[0]; - nlen = header[3] * 256 + header[2]; - if (nlen != (len ^ 0xffff)) return stbi__err("zlib corrupt","Corrupt PNG"); - if (a->zbuffer + len > a->zbuffer_end) return stbi__err("read past buffer","Corrupt PNG"); - if (a->zout + len > a->zout_end) - if (!stbi__zexpand(a, a->zout, len)) return 0; - memcpy(a->zout, a->zbuffer, len); - a->zbuffer += len; - a->zout += len; - return 1; -} - -static int stbi__parse_zlib_header(stbi__zbuf *a) -{ - int cmf = stbi__zget8(a); - int cm = cmf & 15; - /* int cinfo = cmf >> 4; */ - int flg = stbi__zget8(a); - if (stbi__zeof(a)) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec - if ((cmf*256+flg) % 31 != 0) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec - if (flg & 32) return stbi__err("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png - if (cm != 8) return stbi__err("bad compression","Corrupt PNG"); // DEFLATE required for png - // window = 1 << (8 + cinfo)... but who cares, we fully buffer output - return 1; -} - -static const stbi_uc stbi__zdefault_length[STBI__ZNSYMS] = -{ - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8 -}; -static const stbi_uc stbi__zdefault_distance[32] = -{ - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 -}; -/* -Init algorithm: -{ - int i; // use <= to match clearly with spec - for (i=0; i <= 143; ++i) stbi__zdefault_length[i] = 8; - for ( ; i <= 255; ++i) stbi__zdefault_length[i] = 9; - for ( ; i <= 279; ++i) stbi__zdefault_length[i] = 7; - for ( ; i <= 287; ++i) stbi__zdefault_length[i] = 8; - - for (i=0; i <= 31; ++i) stbi__zdefault_distance[i] = 5; -} -*/ - -static int stbi__parse_zlib(stbi__zbuf *a, int parse_header) -{ - int final, type; - if (parse_header) - if (!stbi__parse_zlib_header(a)) return 0; - a->num_bits = 0; - a->code_buffer = 0; - do { - final = stbi__zreceive(a,1); - type = stbi__zreceive(a,2); - if (type == 0) { - if (!stbi__parse_uncompressed_block(a)) return 0; - } else if (type == 3) { - return 0; - } else { - if (type == 1) { - // use fixed code lengths - if (!stbi__zbuild_huffman(&a->z_length , stbi__zdefault_length , STBI__ZNSYMS)) return 0; - if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance, 32)) return 0; - } else { - if (!stbi__compute_huffman_codes(a)) return 0; - } - if (!stbi__parse_huffman_block(a)) return 0; - } - } while (!final); - return 1; -} - -static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse_header) -{ - a->zout_start = obuf; - a->zout = obuf; - a->zout_end = obuf + olen; - a->z_expandable = exp; - - return stbi__parse_zlib(a, parse_header); -} - -STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen) -{ - stbi__zbuf a; - char *p = (char *) stbi__malloc(initial_size); - if (p == NULL) return NULL; - a.zbuffer = (stbi_uc *) buffer; - a.zbuffer_end = (stbi_uc *) buffer + len; - if (stbi__do_zlib(&a, p, initial_size, 1, 1)) { - if (outlen) *outlen = (int) (a.zout - a.zout_start); - return a.zout_start; - } else { - STBI_FREE(a.zout_start); - return NULL; - } -} - -STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen) -{ - return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen); -} - -STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header) -{ - stbi__zbuf a; - char *p = (char *) stbi__malloc(initial_size); - if (p == NULL) return NULL; - a.zbuffer = (stbi_uc *) buffer; - a.zbuffer_end = (stbi_uc *) buffer + len; - if (stbi__do_zlib(&a, p, initial_size, 1, parse_header)) { - if (outlen) *outlen = (int) (a.zout - a.zout_start); - return a.zout_start; - } else { - STBI_FREE(a.zout_start); - return NULL; - } -} - -STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen) -{ - stbi__zbuf a; - a.zbuffer = (stbi_uc *) ibuffer; - a.zbuffer_end = (stbi_uc *) ibuffer + ilen; - if (stbi__do_zlib(&a, obuffer, olen, 0, 1)) - return (int) (a.zout - a.zout_start); - else - return -1; -} - -STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen) -{ - stbi__zbuf a; - char *p = (char *) stbi__malloc(16384); - if (p == NULL) return NULL; - a.zbuffer = (stbi_uc *) buffer; - a.zbuffer_end = (stbi_uc *) buffer+len; - if (stbi__do_zlib(&a, p, 16384, 1, 0)) { - if (outlen) *outlen = (int) (a.zout - a.zout_start); - return a.zout_start; - } else { - STBI_FREE(a.zout_start); - return NULL; - } -} - -STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen) -{ - stbi__zbuf a; - a.zbuffer = (stbi_uc *) ibuffer; - a.zbuffer_end = (stbi_uc *) ibuffer + ilen; - if (stbi__do_zlib(&a, obuffer, olen, 0, 0)) - return (int) (a.zout - a.zout_start); - else - return -1; -} -#endif - -// public domain "baseline" PNG decoder v0.10 Sean Barrett 2006-11-18 -// simple implementation -// - only 8-bit samples -// - no CRC checking -// - allocates lots of intermediate memory -// - avoids problem of streaming data between subsystems -// - avoids explicit window management -// performance -// - uses stb_zlib, a PD zlib implementation with fast huffman decoding - -#ifndef STBI_NO_PNG -typedef struct -{ - stbi__uint32 length; - stbi__uint32 type; -} stbi__pngchunk; - -static stbi__pngchunk stbi__get_chunk_header(stbi__context *s) -{ - stbi__pngchunk c; - c.length = stbi__get32be(s); - c.type = stbi__get32be(s); - return c; -} - -static int stbi__check_png_header(stbi__context *s) -{ - static const stbi_uc png_sig[8] = { 137,80,78,71,13,10,26,10 }; - int i; - for (i=0; i < 8; ++i) - if (stbi__get8(s) != png_sig[i]) return stbi__err("bad png sig","Not a PNG"); - return 1; -} - -typedef struct -{ - stbi__context *s; - stbi_uc *idata, *expanded, *out; - int depth; -} stbi__png; - - -enum { - STBI__F_none=0, - STBI__F_sub=1, - STBI__F_up=2, - STBI__F_avg=3, - STBI__F_paeth=4, - // synthetic filters used for first scanline to avoid needing a dummy row of 0s - STBI__F_avg_first, - STBI__F_paeth_first -}; - -static stbi_uc first_row_filter[5] = -{ - STBI__F_none, - STBI__F_sub, - STBI__F_none, - STBI__F_avg_first, - STBI__F_paeth_first -}; - -static int stbi__paeth(int a, int b, int c) -{ - int p = a + b - c; - int pa = abs(p-a); - int pb = abs(p-b); - int pc = abs(p-c); - if (pa <= pb && pa <= pc) return a; - if (pb <= pc) return b; - return c; -} - -static const stbi_uc stbi__depth_scale_table[9] = { 0, 0xff, 0x55, 0, 0x11, 0,0,0, 0x01 }; - -// create the png data from post-deflated data -static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 raw_len, int out_n, stbi__uint32 x, stbi__uint32 y, int depth, int color) -{ - int bytes = (depth == 16? 2 : 1); - stbi__context *s = a->s; - stbi__uint32 i,j,stride = x*out_n*bytes; - stbi__uint32 img_len, img_width_bytes; - int k; - int img_n = s->img_n; // copy it into a local for later - - int output_bytes = out_n*bytes; - int filter_bytes = img_n*bytes; - int width = x; - - STBI_ASSERT(out_n == s->img_n || out_n == s->img_n+1); - a->out = (stbi_uc *) stbi__malloc_mad3(x, y, output_bytes, 0); // extra bytes to write off the end into - if (!a->out) return stbi__err("outofmem", "Out of memory"); - - if (!stbi__mad3sizes_valid(img_n, x, depth, 7)) return stbi__err("too large", "Corrupt PNG"); - img_width_bytes = (((img_n * x * depth) + 7) >> 3); - img_len = (img_width_bytes + 1) * y; - - // we used to check for exact match between raw_len and img_len on non-interlaced PNGs, - // but issue #276 reported a PNG in the wild that had extra data at the end (all zeros), - // so just check for raw_len < img_len always. - if (raw_len < img_len) return stbi__err("not enough pixels","Corrupt PNG"); - - for (j=0; j < y; ++j) { - stbi_uc *cur = a->out + stride*j; - stbi_uc *prior; - int filter = *raw++; - - if (filter > 4) - return stbi__err("invalid filter","Corrupt PNG"); - - if (depth < 8) { - if (img_width_bytes > x) return stbi__err("invalid width","Corrupt PNG"); - cur += x*out_n - img_width_bytes; // store output to the rightmost img_len bytes, so we can decode in place - filter_bytes = 1; - width = img_width_bytes; - } - prior = cur - stride; // bugfix: need to compute this after 'cur +=' computation above - - // if first row, use special filter that doesn't sample previous row - if (j == 0) filter = first_row_filter[filter]; - - // handle first byte explicitly - for (k=0; k < filter_bytes; ++k) { - switch (filter) { - case STBI__F_none : cur[k] = raw[k]; break; - case STBI__F_sub : cur[k] = raw[k]; break; - case STBI__F_up : cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; - case STBI__F_avg : cur[k] = STBI__BYTECAST(raw[k] + (prior[k]>>1)); break; - case STBI__F_paeth : cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(0,prior[k],0)); break; - case STBI__F_avg_first : cur[k] = raw[k]; break; - case STBI__F_paeth_first: cur[k] = raw[k]; break; - } - } - - if (depth == 8) { - if (img_n != out_n) - cur[img_n] = 255; // first pixel - raw += img_n; - cur += out_n; - prior += out_n; - } else if (depth == 16) { - if (img_n != out_n) { - cur[filter_bytes] = 255; // first pixel top byte - cur[filter_bytes+1] = 255; // first pixel bottom byte - } - raw += filter_bytes; - cur += output_bytes; - prior += output_bytes; - } else { - raw += 1; - cur += 1; - prior += 1; - } - - // this is a little gross, so that we don't switch per-pixel or per-component - if (depth < 8 || img_n == out_n) { - int nk = (width - 1)*filter_bytes; - #define STBI__CASE(f) \ - case f: \ - for (k=0; k < nk; ++k) - switch (filter) { - // "none" filter turns into a memcpy here; make that explicit. - case STBI__F_none: memcpy(cur, raw, nk); break; - STBI__CASE(STBI__F_sub) { cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); } break; - STBI__CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break; - STBI__CASE(STBI__F_avg) { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); } break; - STBI__CASE(STBI__F_paeth) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],prior[k],prior[k-filter_bytes])); } break; - STBI__CASE(STBI__F_avg_first) { cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); } break; - STBI__CASE(STBI__F_paeth_first) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],0,0)); } break; - } - #undef STBI__CASE - raw += nk; - } else { - STBI_ASSERT(img_n+1 == out_n); - #define STBI__CASE(f) \ - case f: \ - for (i=x-1; i >= 1; --i, cur[filter_bytes]=255,raw+=filter_bytes,cur+=output_bytes,prior+=output_bytes) \ - for (k=0; k < filter_bytes; ++k) - switch (filter) { - STBI__CASE(STBI__F_none) { cur[k] = raw[k]; } break; - STBI__CASE(STBI__F_sub) { cur[k] = STBI__BYTECAST(raw[k] + cur[k- output_bytes]); } break; - STBI__CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break; - STBI__CASE(STBI__F_avg) { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k- output_bytes])>>1)); } break; - STBI__CASE(STBI__F_paeth) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],prior[k],prior[k- output_bytes])); } break; - STBI__CASE(STBI__F_avg_first) { cur[k] = STBI__BYTECAST(raw[k] + (cur[k- output_bytes] >> 1)); } break; - STBI__CASE(STBI__F_paeth_first) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],0,0)); } break; - } - #undef STBI__CASE - - // the loop above sets the high byte of the pixels' alpha, but for - // 16 bit png files we also need the low byte set. we'll do that here. - if (depth == 16) { - cur = a->out + stride*j; // start at the beginning of the row again - for (i=0; i < x; ++i,cur+=output_bytes) { - cur[filter_bytes+1] = 255; - } - } - } - } - - // we make a separate pass to expand bits to pixels; for performance, - // this could run two scanlines behind the above code, so it won't - // intefere with filtering but will still be in the cache. - if (depth < 8) { - for (j=0; j < y; ++j) { - stbi_uc *cur = a->out + stride*j; - stbi_uc *in = a->out + stride*j + x*out_n - img_width_bytes; - // unpack 1/2/4-bit into a 8-bit buffer. allows us to keep the common 8-bit path optimal at minimal cost for 1/2/4-bit - // png guarante byte alignment, if width is not multiple of 8/4/2 we'll decode dummy trailing data that will be skipped in the later loop - stbi_uc scale = (color == 0) ? stbi__depth_scale_table[depth] : 1; // scale grayscale values to 0..255 range - - // note that the final byte might overshoot and write more data than desired. - // we can allocate enough data that this never writes out of memory, but it - // could also overwrite the next scanline. can it overwrite non-empty data - // on the next scanline? yes, consider 1-pixel-wide scanlines with 1-bit-per-pixel. - // so we need to explicitly clamp the final ones - - if (depth == 4) { - for (k=x*img_n; k >= 2; k-=2, ++in) { - *cur++ = scale * ((*in >> 4) ); - *cur++ = scale * ((*in ) & 0x0f); - } - if (k > 0) *cur++ = scale * ((*in >> 4) ); - } else if (depth == 2) { - for (k=x*img_n; k >= 4; k-=4, ++in) { - *cur++ = scale * ((*in >> 6) ); - *cur++ = scale * ((*in >> 4) & 0x03); - *cur++ = scale * ((*in >> 2) & 0x03); - *cur++ = scale * ((*in ) & 0x03); - } - if (k > 0) *cur++ = scale * ((*in >> 6) ); - if (k > 1) *cur++ = scale * ((*in >> 4) & 0x03); - if (k > 2) *cur++ = scale * ((*in >> 2) & 0x03); - } else if (depth == 1) { - for (k=x*img_n; k >= 8; k-=8, ++in) { - *cur++ = scale * ((*in >> 7) ); - *cur++ = scale * ((*in >> 6) & 0x01); - *cur++ = scale * ((*in >> 5) & 0x01); - *cur++ = scale * ((*in >> 4) & 0x01); - *cur++ = scale * ((*in >> 3) & 0x01); - *cur++ = scale * ((*in >> 2) & 0x01); - *cur++ = scale * ((*in >> 1) & 0x01); - *cur++ = scale * ((*in ) & 0x01); - } - if (k > 0) *cur++ = scale * ((*in >> 7) ); - if (k > 1) *cur++ = scale * ((*in >> 6) & 0x01); - if (k > 2) *cur++ = scale * ((*in >> 5) & 0x01); - if (k > 3) *cur++ = scale * ((*in >> 4) & 0x01); - if (k > 4) *cur++ = scale * ((*in >> 3) & 0x01); - if (k > 5) *cur++ = scale * ((*in >> 2) & 0x01); - if (k > 6) *cur++ = scale * ((*in >> 1) & 0x01); - } - if (img_n != out_n) { - int q; - // insert alpha = 255 - cur = a->out + stride*j; - if (img_n == 1) { - for (q=x-1; q >= 0; --q) { - cur[q*2+1] = 255; - cur[q*2+0] = cur[q]; - } - } else { - STBI_ASSERT(img_n == 3); - for (q=x-1; q >= 0; --q) { - cur[q*4+3] = 255; - cur[q*4+2] = cur[q*3+2]; - cur[q*4+1] = cur[q*3+1]; - cur[q*4+0] = cur[q*3+0]; - } - } - } - } - } else if (depth == 16) { - // force the image data from big-endian to platform-native. - // this is done in a separate pass due to the decoding relying - // on the data being untouched, but could probably be done - // per-line during decode if care is taken. - stbi_uc *cur = a->out; - stbi__uint16 *cur16 = (stbi__uint16*)cur; - - for(i=0; i < x*y*out_n; ++i,cur16++,cur+=2) { - *cur16 = (cur[0] << 8) | cur[1]; - } - } - - return 1; -} - -static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, int out_n, int depth, int color, int interlaced) -{ - int bytes = (depth == 16 ? 2 : 1); - int out_bytes = out_n * bytes; - stbi_uc *final; - int p; - if (!interlaced) - return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, a->s->img_x, a->s->img_y, depth, color); - - // de-interlacing - final = (stbi_uc *) stbi__malloc_mad3(a->s->img_x, a->s->img_y, out_bytes, 0); - if (!final) return stbi__err("outofmem", "Out of memory"); - for (p=0; p < 7; ++p) { - int xorig[] = { 0,4,0,2,0,1,0 }; - int yorig[] = { 0,0,4,0,2,0,1 }; - int xspc[] = { 8,8,4,4,2,2,1 }; - int yspc[] = { 8,8,8,4,4,2,2 }; - int i,j,x,y; - // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1 - x = (a->s->img_x - xorig[p] + xspc[p]-1) / xspc[p]; - y = (a->s->img_y - yorig[p] + yspc[p]-1) / yspc[p]; - if (x && y) { - stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y; - if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, y, depth, color)) { - STBI_FREE(final); - return 0; - } - for (j=0; j < y; ++j) { - for (i=0; i < x; ++i) { - int out_y = j*yspc[p]+yorig[p]; - int out_x = i*xspc[p]+xorig[p]; - memcpy(final + out_y*a->s->img_x*out_bytes + out_x*out_bytes, - a->out + (j*x+i)*out_bytes, out_bytes); - } - } - STBI_FREE(a->out); - image_data += img_len; - image_data_len -= img_len; - } - } - a->out = final; - - return 1; -} - -static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n) -{ - stbi__context *s = z->s; - stbi__uint32 i, pixel_count = s->img_x * s->img_y; - stbi_uc *p = z->out; - - // compute color-based transparency, assuming we've - // already got 255 as the alpha value in the output - STBI_ASSERT(out_n == 2 || out_n == 4); - - if (out_n == 2) { - for (i=0; i < pixel_count; ++i) { - p[1] = (p[0] == tc[0] ? 0 : 255); - p += 2; - } - } else { - for (i=0; i < pixel_count; ++i) { - if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) - p[3] = 0; - p += 4; - } - } - return 1; -} - -static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], int out_n) -{ - stbi__context *s = z->s; - stbi__uint32 i, pixel_count = s->img_x * s->img_y; - stbi__uint16 *p = (stbi__uint16*) z->out; - - // compute color-based transparency, assuming we've - // already got 65535 as the alpha value in the output - STBI_ASSERT(out_n == 2 || out_n == 4); - - if (out_n == 2) { - for (i = 0; i < pixel_count; ++i) { - p[1] = (p[0] == tc[0] ? 0 : 65535); - p += 2; - } - } else { - for (i = 0; i < pixel_count; ++i) { - if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) - p[3] = 0; - p += 4; - } - } - return 1; -} - -static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int pal_img_n) -{ - stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y; - stbi_uc *p, *temp_out, *orig = a->out; - - p = (stbi_uc *) stbi__malloc_mad2(pixel_count, pal_img_n, 0); - if (p == NULL) return stbi__err("outofmem", "Out of memory"); - - // between here and free(out) below, exitting would leak - temp_out = p; - - if (pal_img_n == 3) { - for (i=0; i < pixel_count; ++i) { - int n = orig[i]*4; - p[0] = palette[n ]; - p[1] = palette[n+1]; - p[2] = palette[n+2]; - p += 3; - } - } else { - for (i=0; i < pixel_count; ++i) { - int n = orig[i]*4; - p[0] = palette[n ]; - p[1] = palette[n+1]; - p[2] = palette[n+2]; - p[3] = palette[n+3]; - p += 4; - } - } - STBI_FREE(a->out); - a->out = temp_out; - - STBI_NOTUSED(len); - - return 1; -} - -static int stbi__unpremultiply_on_load_global = 0; -static int stbi__de_iphone_flag_global = 0; - -STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply) -{ - stbi__unpremultiply_on_load_global = flag_true_if_should_unpremultiply; -} - -STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert) -{ - stbi__de_iphone_flag_global = flag_true_if_should_convert; -} - -#ifndef STBI_THREAD_LOCAL -#define stbi__unpremultiply_on_load stbi__unpremultiply_on_load_global -#define stbi__de_iphone_flag stbi__de_iphone_flag_global -#else -static STBI_THREAD_LOCAL int stbi__unpremultiply_on_load_local, stbi__unpremultiply_on_load_set; -static STBI_THREAD_LOCAL int stbi__de_iphone_flag_local, stbi__de_iphone_flag_set; - -STBIDEF void stbi_set_unpremultiply_on_load_thread(int flag_true_if_should_unpremultiply) -{ - stbi__unpremultiply_on_load_local = flag_true_if_should_unpremultiply; - stbi__unpremultiply_on_load_set = 1; -} - -STBIDEF void stbi_convert_iphone_png_to_rgb_thread(int flag_true_if_should_convert) -{ - stbi__de_iphone_flag_local = flag_true_if_should_convert; - stbi__de_iphone_flag_set = 1; -} - -#define stbi__unpremultiply_on_load (stbi__unpremultiply_on_load_set \ - ? stbi__unpremultiply_on_load_local \ - : stbi__unpremultiply_on_load_global) -#define stbi__de_iphone_flag (stbi__de_iphone_flag_set \ - ? stbi__de_iphone_flag_local \ - : stbi__de_iphone_flag_global) -#endif // STBI_THREAD_LOCAL - -static void stbi__de_iphone(stbi__png *z) -{ - stbi__context *s = z->s; - stbi__uint32 i, pixel_count = s->img_x * s->img_y; - stbi_uc *p = z->out; - - if (s->img_out_n == 3) { // convert bgr to rgb - for (i=0; i < pixel_count; ++i) { - stbi_uc t = p[0]; - p[0] = p[2]; - p[2] = t; - p += 3; - } - } else { - STBI_ASSERT(s->img_out_n == 4); - if (stbi__unpremultiply_on_load) { - // convert bgr to rgb and unpremultiply - for (i=0; i < pixel_count; ++i) { - stbi_uc a = p[3]; - stbi_uc t = p[0]; - if (a) { - stbi_uc half = a / 2; - p[0] = (p[2] * 255 + half) / a; - p[1] = (p[1] * 255 + half) / a; - p[2] = ( t * 255 + half) / a; - } else { - p[0] = p[2]; - p[2] = t; - } - p += 4; - } - } else { - // convert bgr to rgb - for (i=0; i < pixel_count; ++i) { - stbi_uc t = p[0]; - p[0] = p[2]; - p[2] = t; - p += 4; - } - } - } -} - -#define STBI__PNG_TYPE(a,b,c,d) (((unsigned) (a) << 24) + ((unsigned) (b) << 16) + ((unsigned) (c) << 8) + (unsigned) (d)) - -static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp) -{ - stbi_uc palette[1024], pal_img_n=0; - stbi_uc has_trans=0, tc[3]={0}; - stbi__uint16 tc16[3]; - stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0; - int first=1,k,interlace=0, color=0, is_iphone=0; - stbi__context *s = z->s; - - z->expanded = NULL; - z->idata = NULL; - z->out = NULL; - - if (!stbi__check_png_header(s)) return 0; - - if (scan == STBI__SCAN_type) return 1; - - for (;;) { - stbi__pngchunk c = stbi__get_chunk_header(s); - switch (c.type) { - case STBI__PNG_TYPE('C','g','B','I'): - is_iphone = 1; - stbi__skip(s, c.length); - break; - case STBI__PNG_TYPE('I','H','D','R'): { - int comp,filter; - if (!first) return stbi__err("multiple IHDR","Corrupt PNG"); - first = 0; - if (c.length != 13) return stbi__err("bad IHDR len","Corrupt PNG"); - s->img_x = stbi__get32be(s); - s->img_y = stbi__get32be(s); - if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); - if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); - z->depth = stbi__get8(s); if (z->depth != 1 && z->depth != 2 && z->depth != 4 && z->depth != 8 && z->depth != 16) return stbi__err("1/2/4/8/16-bit only","PNG not supported: 1/2/4/8/16-bit only"); - color = stbi__get8(s); if (color > 6) return stbi__err("bad ctype","Corrupt PNG"); - if (color == 3 && z->depth == 16) return stbi__err("bad ctype","Corrupt PNG"); - if (color == 3) pal_img_n = 3; else if (color & 1) return stbi__err("bad ctype","Corrupt PNG"); - comp = stbi__get8(s); if (comp) return stbi__err("bad comp method","Corrupt PNG"); - filter= stbi__get8(s); if (filter) return stbi__err("bad filter method","Corrupt PNG"); - interlace = stbi__get8(s); if (interlace>1) return stbi__err("bad interlace method","Corrupt PNG"); - if (!s->img_x || !s->img_y) return stbi__err("0-pixel image","Corrupt PNG"); - if (!pal_img_n) { - s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0); - if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode"); - } else { - // if paletted, then pal_n is our final components, and - // img_n is # components to decompress/filter. - s->img_n = 1; - if ((1 << 30) / s->img_x / 4 < s->img_y) return stbi__err("too large","Corrupt PNG"); - } - // even with SCAN_header, have to scan to see if we have a tRNS - break; - } - - case STBI__PNG_TYPE('P','L','T','E'): { - if (first) return stbi__err("first not IHDR", "Corrupt PNG"); - if (c.length > 256*3) return stbi__err("invalid PLTE","Corrupt PNG"); - pal_len = c.length / 3; - if (pal_len * 3 != c.length) return stbi__err("invalid PLTE","Corrupt PNG"); - for (i=0; i < pal_len; ++i) { - palette[i*4+0] = stbi__get8(s); - palette[i*4+1] = stbi__get8(s); - palette[i*4+2] = stbi__get8(s); - palette[i*4+3] = 255; - } - break; - } - - case STBI__PNG_TYPE('t','R','N','S'): { - if (first) return stbi__err("first not IHDR", "Corrupt PNG"); - if (z->idata) return stbi__err("tRNS after IDAT","Corrupt PNG"); - if (pal_img_n) { - if (scan == STBI__SCAN_header) { s->img_n = 4; return 1; } - if (pal_len == 0) return stbi__err("tRNS before PLTE","Corrupt PNG"); - if (c.length > pal_len) return stbi__err("bad tRNS len","Corrupt PNG"); - pal_img_n = 4; - for (i=0; i < c.length; ++i) - palette[i*4+3] = stbi__get8(s); - } else { - if (!(s->img_n & 1)) return stbi__err("tRNS with alpha","Corrupt PNG"); - if (c.length != (stbi__uint32) s->img_n*2) return stbi__err("bad tRNS len","Corrupt PNG"); - has_trans = 1; - // non-paletted with tRNS = constant alpha. if header-scanning, we can stop now. - if (scan == STBI__SCAN_header) { ++s->img_n; return 1; } - if (z->depth == 16) { - for (k = 0; k < s->img_n; ++k) tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is - } else { - for (k = 0; k < s->img_n; ++k) tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger - } - } - break; - } - - case STBI__PNG_TYPE('I','D','A','T'): { - if (first) return stbi__err("first not IHDR", "Corrupt PNG"); - if (pal_img_n && !pal_len) return stbi__err("no PLTE","Corrupt PNG"); - if (scan == STBI__SCAN_header) { - // header scan definitely stops at first IDAT - if (pal_img_n) - s->img_n = pal_img_n; - return 1; - } - if (c.length > (1u << 30)) return stbi__err("IDAT size limit", "IDAT section larger than 2^30 bytes"); - if ((int)(ioff + c.length) < (int)ioff) return 0; - if (ioff + c.length > idata_limit) { - stbi__uint32 idata_limit_old = idata_limit; - stbi_uc *p; - if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096; - while (ioff + c.length > idata_limit) - idata_limit *= 2; - STBI_NOTUSED(idata_limit_old); - p = (stbi_uc *) STBI_REALLOC_SIZED(z->idata, idata_limit_old, idata_limit); if (p == NULL) return stbi__err("outofmem", "Out of memory"); - z->idata = p; - } - if (!stbi__getn(s, z->idata+ioff,c.length)) return stbi__err("outofdata","Corrupt PNG"); - ioff += c.length; - break; - } - - case STBI__PNG_TYPE('I','E','N','D'): { - stbi__uint32 raw_len, bpl; - if (first) return stbi__err("first not IHDR", "Corrupt PNG"); - if (scan != STBI__SCAN_load) return 1; - if (z->idata == NULL) return stbi__err("no IDAT","Corrupt PNG"); - // initial guess for decoded data size to avoid unnecessary reallocs - bpl = (s->img_x * z->depth + 7) / 8; // bytes per line, per component - raw_len = bpl * s->img_y * s->img_n /* pixels */ + s->img_y /* filter mode per row */; - z->expanded = (stbi_uc *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, raw_len, (int *) &raw_len, !is_iphone); - if (z->expanded == NULL) return 0; // zlib should set error - STBI_FREE(z->idata); z->idata = NULL; - if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans) - s->img_out_n = s->img_n+1; - else - s->img_out_n = s->img_n; - if (!stbi__create_png_image(z, z->expanded, raw_len, s->img_out_n, z->depth, color, interlace)) return 0; - if (has_trans) { - if (z->depth == 16) { - if (!stbi__compute_transparency16(z, tc16, s->img_out_n)) return 0; - } else { - if (!stbi__compute_transparency(z, tc, s->img_out_n)) return 0; - } - } - if (is_iphone && stbi__de_iphone_flag && s->img_out_n > 2) - stbi__de_iphone(z); - if (pal_img_n) { - // pal_img_n == 3 or 4 - s->img_n = pal_img_n; // record the actual colors we had - s->img_out_n = pal_img_n; - if (req_comp >= 3) s->img_out_n = req_comp; - if (!stbi__expand_png_palette(z, palette, pal_len, s->img_out_n)) - return 0; - } else if (has_trans) { - // non-paletted image with tRNS -> source image has (constant) alpha - ++s->img_n; - } - STBI_FREE(z->expanded); z->expanded = NULL; - // end of PNG chunk, read and skip CRC - stbi__get32be(s); - return 1; - } - - default: - // if critical, fail - if (first) return stbi__err("first not IHDR", "Corrupt PNG"); - if ((c.type & (1 << 29)) == 0) { - #ifndef STBI_NO_FAILURE_STRINGS - // not threadsafe - static char invalid_chunk[] = "XXXX PNG chunk not known"; - invalid_chunk[0] = STBI__BYTECAST(c.type >> 24); - invalid_chunk[1] = STBI__BYTECAST(c.type >> 16); - invalid_chunk[2] = STBI__BYTECAST(c.type >> 8); - invalid_chunk[3] = STBI__BYTECAST(c.type >> 0); - #endif - return stbi__err(invalid_chunk, "PNG not supported: unknown PNG chunk type"); - } - stbi__skip(s, c.length); - break; - } - // end of PNG chunk, read and skip CRC - stbi__get32be(s); - } -} - -static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp, stbi__result_info *ri) -{ - void *result=NULL; - if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); - if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) { - if (p->depth <= 8) - ri->bits_per_channel = 8; - else if (p->depth == 16) - ri->bits_per_channel = 16; - else - return stbi__errpuc("bad bits_per_channel", "PNG not supported: unsupported color depth"); - result = p->out; - p->out = NULL; - if (req_comp && req_comp != p->s->img_out_n) { - if (ri->bits_per_channel == 8) - result = stbi__convert_format((unsigned char *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); - else - result = stbi__convert_format16((stbi__uint16 *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); - p->s->img_out_n = req_comp; - if (result == NULL) return result; - } - *x = p->s->img_x; - *y = p->s->img_y; - if (n) *n = p->s->img_n; - } - STBI_FREE(p->out); p->out = NULL; - STBI_FREE(p->expanded); p->expanded = NULL; - STBI_FREE(p->idata); p->idata = NULL; - - return result; -} - -static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - stbi__png p; - p.s = s; - return stbi__do_png(&p, x,y,comp,req_comp, ri); -} - -static int stbi__png_test(stbi__context *s) -{ - int r; - r = stbi__check_png_header(s); - stbi__rewind(s); - return r; -} - -static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp) -{ - if (!stbi__parse_png_file(p, STBI__SCAN_header, 0)) { - stbi__rewind( p->s ); - return 0; - } - if (x) *x = p->s->img_x; - if (y) *y = p->s->img_y; - if (comp) *comp = p->s->img_n; - return 1; -} - -static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp) -{ - stbi__png p; - p.s = s; - return stbi__png_info_raw(&p, x, y, comp); -} - -static int stbi__png_is16(stbi__context *s) -{ - stbi__png p; - p.s = s; - if (!stbi__png_info_raw(&p, NULL, NULL, NULL)) - return 0; - if (p.depth != 16) { - stbi__rewind(p.s); - return 0; - } - return 1; -} -#endif - -// Microsoft/Windows BMP image - -#ifndef STBI_NO_BMP -static int stbi__bmp_test_raw(stbi__context *s) -{ - int r; - int sz; - if (stbi__get8(s) != 'B') return 0; - if (stbi__get8(s) != 'M') return 0; - stbi__get32le(s); // discard filesize - stbi__get16le(s); // discard reserved - stbi__get16le(s); // discard reserved - stbi__get32le(s); // discard data offset - sz = stbi__get32le(s); - r = (sz == 12 || sz == 40 || sz == 56 || sz == 108 || sz == 124); - return r; -} - -static int stbi__bmp_test(stbi__context *s) -{ - int r = stbi__bmp_test_raw(s); - stbi__rewind(s); - return r; -} - - -// returns 0..31 for the highest set bit -static int stbi__high_bit(unsigned int z) -{ - int n=0; - if (z == 0) return -1; - if (z >= 0x10000) { n += 16; z >>= 16; } - if (z >= 0x00100) { n += 8; z >>= 8; } - if (z >= 0x00010) { n += 4; z >>= 4; } - if (z >= 0x00004) { n += 2; z >>= 2; } - if (z >= 0x00002) { n += 1;/* >>= 1;*/ } - return n; -} - -static int stbi__bitcount(unsigned int a) -{ - a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 - a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 - a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits - a = (a + (a >> 8)); // max 16 per 8 bits - a = (a + (a >> 16)); // max 32 per 8 bits - return a & 0xff; -} - -// extract an arbitrarily-aligned N-bit value (N=bits) -// from v, and then make it 8-bits long and fractionally -// extend it to full full range. -static int stbi__shiftsigned(unsigned int v, int shift, int bits) -{ - static unsigned int mul_table[9] = { - 0, - 0xff/*0b11111111*/, 0x55/*0b01010101*/, 0x49/*0b01001001*/, 0x11/*0b00010001*/, - 0x21/*0b00100001*/, 0x41/*0b01000001*/, 0x81/*0b10000001*/, 0x01/*0b00000001*/, - }; - static unsigned int shift_table[9] = { - 0, 0,0,1,0,2,4,6,0, - }; - if (shift < 0) - v <<= -shift; - else - v >>= shift; - STBI_ASSERT(v < 256); - v >>= (8-bits); - STBI_ASSERT(bits >= 0 && bits <= 8); - return (int) ((unsigned) v * mul_table[bits]) >> shift_table[bits]; -} - -typedef struct -{ - int bpp, offset, hsz; - unsigned int mr,mg,mb,ma, all_a; - int extra_read; -} stbi__bmp_data; - -static int stbi__bmp_set_mask_defaults(stbi__bmp_data *info, int compress) -{ - // BI_BITFIELDS specifies masks explicitly, don't override - if (compress == 3) - return 1; - - if (compress == 0) { - if (info->bpp == 16) { - info->mr = 31u << 10; - info->mg = 31u << 5; - info->mb = 31u << 0; - } else if (info->bpp == 32) { - info->mr = 0xffu << 16; - info->mg = 0xffu << 8; - info->mb = 0xffu << 0; - info->ma = 0xffu << 24; - info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0 - } else { - // otherwise, use defaults, which is all-0 - info->mr = info->mg = info->mb = info->ma = 0; - } - return 1; - } - return 0; // error -} - -static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info) -{ - int hsz; - if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') return stbi__errpuc("not BMP", "Corrupt BMP"); - stbi__get32le(s); // discard filesize - stbi__get16le(s); // discard reserved - stbi__get16le(s); // discard reserved - info->offset = stbi__get32le(s); - info->hsz = hsz = stbi__get32le(s); - info->mr = info->mg = info->mb = info->ma = 0; - info->extra_read = 14; - - if (info->offset < 0) return stbi__errpuc("bad BMP", "bad BMP"); - - if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) return stbi__errpuc("unknown BMP", "BMP type not supported: unknown"); - if (hsz == 12) { - s->img_x = stbi__get16le(s); - s->img_y = stbi__get16le(s); - } else { - s->img_x = stbi__get32le(s); - s->img_y = stbi__get32le(s); - } - if (stbi__get16le(s) != 1) return stbi__errpuc("bad BMP", "bad BMP"); - info->bpp = stbi__get16le(s); - if (hsz != 12) { - int compress = stbi__get32le(s); - if (compress == 1 || compress == 2) return stbi__errpuc("BMP RLE", "BMP type not supported: RLE"); - if (compress >= 4) return stbi__errpuc("BMP JPEG/PNG", "BMP type not supported: unsupported compression"); // this includes PNG/JPEG modes - if (compress == 3 && info->bpp != 16 && info->bpp != 32) return stbi__errpuc("bad BMP", "bad BMP"); // bitfields requires 16 or 32 bits/pixel - stbi__get32le(s); // discard sizeof - stbi__get32le(s); // discard hres - stbi__get32le(s); // discard vres - stbi__get32le(s); // discard colorsused - stbi__get32le(s); // discard max important - if (hsz == 40 || hsz == 56) { - if (hsz == 56) { - stbi__get32le(s); - stbi__get32le(s); - stbi__get32le(s); - stbi__get32le(s); - } - if (info->bpp == 16 || info->bpp == 32) { - if (compress == 0) { - stbi__bmp_set_mask_defaults(info, compress); - } else if (compress == 3) { - info->mr = stbi__get32le(s); - info->mg = stbi__get32le(s); - info->mb = stbi__get32le(s); - info->extra_read += 12; - // not documented, but generated by photoshop and handled by mspaint - if (info->mr == info->mg && info->mg == info->mb) { - // ?!?!? - return stbi__errpuc("bad BMP", "bad BMP"); - } - } else - return stbi__errpuc("bad BMP", "bad BMP"); - } - } else { - // V4/V5 header - int i; - if (hsz != 108 && hsz != 124) - return stbi__errpuc("bad BMP", "bad BMP"); - info->mr = stbi__get32le(s); - info->mg = stbi__get32le(s); - info->mb = stbi__get32le(s); - info->ma = stbi__get32le(s); - if (compress != 3) // override mr/mg/mb unless in BI_BITFIELDS mode, as per docs - stbi__bmp_set_mask_defaults(info, compress); - stbi__get32le(s); // discard color space - for (i=0; i < 12; ++i) - stbi__get32le(s); // discard color space parameters - if (hsz == 124) { - stbi__get32le(s); // discard rendering intent - stbi__get32le(s); // discard offset of profile data - stbi__get32le(s); // discard size of profile data - stbi__get32le(s); // discard reserved - } - } - } - return (void *) 1; -} - - -static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - stbi_uc *out; - unsigned int mr=0,mg=0,mb=0,ma=0, all_a; - stbi_uc pal[256][4]; - int psize=0,i,j,width; - int flip_vertically, pad, target; - stbi__bmp_data info; - STBI_NOTUSED(ri); - - info.all_a = 255; - if (stbi__bmp_parse_header(s, &info) == NULL) - return NULL; // error code already set - - flip_vertically = ((int) s->img_y) > 0; - s->img_y = abs((int) s->img_y); - - if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); - if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); - - mr = info.mr; - mg = info.mg; - mb = info.mb; - ma = info.ma; - all_a = info.all_a; - - if (info.hsz == 12) { - if (info.bpp < 24) - psize = (info.offset - info.extra_read - 24) / 3; - } else { - if (info.bpp < 16) - psize = (info.offset - info.extra_read - info.hsz) >> 2; - } - if (psize == 0) { - // accept some number of extra bytes after the header, but if the offset points either to before - // the header ends or implies a large amount of extra data, reject the file as malformed - int bytes_read_so_far = s->callback_already_read + (int)(s->img_buffer - s->img_buffer_original); - int header_limit = 1024; // max we actually read is below 256 bytes currently. - int extra_data_limit = 256*4; // what ordinarily goes here is a palette; 256 entries*4 bytes is its max size. - if (bytes_read_so_far <= 0 || bytes_read_so_far > header_limit) { - return stbi__errpuc("bad header", "Corrupt BMP"); - } - // we established that bytes_read_so_far is positive and sensible. - // the first half of this test rejects offsets that are either too small positives, or - // negative, and guarantees that info.offset >= bytes_read_so_far > 0. this in turn - // ensures the number computed in the second half of the test can't overflow. - if (info.offset < bytes_read_so_far || info.offset - bytes_read_so_far > extra_data_limit) { - return stbi__errpuc("bad offset", "Corrupt BMP"); - } else { - stbi__skip(s, info.offset - bytes_read_so_far); - } - } - - if (info.bpp == 24 && ma == 0xff000000) - s->img_n = 3; - else - s->img_n = ma ? 4 : 3; - if (req_comp && req_comp >= 3) // we can directly decode 3 or 4 - target = req_comp; - else - target = s->img_n; // if they want monochrome, we'll post-convert - - // sanity-check size - if (!stbi__mad3sizes_valid(target, s->img_x, s->img_y, 0)) - return stbi__errpuc("too large", "Corrupt BMP"); - - out = (stbi_uc *) stbi__malloc_mad3(target, s->img_x, s->img_y, 0); - if (!out) return stbi__errpuc("outofmem", "Out of memory"); - if (info.bpp < 16) { - int z=0; - if (psize == 0 || psize > 256) { STBI_FREE(out); return stbi__errpuc("invalid", "Corrupt BMP"); } - for (i=0; i < psize; ++i) { - pal[i][2] = stbi__get8(s); - pal[i][1] = stbi__get8(s); - pal[i][0] = stbi__get8(s); - if (info.hsz != 12) stbi__get8(s); - pal[i][3] = 255; - } - stbi__skip(s, info.offset - info.extra_read - info.hsz - psize * (info.hsz == 12 ? 3 : 4)); - if (info.bpp == 1) width = (s->img_x + 7) >> 3; - else if (info.bpp == 4) width = (s->img_x + 1) >> 1; - else if (info.bpp == 8) width = s->img_x; - else { STBI_FREE(out); return stbi__errpuc("bad bpp", "Corrupt BMP"); } - pad = (-width)&3; - if (info.bpp == 1) { - for (j=0; j < (int) s->img_y; ++j) { - int bit_offset = 7, v = stbi__get8(s); - for (i=0; i < (int) s->img_x; ++i) { - int color = (v>>bit_offset)&0x1; - out[z++] = pal[color][0]; - out[z++] = pal[color][1]; - out[z++] = pal[color][2]; - if (target == 4) out[z++] = 255; - if (i+1 == (int) s->img_x) break; - if((--bit_offset) < 0) { - bit_offset = 7; - v = stbi__get8(s); - } - } - stbi__skip(s, pad); - } - } else { - for (j=0; j < (int) s->img_y; ++j) { - for (i=0; i < (int) s->img_x; i += 2) { - int v=stbi__get8(s),v2=0; - if (info.bpp == 4) { - v2 = v & 15; - v >>= 4; - } - out[z++] = pal[v][0]; - out[z++] = pal[v][1]; - out[z++] = pal[v][2]; - if (target == 4) out[z++] = 255; - if (i+1 == (int) s->img_x) break; - v = (info.bpp == 8) ? stbi__get8(s) : v2; - out[z++] = pal[v][0]; - out[z++] = pal[v][1]; - out[z++] = pal[v][2]; - if (target == 4) out[z++] = 255; - } - stbi__skip(s, pad); - } - } - } else { - int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0; - int z = 0; - int easy=0; - stbi__skip(s, info.offset - info.extra_read - info.hsz); - if (info.bpp == 24) width = 3 * s->img_x; - else if (info.bpp == 16) width = 2*s->img_x; - else /* bpp = 32 and pad = 0 */ width=0; - pad = (-width) & 3; - if (info.bpp == 24) { - easy = 1; - } else if (info.bpp == 32) { - if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000) - easy = 2; - } - if (!easy) { - if (!mr || !mg || !mb) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); } - // right shift amt to put high bit in position #7 - rshift = stbi__high_bit(mr)-7; rcount = stbi__bitcount(mr); - gshift = stbi__high_bit(mg)-7; gcount = stbi__bitcount(mg); - bshift = stbi__high_bit(mb)-7; bcount = stbi__bitcount(mb); - ashift = stbi__high_bit(ma)-7; acount = stbi__bitcount(ma); - if (rcount > 8 || gcount > 8 || bcount > 8 || acount > 8) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); } - } - for (j=0; j < (int) s->img_y; ++j) { - if (easy) { - for (i=0; i < (int) s->img_x; ++i) { - unsigned char a; - out[z+2] = stbi__get8(s); - out[z+1] = stbi__get8(s); - out[z+0] = stbi__get8(s); - z += 3; - a = (easy == 2 ? stbi__get8(s) : 255); - all_a |= a; - if (target == 4) out[z++] = a; - } - } else { - int bpp = info.bpp; - for (i=0; i < (int) s->img_x; ++i) { - stbi__uint32 v = (bpp == 16 ? (stbi__uint32) stbi__get16le(s) : stbi__get32le(s)); - unsigned int a; - out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount)); - out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount)); - out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount)); - a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255); - all_a |= a; - if (target == 4) out[z++] = STBI__BYTECAST(a); - } - } - stbi__skip(s, pad); - } - } - - // if alpha channel is all 0s, replace with all 255s - if (target == 4 && all_a == 0) - for (i=4*s->img_x*s->img_y-1; i >= 0; i -= 4) - out[i] = 255; - - if (flip_vertically) { - stbi_uc t; - for (j=0; j < (int) s->img_y>>1; ++j) { - stbi_uc *p1 = out + j *s->img_x*target; - stbi_uc *p2 = out + (s->img_y-1-j)*s->img_x*target; - for (i=0; i < (int) s->img_x*target; ++i) { - t = p1[i]; p1[i] = p2[i]; p2[i] = t; - } - } - } - - if (req_comp && req_comp != target) { - out = stbi__convert_format(out, target, req_comp, s->img_x, s->img_y); - if (out == NULL) return out; // stbi__convert_format frees input on failure - } - - *x = s->img_x; - *y = s->img_y; - if (comp) *comp = s->img_n; - return out; -} -#endif - -// Targa Truevision - TGA -// by Jonathan Dummer -#ifndef STBI_NO_TGA -// returns STBI_rgb or whatever, 0 on error -static int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int* is_rgb16) -{ - // only RGB or RGBA (incl. 16bit) or grey allowed - if (is_rgb16) *is_rgb16 = 0; - switch(bits_per_pixel) { - case 8: return STBI_grey; - case 16: if(is_grey) return STBI_grey_alpha; - // fallthrough - case 15: if(is_rgb16) *is_rgb16 = 1; - return STBI_rgb; - case 24: // fallthrough - case 32: return bits_per_pixel/8; - default: return 0; - } -} - -static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp) -{ - int tga_w, tga_h, tga_comp, tga_image_type, tga_bits_per_pixel, tga_colormap_bpp; - int sz, tga_colormap_type; - stbi__get8(s); // discard Offset - tga_colormap_type = stbi__get8(s); // colormap type - if( tga_colormap_type > 1 ) { - stbi__rewind(s); - return 0; // only RGB or indexed allowed - } - tga_image_type = stbi__get8(s); // image type - if ( tga_colormap_type == 1 ) { // colormapped (paletted) image - if (tga_image_type != 1 && tga_image_type != 9) { - stbi__rewind(s); - return 0; - } - stbi__skip(s,4); // skip index of first colormap entry and number of entries - sz = stbi__get8(s); // check bits per palette color entry - if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) { - stbi__rewind(s); - return 0; - } - stbi__skip(s,4); // skip image x and y origin - tga_colormap_bpp = sz; - } else { // "normal" image w/o colormap - only RGB or grey allowed, +/- RLE - if ( (tga_image_type != 2) && (tga_image_type != 3) && (tga_image_type != 10) && (tga_image_type != 11) ) { - stbi__rewind(s); - return 0; // only RGB or grey allowed, +/- RLE - } - stbi__skip(s,9); // skip colormap specification and image x/y origin - tga_colormap_bpp = 0; - } - tga_w = stbi__get16le(s); - if( tga_w < 1 ) { - stbi__rewind(s); - return 0; // test width - } - tga_h = stbi__get16le(s); - if( tga_h < 1 ) { - stbi__rewind(s); - return 0; // test height - } - tga_bits_per_pixel = stbi__get8(s); // bits per pixel - stbi__get8(s); // ignore alpha bits - if (tga_colormap_bpp != 0) { - if((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16)) { - // when using a colormap, tga_bits_per_pixel is the size of the indexes - // I don't think anything but 8 or 16bit indexes makes sense - stbi__rewind(s); - return 0; - } - tga_comp = stbi__tga_get_comp(tga_colormap_bpp, 0, NULL); - } else { - tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3) || (tga_image_type == 11), NULL); - } - if(!tga_comp) { - stbi__rewind(s); - return 0; - } - if (x) *x = tga_w; - if (y) *y = tga_h; - if (comp) *comp = tga_comp; - return 1; // seems to have passed everything -} - -static int stbi__tga_test(stbi__context *s) -{ - int res = 0; - int sz, tga_color_type; - stbi__get8(s); // discard Offset - tga_color_type = stbi__get8(s); // color type - if ( tga_color_type > 1 ) goto errorEnd; // only RGB or indexed allowed - sz = stbi__get8(s); // image type - if ( tga_color_type == 1 ) { // colormapped (paletted) image - if (sz != 1 && sz != 9) goto errorEnd; // colortype 1 demands image type 1 or 9 - stbi__skip(s,4); // skip index of first colormap entry and number of entries - sz = stbi__get8(s); // check bits per palette color entry - if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; - stbi__skip(s,4); // skip image x and y origin - } else { // "normal" image w/o colormap - if ( (sz != 2) && (sz != 3) && (sz != 10) && (sz != 11) ) goto errorEnd; // only RGB or grey allowed, +/- RLE - stbi__skip(s,9); // skip colormap specification and image x/y origin - } - if ( stbi__get16le(s) < 1 ) goto errorEnd; // test width - if ( stbi__get16le(s) < 1 ) goto errorEnd; // test height - sz = stbi__get8(s); // bits per pixel - if ( (tga_color_type == 1) && (sz != 8) && (sz != 16) ) goto errorEnd; // for colormapped images, bpp is size of an index - if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; - - res = 1; // if we got this far, everything's good and we can return 1 instead of 0 - -errorEnd: - stbi__rewind(s); - return res; -} - -// read 16bit value and convert to 24bit RGB -static void stbi__tga_read_rgb16(stbi__context *s, stbi_uc* out) -{ - stbi__uint16 px = (stbi__uint16)stbi__get16le(s); - stbi__uint16 fiveBitMask = 31; - // we have 3 channels with 5bits each - int r = (px >> 10) & fiveBitMask; - int g = (px >> 5) & fiveBitMask; - int b = px & fiveBitMask; - // Note that this saves the data in RGB(A) order, so it doesn't need to be swapped later - out[0] = (stbi_uc)((r * 255)/31); - out[1] = (stbi_uc)((g * 255)/31); - out[2] = (stbi_uc)((b * 255)/31); - - // some people claim that the most significant bit might be used for alpha - // (possibly if an alpha-bit is set in the "image descriptor byte") - // but that only made 16bit test images completely translucent.. - // so let's treat all 15 and 16bit TGAs as RGB with no alpha. -} - -static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - // read in the TGA header stuff - int tga_offset = stbi__get8(s); - int tga_indexed = stbi__get8(s); - int tga_image_type = stbi__get8(s); - int tga_is_RLE = 0; - int tga_palette_start = stbi__get16le(s); - int tga_palette_len = stbi__get16le(s); - int tga_palette_bits = stbi__get8(s); - int tga_x_origin = stbi__get16le(s); - int tga_y_origin = stbi__get16le(s); - int tga_width = stbi__get16le(s); - int tga_height = stbi__get16le(s); - int tga_bits_per_pixel = stbi__get8(s); - int tga_comp, tga_rgb16=0; - int tga_inverted = stbi__get8(s); - // int tga_alpha_bits = tga_inverted & 15; // the 4 lowest bits - unused (useless?) - // image data - unsigned char *tga_data; - unsigned char *tga_palette = NULL; - int i, j; - unsigned char raw_data[4] = {0}; - int RLE_count = 0; - int RLE_repeating = 0; - int read_next_pixel = 1; - STBI_NOTUSED(ri); - STBI_NOTUSED(tga_x_origin); // @TODO - STBI_NOTUSED(tga_y_origin); // @TODO - - if (tga_height > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); - if (tga_width > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); - - // do a tiny bit of precessing - if ( tga_image_type >= 8 ) - { - tga_image_type -= 8; - tga_is_RLE = 1; - } - tga_inverted = 1 - ((tga_inverted >> 5) & 1); - - // If I'm paletted, then I'll use the number of bits from the palette - if ( tga_indexed ) tga_comp = stbi__tga_get_comp(tga_palette_bits, 0, &tga_rgb16); - else tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3), &tga_rgb16); - - if(!tga_comp) // shouldn't really happen, stbi__tga_test() should have ensured basic consistency - return stbi__errpuc("bad format", "Can't find out TGA pixelformat"); - - // tga info - *x = tga_width; - *y = tga_height; - if (comp) *comp = tga_comp; - - if (!stbi__mad3sizes_valid(tga_width, tga_height, tga_comp, 0)) - return stbi__errpuc("too large", "Corrupt TGA"); - - tga_data = (unsigned char*)stbi__malloc_mad3(tga_width, tga_height, tga_comp, 0); - if (!tga_data) return stbi__errpuc("outofmem", "Out of memory"); - - // skip to the data's starting position (offset usually = 0) - stbi__skip(s, tga_offset ); - - if ( !tga_indexed && !tga_is_RLE && !tga_rgb16 ) { - for (i=0; i < tga_height; ++i) { - int row = tga_inverted ? tga_height -i - 1 : i; - stbi_uc *tga_row = tga_data + row*tga_width*tga_comp; - stbi__getn(s, tga_row, tga_width * tga_comp); - } - } else { - // do I need to load a palette? - if ( tga_indexed) - { - if (tga_palette_len == 0) { /* you have to have at least one entry! */ - STBI_FREE(tga_data); - return stbi__errpuc("bad palette", "Corrupt TGA"); - } - - // any data to skip? (offset usually = 0) - stbi__skip(s, tga_palette_start ); - // load the palette - tga_palette = (unsigned char*)stbi__malloc_mad2(tga_palette_len, tga_comp, 0); - if (!tga_palette) { - STBI_FREE(tga_data); - return stbi__errpuc("outofmem", "Out of memory"); - } - if (tga_rgb16) { - stbi_uc *pal_entry = tga_palette; - STBI_ASSERT(tga_comp == STBI_rgb); - for (i=0; i < tga_palette_len; ++i) { - stbi__tga_read_rgb16(s, pal_entry); - pal_entry += tga_comp; - } - } else if (!stbi__getn(s, tga_palette, tga_palette_len * tga_comp)) { - STBI_FREE(tga_data); - STBI_FREE(tga_palette); - return stbi__errpuc("bad palette", "Corrupt TGA"); - } - } - // load the data - for (i=0; i < tga_width * tga_height; ++i) - { - // if I'm in RLE mode, do I need to get a RLE stbi__pngchunk? - if ( tga_is_RLE ) - { - if ( RLE_count == 0 ) - { - // yep, get the next byte as a RLE command - int RLE_cmd = stbi__get8(s); - RLE_count = 1 + (RLE_cmd & 127); - RLE_repeating = RLE_cmd >> 7; - read_next_pixel = 1; - } else if ( !RLE_repeating ) - { - read_next_pixel = 1; - } - } else - { - read_next_pixel = 1; - } - // OK, if I need to read a pixel, do it now - if ( read_next_pixel ) - { - // load however much data we did have - if ( tga_indexed ) - { - // read in index, then perform the lookup - int pal_idx = (tga_bits_per_pixel == 8) ? stbi__get8(s) : stbi__get16le(s); - if ( pal_idx >= tga_palette_len ) { - // invalid index - pal_idx = 0; - } - pal_idx *= tga_comp; - for (j = 0; j < tga_comp; ++j) { - raw_data[j] = tga_palette[pal_idx+j]; - } - } else if(tga_rgb16) { - STBI_ASSERT(tga_comp == STBI_rgb); - stbi__tga_read_rgb16(s, raw_data); - } else { - // read in the data raw - for (j = 0; j < tga_comp; ++j) { - raw_data[j] = stbi__get8(s); - } - } - // clear the reading flag for the next pixel - read_next_pixel = 0; - } // end of reading a pixel - - // copy data - for (j = 0; j < tga_comp; ++j) - tga_data[i*tga_comp+j] = raw_data[j]; - - // in case we're in RLE mode, keep counting down - --RLE_count; - } - // do I need to invert the image? - if ( tga_inverted ) - { - for (j = 0; j*2 < tga_height; ++j) - { - int index1 = j * tga_width * tga_comp; - int index2 = (tga_height - 1 - j) * tga_width * tga_comp; - for (i = tga_width * tga_comp; i > 0; --i) - { - unsigned char temp = tga_data[index1]; - tga_data[index1] = tga_data[index2]; - tga_data[index2] = temp; - ++index1; - ++index2; - } - } - } - // clear my palette, if I had one - if ( tga_palette != NULL ) - { - STBI_FREE( tga_palette ); - } - } - - // swap RGB - if the source data was RGB16, it already is in the right order - if (tga_comp >= 3 && !tga_rgb16) - { - unsigned char* tga_pixel = tga_data; - for (i=0; i < tga_width * tga_height; ++i) - { - unsigned char temp = tga_pixel[0]; - tga_pixel[0] = tga_pixel[2]; - tga_pixel[2] = temp; - tga_pixel += tga_comp; - } - } - - // convert to target component count - if (req_comp && req_comp != tga_comp) - tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height); - - // the things I do to get rid of an error message, and yet keep - // Microsoft's C compilers happy... [8^( - tga_palette_start = tga_palette_len = tga_palette_bits = - tga_x_origin = tga_y_origin = 0; - STBI_NOTUSED(tga_palette_start); - // OK, done - return tga_data; -} -#endif - -// ************************************************************************************************* -// Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB - -#ifndef STBI_NO_PSD -static int stbi__psd_test(stbi__context *s) -{ - int r = (stbi__get32be(s) == 0x38425053); - stbi__rewind(s); - return r; -} - -static int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, int pixelCount) -{ - int count, nleft, len; - - count = 0; - while ((nleft = pixelCount - count) > 0) { - len = stbi__get8(s); - if (len == 128) { - // No-op. - } else if (len < 128) { - // Copy next len+1 bytes literally. - len++; - if (len > nleft) return 0; // corrupt data - count += len; - while (len) { - *p = stbi__get8(s); - p += 4; - len--; - } - } else if (len > 128) { - stbi_uc val; - // Next -len+1 bytes in the dest are replicated from next source byte. - // (Interpret len as a negative 8-bit int.) - len = 257 - len; - if (len > nleft) return 0; // corrupt data - val = stbi__get8(s); - count += len; - while (len) { - *p = val; - p += 4; - len--; - } - } - } - - return 1; -} - -static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) -{ - int pixelCount; - int channelCount, compression; - int channel, i; - int bitdepth; - int w,h; - stbi_uc *out; - STBI_NOTUSED(ri); - - // Check identifier - if (stbi__get32be(s) != 0x38425053) // "8BPS" - return stbi__errpuc("not PSD", "Corrupt PSD image"); - - // Check file type version. - if (stbi__get16be(s) != 1) - return stbi__errpuc("wrong version", "Unsupported version of PSD image"); - - // Skip 6 reserved bytes. - stbi__skip(s, 6 ); - - // Read the number of channels (R, G, B, A, etc). - channelCount = stbi__get16be(s); - if (channelCount < 0 || channelCount > 16) - return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image"); - - // Read the rows and columns of the image. - h = stbi__get32be(s); - w = stbi__get32be(s); - - if (h > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); - if (w > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); - - // Make sure the depth is 8 bits. - bitdepth = stbi__get16be(s); - if (bitdepth != 8 && bitdepth != 16) - return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit"); - - // Make sure the color mode is RGB. - // Valid options are: - // 0: Bitmap - // 1: Grayscale - // 2: Indexed color - // 3: RGB color - // 4: CMYK color - // 7: Multichannel - // 8: Duotone - // 9: Lab color - if (stbi__get16be(s) != 3) - return stbi__errpuc("wrong color format", "PSD is not in RGB color format"); - - // Skip the Mode Data. (It's the palette for indexed color; other info for other modes.) - stbi__skip(s,stbi__get32be(s) ); - - // Skip the image resources. (resolution, pen tool paths, etc) - stbi__skip(s, stbi__get32be(s) ); - - // Skip the reserved data. - stbi__skip(s, stbi__get32be(s) ); - - // Find out if the data is compressed. - // Known values: - // 0: no compression - // 1: RLE compressed - compression = stbi__get16be(s); - if (compression > 1) - return stbi__errpuc("bad compression", "PSD has an unknown compression format"); - - // Check size - if (!stbi__mad3sizes_valid(4, w, h, 0)) - return stbi__errpuc("too large", "Corrupt PSD"); - - // Create the destination image. - - if (!compression && bitdepth == 16 && bpc == 16) { - out = (stbi_uc *) stbi__malloc_mad3(8, w, h, 0); - ri->bits_per_channel = 16; - } else - out = (stbi_uc *) stbi__malloc(4 * w*h); - - if (!out) return stbi__errpuc("outofmem", "Out of memory"); - pixelCount = w*h; - - // Initialize the data to zero. - //memset( out, 0, pixelCount * 4 ); - - // Finally, the image data. - if (compression) { - // RLE as used by .PSD and .TIFF - // Loop until you get the number of unpacked bytes you are expecting: - // Read the next source byte into n. - // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. - // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times. - // Else if n is 128, noop. - // Endloop - - // The RLE-compressed data is preceded by a 2-byte data count for each row in the data, - // which we're going to just skip. - stbi__skip(s, h * channelCount * 2 ); - - // Read the RLE data by channel. - for (channel = 0; channel < 4; channel++) { - stbi_uc *p; - - p = out+channel; - if (channel >= channelCount) { - // Fill this channel with default data. - for (i = 0; i < pixelCount; i++, p += 4) - *p = (channel == 3 ? 255 : 0); - } else { - // Read the RLE data. - if (!stbi__psd_decode_rle(s, p, pixelCount)) { - STBI_FREE(out); - return stbi__errpuc("corrupt", "bad RLE data"); - } - } - } - - } else { - // We're at the raw image data. It's each channel in order (Red, Green, Blue, Alpha, ...) - // where each channel consists of an 8-bit (or 16-bit) value for each pixel in the image. - - // Read the data by channel. - for (channel = 0; channel < 4; channel++) { - if (channel >= channelCount) { - // Fill this channel with default data. - if (bitdepth == 16 && bpc == 16) { - stbi__uint16 *q = ((stbi__uint16 *) out) + channel; - stbi__uint16 val = channel == 3 ? 65535 : 0; - for (i = 0; i < pixelCount; i++, q += 4) - *q = val; - } else { - stbi_uc *p = out+channel; - stbi_uc val = channel == 3 ? 255 : 0; - for (i = 0; i < pixelCount; i++, p += 4) - *p = val; - } - } else { - if (ri->bits_per_channel == 16) { // output bpc - stbi__uint16 *q = ((stbi__uint16 *) out) + channel; - for (i = 0; i < pixelCount; i++, q += 4) - *q = (stbi__uint16) stbi__get16be(s); - } else { - stbi_uc *p = out+channel; - if (bitdepth == 16) { // input bpc - for (i = 0; i < pixelCount; i++, p += 4) - *p = (stbi_uc) (stbi__get16be(s) >> 8); - } else { - for (i = 0; i < pixelCount; i++, p += 4) - *p = stbi__get8(s); - } - } - } - } - } - - // remove weird white matte from PSD - if (channelCount >= 4) { - if (ri->bits_per_channel == 16) { - for (i=0; i < w*h; ++i) { - stbi__uint16 *pixel = (stbi__uint16 *) out + 4*i; - if (pixel[3] != 0 && pixel[3] != 65535) { - float a = pixel[3] / 65535.0f; - float ra = 1.0f / a; - float inv_a = 65535.0f * (1 - ra); - pixel[0] = (stbi__uint16) (pixel[0]*ra + inv_a); - pixel[1] = (stbi__uint16) (pixel[1]*ra + inv_a); - pixel[2] = (stbi__uint16) (pixel[2]*ra + inv_a); - } - } - } else { - for (i=0; i < w*h; ++i) { - unsigned char *pixel = out + 4*i; - if (pixel[3] != 0 && pixel[3] != 255) { - float a = pixel[3] / 255.0f; - float ra = 1.0f / a; - float inv_a = 255.0f * (1 - ra); - pixel[0] = (unsigned char) (pixel[0]*ra + inv_a); - pixel[1] = (unsigned char) (pixel[1]*ra + inv_a); - pixel[2] = (unsigned char) (pixel[2]*ra + inv_a); - } - } - } - } - - // convert to desired output format - if (req_comp && req_comp != 4) { - if (ri->bits_per_channel == 16) - out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, 4, req_comp, w, h); - else - out = stbi__convert_format(out, 4, req_comp, w, h); - if (out == NULL) return out; // stbi__convert_format frees input on failure - } - - if (comp) *comp = 4; - *y = h; - *x = w; - - return out; -} -#endif - -// ************************************************************************************************* -// Softimage PIC loader -// by Tom Seddon -// -// See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format -// See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/ - -#ifndef STBI_NO_PIC -static int stbi__pic_is4(stbi__context *s,const char *str) -{ - int i; - for (i=0; i<4; ++i) - if (stbi__get8(s) != (stbi_uc)str[i]) - return 0; - - return 1; -} - -static int stbi__pic_test_core(stbi__context *s) -{ - int i; - - if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) - return 0; - - for(i=0;i<84;++i) - stbi__get8(s); - - if (!stbi__pic_is4(s,"PICT")) - return 0; - - return 1; -} - -typedef struct -{ - stbi_uc size,type,channel; -} stbi__pic_packet; - -static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest) -{ - int mask=0x80, i; - - for (i=0; i<4; ++i, mask>>=1) { - if (channel & mask) { - if (stbi__at_eof(s)) return stbi__errpuc("bad file","PIC file too short"); - dest[i]=stbi__get8(s); - } - } - - return dest; -} - -static void stbi__copyval(int channel,stbi_uc *dest,const stbi_uc *src) -{ - int mask=0x80,i; - - for (i=0;i<4; ++i, mask>>=1) - if (channel&mask) - dest[i]=src[i]; -} - -static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *comp, stbi_uc *result) -{ - int act_comp=0,num_packets=0,y,chained; - stbi__pic_packet packets[10]; - - // this will (should...) cater for even some bizarre stuff like having data - // for the same channel in multiple packets. - do { - stbi__pic_packet *packet; - - if (num_packets==sizeof(packets)/sizeof(packets[0])) - return stbi__errpuc("bad format","too many packets"); - - packet = &packets[num_packets++]; - - chained = stbi__get8(s); - packet->size = stbi__get8(s); - packet->type = stbi__get8(s); - packet->channel = stbi__get8(s); - - act_comp |= packet->channel; - - if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (reading packets)"); - if (packet->size != 8) return stbi__errpuc("bad format","packet isn't 8bpp"); - } while (chained); - - *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel? - - for(y=0; ytype) { - default: - return stbi__errpuc("bad format","packet has bad compression type"); - - case 0: {//uncompressed - int x; - - for(x=0;xchannel,dest)) - return 0; - break; - } - - case 1://Pure RLE - { - int left=width, i; - - while (left>0) { - stbi_uc count,value[4]; - - count=stbi__get8(s); - if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pure read count)"); - - if (count > left) - count = (stbi_uc) left; - - if (!stbi__readval(s,packet->channel,value)) return 0; - - for(i=0; ichannel,dest,value); - left -= count; - } - } - break; - - case 2: {//Mixed RLE - int left=width; - while (left>0) { - int count = stbi__get8(s), i; - if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (mixed read count)"); - - if (count >= 128) { // Repeated - stbi_uc value[4]; - - if (count==128) - count = stbi__get16be(s); - else - count -= 127; - if (count > left) - return stbi__errpuc("bad file","scanline overrun"); - - if (!stbi__readval(s,packet->channel,value)) - return 0; - - for(i=0;ichannel,dest,value); - } else { // Raw - ++count; - if (count>left) return stbi__errpuc("bad file","scanline overrun"); - - for(i=0;ichannel,dest)) - return 0; - } - left-=count; - } - break; - } - } - } - } - - return result; -} - -static void *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_comp, stbi__result_info *ri) -{ - stbi_uc *result; - int i, x,y, internal_comp; - STBI_NOTUSED(ri); - - if (!comp) comp = &internal_comp; - - for (i=0; i<92; ++i) - stbi__get8(s); - - x = stbi__get16be(s); - y = stbi__get16be(s); - - if (y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); - if (x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); - - if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pic header)"); - if (!stbi__mad3sizes_valid(x, y, 4, 0)) return stbi__errpuc("too large", "PIC image too large to decode"); - - stbi__get32be(s); //skip `ratio' - stbi__get16be(s); //skip `fields' - stbi__get16be(s); //skip `pad' - - // intermediate buffer is RGBA - result = (stbi_uc *) stbi__malloc_mad3(x, y, 4, 0); - if (!result) return stbi__errpuc("outofmem", "Out of memory"); - memset(result, 0xff, x*y*4); - - if (!stbi__pic_load_core(s,x,y,comp, result)) { - STBI_FREE(result); - result=0; - } - *px = x; - *py = y; - if (req_comp == 0) req_comp = *comp; - result=stbi__convert_format(result,4,req_comp,x,y); - - return result; -} - -static int stbi__pic_test(stbi__context *s) -{ - int r = stbi__pic_test_core(s); - stbi__rewind(s); - return r; -} -#endif - -// ************************************************************************************************* -// GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb - -#ifndef STBI_NO_GIF -typedef struct -{ - stbi__int16 prefix; - stbi_uc first; - stbi_uc suffix; -} stbi__gif_lzw; - -typedef struct -{ - int w,h; - stbi_uc *out; // output buffer (always 4 components) - stbi_uc *background; // The current "background" as far as a gif is concerned - stbi_uc *history; - int flags, bgindex, ratio, transparent, eflags; - stbi_uc pal[256][4]; - stbi_uc lpal[256][4]; - stbi__gif_lzw codes[8192]; - stbi_uc *color_table; - int parse, step; - int lflags; - int start_x, start_y; - int max_x, max_y; - int cur_x, cur_y; - int line_size; - int delay; -} stbi__gif; - -static int stbi__gif_test_raw(stbi__context *s) -{ - int sz; - if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return 0; - sz = stbi__get8(s); - if (sz != '9' && sz != '7') return 0; - if (stbi__get8(s) != 'a') return 0; - return 1; -} - -static int stbi__gif_test(stbi__context *s) -{ - int r = stbi__gif_test_raw(s); - stbi__rewind(s); - return r; -} - -static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], int num_entries, int transp) -{ - int i; - for (i=0; i < num_entries; ++i) { - pal[i][2] = stbi__get8(s); - pal[i][1] = stbi__get8(s); - pal[i][0] = stbi__get8(s); - pal[i][3] = transp == i ? 0 : 255; - } -} - -static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info) -{ - stbi_uc version; - if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') - return stbi__err("not GIF", "Corrupt GIF"); - - version = stbi__get8(s); - if (version != '7' && version != '9') return stbi__err("not GIF", "Corrupt GIF"); - if (stbi__get8(s) != 'a') return stbi__err("not GIF", "Corrupt GIF"); - - stbi__g_failure_reason = ""; - g->w = stbi__get16le(s); - g->h = stbi__get16le(s); - g->flags = stbi__get8(s); - g->bgindex = stbi__get8(s); - g->ratio = stbi__get8(s); - g->transparent = -1; - - if (g->w > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); - if (g->h > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); - - if (comp != 0) *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments - - if (is_info) return 1; - - if (g->flags & 0x80) - stbi__gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1); - - return 1; -} - -static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp) -{ - stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif)); - if (!g) return stbi__err("outofmem", "Out of memory"); - if (!stbi__gif_header(s, g, comp, 1)) { - STBI_FREE(g); - stbi__rewind( s ); - return 0; - } - if (x) *x = g->w; - if (y) *y = g->h; - STBI_FREE(g); - return 1; -} - -static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code) -{ - stbi_uc *p, *c; - int idx; - - // recurse to decode the prefixes, since the linked-list is backwards, - // and working backwards through an interleaved image would be nasty - if (g->codes[code].prefix >= 0) - stbi__out_gif_code(g, g->codes[code].prefix); - - if (g->cur_y >= g->max_y) return; - - idx = g->cur_x + g->cur_y; - p = &g->out[idx]; - g->history[idx / 4] = 1; - - c = &g->color_table[g->codes[code].suffix * 4]; - if (c[3] > 128) { // don't render transparent pixels; - p[0] = c[2]; - p[1] = c[1]; - p[2] = c[0]; - p[3] = c[3]; - } - g->cur_x += 4; - - if (g->cur_x >= g->max_x) { - g->cur_x = g->start_x; - g->cur_y += g->step; - - while (g->cur_y >= g->max_y && g->parse > 0) { - g->step = (1 << g->parse) * g->line_size; - g->cur_y = g->start_y + (g->step >> 1); - --g->parse; - } - } -} - -static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g) -{ - stbi_uc lzw_cs; - stbi__int32 len, init_code; - stbi__uint32 first; - stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear; - stbi__gif_lzw *p; - - lzw_cs = stbi__get8(s); - if (lzw_cs > 12) return NULL; - clear = 1 << lzw_cs; - first = 1; - codesize = lzw_cs + 1; - codemask = (1 << codesize) - 1; - bits = 0; - valid_bits = 0; - for (init_code = 0; init_code < clear; init_code++) { - g->codes[init_code].prefix = -1; - g->codes[init_code].first = (stbi_uc) init_code; - g->codes[init_code].suffix = (stbi_uc) init_code; - } - - // support no starting clear code - avail = clear+2; - oldcode = -1; - - len = 0; - for(;;) { - if (valid_bits < codesize) { - if (len == 0) { - len = stbi__get8(s); // start new block - if (len == 0) - return g->out; - } - --len; - bits |= (stbi__int32) stbi__get8(s) << valid_bits; - valid_bits += 8; - } else { - stbi__int32 code = bits & codemask; - bits >>= codesize; - valid_bits -= codesize; - // @OPTIMIZE: is there some way we can accelerate the non-clear path? - if (code == clear) { // clear code - codesize = lzw_cs + 1; - codemask = (1 << codesize) - 1; - avail = clear + 2; - oldcode = -1; - first = 0; - } else if (code == clear + 1) { // end of stream code - stbi__skip(s, len); - while ((len = stbi__get8(s)) > 0) - stbi__skip(s,len); - return g->out; - } else if (code <= avail) { - if (first) { - return stbi__errpuc("no clear code", "Corrupt GIF"); - } - - if (oldcode >= 0) { - p = &g->codes[avail++]; - if (avail > 8192) { - return stbi__errpuc("too many codes", "Corrupt GIF"); - } - - p->prefix = (stbi__int16) oldcode; - p->first = g->codes[oldcode].first; - p->suffix = (code == avail) ? p->first : g->codes[code].first; - } else if (code == avail) - return stbi__errpuc("illegal code in raster", "Corrupt GIF"); - - stbi__out_gif_code(g, (stbi__uint16) code); - - if ((avail & codemask) == 0 && avail <= 0x0FFF) { - codesize++; - codemask = (1 << codesize) - 1; - } - - oldcode = code; - } else { - return stbi__errpuc("illegal code in raster", "Corrupt GIF"); - } - } - } -} - -// this function is designed to support animated gifs, although stb_image doesn't support it -// two back is the image from two frames ago, used for a very specific disposal format -static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back) -{ - int dispose; - int first_frame; - int pi; - int pcount; - STBI_NOTUSED(req_comp); - - // on first frame, any non-written pixels get the background colour (non-transparent) - first_frame = 0; - if (g->out == 0) { - if (!stbi__gif_header(s, g, comp,0)) return 0; // stbi__g_failure_reason set by stbi__gif_header - if (!stbi__mad3sizes_valid(4, g->w, g->h, 0)) - return stbi__errpuc("too large", "GIF image is too large"); - pcount = g->w * g->h; - g->out = (stbi_uc *) stbi__malloc(4 * pcount); - g->background = (stbi_uc *) stbi__malloc(4 * pcount); - g->history = (stbi_uc *) stbi__malloc(pcount); - if (!g->out || !g->background || !g->history) - return stbi__errpuc("outofmem", "Out of memory"); - - // image is treated as "transparent" at the start - ie, nothing overwrites the current background; - // background colour is only used for pixels that are not rendered first frame, after that "background" - // color refers to the color that was there the previous frame. - memset(g->out, 0x00, 4 * pcount); - memset(g->background, 0x00, 4 * pcount); // state of the background (starts transparent) - memset(g->history, 0x00, pcount); // pixels that were affected previous frame - first_frame = 1; - } else { - // second frame - how do we dispose of the previous one? - dispose = (g->eflags & 0x1C) >> 2; - pcount = g->w * g->h; - - if ((dispose == 3) && (two_back == 0)) { - dispose = 2; // if I don't have an image to revert back to, default to the old background - } - - if (dispose == 3) { // use previous graphic - for (pi = 0; pi < pcount; ++pi) { - if (g->history[pi]) { - memcpy( &g->out[pi * 4], &two_back[pi * 4], 4 ); - } - } - } else if (dispose == 2) { - // restore what was changed last frame to background before that frame; - for (pi = 0; pi < pcount; ++pi) { - if (g->history[pi]) { - memcpy( &g->out[pi * 4], &g->background[pi * 4], 4 ); - } - } - } else { - // This is a non-disposal case eithe way, so just - // leave the pixels as is, and they will become the new background - // 1: do not dispose - // 0: not specified. - } - - // background is what out is after the undoing of the previou frame; - memcpy( g->background, g->out, 4 * g->w * g->h ); - } - - // clear my history; - memset( g->history, 0x00, g->w * g->h ); // pixels that were affected previous frame - - for (;;) { - int tag = stbi__get8(s); - switch (tag) { - case 0x2C: /* Image Descriptor */ - { - stbi__int32 x, y, w, h; - stbi_uc *o; - - x = stbi__get16le(s); - y = stbi__get16le(s); - w = stbi__get16le(s); - h = stbi__get16le(s); - if (((x + w) > (g->w)) || ((y + h) > (g->h))) - return stbi__errpuc("bad Image Descriptor", "Corrupt GIF"); - - g->line_size = g->w * 4; - g->start_x = x * 4; - g->start_y = y * g->line_size; - g->max_x = g->start_x + w * 4; - g->max_y = g->start_y + h * g->line_size; - g->cur_x = g->start_x; - g->cur_y = g->start_y; - - // if the width of the specified rectangle is 0, that means - // we may not see *any* pixels or the image is malformed; - // to make sure this is caught, move the current y down to - // max_y (which is what out_gif_code checks). - if (w == 0) - g->cur_y = g->max_y; - - g->lflags = stbi__get8(s); - - if (g->lflags & 0x40) { - g->step = 8 * g->line_size; // first interlaced spacing - g->parse = 3; - } else { - g->step = g->line_size; - g->parse = 0; - } - - if (g->lflags & 0x80) { - stbi__gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1); - g->color_table = (stbi_uc *) g->lpal; - } else if (g->flags & 0x80) { - g->color_table = (stbi_uc *) g->pal; - } else - return stbi__errpuc("missing color table", "Corrupt GIF"); - - o = stbi__process_gif_raster(s, g); - if (!o) return NULL; - - // if this was the first frame, - pcount = g->w * g->h; - if (first_frame && (g->bgindex > 0)) { - // if first frame, any pixel not drawn to gets the background color - for (pi = 0; pi < pcount; ++pi) { - if (g->history[pi] == 0) { - g->pal[g->bgindex][3] = 255; // just in case it was made transparent, undo that; It will be reset next frame if need be; - memcpy( &g->out[pi * 4], &g->pal[g->bgindex], 4 ); - } - } - } - - return o; - } - - case 0x21: // Comment Extension. - { - int len; - int ext = stbi__get8(s); - if (ext == 0xF9) { // Graphic Control Extension. - len = stbi__get8(s); - if (len == 4) { - g->eflags = stbi__get8(s); - g->delay = 10 * stbi__get16le(s); // delay - 1/100th of a second, saving as 1/1000ths. - - // unset old transparent - if (g->transparent >= 0) { - g->pal[g->transparent][3] = 255; - } - if (g->eflags & 0x01) { - g->transparent = stbi__get8(s); - if (g->transparent >= 0) { - g->pal[g->transparent][3] = 0; - } - } else { - // don't need transparent - stbi__skip(s, 1); - g->transparent = -1; - } - } else { - stbi__skip(s, len); - break; - } - } - while ((len = stbi__get8(s)) != 0) { - stbi__skip(s, len); - } - break; - } - - case 0x3B: // gif stream termination code - return (stbi_uc *) s; // using '1' causes warning on some compilers - - default: - return stbi__errpuc("unknown code", "Corrupt GIF"); - } - } -} - -static void *stbi__load_gif_main_outofmem(stbi__gif *g, stbi_uc *out, int **delays) -{ - STBI_FREE(g->out); - STBI_FREE(g->history); - STBI_FREE(g->background); - - if (out) STBI_FREE(out); - if (delays && *delays) STBI_FREE(*delays); - return stbi__errpuc("outofmem", "Out of memory"); -} - -static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp) -{ - if (stbi__gif_test(s)) { - int layers = 0; - stbi_uc *u = 0; - stbi_uc *out = 0; - stbi_uc *two_back = 0; - stbi__gif g; - int stride; - int out_size = 0; - int delays_size = 0; - - STBI_NOTUSED(out_size); - STBI_NOTUSED(delays_size); - - memset(&g, 0, sizeof(g)); - if (delays) { - *delays = 0; - } - - do { - u = stbi__gif_load_next(s, &g, comp, req_comp, two_back); - if (u == (stbi_uc *) s) u = 0; // end of animated gif marker - - if (u) { - *x = g.w; - *y = g.h; - ++layers; - stride = g.w * g.h * 4; - - if (out) { - void *tmp = (stbi_uc*) STBI_REALLOC_SIZED( out, out_size, layers * stride ); - if (!tmp) - return stbi__load_gif_main_outofmem(&g, out, delays); - else { - out = (stbi_uc*) tmp; - out_size = layers * stride; - } - - if (delays) { - int *new_delays = (int*) STBI_REALLOC_SIZED( *delays, delays_size, sizeof(int) * layers ); - if (!new_delays) - return stbi__load_gif_main_outofmem(&g, out, delays); - *delays = new_delays; - delays_size = layers * sizeof(int); - } - } else { - out = (stbi_uc*)stbi__malloc( layers * stride ); - if (!out) - return stbi__load_gif_main_outofmem(&g, out, delays); - out_size = layers * stride; - if (delays) { - *delays = (int*) stbi__malloc( layers * sizeof(int) ); - if (!*delays) - return stbi__load_gif_main_outofmem(&g, out, delays); - delays_size = layers * sizeof(int); - } - } - memcpy( out + ((layers - 1) * stride), u, stride ); - if (layers >= 2) { - two_back = out - 2 * stride; - } - - if (delays) { - (*delays)[layers - 1U] = g.delay; - } - } - } while (u != 0); - - // free temp buffer; - STBI_FREE(g.out); - STBI_FREE(g.history); - STBI_FREE(g.background); - - // do the final conversion after loading everything; - if (req_comp && req_comp != 4) - out = stbi__convert_format(out, 4, req_comp, layers * g.w, g.h); - - *z = layers; - return out; - } else { - return stbi__errpuc("not GIF", "Image was not as a gif type."); - } -} - -static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - stbi_uc *u = 0; - stbi__gif g; - memset(&g, 0, sizeof(g)); - STBI_NOTUSED(ri); - - u = stbi__gif_load_next(s, &g, comp, req_comp, 0); - if (u == (stbi_uc *) s) u = 0; // end of animated gif marker - if (u) { - *x = g.w; - *y = g.h; - - // moved conversion to after successful load so that the same - // can be done for multiple frames. - if (req_comp && req_comp != 4) - u = stbi__convert_format(u, 4, req_comp, g.w, g.h); - } else if (g.out) { - // if there was an error and we allocated an image buffer, free it! - STBI_FREE(g.out); - } - - // free buffers needed for multiple frame loading; - STBI_FREE(g.history); - STBI_FREE(g.background); - - return u; -} - -static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp) -{ - return stbi__gif_info_raw(s,x,y,comp); -} -#endif - -// ************************************************************************************************* -// Radiance RGBE HDR loader -// originally by Nicolas Schulz -#ifndef STBI_NO_HDR -static int stbi__hdr_test_core(stbi__context *s, const char *signature) -{ - int i; - for (i=0; signature[i]; ++i) - if (stbi__get8(s) != signature[i]) - return 0; - stbi__rewind(s); - return 1; -} - -static int stbi__hdr_test(stbi__context* s) -{ - int r = stbi__hdr_test_core(s, "#?RADIANCE\n"); - stbi__rewind(s); - if(!r) { - r = stbi__hdr_test_core(s, "#?RGBE\n"); - stbi__rewind(s); - } - return r; -} - -#define STBI__HDR_BUFLEN 1024 -static char *stbi__hdr_gettoken(stbi__context *z, char *buffer) -{ - int len=0; - char c = '\0'; - - c = (char) stbi__get8(z); - - while (!stbi__at_eof(z) && c != '\n') { - buffer[len++] = c; - if (len == STBI__HDR_BUFLEN-1) { - // flush to end of line - while (!stbi__at_eof(z) && stbi__get8(z) != '\n') - ; - break; - } - c = (char) stbi__get8(z); - } - - buffer[len] = 0; - return buffer; -} - -static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp) -{ - if ( input[3] != 0 ) { - float f1; - // Exponent - f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8)); - if (req_comp <= 2) - output[0] = (input[0] + input[1] + input[2]) * f1 / 3; - else { - output[0] = input[0] * f1; - output[1] = input[1] * f1; - output[2] = input[2] * f1; - } - if (req_comp == 2) output[1] = 1; - if (req_comp == 4) output[3] = 1; - } else { - switch (req_comp) { - case 4: output[3] = 1; /* fallthrough */ - case 3: output[0] = output[1] = output[2] = 0; - break; - case 2: output[1] = 1; /* fallthrough */ - case 1: output[0] = 0; - break; - } - } -} - -static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - char buffer[STBI__HDR_BUFLEN]; - char *token; - int valid = 0; - int width, height; - stbi_uc *scanline; - float *hdr_data; - int len; - unsigned char count, value; - int i, j, k, c1,c2, z; - const char *headerToken; - STBI_NOTUSED(ri); - - // Check identifier - headerToken = stbi__hdr_gettoken(s,buffer); - if (strcmp(headerToken, "#?RADIANCE") != 0 && strcmp(headerToken, "#?RGBE") != 0) - return stbi__errpf("not HDR", "Corrupt HDR image"); - - // Parse header - for(;;) { - token = stbi__hdr_gettoken(s,buffer); - if (token[0] == 0) break; - if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; - } - - if (!valid) return stbi__errpf("unsupported format", "Unsupported HDR format"); - - // Parse width and height - // can't use sscanf() if we're not using stdio! - token = stbi__hdr_gettoken(s,buffer); - if (strncmp(token, "-Y ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); - token += 3; - height = (int) strtol(token, &token, 10); - while (*token == ' ') ++token; - if (strncmp(token, "+X ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); - token += 3; - width = (int) strtol(token, NULL, 10); - - if (height > STBI_MAX_DIMENSIONS) return stbi__errpf("too large","Very large image (corrupt?)"); - if (width > STBI_MAX_DIMENSIONS) return stbi__errpf("too large","Very large image (corrupt?)"); - - *x = width; - *y = height; - - if (comp) *comp = 3; - if (req_comp == 0) req_comp = 3; - - if (!stbi__mad4sizes_valid(width, height, req_comp, sizeof(float), 0)) - return stbi__errpf("too large", "HDR image is too large"); - - // Read data - hdr_data = (float *) stbi__malloc_mad4(width, height, req_comp, sizeof(float), 0); - if (!hdr_data) - return stbi__errpf("outofmem", "Out of memory"); - - // Load image data - // image data is stored as some number of sca - if ( width < 8 || width >= 32768) { - // Read flat data - for (j=0; j < height; ++j) { - for (i=0; i < width; ++i) { - stbi_uc rgbe[4]; - main_decode_loop: - stbi__getn(s, rgbe, 4); - stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp); - } - } - } else { - // Read RLE-encoded data - scanline = NULL; - - for (j = 0; j < height; ++j) { - c1 = stbi__get8(s); - c2 = stbi__get8(s); - len = stbi__get8(s); - if (c1 != 2 || c2 != 2 || (len & 0x80)) { - // not run-length encoded, so we have to actually use THIS data as a decoded - // pixel (note this can't be a valid pixel--one of RGB must be >= 128) - stbi_uc rgbe[4]; - rgbe[0] = (stbi_uc) c1; - rgbe[1] = (stbi_uc) c2; - rgbe[2] = (stbi_uc) len; - rgbe[3] = (stbi_uc) stbi__get8(s); - stbi__hdr_convert(hdr_data, rgbe, req_comp); - i = 1; - j = 0; - STBI_FREE(scanline); - goto main_decode_loop; // yes, this makes no sense - } - len <<= 8; - len |= stbi__get8(s); - if (len != width) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("invalid decoded scanline length", "corrupt HDR"); } - if (scanline == NULL) { - scanline = (stbi_uc *) stbi__malloc_mad2(width, 4, 0); - if (!scanline) { - STBI_FREE(hdr_data); - return stbi__errpf("outofmem", "Out of memory"); - } - } - - for (k = 0; k < 4; ++k) { - int nleft; - i = 0; - while ((nleft = width - i) > 0) { - count = stbi__get8(s); - if (count > 128) { - // Run - value = stbi__get8(s); - count -= 128; - if ((count == 0) || (count > nleft)) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } - for (z = 0; z < count; ++z) - scanline[i++ * 4 + k] = value; - } else { - // Dump - if ((count == 0) || (count > nleft)) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } - for (z = 0; z < count; ++z) - scanline[i++ * 4 + k] = stbi__get8(s); - } - } - } - for (i=0; i < width; ++i) - stbi__hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp); - } - if (scanline) - STBI_FREE(scanline); - } - - return hdr_data; -} - -static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp) -{ - char buffer[STBI__HDR_BUFLEN]; - char *token; - int valid = 0; - int dummy; - - if (!x) x = &dummy; - if (!y) y = &dummy; - if (!comp) comp = &dummy; - - if (stbi__hdr_test(s) == 0) { - stbi__rewind( s ); - return 0; - } - - for(;;) { - token = stbi__hdr_gettoken(s,buffer); - if (token[0] == 0) break; - if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; - } - - if (!valid) { - stbi__rewind( s ); - return 0; - } - token = stbi__hdr_gettoken(s,buffer); - if (strncmp(token, "-Y ", 3)) { - stbi__rewind( s ); - return 0; - } - token += 3; - *y = (int) strtol(token, &token, 10); - while (*token == ' ') ++token; - if (strncmp(token, "+X ", 3)) { - stbi__rewind( s ); - return 0; - } - token += 3; - *x = (int) strtol(token, NULL, 10); - *comp = 3; - return 1; -} -#endif // STBI_NO_HDR - -#ifndef STBI_NO_BMP -static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp) -{ - void *p; - stbi__bmp_data info; - - info.all_a = 255; - p = stbi__bmp_parse_header(s, &info); - if (p == NULL) { - stbi__rewind( s ); - return 0; - } - if (x) *x = s->img_x; - if (y) *y = s->img_y; - if (comp) { - if (info.bpp == 24 && info.ma == 0xff000000) - *comp = 3; - else - *comp = info.ma ? 4 : 3; - } - return 1; -} -#endif - -#ifndef STBI_NO_PSD -static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp) -{ - int channelCount, dummy, depth; - if (!x) x = &dummy; - if (!y) y = &dummy; - if (!comp) comp = &dummy; - if (stbi__get32be(s) != 0x38425053) { - stbi__rewind( s ); - return 0; - } - if (stbi__get16be(s) != 1) { - stbi__rewind( s ); - return 0; - } - stbi__skip(s, 6); - channelCount = stbi__get16be(s); - if (channelCount < 0 || channelCount > 16) { - stbi__rewind( s ); - return 0; - } - *y = stbi__get32be(s); - *x = stbi__get32be(s); - depth = stbi__get16be(s); - if (depth != 8 && depth != 16) { - stbi__rewind( s ); - return 0; - } - if (stbi__get16be(s) != 3) { - stbi__rewind( s ); - return 0; - } - *comp = 4; - return 1; -} - -static int stbi__psd_is16(stbi__context *s) -{ - int channelCount, depth; - if (stbi__get32be(s) != 0x38425053) { - stbi__rewind( s ); - return 0; - } - if (stbi__get16be(s) != 1) { - stbi__rewind( s ); - return 0; - } - stbi__skip(s, 6); - channelCount = stbi__get16be(s); - if (channelCount < 0 || channelCount > 16) { - stbi__rewind( s ); - return 0; - } - STBI_NOTUSED(stbi__get32be(s)); - STBI_NOTUSED(stbi__get32be(s)); - depth = stbi__get16be(s); - if (depth != 16) { - stbi__rewind( s ); - return 0; - } - return 1; -} -#endif - -#ifndef STBI_NO_PIC -static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp) -{ - int act_comp=0,num_packets=0,chained,dummy; - stbi__pic_packet packets[10]; - - if (!x) x = &dummy; - if (!y) y = &dummy; - if (!comp) comp = &dummy; - - if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) { - stbi__rewind(s); - return 0; - } - - stbi__skip(s, 88); - - *x = stbi__get16be(s); - *y = stbi__get16be(s); - if (stbi__at_eof(s)) { - stbi__rewind( s); - return 0; - } - if ( (*x) != 0 && (1 << 28) / (*x) < (*y)) { - stbi__rewind( s ); - return 0; - } - - stbi__skip(s, 8); - - do { - stbi__pic_packet *packet; - - if (num_packets==sizeof(packets)/sizeof(packets[0])) - return 0; - - packet = &packets[num_packets++]; - chained = stbi__get8(s); - packet->size = stbi__get8(s); - packet->type = stbi__get8(s); - packet->channel = stbi__get8(s); - act_comp |= packet->channel; - - if (stbi__at_eof(s)) { - stbi__rewind( s ); - return 0; - } - if (packet->size != 8) { - stbi__rewind( s ); - return 0; - } - } while (chained); - - *comp = (act_comp & 0x10 ? 4 : 3); - - return 1; -} -#endif - -// ************************************************************************************************* -// Portable Gray Map and Portable Pixel Map loader -// by Ken Miller -// -// PGM: http://netpbm.sourceforge.net/doc/pgm.html -// PPM: http://netpbm.sourceforge.net/doc/ppm.html -// -// Known limitations: -// Does not support comments in the header section -// Does not support ASCII image data (formats P2 and P3) - -#ifndef STBI_NO_PNM - -static int stbi__pnm_test(stbi__context *s) -{ - char p, t; - p = (char) stbi__get8(s); - t = (char) stbi__get8(s); - if (p != 'P' || (t != '5' && t != '6')) { - stbi__rewind( s ); - return 0; - } - return 1; -} - -static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - stbi_uc *out; - STBI_NOTUSED(ri); - - ri->bits_per_channel = stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n); - if (ri->bits_per_channel == 0) - return 0; - - if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); - if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); - - *x = s->img_x; - *y = s->img_y; - if (comp) *comp = s->img_n; - - if (!stbi__mad4sizes_valid(s->img_n, s->img_x, s->img_y, ri->bits_per_channel / 8, 0)) - return stbi__errpuc("too large", "PNM too large"); - - out = (stbi_uc *) stbi__malloc_mad4(s->img_n, s->img_x, s->img_y, ri->bits_per_channel / 8, 0); - if (!out) return stbi__errpuc("outofmem", "Out of memory"); - if (!stbi__getn(s, out, s->img_n * s->img_x * s->img_y * (ri->bits_per_channel / 8))) { - STBI_FREE(out); - return stbi__errpuc("bad PNM", "PNM file truncated"); - } - - if (req_comp && req_comp != s->img_n) { - if (ri->bits_per_channel == 16) { - out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, s->img_n, req_comp, s->img_x, s->img_y); - } else { - out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y); - } - if (out == NULL) return out; // stbi__convert_format frees input on failure - } - return out; -} - -static int stbi__pnm_isspace(char c) -{ - return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'; -} - -static void stbi__pnm_skip_whitespace(stbi__context *s, char *c) -{ - for (;;) { - while (!stbi__at_eof(s) && stbi__pnm_isspace(*c)) - *c = (char) stbi__get8(s); - - if (stbi__at_eof(s) || *c != '#') - break; - - while (!stbi__at_eof(s) && *c != '\n' && *c != '\r' ) - *c = (char) stbi__get8(s); - } -} - -static int stbi__pnm_isdigit(char c) -{ - return c >= '0' && c <= '9'; -} - -static int stbi__pnm_getinteger(stbi__context *s, char *c) -{ - int value = 0; - - while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) { - value = value*10 + (*c - '0'); - *c = (char) stbi__get8(s); - if((value > 214748364) || (value == 214748364 && *c > '7')) - return stbi__err("integer parse overflow", "Parsing an integer in the PPM header overflowed a 32-bit int"); - } - - return value; -} - -static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp) -{ - int maxv, dummy; - char c, p, t; - - if (!x) x = &dummy; - if (!y) y = &dummy; - if (!comp) comp = &dummy; - - stbi__rewind(s); - - // Get identifier - p = (char) stbi__get8(s); - t = (char) stbi__get8(s); - if (p != 'P' || (t != '5' && t != '6')) { - stbi__rewind(s); - return 0; - } - - *comp = (t == '6') ? 3 : 1; // '5' is 1-component .pgm; '6' is 3-component .ppm - - c = (char) stbi__get8(s); - stbi__pnm_skip_whitespace(s, &c); - - *x = stbi__pnm_getinteger(s, &c); // read width - if(*x == 0) - return stbi__err("invalid width", "PPM image header had zero or overflowing width"); - stbi__pnm_skip_whitespace(s, &c); - - *y = stbi__pnm_getinteger(s, &c); // read height - if (*y == 0) - return stbi__err("invalid width", "PPM image header had zero or overflowing width"); - stbi__pnm_skip_whitespace(s, &c); - - maxv = stbi__pnm_getinteger(s, &c); // read max value - if (maxv > 65535) - return stbi__err("max value > 65535", "PPM image supports only 8-bit and 16-bit images"); - else if (maxv > 255) - return 16; - else - return 8; -} - -static int stbi__pnm_is16(stbi__context *s) -{ - if (stbi__pnm_info(s, NULL, NULL, NULL) == 16) - return 1; - return 0; -} -#endif - -static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp) -{ - #ifndef STBI_NO_JPEG - if (stbi__jpeg_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_PNG - if (stbi__png_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_GIF - if (stbi__gif_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_BMP - if (stbi__bmp_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_PSD - if (stbi__psd_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_PIC - if (stbi__pic_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_PNM - if (stbi__pnm_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_HDR - if (stbi__hdr_info(s, x, y, comp)) return 1; - #endif - - // test tga last because it's a crappy test! - #ifndef STBI_NO_TGA - if (stbi__tga_info(s, x, y, comp)) - return 1; - #endif - return stbi__err("unknown image type", "Image not of any known type, or corrupt"); -} - -static int stbi__is_16_main(stbi__context *s) -{ - #ifndef STBI_NO_PNG - if (stbi__png_is16(s)) return 1; - #endif - - #ifndef STBI_NO_PSD - if (stbi__psd_is16(s)) return 1; - #endif - - #ifndef STBI_NO_PNM - if (stbi__pnm_is16(s)) return 1; - #endif - return 0; -} - -#ifndef STBI_NO_STDIO -STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp) -{ - FILE *f = stbi__fopen(filename, "rb"); - int result; - if (!f) return stbi__err("can't fopen", "Unable to open file"); - result = stbi_info_from_file(f, x, y, comp); - fclose(f); - return result; -} - -STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp) -{ - int r; - stbi__context s; - long pos = ftell(f); - stbi__start_file(&s, f); - r = stbi__info_main(&s,x,y,comp); - fseek(f,pos,SEEK_SET); - return r; -} - -STBIDEF int stbi_is_16_bit(char const *filename) -{ - FILE *f = stbi__fopen(filename, "rb"); - int result; - if (!f) return stbi__err("can't fopen", "Unable to open file"); - result = stbi_is_16_bit_from_file(f); - fclose(f); - return result; -} - -STBIDEF int stbi_is_16_bit_from_file(FILE *f) -{ - int r; - stbi__context s; - long pos = ftell(f); - stbi__start_file(&s, f); - r = stbi__is_16_main(&s); - fseek(f,pos,SEEK_SET); - return r; -} -#endif // !STBI_NO_STDIO - -STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) -{ - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__info_main(&s,x,y,comp); -} - -STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp) -{ - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); - return stbi__info_main(&s,x,y,comp); -} - -STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len) -{ - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__is_16_main(&s); -} - -STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user) -{ - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); - return stbi__is_16_main(&s); -} - -#endif // STB_IMAGE_IMPLEMENTATION - -/* - revision history: - 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs - 2.19 (2018-02-11) fix warning - 2.18 (2018-01-30) fix warnings - 2.17 (2018-01-29) change sbti__shiftsigned to avoid clang -O2 bug - 1-bit BMP - *_is_16_bit api - avoid warnings - 2.16 (2017-07-23) all functions have 16-bit variants; - STBI_NO_STDIO works again; - compilation fixes; - fix rounding in unpremultiply; - optimize vertical flip; - disable raw_len validation; - documentation fixes - 2.15 (2017-03-18) fix png-1,2,4 bug; now all Imagenet JPGs decode; - warning fixes; disable run-time SSE detection on gcc; - uniform handling of optional "return" values; - thread-safe initialization of zlib tables - 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs - 2.13 (2016-11-29) add 16-bit API, only supported for PNG right now - 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes - 2.11 (2016-04-02) allocate large structures on the stack - remove white matting for transparent PSD - fix reported channel count for PNG & BMP - re-enable SSE2 in non-gcc 64-bit - support RGB-formatted JPEG - read 16-bit PNGs (only as 8-bit) - 2.10 (2016-01-22) avoid warning introduced in 2.09 by STBI_REALLOC_SIZED - 2.09 (2016-01-16) allow comments in PNM files - 16-bit-per-pixel TGA (not bit-per-component) - info() for TGA could break due to .hdr handling - info() for BMP to shares code instead of sloppy parse - can use STBI_REALLOC_SIZED if allocator doesn't support realloc - code cleanup - 2.08 (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA - 2.07 (2015-09-13) fix compiler warnings - partial animated GIF support - limited 16-bpc PSD support - #ifdef unused functions - bug with < 92 byte PIC,PNM,HDR,TGA - 2.06 (2015-04-19) fix bug where PSD returns wrong '*comp' value - 2.05 (2015-04-19) fix bug in progressive JPEG handling, fix warning - 2.04 (2015-04-15) try to re-enable SIMD on MinGW 64-bit - 2.03 (2015-04-12) extra corruption checking (mmozeiko) - stbi_set_flip_vertically_on_load (nguillemot) - fix NEON support; fix mingw support - 2.02 (2015-01-19) fix incorrect assert, fix warning - 2.01 (2015-01-17) fix various warnings; suppress SIMD on gcc 32-bit without -msse2 - 2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG - 2.00 (2014-12-25) optimize JPG, including x86 SSE2 & NEON SIMD (ryg) - progressive JPEG (stb) - PGM/PPM support (Ken Miller) - STBI_MALLOC,STBI_REALLOC,STBI_FREE - GIF bugfix -- seemingly never worked - STBI_NO_*, STBI_ONLY_* - 1.48 (2014-12-14) fix incorrectly-named assert() - 1.47 (2014-12-14) 1/2/4-bit PNG support, both direct and paletted (Omar Cornut & stb) - optimize PNG (ryg) - fix bug in interlaced PNG with user-specified channel count (stb) - 1.46 (2014-08-26) - fix broken tRNS chunk (colorkey-style transparency) in non-paletted PNG - 1.45 (2014-08-16) - fix MSVC-ARM internal compiler error by wrapping malloc - 1.44 (2014-08-07) - various warning fixes from Ronny Chevalier - 1.43 (2014-07-15) - fix MSVC-only compiler problem in code changed in 1.42 - 1.42 (2014-07-09) - don't define _CRT_SECURE_NO_WARNINGS (affects user code) - fixes to stbi__cleanup_jpeg path - added STBI_ASSERT to avoid requiring assert.h - 1.41 (2014-06-25) - fix search&replace from 1.36 that messed up comments/error messages - 1.40 (2014-06-22) - fix gcc struct-initialization warning - 1.39 (2014-06-15) - fix to TGA optimization when req_comp != number of components in TGA; - fix to GIF loading because BMP wasn't rewinding (whoops, no GIFs in my test suite) - add support for BMP version 5 (more ignored fields) - 1.38 (2014-06-06) - suppress MSVC warnings on integer casts truncating values - fix accidental rename of 'skip' field of I/O - 1.37 (2014-06-04) - remove duplicate typedef - 1.36 (2014-06-03) - convert to header file single-file library - if de-iphone isn't set, load iphone images color-swapped instead of returning NULL - 1.35 (2014-05-27) - various warnings - fix broken STBI_SIMD path - fix bug where stbi_load_from_file no longer left file pointer in correct place - fix broken non-easy path for 32-bit BMP (possibly never used) - TGA optimization by Arseny Kapoulkine - 1.34 (unknown) - use STBI_NOTUSED in stbi__resample_row_generic(), fix one more leak in tga failure case - 1.33 (2011-07-14) - make stbi_is_hdr work in STBI_NO_HDR (as specified), minor compiler-friendly improvements - 1.32 (2011-07-13) - support for "info" function for all supported filetypes (SpartanJ) - 1.31 (2011-06-20) - a few more leak fixes, bug in PNG handling (SpartanJ) - 1.30 (2011-06-11) - added ability to load files via callbacks to accomidate custom input streams (Ben Wenger) - removed deprecated format-specific test/load functions - removed support for installable file formats (stbi_loader) -- would have been broken for IO callbacks anyway - error cases in bmp and tga give messages and don't leak (Raymond Barbiero, grisha) - fix inefficiency in decoding 32-bit BMP (David Woo) - 1.29 (2010-08-16) - various warning fixes from Aurelien Pocheville - 1.28 (2010-08-01) - fix bug in GIF palette transparency (SpartanJ) - 1.27 (2010-08-01) - cast-to-stbi_uc to fix warnings - 1.26 (2010-07-24) - fix bug in file buffering for PNG reported by SpartanJ - 1.25 (2010-07-17) - refix trans_data warning (Won Chun) - 1.24 (2010-07-12) - perf improvements reading from files on platforms with lock-heavy fgetc() - minor perf improvements for jpeg - deprecated type-specific functions so we'll get feedback if they're needed - attempt to fix trans_data warning (Won Chun) - 1.23 fixed bug in iPhone support - 1.22 (2010-07-10) - removed image *writing* support - stbi_info support from Jetro Lauha - GIF support from Jean-Marc Lienher - iPhone PNG-extensions from James Brown - warning-fixes from Nicolas Schulz and Janez Zemva (i.stbi__err. Janez (U+017D)emva) - 1.21 fix use of 'stbi_uc' in header (reported by jon blow) - 1.20 added support for Softimage PIC, by Tom Seddon - 1.19 bug in interlaced PNG corruption check (found by ryg) - 1.18 (2008-08-02) - fix a threading bug (local mutable static) - 1.17 support interlaced PNG - 1.16 major bugfix - stbi__convert_format converted one too many pixels - 1.15 initialize some fields for thread safety - 1.14 fix threadsafe conversion bug - header-file-only version (#define STBI_HEADER_FILE_ONLY before including) - 1.13 threadsafe - 1.12 const qualifiers in the API - 1.11 Support installable IDCT, colorspace conversion routines - 1.10 Fixes for 64-bit (don't use "unsigned long") - optimized upsampling by Fabian "ryg" Giesen - 1.09 Fix format-conversion for PSD code (bad global variables!) - 1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz - 1.07 attempt to fix C++ warning/errors again - 1.06 attempt to fix C++ warning/errors again - 1.05 fix TGA loading to return correct *comp and use good luminance calc - 1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free - 1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR - 1.02 support for (subset of) HDR files, float interface for preferred access to them - 1.01 fix bug: possible bug in handling right-side up bmps... not sure - fix bug: the stbi__bmp_load() and stbi__tga_load() functions didn't work at all - 1.00 interface to zlib that skips zlib header - 0.99 correct handling of alpha in palette - 0.98 TGA loader by lonesock; dynamically add loaders (untested) - 0.97 jpeg errors on too large a file; also catch another malloc failure - 0.96 fix detection of invalid v value - particleman@mollyrocket forum - 0.95 during header scan, seek to markers in case of padding - 0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same - 0.93 handle jpegtran output; verbose errors - 0.92 read 4,8,16,24,32-bit BMP files of several formats - 0.91 output 24-bit Windows 3.0 BMP files - 0.90 fix a few more warnings; bump version number to approach 1.0 - 0.61 bugfixes due to Marc LeBlanc, Christopher Lloyd - 0.60 fix compiling as c++ - 0.59 fix warnings: merge Dave Moore's -Wall fixes - 0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian - 0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less than 16 available - 0.56 fix bug: zlib uncompressed mode len vs. nlen - 0.55 fix bug: restart_interval not initialized to 0 - 0.54 allow NULL for 'int *comp' - 0.53 fix bug in png 3->4; speedup png decoding - 0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments - 0.51 obey req_comp requests, 1-component jpegs return as 1-component, - on 'test' only check type, not whether we support this variant - 0.50 (2006-11-19) - first released version -*/ - - -/* ------------------------------------------------------------------------------- -This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------- -ALTERNATIVE A - MIT License -Copyright (c) 2017 Sean Barrett -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. ------------------------------------------------------------------------------- -ALTERNATIVE B - Public Domain (www.unlicense.org) -This is free and unencumbered software released into the public domain. -Anyone is free to copy, modify, publish, use, compile, sell, or distribute this -software, either in source code form or as a compiled binary, for any purpose, -commercial or non-commercial, and by any means. -In jurisdictions that recognize copyright laws, the author or authors of this -software dedicate any and all copyright interest in the software to the public -domain. We make this dedication for the benefit of the public at large and to -the detriment of our heirs and successors. We intend this dedication to be an -overt act of relinquishment in perpetuity of all present and future rights to -this software under copyright law. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------- -*/ diff --git a/include/image/imagebuilder.hpp b/include/image/imagebuilder.hpp new file mode 100644 index 00000000..18c2adfa --- /dev/null +++ b/include/image/imagebuilder.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include "image/imagedata.hpp" +#include "image/imagehandle.hpp" + +namespace Toolbox::UI { + + class ImageBuilder { + public: + static ScopePtr ImageAdd(const ImageData &a, const ImageData &b, + float scale = 1.0f, float offset = 0.0f); + static ScopePtr ImageAddModulo(const ImageData &a, const ImageData &b); + static ScopePtr ImageBlend(const ImageData &a, const ImageData &b, + float alpha); + static ScopePtr ImageComposite(const ImageData &a, const ImageData &b); + static ScopePtr ImageDarker(const ImageData &a, const ImageData &b); + static ScopePtr ImageDifference(const ImageData &a, const ImageData &b); + static ScopePtr ImageDivide(const ImageData &a, const ImageData &b); + static ScopePtr ImageLighter(const ImageData &a, const ImageData &b); + static ScopePtr ImageMultiply(const ImageData &a, const ImageData &b); + static ScopePtr ImageOffset(const ImageData &image, int x, int y); + static ScopePtr ImageOverlay(const ImageData &a, const ImageData &b); + static ScopePtr ImageResize(const ImageData &image, int width, int height); + static ScopePtr ImageScreen(const ImageData &a, const ImageData &b); + static ScopePtr ImageSubtract(const ImageData &a, const ImageData &b, + float scale = 1.0f, float offset = 0.0f); + static ScopePtr ImageSubtractModulo(const ImageData &a, const ImageData &b); + static ScopePtr ImageAND(const ImageData &a, const ImageData &b); + static ScopePtr ImageOR(const ImageData &a, const ImageData &b); + static ScopePtr ImageXOR(const ImageData &a, const ImageData &b); + }; + +} // namespace Toolbox::UI \ No newline at end of file diff --git a/include/image/imagedata.hpp b/include/image/imagedata.hpp new file mode 100644 index 00000000..2e1f214d --- /dev/null +++ b/include/image/imagedata.hpp @@ -0,0 +1,56 @@ +#pragma once + +#include "core/core.hpp" +#include "color.hpp" +#include "fsystem.hpp" + +#include + +namespace Toolbox { + + class ImageData { + public: + friend class ImageBuilder; + friend class ImageHandle; + + ImageData() = default; + ImageData(const ImageData &) = default; + ImageData(ImageData &&) noexcept = default; + + ~ImageData(); + + ImageData(const fs_path &res_path); + + ImageData(std::span data); + ImageData(std::span data, int channels, int dx, int dy); + + ImageData(const Buffer &data); + + // Data should be a valid RED, RGB, or RGBA image as loaded by stbi + ImageData(Buffer &&data, int channels, int dx, int dy); + + [[nodiscard]] bool save(const fs_path &filename) const; + + [[nodiscard]] bool isValid() const noexcept { + return m_width > 0 && m_height > 0 && m_channels > 0; + } + + [[nodiscard]] int getWidth() const noexcept { return m_width; } + [[nodiscard]] int getHeight() const noexcept { return m_height; } + [[nodiscard]] int getChannels() const noexcept { return m_channels; } + + [[nodiscard]] + [[nodiscard]] const u8 *getData() const noexcept { return m_data.buf(); } + [[nodiscard]] size_t getSize() const noexcept { return m_data.size(); } + + ImageData &operator=(const ImageData &) = default; + ImageData &operator=(ImageData &&) noexcept = default; + + private: + int m_width = 0; + int m_height = 0; + int m_channels = 0; + Buffer m_data; + }; + +} // namespace Toolbox \ No newline at end of file diff --git a/include/image/imagehandle.hpp b/include/image/imagehandle.hpp index 46750d02..609e52bf 100644 --- a/include/image/imagehandle.hpp +++ b/include/image/imagehandle.hpp @@ -5,6 +5,8 @@ #include #include +#include "image/imagedata.hpp" + namespace Toolbox { namespace UI { @@ -13,6 +15,7 @@ namespace Toolbox { class ImageHandle { friend class UI::ImagePainter; + friend class ImageBuilder; public: ImageHandle() = default; @@ -26,6 +29,7 @@ namespace Toolbox { ImageHandle(std::span data, int channels, int dx, int dy); ImageHandle(const Buffer &data); + ImageHandle(const ImageData &data); // Data should be a valid RED, RGB, or RGBA image as loaded by stbi ImageHandle(const Buffer &data, int channels, int dx, int dy); diff --git a/include/resource/resource.hpp b/include/resource/resource.hpp index 9ccf0037..ee89606f 100644 --- a/include/resource/resource.hpp +++ b/include/resource/resource.hpp @@ -73,6 +73,11 @@ namespace Toolbox { const UUID64 &resource_path_uuid = 0) const; [[nodiscard]] bool hasDataPath(fs_path &&path, const UUID64 &resource_path_uuid = 0) const; + [[nodiscard]] Result, FSError> + getImageData(const fs_path &path, const UUID64 &resource_path_uuid = 0) const; + [[nodiscard]] Result, FSError> + getImageData(fs_path &&path, const UUID64 &resource_path_uuid = 0) const; + [[nodiscard]] Result, FSError> getImageHandle(const fs_path &path, const UUID64 &resource_path_uuid = 0) const; [[nodiscard]] Result, FSError> diff --git a/lib/stb/stb_image.h b/lib/stb/stb_image.h new file mode 100644 index 00000000..cb03941c --- /dev/null +++ b/lib/stb/stb_image.h @@ -0,0 +1,8509 @@ +/* stb_image - v2.30 - public domain image loader - http://nothings.org/stb + no warranty implied; use at your own risk + + Do this: + #define STB_IMAGE_IMPLEMENTATION + before you include this file in *one* C or C++ file to create the implementation. + + // i.e. it should look like this: + #include ... + #include ... + #include ... + #define STB_IMAGE_IMPLEMENTATION + #include "stb_image.h" + + You can #define STBI_ASSERT(x) before the #include to avoid using assert.h. + And #define STBI_MALLOC, STBI_REALLOC, and STBI_FREE to avoid using malloc,realloc,free + + + QUICK NOTES: + Primarily of interest to game developers and other people who can + avoid problematic images and only need the trivial interface + + JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib) + PNG 1/2/4/8/16-bit-per-channel + + TGA (not sure what subset, if a subset) + BMP non-1bpp, non-RLE + PSD (composited view only, no extra channels, 8/16 bit-per-channel) + + GIF (*comp always reports as 4-channel) + HDR (radiance rgbE format) + PIC (Softimage PIC) + PNM (PPM and PGM binary only) + + Animated GIF still needs a proper API, but here's one way to do it: + http://gist.github.com/urraka/685d9a6340b26b830d49 + + - decode from memory or through FILE (define STBI_NO_STDIO to remove code) + - decode from arbitrary I/O callbacks + - SIMD acceleration on x86/x64 (SSE2) and ARM (NEON) + + Full documentation under "DOCUMENTATION" below. + + +LICENSE + + See end of file for license information. + +RECENT REVISION HISTORY: + + 2.30 (2024-05-31) avoid erroneous gcc warning + 2.29 (2023-05-xx) optimizations + 2.28 (2023-01-29) many error fixes, security errors, just tons of stuff + 2.27 (2021-07-11) document stbi_info better, 16-bit PNM support, bug fixes + 2.26 (2020-07-13) many minor fixes + 2.25 (2020-02-02) fix warnings + 2.24 (2020-02-02) fix warnings; thread-local failure_reason and flip_vertically + 2.23 (2019-08-11) fix clang static analysis warning + 2.22 (2019-03-04) gif fixes, fix warnings + 2.21 (2019-02-25) fix typo in comment + 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs + 2.19 (2018-02-11) fix warning + 2.18 (2018-01-30) fix warnings + 2.17 (2018-01-29) bugfix, 1-bit BMP, 16-bitness query, fix warnings + 2.16 (2017-07-23) all functions have 16-bit variants; optimizations; bugfixes + 2.15 (2017-03-18) fix png-1,2,4; all Imagenet JPGs; no runtime SSE detection on GCC + 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs + 2.13 (2016-12-04) experimental 16-bit API, only for PNG so far; fixes + 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes + 2.11 (2016-04-02) 16-bit PNGS; enable SSE2 in non-gcc x64 + RGB-format JPEG; remove white matting in PSD; + allocate large structures on the stack; + correct channel count for PNG & BMP + 2.10 (2016-01-22) avoid warning introduced in 2.09 + 2.09 (2016-01-16) 16-bit TGA; comments in PNM files; STBI_REALLOC_SIZED + + See end of file for full revision history. + + + ============================ Contributors ========================= + + Image formats Extensions, features + Sean Barrett (jpeg, png, bmp) Jetro Lauha (stbi_info) + Nicolas Schulz (hdr, psd) Martin "SpartanJ" Golini (stbi_info) + Jonathan Dummer (tga) James "moose2000" Brown (iPhone PNG) + Jean-Marc Lienher (gif) Ben "Disch" Wenger (io callbacks) + Tom Seddon (pic) Omar Cornut (1/2/4-bit PNG) + Thatcher Ulrich (psd) Nicolas Guillemot (vertical flip) + Ken Miller (pgm, ppm) Richard Mitton (16-bit PSD) + github:urraka (animated gif) Junggon Kim (PNM comments) + Christopher Forseth (animated gif) Daniel Gibson (16-bit TGA) + socks-the-fox (16-bit PNG) + Jeremy Sawicki (handle all ImageNet JPGs) + Optimizations & bugfixes Mikhail Morozov (1-bit BMP) + Fabian "ryg" Giesen Anael Seghezzi (is-16-bit query) + Arseny Kapoulkine Simon Breuss (16-bit PNM) + John-Mark Allen + Carmelo J Fdez-Aguera + + Bug & warning fixes + Marc LeBlanc David Woo Guillaume George Martins Mozeiko + Christpher Lloyd Jerry Jansson Joseph Thomson Blazej Dariusz Roszkowski + Phil Jordan Dave Moore Roy Eltham + Hayaki Saito Nathan Reed Won Chun + Luke Graham Johan Duparc Nick Verigakis the Horde3D community + Thomas Ruf Ronny Chevalier github:rlyeh + Janez Zemva John Bartholomew Michal Cichon github:romigrou + Jonathan Blow Ken Hamada Tero Hanninen github:svdijk + Eugene Golushkov Laurent Gomila Cort Stratton github:snagar + Aruelien Pocheville Sergio Gonzalez Thibault Reuille github:Zelex + Cass Everitt Ryamond Barbiero github:grim210 + Paul Du Bois Engin Manap Aldo Culquicondor github:sammyhw + Philipp Wiesemann Dale Weiler Oriol Ferrer Mesia github:phprus + Josh Tobin Neil Bickford Matthew Gregan github:poppolopoppo + Julian Raschke Gregory Mullen Christian Floisand github:darealshinji + Baldur Karlsson Kevin Schmidt JR Smith github:Michaelangel007 + Brad Weinberger Matvey Cherevko github:mosra + Luca Sas Alexander Veselov Zack Middleton [reserved] + Ryan C. Gordon [reserved] [reserved] + DO NOT ADD YOUR NAME HERE + + Jacko Dirks + + To add your name to the credits, pick a random blank space in the middle and fill it. + 80% of merge conflicts on stb PRs are due to people adding their name at the end + of the credits. +*/ + +#ifndef STBI_INCLUDE_STB_IMAGE_H +#define STBI_INCLUDE_STB_IMAGE_H + +// DOCUMENTATION +// +// Limitations: +// - no 12-bit-per-channel JPEG +// - no JPEGs with arithmetic coding +// - GIF always returns *comp=4 +// +// Basic usage (see HDR discussion below for HDR usage): +// int x,y,n; +// unsigned char *data = stbi_load(filename, &x, &y, &n, 0); +// // ... process data if not NULL ... +// // ... x = width, y = height, n = # 8-bit components per pixel ... +// // ... replace '0' with '1'..'4' to force that many components per pixel +// // ... but 'n' will always be the number that it would have been if you said 0 +// stbi_image_free(data); +// +// Standard parameters: +// int *x -- outputs image width in pixels +// int *y -- outputs image height in pixels +// int *channels_in_file -- outputs # of image components in image file +// int desired_channels -- if non-zero, # of image components requested in result +// +// The return value from an image loader is an 'unsigned char *' which points +// to the pixel data, or NULL on an allocation failure or if the image is +// corrupt or invalid. The pixel data consists of *y scanlines of *x pixels, +// with each pixel consisting of N interleaved 8-bit components; the first +// pixel pointed to is top-left-most in the image. There is no padding between +// image scanlines or between pixels, regardless of format. The number of +// components N is 'desired_channels' if desired_channels is non-zero, or +// *channels_in_file otherwise. If desired_channels is non-zero, +// *channels_in_file has the number of components that _would_ have been +// output otherwise. E.g. if you set desired_channels to 4, you will always +// get RGBA output, but you can check *channels_in_file to see if it's trivially +// opaque because e.g. there were only 3 channels in the source image. +// +// An output image with N components has the following components interleaved +// in this order in each pixel: +// +// N=#comp components +// 1 grey +// 2 grey, alpha +// 3 red, green, blue +// 4 red, green, blue, alpha +// +// If image loading fails for any reason, the return value will be NULL, +// and *x, *y, *channels_in_file will be unchanged. The function +// stbi_failure_reason() can be queried for an extremely brief, end-user +// unfriendly explanation of why the load failed. Define STBI_NO_FAILURE_STRINGS +// to avoid compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly +// more user-friendly ones. +// +// Paletted PNG, BMP, GIF, and PIC images are automatically depalettized. +// +// To query the width, height and component count of an image without having to +// decode the full file, you can use the stbi_info family of functions: +// +// int x,y,n,ok; +// ok = stbi_info(filename, &x, &y, &n); +// // returns ok=1 and sets x, y, n if image is a supported format, +// // 0 otherwise. +// +// Note that stb_image pervasively uses ints in its public API for sizes, +// including sizes of memory buffers. This is now part of the API and thus +// hard to change without causing breakage. As a result, the various image +// loaders all have certain limits on image size; these differ somewhat +// by format but generally boil down to either just under 2GB or just under +// 1GB. When the decoded image would be larger than this, stb_image decoding +// will fail. +// +// Additionally, stb_image will reject image files that have any of their +// dimensions set to a larger value than the configurable STBI_MAX_DIMENSIONS, +// which defaults to 2**24 = 16777216 pixels. Due to the above memory limit, +// the only way to have an image with such dimensions load correctly +// is for it to have a rather extreme aspect ratio. Either way, the +// assumption here is that such larger images are likely to be malformed +// or malicious. If you do need to load an image with individual dimensions +// larger than that, and it still fits in the overall size limit, you can +// #define STBI_MAX_DIMENSIONS on your own to be something larger. +// +// =========================================================================== +// +// UNICODE: +// +// If compiling for Windows and you wish to use Unicode filenames, compile +// with +// #define STBI_WINDOWS_UTF8 +// and pass utf8-encoded filenames. Call stbi_convert_wchar_to_utf8 to convert +// Windows wchar_t filenames to utf8. +// +// =========================================================================== +// +// Philosophy +// +// stb libraries are designed with the following priorities: +// +// 1. easy to use +// 2. easy to maintain +// 3. good performance +// +// Sometimes I let "good performance" creep up in priority over "easy to maintain", +// and for best performance I may provide less-easy-to-use APIs that give higher +// performance, in addition to the easy-to-use ones. Nevertheless, it's important +// to keep in mind that from the standpoint of you, a client of this library, +// all you care about is #1 and #3, and stb libraries DO NOT emphasize #3 above all. +// +// Some secondary priorities arise directly from the first two, some of which +// provide more explicit reasons why performance can't be emphasized. +// +// - Portable ("ease of use") +// - Small source code footprint ("easy to maintain") +// - No dependencies ("ease of use") +// +// =========================================================================== +// +// I/O callbacks +// +// I/O callbacks allow you to read from arbitrary sources, like packaged +// files or some other source. Data read from callbacks are processed +// through a small internal buffer (currently 128 bytes) to try to reduce +// overhead. +// +// The three functions you must define are "read" (reads some bytes of data), +// "skip" (skips some bytes of data), "eof" (reports if the stream is at the end). +// +// =========================================================================== +// +// SIMD support +// +// The JPEG decoder will try to automatically use SIMD kernels on x86 when +// supported by the compiler. For ARM Neon support, you must explicitly +// request it. +// +// (The old do-it-yourself SIMD API is no longer supported in the current +// code.) +// +// On x86, SSE2 will automatically be used when available based on a run-time +// test; if not, the generic C versions are used as a fall-back. On ARM targets, +// the typical path is to have separate builds for NEON and non-NEON devices +// (at least this is true for iOS and Android). Therefore, the NEON support is +// toggled by a build flag: define STBI_NEON to get NEON loops. +// +// If for some reason you do not want to use any of SIMD code, or if +// you have issues compiling it, you can disable it entirely by +// defining STBI_NO_SIMD. +// +// =========================================================================== +// +// HDR image support (disable by defining STBI_NO_HDR) +// +// stb_image supports loading HDR images in general, and currently the Radiance +// .HDR file format specifically. You can still load any file through the existing +// interface; if you attempt to load an HDR file, it will be automatically remapped +// to LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1; +// both of these constants can be reconfigured through this interface: +// +// stbi_hdr_to_ldr_gamma(2.2f); +// stbi_hdr_to_ldr_scale(1.0f); +// +// (note, do not use _inverse_ constants; stbi_image will invert them +// appropriately). +// +// Additionally, there is a new, parallel interface for loading files as +// (linear) floats to preserve the full dynamic range: +// +// float *data = stbi_loadf(filename, &x, &y, &n, 0); +// +// If you load LDR images through this interface, those images will +// be promoted to floating point values, run through the inverse of +// constants corresponding to the above: +// +// stbi_ldr_to_hdr_scale(1.0f); +// stbi_ldr_to_hdr_gamma(2.2f); +// +// Finally, given a filename (or an open file or memory block--see header +// file for details) containing image data, you can query for the "most +// appropriate" interface to use (that is, whether the image is HDR or +// not), using: +// +// stbi_is_hdr(char *filename); +// +// =========================================================================== +// +// iPhone PNG support: +// +// We optionally support converting iPhone-formatted PNGs (which store +// premultiplied BGRA) back to RGB, even though they're internally encoded +// differently. To enable this conversion, call +// stbi_convert_iphone_png_to_rgb(1). +// +// Call stbi_set_unpremultiply_on_load(1) as well to force a divide per +// pixel to remove any premultiplied alpha *only* if the image file explicitly +// says there's premultiplied data (currently only happens in iPhone images, +// and only if iPhone convert-to-rgb processing is on). +// +// =========================================================================== +// +// ADDITIONAL CONFIGURATION +// +// - You can suppress implementation of any of the decoders to reduce +// your code footprint by #defining one or more of the following +// symbols before creating the implementation. +// +// STBI_NO_JPEG +// STBI_NO_PNG +// STBI_NO_BMP +// STBI_NO_PSD +// STBI_NO_TGA +// STBI_NO_GIF +// STBI_NO_HDR +// STBI_NO_PIC +// STBI_NO_PNM (.ppm and .pgm) +// +// - You can request *only* certain decoders and suppress all other ones +// (this will be more forward-compatible, as addition of new decoders +// doesn't require you to disable them explicitly): +// +// STBI_ONLY_JPEG +// STBI_ONLY_PNG +// STBI_ONLY_BMP +// STBI_ONLY_PSD +// STBI_ONLY_TGA +// STBI_ONLY_GIF +// STBI_ONLY_HDR +// STBI_ONLY_PIC +// STBI_ONLY_PNM (.ppm and .pgm) +// +// - If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still +// want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB +// +// - If you define STBI_MAX_DIMENSIONS, stb_image will reject images greater +// than that size (in either width or height) without further processing. +// This is to let programs in the wild set an upper bound to prevent +// denial-of-service attacks on untrusted data, as one could generate a +// valid image of gigantic dimensions and force stb_image to allocate a +// huge block of memory and spend disproportionate time decoding it. By +// default this is set to (1 << 24), which is 16777216, but that's still +// very big. + +#ifndef STBI_NO_STDIO +#include +#endif // STBI_NO_STDIO + +#define STBI_VERSION 1 + +enum { + STBI_default = 0, // only used for desired_channels + + STBI_grey = 1, + STBI_grey_alpha = 2, + STBI_rgb = 3, + STBI_rgb_alpha = 4 +}; + +#include +typedef unsigned char stbi_uc; +typedef unsigned short stbi_us; + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef STBIDEF +#ifdef STB_IMAGE_STATIC +#define STBIDEF static +#else +#define STBIDEF extern +#endif +#endif + +////////////////////////////////////////////////////////////////////////////// +// +// PRIMARY API - works on images of any type +// + +// +// load image by filename, open file, or memory buffer +// + +typedef struct { + int (*read)(void *user, char *data, + int size); // fill 'data' with 'size' bytes. return number of bytes actually read + void (*skip)(void *user, + int n); // skip the next 'n' bytes, or 'unget' the last -n bytes if negative + int (*eof)(void *user); // returns nonzero if we are at end of file/data +} stbi_io_callbacks; + +//////////////////////////////////// +// +// 8-bits-per-channel interface +// + +STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, + int *channels_in_file, int desired_channels); +STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, + int *channels_in_file, int desired_channels); + +#ifndef STBI_NO_STDIO +STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *channels_in_file, + int desired_channels); +STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *channels_in_file, + int desired_channels); +// for stbi_load_from_file, file pointer is left pointing immediately after image +#endif + +#ifndef STBI_NO_GIF +STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, + int *y, int *z, int *comp, int req_comp); +#endif + +#ifdef STBI_WINDOWS_UTF8 +STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t *input); +#endif + +//////////////////////////////////// +// +// 16-bits-per-channel interface +// + +STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, int len, int *x, int *y, + int *channels_in_file, int desired_channels); +STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, + int *y, int *channels_in_file, int desired_channels); + +#ifndef STBI_NO_STDIO +STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *channels_in_file, + int desired_channels); +STBIDEF stbi_us *stbi_load_from_file_16(FILE *f, int *x, int *y, int *channels_in_file, + int desired_channels); +#endif + +//////////////////////////////////// +// +// float-per-channel interface +// +#ifndef STBI_NO_LINEAR +STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, + int *channels_in_file, int desired_channels); +STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, + int *channels_in_file, int desired_channels); + +#ifndef STBI_NO_STDIO +STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *channels_in_file, + int desired_channels); +STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *channels_in_file, + int desired_channels); +#endif +#endif + +#ifndef STBI_NO_HDR +STBIDEF void stbi_hdr_to_ldr_gamma(float gamma); +STBIDEF void stbi_hdr_to_ldr_scale(float scale); +#endif // STBI_NO_HDR + +#ifndef STBI_NO_LINEAR +STBIDEF void stbi_ldr_to_hdr_gamma(float gamma); +STBIDEF void stbi_ldr_to_hdr_scale(float scale); +#endif // STBI_NO_LINEAR + +// stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR +STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user); +STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len); +#ifndef STBI_NO_STDIO +STBIDEF int stbi_is_hdr(char const *filename); +STBIDEF int stbi_is_hdr_from_file(FILE *f); +#endif // STBI_NO_STDIO + +// get a VERY brief reason for failure +// on most compilers (and ALL modern mainstream compilers) this is threadsafe +STBIDEF const char *stbi_failure_reason(void); + +// free the loaded image -- this is just free() +STBIDEF void stbi_image_free(void *retval_from_stbi_load); + +// get image dimensions & components without fully decoding +STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); +STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, + int *comp); +STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len); +STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *clbk, void *user); + +#ifndef STBI_NO_STDIO +STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp); +STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp); +STBIDEF int stbi_is_16_bit(char const *filename); +STBIDEF int stbi_is_16_bit_from_file(FILE *f); +#endif + +// for image formats that explicitly notate that they have premultiplied alpha, +// we just return the colors as stored in the file. set this flag to force +// unpremultiplication. results are undefined if the unpremultiply overflow. +STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply); + +// indicate whether we should process iphone images back to canonical format, +// or just pass them through "as-is" +STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert); + +// flip the image vertically, so the first pixel in the output array is the bottom left +STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip); + +// as above, but only applies to images loaded on the thread that calls the function +// this function is only available if your compiler supports thread-local variables; +// calling it will fail to link if your compiler doesn't +STBIDEF void stbi_set_unpremultiply_on_load_thread(int flag_true_if_should_unpremultiply); +STBIDEF void stbi_convert_iphone_png_to_rgb_thread(int flag_true_if_should_convert); +STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip); + +// ZLIB client - used by PNG, available for other purposes + +STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, + int *outlen); +STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, + int initial_size, int *outlen, + int parse_header); +STBIDEF char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen); +STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); + +STBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen); +STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, + int ilen); + +#ifdef __cplusplus +} +#endif + +// +// +//// end header file ///////////////////////////////////////////////////// +#endif // STBI_INCLUDE_STB_IMAGE_H + +#ifdef STB_IMAGE_IMPLEMENTATION + +#if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) || \ + defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) || \ + defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) || \ + defined(STBI_ONLY_ZLIB) +#ifndef STBI_ONLY_JPEG +#define STBI_NO_JPEG +#endif +#ifndef STBI_ONLY_PNG +#define STBI_NO_PNG +#endif +#ifndef STBI_ONLY_BMP +#define STBI_NO_BMP +#endif +#ifndef STBI_ONLY_PSD +#define STBI_NO_PSD +#endif +#ifndef STBI_ONLY_TGA +#define STBI_NO_TGA +#endif +#ifndef STBI_ONLY_GIF +#define STBI_NO_GIF +#endif +#ifndef STBI_ONLY_HDR +#define STBI_NO_HDR +#endif +#ifndef STBI_ONLY_PIC +#define STBI_NO_PIC +#endif +#ifndef STBI_ONLY_PNM +#define STBI_NO_PNM +#endif +#endif + +#if defined(STBI_NO_PNG) && !defined(STBI_SUPPORT_ZLIB) && !defined(STBI_NO_ZLIB) +#define STBI_NO_ZLIB +#endif + +#include +#include +#include // ptrdiff_t on osx +#include +#include + +#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) +#include // ldexp, pow +#endif + +#ifndef STBI_NO_STDIO +#include +#endif + +#ifndef STBI_ASSERT +#include +#define STBI_ASSERT(x) assert(x) +#endif + +#ifdef __cplusplus +#define STBI_EXTERN extern "C" +#else +#define STBI_EXTERN extern +#endif + +#ifndef _MSC_VER +#ifdef __cplusplus +#define stbi_inline inline +#else +#define stbi_inline +#endif +#else +#define stbi_inline __forceinline +#endif + +#ifndef STBI_NO_THREAD_LOCALS +#if defined(__cplusplus) && __cplusplus >= 201103L +#define STBI_THREAD_LOCAL thread_local +#elif defined(__GNUC__) && __GNUC__ < 5 +#define STBI_THREAD_LOCAL __thread +#elif defined(_MSC_VER) +#define STBI_THREAD_LOCAL __declspec(thread) +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__) +#define STBI_THREAD_LOCAL _Thread_local +#endif + +#ifndef STBI_THREAD_LOCAL +#if defined(__GNUC__) +#define STBI_THREAD_LOCAL __thread +#endif +#endif +#endif + +#if defined(_MSC_VER) || defined(__SYMBIAN32__) +typedef unsigned short stbi__uint16; +typedef signed short stbi__int16; +typedef unsigned int stbi__uint32; +typedef signed int stbi__int32; +#else +#include +typedef uint16_t stbi__uint16; +typedef int16_t stbi__int16; +typedef uint32_t stbi__uint32; +typedef int32_t stbi__int32; +#endif + +// should produce compiler error if size is wrong +typedef unsigned char validate_uint32[sizeof(stbi__uint32) == 4 ? 1 : -1]; + +#ifdef _MSC_VER +#define STBI_NOTUSED(v) (void)(v) +#else +#define STBI_NOTUSED(v) (void)sizeof(v) +#endif + +#ifdef _MSC_VER +#define STBI_HAS_LROTL +#endif + +#ifdef STBI_HAS_LROTL +#define stbi_lrot(x, y) _lrotl(x, y) +#else +#define stbi_lrot(x, y) (((x) << (y)) | ((x) >> (-(y) & 31))) +#endif + +#if defined(STBI_MALLOC) && defined(STBI_FREE) && \ + (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED)) +// ok +#elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC) && \ + !defined(STBI_REALLOC_SIZED) +// ok +#else +#error \ + "Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC (or STBI_REALLOC_SIZED)." +#endif + +#ifndef STBI_MALLOC +#define STBI_MALLOC(sz) malloc(sz) +#define STBI_REALLOC(p, newsz) realloc(p, newsz) +#define STBI_FREE(p) free(p) +#endif + +#ifndef STBI_REALLOC_SIZED +#define STBI_REALLOC_SIZED(p, oldsz, newsz) STBI_REALLOC(p, newsz) +#endif + +// x86/x64 detection +#if defined(__x86_64__) || defined(_M_X64) +#define STBI__X64_TARGET +#elif defined(__i386) || defined(_M_IX86) +#define STBI__X86_TARGET +#endif + +#if defined(__GNUC__) && defined(STBI__X86_TARGET) && !defined(__SSE2__) && !defined(STBI_NO_SIMD) +// gcc doesn't support sse2 intrinsics unless you compile with -msse2, +// which in turn means it gets to use SSE2 everywhere. This is unfortunate, +// but previous attempts to provide the SSE2 functions with runtime +// detection caused numerous issues. The way architecture extensions are +// exposed in GCC/Clang is, sadly, not really suited for one-file libs. +// New behavior: if compiled with -msse2, we use SSE2 without any +// detection; if not, we don't use it at all. +#define STBI_NO_SIMD +#endif + +#if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && \ + !defined(STBI_NO_SIMD) +// Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET +// +// 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the +// Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant. +// As a result, enabling SSE2 on 32-bit MinGW is dangerous when not +// simultaneously enabling "-mstackrealign". +// +// See https://github.com/nothings/stb/issues/81 for more information. +// +// So default to no SSE2 on 32-bit MinGW. If you've read this far and added +// -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2. +#define STBI_NO_SIMD +#endif + +#if !defined(STBI_NO_SIMD) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) +#define STBI_SSE2 +#include + +#ifdef _MSC_VER + +#if _MSC_VER >= 1400 // not VC6 +#include // __cpuid +static int stbi__cpuid3(void) { + int info[4]; + __cpuid(info, 1); + return info[3]; +} +#else +static int stbi__cpuid3(void) { + int res; + __asm { + mov eax,1 + cpuid + mov res,edx + } + return res; +} +#endif + +#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name + +#if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) +static int stbi__sse2_available(void) { + int info3 = stbi__cpuid3(); + return ((info3 >> 26) & 1) != 0; +} +#endif + +#else // assume GCC-style if not VC++ +#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) + +#if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) +static int stbi__sse2_available(void) { + // If we're even attempting to compile this on GCC/Clang, that means + // -msse2 is on, which means the compiler is allowed to use SSE2 + // instructions at will, and so are we. + return 1; +} +#endif + +#endif +#endif + +// ARM NEON +#if defined(STBI_NO_SIMD) && defined(STBI_NEON) +#undef STBI_NEON +#endif + +#ifdef STBI_NEON +#include +#ifdef _MSC_VER +#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name +#else +#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) +#endif +#endif + +#ifndef STBI_SIMD_ALIGN +#define STBI_SIMD_ALIGN(type, name) type name +#endif + +#ifndef STBI_MAX_DIMENSIONS +#define STBI_MAX_DIMENSIONS (1 << 24) +#endif + +/////////////////////////////////////////////// +// +// stbi__context struct and start_xxx functions + +// stbi__context structure is our basic context used by all images, so it +// contains all the IO context, plus some basic image information +typedef struct { + stbi__uint32 img_x, img_y; + int img_n, img_out_n; + + stbi_io_callbacks io; + void *io_user_data; + + int read_from_callbacks; + int buflen; + stbi_uc buffer_start[128]; + int callback_already_read; + + stbi_uc *img_buffer, *img_buffer_end; + stbi_uc *img_buffer_original, *img_buffer_original_end; +} stbi__context; + +static void stbi__refill_buffer(stbi__context *s); + +// initialize a memory-decode context +static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len) { + s->io.read = NULL; + s->read_from_callbacks = 0; + s->callback_already_read = 0; + s->img_buffer = s->img_buffer_original = (stbi_uc *)buffer; + s->img_buffer_end = s->img_buffer_original_end = (stbi_uc *)buffer + len; +} + +// initialize a callback-based context +static void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, void *user) { + s->io = *c; + s->io_user_data = user; + s->buflen = sizeof(s->buffer_start); + s->read_from_callbacks = 1; + s->callback_already_read = 0; + s->img_buffer = s->img_buffer_original = s->buffer_start; + stbi__refill_buffer(s); + s->img_buffer_original_end = s->img_buffer_end; +} + +#ifndef STBI_NO_STDIO + +static int stbi__stdio_read(void *user, char *data, int size) { + return (int)fread(data, 1, size, (FILE *)user); +} + +static void stbi__stdio_skip(void *user, int n) { + int ch; + fseek((FILE *)user, n, SEEK_CUR); + ch = fgetc((FILE *)user); /* have to read a byte to reset feof()'s flag */ + if (ch != EOF) { + ungetc(ch, (FILE *)user); /* push byte back onto stream if valid. */ + } +} + +static int stbi__stdio_eof(void *user) { return feof((FILE *)user) || ferror((FILE *)user); } + +static stbi_io_callbacks stbi__stdio_callbacks = { + stbi__stdio_read, + stbi__stdio_skip, + stbi__stdio_eof, +}; + +static void stbi__start_file(stbi__context *s, FILE *f) { + stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *)f); +} + +// static void stop_file(stbi__context *s) { } + +#endif // !STBI_NO_STDIO + +static void stbi__rewind(stbi__context *s) { + // conceptually rewind SHOULD rewind to the beginning of the stream, + // but we just rewind to the beginning of the initial buffer, because + // we only use it after doing 'test', which only ever looks at at most 92 bytes + s->img_buffer = s->img_buffer_original; + s->img_buffer_end = s->img_buffer_original_end; +} + +enum { STBI_ORDER_RGB, STBI_ORDER_BGR }; + +typedef struct { + int bits_per_channel; + int num_channels; + int channel_order; +} stbi__result_info; + +#ifndef STBI_NO_JPEG +static int stbi__jpeg_test(stbi__context *s); +static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, + stbi__result_info *ri); +static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_PNG +static int stbi__png_test(stbi__context *s); +static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, + stbi__result_info *ri); +static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp); +static int stbi__png_is16(stbi__context *s); +#endif + +#ifndef STBI_NO_BMP +static int stbi__bmp_test(stbi__context *s); +static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, + stbi__result_info *ri); +static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_TGA +static int stbi__tga_test(stbi__context *s); +static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, + stbi__result_info *ri); +static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_PSD +static int stbi__psd_test(stbi__context *s); +static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, + stbi__result_info *ri, int bpc); +static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp); +static int stbi__psd_is16(stbi__context *s); +#endif + +#ifndef STBI_NO_HDR +static int stbi__hdr_test(stbi__context *s); +static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, + stbi__result_info *ri); +static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_PIC +static int stbi__pic_test(stbi__context *s); +static void *stbi__pic_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, + stbi__result_info *ri); +static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_GIF +static int stbi__gif_test(stbi__context *s); +static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, + stbi__result_info *ri); +static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, + int req_comp); +static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_PNM +static int stbi__pnm_test(stbi__context *s); +static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, + stbi__result_info *ri); +static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp); +static int stbi__pnm_is16(stbi__context *s); +#endif + +static +#ifdef STBI_THREAD_LOCAL + STBI_THREAD_LOCAL +#endif + const char *stbi__g_failure_reason; + +STBIDEF const char *stbi_failure_reason(void) { return stbi__g_failure_reason; } + +#ifndef STBI_NO_FAILURE_STRINGS +static int stbi__err(const char *str) { + stbi__g_failure_reason = str; + return 0; +} +#endif + +static void *stbi__malloc(size_t size) { return STBI_MALLOC(size); } + +// stb_image uses ints pervasively, including for offset calculations. +// therefore the largest decoded image size we can support with the +// current code, even on 64-bit targets, is INT_MAX. this is not a +// significant limitation for the intended use case. +// +// we do, however, need to make sure our size calculations don't +// overflow. hence a few helper functions for size calculations that +// multiply integers together, making sure that they're non-negative +// and no overflow occurs. + +// return 1 if the sum is valid, 0 on overflow. +// negative terms are considered invalid. +static int stbi__addsizes_valid(int a, int b) { + if (b < 0) + return 0; + // now 0 <= b <= INT_MAX, hence also + // 0 <= INT_MAX - b <= INTMAX. + // And "a + b <= INT_MAX" (which might overflow) is the + // same as a <= INT_MAX - b (no overflow) + return a <= INT_MAX - b; +} + +// returns 1 if the product is valid, 0 on overflow. +// negative factors are considered invalid. +static int stbi__mul2sizes_valid(int a, int b) { + if (a < 0 || b < 0) + return 0; + if (b == 0) + return 1; // mul-by-0 is always safe + // portable way to check for no overflows in a*b + return a <= INT_MAX / b; +} + +#if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || \ + !defined(STBI_NO_HDR) +// returns 1 if "a*b + add" has no negative terms/factors and doesn't overflow +static int stbi__mad2sizes_valid(int a, int b, int add) { + return stbi__mul2sizes_valid(a, b) && stbi__addsizes_valid(a * b, add); +} +#endif + +// returns 1 if "a*b*c + add" has no negative terms/factors and doesn't overflow +static int stbi__mad3sizes_valid(int a, int b, int c, int add) { + return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a * b, c) && + stbi__addsizes_valid(a * b * c, add); +} + +// returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow +#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) || !defined(STBI_NO_PNM) +static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add) { + return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a * b, c) && + stbi__mul2sizes_valid(a * b * c, d) && stbi__addsizes_valid(a * b * c * d, add); +} +#endif + +#if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || \ + !defined(STBI_NO_HDR) +// mallocs with size overflow checking +static void *stbi__malloc_mad2(int a, int b, int add) { + if (!stbi__mad2sizes_valid(a, b, add)) + return NULL; + return stbi__malloc(a * b + add); +} +#endif + +static void *stbi__malloc_mad3(int a, int b, int c, int add) { + if (!stbi__mad3sizes_valid(a, b, c, add)) + return NULL; + return stbi__malloc(a * b * c + add); +} + +#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) || !defined(STBI_NO_PNM) +static void *stbi__malloc_mad4(int a, int b, int c, int d, int add) { + if (!stbi__mad4sizes_valid(a, b, c, d, add)) + return NULL; + return stbi__malloc(a * b * c * d + add); +} +#endif + +// returns 1 if the sum of two signed ints is valid (between -2^31 and 2^31-1 inclusive), 0 on +// overflow. +static int stbi__addints_valid(int a, int b) { + if ((a >= 0) != (b >= 0)) + return 1; // a and b have different signs, so no overflow + if (a < 0 && b < 0) + return a >= + INT_MIN - b; // same as a + b >= INT_MIN; INT_MIN - b cannot overflow since b < 0. + return a <= INT_MAX - b; +} + +// returns 1 if the product of two ints fits in a signed short, 0 on overflow. +static int stbi__mul2shorts_valid(int a, int b) { + if (b == 0 || b == -1) + return 1; // multiplication by 0 is always 0; check for -1 so SHRT_MIN/b doesn't overflow + if ((a >= 0) == (b >= 0)) + return a <= SHRT_MAX / b; // product is positive, so similar to mul2sizes_valid + if (b < 0) + return a <= SHRT_MIN / b; // same as a * b >= SHRT_MIN + return a >= SHRT_MIN / b; +} + +// stbi__err - error +// stbi__errpf - error returning pointer to float +// stbi__errpuc - error returning pointer to unsigned char + +#ifdef STBI_NO_FAILURE_STRINGS +#define stbi__err(x, y) 0 +#elif defined(STBI_FAILURE_USERMSG) +#define stbi__err(x, y) stbi__err(y) +#else +#define stbi__err(x, y) stbi__err(x) +#endif + +#define stbi__errpf(x, y) ((float *)(size_t)(stbi__err(x, y) ? NULL : NULL)) +#define stbi__errpuc(x, y) ((unsigned char *)(size_t)(stbi__err(x, y) ? NULL : NULL)) + +STBIDEF void stbi_image_free(void *retval_from_stbi_load) { STBI_FREE(retval_from_stbi_load); } + +#ifndef STBI_NO_LINEAR +static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp); +#endif + +#ifndef STBI_NO_HDR +static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp); +#endif + +static int stbi__vertically_flip_on_load_global = 0; + +STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip) { + stbi__vertically_flip_on_load_global = flag_true_if_should_flip; +} + +#ifndef STBI_THREAD_LOCAL +#define stbi__vertically_flip_on_load stbi__vertically_flip_on_load_global +#else +static STBI_THREAD_LOCAL int stbi__vertically_flip_on_load_local, stbi__vertically_flip_on_load_set; + +STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip) { + stbi__vertically_flip_on_load_local = flag_true_if_should_flip; + stbi__vertically_flip_on_load_set = 1; +} + +#define stbi__vertically_flip_on_load \ + (stbi__vertically_flip_on_load_set ? stbi__vertically_flip_on_load_local \ + : stbi__vertically_flip_on_load_global) +#endif // STBI_THREAD_LOCAL + +static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp, + stbi__result_info *ri, int bpc) { + memset(ri, 0, sizeof(*ri)); // make sure it's initialized if we add new fields + ri->bits_per_channel = 8; // default is 8 so most paths don't have to be changed + ri->channel_order = STBI_ORDER_RGB; // all current input & output are this, but this is here so + // we can add BGR order + ri->num_channels = 0; + +// test the formats with a very explicit header first (at least a FOURCC +// or distinctive magic number first) +#ifndef STBI_NO_PNG + if (stbi__png_test(s)) + return stbi__png_load(s, x, y, comp, req_comp, ri); +#endif +#ifndef STBI_NO_BMP + if (stbi__bmp_test(s)) + return stbi__bmp_load(s, x, y, comp, req_comp, ri); +#endif +#ifndef STBI_NO_GIF + if (stbi__gif_test(s)) + return stbi__gif_load(s, x, y, comp, req_comp, ri); +#endif +#ifndef STBI_NO_PSD + if (stbi__psd_test(s)) + return stbi__psd_load(s, x, y, comp, req_comp, ri, bpc); +#else + STBI_NOTUSED(bpc); +#endif +#ifndef STBI_NO_PIC + if (stbi__pic_test(s)) + return stbi__pic_load(s, x, y, comp, req_comp, ri); +#endif + +// then the formats that can end up attempting to load with just 1 or 2 +// bytes matching expectations; these are prone to false positives, so +// try them later +#ifndef STBI_NO_JPEG + if (stbi__jpeg_test(s)) + return stbi__jpeg_load(s, x, y, comp, req_comp, ri); +#endif +#ifndef STBI_NO_PNM + if (stbi__pnm_test(s)) + return stbi__pnm_load(s, x, y, comp, req_comp, ri); +#endif + +#ifndef STBI_NO_HDR + if (stbi__hdr_test(s)) { + float *hdr = stbi__hdr_load(s, x, y, comp, req_comp, ri); + return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); + } +#endif + +#ifndef STBI_NO_TGA + // test tga last because it's a crappy test! + if (stbi__tga_test(s)) + return stbi__tga_load(s, x, y, comp, req_comp, ri); +#endif + + return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt"); +} + +static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, int channels) { + int i; + int img_len = w * h * channels; + stbi_uc *reduced; + + reduced = (stbi_uc *)stbi__malloc(img_len); + if (reduced == NULL) + return stbi__errpuc("outofmem", "Out of memory"); + + for (i = 0; i < img_len; ++i) + reduced[i] = + (stbi_uc)((orig[i] >> 8) & + 0xFF); // top half of each byte is sufficient approx of 16->8 bit scaling + + STBI_FREE(orig); + return reduced; +} + +static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, int channels) { + int i; + int img_len = w * h * channels; + stbi__uint16 *enlarged; + + enlarged = (stbi__uint16 *)stbi__malloc(img_len * 2); + if (enlarged == NULL) + return (stbi__uint16 *)stbi__errpuc("outofmem", "Out of memory"); + + for (i = 0; i < img_len; ++i) + enlarged[i] = + (stbi__uint16)((orig[i] << 8) + + orig[i]); // replicate to high and low byte, maps 0->0, 255->0xffff + + STBI_FREE(orig); + return enlarged; +} + +static void stbi__vertical_flip(void *image, int w, int h, int bytes_per_pixel) { + int row; + size_t bytes_per_row = (size_t)w * bytes_per_pixel; + stbi_uc temp[2048]; + stbi_uc *bytes = (stbi_uc *)image; + + for (row = 0; row < (h >> 1); row++) { + stbi_uc *row0 = bytes + row * bytes_per_row; + stbi_uc *row1 = bytes + (h - row - 1) * bytes_per_row; + // swap row0 with row1 + size_t bytes_left = bytes_per_row; + while (bytes_left) { + size_t bytes_copy = (bytes_left < sizeof(temp)) ? bytes_left : sizeof(temp); + memcpy(temp, row0, bytes_copy); + memcpy(row0, row1, bytes_copy); + memcpy(row1, temp, bytes_copy); + row0 += bytes_copy; + row1 += bytes_copy; + bytes_left -= bytes_copy; + } + } +} + +#ifndef STBI_NO_GIF +static void stbi__vertical_flip_slices(void *image, int w, int h, int z, int bytes_per_pixel) { + int slice; + int slice_size = w * h * bytes_per_pixel; + + stbi_uc *bytes = (stbi_uc *)image; + for (slice = 0; slice < z; ++slice) { + stbi__vertical_flip(bytes, w, h, bytes_per_pixel); + bytes += slice_size; + } +} +#endif + +static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, int *y, int *comp, + int req_comp) { + stbi__result_info ri; + void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 8); + + if (result == NULL) + return NULL; + + // it is the responsibility of the loaders to make sure we get either 8 or 16 bit. + STBI_ASSERT(ri.bits_per_channel == 8 || ri.bits_per_channel == 16); + + if (ri.bits_per_channel != 8) { + result = + stbi__convert_16_to_8((stbi__uint16 *)result, *x, *y, req_comp == 0 ? *comp : req_comp); + ri.bits_per_channel = 8; + } + + // @TODO: move stbi__convert_format to here + + if (stbi__vertically_flip_on_load) { + int channels = req_comp ? req_comp : *comp; + stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi_uc)); + } + + return (unsigned char *)result; +} + +static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, int *y, int *comp, + int req_comp) { + stbi__result_info ri; + void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 16); + + if (result == NULL) + return NULL; + + // it is the responsibility of the loaders to make sure we get either 8 or 16 bit. + STBI_ASSERT(ri.bits_per_channel == 8 || ri.bits_per_channel == 16); + + if (ri.bits_per_channel != 16) { + result = stbi__convert_8_to_16((stbi_uc *)result, *x, *y, req_comp == 0 ? *comp : req_comp); + ri.bits_per_channel = 16; + } + + // @TODO: move stbi__convert_format16 to here + // @TODO: special case RGB-to-Y (and RGBA-to-YA) for 8-bit-to-16-bit case to keep more precision + + if (stbi__vertically_flip_on_load) { + int channels = req_comp ? req_comp : *comp; + stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi__uint16)); + } + + return (stbi__uint16 *)result; +} + +#if !defined(STBI_NO_HDR) && !defined(STBI_NO_LINEAR) +static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, int req_comp) { + if (stbi__vertically_flip_on_load && result != NULL) { + int channels = req_comp ? req_comp : *comp; + stbi__vertical_flip(result, *x, *y, channels * sizeof(float)); + } +} +#endif + +#ifndef STBI_NO_STDIO + +#if defined(_WIN32) && defined(STBI_WINDOWS_UTF8) +STBI_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, + unsigned long flags, + const char *str, int cbmb, + wchar_t *widestr, int cchwide); +STBI_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte( + unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, + const char *defchar, int *used_default); +#endif + +#if defined(_WIN32) && defined(STBI_WINDOWS_UTF8) +STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t *input) { + return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int)bufferlen, NULL, NULL); +} +#endif + +static FILE *stbi__fopen(char const *filename, char const *mode) { + FILE *f; +#if defined(_WIN32) && defined(STBI_WINDOWS_UTF8) + wchar_t wMode[64]; + wchar_t wFilename[1024]; + if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, + sizeof(wFilename) / sizeof(*wFilename))) + return 0; + + if (0 == + MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode) / sizeof(*wMode))) + return 0; + +#if defined(_MSC_VER) && _MSC_VER >= 1400 + if (0 != _wfopen_s(&f, wFilename, wMode)) + f = 0; +#else + f = _wfopen(wFilename, wMode); +#endif + +#elif defined(_MSC_VER) && _MSC_VER >= 1400 + if (0 != fopen_s(&f, filename, mode)) + f = 0; +#else + f = fopen(filename, mode); +#endif + return f; +} + +STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp) { + FILE *f = stbi__fopen(filename, "rb"); + unsigned char *result; + if (!f) + return stbi__errpuc("can't fopen", "Unable to open file"); + result = stbi_load_from_file(f, x, y, comp, req_comp); + fclose(f); + return result; +} + +STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) { + unsigned char *result; + stbi__context s; + stbi__start_file(&s, f); + result = stbi__load_and_postprocess_8bit(&s, x, y, comp, req_comp); + if (result) { + // need to 'unget' all the characters in the IO buffer + fseek(f, -(int)(s.img_buffer_end - s.img_buffer), SEEK_CUR); + } + return result; +} + +STBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, int req_comp) { + stbi__uint16 *result; + stbi__context s; + stbi__start_file(&s, f); + result = stbi__load_and_postprocess_16bit(&s, x, y, comp, req_comp); + if (result) { + // need to 'unget' all the characters in the IO buffer + fseek(f, -(int)(s.img_buffer_end - s.img_buffer), SEEK_CUR); + } + return result; +} + +STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *comp, int req_comp) { + FILE *f = stbi__fopen(filename, "rb"); + stbi__uint16 *result; + if (!f) + return (stbi_us *)stbi__errpuc("can't fopen", "Unable to open file"); + result = stbi_load_from_file_16(f, x, y, comp, req_comp); + fclose(f); + return result; +} + +#endif //! STBI_NO_STDIO + +STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, int len, int *x, int *y, + int *channels_in_file, int desired_channels) { + stbi__context s; + stbi__start_mem(&s, buffer, len); + return stbi__load_and_postprocess_16bit(&s, x, y, channels_in_file, desired_channels); +} + +STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, + int *y, int *channels_in_file, int desired_channels) { + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); + return stbi__load_and_postprocess_16bit(&s, x, y, channels_in_file, desired_channels); +} + +STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, + int req_comp) { + stbi__context s; + stbi__start_mem(&s, buffer, len); + return stbi__load_and_postprocess_8bit(&s, x, y, comp, req_comp); +} + +STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, + int *comp, int req_comp) { + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); + return stbi__load_and_postprocess_8bit(&s, x, y, comp, req_comp); +} + +#ifndef STBI_NO_GIF +STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, + int *y, int *z, int *comp, int req_comp) { + unsigned char *result; + stbi__context s; + stbi__start_mem(&s, buffer, len); + + result = (unsigned char *)stbi__load_gif_main(&s, delays, x, y, z, comp, req_comp); + if (stbi__vertically_flip_on_load) { + stbi__vertical_flip_slices(result, *x, *y, *z, *comp); + } + + return result; +} +#endif + +#ifndef STBI_NO_LINEAR +static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) { + unsigned char *data; +#ifndef STBI_NO_HDR + if (stbi__hdr_test(s)) { + stbi__result_info ri; + float *hdr_data = stbi__hdr_load(s, x, y, comp, req_comp, &ri); + if (hdr_data) + stbi__float_postprocess(hdr_data, x, y, comp, req_comp); + return hdr_data; + } +#endif + data = stbi__load_and_postprocess_8bit(s, x, y, comp, req_comp); + if (data) + return stbi__ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); + return stbi__errpf("unknown image type", "Image not of any known type, or corrupt"); +} + +STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, + int req_comp) { + stbi__context s; + stbi__start_mem(&s, buffer, len); + return stbi__loadf_main(&s, x, y, comp, req_comp); +} + +STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, + int *comp, int req_comp) { + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); + return stbi__loadf_main(&s, x, y, comp, req_comp); +} + +#ifndef STBI_NO_STDIO +STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp) { + float *result; + FILE *f = stbi__fopen(filename, "rb"); + if (!f) + return stbi__errpf("can't fopen", "Unable to open file"); + result = stbi_loadf_from_file(f, x, y, comp, req_comp); + fclose(f); + return result; +} + +STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) { + stbi__context s; + stbi__start_file(&s, f); + return stbi__loadf_main(&s, x, y, comp, req_comp); +} +#endif // !STBI_NO_STDIO + +#endif // !STBI_NO_LINEAR + +// these is-hdr-or-not is defined independent of whether STBI_NO_LINEAR is +// defined, for API simplicity; if STBI_NO_LINEAR is defined, it always +// reports false! + +STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len) { +#ifndef STBI_NO_HDR + stbi__context s; + stbi__start_mem(&s, buffer, len); + return stbi__hdr_test(&s); +#else + STBI_NOTUSED(buffer); + STBI_NOTUSED(len); + return 0; +#endif +} + +#ifndef STBI_NO_STDIO +STBIDEF int stbi_is_hdr(char const *filename) { + FILE *f = stbi__fopen(filename, "rb"); + int result = 0; + if (f) { + result = stbi_is_hdr_from_file(f); + fclose(f); + } + return result; +} + +STBIDEF int stbi_is_hdr_from_file(FILE *f) { +#ifndef STBI_NO_HDR + long pos = ftell(f); + int res; + stbi__context s; + stbi__start_file(&s, f); + res = stbi__hdr_test(&s); + fseek(f, pos, SEEK_SET); + return res; +#else + STBI_NOTUSED(f); + return 0; +#endif +} +#endif // !STBI_NO_STDIO + +STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user) { +#ifndef STBI_NO_HDR + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); + return stbi__hdr_test(&s); +#else + STBI_NOTUSED(clbk); + STBI_NOTUSED(user); + return 0; +#endif +} + +#ifndef STBI_NO_LINEAR +static float stbi__l2h_gamma = 2.2f, stbi__l2h_scale = 1.0f; + +STBIDEF void stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; } +STBIDEF void stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; } +#endif + +static float stbi__h2l_gamma_i = 1.0f / 2.2f, stbi__h2l_scale_i = 1.0f; + +STBIDEF void stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1 / gamma; } +STBIDEF void stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1 / scale; } + +////////////////////////////////////////////////////////////////////////////// +// +// Common code used by all image loaders +// + +enum { STBI__SCAN_load = 0, STBI__SCAN_type, STBI__SCAN_header }; + +static void stbi__refill_buffer(stbi__context *s) { + int n = (s->io.read)(s->io_user_data, (char *)s->buffer_start, s->buflen); + s->callback_already_read += (int)(s->img_buffer - s->img_buffer_original); + if (n == 0) { + // at end of file, treat same as if from memory, but need to handle case + // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file + s->read_from_callbacks = 0; + s->img_buffer = s->buffer_start; + s->img_buffer_end = s->buffer_start + 1; + *s->img_buffer = 0; + } else { + s->img_buffer = s->buffer_start; + s->img_buffer_end = s->buffer_start + n; + } +} + +stbi_inline static stbi_uc stbi__get8(stbi__context *s) { + if (s->img_buffer < s->img_buffer_end) + return *s->img_buffer++; + if (s->read_from_callbacks) { + stbi__refill_buffer(s); + return *s->img_buffer++; + } + return 0; +} + +#if defined(STBI_NO_JPEG) && defined(STBI_NO_HDR) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) +// nothing +#else +stbi_inline static int stbi__at_eof(stbi__context *s) { + if (s->io.read) { + if (!(s->io.eof)(s->io_user_data)) + return 0; + // if feof() is true, check if buffer = end + // special case: we've only got the special 0 character at the end + if (s->read_from_callbacks == 0) + return 1; + } + + return s->img_buffer >= s->img_buffer_end; +} +#endif + +#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && \ + defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) +// nothing +#else +static void stbi__skip(stbi__context *s, int n) { + if (n == 0) + return; // already there! + if (n < 0) { + s->img_buffer = s->img_buffer_end; + return; + } + if (s->io.read) { + int blen = (int)(s->img_buffer_end - s->img_buffer); + if (blen < n) { + s->img_buffer = s->img_buffer_end; + (s->io.skip)(s->io_user_data, n - blen); + return; + } + } + s->img_buffer += n; +} +#endif + +#if defined(STBI_NO_PNG) && defined(STBI_NO_TGA) && defined(STBI_NO_HDR) && defined(STBI_NO_PNM) +// nothing +#else +static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n) { + if (s->io.read) { + int blen = (int)(s->img_buffer_end - s->img_buffer); + if (blen < n) { + int res, count; + + memcpy(buffer, s->img_buffer, blen); + + count = (s->io.read)(s->io_user_data, (char *)buffer + blen, n - blen); + res = (count == (n - blen)); + s->img_buffer = s->img_buffer_end; + return res; + } + } + + if (s->img_buffer + n <= s->img_buffer_end) { + memcpy(buffer, s->img_buffer, n); + s->img_buffer += n; + return 1; + } else + return 0; +} +#endif + +#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC) +// nothing +#else +static int stbi__get16be(stbi__context *s) { + int z = stbi__get8(s); + return (z << 8) + stbi__get8(s); +} +#endif + +#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC) +// nothing +#else +static stbi__uint32 stbi__get32be(stbi__context *s) { + stbi__uint32 z = stbi__get16be(s); + return (z << 16) + stbi__get16be(s); +} +#endif + +#if defined(STBI_NO_BMP) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) +// nothing +#else +static int stbi__get16le(stbi__context *s) { + int z = stbi__get8(s); + return z + (stbi__get8(s) << 8); +} +#endif + +#ifndef STBI_NO_BMP +static stbi__uint32 stbi__get32le(stbi__context *s) { + stbi__uint32 z = stbi__get16le(s); + z += (stbi__uint32)stbi__get16le(s) << 16; + return z; +} +#endif + +#define STBI__BYTECAST(x) ((stbi_uc)((x) & 255)) // truncate int to byte without warnings + +#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && \ + defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && \ + defined(STBI_NO_PIC) && defined(STBI_NO_PNM) +// nothing +#else +////////////////////////////////////////////////////////////////////////////// +// +// generic converter from built-in img_n to req_comp +// individual types do this automatically as much as possible (e.g. jpeg +// does all cases internally since it needs to colorspace convert anyway, +// and it never has alpha, so very few cases ). png can automatically +// interleave an alpha=255 channel, but falls back to this for other cases +// +// assume data buffer is malloced, so malloc a new one and free that one +// only failure mode is malloc failing + +static stbi_uc stbi__compute_y(int r, int g, int b) { + return (stbi_uc)(((r * 77) + (g * 150) + (29 * b)) >> 8); +} +#endif + +#if defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && \ + defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) +// nothing +#else +static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, + unsigned int x, unsigned int y) { + int i, j; + unsigned char *good; + + if (req_comp == img_n) + return data; + STBI_ASSERT(req_comp >= 1 && req_comp <= 4); + + good = (unsigned char *)stbi__malloc_mad3(req_comp, x, y, 0); + if (good == NULL) { + STBI_FREE(data); + return stbi__errpuc("outofmem", "Out of memory"); + } + + for (j = 0; j < (int)y; ++j) { + unsigned char *src = data + j * x * img_n; + unsigned char *dest = good + j * x * req_comp; + +#define STBI__COMBO(a, b) ((a) * 8 + (b)) +#define STBI__CASE(a, b) \ + case STBI__COMBO(a, b): \ + for (i = x - 1; i >= 0; --i, src += a, dest += b) + // convert source image with img_n components to one with req_comp components; + // avoid switch per pixel, so use switch per scanline and massive macros + switch (STBI__COMBO(img_n, req_comp)) { + STBI__CASE(1, 2) { + dest[0] = src[0]; + dest[1] = 255; + } + break; + STBI__CASE(1, 3) { dest[0] = dest[1] = dest[2] = src[0]; } + break; + STBI__CASE(1, 4) { + dest[0] = dest[1] = dest[2] = src[0]; + dest[3] = 255; + } + break; + STBI__CASE(2, 1) { dest[0] = src[0]; } + break; + STBI__CASE(2, 3) { dest[0] = dest[1] = dest[2] = src[0]; } + break; + STBI__CASE(2, 4) { + dest[0] = dest[1] = dest[2] = src[0]; + dest[3] = src[1]; + } + break; + STBI__CASE(3, 4) { + dest[0] = src[0]; + dest[1] = src[1]; + dest[2] = src[2]; + dest[3] = 255; + } + break; + STBI__CASE(3, 1) { dest[0] = stbi__compute_y(src[0], src[1], src[2]); } + break; + STBI__CASE(3, 2) { + dest[0] = stbi__compute_y(src[0], src[1], src[2]); + dest[1] = 255; + } + break; + STBI__CASE(4, 1) { dest[0] = stbi__compute_y(src[0], src[1], src[2]); } + break; + STBI__CASE(4, 2) { + dest[0] = stbi__compute_y(src[0], src[1], src[2]); + dest[1] = src[3]; + } + break; + STBI__CASE(4, 3) { + dest[0] = src[0]; + dest[1] = src[1]; + dest[2] = src[2]; + } + break; + default: + STBI_ASSERT(0); + STBI_FREE(data); + STBI_FREE(good); + return stbi__errpuc("unsupported", "Unsupported format conversion"); + } +#undef STBI__CASE + } + + STBI_FREE(data); + return good; +} +#endif + +#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) +// nothing +#else +static stbi__uint16 stbi__compute_y_16(int r, int g, int b) { + return (stbi__uint16)(((r * 77) + (g * 150) + (29 * b)) >> 8); +} +#endif + +#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) +// nothing +#else +static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, + unsigned int x, unsigned int y) { + int i, j; + stbi__uint16 *good; + + if (req_comp == img_n) + return data; + STBI_ASSERT(req_comp >= 1 && req_comp <= 4); + + good = (stbi__uint16 *)stbi__malloc(req_comp * x * y * 2); + if (good == NULL) { + STBI_FREE(data); + return (stbi__uint16 *)stbi__errpuc("outofmem", "Out of memory"); + } + + for (j = 0; j < (int)y; ++j) { + stbi__uint16 *src = data + j * x * img_n; + stbi__uint16 *dest = good + j * x * req_comp; + +#define STBI__COMBO(a, b) ((a) * 8 + (b)) +#define STBI__CASE(a, b) \ + case STBI__COMBO(a, b): \ + for (i = x - 1; i >= 0; --i, src += a, dest += b) + // convert source image with img_n components to one with req_comp components; + // avoid switch per pixel, so use switch per scanline and massive macros + switch (STBI__COMBO(img_n, req_comp)) { + STBI__CASE(1, 2) { + dest[0] = src[0]; + dest[1] = 0xffff; + } + break; + STBI__CASE(1, 3) { dest[0] = dest[1] = dest[2] = src[0]; } + break; + STBI__CASE(1, 4) { + dest[0] = dest[1] = dest[2] = src[0]; + dest[3] = 0xffff; + } + break; + STBI__CASE(2, 1) { dest[0] = src[0]; } + break; + STBI__CASE(2, 3) { dest[0] = dest[1] = dest[2] = src[0]; } + break; + STBI__CASE(2, 4) { + dest[0] = dest[1] = dest[2] = src[0]; + dest[3] = src[1]; + } + break; + STBI__CASE(3, 4) { + dest[0] = src[0]; + dest[1] = src[1]; + dest[2] = src[2]; + dest[3] = 0xffff; + } + break; + STBI__CASE(3, 1) { dest[0] = stbi__compute_y_16(src[0], src[1], src[2]); } + break; + STBI__CASE(3, 2) { + dest[0] = stbi__compute_y_16(src[0], src[1], src[2]); + dest[1] = 0xffff; + } + break; + STBI__CASE(4, 1) { dest[0] = stbi__compute_y_16(src[0], src[1], src[2]); } + break; + STBI__CASE(4, 2) { + dest[0] = stbi__compute_y_16(src[0], src[1], src[2]); + dest[1] = src[3]; + } + break; + STBI__CASE(4, 3) { + dest[0] = src[0]; + dest[1] = src[1]; + dest[2] = src[2]; + } + break; + default: + STBI_ASSERT(0); + STBI_FREE(data); + STBI_FREE(good); + return (stbi__uint16 *)stbi__errpuc("unsupported", "Unsupported format conversion"); + } +#undef STBI__CASE + } + + STBI_FREE(data); + return good; +} +#endif + +#ifndef STBI_NO_LINEAR +static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp) { + int i, k, n; + float *output; + if (!data) + return NULL; + output = (float *)stbi__malloc_mad4(x, y, comp, sizeof(float), 0); + if (output == NULL) { + STBI_FREE(data); + return stbi__errpf("outofmem", "Out of memory"); + } + // compute number of non-alpha components + if (comp & 1) + n = comp; + else + n = comp - 1; + for (i = 0; i < x * y; ++i) { + for (k = 0; k < n; ++k) { + output[i * comp + k] = + (float)(pow(data[i * comp + k] / 255.0f, stbi__l2h_gamma) * stbi__l2h_scale); + } + } + if (n < comp) { + for (i = 0; i < x * y; ++i) { + output[i * comp + n] = data[i * comp + n] / 255.0f; + } + } + STBI_FREE(data); + return output; +} +#endif + +#ifndef STBI_NO_HDR +#define stbi__float2int(x) ((int)(x)) +static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp) { + int i, k, n; + stbi_uc *output; + if (!data) + return NULL; + output = (stbi_uc *)stbi__malloc_mad3(x, y, comp, 0); + if (output == NULL) { + STBI_FREE(data); + return stbi__errpuc("outofmem", "Out of memory"); + } + // compute number of non-alpha components + if (comp & 1) + n = comp; + else + n = comp - 1; + for (i = 0; i < x * y; ++i) { + for (k = 0; k < n; ++k) { + float z = + (float)pow(data[i * comp + k] * stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f; + if (z < 0) + z = 0; + if (z > 255) + z = 255; + output[i * comp + k] = (stbi_uc)stbi__float2int(z); + } + if (k < comp) { + float z = data[i * comp + k] * 255 + 0.5f; + if (z < 0) + z = 0; + if (z > 255) + z = 255; + output[i * comp + k] = (stbi_uc)stbi__float2int(z); + } + } + STBI_FREE(data); + return output; +} +#endif + +////////////////////////////////////////////////////////////////////////////// +// +// "baseline" JPEG/JFIF decoder +// +// simple implementation +// - doesn't support delayed output of y-dimension +// - simple interface (only one output format: 8-bit interleaved RGB) +// - doesn't try to recover corrupt jpegs +// - doesn't allow partial loading, loading multiple at once +// - still fast on x86 (copying globals into locals doesn't help x86) +// - allocates lots of intermediate memory (full size of all components) +// - non-interleaved case requires this anyway +// - allows good upsampling (see next) +// high-quality +// - upsampled channels are bilinearly interpolated, even across blocks +// - quality integer IDCT derived from IJG's 'slow' +// performance +// - fast huffman; reasonable integer IDCT +// - some SIMD kernels for common paths on targets with SSE2/NEON +// - uses a lot of intermediate memory, could cache poorly + +#ifndef STBI_NO_JPEG + +// huffman decoding acceleration +#define FAST_BITS 9 // larger handles more cases; smaller stomps less cache + +typedef struct { + stbi_uc fast[1 << FAST_BITS]; + // weirdly, repacking this into AoS is a 10% speed loss, instead of a win + stbi__uint16 code[256]; + stbi_uc values[256]; + stbi_uc size[257]; + unsigned int maxcode[18]; + int delta[17]; // old 'firstsymbol' - old 'firstcode' +} stbi__huffman; + +typedef struct { + stbi__context *s; + stbi__huffman huff_dc[4]; + stbi__huffman huff_ac[4]; + stbi__uint16 dequant[4][64]; + stbi__int16 fast_ac[4][1 << FAST_BITS]; + + // sizes for components, interleaved MCUs + int img_h_max, img_v_max; + int img_mcu_x, img_mcu_y; + int img_mcu_w, img_mcu_h; + + // definition of jpeg image component + struct { + int id; + int h, v; + int tq; + int hd, ha; + int dc_pred; + + int x, y, w2, h2; + stbi_uc *data; + void *raw_data, *raw_coeff; + stbi_uc *linebuf; + short *coeff; // progressive only + int coeff_w, coeff_h; // number of 8x8 coefficient blocks + } img_comp[4]; + + stbi__uint32 code_buffer; // jpeg entropy-coded buffer + int code_bits; // number of valid bits + unsigned char marker; // marker seen while filling entropy buffer + int nomore; // flag if we saw a marker so must stop + + int progressive; + int spec_start; + int spec_end; + int succ_high; + int succ_low; + int eob_run; + int jfif; + int app14_color_transform; // Adobe APP14 tag + int rgb; + + int scan_n, order[4]; + int restart_interval, todo; + + // kernels + void (*idct_block_kernel)(stbi_uc *out, int out_stride, short data[64]); + void (*YCbCr_to_RGB_kernel)(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, + const stbi_uc *pcr, int count, int step); + stbi_uc *(*resample_row_hv_2_kernel)(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, + int hs); +} stbi__jpeg; + +static int stbi__build_huffman(stbi__huffman *h, int *count) { + int i, j, k = 0; + unsigned int code; + // build size list for each symbol (from JPEG spec) + for (i = 0; i < 16; ++i) { + for (j = 0; j < count[i]; ++j) { + h->size[k++] = (stbi_uc)(i + 1); + if (k >= 257) + return stbi__err("bad size list", "Corrupt JPEG"); + } + } + h->size[k] = 0; + + // compute actual symbols (from jpeg spec) + code = 0; + k = 0; + for (j = 1; j <= 16; ++j) { + // compute delta to add to code to compute symbol id + h->delta[j] = k - code; + if (h->size[k] == j) { + while (h->size[k] == j) + h->code[k++] = (stbi__uint16)(code++); + if (code - 1 >= (1u << j)) + return stbi__err("bad code lengths", "Corrupt JPEG"); + } + // compute largest code + 1 for this size, preshifted as needed later + h->maxcode[j] = code << (16 - j); + code <<= 1; + } + h->maxcode[j] = 0xffffffff; + + // build non-spec acceleration table; 255 is flag for not-accelerated + memset(h->fast, 255, 1 << FAST_BITS); + for (i = 0; i < k; ++i) { + int s = h->size[i]; + if (s <= FAST_BITS) { + int c = h->code[i] << (FAST_BITS - s); + int m = 1 << (FAST_BITS - s); + for (j = 0; j < m; ++j) { + h->fast[c + j] = (stbi_uc)i; + } + } + } + return 1; +} + +// build a table that decodes both magnitude and value of small ACs in +// one go. +static void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h) { + int i; + for (i = 0; i < (1 << FAST_BITS); ++i) { + stbi_uc fast = h->fast[i]; + fast_ac[i] = 0; + if (fast < 255) { + int rs = h->values[fast]; + int run = (rs >> 4) & 15; + int magbits = rs & 15; + int len = h->size[fast]; + + if (magbits && len + magbits <= FAST_BITS) { + // magnitude code followed by receive_extend code + int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits); + int m = 1 << (magbits - 1); + if (k < m) + k += (~0U << magbits) + 1; + // if the result is small enough, we can fit it in fast_ac table + if (k >= -128 && k <= 127) + fast_ac[i] = (stbi__int16)((k * 256) + (run * 16) + (len + magbits)); + } + } + } +} + +static void stbi__grow_buffer_unsafe(stbi__jpeg *j) { + do { + unsigned int b = j->nomore ? 0 : stbi__get8(j->s); + if (b == 0xff) { + int c = stbi__get8(j->s); + while (c == 0xff) + c = stbi__get8(j->s); // consume fill bytes + if (c != 0) { + j->marker = (unsigned char)c; + j->nomore = 1; + return; + } + } + j->code_buffer |= b << (24 - j->code_bits); + j->code_bits += 8; + } while (j->code_bits <= 24); +} + +// (1 << n) - 1 +static const stbi__uint32 stbi__bmask[17] = {0, 1, 3, 7, 15, 31, 63, 127, 255, + 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535}; + +// decode a jpeg huffman value from the bitstream +stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) { + unsigned int temp; + int c, k; + + if (j->code_bits < 16) + stbi__grow_buffer_unsafe(j); + + // look at the top FAST_BITS and determine what symbol ID it is, + // if the code is <= FAST_BITS + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS) - 1); + k = h->fast[c]; + if (k < 255) { + int s = h->size[k]; + if (s > j->code_bits) + return -1; + j->code_buffer <<= s; + j->code_bits -= s; + return h->values[k]; + } + + // naive test is to shift the code_buffer down so k bits are + // valid, then test against maxcode. To speed this up, we've + // preshifted maxcode left so that it has (16-k) 0s at the + // end; in other words, regardless of the number of bits, it + // wants to be compared against something shifted to have 16; + // that way we don't need to shift inside the loop. + temp = j->code_buffer >> 16; + for (k = FAST_BITS + 1;; ++k) + if (temp < h->maxcode[k]) + break; + if (k == 17) { + // error! code not found + j->code_bits -= 16; + return -1; + } + + if (k > j->code_bits) + return -1; + + // convert the huffman code to the symbol id + c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k]; + if (c < 0 || c >= 256) // symbol id out of bounds! + return -1; + STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]); + + // convert the id to a symbol + j->code_bits -= k; + j->code_buffer <<= k; + return h->values[c]; +} + +// bias[n] = (-1<code_bits < n) + stbi__grow_buffer_unsafe(j); + if (j->code_bits < n) + return 0; // ran out of bits from stream, return 0s intead of continuing + + sgn = j->code_buffer >> + 31; // sign bit always in MSB; 0 if MSB clear (positive), 1 if MSB set (negative) + k = stbi_lrot(j->code_buffer, n); + j->code_buffer = k & ~stbi__bmask[n]; + k &= stbi__bmask[n]; + j->code_bits -= n; + return k + (stbi__jbias[n] & (sgn - 1)); +} + +// get some unsigned bits +stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n) { + unsigned int k; + if (j->code_bits < n) + stbi__grow_buffer_unsafe(j); + if (j->code_bits < n) + return 0; // ran out of bits from stream, return 0s intead of continuing + k = stbi_lrot(j->code_buffer, n); + j->code_buffer = k & ~stbi__bmask[n]; + k &= stbi__bmask[n]; + j->code_bits -= n; + return k; +} + +stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j) { + unsigned int k; + if (j->code_bits < 1) + stbi__grow_buffer_unsafe(j); + if (j->code_bits < 1) + return 0; // ran out of bits from stream, return 0s intead of continuing + k = j->code_buffer; + j->code_buffer <<= 1; + --j->code_bits; + return k & 0x80000000; +} + +// given a value that's at position X in the zigzag stream, +// where does it appear in the 8x8 matrix coded as row-major? +static const stbi_uc stbi__jpeg_dezigzag[64 + 15] = { + 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, + 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, + 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63, + // let corrupt input sample past end + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63}; + +// decode one 64-entry block-- +static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, + stbi__huffman *hac, stbi__int16 *fac, int b, + stbi__uint16 *dequant) { + int diff, dc, k; + int t; + + if (j->code_bits < 16) + stbi__grow_buffer_unsafe(j); + t = stbi__jpeg_huff_decode(j, hdc); + if (t < 0 || t > 15) + return stbi__err("bad huffman code", "Corrupt JPEG"); + + // 0 all the ac values now so we can do it 32-bits at a time + memset(data, 0, 64 * sizeof(data[0])); + + diff = t ? stbi__extend_receive(j, t) : 0; + if (!stbi__addints_valid(j->img_comp[b].dc_pred, diff)) + return stbi__err("bad delta", "Corrupt JPEG"); + dc = j->img_comp[b].dc_pred + diff; + j->img_comp[b].dc_pred = dc; + if (!stbi__mul2shorts_valid(dc, dequant[0])) + return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + data[0] = (short)(dc * dequant[0]); + + // decode AC components, see JPEG spec + k = 1; + do { + unsigned int zig; + int c, r, s; + if (j->code_bits < 16) + stbi__grow_buffer_unsafe(j); + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS) - 1); + r = fac[c]; + if (r) { // fast-AC path + k += (r >> 4) & 15; // run + s = r & 15; // combined length + if (s > j->code_bits) + return stbi__err("bad huffman code", + "Combined length longer than code bits available"); + j->code_buffer <<= s; + j->code_bits -= s; + // decode into unzigzag'd location + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short)((r >> 8) * dequant[zig]); + } else { + int rs = stbi__jpeg_huff_decode(j, hac); + if (rs < 0) + return stbi__err("bad huffman code", "Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (rs != 0xf0) + break; // end block + k += 16; + } else { + k += r; + // decode into unzigzag'd location + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short)(stbi__extend_receive(j, s) * dequant[zig]); + } + } + } while (k < 64); + return 1; +} + +static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, + int b) { + int diff, dc; + int t; + if (j->spec_end != 0) + return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + + if (j->code_bits < 16) + stbi__grow_buffer_unsafe(j); + + if (j->succ_high == 0) { + // first scan for DC coefficient, must be first + memset(data, 0, 64 * sizeof(data[0])); // 0 all the ac values now + t = stbi__jpeg_huff_decode(j, hdc); + if (t < 0 || t > 15) + return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + diff = t ? stbi__extend_receive(j, t) : 0; + + if (!stbi__addints_valid(j->img_comp[b].dc_pred, diff)) + return stbi__err("bad delta", "Corrupt JPEG"); + dc = j->img_comp[b].dc_pred + diff; + j->img_comp[b].dc_pred = dc; + if (!stbi__mul2shorts_valid(dc, 1 << j->succ_low)) + return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + data[0] = (short)(dc * (1 << j->succ_low)); + } else { + // refinement scan for DC coefficient + if (stbi__jpeg_get_bit(j)) + data[0] += (short)(1 << j->succ_low); + } + return 1; +} + +// @OPTIMIZE: store non-zigzagged during the decode passes, +// and only de-zigzag when dequantizing +static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, + stbi__int16 *fac) { + int k; + if (j->spec_start == 0) + return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + + if (j->succ_high == 0) { + int shift = j->succ_low; + + if (j->eob_run) { + --j->eob_run; + return 1; + } + + k = j->spec_start; + do { + unsigned int zig; + int c, r, s; + if (j->code_bits < 16) + stbi__grow_buffer_unsafe(j); + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS) - 1); + r = fac[c]; + if (r) { // fast-AC path + k += (r >> 4) & 15; // run + s = r & 15; // combined length + if (s > j->code_bits) + return stbi__err("bad huffman code", + "Combined length longer than code bits available"); + j->code_buffer <<= s; + j->code_bits -= s; + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short)((r >> 8) * (1 << shift)); + } else { + int rs = stbi__jpeg_huff_decode(j, hac); + if (rs < 0) + return stbi__err("bad huffman code", "Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (r < 15) { + j->eob_run = (1 << r); + if (r) + j->eob_run += stbi__jpeg_get_bits(j, r); + --j->eob_run; + break; + } + k += 16; + } else { + k += r; + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short)(stbi__extend_receive(j, s) * (1 << shift)); + } + } + } while (k <= j->spec_end); + } else { + // refinement scan for these AC coefficients + + short bit = (short)(1 << j->succ_low); + + if (j->eob_run) { + --j->eob_run; + for (k = j->spec_start; k <= j->spec_end; ++k) { + short *p = &data[stbi__jpeg_dezigzag[k]]; + if (*p != 0) + if (stbi__jpeg_get_bit(j)) + if ((*p & bit) == 0) { + if (*p > 0) + *p += bit; + else + *p -= bit; + } + } + } else { + k = j->spec_start; + do { + int r, s; + int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast + // path here, advance-by-r is so slow, eh + if (rs < 0) + return stbi__err("bad huffman code", "Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (r < 15) { + j->eob_run = (1 << r) - 1; + if (r) + j->eob_run += stbi__jpeg_get_bits(j, r); + r = 64; // force end of block + } else { + // r=15 s=0 should write 16 0s, so we just do + // a run of 15 0s and then write s (which is 0), + // so we don't have to do anything special here + } + } else { + if (s != 1) + return stbi__err("bad huffman code", "Corrupt JPEG"); + // sign bit + if (stbi__jpeg_get_bit(j)) + s = bit; + else + s = -bit; + } + + // advance by r + while (k <= j->spec_end) { + short *p = &data[stbi__jpeg_dezigzag[k++]]; + if (*p != 0) { + if (stbi__jpeg_get_bit(j)) + if ((*p & bit) == 0) { + if (*p > 0) + *p += bit; + else + *p -= bit; + } + } else { + if (r == 0) { + *p = (short)s; + break; + } + --r; + } + } + } while (k <= j->spec_end); + } + } + return 1; +} + +// take a -128..127 value and stbi__clamp it and convert to 0..255 +stbi_inline static stbi_uc stbi__clamp(int x) { + // trick to use a single test to catch both cases + if ((unsigned int)x > 255) { + if (x < 0) + return 0; + if (x > 255) + return 255; + } + return (stbi_uc)x; +} + +#define stbi__f2f(x) ((int)(((x) * 4096 + 0.5))) +#define stbi__fsh(x) ((x) * 4096) + +// derived from jidctint -- DCT_ISLOW +#define STBI__IDCT_1D(s0, s1, s2, s3, s4, s5, s6, s7) \ + int t0, t1, t2, t3, p1, p2, p3, p4, p5, x0, x1, x2, x3; \ + p2 = s2; \ + p3 = s6; \ + p1 = (p2 + p3) * stbi__f2f(0.5411961f); \ + t2 = p1 + p3 * stbi__f2f(-1.847759065f); \ + t3 = p1 + p2 * stbi__f2f(0.765366865f); \ + p2 = s0; \ + p3 = s4; \ + t0 = stbi__fsh(p2 + p3); \ + t1 = stbi__fsh(p2 - p3); \ + x0 = t0 + t3; \ + x3 = t0 - t3; \ + x1 = t1 + t2; \ + x2 = t1 - t2; \ + t0 = s7; \ + t1 = s5; \ + t2 = s3; \ + t3 = s1; \ + p3 = t0 + t2; \ + p4 = t1 + t3; \ + p1 = t0 + t3; \ + p2 = t1 + t2; \ + p5 = (p3 + p4) * stbi__f2f(1.175875602f); \ + t0 = t0 * stbi__f2f(0.298631336f); \ + t1 = t1 * stbi__f2f(2.053119869f); \ + t2 = t2 * stbi__f2f(3.072711026f); \ + t3 = t3 * stbi__f2f(1.501321110f); \ + p1 = p5 + p1 * stbi__f2f(-0.899976223f); \ + p2 = p5 + p2 * stbi__f2f(-2.562915447f); \ + p3 = p3 * stbi__f2f(-1.961570560f); \ + p4 = p4 * stbi__f2f(-0.390180644f); \ + t3 += p1 + p4; \ + t2 += p2 + p3; \ + t1 += p2 + p4; \ + t0 += p1 + p3; + +static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64]) { + int i, val[64], *v = val; + stbi_uc *o; + short *d = data; + + // columns + for (i = 0; i < 8; ++i, ++d, ++v) { + // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing + if (d[8] == 0 && d[16] == 0 && d[24] == 0 && d[32] == 0 && d[40] == 0 && d[48] == 0 && + d[56] == 0) { + // no shortcut 0 seconds + // (1|2|3|4|5|6|7)==0 0 seconds + // all separate -0.047 seconds + // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds + int dcterm = d[0] * 4; + v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; + } else { + STBI__IDCT_1D(d[0], d[8], d[16], d[24], d[32], d[40], d[48], d[56]) + // constants scaled things up by 1<<12; let's bring them back + // down, but keep 2 extra bits of precision + x0 += 512; + x1 += 512; + x2 += 512; + x3 += 512; + v[0] = (x0 + t3) >> 10; + v[56] = (x0 - t3) >> 10; + v[8] = (x1 + t2) >> 10; + v[48] = (x1 - t2) >> 10; + v[16] = (x2 + t1) >> 10; + v[40] = (x2 - t1) >> 10; + v[24] = (x3 + t0) >> 10; + v[32] = (x3 - t0) >> 10; + } + } + + for (i = 0, v = val, o = out; i < 8; ++i, v += 8, o += out_stride) { + // no fast case since the first 1D IDCT spread components out + STBI__IDCT_1D(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]) + // constants scaled things up by 1<<12, plus we had 1<<2 from first + // loop, plus horizontal and vertical each scale by sqrt(8) so together + // we've got an extra 1<<3, so 1<<17 total we need to remove. + // so we want to round that, which means adding 0.5 * 1<<17, + // aka 65536. Also, we'll end up with -128 to 127 that we want + // to encode as 0..255 by adding 128, so we'll add that before the shift + x0 += 65536 + (128 << 17); + x1 += 65536 + (128 << 17); + x2 += 65536 + (128 << 17); + x3 += 65536 + (128 << 17); + // tried computing the shifts into temps, or'ing the temps to see + // if any were out of range, but that was slower + o[0] = stbi__clamp((x0 + t3) >> 17); + o[7] = stbi__clamp((x0 - t3) >> 17); + o[1] = stbi__clamp((x1 + t2) >> 17); + o[6] = stbi__clamp((x1 - t2) >> 17); + o[2] = stbi__clamp((x2 + t1) >> 17); + o[5] = stbi__clamp((x2 - t1) >> 17); + o[3] = stbi__clamp((x3 + t0) >> 17); + o[4] = stbi__clamp((x3 - t0) >> 17); + } +} + +#ifdef STBI_SSE2 +// sse2 integer IDCT. not the fastest possible implementation but it +// produces bit-identical results to the generic C version so it's +// fully "transparent". +static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) { + // This is constructed to match our regular (generic) integer IDCT exactly. + __m128i row0, row1, row2, row3, row4, row5, row6, row7; + __m128i tmp; + +// dot product constant: even elems=x, odd elems=y +#define dct_const(x, y) _mm_setr_epi16((x), (y), (x), (y), (x), (y), (x), (y)) + +// out(0) = c0[even]*x + c0[odd]*y (c0, x, y 16-bit, out 32-bit) +// out(1) = c1[even]*x + c1[odd]*y +#define dct_rot(out0, out1, x, y, c0, c1) \ + __m128i c0##lo = _mm_unpacklo_epi16((x), (y)); \ + __m128i c0##hi = _mm_unpackhi_epi16((x), (y)); \ + __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \ + __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \ + __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \ + __m128i out1##_h = _mm_madd_epi16(c0##hi, c1) + +// out = in << 12 (in 16-bit, out 32-bit) +#define dct_widen(out, in) \ + __m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \ + __m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4) + +// wide add +#define dct_wadd(out, a, b) \ + __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \ + __m128i out##_h = _mm_add_epi32(a##_h, b##_h) + +// wide sub +#define dct_wsub(out, a, b) \ + __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \ + __m128i out##_h = _mm_sub_epi32(a##_h, b##_h) + +// butterfly a/b, add bias, then shift by "s" and pack +#define dct_bfly32o(out0, out1, a, b, bias, s) \ + { \ + __m128i abiased_l = _mm_add_epi32(a##_l, bias); \ + __m128i abiased_h = _mm_add_epi32(a##_h, bias); \ + dct_wadd(sum, abiased, b); \ + dct_wsub(dif, abiased, b); \ + out0 = _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \ + out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \ + } + +// 8-bit interleave step (for transposes) +#define dct_interleave8(a, b) \ + tmp = a; \ + a = _mm_unpacklo_epi8(a, b); \ + b = _mm_unpackhi_epi8(tmp, b) + +// 16-bit interleave step (for transposes) +#define dct_interleave16(a, b) \ + tmp = a; \ + a = _mm_unpacklo_epi16(a, b); \ + b = _mm_unpackhi_epi16(tmp, b) + +#define dct_pass(bias, shift) \ + { \ + /* even part */ \ + dct_rot(t2e, t3e, row2, row6, rot0_0, rot0_1); \ + __m128i sum04 = _mm_add_epi16(row0, row4); \ + __m128i dif04 = _mm_sub_epi16(row0, row4); \ + dct_widen(t0e, sum04); \ + dct_widen(t1e, dif04); \ + dct_wadd(x0, t0e, t3e); \ + dct_wsub(x3, t0e, t3e); \ + dct_wadd(x1, t1e, t2e); \ + dct_wsub(x2, t1e, t2e); \ + /* odd part */ \ + dct_rot(y0o, y2o, row7, row3, rot2_0, rot2_1); \ + dct_rot(y1o, y3o, row5, row1, rot3_0, rot3_1); \ + __m128i sum17 = _mm_add_epi16(row1, row7); \ + __m128i sum35 = _mm_add_epi16(row3, row5); \ + dct_rot(y4o, y5o, sum17, sum35, rot1_0, rot1_1); \ + dct_wadd(x4, y0o, y4o); \ + dct_wadd(x5, y1o, y5o); \ + dct_wadd(x6, y2o, y5o); \ + dct_wadd(x7, y3o, y4o); \ + dct_bfly32o(row0, row7, x0, x7, bias, shift); \ + dct_bfly32o(row1, row6, x1, x6, bias, shift); \ + dct_bfly32o(row2, row5, x2, x5, bias, shift); \ + dct_bfly32o(row3, row4, x3, x4, bias, shift); \ + } + + __m128i rot0_0 = + dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f)); + __m128i rot0_1 = + dct_const(stbi__f2f(0.5411961f) + stbi__f2f(0.765366865f), stbi__f2f(0.5411961f)); + __m128i rot1_0 = + dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f)); + __m128i rot1_1 = + dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f)); + __m128i rot2_0 = + dct_const(stbi__f2f(-1.961570560f) + stbi__f2f(0.298631336f), stbi__f2f(-1.961570560f)); + __m128i rot2_1 = + dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f(3.072711026f)); + __m128i rot3_0 = + dct_const(stbi__f2f(-0.390180644f) + stbi__f2f(2.053119869f), stbi__f2f(-0.390180644f)); + __m128i rot3_1 = + dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f(1.501321110f)); + + // rounding biases in column/row passes, see stbi__idct_block for explanation. + __m128i bias_0 = _mm_set1_epi32(512); + __m128i bias_1 = _mm_set1_epi32(65536 + (128 << 17)); + + // load + row0 = _mm_load_si128((const __m128i *)(data + 0 * 8)); + row1 = _mm_load_si128((const __m128i *)(data + 1 * 8)); + row2 = _mm_load_si128((const __m128i *)(data + 2 * 8)); + row3 = _mm_load_si128((const __m128i *)(data + 3 * 8)); + row4 = _mm_load_si128((const __m128i *)(data + 4 * 8)); + row5 = _mm_load_si128((const __m128i *)(data + 5 * 8)); + row6 = _mm_load_si128((const __m128i *)(data + 6 * 8)); + row7 = _mm_load_si128((const __m128i *)(data + 7 * 8)); + + // column pass + dct_pass(bias_0, 10); + + { + // 16bit 8x8 transpose pass 1 + dct_interleave16(row0, row4); + dct_interleave16(row1, row5); + dct_interleave16(row2, row6); + dct_interleave16(row3, row7); + + // transpose pass 2 + dct_interleave16(row0, row2); + dct_interleave16(row1, row3); + dct_interleave16(row4, row6); + dct_interleave16(row5, row7); + + // transpose pass 3 + dct_interleave16(row0, row1); + dct_interleave16(row2, row3); + dct_interleave16(row4, row5); + dct_interleave16(row6, row7); + } + + // row pass + dct_pass(bias_1, 17); + + { + // pack + __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7 + __m128i p1 = _mm_packus_epi16(row2, row3); + __m128i p2 = _mm_packus_epi16(row4, row5); + __m128i p3 = _mm_packus_epi16(row6, row7); + + // 8bit 8x8 transpose pass 1 + dct_interleave8(p0, p2); // a0e0a1e1... + dct_interleave8(p1, p3); // c0g0c1g1... + + // transpose pass 2 + dct_interleave8(p0, p1); // a0c0e0g0... + dct_interleave8(p2, p3); // b0d0f0h0... + + // transpose pass 3 + dct_interleave8(p0, p2); // a0b0c0d0... + dct_interleave8(p1, p3); // a4b4c4d4... + + // store + _mm_storel_epi64((__m128i *)out, p0); + out += out_stride; + _mm_storel_epi64((__m128i *)out, _mm_shuffle_epi32(p0, 0x4e)); + out += out_stride; + _mm_storel_epi64((__m128i *)out, p2); + out += out_stride; + _mm_storel_epi64((__m128i *)out, _mm_shuffle_epi32(p2, 0x4e)); + out += out_stride; + _mm_storel_epi64((__m128i *)out, p1); + out += out_stride; + _mm_storel_epi64((__m128i *)out, _mm_shuffle_epi32(p1, 0x4e)); + out += out_stride; + _mm_storel_epi64((__m128i *)out, p3); + out += out_stride; + _mm_storel_epi64((__m128i *)out, _mm_shuffle_epi32(p3, 0x4e)); + } + +#undef dct_const +#undef dct_rot +#undef dct_widen +#undef dct_wadd +#undef dct_wsub +#undef dct_bfly32o +#undef dct_interleave8 +#undef dct_interleave16 +#undef dct_pass +} + +#endif // STBI_SSE2 + +#ifdef STBI_NEON + +// NEON integer IDCT. should produce bit-identical +// results to the generic C version. +static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) { + int16x8_t row0, row1, row2, row3, row4, row5, row6, row7; + + int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f)); + int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f)); + int16x4_t rot0_2 = vdup_n_s16(stbi__f2f(0.765366865f)); + int16x4_t rot1_0 = vdup_n_s16(stbi__f2f(1.175875602f)); + int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f)); + int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f)); + int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f)); + int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f)); + int16x4_t rot3_0 = vdup_n_s16(stbi__f2f(0.298631336f)); + int16x4_t rot3_1 = vdup_n_s16(stbi__f2f(2.053119869f)); + int16x4_t rot3_2 = vdup_n_s16(stbi__f2f(3.072711026f)); + int16x4_t rot3_3 = vdup_n_s16(stbi__f2f(1.501321110f)); + +#define dct_long_mul(out, inq, coeff) \ + int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \ + int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff) + +#define dct_long_mac(out, acc, inq, coeff) \ + int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \ + int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff) + +#define dct_widen(out, inq) \ + int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \ + int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12) + +// wide add +#define dct_wadd(out, a, b) \ + int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \ + int32x4_t out##_h = vaddq_s32(a##_h, b##_h) + +// wide sub +#define dct_wsub(out, a, b) \ + int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \ + int32x4_t out##_h = vsubq_s32(a##_h, b##_h) + +// butterfly a/b, then shift using "shiftop" by "s" and pack +#define dct_bfly32o(out0, out1, a, b, shiftop, s) \ + { \ + dct_wadd(sum, a, b); \ + dct_wsub(dif, a, b); \ + out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \ + out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \ + } + +#define dct_pass(shiftop, shift) \ + { \ + /* even part */ \ + int16x8_t sum26 = vaddq_s16(row2, row6); \ + dct_long_mul(p1e, sum26, rot0_0); \ + dct_long_mac(t2e, p1e, row6, rot0_1); \ + dct_long_mac(t3e, p1e, row2, rot0_2); \ + int16x8_t sum04 = vaddq_s16(row0, row4); \ + int16x8_t dif04 = vsubq_s16(row0, row4); \ + dct_widen(t0e, sum04); \ + dct_widen(t1e, dif04); \ + dct_wadd(x0, t0e, t3e); \ + dct_wsub(x3, t0e, t3e); \ + dct_wadd(x1, t1e, t2e); \ + dct_wsub(x2, t1e, t2e); \ + /* odd part */ \ + int16x8_t sum15 = vaddq_s16(row1, row5); \ + int16x8_t sum17 = vaddq_s16(row1, row7); \ + int16x8_t sum35 = vaddq_s16(row3, row5); \ + int16x8_t sum37 = vaddq_s16(row3, row7); \ + int16x8_t sumodd = vaddq_s16(sum17, sum35); \ + dct_long_mul(p5o, sumodd, rot1_0); \ + dct_long_mac(p1o, p5o, sum17, rot1_1); \ + dct_long_mac(p2o, p5o, sum35, rot1_2); \ + dct_long_mul(p3o, sum37, rot2_0); \ + dct_long_mul(p4o, sum15, rot2_1); \ + dct_wadd(sump13o, p1o, p3o); \ + dct_wadd(sump24o, p2o, p4o); \ + dct_wadd(sump23o, p2o, p3o); \ + dct_wadd(sump14o, p1o, p4o); \ + dct_long_mac(x4, sump13o, row7, rot3_0); \ + dct_long_mac(x5, sump24o, row5, rot3_1); \ + dct_long_mac(x6, sump23o, row3, rot3_2); \ + dct_long_mac(x7, sump14o, row1, rot3_3); \ + dct_bfly32o(row0, row7, x0, x7, shiftop, shift); \ + dct_bfly32o(row1, row6, x1, x6, shiftop, shift); \ + dct_bfly32o(row2, row5, x2, x5, shiftop, shift); \ + dct_bfly32o(row3, row4, x3, x4, shiftop, shift); \ + } + + // load + row0 = vld1q_s16(data + 0 * 8); + row1 = vld1q_s16(data + 1 * 8); + row2 = vld1q_s16(data + 2 * 8); + row3 = vld1q_s16(data + 3 * 8); + row4 = vld1q_s16(data + 4 * 8); + row5 = vld1q_s16(data + 5 * 8); + row6 = vld1q_s16(data + 6 * 8); + row7 = vld1q_s16(data + 7 * 8); + + // add DC bias + row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0)); + + // column pass + dct_pass(vrshrn_n_s32, 10); + + // 16bit 8x8 transpose + { +// these three map to a single VTRN.16, VTRN.32, and VSWP, respectively. +// whether compilers actually get this is another story, sadly. +#define dct_trn16(x, y) \ + { \ + int16x8x2_t t = vtrnq_s16(x, y); \ + x = t.val[0]; \ + y = t.val[1]; \ + } +#define dct_trn32(x, y) \ + { \ + int32x4x2_t t = vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); \ + x = vreinterpretq_s16_s32(t.val[0]); \ + y = vreinterpretq_s16_s32(t.val[1]); \ + } +#define dct_trn64(x, y) \ + { \ + int16x8_t x0 = x; \ + int16x8_t y0 = y; \ + x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); \ + y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); \ + } + + // pass 1 + dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6 + dct_trn16(row2, row3); + dct_trn16(row4, row5); + dct_trn16(row6, row7); + + // pass 2 + dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4 + dct_trn32(row1, row3); + dct_trn32(row4, row6); + dct_trn32(row5, row7); + + // pass 3 + dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0 + dct_trn64(row1, row5); + dct_trn64(row2, row6); + dct_trn64(row3, row7); + +#undef dct_trn16 +#undef dct_trn32 +#undef dct_trn64 + } + + // row pass + // vrshrn_n_s32 only supports shifts up to 16, we need + // 17. so do a non-rounding shift of 16 first then follow + // up with a rounding shift by 1. + dct_pass(vshrn_n_s32, 16); + + { + // pack and round + uint8x8_t p0 = vqrshrun_n_s16(row0, 1); + uint8x8_t p1 = vqrshrun_n_s16(row1, 1); + uint8x8_t p2 = vqrshrun_n_s16(row2, 1); + uint8x8_t p3 = vqrshrun_n_s16(row3, 1); + uint8x8_t p4 = vqrshrun_n_s16(row4, 1); + uint8x8_t p5 = vqrshrun_n_s16(row5, 1); + uint8x8_t p6 = vqrshrun_n_s16(row6, 1); + uint8x8_t p7 = vqrshrun_n_s16(row7, 1); + + // again, these can translate into one instruction, but often don't. +#define dct_trn8_8(x, y) \ + { \ + uint8x8x2_t t = vtrn_u8(x, y); \ + x = t.val[0]; \ + y = t.val[1]; \ + } +#define dct_trn8_16(x, y) \ + { \ + uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); \ + x = vreinterpret_u8_u16(t.val[0]); \ + y = vreinterpret_u8_u16(t.val[1]); \ + } +#define dct_trn8_32(x, y) \ + { \ + uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); \ + x = vreinterpret_u8_u32(t.val[0]); \ + y = vreinterpret_u8_u32(t.val[1]); \ + } + + // sadly can't use interleaved stores here since we only write + // 8 bytes to each scan line! + + // 8x8 8-bit transpose pass 1 + dct_trn8_8(p0, p1); + dct_trn8_8(p2, p3); + dct_trn8_8(p4, p5); + dct_trn8_8(p6, p7); + + // pass 2 + dct_trn8_16(p0, p2); + dct_trn8_16(p1, p3); + dct_trn8_16(p4, p6); + dct_trn8_16(p5, p7); + + // pass 3 + dct_trn8_32(p0, p4); + dct_trn8_32(p1, p5); + dct_trn8_32(p2, p6); + dct_trn8_32(p3, p7); + + // store + vst1_u8(out, p0); + out += out_stride; + vst1_u8(out, p1); + out += out_stride; + vst1_u8(out, p2); + out += out_stride; + vst1_u8(out, p3); + out += out_stride; + vst1_u8(out, p4); + out += out_stride; + vst1_u8(out, p5); + out += out_stride; + vst1_u8(out, p6); + out += out_stride; + vst1_u8(out, p7); + +#undef dct_trn8_8 +#undef dct_trn8_16 +#undef dct_trn8_32 + } + +#undef dct_long_mul +#undef dct_long_mac +#undef dct_widen +#undef dct_wadd +#undef dct_wsub +#undef dct_bfly32o +#undef dct_pass +} + +#endif // STBI_NEON + +#define STBI__MARKER_none 0xff +// if there's a pending marker from the entropy stream, return that +// otherwise, fetch from the stream and get a marker. if there's no +// marker, return 0xff, which is never a valid marker value +static stbi_uc stbi__get_marker(stbi__jpeg *j) { + stbi_uc x; + if (j->marker != STBI__MARKER_none) { + x = j->marker; + j->marker = STBI__MARKER_none; + return x; + } + x = stbi__get8(j->s); + if (x != 0xff) + return STBI__MARKER_none; + while (x == 0xff) + x = stbi__get8(j->s); // consume repeated 0xff fill bytes + return x; +} + +// in each scan, we'll have scan_n components, and the order +// of the components is specified by order[] +#define STBI__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) + +// after a restart interval, stbi__jpeg_reset the entropy decoder and +// the dc prediction +static void stbi__jpeg_reset(stbi__jpeg *j) { + j->code_bits = 0; + j->code_buffer = 0; + j->nomore = 0; + j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = + j->img_comp[3].dc_pred = 0; + j->marker = STBI__MARKER_none; + j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; + j->eob_run = 0; + // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, + // since we don't even allow 1<<30 pixels +} + +static int stbi__parse_entropy_coded_data(stbi__jpeg *z) { + stbi__jpeg_reset(z); + if (!z->progressive) { + if (z->scan_n == 1) { + int i, j; + STBI_SIMD_ALIGN(short, data[64]); + int n = z->order[0]; + // non-interleaved data, we just need to process one block at a time, + // in trivial scanline order + // number of blocks to do just depends on how many actual "pixels" this + // component has, independent of interleaved MCU blocking and such + int w = (z->img_comp[n].x + 7) >> 3; + int h = (z->img_comp[n].y + 7) >> 3; + for (j = 0; j < h; ++j) { + for (i = 0; i < w; ++i) { + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block(z, data, z->huff_dc + z->img_comp[n].hd, + z->huff_ac + ha, z->fast_ac[ha], n, + z->dequant[z->img_comp[n].tq])) + return 0; + z->idct_block_kernel(z->img_comp[n].data + z->img_comp[n].w2 * j * 8 + i * 8, + z->img_comp[n].w2, data); + // every data block is an MCU, so countdown the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) + stbi__grow_buffer_unsafe(z); + // if it's NOT a restart, then just bail, so we get corrupt data + // rather than no data + if (!STBI__RESTART(z->marker)) + return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } else { // interleaved + int i, j, k, x, y; + STBI_SIMD_ALIGN(short, data[64]); + for (j = 0; j < z->img_mcu_y; ++j) { + for (i = 0; i < z->img_mcu_x; ++i) { + // scan an interleaved mcu... process scan_n components in order + for (k = 0; k < z->scan_n; ++k) { + int n = z->order[k]; + // scan out an mcu's worth of this component; that's just determined + // by the basic H and V specified for the component + for (y = 0; y < z->img_comp[n].v; ++y) { + for (x = 0; x < z->img_comp[n].h; ++x) { + int x2 = (i * z->img_comp[n].h + x) * 8; + int y2 = (j * z->img_comp[n].v + y) * 8; + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block( + z, data, z->huff_dc + z->img_comp[n].hd, z->huff_ac + ha, + z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) + return 0; + z->idct_block_kernel(z->img_comp[n].data + z->img_comp[n].w2 * y2 + + x2, + z->img_comp[n].w2, data); + } + } + } + // after all interleaved components, that's an interleaved MCU, + // so now count down the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) + stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) + return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } + } else { + if (z->scan_n == 1) { + int i, j; + int n = z->order[0]; + // non-interleaved data, we just need to process one block at a time, + // in trivial scanline order + // number of blocks to do just depends on how many actual "pixels" this + // component has, independent of interleaved MCU blocking and such + int w = (z->img_comp[n].x + 7) >> 3; + int h = (z->img_comp[n].y + 7) >> 3; + for (j = 0; j < h; ++j) { + for (i = 0; i < w; ++i) { + short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); + if (z->spec_start == 0) { + if (!stbi__jpeg_decode_block_prog_dc(z, data, + &z->huff_dc[z->img_comp[n].hd], n)) + return 0; + } else { + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], + z->fast_ac[ha])) + return 0; + } + // every data block is an MCU, so countdown the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) + stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) + return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } else { // interleaved + int i, j, k, x, y; + for (j = 0; j < z->img_mcu_y; ++j) { + for (i = 0; i < z->img_mcu_x; ++i) { + // scan an interleaved mcu... process scan_n components in order + for (k = 0; k < z->scan_n; ++k) { + int n = z->order[k]; + // scan out an mcu's worth of this component; that's just determined + // by the basic H and V specified for the component + for (y = 0; y < z->img_comp[n].v; ++y) { + for (x = 0; x < z->img_comp[n].h; ++x) { + int x2 = (i * z->img_comp[n].h + x); + int y2 = (j * z->img_comp[n].v + y); + short *data = + z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w); + if (!stbi__jpeg_decode_block_prog_dc( + z, data, &z->huff_dc[z->img_comp[n].hd], n)) + return 0; + } + } + } + // after all interleaved components, that's an interleaved MCU, + // so now count down the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) + stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) + return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } + } +} + +static void stbi__jpeg_dequantize(short *data, stbi__uint16 *dequant) { + int i; + for (i = 0; i < 64; ++i) + data[i] *= dequant[i]; +} + +static void stbi__jpeg_finish(stbi__jpeg *z) { + if (z->progressive) { + // dequantize and idct the data + int i, j, n; + for (n = 0; n < z->s->img_n; ++n) { + int w = (z->img_comp[n].x + 7) >> 3; + int h = (z->img_comp[n].y + 7) >> 3; + for (j = 0; j < h; ++j) { + for (i = 0; i < w; ++i) { + short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); + stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]); + z->idct_block_kernel(z->img_comp[n].data + z->img_comp[n].w2 * j * 8 + i * 8, + z->img_comp[n].w2, data); + } + } + } + } +} + +static int stbi__process_marker(stbi__jpeg *z, int m) { + int L; + switch (m) { + case STBI__MARKER_none: // no marker found + return stbi__err("expected marker", "Corrupt JPEG"); + + case 0xDD: // DRI - specify restart interval + if (stbi__get16be(z->s) != 4) + return stbi__err("bad DRI len", "Corrupt JPEG"); + z->restart_interval = stbi__get16be(z->s); + return 1; + + case 0xDB: // DQT - define quantization table + L = stbi__get16be(z->s) - 2; + while (L > 0) { + int q = stbi__get8(z->s); + int p = q >> 4, sixteen = (p != 0); + int t = q & 15, i; + if (p != 0 && p != 1) + return stbi__err("bad DQT type", "Corrupt JPEG"); + if (t > 3) + return stbi__err("bad DQT table", "Corrupt JPEG"); + + for (i = 0; i < 64; ++i) + z->dequant[t][stbi__jpeg_dezigzag[i]] = + (stbi__uint16)(sixteen ? stbi__get16be(z->s) : stbi__get8(z->s)); + L -= (sixteen ? 129 : 65); + } + return L == 0; + + case 0xC4: // DHT - define huffman table + L = stbi__get16be(z->s) - 2; + while (L > 0) { + stbi_uc *v; + int sizes[16], i, n = 0; + int q = stbi__get8(z->s); + int tc = q >> 4; + int th = q & 15; + if (tc > 1 || th > 3) + return stbi__err("bad DHT header", "Corrupt JPEG"); + for (i = 0; i < 16; ++i) { + sizes[i] = stbi__get8(z->s); + n += sizes[i]; + } + if (n > 256) + return stbi__err( + "bad DHT header", + "Corrupt JPEG"); // Loop over i < n would write past end of values! + L -= 17; + if (tc == 0) { + if (!stbi__build_huffman(z->huff_dc + th, sizes)) + return 0; + v = z->huff_dc[th].values; + } else { + if (!stbi__build_huffman(z->huff_ac + th, sizes)) + return 0; + v = z->huff_ac[th].values; + } + for (i = 0; i < n; ++i) + v[i] = stbi__get8(z->s); + if (tc != 0) + stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th); + L -= n; + } + return L == 0; + } + + // check for comment block or APP blocks + if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { + L = stbi__get16be(z->s); + if (L < 2) { + if (m == 0xFE) + return stbi__err("bad COM len", "Corrupt JPEG"); + else + return stbi__err("bad APP len", "Corrupt JPEG"); + } + L -= 2; + + if (m == 0xE0 && L >= 5) { // JFIF APP0 segment + static const unsigned char tag[5] = {'J', 'F', 'I', 'F', '\0'}; + int ok = 1; + int i; + for (i = 0; i < 5; ++i) + if (stbi__get8(z->s) != tag[i]) + ok = 0; + L -= 5; + if (ok) + z->jfif = 1; + } else if (m == 0xEE && L >= 12) { // Adobe APP14 segment + static const unsigned char tag[6] = {'A', 'd', 'o', 'b', 'e', '\0'}; + int ok = 1; + int i; + for (i = 0; i < 6; ++i) + if (stbi__get8(z->s) != tag[i]) + ok = 0; + L -= 6; + if (ok) { + stbi__get8(z->s); // version + stbi__get16be(z->s); // flags0 + stbi__get16be(z->s); // flags1 + z->app14_color_transform = stbi__get8(z->s); // color transform + L -= 6; + } + } + + stbi__skip(z->s, L); + return 1; + } + + return stbi__err("unknown marker", "Corrupt JPEG"); +} + +// after we see SOS +static int stbi__process_scan_header(stbi__jpeg *z) { + int i; + int Ls = stbi__get16be(z->s); + z->scan_n = stbi__get8(z->s); + if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int)z->s->img_n) + return stbi__err("bad SOS component count", "Corrupt JPEG"); + if (Ls != 6 + 2 * z->scan_n) + return stbi__err("bad SOS len", "Corrupt JPEG"); + for (i = 0; i < z->scan_n; ++i) { + int id = stbi__get8(z->s), which; + int q = stbi__get8(z->s); + for (which = 0; which < z->s->img_n; ++which) + if (z->img_comp[which].id == id) + break; + if (which == z->s->img_n) + return 0; // no match + z->img_comp[which].hd = q >> 4; + if (z->img_comp[which].hd > 3) + return stbi__err("bad DC huff", "Corrupt JPEG"); + z->img_comp[which].ha = q & 15; + if (z->img_comp[which].ha > 3) + return stbi__err("bad AC huff", "Corrupt JPEG"); + z->order[i] = which; + } + + { + int aa; + z->spec_start = stbi__get8(z->s); + z->spec_end = stbi__get8(z->s); // should be 63, but might be 0 + aa = stbi__get8(z->s); + z->succ_high = (aa >> 4); + z->succ_low = (aa & 15); + if (z->progressive) { + if (z->spec_start > 63 || z->spec_end > 63 || z->spec_start > z->spec_end || + z->succ_high > 13 || z->succ_low > 13) + return stbi__err("bad SOS", "Corrupt JPEG"); + } else { + if (z->spec_start != 0) + return stbi__err("bad SOS", "Corrupt JPEG"); + if (z->succ_high != 0 || z->succ_low != 0) + return stbi__err("bad SOS", "Corrupt JPEG"); + z->spec_end = 63; + } + } + + return 1; +} + +static int stbi__free_jpeg_components(stbi__jpeg *z, int ncomp, int why) { + int i; + for (i = 0; i < ncomp; ++i) { + if (z->img_comp[i].raw_data) { + STBI_FREE(z->img_comp[i].raw_data); + z->img_comp[i].raw_data = NULL; + z->img_comp[i].data = NULL; + } + if (z->img_comp[i].raw_coeff) { + STBI_FREE(z->img_comp[i].raw_coeff); + z->img_comp[i].raw_coeff = 0; + z->img_comp[i].coeff = 0; + } + if (z->img_comp[i].linebuf) { + STBI_FREE(z->img_comp[i].linebuf); + z->img_comp[i].linebuf = NULL; + } + } + return why; +} + +static int stbi__process_frame_header(stbi__jpeg *z, int scan) { + stbi__context *s = z->s; + int Lf, p, i, q, h_max = 1, v_max = 1, c; + Lf = stbi__get16be(s); + if (Lf < 11) + return stbi__err("bad SOF len", "Corrupt JPEG"); // JPEG + p = stbi__get8(s); + if (p != 8) + return stbi__err("only 8-bit", "JPEG format not supported: 8-bit only"); // JPEG baseline + s->img_y = stbi__get16be(s); + if (s->img_y == 0) + return stbi__err( + "no header height", + "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but + // neither does IJG + s->img_x = stbi__get16be(s); + if (s->img_x == 0) + return stbi__err("0 width", "Corrupt JPEG"); // JPEG requires + if (s->img_y > STBI_MAX_DIMENSIONS) + return stbi__err("too large", "Very large image (corrupt?)"); + if (s->img_x > STBI_MAX_DIMENSIONS) + return stbi__err("too large", "Very large image (corrupt?)"); + c = stbi__get8(s); + if (c != 3 && c != 1 && c != 4) + return stbi__err("bad component count", "Corrupt JPEG"); + s->img_n = c; + for (i = 0; i < c; ++i) { + z->img_comp[i].data = NULL; + z->img_comp[i].linebuf = NULL; + } + + if (Lf != 8 + 3 * s->img_n) + return stbi__err("bad SOF len", "Corrupt JPEG"); + + z->rgb = 0; + for (i = 0; i < s->img_n; ++i) { + static const unsigned char rgb[3] = {'R', 'G', 'B'}; + z->img_comp[i].id = stbi__get8(s); + if (s->img_n == 3 && z->img_comp[i].id == rgb[i]) + ++z->rgb; + q = stbi__get8(s); + z->img_comp[i].h = (q >> 4); + if (!z->img_comp[i].h || z->img_comp[i].h > 4) + return stbi__err("bad H", "Corrupt JPEG"); + z->img_comp[i].v = q & 15; + if (!z->img_comp[i].v || z->img_comp[i].v > 4) + return stbi__err("bad V", "Corrupt JPEG"); + z->img_comp[i].tq = stbi__get8(s); + if (z->img_comp[i].tq > 3) + return stbi__err("bad TQ", "Corrupt JPEG"); + } + + if (scan != STBI__SCAN_load) + return 1; + + if (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) + return stbi__err("too large", "Image too large to decode"); + + for (i = 0; i < s->img_n; ++i) { + if (z->img_comp[i].h > h_max) + h_max = z->img_comp[i].h; + if (z->img_comp[i].v > v_max) + v_max = z->img_comp[i].v; + } + + // check that plane subsampling factors are integer ratios; our resamplers can't deal with + // fractional ratios and I've never seen a non-corrupted JPEG file actually use them + for (i = 0; i < s->img_n; ++i) { + if (h_max % z->img_comp[i].h != 0) + return stbi__err("bad H", "Corrupt JPEG"); + if (v_max % z->img_comp[i].v != 0) + return stbi__err("bad V", "Corrupt JPEG"); + } + + // compute interleaved mcu info + z->img_h_max = h_max; + z->img_v_max = v_max; + z->img_mcu_w = h_max * 8; + z->img_mcu_h = v_max * 8; + // these sizes can't be more than 17 bits + z->img_mcu_x = (s->img_x + z->img_mcu_w - 1) / z->img_mcu_w; + z->img_mcu_y = (s->img_y + z->img_mcu_h - 1) / z->img_mcu_h; + + for (i = 0; i < s->img_n; ++i) { + // number of effective pixels (e.g. for non-interleaved MCU) + z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max - 1) / h_max; + z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max - 1) / v_max; + // to simplify generation, we'll allocate enough memory to decode + // the bogus oversized data from using interleaved MCUs and their + // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't + // discard the extra data until colorspace conversion + // + // img_mcu_x, img_mcu_y: <=17 bits; comp[i].h and .v are <=4 (checked earlier) + // so these muls can't overflow with 32-bit ints (which we require) + z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; + z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; + z->img_comp[i].coeff = 0; + z->img_comp[i].raw_coeff = 0; + z->img_comp[i].linebuf = NULL; + z->img_comp[i].raw_data = stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15); + if (z->img_comp[i].raw_data == NULL) + return stbi__free_jpeg_components(z, i + 1, stbi__err("outofmem", "Out of memory")); + // align blocks for idct using mmx/sse + z->img_comp[i].data = (stbi_uc *)(((size_t)z->img_comp[i].raw_data + 15) & ~15); + if (z->progressive) { + // w2, h2 are multiples of 8 (see above) + z->img_comp[i].coeff_w = z->img_comp[i].w2 / 8; + z->img_comp[i].coeff_h = z->img_comp[i].h2 / 8; + z->img_comp[i].raw_coeff = + stbi__malloc_mad3(z->img_comp[i].w2, z->img_comp[i].h2, sizeof(short), 15); + if (z->img_comp[i].raw_coeff == NULL) + return stbi__free_jpeg_components(z, i + 1, stbi__err("outofmem", "Out of memory")); + z->img_comp[i].coeff = (short *)(((size_t)z->img_comp[i].raw_coeff + 15) & ~15); + } + } + + return 1; +} + +// use comparisons since in some cases we handle more than one case (e.g. SOF) +#define stbi__DNL(x) ((x) == 0xdc) +#define stbi__SOI(x) ((x) == 0xd8) +#define stbi__EOI(x) ((x) == 0xd9) +#define stbi__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) +#define stbi__SOS(x) ((x) == 0xda) + +#define stbi__SOF_progressive(x) ((x) == 0xc2) + +static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) { + int m; + z->jfif = 0; + z->app14_color_transform = -1; // valid values are 0,1,2 + z->marker = STBI__MARKER_none; // initialize cached marker to empty + m = stbi__get_marker(z); + if (!stbi__SOI(m)) + return stbi__err("no SOI", "Corrupt JPEG"); + if (scan == STBI__SCAN_type) + return 1; + m = stbi__get_marker(z); + while (!stbi__SOF(m)) { + if (!stbi__process_marker(z, m)) + return 0; + m = stbi__get_marker(z); + while (m == STBI__MARKER_none) { + // some files have extra padding after their blocks, so ok, we'll scan + if (stbi__at_eof(z->s)) + return stbi__err("no SOF", "Corrupt JPEG"); + m = stbi__get_marker(z); + } + } + z->progressive = stbi__SOF_progressive(m); + if (!stbi__process_frame_header(z, scan)) + return 0; + return 1; +} + +static stbi_uc stbi__skip_jpeg_junk_at_end(stbi__jpeg *j) { + // some JPEGs have junk at end, skip over it but if we find what looks + // like a valid marker, resume there + while (!stbi__at_eof(j->s)) { + stbi_uc x = stbi__get8(j->s); + while (x == 0xff) { // might be a marker + if (stbi__at_eof(j->s)) + return STBI__MARKER_none; + x = stbi__get8(j->s); + if (x != 0x00 && x != 0xff) { + // not a stuffed zero or lead-in to another marker, looks + // like an actual marker, return it + return x; + } + // stuffed zero has x=0 now which ends the loop, meaning we go + // back to regular scan loop. + // repeated 0xff keeps trying to read the next byte of the marker. + } + } + return STBI__MARKER_none; +} + +// decode image to YCbCr format +static int stbi__decode_jpeg_image(stbi__jpeg *j) { + int m; + for (m = 0; m < 4; m++) { + j->img_comp[m].raw_data = NULL; + j->img_comp[m].raw_coeff = NULL; + } + j->restart_interval = 0; + if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) + return 0; + m = stbi__get_marker(j); + while (!stbi__EOI(m)) { + if (stbi__SOS(m)) { + if (!stbi__process_scan_header(j)) + return 0; + if (!stbi__parse_entropy_coded_data(j)) + return 0; + if (j->marker == STBI__MARKER_none) { + j->marker = stbi__skip_jpeg_junk_at_end(j); + // if we reach eof without hitting a marker, stbi__get_marker() below will fail and + // we'll eventually return 0 + } + m = stbi__get_marker(j); + if (STBI__RESTART(m)) + m = stbi__get_marker(j); + } else if (stbi__DNL(m)) { + int Ld = stbi__get16be(j->s); + stbi__uint32 NL = stbi__get16be(j->s); + if (Ld != 4) + return stbi__err("bad DNL len", "Corrupt JPEG"); + if (NL != j->s->img_y) + return stbi__err("bad DNL height", "Corrupt JPEG"); + m = stbi__get_marker(j); + } else { + if (!stbi__process_marker(j, m)) + return 1; + m = stbi__get_marker(j); + } + } + if (j->progressive) + stbi__jpeg_finish(j); + return 1; +} + +// static jfif-centered resampling (across block boundaries) + +typedef stbi_uc *(*resample_row_func)(stbi_uc *out, stbi_uc *in0, stbi_uc *in1, int w, int hs); + +#define stbi__div4(x) ((stbi_uc)((x) >> 2)) + +static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { + STBI_NOTUSED(out); + STBI_NOTUSED(in_far); + STBI_NOTUSED(w); + STBI_NOTUSED(hs); + return in_near; +} + +static stbi_uc *stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, + int hs) { + // need to generate two samples vertically for every one in input + int i; + STBI_NOTUSED(hs); + for (i = 0; i < w; ++i) + out[i] = stbi__div4(3 * in_near[i] + in_far[i] + 2); + return out; +} + +static stbi_uc *stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, + int hs) { + // need to generate two samples horizontally for every one in input + int i; + stbi_uc *input = in_near; + + if (w == 1) { + // if only one sample, can't do any interpolation + out[0] = out[1] = input[0]; + return out; + } + + out[0] = input[0]; + out[1] = stbi__div4(input[0] * 3 + input[1] + 2); + for (i = 1; i < w - 1; ++i) { + int n = 3 * input[i] + 2; + out[i * 2 + 0] = stbi__div4(n + input[i - 1]); + out[i * 2 + 1] = stbi__div4(n + input[i + 1]); + } + out[i * 2 + 0] = stbi__div4(input[w - 2] * 3 + input[w - 1] + 2); + out[i * 2 + 1] = input[w - 1]; + + STBI_NOTUSED(in_far); + STBI_NOTUSED(hs); + + return out; +} + +#define stbi__div16(x) ((stbi_uc)((x) >> 4)) + +static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, + int hs) { + // need to generate 2x2 samples for every one in input + int i, t0, t1; + if (w == 1) { + out[0] = out[1] = stbi__div4(3 * in_near[0] + in_far[0] + 2); + return out; + } + + t1 = 3 * in_near[0] + in_far[0]; + out[0] = stbi__div4(t1 + 2); + for (i = 1; i < w; ++i) { + t0 = t1; + t1 = 3 * in_near[i] + in_far[i]; + out[i * 2 - 1] = stbi__div16(3 * t0 + t1 + 8); + out[i * 2] = stbi__div16(3 * t1 + t0 + 8); + } + out[w * 2 - 1] = stbi__div4(t1 + 2); + + STBI_NOTUSED(hs); + + return out; +} + +#if defined(STBI_SSE2) || defined(STBI_NEON) +static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, + int hs) { + // need to generate 2x2 samples for every one in input + int i = 0, t0, t1; + + if (w == 1) { + out[0] = out[1] = stbi__div4(3 * in_near[0] + in_far[0] + 2); + return out; + } + + t1 = 3 * in_near[0] + in_far[0]; + // process groups of 8 pixels for as long as we can. + // note we can't handle the last pixel in a row in this loop + // because we need to handle the filter boundary conditions. + for (; i < ((w - 1) & ~7); i += 8) { +#if defined(STBI_SSE2) + // load and perform the vertical filtering pass + // this uses 3*x + y = 4*x + (y - x) + __m128i zero = _mm_setzero_si128(); + __m128i farb = _mm_loadl_epi64((__m128i *)(in_far + i)); + __m128i nearb = _mm_loadl_epi64((__m128i *)(in_near + i)); + __m128i farw = _mm_unpacklo_epi8(farb, zero); + __m128i nearw = _mm_unpacklo_epi8(nearb, zero); + __m128i diff = _mm_sub_epi16(farw, nearw); + __m128i nears = _mm_slli_epi16(nearw, 2); + __m128i curr = _mm_add_epi16(nears, diff); // current row + + // horizontal filter works the same based on shifted vers of current + // row. "prev" is current row shifted right by 1 pixel; we need to + // insert the previous pixel value (from t1). + // "next" is current row shifted left by 1 pixel, with first pixel + // of next block of 8 pixels added in. + __m128i prv0 = _mm_slli_si128(curr, 2); + __m128i nxt0 = _mm_srli_si128(curr, 2); + __m128i prev = _mm_insert_epi16(prv0, t1, 0); + __m128i next = _mm_insert_epi16(nxt0, 3 * in_near[i + 8] + in_far[i + 8], 7); + + // horizontal filter, polyphase implementation since it's convenient: + // even pixels = 3*cur + prev = cur*4 + (prev - cur) + // odd pixels = 3*cur + next = cur*4 + (next - cur) + // note the shared term. + __m128i bias = _mm_set1_epi16(8); + __m128i curs = _mm_slli_epi16(curr, 2); + __m128i prvd = _mm_sub_epi16(prev, curr); + __m128i nxtd = _mm_sub_epi16(next, curr); + __m128i curb = _mm_add_epi16(curs, bias); + __m128i even = _mm_add_epi16(prvd, curb); + __m128i odd = _mm_add_epi16(nxtd, curb); + + // interleave even and odd pixels, then undo scaling. + __m128i int0 = _mm_unpacklo_epi16(even, odd); + __m128i int1 = _mm_unpackhi_epi16(even, odd); + __m128i de0 = _mm_srli_epi16(int0, 4); + __m128i de1 = _mm_srli_epi16(int1, 4); + + // pack and write output + __m128i outv = _mm_packus_epi16(de0, de1); + _mm_storeu_si128((__m128i *)(out + i * 2), outv); +#elif defined(STBI_NEON) + // load and perform the vertical filtering pass + // this uses 3*x + y = 4*x + (y - x) + uint8x8_t farb = vld1_u8(in_far + i); + uint8x8_t nearb = vld1_u8(in_near + i); + int16x8_t diff = vreinterpretq_s16_u16(vsubl_u8(farb, nearb)); + int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2)); + int16x8_t curr = vaddq_s16(nears, diff); // current row + + // horizontal filter works the same based on shifted vers of current + // row. "prev" is current row shifted right by 1 pixel; we need to + // insert the previous pixel value (from t1). + // "next" is current row shifted left by 1 pixel, with first pixel + // of next block of 8 pixels added in. + int16x8_t prv0 = vextq_s16(curr, curr, 7); + int16x8_t nxt0 = vextq_s16(curr, curr, 1); + int16x8_t prev = vsetq_lane_s16(t1, prv0, 0); + int16x8_t next = vsetq_lane_s16(3 * in_near[i + 8] + in_far[i + 8], nxt0, 7); + + // horizontal filter, polyphase implementation since it's convenient: + // even pixels = 3*cur + prev = cur*4 + (prev - cur) + // odd pixels = 3*cur + next = cur*4 + (next - cur) + // note the shared term. + int16x8_t curs = vshlq_n_s16(curr, 2); + int16x8_t prvd = vsubq_s16(prev, curr); + int16x8_t nxtd = vsubq_s16(next, curr); + int16x8_t even = vaddq_s16(curs, prvd); + int16x8_t odd = vaddq_s16(curs, nxtd); + + // undo scaling and round, then store with even/odd phases interleaved + uint8x8x2_t o; + o.val[0] = vqrshrun_n_s16(even, 4); + o.val[1] = vqrshrun_n_s16(odd, 4); + vst2_u8(out + i * 2, o); +#endif + + // "previous" value for next iter + t1 = 3 * in_near[i + 7] + in_far[i + 7]; + } + + t0 = t1; + t1 = 3 * in_near[i] + in_far[i]; + out[i * 2] = stbi__div16(3 * t1 + t0 + 8); + + for (++i; i < w; ++i) { + t0 = t1; + t1 = 3 * in_near[i] + in_far[i]; + out[i * 2 - 1] = stbi__div16(3 * t0 + t1 + 8); + out[i * 2] = stbi__div16(3 * t1 + t0 + 8); + } + out[w * 2 - 1] = stbi__div4(t1 + 2); + + STBI_NOTUSED(hs); + + return out; +} +#endif + +static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, + int hs) { + // resample with nearest-neighbor + int i, j; + STBI_NOTUSED(in_far); + for (i = 0; i < w; ++i) + for (j = 0; j < hs; ++j) + out[i * hs + j] = in_near[i]; + return out; +} + +// this is a reduced-precision calculation of YCbCr-to-RGB introduced +// to make sure the code produces the same results in both SIMD and scalar +#define stbi__float2fixed(x) (((int)((x) * 4096.0f + 0.5f)) << 8) +static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, + const stbi_uc *pcr, int count, int step) { + int i; + for (i = 0; i < count; ++i) { + int y_fixed = (y[i] << 20) + (1 << 19); // rounding + int r, g, b; + int cr = pcr[i] - 128; + int cb = pcb[i] - 128; + r = y_fixed + cr * stbi__float2fixed(1.40200f); + g = y_fixed + (cr * -stbi__float2fixed(0.71414f)) + + ((cb * -stbi__float2fixed(0.34414f)) & 0xffff0000); + b = y_fixed + cb * stbi__float2fixed(1.77200f); + r >>= 20; + g >>= 20; + b >>= 20; + if ((unsigned)r > 255) { + if (r < 0) + r = 0; + else + r = 255; + } + if ((unsigned)g > 255) { + if (g < 0) + g = 0; + else + g = 255; + } + if ((unsigned)b > 255) { + if (b < 0) + b = 0; + else + b = 255; + } + out[0] = (stbi_uc)r; + out[1] = (stbi_uc)g; + out[2] = (stbi_uc)b; + out[3] = 255; + out += step; + } +} + +#if defined(STBI_SSE2) || defined(STBI_NEON) +static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, + stbi_uc const *pcr, int count, int step) { + int i = 0; + +#ifdef STBI_SSE2 + // step == 3 is pretty ugly on the final interleave, and i'm not convinced + // it's useful in practice (you wouldn't use it for textures, for example). + // so just accelerate step == 4 case. + if (step == 4) { + // this is a fairly straightforward implementation and not super-optimized. + __m128i signflip = _mm_set1_epi8(-0x80); + __m128i cr_const0 = _mm_set1_epi16((short)(1.40200f * 4096.0f + 0.5f)); + __m128i cr_const1 = _mm_set1_epi16(-(short)(0.71414f * 4096.0f + 0.5f)); + __m128i cb_const0 = _mm_set1_epi16(-(short)(0.34414f * 4096.0f + 0.5f)); + __m128i cb_const1 = _mm_set1_epi16((short)(1.77200f * 4096.0f + 0.5f)); + __m128i y_bias = _mm_set1_epi8((char)(unsigned char)128); + __m128i xw = _mm_set1_epi16(255); // alpha channel + + for (; i + 7 < count; i += 8) { + // load + __m128i y_bytes = _mm_loadl_epi64((__m128i *)(y + i)); + __m128i cr_bytes = _mm_loadl_epi64((__m128i *)(pcr + i)); + __m128i cb_bytes = _mm_loadl_epi64((__m128i *)(pcb + i)); + __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128 + __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128 + + // unpack to short (and left-shift cr, cb by 8) + __m128i yw = _mm_unpacklo_epi8(y_bias, y_bytes); + __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased); + __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased); + + // color transform + __m128i yws = _mm_srli_epi16(yw, 4); + __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw); + __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw); + __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1); + __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1); + __m128i rws = _mm_add_epi16(cr0, yws); + __m128i gwt = _mm_add_epi16(cb0, yws); + __m128i bws = _mm_add_epi16(yws, cb1); + __m128i gws = _mm_add_epi16(gwt, cr1); + + // descale + __m128i rw = _mm_srai_epi16(rws, 4); + __m128i bw = _mm_srai_epi16(bws, 4); + __m128i gw = _mm_srai_epi16(gws, 4); + + // back to byte, set up for transpose + __m128i brb = _mm_packus_epi16(rw, bw); + __m128i gxb = _mm_packus_epi16(gw, xw); + + // transpose to interleave channels + __m128i t0 = _mm_unpacklo_epi8(brb, gxb); + __m128i t1 = _mm_unpackhi_epi8(brb, gxb); + __m128i o0 = _mm_unpacklo_epi16(t0, t1); + __m128i o1 = _mm_unpackhi_epi16(t0, t1); + + // store + _mm_storeu_si128((__m128i *)(out + 0), o0); + _mm_storeu_si128((__m128i *)(out + 16), o1); + out += 32; + } + } +#endif + +#ifdef STBI_NEON + // in this version, step=3 support would be easy to add. but is there demand? + if (step == 4) { + // this is a fairly straightforward implementation and not super-optimized. + uint8x8_t signflip = vdup_n_u8(0x80); + int16x8_t cr_const0 = vdupq_n_s16((short)(1.40200f * 4096.0f + 0.5f)); + int16x8_t cr_const1 = vdupq_n_s16(-(short)(0.71414f * 4096.0f + 0.5f)); + int16x8_t cb_const0 = vdupq_n_s16(-(short)(0.34414f * 4096.0f + 0.5f)); + int16x8_t cb_const1 = vdupq_n_s16((short)(1.77200f * 4096.0f + 0.5f)); + + for (; i + 7 < count; i += 8) { + // load + uint8x8_t y_bytes = vld1_u8(y + i); + uint8x8_t cr_bytes = vld1_u8(pcr + i); + uint8x8_t cb_bytes = vld1_u8(pcb + i); + int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip)); + int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip)); + + // expand to s16 + int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4)); + int16x8_t crw = vshll_n_s8(cr_biased, 7); + int16x8_t cbw = vshll_n_s8(cb_biased, 7); + + // color transform + int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0); + int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0); + int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1); + int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1); + int16x8_t rws = vaddq_s16(yws, cr0); + int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1); + int16x8_t bws = vaddq_s16(yws, cb1); + + // undo scaling, round, convert to byte + uint8x8x4_t o; + o.val[0] = vqrshrun_n_s16(rws, 4); + o.val[1] = vqrshrun_n_s16(gws, 4); + o.val[2] = vqrshrun_n_s16(bws, 4); + o.val[3] = vdup_n_u8(255); + + // store, interleaving r/g/b/a + vst4_u8(out, o); + out += 8 * 4; + } + } +#endif + + for (; i < count; ++i) { + int y_fixed = (y[i] << 20) + (1 << 19); // rounding + int r, g, b; + int cr = pcr[i] - 128; + int cb = pcb[i] - 128; + r = y_fixed + cr * stbi__float2fixed(1.40200f); + g = y_fixed + cr * -stbi__float2fixed(0.71414f) + + ((cb * -stbi__float2fixed(0.34414f)) & 0xffff0000); + b = y_fixed + cb * stbi__float2fixed(1.77200f); + r >>= 20; + g >>= 20; + b >>= 20; + if ((unsigned)r > 255) { + if (r < 0) + r = 0; + else + r = 255; + } + if ((unsigned)g > 255) { + if (g < 0) + g = 0; + else + g = 255; + } + if ((unsigned)b > 255) { + if (b < 0) + b = 0; + else + b = 255; + } + out[0] = (stbi_uc)r; + out[1] = (stbi_uc)g; + out[2] = (stbi_uc)b; + out[3] = 255; + out += step; + } +} +#endif + +// set up the kernels +static void stbi__setup_jpeg(stbi__jpeg *j) { + j->idct_block_kernel = stbi__idct_block; + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row; + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2; + +#ifdef STBI_SSE2 + if (stbi__sse2_available()) { + j->idct_block_kernel = stbi__idct_simd; + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; + } +#endif + +#ifdef STBI_NEON + j->idct_block_kernel = stbi__idct_simd; + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; +#endif +} + +// clean up the temporary component buffers +static void stbi__cleanup_jpeg(stbi__jpeg *j) { stbi__free_jpeg_components(j, j->s->img_n, 0); } + +typedef struct { + resample_row_func resample; + stbi_uc *line0, *line1; + int hs, vs; // expansion factor in each axis + int w_lores; // horizontal pixels pre-expansion + int ystep; // how far through vertical expansion we are + int ypos; // which pre-expansion row we're on +} stbi__resample; + +// fast 0..255 * 0..255 => 0..255 rounded multiplication +static stbi_uc stbi__blinn_8x8(stbi_uc x, stbi_uc y) { + unsigned int t = x * y + 128; + return (stbi_uc)((t + (t >> 8)) >> 8); +} + +static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) { + int n, decode_n, is_rgb; + z->s->img_n = 0; // make stbi__cleanup_jpeg safe + + // validate req_comp + if (req_comp < 0 || req_comp > 4) + return stbi__errpuc("bad req_comp", "Internal error"); + + // load a jpeg image from whichever source, but leave in YCbCr format + if (!stbi__decode_jpeg_image(z)) { + stbi__cleanup_jpeg(z); + return NULL; + } + + // determine actual number of components to generate + n = req_comp ? req_comp : z->s->img_n >= 3 ? 3 : 1; + + is_rgb = z->s->img_n == 3 && (z->rgb == 3 || (z->app14_color_transform == 0 && !z->jfif)); + + if (z->s->img_n == 3 && n < 3 && !is_rgb) + decode_n = 1; + else + decode_n = z->s->img_n; + + // nothing to do if no components requested; check this now to avoid + // accessing uninitialized coutput[0] later + if (decode_n <= 0) { + stbi__cleanup_jpeg(z); + return NULL; + } + + // resample and color-convert + { + int k; + unsigned int i, j; + stbi_uc *output; + stbi_uc *coutput[4] = {NULL, NULL, NULL, NULL}; + + stbi__resample res_comp[4]; + + for (k = 0; k < decode_n; ++k) { + stbi__resample *r = &res_comp[k]; + + // allocate line buffer big enough for upsampling off the edges + // with upsample factor of 4 + z->img_comp[k].linebuf = (stbi_uc *)stbi__malloc(z->s->img_x + 3); + if (!z->img_comp[k].linebuf) { + stbi__cleanup_jpeg(z); + return stbi__errpuc("outofmem", "Out of memory"); + } + + r->hs = z->img_h_max / z->img_comp[k].h; + r->vs = z->img_v_max / z->img_comp[k].v; + r->ystep = r->vs >> 1; + r->w_lores = (z->s->img_x + r->hs - 1) / r->hs; + r->ypos = 0; + r->line0 = r->line1 = z->img_comp[k].data; + + if (r->hs == 1 && r->vs == 1) + r->resample = resample_row_1; + else if (r->hs == 1 && r->vs == 2) + r->resample = stbi__resample_row_v_2; + else if (r->hs == 2 && r->vs == 1) + r->resample = stbi__resample_row_h_2; + else if (r->hs == 2 && r->vs == 2) + r->resample = z->resample_row_hv_2_kernel; + else + r->resample = stbi__resample_row_generic; + } + + // can't error after this so, this is safe + output = (stbi_uc *)stbi__malloc_mad3(n, z->s->img_x, z->s->img_y, 1); + if (!output) { + stbi__cleanup_jpeg(z); + return stbi__errpuc("outofmem", "Out of memory"); + } + + // now go ahead and resample + for (j = 0; j < z->s->img_y; ++j) { + stbi_uc *out = output + n * z->s->img_x * j; + for (k = 0; k < decode_n; ++k) { + stbi__resample *r = &res_comp[k]; + int y_bot = r->ystep >= (r->vs >> 1); + coutput[k] = r->resample(z->img_comp[k].linebuf, y_bot ? r->line1 : r->line0, + y_bot ? r->line0 : r->line1, r->w_lores, r->hs); + if (++r->ystep >= r->vs) { + r->ystep = 0; + r->line0 = r->line1; + if (++r->ypos < z->img_comp[k].y) + r->line1 += z->img_comp[k].w2; + } + } + if (n >= 3) { + stbi_uc *y = coutput[0]; + if (z->s->img_n == 3) { + if (is_rgb) { + for (i = 0; i < z->s->img_x; ++i) { + out[0] = y[i]; + out[1] = coutput[1][i]; + out[2] = coutput[2][i]; + out[3] = 255; + out += n; + } + } else { + z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); + } + } else if (z->s->img_n == 4) { + if (z->app14_color_transform == 0) { // CMYK + for (i = 0; i < z->s->img_x; ++i) { + stbi_uc m = coutput[3][i]; + out[0] = stbi__blinn_8x8(coutput[0][i], m); + out[1] = stbi__blinn_8x8(coutput[1][i], m); + out[2] = stbi__blinn_8x8(coutput[2][i], m); + out[3] = 255; + out += n; + } + } else if (z->app14_color_transform == 2) { // YCCK + z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); + for (i = 0; i < z->s->img_x; ++i) { + stbi_uc m = coutput[3][i]; + out[0] = stbi__blinn_8x8(255 - out[0], m); + out[1] = stbi__blinn_8x8(255 - out[1], m); + out[2] = stbi__blinn_8x8(255 - out[2], m); + out += n; + } + } else { // YCbCr + alpha? Ignore the fourth channel for now + z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); + } + } else + for (i = 0; i < z->s->img_x; ++i) { + out[0] = out[1] = out[2] = y[i]; + out[3] = 255; // not used if n==3 + out += n; + } + } else { + if (is_rgb) { + if (n == 1) + for (i = 0; i < z->s->img_x; ++i) + *out++ = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); + else { + for (i = 0; i < z->s->img_x; ++i, out += 2) { + out[0] = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); + out[1] = 255; + } + } + } else if (z->s->img_n == 4 && z->app14_color_transform == 0) { + for (i = 0; i < z->s->img_x; ++i) { + stbi_uc m = coutput[3][i]; + stbi_uc r = stbi__blinn_8x8(coutput[0][i], m); + stbi_uc g = stbi__blinn_8x8(coutput[1][i], m); + stbi_uc b = stbi__blinn_8x8(coutput[2][i], m); + out[0] = stbi__compute_y(r, g, b); + out[1] = 255; + out += n; + } + } else if (z->s->img_n == 4 && z->app14_color_transform == 2) { + for (i = 0; i < z->s->img_x; ++i) { + out[0] = stbi__blinn_8x8(255 - coutput[0][i], coutput[3][i]); + out[1] = 255; + out += n; + } + } else { + stbi_uc *y = coutput[0]; + if (n == 1) + for (i = 0; i < z->s->img_x; ++i) + out[i] = y[i]; + else + for (i = 0; i < z->s->img_x; ++i) { + *out++ = y[i]; + *out++ = 255; + } + } + } + } + stbi__cleanup_jpeg(z); + *out_x = z->s->img_x; + *out_y = z->s->img_y; + if (comp) + *comp = z->s->img_n >= 3 ? 3 : 1; // report original components, not output + return output; + } +} + +static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, + stbi__result_info *ri) { + unsigned char *result; + stbi__jpeg *j = (stbi__jpeg *)stbi__malloc(sizeof(stbi__jpeg)); + if (!j) + return stbi__errpuc("outofmem", "Out of memory"); + memset(j, 0, sizeof(stbi__jpeg)); + STBI_NOTUSED(ri); + j->s = s; + stbi__setup_jpeg(j); + result = load_jpeg_image(j, x, y, comp, req_comp); + STBI_FREE(j); + return result; +} + +static int stbi__jpeg_test(stbi__context *s) { + int r; + stbi__jpeg *j = (stbi__jpeg *)stbi__malloc(sizeof(stbi__jpeg)); + if (!j) + return stbi__err("outofmem", "Out of memory"); + memset(j, 0, sizeof(stbi__jpeg)); + j->s = s; + stbi__setup_jpeg(j); + r = stbi__decode_jpeg_header(j, STBI__SCAN_type); + stbi__rewind(s); + STBI_FREE(j); + return r; +} + +static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp) { + if (!stbi__decode_jpeg_header(j, STBI__SCAN_header)) { + stbi__rewind(j->s); + return 0; + } + if (x) + *x = j->s->img_x; + if (y) + *y = j->s->img_y; + if (comp) + *comp = j->s->img_n >= 3 ? 3 : 1; + return 1; +} + +static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp) { + int result; + stbi__jpeg *j = (stbi__jpeg *)(stbi__malloc(sizeof(stbi__jpeg))); + if (!j) + return stbi__err("outofmem", "Out of memory"); + memset(j, 0, sizeof(stbi__jpeg)); + j->s = s; + result = stbi__jpeg_info_raw(j, x, y, comp); + STBI_FREE(j); + return result; +} +#endif + +// public domain zlib decode v0.2 Sean Barrett 2006-11-18 +// simple implementation +// - all input must be provided in an upfront buffer +// - all output is written to a single output buffer (can malloc/realloc) +// performance +// - fast huffman + +#ifndef STBI_NO_ZLIB + +// fast-way is faster to check than jpeg huffman, but slow way is slower +#define STBI__ZFAST_BITS 9 // accelerate all cases in default tables +#define STBI__ZFAST_MASK ((1 << STBI__ZFAST_BITS) - 1) +#define STBI__ZNSYMS 288 // number of symbols in literal/length alphabet + +// zlib-style huffman encoding +// (jpegs packs from left, zlib from right, so can't share code) +typedef struct { + stbi__uint16 fast[1 << STBI__ZFAST_BITS]; + stbi__uint16 firstcode[16]; + int maxcode[17]; + stbi__uint16 firstsymbol[16]; + stbi_uc size[STBI__ZNSYMS]; + stbi__uint16 value[STBI__ZNSYMS]; +} stbi__zhuffman; + +stbi_inline static int stbi__bitreverse16(int n) { + n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1); + n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2); + n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4); + n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); + return n; +} + +stbi_inline static int stbi__bit_reverse(int v, int bits) { + STBI_ASSERT(bits <= 16); + // to bit reverse n bits, reverse 16 and shift + // e.g. 11 bits, bit reverse and shift away 5 + return stbi__bitreverse16(v) >> (16 - bits); +} + +static int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, int num) { + int i, k = 0; + int code, next_code[16], sizes[17]; + + // DEFLATE spec for generating codes + memset(sizes, 0, sizeof(sizes)); + memset(z->fast, 0, sizeof(z->fast)); + for (i = 0; i < num; ++i) + ++sizes[sizelist[i]]; + sizes[0] = 0; + for (i = 1; i < 16; ++i) + if (sizes[i] > (1 << i)) + return stbi__err("bad sizes", "Corrupt PNG"); + code = 0; + for (i = 1; i < 16; ++i) { + next_code[i] = code; + z->firstcode[i] = (stbi__uint16)code; + z->firstsymbol[i] = (stbi__uint16)k; + code = (code + sizes[i]); + if (sizes[i]) + if (code - 1 >= (1 << i)) + return stbi__err("bad codelengths", "Corrupt PNG"); + z->maxcode[i] = code << (16 - i); // preshift for inner loop + code <<= 1; + k += sizes[i]; + } + z->maxcode[16] = 0x10000; // sentinel + for (i = 0; i < num; ++i) { + int s = sizelist[i]; + if (s) { + int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s]; + stbi__uint16 fastv = (stbi__uint16)((s << 9) | i); + z->size[c] = (stbi_uc)s; + z->value[c] = (stbi__uint16)i; + if (s <= STBI__ZFAST_BITS) { + int j = stbi__bit_reverse(next_code[s], s); + while (j < (1 << STBI__ZFAST_BITS)) { + z->fast[j] = fastv; + j += (1 << s); + } + } + ++next_code[s]; + } + } + return 1; +} + +// zlib-from-memory implementation for PNG reading +// because PNG allows splitting the zlib stream arbitrarily, +// and it's annoying structurally to have PNG call ZLIB call PNG, +// we require PNG read all the IDATs and combine them into a single +// memory buffer + +typedef struct { + stbi_uc *zbuffer, *zbuffer_end; + int num_bits; + int hit_zeof_once; + stbi__uint32 code_buffer; + + char *zout; + char *zout_start; + char *zout_end; + int z_expandable; + + stbi__zhuffman z_length, z_distance; +} stbi__zbuf; + +stbi_inline static int stbi__zeof(stbi__zbuf *z) { return (z->zbuffer >= z->zbuffer_end); } + +stbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z) { return stbi__zeof(z) ? 0 : *z->zbuffer++; } + +static void stbi__fill_bits(stbi__zbuf *z) { + do { + if (z->code_buffer >= (1U << z->num_bits)) { + z->zbuffer = z->zbuffer_end; /* treat this as EOF so we fail. */ + return; + } + z->code_buffer |= (unsigned int)stbi__zget8(z) << z->num_bits; + z->num_bits += 8; + } while (z->num_bits <= 24); +} + +stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n) { + unsigned int k; + if (z->num_bits < n) + stbi__fill_bits(z); + k = z->code_buffer & ((1 << n) - 1); + z->code_buffer >>= n; + z->num_bits -= n; + return k; +} + +static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z) { + int b, s, k; + // not resolved by fast table, so compute it the slow way + // use jpeg approach, which requires MSbits at top + k = stbi__bit_reverse(a->code_buffer, 16); + for (s = STBI__ZFAST_BITS + 1;; ++s) + if (k < z->maxcode[s]) + break; + if (s >= 16) + return -1; // invalid code! + // code size is s, so: + b = (k >> (16 - s)) - z->firstcode[s] + z->firstsymbol[s]; + if (b >= STBI__ZNSYMS) + return -1; // some data was corrupt somewhere! + if (z->size[b] != s) + return -1; // was originally an assert, but report failure instead. + a->code_buffer >>= s; + a->num_bits -= s; + return z->value[b]; +} + +stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z) { + int b, s; + if (a->num_bits < 16) { + if (stbi__zeof(a)) { + if (!a->hit_zeof_once) { + // This is the first time we hit eof, insert 16 extra padding btis + // to allow us to keep going; if we actually consume any of them + // though, that is invalid data. This is caught later. + a->hit_zeof_once = 1; + a->num_bits += 16; // add 16 implicit zero bits + } else { + // We already inserted our extra 16 padding bits and are again + // out, this stream is actually prematurely terminated. + return -1; + } + } else { + stbi__fill_bits(a); + } + } + b = z->fast[a->code_buffer & STBI__ZFAST_MASK]; + if (b) { + s = b >> 9; + a->code_buffer >>= s; + a->num_bits -= s; + return b & 511; + } + return stbi__zhuffman_decode_slowpath(a, z); +} + +static int stbi__zexpand(stbi__zbuf *z, char *zout, int n) // need to make room for n bytes +{ + char *q; + unsigned int cur, limit, old_limit; + z->zout = zout; + if (!z->z_expandable) + return stbi__err("output buffer limit", "Corrupt PNG"); + cur = (unsigned int)(z->zout - z->zout_start); + limit = old_limit = (unsigned)(z->zout_end - z->zout_start); + if (UINT_MAX - cur < (unsigned)n) + return stbi__err("outofmem", "Out of memory"); + while (cur + n > limit) { + if (limit > UINT_MAX / 2) + return stbi__err("outofmem", "Out of memory"); + limit *= 2; + } + q = (char *)STBI_REALLOC_SIZED(z->zout_start, old_limit, limit); + STBI_NOTUSED(old_limit); + if (q == NULL) + return stbi__err("outofmem", "Out of memory"); + z->zout_start = q; + z->zout = q + cur; + z->zout_end = q + limit; + return 1; +} + +static const int stbi__zlength_base[31] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, + 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, + 99, 115, 131, 163, 195, 227, 258, 0, 0}; + +static const int stbi__zlength_extra[31] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, + 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0}; + +static const int stbi__zdist_base[32] = { + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0}; + +static const int stbi__zdist_extra[32] = {0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, + 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13}; + +static int stbi__parse_huffman_block(stbi__zbuf *a) { + char *zout = a->zout; + for (;;) { + int z = stbi__zhuffman_decode(a, &a->z_length); + if (z < 256) { + if (z < 0) + return stbi__err("bad huffman code", "Corrupt PNG"); // error in huffman codes + if (zout >= a->zout_end) { + if (!stbi__zexpand(a, zout, 1)) + return 0; + zout = a->zout; + } + *zout++ = (char)z; + } else { + stbi_uc *p; + int len, dist; + if (z == 256) { + a->zout = zout; + if (a->hit_zeof_once && a->num_bits < 16) { + // The first time we hit zeof, we inserted 16 extra zero bits into our bit + // buffer so the decoder can just do its speculative decoding. But if we + // actually consumed any of those bits (which is the case when num_bits < 16), + // the stream actually read past the end so it is malformed. + return stbi__err("unexpected end", "Corrupt PNG"); + } + return 1; + } + if (z >= 286) + return stbi__err("bad huffman code", + "Corrupt PNG"); // per DEFLATE, length codes 286 and 287 must not + // appear in compressed data + z -= 257; + len = stbi__zlength_base[z]; + if (stbi__zlength_extra[z]) + len += stbi__zreceive(a, stbi__zlength_extra[z]); + z = stbi__zhuffman_decode(a, &a->z_distance); + if (z < 0 || z >= 30) + return stbi__err("bad huffman code", + "Corrupt PNG"); // per DEFLATE, distance codes 30 and 31 must not + // appear in compressed data + dist = stbi__zdist_base[z]; + if (stbi__zdist_extra[z]) + dist += stbi__zreceive(a, stbi__zdist_extra[z]); + if (zout - a->zout_start < dist) + return stbi__err("bad dist", "Corrupt PNG"); + if (len > a->zout_end - zout) { + if (!stbi__zexpand(a, zout, len)) + return 0; + zout = a->zout; + } + p = (stbi_uc *)(zout - dist); + if (dist == 1) { // run of one byte; common in images. + stbi_uc v = *p; + if (len) { + do + *zout++ = v; + while (--len); + } + } else { + if (len) { + do + *zout++ = *p++; + while (--len); + } + } + } + } +} + +static int stbi__compute_huffman_codes(stbi__zbuf *a) { + static const stbi_uc length_dezigzag[19] = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, + 11, 4, 12, 3, 13, 2, 14, 1, 15}; + stbi__zhuffman z_codelength; + stbi_uc lencodes[286 + 32 + 137]; // padding for maximum single op + stbi_uc codelength_sizes[19]; + int i, n; + + int hlit = stbi__zreceive(a, 5) + 257; + int hdist = stbi__zreceive(a, 5) + 1; + int hclen = stbi__zreceive(a, 4) + 4; + int ntot = hlit + hdist; + + memset(codelength_sizes, 0, sizeof(codelength_sizes)); + for (i = 0; i < hclen; ++i) { + int s = stbi__zreceive(a, 3); + codelength_sizes[length_dezigzag[i]] = (stbi_uc)s; + } + if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) + return 0; + + n = 0; + while (n < ntot) { + int c = stbi__zhuffman_decode(a, &z_codelength); + if (c < 0 || c >= 19) + return stbi__err("bad codelengths", "Corrupt PNG"); + if (c < 16) + lencodes[n++] = (stbi_uc)c; + else { + stbi_uc fill = 0; + if (c == 16) { + c = stbi__zreceive(a, 2) + 3; + if (n == 0) + return stbi__err("bad codelengths", "Corrupt PNG"); + fill = lencodes[n - 1]; + } else if (c == 17) { + c = stbi__zreceive(a, 3) + 3; + } else if (c == 18) { + c = stbi__zreceive(a, 7) + 11; + } else { + return stbi__err("bad codelengths", "Corrupt PNG"); + } + if (ntot - n < c) + return stbi__err("bad codelengths", "Corrupt PNG"); + memset(lencodes + n, fill, c); + n += c; + } + } + if (n != ntot) + return stbi__err("bad codelengths", "Corrupt PNG"); + if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) + return 0; + if (!stbi__zbuild_huffman(&a->z_distance, lencodes + hlit, hdist)) + return 0; + return 1; +} + +static int stbi__parse_uncompressed_block(stbi__zbuf *a) { + stbi_uc header[4]; + int len, nlen, k; + if (a->num_bits & 7) + stbi__zreceive(a, a->num_bits & 7); // discard + // drain the bit-packed data into header + k = 0; + while (a->num_bits > 0) { + header[k++] = (stbi_uc)(a->code_buffer & 255); // suppress MSVC run-time check + a->code_buffer >>= 8; + a->num_bits -= 8; + } + if (a->num_bits < 0) + return stbi__err("zlib corrupt", "Corrupt PNG"); + // now fill header the normal way + while (k < 4) + header[k++] = stbi__zget8(a); + len = header[1] * 256 + header[0]; + nlen = header[3] * 256 + header[2]; + if (nlen != (len ^ 0xffff)) + return stbi__err("zlib corrupt", "Corrupt PNG"); + if (a->zbuffer + len > a->zbuffer_end) + return stbi__err("read past buffer", "Corrupt PNG"); + if (a->zout + len > a->zout_end) + if (!stbi__zexpand(a, a->zout, len)) + return 0; + memcpy(a->zout, a->zbuffer, len); + a->zbuffer += len; + a->zout += len; + return 1; +} + +static int stbi__parse_zlib_header(stbi__zbuf *a) { + int cmf = stbi__zget8(a); + int cm = cmf & 15; + /* int cinfo = cmf >> 4; */ + int flg = stbi__zget8(a); + if (stbi__zeof(a)) + return stbi__err("bad zlib header", "Corrupt PNG"); // zlib spec + if ((cmf * 256 + flg) % 31 != 0) + return stbi__err("bad zlib header", "Corrupt PNG"); // zlib spec + if (flg & 32) + return stbi__err("no preset dict", "Corrupt PNG"); // preset dictionary not allowed in png + if (cm != 8) + return stbi__err("bad compression", "Corrupt PNG"); // DEFLATE required for png + // window = 1 << (8 + cinfo)... but who cares, we fully buffer output + return 1; +} + +static const stbi_uc stbi__zdefault_length[STBI__ZNSYMS] = { + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8}; +static const stbi_uc stbi__zdefault_distance[32] = {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}; +/* +Init algorithm: +{ + int i; // use <= to match clearly with spec + for (i=0; i <= 143; ++i) stbi__zdefault_length[i] = 8; + for ( ; i <= 255; ++i) stbi__zdefault_length[i] = 9; + for ( ; i <= 279; ++i) stbi__zdefault_length[i] = 7; + for ( ; i <= 287; ++i) stbi__zdefault_length[i] = 8; + + for (i=0; i <= 31; ++i) stbi__zdefault_distance[i] = 5; +} +*/ + +static int stbi__parse_zlib(stbi__zbuf *a, int parse_header) { + int final, type; + if (parse_header) + if (!stbi__parse_zlib_header(a)) + return 0; + a->num_bits = 0; + a->code_buffer = 0; + a->hit_zeof_once = 0; + do { + final = stbi__zreceive(a, 1); + type = stbi__zreceive(a, 2); + if (type == 0) { + if (!stbi__parse_uncompressed_block(a)) + return 0; + } else if (type == 3) { + return 0; + } else { + if (type == 1) { + // use fixed code lengths + if (!stbi__zbuild_huffman(&a->z_length, stbi__zdefault_length, STBI__ZNSYMS)) + return 0; + if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance, 32)) + return 0; + } else { + if (!stbi__compute_huffman_codes(a)) + return 0; + } + if (!stbi__parse_huffman_block(a)) + return 0; + } + } while (!final); + return 1; +} + +static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse_header) { + a->zout_start = obuf; + a->zout = obuf; + a->zout_end = obuf + olen; + a->z_expandable = exp; + + return stbi__parse_zlib(a, parse_header); +} + +STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, + int *outlen) { + stbi__zbuf a; + char *p = (char *)stbi__malloc(initial_size); + if (p == NULL) + return NULL; + a.zbuffer = (stbi_uc *)buffer; + a.zbuffer_end = (stbi_uc *)buffer + len; + if (stbi__do_zlib(&a, p, initial_size, 1, 1)) { + if (outlen) + *outlen = (int)(a.zout - a.zout_start); + return a.zout_start; + } else { + STBI_FREE(a.zout_start); + return NULL; + } +} + +STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen) { + return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen); +} + +STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, + int initial_size, int *outlen, + int parse_header) { + stbi__zbuf a; + char *p = (char *)stbi__malloc(initial_size); + if (p == NULL) + return NULL; + a.zbuffer = (stbi_uc *)buffer; + a.zbuffer_end = (stbi_uc *)buffer + len; + if (stbi__do_zlib(&a, p, initial_size, 1, parse_header)) { + if (outlen) + *outlen = (int)(a.zout - a.zout_start); + return a.zout_start; + } else { + STBI_FREE(a.zout_start); + return NULL; + } +} + +STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen) { + stbi__zbuf a; + a.zbuffer = (stbi_uc *)ibuffer; + a.zbuffer_end = (stbi_uc *)ibuffer + ilen; + if (stbi__do_zlib(&a, obuffer, olen, 0, 1)) + return (int)(a.zout - a.zout_start); + else + return -1; +} + +STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen) { + stbi__zbuf a; + char *p = (char *)stbi__malloc(16384); + if (p == NULL) + return NULL; + a.zbuffer = (stbi_uc *)buffer; + a.zbuffer_end = (stbi_uc *)buffer + len; + if (stbi__do_zlib(&a, p, 16384, 1, 0)) { + if (outlen) + *outlen = (int)(a.zout - a.zout_start); + return a.zout_start; + } else { + STBI_FREE(a.zout_start); + return NULL; + } +} + +STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, + int ilen) { + stbi__zbuf a; + a.zbuffer = (stbi_uc *)ibuffer; + a.zbuffer_end = (stbi_uc *)ibuffer + ilen; + if (stbi__do_zlib(&a, obuffer, olen, 0, 0)) + return (int)(a.zout - a.zout_start); + else + return -1; +} +#endif + +// public domain "baseline" PNG decoder v0.10 Sean Barrett 2006-11-18 +// simple implementation +// - only 8-bit samples +// - no CRC checking +// - allocates lots of intermediate memory +// - avoids problem of streaming data between subsystems +// - avoids explicit window management +// performance +// - uses stb_zlib, a PD zlib implementation with fast huffman decoding + +#ifndef STBI_NO_PNG +typedef struct { + stbi__uint32 length; + stbi__uint32 type; +} stbi__pngchunk; + +static stbi__pngchunk stbi__get_chunk_header(stbi__context *s) { + stbi__pngchunk c; + c.length = stbi__get32be(s); + c.type = stbi__get32be(s); + return c; +} + +static int stbi__check_png_header(stbi__context *s) { + static const stbi_uc png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; + int i; + for (i = 0; i < 8; ++i) + if (stbi__get8(s) != png_sig[i]) + return stbi__err("bad png sig", "Not a PNG"); + return 1; +} + +typedef struct { + stbi__context *s; + stbi_uc *idata, *expanded, *out; + int depth; +} stbi__png; + +enum { + STBI__F_none = 0, + STBI__F_sub = 1, + STBI__F_up = 2, + STBI__F_avg = 3, + STBI__F_paeth = 4, + // synthetic filter used for first scanline to avoid needing a dummy row of 0s + STBI__F_avg_first +}; + +static stbi_uc first_row_filter[5] = { + STBI__F_none, STBI__F_sub, STBI__F_none, STBI__F_avg_first, + STBI__F_sub // Paeth with b=c=0 turns out to be equivalent to sub +}; + +static int stbi__paeth(int a, int b, int c) { + // This formulation looks very different from the reference in the PNG spec, but is + // actually equivalent and has favorable data dependencies and admits straightforward + // generation of branch-free code, which helps performance significantly. + int thresh = c * 3 - (a + b); + int lo = a < b ? a : b; + int hi = a < b ? b : a; + int t0 = (hi <= thresh) ? lo : c; + int t1 = (thresh <= lo) ? hi : t0; + return t1; +} + +static const stbi_uc stbi__depth_scale_table[9] = {0, 0xff, 0x55, 0, 0x11, 0, 0, 0, 0x01}; + +// adds an extra all-255 alpha channel +// dest == src is legal +// img_n must be 1 or 3 +static void stbi__create_png_alpha_expand8(stbi_uc *dest, stbi_uc *src, stbi__uint32 x, int img_n) { + int i; + // must process data backwards since we allow dest==src + if (img_n == 1) { + for (i = x - 1; i >= 0; --i) { + dest[i * 2 + 1] = 255; + dest[i * 2 + 0] = src[i]; + } + } else { + STBI_ASSERT(img_n == 3); + for (i = x - 1; i >= 0; --i) { + dest[i * 4 + 3] = 255; + dest[i * 4 + 2] = src[i * 3 + 2]; + dest[i * 4 + 1] = src[i * 3 + 1]; + dest[i * 4 + 0] = src[i * 3 + 0]; + } + } +} + +// create the png data from post-deflated data +static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 raw_len, int out_n, + stbi__uint32 x, stbi__uint32 y, int depth, int color) { + int bytes = (depth == 16 ? 2 : 1); + stbi__context *s = a->s; + stbi__uint32 i, j, stride = x * out_n * bytes; + stbi__uint32 img_len, img_width_bytes; + stbi_uc *filter_buf; + int all_ok = 1; + int k; + int img_n = s->img_n; // copy it into a local for later + + int output_bytes = out_n * bytes; + int filter_bytes = img_n * bytes; + int width = x; + + STBI_ASSERT(out_n == s->img_n || out_n == s->img_n + 1); + a->out = (stbi_uc *)stbi__malloc_mad3(x, y, output_bytes, + 0); // extra bytes to write off the end into + if (!a->out) + return stbi__err("outofmem", "Out of memory"); + + // note: error exits here don't need to clean up a->out individually, + // stbi__do_png always does on error. + if (!stbi__mad3sizes_valid(img_n, x, depth, 7)) + return stbi__err("too large", "Corrupt PNG"); + img_width_bytes = (((img_n * x * depth) + 7) >> 3); + if (!stbi__mad2sizes_valid(img_width_bytes, y, img_width_bytes)) + return stbi__err("too large", "Corrupt PNG"); + img_len = (img_width_bytes + 1) * y; + + // we used to check for exact match between raw_len and img_len on non-interlaced PNGs, + // but issue #276 reported a PNG in the wild that had extra data at the end (all zeros), + // so just check for raw_len < img_len always. + if (raw_len < img_len) + return stbi__err("not enough pixels", "Corrupt PNG"); + + // Allocate two scan lines worth of filter workspace buffer. + filter_buf = (stbi_uc *)stbi__malloc_mad2(img_width_bytes, 2, 0); + if (!filter_buf) + return stbi__err("outofmem", "Out of memory"); + + // Filtering for low-bit-depth images + if (depth < 8) { + filter_bytes = 1; + width = img_width_bytes; + } + + for (j = 0; j < y; ++j) { + // cur/prior filter buffers alternate + stbi_uc *cur = filter_buf + (j & 1) * img_width_bytes; + stbi_uc *prior = filter_buf + (~j & 1) * img_width_bytes; + stbi_uc *dest = a->out + stride * j; + int nk = width * filter_bytes; + int filter = *raw++; + + // check filter type + if (filter > 4) { + all_ok = stbi__err("invalid filter", "Corrupt PNG"); + break; + } + + // if first row, use special filter that doesn't sample previous row + if (j == 0) + filter = first_row_filter[filter]; + + // perform actual filtering + switch (filter) { + case STBI__F_none: + memcpy(cur, raw, nk); + break; + case STBI__F_sub: + memcpy(cur, raw, filter_bytes); + for (k = filter_bytes; k < nk; ++k) + cur[k] = STBI__BYTECAST(raw[k] + cur[k - filter_bytes]); + break; + case STBI__F_up: + for (k = 0; k < nk; ++k) + cur[k] = STBI__BYTECAST(raw[k] + prior[k]); + break; + case STBI__F_avg: + for (k = 0; k < filter_bytes; ++k) + cur[k] = STBI__BYTECAST(raw[k] + (prior[k] >> 1)); + for (k = filter_bytes; k < nk; ++k) + cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k - filter_bytes]) >> 1)); + break; + case STBI__F_paeth: + for (k = 0; k < filter_bytes; ++k) + cur[k] = + STBI__BYTECAST(raw[k] + prior[k]); // prior[k] == stbi__paeth(0,prior[k],0) + for (k = filter_bytes; k < nk; ++k) + cur[k] = STBI__BYTECAST( + raw[k] + stbi__paeth(cur[k - filter_bytes], prior[k], prior[k - filter_bytes])); + break; + case STBI__F_avg_first: + memcpy(cur, raw, filter_bytes); + for (k = filter_bytes; k < nk; ++k) + cur[k] = STBI__BYTECAST(raw[k] + (cur[k - filter_bytes] >> 1)); + break; + } + + raw += nk; + + // expand decoded bits in cur to dest, also adding an extra alpha channel if desired + if (depth < 8) { + stbi_uc scale = (color == 0) ? stbi__depth_scale_table[depth] + : 1; // scale grayscale values to 0..255 range + stbi_uc *in = cur; + stbi_uc *out = dest; + stbi_uc inb = 0; + stbi__uint32 nsmp = x * img_n; + + // expand bits to bytes first + if (depth == 4) { + for (i = 0; i < nsmp; ++i) { + if ((i & 1) == 0) + inb = *in++; + *out++ = scale * (inb >> 4); + inb <<= 4; + } + } else if (depth == 2) { + for (i = 0; i < nsmp; ++i) { + if ((i & 3) == 0) + inb = *in++; + *out++ = scale * (inb >> 6); + inb <<= 2; + } + } else { + STBI_ASSERT(depth == 1); + for (i = 0; i < nsmp; ++i) { + if ((i & 7) == 0) + inb = *in++; + *out++ = scale * (inb >> 7); + inb <<= 1; + } + } + + // insert alpha=255 values if desired + if (img_n != out_n) + stbi__create_png_alpha_expand8(dest, dest, x, img_n); + } else if (depth == 8) { + if (img_n == out_n) + memcpy(dest, cur, x * img_n); + else + stbi__create_png_alpha_expand8(dest, cur, x, img_n); + } else if (depth == 16) { + // convert the image data from big-endian to platform-native + stbi__uint16 *dest16 = (stbi__uint16 *)dest; + stbi__uint32 nsmp = x * img_n; + + if (img_n == out_n) { + for (i = 0; i < nsmp; ++i, ++dest16, cur += 2) + *dest16 = (cur[0] << 8) | cur[1]; + } else { + STBI_ASSERT(img_n + 1 == out_n); + if (img_n == 1) { + for (i = 0; i < x; ++i, dest16 += 2, cur += 2) { + dest16[0] = (cur[0] << 8) | cur[1]; + dest16[1] = 0xffff; + } + } else { + STBI_ASSERT(img_n == 3); + for (i = 0; i < x; ++i, dest16 += 4, cur += 6) { + dest16[0] = (cur[0] << 8) | cur[1]; + dest16[1] = (cur[2] << 8) | cur[3]; + dest16[2] = (cur[4] << 8) | cur[5]; + dest16[3] = 0xffff; + } + } + } + } + } + + STBI_FREE(filter_buf); + if (!all_ok) + return 0; + + return 1; +} + +static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, + int out_n, int depth, int color, int interlaced) { + int bytes = (depth == 16 ? 2 : 1); + int out_bytes = out_n * bytes; + stbi_uc *final; + int p; + if (!interlaced) + return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, a->s->img_x, + a->s->img_y, depth, color); + + // de-interlacing + final = (stbi_uc *)stbi__malloc_mad3(a->s->img_x, a->s->img_y, out_bytes, 0); + if (!final) + return stbi__err("outofmem", "Out of memory"); + for (p = 0; p < 7; ++p) { + int xorig[] = {0, 4, 0, 2, 0, 1, 0}; + int yorig[] = {0, 0, 4, 0, 2, 0, 1}; + int xspc[] = {8, 8, 4, 4, 2, 2, 1}; + int yspc[] = {8, 8, 8, 4, 4, 2, 2}; + int i, j, x, y; + // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1 + x = (a->s->img_x - xorig[p] + xspc[p] - 1) / xspc[p]; + y = (a->s->img_y - yorig[p] + yspc[p] - 1) / yspc[p]; + if (x && y) { + stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y; + if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, y, depth, + color)) { + STBI_FREE(final); + return 0; + } + for (j = 0; j < y; ++j) { + for (i = 0; i < x; ++i) { + int out_y = j * yspc[p] + yorig[p]; + int out_x = i * xspc[p] + xorig[p]; + memcpy(final + out_y * a->s->img_x * out_bytes + out_x * out_bytes, + a->out + (j * x + i) * out_bytes, out_bytes); + } + } + STBI_FREE(a->out); + image_data += img_len; + image_data_len -= img_len; + } + } + a->out = final; + + return 1; +} + +static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n) { + stbi__context *s = z->s; + stbi__uint32 i, pixel_count = s->img_x * s->img_y; + stbi_uc *p = z->out; + + // compute color-based transparency, assuming we've + // already got 255 as the alpha value in the output + STBI_ASSERT(out_n == 2 || out_n == 4); + + if (out_n == 2) { + for (i = 0; i < pixel_count; ++i) { + p[1] = (p[0] == tc[0] ? 0 : 255); + p += 2; + } + } else { + for (i = 0; i < pixel_count; ++i) { + if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) + p[3] = 0; + p += 4; + } + } + return 1; +} + +static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], int out_n) { + stbi__context *s = z->s; + stbi__uint32 i, pixel_count = s->img_x * s->img_y; + stbi__uint16 *p = (stbi__uint16 *)z->out; + + // compute color-based transparency, assuming we've + // already got 65535 as the alpha value in the output + STBI_ASSERT(out_n == 2 || out_n == 4); + + if (out_n == 2) { + for (i = 0; i < pixel_count; ++i) { + p[1] = (p[0] == tc[0] ? 0 : 65535); + p += 2; + } + } else { + for (i = 0; i < pixel_count; ++i) { + if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) + p[3] = 0; + p += 4; + } + } + return 1; +} + +static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int pal_img_n) { + stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y; + stbi_uc *p, *temp_out, *orig = a->out; + + p = (stbi_uc *)stbi__malloc_mad2(pixel_count, pal_img_n, 0); + if (p == NULL) + return stbi__err("outofmem", "Out of memory"); + + // between here and free(out) below, exitting would leak + temp_out = p; + + if (pal_img_n == 3) { + for (i = 0; i < pixel_count; ++i) { + int n = orig[i] * 4; + p[0] = palette[n]; + p[1] = palette[n + 1]; + p[2] = palette[n + 2]; + p += 3; + } + } else { + for (i = 0; i < pixel_count; ++i) { + int n = orig[i] * 4; + p[0] = palette[n]; + p[1] = palette[n + 1]; + p[2] = palette[n + 2]; + p[3] = palette[n + 3]; + p += 4; + } + } + STBI_FREE(a->out); + a->out = temp_out; + + STBI_NOTUSED(len); + + return 1; +} + +static int stbi__unpremultiply_on_load_global = 0; +static int stbi__de_iphone_flag_global = 0; + +STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply) { + stbi__unpremultiply_on_load_global = flag_true_if_should_unpremultiply; +} + +STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert) { + stbi__de_iphone_flag_global = flag_true_if_should_convert; +} + +#ifndef STBI_THREAD_LOCAL +#define stbi__unpremultiply_on_load stbi__unpremultiply_on_load_global +#define stbi__de_iphone_flag stbi__de_iphone_flag_global +#else +static STBI_THREAD_LOCAL int stbi__unpremultiply_on_load_local, stbi__unpremultiply_on_load_set; +static STBI_THREAD_LOCAL int stbi__de_iphone_flag_local, stbi__de_iphone_flag_set; + +STBIDEF void stbi_set_unpremultiply_on_load_thread(int flag_true_if_should_unpremultiply) { + stbi__unpremultiply_on_load_local = flag_true_if_should_unpremultiply; + stbi__unpremultiply_on_load_set = 1; +} + +STBIDEF void stbi_convert_iphone_png_to_rgb_thread(int flag_true_if_should_convert) { + stbi__de_iphone_flag_local = flag_true_if_should_convert; + stbi__de_iphone_flag_set = 1; +} + +#define stbi__unpremultiply_on_load \ + (stbi__unpremultiply_on_load_set ? stbi__unpremultiply_on_load_local \ + : stbi__unpremultiply_on_load_global) +#define stbi__de_iphone_flag \ + (stbi__de_iphone_flag_set ? stbi__de_iphone_flag_local : stbi__de_iphone_flag_global) +#endif // STBI_THREAD_LOCAL + +static void stbi__de_iphone(stbi__png *z) { + stbi__context *s = z->s; + stbi__uint32 i, pixel_count = s->img_x * s->img_y; + stbi_uc *p = z->out; + + if (s->img_out_n == 3) { // convert bgr to rgb + for (i = 0; i < pixel_count; ++i) { + stbi_uc t = p[0]; + p[0] = p[2]; + p[2] = t; + p += 3; + } + } else { + STBI_ASSERT(s->img_out_n == 4); + if (stbi__unpremultiply_on_load) { + // convert bgr to rgb and unpremultiply + for (i = 0; i < pixel_count; ++i) { + stbi_uc a = p[3]; + stbi_uc t = p[0]; + if (a) { + stbi_uc half = a / 2; + p[0] = (p[2] * 255 + half) / a; + p[1] = (p[1] * 255 + half) / a; + p[2] = (t * 255 + half) / a; + } else { + p[0] = p[2]; + p[2] = t; + } + p += 4; + } + } else { + // convert bgr to rgb + for (i = 0; i < pixel_count; ++i) { + stbi_uc t = p[0]; + p[0] = p[2]; + p[2] = t; + p += 4; + } + } + } +} + +#define STBI__PNG_TYPE(a, b, c, d) \ + (((unsigned)(a) << 24) + ((unsigned)(b) << 16) + ((unsigned)(c) << 8) + (unsigned)(d)) + +static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp) { + stbi_uc palette[1024], pal_img_n = 0; + stbi_uc has_trans = 0, tc[3] = {0}; + stbi__uint16 tc16[3]; + stbi__uint32 ioff = 0, idata_limit = 0, i, pal_len = 0; + int first = 1, k, interlace = 0, color = 0, is_iphone = 0; + stbi__context *s = z->s; + + z->expanded = NULL; + z->idata = NULL; + z->out = NULL; + + if (!stbi__check_png_header(s)) + return 0; + + if (scan == STBI__SCAN_type) + return 1; + + for (;;) { + stbi__pngchunk c = stbi__get_chunk_header(s); + switch (c.type) { + case STBI__PNG_TYPE('C', 'g', 'B', 'I'): + is_iphone = 1; + stbi__skip(s, c.length); + break; + case STBI__PNG_TYPE('I', 'H', 'D', 'R'): { + int comp, filter; + if (!first) + return stbi__err("multiple IHDR", "Corrupt PNG"); + first = 0; + if (c.length != 13) + return stbi__err("bad IHDR len", "Corrupt PNG"); + s->img_x = stbi__get32be(s); + s->img_y = stbi__get32be(s); + if (s->img_y > STBI_MAX_DIMENSIONS) + return stbi__err("too large", "Very large image (corrupt?)"); + if (s->img_x > STBI_MAX_DIMENSIONS) + return stbi__err("too large", "Very large image (corrupt?)"); + z->depth = stbi__get8(s); + if (z->depth != 1 && z->depth != 2 && z->depth != 4 && z->depth != 8 && z->depth != 16) + return stbi__err("1/2/4/8/16-bit only", "PNG not supported: 1/2/4/8/16-bit only"); + color = stbi__get8(s); + if (color > 6) + return stbi__err("bad ctype", "Corrupt PNG"); + if (color == 3 && z->depth == 16) + return stbi__err("bad ctype", "Corrupt PNG"); + if (color == 3) + pal_img_n = 3; + else if (color & 1) + return stbi__err("bad ctype", "Corrupt PNG"); + comp = stbi__get8(s); + if (comp) + return stbi__err("bad comp method", "Corrupt PNG"); + filter = stbi__get8(s); + if (filter) + return stbi__err("bad filter method", "Corrupt PNG"); + interlace = stbi__get8(s); + if (interlace > 1) + return stbi__err("bad interlace method", "Corrupt PNG"); + if (!s->img_x || !s->img_y) + return stbi__err("0-pixel image", "Corrupt PNG"); + if (!pal_img_n) { + s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0); + if ((1 << 30) / s->img_x / s->img_n < s->img_y) + return stbi__err("too large", "Image too large to decode"); + } else { + // if paletted, then pal_n is our final components, and + // img_n is # components to decompress/filter. + s->img_n = 1; + if ((1 << 30) / s->img_x / 4 < s->img_y) + return stbi__err("too large", "Corrupt PNG"); + } + // even with SCAN_header, have to scan to see if we have a tRNS + break; + } + + case STBI__PNG_TYPE('P', 'L', 'T', 'E'): { + if (first) + return stbi__err("first not IHDR", "Corrupt PNG"); + if (c.length > 256 * 3) + return stbi__err("invalid PLTE", "Corrupt PNG"); + pal_len = c.length / 3; + if (pal_len * 3 != c.length) + return stbi__err("invalid PLTE", "Corrupt PNG"); + for (i = 0; i < pal_len; ++i) { + palette[i * 4 + 0] = stbi__get8(s); + palette[i * 4 + 1] = stbi__get8(s); + palette[i * 4 + 2] = stbi__get8(s); + palette[i * 4 + 3] = 255; + } + break; + } + + case STBI__PNG_TYPE('t', 'R', 'N', 'S'): { + if (first) + return stbi__err("first not IHDR", "Corrupt PNG"); + if (z->idata) + return stbi__err("tRNS after IDAT", "Corrupt PNG"); + if (pal_img_n) { + if (scan == STBI__SCAN_header) { + s->img_n = 4; + return 1; + } + if (pal_len == 0) + return stbi__err("tRNS before PLTE", "Corrupt PNG"); + if (c.length > pal_len) + return stbi__err("bad tRNS len", "Corrupt PNG"); + pal_img_n = 4; + for (i = 0; i < c.length; ++i) + palette[i * 4 + 3] = stbi__get8(s); + } else { + if (!(s->img_n & 1)) + return stbi__err("tRNS with alpha", "Corrupt PNG"); + if (c.length != (stbi__uint32)s->img_n * 2) + return stbi__err("bad tRNS len", "Corrupt PNG"); + has_trans = 1; + // non-paletted with tRNS = constant alpha. if header-scanning, we can stop now. + if (scan == STBI__SCAN_header) { + ++s->img_n; + return 1; + } + if (z->depth == 16) { + for (k = 0; k < s->img_n && k < 3; + ++k) // extra loop test to suppress false GCC warning + tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is + } else { + for (k = 0; k < s->img_n && k < 3; ++k) + tc[k] = + (stbi_uc)(stbi__get16be(s) & 255) * + stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger + } + } + break; + } + + case STBI__PNG_TYPE('I', 'D', 'A', 'T'): { + if (first) + return stbi__err("first not IHDR", "Corrupt PNG"); + if (pal_img_n && !pal_len) + return stbi__err("no PLTE", "Corrupt PNG"); + if (scan == STBI__SCAN_header) { + // header scan definitely stops at first IDAT + if (pal_img_n) + s->img_n = pal_img_n; + return 1; + } + if (c.length > (1u << 30)) + return stbi__err("IDAT size limit", "IDAT section larger than 2^30 bytes"); + if ((int)(ioff + c.length) < (int)ioff) + return 0; + if (ioff + c.length > idata_limit) { + stbi__uint32 idata_limit_old = idata_limit; + stbi_uc *p; + if (idata_limit == 0) + idata_limit = c.length > 4096 ? c.length : 4096; + while (ioff + c.length > idata_limit) + idata_limit *= 2; + STBI_NOTUSED(idata_limit_old); + p = (stbi_uc *)STBI_REALLOC_SIZED(z->idata, idata_limit_old, idata_limit); + if (p == NULL) + return stbi__err("outofmem", "Out of memory"); + z->idata = p; + } + if (!stbi__getn(s, z->idata + ioff, c.length)) + return stbi__err("outofdata", "Corrupt PNG"); + ioff += c.length; + break; + } + + case STBI__PNG_TYPE('I', 'E', 'N', 'D'): { + stbi__uint32 raw_len, bpl; + if (first) + return stbi__err("first not IHDR", "Corrupt PNG"); + if (scan != STBI__SCAN_load) + return 1; + if (z->idata == NULL) + return stbi__err("no IDAT", "Corrupt PNG"); + // initial guess for decoded data size to avoid unnecessary reallocs + bpl = (s->img_x * z->depth + 7) / 8; // bytes per line, per component + raw_len = bpl * s->img_y * s->img_n /* pixels */ + s->img_y /* filter mode per row */; + z->expanded = (stbi_uc *)stbi_zlib_decode_malloc_guesssize_headerflag( + (char *)z->idata, ioff, raw_len, (int *)&raw_len, !is_iphone); + if (z->expanded == NULL) + return 0; // zlib should set error + STBI_FREE(z->idata); + z->idata = NULL; + if ((req_comp == s->img_n + 1 && req_comp != 3 && !pal_img_n) || has_trans) + s->img_out_n = s->img_n + 1; + else + s->img_out_n = s->img_n; + if (!stbi__create_png_image(z, z->expanded, raw_len, s->img_out_n, z->depth, color, + interlace)) + return 0; + if (has_trans) { + if (z->depth == 16) { + if (!stbi__compute_transparency16(z, tc16, s->img_out_n)) + return 0; + } else { + if (!stbi__compute_transparency(z, tc, s->img_out_n)) + return 0; + } + } + if (is_iphone && stbi__de_iphone_flag && s->img_out_n > 2) + stbi__de_iphone(z); + if (pal_img_n) { + // pal_img_n == 3 or 4 + s->img_n = pal_img_n; // record the actual colors we had + s->img_out_n = pal_img_n; + if (req_comp >= 3) + s->img_out_n = req_comp; + if (!stbi__expand_png_palette(z, palette, pal_len, s->img_out_n)) + return 0; + } else if (has_trans) { + // non-paletted image with tRNS -> source image has (constant) alpha + ++s->img_n; + } + STBI_FREE(z->expanded); + z->expanded = NULL; + // end of PNG chunk, read and skip CRC + stbi__get32be(s); + return 1; + } + + default: + // if critical, fail + if (first) + return stbi__err("first not IHDR", "Corrupt PNG"); + if ((c.type & (1 << 29)) == 0) { +#ifndef STBI_NO_FAILURE_STRINGS + // not threadsafe + static char invalid_chunk[] = "XXXX PNG chunk not known"; + invalid_chunk[0] = STBI__BYTECAST(c.type >> 24); + invalid_chunk[1] = STBI__BYTECAST(c.type >> 16); + invalid_chunk[2] = STBI__BYTECAST(c.type >> 8); + invalid_chunk[3] = STBI__BYTECAST(c.type >> 0); +#endif + return stbi__err(invalid_chunk, "PNG not supported: unknown PNG chunk type"); + } + stbi__skip(s, c.length); + break; + } + // end of PNG chunk, read and skip CRC + stbi__get32be(s); + } +} + +static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp, + stbi__result_info *ri) { + void *result = NULL; + if (req_comp < 0 || req_comp > 4) + return stbi__errpuc("bad req_comp", "Internal error"); + if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) { + if (p->depth <= 8) + ri->bits_per_channel = 8; + else if (p->depth == 16) + ri->bits_per_channel = 16; + else + return stbi__errpuc("bad bits_per_channel", + "PNG not supported: unsupported color depth"); + result = p->out; + p->out = NULL; + if (req_comp && req_comp != p->s->img_out_n) { + if (ri->bits_per_channel == 8) + result = stbi__convert_format((unsigned char *)result, p->s->img_out_n, req_comp, + p->s->img_x, p->s->img_y); + else + result = stbi__convert_format16((stbi__uint16 *)result, p->s->img_out_n, req_comp, + p->s->img_x, p->s->img_y); + p->s->img_out_n = req_comp; + if (result == NULL) + return result; + } + *x = p->s->img_x; + *y = p->s->img_y; + if (n) + *n = p->s->img_n; + } + STBI_FREE(p->out); + p->out = NULL; + STBI_FREE(p->expanded); + p->expanded = NULL; + STBI_FREE(p->idata); + p->idata = NULL; + + return result; +} + +static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, + stbi__result_info *ri) { + stbi__png p; + p.s = s; + return stbi__do_png(&p, x, y, comp, req_comp, ri); +} + +static int stbi__png_test(stbi__context *s) { + int r; + r = stbi__check_png_header(s); + stbi__rewind(s); + return r; +} + +static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp) { + if (!stbi__parse_png_file(p, STBI__SCAN_header, 0)) { + stbi__rewind(p->s); + return 0; + } + if (x) + *x = p->s->img_x; + if (y) + *y = p->s->img_y; + if (comp) + *comp = p->s->img_n; + return 1; +} + +static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp) { + stbi__png p; + p.s = s; + return stbi__png_info_raw(&p, x, y, comp); +} + +static int stbi__png_is16(stbi__context *s) { + stbi__png p; + p.s = s; + if (!stbi__png_info_raw(&p, NULL, NULL, NULL)) + return 0; + if (p.depth != 16) { + stbi__rewind(p.s); + return 0; + } + return 1; +} +#endif + +// Microsoft/Windows BMP image + +#ifndef STBI_NO_BMP +static int stbi__bmp_test_raw(stbi__context *s) { + int r; + int sz; + if (stbi__get8(s) != 'B') + return 0; + if (stbi__get8(s) != 'M') + return 0; + stbi__get32le(s); // discard filesize + stbi__get16le(s); // discard reserved + stbi__get16le(s); // discard reserved + stbi__get32le(s); // discard data offset + sz = stbi__get32le(s); + r = (sz == 12 || sz == 40 || sz == 56 || sz == 108 || sz == 124); + return r; +} + +static int stbi__bmp_test(stbi__context *s) { + int r = stbi__bmp_test_raw(s); + stbi__rewind(s); + return r; +} + +// returns 0..31 for the highest set bit +static int stbi__high_bit(unsigned int z) { + int n = 0; + if (z == 0) + return -1; + if (z >= 0x10000) { + n += 16; + z >>= 16; + } + if (z >= 0x00100) { + n += 8; + z >>= 8; + } + if (z >= 0x00010) { + n += 4; + z >>= 4; + } + if (z >= 0x00004) { + n += 2; + z >>= 2; + } + if (z >= 0x00002) { + n += 1; /* >>= 1;*/ + } + return n; +} + +static int stbi__bitcount(unsigned int a) { + a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 + a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 + a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits + a = (a + (a >> 8)); // max 16 per 8 bits + a = (a + (a >> 16)); // max 32 per 8 bits + return a & 0xff; +} + +// extract an arbitrarily-aligned N-bit value (N=bits) +// from v, and then make it 8-bits long and fractionally +// extend it to full full range. +static int stbi__shiftsigned(unsigned int v, int shift, int bits) { + static unsigned int mul_table[9] = { + 0, + 0xff /*0b11111111*/, + 0x55 /*0b01010101*/, + 0x49 /*0b01001001*/, + 0x11 /*0b00010001*/, + 0x21 /*0b00100001*/, + 0x41 /*0b01000001*/, + 0x81 /*0b10000001*/, + 0x01 /*0b00000001*/, + }; + static unsigned int shift_table[9] = { + 0, 0, 0, 1, 0, 2, 4, 6, 0, + }; + if (shift < 0) + v <<= -shift; + else + v >>= shift; + STBI_ASSERT(v < 256); + v >>= (8 - bits); + STBI_ASSERT(bits >= 0 && bits <= 8); + return (int)((unsigned)v * mul_table[bits]) >> shift_table[bits]; +} + +typedef struct { + int bpp, offset, hsz; + unsigned int mr, mg, mb, ma, all_a; + int extra_read; +} stbi__bmp_data; + +static int stbi__bmp_set_mask_defaults(stbi__bmp_data *info, int compress) { + // BI_BITFIELDS specifies masks explicitly, don't override + if (compress == 3) + return 1; + + if (compress == 0) { + if (info->bpp == 16) { + info->mr = 31u << 10; + info->mg = 31u << 5; + info->mb = 31u << 0; + } else if (info->bpp == 32) { + info->mr = 0xffu << 16; + info->mg = 0xffu << 8; + info->mb = 0xffu << 0; + info->ma = 0xffu << 24; + info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0 + } else { + // otherwise, use defaults, which is all-0 + info->mr = info->mg = info->mb = info->ma = 0; + } + return 1; + } + return 0; // error +} + +static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info) { + int hsz; + if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') + return stbi__errpuc("not BMP", "Corrupt BMP"); + stbi__get32le(s); // discard filesize + stbi__get16le(s); // discard reserved + stbi__get16le(s); // discard reserved + info->offset = stbi__get32le(s); + info->hsz = hsz = stbi__get32le(s); + info->mr = info->mg = info->mb = info->ma = 0; + info->extra_read = 14; + + if (info->offset < 0) + return stbi__errpuc("bad BMP", "bad BMP"); + + if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) + return stbi__errpuc("unknown BMP", "BMP type not supported: unknown"); + if (hsz == 12) { + s->img_x = stbi__get16le(s); + s->img_y = stbi__get16le(s); + } else { + s->img_x = stbi__get32le(s); + s->img_y = stbi__get32le(s); + } + if (stbi__get16le(s) != 1) + return stbi__errpuc("bad BMP", "bad BMP"); + info->bpp = stbi__get16le(s); + if (hsz != 12) { + int compress = stbi__get32le(s); + if (compress == 1 || compress == 2) + return stbi__errpuc("BMP RLE", "BMP type not supported: RLE"); + if (compress >= 4) + return stbi__errpuc( + "BMP JPEG/PNG", + "BMP type not supported: unsupported compression"); // this includes PNG/JPEG modes + if (compress == 3 && info->bpp != 16 && info->bpp != 32) + return stbi__errpuc("bad BMP", "bad BMP"); // bitfields requires 16 or 32 bits/pixel + stbi__get32le(s); // discard sizeof + stbi__get32le(s); // discard hres + stbi__get32le(s); // discard vres + stbi__get32le(s); // discard colorsused + stbi__get32le(s); // discard max important + if (hsz == 40 || hsz == 56) { + if (hsz == 56) { + stbi__get32le(s); + stbi__get32le(s); + stbi__get32le(s); + stbi__get32le(s); + } + if (info->bpp == 16 || info->bpp == 32) { + if (compress == 0) { + stbi__bmp_set_mask_defaults(info, compress); + } else if (compress == 3) { + info->mr = stbi__get32le(s); + info->mg = stbi__get32le(s); + info->mb = stbi__get32le(s); + info->extra_read += 12; + // not documented, but generated by photoshop and handled by mspaint + if (info->mr == info->mg && info->mg == info->mb) { + // ?!?!? + return stbi__errpuc("bad BMP", "bad BMP"); + } + } else + return stbi__errpuc("bad BMP", "bad BMP"); + } + } else { + // V4/V5 header + int i; + if (hsz != 108 && hsz != 124) + return stbi__errpuc("bad BMP", "bad BMP"); + info->mr = stbi__get32le(s); + info->mg = stbi__get32le(s); + info->mb = stbi__get32le(s); + info->ma = stbi__get32le(s); + if (compress != 3) // override mr/mg/mb unless in BI_BITFIELDS mode, as per docs + stbi__bmp_set_mask_defaults(info, compress); + stbi__get32le(s); // discard color space + for (i = 0; i < 12; ++i) + stbi__get32le(s); // discard color space parameters + if (hsz == 124) { + stbi__get32le(s); // discard rendering intent + stbi__get32le(s); // discard offset of profile data + stbi__get32le(s); // discard size of profile data + stbi__get32le(s); // discard reserved + } + } + } + return (void *)1; +} + +static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, + stbi__result_info *ri) { + stbi_uc *out; + unsigned int mr = 0, mg = 0, mb = 0, ma = 0, all_a; + stbi_uc pal[256][4]; + int psize = 0, i, j, width; + int flip_vertically, pad, target; + stbi__bmp_data info; + STBI_NOTUSED(ri); + + info.all_a = 255; + if (stbi__bmp_parse_header(s, &info) == NULL) + return NULL; // error code already set + + flip_vertically = ((int)s->img_y) > 0; + s->img_y = abs((int)s->img_y); + + if (s->img_y > STBI_MAX_DIMENSIONS) + return stbi__errpuc("too large", "Very large image (corrupt?)"); + if (s->img_x > STBI_MAX_DIMENSIONS) + return stbi__errpuc("too large", "Very large image (corrupt?)"); + + mr = info.mr; + mg = info.mg; + mb = info.mb; + ma = info.ma; + all_a = info.all_a; + + if (info.hsz == 12) { + if (info.bpp < 24) + psize = (info.offset - info.extra_read - 24) / 3; + } else { + if (info.bpp < 16) + psize = (info.offset - info.extra_read - info.hsz) >> 2; + } + if (psize == 0) { + // accept some number of extra bytes after the header, but if the offset points either to + // before the header ends or implies a large amount of extra data, reject the file as + // malformed + int bytes_read_so_far = + s->callback_already_read + (int)(s->img_buffer - s->img_buffer_original); + int header_limit = 1024; // max we actually read is below 256 bytes currently. + int extra_data_limit = + 256 * + 4; // what ordinarily goes here is a palette; 256 entries*4 bytes is its max size. + if (bytes_read_so_far <= 0 || bytes_read_so_far > header_limit) { + return stbi__errpuc("bad header", "Corrupt BMP"); + } + // we established that bytes_read_so_far is positive and sensible. + // the first half of this test rejects offsets that are either too small positives, or + // negative, and guarantees that info.offset >= bytes_read_so_far > 0. this in turn + // ensures the number computed in the second half of the test can't overflow. + if (info.offset < bytes_read_so_far || info.offset - bytes_read_so_far > extra_data_limit) { + return stbi__errpuc("bad offset", "Corrupt BMP"); + } else { + stbi__skip(s, info.offset - bytes_read_so_far); + } + } + + if (info.bpp == 24 && ma == 0xff000000) + s->img_n = 3; + else + s->img_n = ma ? 4 : 3; + if (req_comp && req_comp >= 3) // we can directly decode 3 or 4 + target = req_comp; + else + target = s->img_n; // if they want monochrome, we'll post-convert + + // sanity-check size + if (!stbi__mad3sizes_valid(target, s->img_x, s->img_y, 0)) + return stbi__errpuc("too large", "Corrupt BMP"); + + out = (stbi_uc *)stbi__malloc_mad3(target, s->img_x, s->img_y, 0); + if (!out) + return stbi__errpuc("outofmem", "Out of memory"); + if (info.bpp < 16) { + int z = 0; + if (psize == 0 || psize > 256) { + STBI_FREE(out); + return stbi__errpuc("invalid", "Corrupt BMP"); + } + for (i = 0; i < psize; ++i) { + pal[i][2] = stbi__get8(s); + pal[i][1] = stbi__get8(s); + pal[i][0] = stbi__get8(s); + if (info.hsz != 12) + stbi__get8(s); + pal[i][3] = 255; + } + stbi__skip(s, info.offset - info.extra_read - info.hsz - psize * (info.hsz == 12 ? 3 : 4)); + if (info.bpp == 1) + width = (s->img_x + 7) >> 3; + else if (info.bpp == 4) + width = (s->img_x + 1) >> 1; + else if (info.bpp == 8) + width = s->img_x; + else { + STBI_FREE(out); + return stbi__errpuc("bad bpp", "Corrupt BMP"); + } + pad = (-width) & 3; + if (info.bpp == 1) { + for (j = 0; j < (int)s->img_y; ++j) { + int bit_offset = 7, v = stbi__get8(s); + for (i = 0; i < (int)s->img_x; ++i) { + int color = (v >> bit_offset) & 0x1; + out[z++] = pal[color][0]; + out[z++] = pal[color][1]; + out[z++] = pal[color][2]; + if (target == 4) + out[z++] = 255; + if (i + 1 == (int)s->img_x) + break; + if ((--bit_offset) < 0) { + bit_offset = 7; + v = stbi__get8(s); + } + } + stbi__skip(s, pad); + } + } else { + for (j = 0; j < (int)s->img_y; ++j) { + for (i = 0; i < (int)s->img_x; i += 2) { + int v = stbi__get8(s), v2 = 0; + if (info.bpp == 4) { + v2 = v & 15; + v >>= 4; + } + out[z++] = pal[v][0]; + out[z++] = pal[v][1]; + out[z++] = pal[v][2]; + if (target == 4) + out[z++] = 255; + if (i + 1 == (int)s->img_x) + break; + v = (info.bpp == 8) ? stbi__get8(s) : v2; + out[z++] = pal[v][0]; + out[z++] = pal[v][1]; + out[z++] = pal[v][2]; + if (target == 4) + out[z++] = 255; + } + stbi__skip(s, pad); + } + } + } else { + int rshift = 0, gshift = 0, bshift = 0, ashift = 0, rcount = 0, gcount = 0, bcount = 0, + acount = 0; + int z = 0; + int easy = 0; + stbi__skip(s, info.offset - info.extra_read - info.hsz); + if (info.bpp == 24) + width = 3 * s->img_x; + else if (info.bpp == 16) + width = 2 * s->img_x; + else /* bpp = 32 and pad = 0 */ + width = 0; + pad = (-width) & 3; + if (info.bpp == 24) { + easy = 1; + } else if (info.bpp == 32) { + if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000) + easy = 2; + } + if (!easy) { + if (!mr || !mg || !mb) { + STBI_FREE(out); + return stbi__errpuc("bad masks", "Corrupt BMP"); + } + // right shift amt to put high bit in position #7 + rshift = stbi__high_bit(mr) - 7; + rcount = stbi__bitcount(mr); + gshift = stbi__high_bit(mg) - 7; + gcount = stbi__bitcount(mg); + bshift = stbi__high_bit(mb) - 7; + bcount = stbi__bitcount(mb); + ashift = stbi__high_bit(ma) - 7; + acount = stbi__bitcount(ma); + if (rcount > 8 || gcount > 8 || bcount > 8 || acount > 8) { + STBI_FREE(out); + return stbi__errpuc("bad masks", "Corrupt BMP"); + } + } + for (j = 0; j < (int)s->img_y; ++j) { + if (easy) { + for (i = 0; i < (int)s->img_x; ++i) { + unsigned char a; + out[z + 2] = stbi__get8(s); + out[z + 1] = stbi__get8(s); + out[z + 0] = stbi__get8(s); + z += 3; + a = (easy == 2 ? stbi__get8(s) : 255); + all_a |= a; + if (target == 4) + out[z++] = a; + } + } else { + int bpp = info.bpp; + for (i = 0; i < (int)s->img_x; ++i) { + stbi__uint32 v = + (bpp == 16 ? (stbi__uint32)stbi__get16le(s) : stbi__get32le(s)); + unsigned int a; + out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount)); + out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount)); + out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount)); + a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255); + all_a |= a; + if (target == 4) + out[z++] = STBI__BYTECAST(a); + } + } + stbi__skip(s, pad); + } + } + + // if alpha channel is all 0s, replace with all 255s + if (target == 4 && all_a == 0) + for (i = 4 * s->img_x * s->img_y - 1; i >= 0; i -= 4) + out[i] = 255; + + if (flip_vertically) { + stbi_uc t; + for (j = 0; j < (int)s->img_y >> 1; ++j) { + stbi_uc *p1 = out + j * s->img_x * target; + stbi_uc *p2 = out + (s->img_y - 1 - j) * s->img_x * target; + for (i = 0; i < (int)s->img_x * target; ++i) { + t = p1[i]; + p1[i] = p2[i]; + p2[i] = t; + } + } + } + + if (req_comp && req_comp != target) { + out = stbi__convert_format(out, target, req_comp, s->img_x, s->img_y); + if (out == NULL) + return out; // stbi__convert_format frees input on failure + } + + *x = s->img_x; + *y = s->img_y; + if (comp) + *comp = s->img_n; + return out; +} +#endif + +// Targa Truevision - TGA +// by Jonathan Dummer +#ifndef STBI_NO_TGA +// returns STBI_rgb or whatever, 0 on error +static int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int *is_rgb16) { + // only RGB or RGBA (incl. 16bit) or grey allowed + if (is_rgb16) + *is_rgb16 = 0; + switch (bits_per_pixel) { + case 8: + return STBI_grey; + case 16: + if (is_grey) + return STBI_grey_alpha; + // fallthrough + case 15: + if (is_rgb16) + *is_rgb16 = 1; + return STBI_rgb; + case 24: // fallthrough + case 32: + return bits_per_pixel / 8; + default: + return 0; + } +} + +static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp) { + int tga_w, tga_h, tga_comp, tga_image_type, tga_bits_per_pixel, tga_colormap_bpp; + int sz, tga_colormap_type; + stbi__get8(s); // discard Offset + tga_colormap_type = stbi__get8(s); // colormap type + if (tga_colormap_type > 1) { + stbi__rewind(s); + return 0; // only RGB or indexed allowed + } + tga_image_type = stbi__get8(s); // image type + if (tga_colormap_type == 1) { // colormapped (paletted) image + if (tga_image_type != 1 && tga_image_type != 9) { + stbi__rewind(s); + return 0; + } + stbi__skip(s, 4); // skip index of first colormap entry and number of entries + sz = stbi__get8(s); // check bits per palette color entry + if ((sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32)) { + stbi__rewind(s); + return 0; + } + stbi__skip(s, 4); // skip image x and y origin + tga_colormap_bpp = sz; + } else { // "normal" image w/o colormap - only RGB or grey allowed, +/- RLE + if ((tga_image_type != 2) && (tga_image_type != 3) && (tga_image_type != 10) && + (tga_image_type != 11)) { + stbi__rewind(s); + return 0; // only RGB or grey allowed, +/- RLE + } + stbi__skip(s, 9); // skip colormap specification and image x/y origin + tga_colormap_bpp = 0; + } + tga_w = stbi__get16le(s); + if (tga_w < 1) { + stbi__rewind(s); + return 0; // test width + } + tga_h = stbi__get16le(s); + if (tga_h < 1) { + stbi__rewind(s); + return 0; // test height + } + tga_bits_per_pixel = stbi__get8(s); // bits per pixel + stbi__get8(s); // ignore alpha bits + if (tga_colormap_bpp != 0) { + if ((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16)) { + // when using a colormap, tga_bits_per_pixel is the size of the indexes + // I don't think anything but 8 or 16bit indexes makes sense + stbi__rewind(s); + return 0; + } + tga_comp = stbi__tga_get_comp(tga_colormap_bpp, 0, NULL); + } else { + tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, + (tga_image_type == 3) || (tga_image_type == 11), NULL); + } + if (!tga_comp) { + stbi__rewind(s); + return 0; + } + if (x) + *x = tga_w; + if (y) + *y = tga_h; + if (comp) + *comp = tga_comp; + return 1; // seems to have passed everything +} + +static int stbi__tga_test(stbi__context *s) { + int res = 0; + int sz, tga_color_type; + stbi__get8(s); // discard Offset + tga_color_type = stbi__get8(s); // color type + if (tga_color_type > 1) + goto errorEnd; // only RGB or indexed allowed + sz = stbi__get8(s); // image type + if (tga_color_type == 1) { // colormapped (paletted) image + if (sz != 1 && sz != 9) + goto errorEnd; // colortype 1 demands image type 1 or 9 + stbi__skip(s, 4); // skip index of first colormap entry and number of entries + sz = stbi__get8(s); // check bits per palette color entry + if ((sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32)) + goto errorEnd; + stbi__skip(s, 4); // skip image x and y origin + } else { // "normal" image w/o colormap + if ((sz != 2) && (sz != 3) && (sz != 10) && (sz != 11)) + goto errorEnd; // only RGB or grey allowed, +/- RLE + stbi__skip(s, 9); // skip colormap specification and image x/y origin + } + if (stbi__get16le(s) < 1) + goto errorEnd; // test width + if (stbi__get16le(s) < 1) + goto errorEnd; // test height + sz = stbi__get8(s); // bits per pixel + if ((tga_color_type == 1) && (sz != 8) && (sz != 16)) + goto errorEnd; // for colormapped images, bpp is size of an index + if ((sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32)) + goto errorEnd; + + res = 1; // if we got this far, everything's good and we can return 1 instead of 0 + +errorEnd: + stbi__rewind(s); + return res; +} + +// read 16bit value and convert to 24bit RGB +static void stbi__tga_read_rgb16(stbi__context *s, stbi_uc *out) { + stbi__uint16 px = (stbi__uint16)stbi__get16le(s); + stbi__uint16 fiveBitMask = 31; + // we have 3 channels with 5bits each + int r = (px >> 10) & fiveBitMask; + int g = (px >> 5) & fiveBitMask; + int b = px & fiveBitMask; + // Note that this saves the data in RGB(A) order, so it doesn't need to be swapped later + out[0] = (stbi_uc)((r * 255) / 31); + out[1] = (stbi_uc)((g * 255) / 31); + out[2] = (stbi_uc)((b * 255) / 31); + + // some people claim that the most significant bit might be used for alpha + // (possibly if an alpha-bit is set in the "image descriptor byte") + // but that only made 16bit test images completely translucent.. + // so let's treat all 15 and 16bit TGAs as RGB with no alpha. +} + +static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, + stbi__result_info *ri) { + // read in the TGA header stuff + int tga_offset = stbi__get8(s); + int tga_indexed = stbi__get8(s); + int tga_image_type = stbi__get8(s); + int tga_is_RLE = 0; + int tga_palette_start = stbi__get16le(s); + int tga_palette_len = stbi__get16le(s); + int tga_palette_bits = stbi__get8(s); + int tga_x_origin = stbi__get16le(s); + int tga_y_origin = stbi__get16le(s); + int tga_width = stbi__get16le(s); + int tga_height = stbi__get16le(s); + int tga_bits_per_pixel = stbi__get8(s); + int tga_comp, tga_rgb16 = 0; + int tga_inverted = stbi__get8(s); + // int tga_alpha_bits = tga_inverted & 15; // the 4 lowest bits - unused (useless?) + // image data + unsigned char *tga_data; + unsigned char *tga_palette = NULL; + int i, j; + unsigned char raw_data[4] = {0}; + int RLE_count = 0; + int RLE_repeating = 0; + int read_next_pixel = 1; + STBI_NOTUSED(ri); + STBI_NOTUSED(tga_x_origin); // @TODO + STBI_NOTUSED(tga_y_origin); // @TODO + + if (tga_height > STBI_MAX_DIMENSIONS) + return stbi__errpuc("too large", "Very large image (corrupt?)"); + if (tga_width > STBI_MAX_DIMENSIONS) + return stbi__errpuc("too large", "Very large image (corrupt?)"); + + // do a tiny bit of precessing + if (tga_image_type >= 8) { + tga_image_type -= 8; + tga_is_RLE = 1; + } + tga_inverted = 1 - ((tga_inverted >> 5) & 1); + + // If I'm paletted, then I'll use the number of bits from the palette + if (tga_indexed) + tga_comp = stbi__tga_get_comp(tga_palette_bits, 0, &tga_rgb16); + else + tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3), &tga_rgb16); + + if (!tga_comp) // shouldn't really happen, stbi__tga_test() should have ensured basic + // consistency + return stbi__errpuc("bad format", "Can't find out TGA pixelformat"); + + // tga info + *x = tga_width; + *y = tga_height; + if (comp) + *comp = tga_comp; + + if (!stbi__mad3sizes_valid(tga_width, tga_height, tga_comp, 0)) + return stbi__errpuc("too large", "Corrupt TGA"); + + tga_data = (unsigned char *)stbi__malloc_mad3(tga_width, tga_height, tga_comp, 0); + if (!tga_data) + return stbi__errpuc("outofmem", "Out of memory"); + + // skip to the data's starting position (offset usually = 0) + stbi__skip(s, tga_offset); + + if (!tga_indexed && !tga_is_RLE && !tga_rgb16) { + for (i = 0; i < tga_height; ++i) { + int row = tga_inverted ? tga_height - i - 1 : i; + stbi_uc *tga_row = tga_data + row * tga_width * tga_comp; + stbi__getn(s, tga_row, tga_width * tga_comp); + } + } else { + // do I need to load a palette? + if (tga_indexed) { + if (tga_palette_len == 0) { /* you have to have at least one entry! */ + STBI_FREE(tga_data); + return stbi__errpuc("bad palette", "Corrupt TGA"); + } + + // any data to skip? (offset usually = 0) + stbi__skip(s, tga_palette_start); + // load the palette + tga_palette = (unsigned char *)stbi__malloc_mad2(tga_palette_len, tga_comp, 0); + if (!tga_palette) { + STBI_FREE(tga_data); + return stbi__errpuc("outofmem", "Out of memory"); + } + if (tga_rgb16) { + stbi_uc *pal_entry = tga_palette; + STBI_ASSERT(tga_comp == STBI_rgb); + for (i = 0; i < tga_palette_len; ++i) { + stbi__tga_read_rgb16(s, pal_entry); + pal_entry += tga_comp; + } + } else if (!stbi__getn(s, tga_palette, tga_palette_len * tga_comp)) { + STBI_FREE(tga_data); + STBI_FREE(tga_palette); + return stbi__errpuc("bad palette", "Corrupt TGA"); + } + } + // load the data + for (i = 0; i < tga_width * tga_height; ++i) { + // if I'm in RLE mode, do I need to get a RLE stbi__pngchunk? + if (tga_is_RLE) { + if (RLE_count == 0) { + // yep, get the next byte as a RLE command + int RLE_cmd = stbi__get8(s); + RLE_count = 1 + (RLE_cmd & 127); + RLE_repeating = RLE_cmd >> 7; + read_next_pixel = 1; + } else if (!RLE_repeating) { + read_next_pixel = 1; + } + } else { + read_next_pixel = 1; + } + // OK, if I need to read a pixel, do it now + if (read_next_pixel) { + // load however much data we did have + if (tga_indexed) { + // read in index, then perform the lookup + int pal_idx = (tga_bits_per_pixel == 8) ? stbi__get8(s) : stbi__get16le(s); + if (pal_idx >= tga_palette_len) { + // invalid index + pal_idx = 0; + } + pal_idx *= tga_comp; + for (j = 0; j < tga_comp; ++j) { + raw_data[j] = tga_palette[pal_idx + j]; + } + } else if (tga_rgb16) { + STBI_ASSERT(tga_comp == STBI_rgb); + stbi__tga_read_rgb16(s, raw_data); + } else { + // read in the data raw + for (j = 0; j < tga_comp; ++j) { + raw_data[j] = stbi__get8(s); + } + } + // clear the reading flag for the next pixel + read_next_pixel = 0; + } // end of reading a pixel + + // copy data + for (j = 0; j < tga_comp; ++j) + tga_data[i * tga_comp + j] = raw_data[j]; + + // in case we're in RLE mode, keep counting down + --RLE_count; + } + // do I need to invert the image? + if (tga_inverted) { + for (j = 0; j * 2 < tga_height; ++j) { + int index1 = j * tga_width * tga_comp; + int index2 = (tga_height - 1 - j) * tga_width * tga_comp; + for (i = tga_width * tga_comp; i > 0; --i) { + unsigned char temp = tga_data[index1]; + tga_data[index1] = tga_data[index2]; + tga_data[index2] = temp; + ++index1; + ++index2; + } + } + } + // clear my palette, if I had one + if (tga_palette != NULL) { + STBI_FREE(tga_palette); + } + } + + // swap RGB - if the source data was RGB16, it already is in the right order + if (tga_comp >= 3 && !tga_rgb16) { + unsigned char *tga_pixel = tga_data; + for (i = 0; i < tga_width * tga_height; ++i) { + unsigned char temp = tga_pixel[0]; + tga_pixel[0] = tga_pixel[2]; + tga_pixel[2] = temp; + tga_pixel += tga_comp; + } + } + + // convert to target component count + if (req_comp && req_comp != tga_comp) + tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height); + + // the things I do to get rid of an error message, and yet keep + // Microsoft's C compilers happy... [8^( + tga_palette_start = tga_palette_len = tga_palette_bits = tga_x_origin = tga_y_origin = 0; + STBI_NOTUSED(tga_palette_start); + // OK, done + return tga_data; +} +#endif + +// ************************************************************************************************* +// Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB + +#ifndef STBI_NO_PSD +static int stbi__psd_test(stbi__context *s) { + int r = (stbi__get32be(s) == 0x38425053); + stbi__rewind(s); + return r; +} + +static int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, int pixelCount) { + int count, nleft, len; + + count = 0; + while ((nleft = pixelCount - count) > 0) { + len = stbi__get8(s); + if (len == 128) { + // No-op. + } else if (len < 128) { + // Copy next len+1 bytes literally. + len++; + if (len > nleft) + return 0; // corrupt data + count += len; + while (len) { + *p = stbi__get8(s); + p += 4; + len--; + } + } else if (len > 128) { + stbi_uc val; + // Next -len+1 bytes in the dest are replicated from next source byte. + // (Interpret len as a negative 8-bit int.) + len = 257 - len; + if (len > nleft) + return 0; // corrupt data + val = stbi__get8(s); + count += len; + while (len) { + *p = val; + p += 4; + len--; + } + } + } + + return 1; +} + +static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, + stbi__result_info *ri, int bpc) { + int pixelCount; + int channelCount, compression; + int channel, i; + int bitdepth; + int w, h; + stbi_uc *out; + STBI_NOTUSED(ri); + + // Check identifier + if (stbi__get32be(s) != 0x38425053) // "8BPS" + return stbi__errpuc("not PSD", "Corrupt PSD image"); + + // Check file type version. + if (stbi__get16be(s) != 1) + return stbi__errpuc("wrong version", "Unsupported version of PSD image"); + + // Skip 6 reserved bytes. + stbi__skip(s, 6); + + // Read the number of channels (R, G, B, A, etc). + channelCount = stbi__get16be(s); + if (channelCount < 0 || channelCount > 16) + return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image"); + + // Read the rows and columns of the image. + h = stbi__get32be(s); + w = stbi__get32be(s); + + if (h > STBI_MAX_DIMENSIONS) + return stbi__errpuc("too large", "Very large image (corrupt?)"); + if (w > STBI_MAX_DIMENSIONS) + return stbi__errpuc("too large", "Very large image (corrupt?)"); + + // Make sure the depth is 8 bits. + bitdepth = stbi__get16be(s); + if (bitdepth != 8 && bitdepth != 16) + return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit"); + + // Make sure the color mode is RGB. + // Valid options are: + // 0: Bitmap + // 1: Grayscale + // 2: Indexed color + // 3: RGB color + // 4: CMYK color + // 7: Multichannel + // 8: Duotone + // 9: Lab color + if (stbi__get16be(s) != 3) + return stbi__errpuc("wrong color format", "PSD is not in RGB color format"); + + // Skip the Mode Data. (It's the palette for indexed color; other info for other modes.) + stbi__skip(s, stbi__get32be(s)); + + // Skip the image resources. (resolution, pen tool paths, etc) + stbi__skip(s, stbi__get32be(s)); + + // Skip the reserved data. + stbi__skip(s, stbi__get32be(s)); + + // Find out if the data is compressed. + // Known values: + // 0: no compression + // 1: RLE compressed + compression = stbi__get16be(s); + if (compression > 1) + return stbi__errpuc("bad compression", "PSD has an unknown compression format"); + + // Check size + if (!stbi__mad3sizes_valid(4, w, h, 0)) + return stbi__errpuc("too large", "Corrupt PSD"); + + // Create the destination image. + + if (!compression && bitdepth == 16 && bpc == 16) { + out = (stbi_uc *)stbi__malloc_mad3(8, w, h, 0); + ri->bits_per_channel = 16; + } else + out = (stbi_uc *)stbi__malloc(4 * w * h); + + if (!out) + return stbi__errpuc("outofmem", "Out of memory"); + pixelCount = w * h; + + // Initialize the data to zero. + // memset( out, 0, pixelCount * 4 ); + + // Finally, the image data. + if (compression) { + // RLE as used by .PSD and .TIFF + // Loop until you get the number of unpacked bytes you are expecting: + // Read the next source byte into n. + // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. + // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times. + // Else if n is 128, noop. + // Endloop + + // The RLE-compressed data is preceded by a 2-byte data count for each row in the data, + // which we're going to just skip. + stbi__skip(s, h * channelCount * 2); + + // Read the RLE data by channel. + for (channel = 0; channel < 4; channel++) { + stbi_uc *p; + + p = out + channel; + if (channel >= channelCount) { + // Fill this channel with default data. + for (i = 0; i < pixelCount; i++, p += 4) + *p = (channel == 3 ? 255 : 0); + } else { + // Read the RLE data. + if (!stbi__psd_decode_rle(s, p, pixelCount)) { + STBI_FREE(out); + return stbi__errpuc("corrupt", "bad RLE data"); + } + } + } + + } else { + // We're at the raw image data. It's each channel in order (Red, Green, Blue, Alpha, ...) + // where each channel consists of an 8-bit (or 16-bit) value for each pixel in the image. + + // Read the data by channel. + for (channel = 0; channel < 4; channel++) { + if (channel >= channelCount) { + // Fill this channel with default data. + if (bitdepth == 16 && bpc == 16) { + stbi__uint16 *q = ((stbi__uint16 *)out) + channel; + stbi__uint16 val = channel == 3 ? 65535 : 0; + for (i = 0; i < pixelCount; i++, q += 4) + *q = val; + } else { + stbi_uc *p = out + channel; + stbi_uc val = channel == 3 ? 255 : 0; + for (i = 0; i < pixelCount; i++, p += 4) + *p = val; + } + } else { + if (ri->bits_per_channel == 16) { // output bpc + stbi__uint16 *q = ((stbi__uint16 *)out) + channel; + for (i = 0; i < pixelCount; i++, q += 4) + *q = (stbi__uint16)stbi__get16be(s); + } else { + stbi_uc *p = out + channel; + if (bitdepth == 16) { // input bpc + for (i = 0; i < pixelCount; i++, p += 4) + *p = (stbi_uc)(stbi__get16be(s) >> 8); + } else { + for (i = 0; i < pixelCount; i++, p += 4) + *p = stbi__get8(s); + } + } + } + } + } + + // remove weird white matte from PSD + if (channelCount >= 4) { + if (ri->bits_per_channel == 16) { + for (i = 0; i < w * h; ++i) { + stbi__uint16 *pixel = (stbi__uint16 *)out + 4 * i; + if (pixel[3] != 0 && pixel[3] != 65535) { + float a = pixel[3] / 65535.0f; + float ra = 1.0f / a; + float inv_a = 65535.0f * (1 - ra); + pixel[0] = (stbi__uint16)(pixel[0] * ra + inv_a); + pixel[1] = (stbi__uint16)(pixel[1] * ra + inv_a); + pixel[2] = (stbi__uint16)(pixel[2] * ra + inv_a); + } + } + } else { + for (i = 0; i < w * h; ++i) { + unsigned char *pixel = out + 4 * i; + if (pixel[3] != 0 && pixel[3] != 255) { + float a = pixel[3] / 255.0f; + float ra = 1.0f / a; + float inv_a = 255.0f * (1 - ra); + pixel[0] = (unsigned char)(pixel[0] * ra + inv_a); + pixel[1] = (unsigned char)(pixel[1] * ra + inv_a); + pixel[2] = (unsigned char)(pixel[2] * ra + inv_a); + } + } + } + } + + // convert to desired output format + if (req_comp && req_comp != 4) { + if (ri->bits_per_channel == 16) + out = (stbi_uc *)stbi__convert_format16((stbi__uint16 *)out, 4, req_comp, w, h); + else + out = stbi__convert_format(out, 4, req_comp, w, h); + if (out == NULL) + return out; // stbi__convert_format frees input on failure + } + + if (comp) + *comp = 4; + *y = h; + *x = w; + + return out; +} +#endif + +// ************************************************************************************************* +// Softimage PIC loader +// by Tom Seddon +// +// See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format +// See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/ + +#ifndef STBI_NO_PIC +static int stbi__pic_is4(stbi__context *s, const char *str) { + int i; + for (i = 0; i < 4; ++i) + if (stbi__get8(s) != (stbi_uc)str[i]) + return 0; + + return 1; +} + +static int stbi__pic_test_core(stbi__context *s) { + int i; + + if (!stbi__pic_is4(s, "\x53\x80\xF6\x34")) + return 0; + + for (i = 0; i < 84; ++i) + stbi__get8(s); + + if (!stbi__pic_is4(s, "PICT")) + return 0; + + return 1; +} + +typedef struct { + stbi_uc size, type, channel; +} stbi__pic_packet; + +static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest) { + int mask = 0x80, i; + + for (i = 0; i < 4; ++i, mask >>= 1) { + if (channel & mask) { + if (stbi__at_eof(s)) + return stbi__errpuc("bad file", "PIC file too short"); + dest[i] = stbi__get8(s); + } + } + + return dest; +} + +static void stbi__copyval(int channel, stbi_uc *dest, const stbi_uc *src) { + int mask = 0x80, i; + + for (i = 0; i < 4; ++i, mask >>= 1) + if (channel & mask) + dest[i] = src[i]; +} + +static stbi_uc *stbi__pic_load_core(stbi__context *s, int width, int height, int *comp, + stbi_uc *result) { + int act_comp = 0, num_packets = 0, y, chained; + stbi__pic_packet packets[10]; + + // this will (should...) cater for even some bizarre stuff like having data + // for the same channel in multiple packets. + do { + stbi__pic_packet *packet; + + if (num_packets == sizeof(packets) / sizeof(packets[0])) + return stbi__errpuc("bad format", "too many packets"); + + packet = &packets[num_packets++]; + + chained = stbi__get8(s); + packet->size = stbi__get8(s); + packet->type = stbi__get8(s); + packet->channel = stbi__get8(s); + + act_comp |= packet->channel; + + if (stbi__at_eof(s)) + return stbi__errpuc("bad file", "file too short (reading packets)"); + if (packet->size != 8) + return stbi__errpuc("bad format", "packet isn't 8bpp"); + } while (chained); + + *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel? + + for (y = 0; y < height; ++y) { + int packet_idx; + + for (packet_idx = 0; packet_idx < num_packets; ++packet_idx) { + stbi__pic_packet *packet = &packets[packet_idx]; + stbi_uc *dest = result + y * width * 4; + + switch (packet->type) { + default: + return stbi__errpuc("bad format", "packet has bad compression type"); + + case 0: { // uncompressed + int x; + + for (x = 0; x < width; ++x, dest += 4) + if (!stbi__readval(s, packet->channel, dest)) + return 0; + break; + } + + case 1: // Pure RLE + { + int left = width, i; + + while (left > 0) { + stbi_uc count, value[4]; + + count = stbi__get8(s); + if (stbi__at_eof(s)) + return stbi__errpuc("bad file", "file too short (pure read count)"); + + if (count > left) + count = (stbi_uc)left; + + if (!stbi__readval(s, packet->channel, value)) + return 0; + + for (i = 0; i < count; ++i, dest += 4) + stbi__copyval(packet->channel, dest, value); + left -= count; + } + } break; + + case 2: { // Mixed RLE + int left = width; + while (left > 0) { + int count = stbi__get8(s), i; + if (stbi__at_eof(s)) + return stbi__errpuc("bad file", "file too short (mixed read count)"); + + if (count >= 128) { // Repeated + stbi_uc value[4]; + + if (count == 128) + count = stbi__get16be(s); + else + count -= 127; + if (count > left) + return stbi__errpuc("bad file", "scanline overrun"); + + if (!stbi__readval(s, packet->channel, value)) + return 0; + + for (i = 0; i < count; ++i, dest += 4) + stbi__copyval(packet->channel, dest, value); + } else { // Raw + ++count; + if (count > left) + return stbi__errpuc("bad file", "scanline overrun"); + + for (i = 0; i < count; ++i, dest += 4) + if (!stbi__readval(s, packet->channel, dest)) + return 0; + } + left -= count; + } + break; + } + } + } + } + + return result; +} + +static void *stbi__pic_load(stbi__context *s, int *px, int *py, int *comp, int req_comp, + stbi__result_info *ri) { + stbi_uc *result; + int i, x, y, internal_comp; + STBI_NOTUSED(ri); + + if (!comp) + comp = &internal_comp; + + for (i = 0; i < 92; ++i) + stbi__get8(s); + + x = stbi__get16be(s); + y = stbi__get16be(s); + + if (y > STBI_MAX_DIMENSIONS) + return stbi__errpuc("too large", "Very large image (corrupt?)"); + if (x > STBI_MAX_DIMENSIONS) + return stbi__errpuc("too large", "Very large image (corrupt?)"); + + if (stbi__at_eof(s)) + return stbi__errpuc("bad file", "file too short (pic header)"); + if (!stbi__mad3sizes_valid(x, y, 4, 0)) + return stbi__errpuc("too large", "PIC image too large to decode"); + + stbi__get32be(s); // skip `ratio' + stbi__get16be(s); // skip `fields' + stbi__get16be(s); // skip `pad' + + // intermediate buffer is RGBA + result = (stbi_uc *)stbi__malloc_mad3(x, y, 4, 0); + if (!result) + return stbi__errpuc("outofmem", "Out of memory"); + memset(result, 0xff, x * y * 4); + + if (!stbi__pic_load_core(s, x, y, comp, result)) { + STBI_FREE(result); + result = 0; + } + *px = x; + *py = y; + if (req_comp == 0) + req_comp = *comp; + result = stbi__convert_format(result, 4, req_comp, x, y); + + return result; +} + +static int stbi__pic_test(stbi__context *s) { + int r = stbi__pic_test_core(s); + stbi__rewind(s); + return r; +} +#endif + +// ************************************************************************************************* +// GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb + +#ifndef STBI_NO_GIF +typedef struct { + stbi__int16 prefix; + stbi_uc first; + stbi_uc suffix; +} stbi__gif_lzw; + +typedef struct { + int w, h; + stbi_uc *out; // output buffer (always 4 components) + stbi_uc *background; // The current "background" as far as a gif is concerned + stbi_uc *history; + int flags, bgindex, ratio, transparent, eflags; + stbi_uc pal[256][4]; + stbi_uc lpal[256][4]; + stbi__gif_lzw codes[8192]; + stbi_uc *color_table; + int parse, step; + int lflags; + int start_x, start_y; + int max_x, max_y; + int cur_x, cur_y; + int line_size; + int delay; +} stbi__gif; + +static int stbi__gif_test_raw(stbi__context *s) { + int sz; + if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || + stbi__get8(s) != '8') + return 0; + sz = stbi__get8(s); + if (sz != '9' && sz != '7') + return 0; + if (stbi__get8(s) != 'a') + return 0; + return 1; +} + +static int stbi__gif_test(stbi__context *s) { + int r = stbi__gif_test_raw(s); + stbi__rewind(s); + return r; +} + +static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], int num_entries, + int transp) { + int i; + for (i = 0; i < num_entries; ++i) { + pal[i][2] = stbi__get8(s); + pal[i][1] = stbi__get8(s); + pal[i][0] = stbi__get8(s); + pal[i][3] = transp == i ? 0 : 255; + } +} + +static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info) { + stbi_uc version; + if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || + stbi__get8(s) != '8') + return stbi__err("not GIF", "Corrupt GIF"); + + version = stbi__get8(s); + if (version != '7' && version != '9') + return stbi__err("not GIF", "Corrupt GIF"); + if (stbi__get8(s) != 'a') + return stbi__err("not GIF", "Corrupt GIF"); + + stbi__g_failure_reason = ""; + g->w = stbi__get16le(s); + g->h = stbi__get16le(s); + g->flags = stbi__get8(s); + g->bgindex = stbi__get8(s); + g->ratio = stbi__get8(s); + g->transparent = -1; + + if (g->w > STBI_MAX_DIMENSIONS) + return stbi__err("too large", "Very large image (corrupt?)"); + if (g->h > STBI_MAX_DIMENSIONS) + return stbi__err("too large", "Very large image (corrupt?)"); + + if (comp != 0) + *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments + + if (is_info) + return 1; + + if (g->flags & 0x80) + stbi__gif_parse_colortable(s, g->pal, 2 << (g->flags & 7), -1); + + return 1; +} + +static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp) { + stbi__gif *g = (stbi__gif *)stbi__malloc(sizeof(stbi__gif)); + if (!g) + return stbi__err("outofmem", "Out of memory"); + if (!stbi__gif_header(s, g, comp, 1)) { + STBI_FREE(g); + stbi__rewind(s); + return 0; + } + if (x) + *x = g->w; + if (y) + *y = g->h; + STBI_FREE(g); + return 1; +} + +static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code) { + stbi_uc *p, *c; + int idx; + + // recurse to decode the prefixes, since the linked-list is backwards, + // and working backwards through an interleaved image would be nasty + if (g->codes[code].prefix >= 0) + stbi__out_gif_code(g, g->codes[code].prefix); + + if (g->cur_y >= g->max_y) + return; + + idx = g->cur_x + g->cur_y; + p = &g->out[idx]; + g->history[idx / 4] = 1; + + c = &g->color_table[g->codes[code].suffix * 4]; + if (c[3] > 128) { // don't render transparent pixels; + p[0] = c[2]; + p[1] = c[1]; + p[2] = c[0]; + p[3] = c[3]; + } + g->cur_x += 4; + + if (g->cur_x >= g->max_x) { + g->cur_x = g->start_x; + g->cur_y += g->step; + + while (g->cur_y >= g->max_y && g->parse > 0) { + g->step = (1 << g->parse) * g->line_size; + g->cur_y = g->start_y + (g->step >> 1); + --g->parse; + } + } +} + +static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g) { + stbi_uc lzw_cs; + stbi__int32 len, init_code; + stbi__uint32 first; + stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear; + stbi__gif_lzw *p; + + lzw_cs = stbi__get8(s); + if (lzw_cs > 12) + return NULL; + clear = 1 << lzw_cs; + first = 1; + codesize = lzw_cs + 1; + codemask = (1 << codesize) - 1; + bits = 0; + valid_bits = 0; + for (init_code = 0; init_code < clear; init_code++) { + g->codes[init_code].prefix = -1; + g->codes[init_code].first = (stbi_uc)init_code; + g->codes[init_code].suffix = (stbi_uc)init_code; + } + + // support no starting clear code + avail = clear + 2; + oldcode = -1; + + len = 0; + for (;;) { + if (valid_bits < codesize) { + if (len == 0) { + len = stbi__get8(s); // start new block + if (len == 0) + return g->out; + } + --len; + bits |= (stbi__int32)stbi__get8(s) << valid_bits; + valid_bits += 8; + } else { + stbi__int32 code = bits & codemask; + bits >>= codesize; + valid_bits -= codesize; + // @OPTIMIZE: is there some way we can accelerate the non-clear path? + if (code == clear) { // clear code + codesize = lzw_cs + 1; + codemask = (1 << codesize) - 1; + avail = clear + 2; + oldcode = -1; + first = 0; + } else if (code == clear + 1) { // end of stream code + stbi__skip(s, len); + while ((len = stbi__get8(s)) > 0) + stbi__skip(s, len); + return g->out; + } else if (code <= avail) { + if (first) { + return stbi__errpuc("no clear code", "Corrupt GIF"); + } + + if (oldcode >= 0) { + p = &g->codes[avail++]; + if (avail > 8192) { + return stbi__errpuc("too many codes", "Corrupt GIF"); + } + + p->prefix = (stbi__int16)oldcode; + p->first = g->codes[oldcode].first; + p->suffix = (code == avail) ? p->first : g->codes[code].first; + } else if (code == avail) + return stbi__errpuc("illegal code in raster", "Corrupt GIF"); + + stbi__out_gif_code(g, (stbi__uint16)code); + + if ((avail & codemask) == 0 && avail <= 0x0FFF) { + codesize++; + codemask = (1 << codesize) - 1; + } + + oldcode = code; + } else { + return stbi__errpuc("illegal code in raster", "Corrupt GIF"); + } + } + } +} + +// this function is designed to support animated gifs, although stb_image doesn't support it +// two back is the image from two frames ago, used for a very specific disposal format +static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, + stbi_uc *two_back) { + int dispose; + int first_frame; + int pi; + int pcount; + STBI_NOTUSED(req_comp); + + // on first frame, any non-written pixels get the background colour (non-transparent) + first_frame = 0; + if (g->out == 0) { + if (!stbi__gif_header(s, g, comp, 0)) + return 0; // stbi__g_failure_reason set by stbi__gif_header + if (!stbi__mad3sizes_valid(4, g->w, g->h, 0)) + return stbi__errpuc("too large", "GIF image is too large"); + pcount = g->w * g->h; + g->out = (stbi_uc *)stbi__malloc(4 * pcount); + g->background = (stbi_uc *)stbi__malloc(4 * pcount); + g->history = (stbi_uc *)stbi__malloc(pcount); + if (!g->out || !g->background || !g->history) + return stbi__errpuc("outofmem", "Out of memory"); + + // image is treated as "transparent" at the start - ie, nothing overwrites the current + // background; background colour is only used for pixels that are not rendered first frame, + // after that "background" color refers to the color that was there the previous frame. + memset(g->out, 0x00, 4 * pcount); + memset(g->background, 0x00, 4 * pcount); // state of the background (starts transparent) + memset(g->history, 0x00, pcount); // pixels that were affected previous frame + first_frame = 1; + } else { + // second frame - how do we dispose of the previous one? + dispose = (g->eflags & 0x1C) >> 2; + pcount = g->w * g->h; + + if ((dispose == 3) && (two_back == 0)) { + dispose = + 2; // if I don't have an image to revert back to, default to the old background + } + + if (dispose == 3) { // use previous graphic + for (pi = 0; pi < pcount; ++pi) { + if (g->history[pi]) { + memcpy(&g->out[pi * 4], &two_back[pi * 4], 4); + } + } + } else if (dispose == 2) { + // restore what was changed last frame to background before that frame; + for (pi = 0; pi < pcount; ++pi) { + if (g->history[pi]) { + memcpy(&g->out[pi * 4], &g->background[pi * 4], 4); + } + } + } else { + // This is a non-disposal case eithe way, so just + // leave the pixels as is, and they will become the new background + // 1: do not dispose + // 0: not specified. + } + + // background is what out is after the undoing of the previou frame; + memcpy(g->background, g->out, 4 * g->w * g->h); + } + + // clear my history; + memset(g->history, 0x00, g->w * g->h); // pixels that were affected previous frame + + for (;;) { + int tag = stbi__get8(s); + switch (tag) { + case 0x2C: /* Image Descriptor */ + { + stbi__int32 x, y, w, h; + stbi_uc *o; + + x = stbi__get16le(s); + y = stbi__get16le(s); + w = stbi__get16le(s); + h = stbi__get16le(s); + if (((x + w) > (g->w)) || ((y + h) > (g->h))) + return stbi__errpuc("bad Image Descriptor", "Corrupt GIF"); + + g->line_size = g->w * 4; + g->start_x = x * 4; + g->start_y = y * g->line_size; + g->max_x = g->start_x + w * 4; + g->max_y = g->start_y + h * g->line_size; + g->cur_x = g->start_x; + g->cur_y = g->start_y; + + // if the width of the specified rectangle is 0, that means + // we may not see *any* pixels or the image is malformed; + // to make sure this is caught, move the current y down to + // max_y (which is what out_gif_code checks). + if (w == 0) + g->cur_y = g->max_y; + + g->lflags = stbi__get8(s); + + if (g->lflags & 0x40) { + g->step = 8 * g->line_size; // first interlaced spacing + g->parse = 3; + } else { + g->step = g->line_size; + g->parse = 0; + } + + if (g->lflags & 0x80) { + stbi__gif_parse_colortable(s, g->lpal, 2 << (g->lflags & 7), + g->eflags & 0x01 ? g->transparent : -1); + g->color_table = (stbi_uc *)g->lpal; + } else if (g->flags & 0x80) { + g->color_table = (stbi_uc *)g->pal; + } else + return stbi__errpuc("missing color table", "Corrupt GIF"); + + o = stbi__process_gif_raster(s, g); + if (!o) + return NULL; + + // if this was the first frame, + pcount = g->w * g->h; + if (first_frame && (g->bgindex > 0)) { + // if first frame, any pixel not drawn to gets the background color + for (pi = 0; pi < pcount; ++pi) { + if (g->history[pi] == 0) { + g->pal[g->bgindex][3] = + 255; // just in case it was made transparent, undo that; It will be + // reset next frame if need be; + memcpy(&g->out[pi * 4], &g->pal[g->bgindex], 4); + } + } + } + + return o; + } + + case 0x21: // Comment Extension. + { + int len; + int ext = stbi__get8(s); + if (ext == 0xF9) { // Graphic Control Extension. + len = stbi__get8(s); + if (len == 4) { + g->eflags = stbi__get8(s); + g->delay = + 10 * stbi__get16le(s); // delay - 1/100th of a second, saving as 1/1000ths. + + // unset old transparent + if (g->transparent >= 0) { + g->pal[g->transparent][3] = 255; + } + if (g->eflags & 0x01) { + g->transparent = stbi__get8(s); + if (g->transparent >= 0) { + g->pal[g->transparent][3] = 0; + } + } else { + // don't need transparent + stbi__skip(s, 1); + g->transparent = -1; + } + } else { + stbi__skip(s, len); + break; + } + } + while ((len = stbi__get8(s)) != 0) { + stbi__skip(s, len); + } + break; + } + + case 0x3B: // gif stream termination code + return (stbi_uc *)s; // using '1' causes warning on some compilers + + default: + return stbi__errpuc("unknown code", "Corrupt GIF"); + } + } +} + +static void *stbi__load_gif_main_outofmem(stbi__gif *g, stbi_uc *out, int **delays) { + STBI_FREE(g->out); + STBI_FREE(g->history); + STBI_FREE(g->background); + + if (out) + STBI_FREE(out); + if (delays && *delays) + STBI_FREE(*delays); + return stbi__errpuc("outofmem", "Out of memory"); +} + +static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, + int req_comp) { + if (stbi__gif_test(s)) { + int layers = 0; + stbi_uc *u = 0; + stbi_uc *out = 0; + stbi_uc *two_back = 0; + stbi__gif g; + int stride; + int out_size = 0; + int delays_size = 0; + + STBI_NOTUSED(out_size); + STBI_NOTUSED(delays_size); + + memset(&g, 0, sizeof(g)); + if (delays) { + *delays = 0; + } + + do { + u = stbi__gif_load_next(s, &g, comp, req_comp, two_back); + if (u == (stbi_uc *)s) + u = 0; // end of animated gif marker + + if (u) { + *x = g.w; + *y = g.h; + ++layers; + stride = g.w * g.h * 4; + + if (out) { + void *tmp = (stbi_uc *)STBI_REALLOC_SIZED(out, out_size, layers * stride); + if (!tmp) + return stbi__load_gif_main_outofmem(&g, out, delays); + else { + out = (stbi_uc *)tmp; + out_size = layers * stride; + } + + if (delays) { + int *new_delays = + (int *)STBI_REALLOC_SIZED(*delays, delays_size, sizeof(int) * layers); + if (!new_delays) + return stbi__load_gif_main_outofmem(&g, out, delays); + *delays = new_delays; + delays_size = layers * sizeof(int); + } + } else { + out = (stbi_uc *)stbi__malloc(layers * stride); + if (!out) + return stbi__load_gif_main_outofmem(&g, out, delays); + out_size = layers * stride; + if (delays) { + *delays = (int *)stbi__malloc(layers * sizeof(int)); + if (!*delays) + return stbi__load_gif_main_outofmem(&g, out, delays); + delays_size = layers * sizeof(int); + } + } + memcpy(out + ((layers - 1) * stride), u, stride); + if (layers >= 2) { + two_back = out - 2 * stride; + } + + if (delays) { + (*delays)[layers - 1U] = g.delay; + } + } + } while (u != 0); + + // free temp buffer; + STBI_FREE(g.out); + STBI_FREE(g.history); + STBI_FREE(g.background); + + // do the final conversion after loading everything; + if (req_comp && req_comp != 4) + out = stbi__convert_format(out, 4, req_comp, layers * g.w, g.h); + + *z = layers; + return out; + } else { + return stbi__errpuc("not GIF", "Image was not as a gif type."); + } +} + +static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, + stbi__result_info *ri) { + stbi_uc *u = 0; + stbi__gif g; + memset(&g, 0, sizeof(g)); + STBI_NOTUSED(ri); + + u = stbi__gif_load_next(s, &g, comp, req_comp, 0); + if (u == (stbi_uc *)s) + u = 0; // end of animated gif marker + if (u) { + *x = g.w; + *y = g.h; + + // moved conversion to after successful load so that the same + // can be done for multiple frames. + if (req_comp && req_comp != 4) + u = stbi__convert_format(u, 4, req_comp, g.w, g.h); + } else if (g.out) { + // if there was an error and we allocated an image buffer, free it! + STBI_FREE(g.out); + } + + // free buffers needed for multiple frame loading; + STBI_FREE(g.history); + STBI_FREE(g.background); + + return u; +} + +static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp) { + return stbi__gif_info_raw(s, x, y, comp); +} +#endif + +// ************************************************************************************************* +// Radiance RGBE HDR loader +// originally by Nicolas Schulz +#ifndef STBI_NO_HDR +static int stbi__hdr_test_core(stbi__context *s, const char *signature) { + int i; + for (i = 0; signature[i]; ++i) + if (stbi__get8(s) != signature[i]) + return 0; + stbi__rewind(s); + return 1; +} + +static int stbi__hdr_test(stbi__context *s) { + int r = stbi__hdr_test_core(s, "#?RADIANCE\n"); + stbi__rewind(s); + if (!r) { + r = stbi__hdr_test_core(s, "#?RGBE\n"); + stbi__rewind(s); + } + return r; +} + +#define STBI__HDR_BUFLEN 1024 +static char *stbi__hdr_gettoken(stbi__context *z, char *buffer) { + int len = 0; + char c = '\0'; + + c = (char)stbi__get8(z); + + while (!stbi__at_eof(z) && c != '\n') { + buffer[len++] = c; + if (len == STBI__HDR_BUFLEN - 1) { + // flush to end of line + while (!stbi__at_eof(z) && stbi__get8(z) != '\n') + ; + break; + } + c = (char)stbi__get8(z); + } + + buffer[len] = 0; + return buffer; +} + +static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp) { + if (input[3] != 0) { + float f1; + // Exponent + f1 = (float)ldexp(1.0f, input[3] - (int)(128 + 8)); + if (req_comp <= 2) + output[0] = (input[0] + input[1] + input[2]) * f1 / 3; + else { + output[0] = input[0] * f1; + output[1] = input[1] * f1; + output[2] = input[2] * f1; + } + if (req_comp == 2) + output[1] = 1; + if (req_comp == 4) + output[3] = 1; + } else { + switch (req_comp) { + case 4: + output[3] = 1; /* fallthrough */ + case 3: + output[0] = output[1] = output[2] = 0; + break; + case 2: + output[1] = 1; /* fallthrough */ + case 1: + output[0] = 0; + break; + } + } +} + +static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, + stbi__result_info *ri) { + char buffer[STBI__HDR_BUFLEN]; + char *token; + int valid = 0; + int width, height; + stbi_uc *scanline; + float *hdr_data; + int len; + unsigned char count, value; + int i, j, k, c1, c2, z; + const char *headerToken; + STBI_NOTUSED(ri); + + // Check identifier + headerToken = stbi__hdr_gettoken(s, buffer); + if (strcmp(headerToken, "#?RADIANCE") != 0 && strcmp(headerToken, "#?RGBE") != 0) + return stbi__errpf("not HDR", "Corrupt HDR image"); + + // Parse header + for (;;) { + token = stbi__hdr_gettoken(s, buffer); + if (token[0] == 0) + break; + if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) + valid = 1; + } + + if (!valid) + return stbi__errpf("unsupported format", "Unsupported HDR format"); + + // Parse width and height + // can't use sscanf() if we're not using stdio! + token = stbi__hdr_gettoken(s, buffer); + if (strncmp(token, "-Y ", 3)) + return stbi__errpf("unsupported data layout", "Unsupported HDR format"); + token += 3; + height = (int)strtol(token, &token, 10); + while (*token == ' ') + ++token; + if (strncmp(token, "+X ", 3)) + return stbi__errpf("unsupported data layout", "Unsupported HDR format"); + token += 3; + width = (int)strtol(token, NULL, 10); + + if (height > STBI_MAX_DIMENSIONS) + return stbi__errpf("too large", "Very large image (corrupt?)"); + if (width > STBI_MAX_DIMENSIONS) + return stbi__errpf("too large", "Very large image (corrupt?)"); + + *x = width; + *y = height; + + if (comp) + *comp = 3; + if (req_comp == 0) + req_comp = 3; + + if (!stbi__mad4sizes_valid(width, height, req_comp, sizeof(float), 0)) + return stbi__errpf("too large", "HDR image is too large"); + + // Read data + hdr_data = (float *)stbi__malloc_mad4(width, height, req_comp, sizeof(float), 0); + if (!hdr_data) + return stbi__errpf("outofmem", "Out of memory"); + + // Load image data + // image data is stored as some number of sca + if (width < 8 || width >= 32768) { + // Read flat data + for (j = 0; j < height; ++j) { + for (i = 0; i < width; ++i) { + stbi_uc rgbe[4]; + main_decode_loop: + stbi__getn(s, rgbe, 4); + stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp); + } + } + } else { + // Read RLE-encoded data + scanline = NULL; + + for (j = 0; j < height; ++j) { + c1 = stbi__get8(s); + c2 = stbi__get8(s); + len = stbi__get8(s); + if (c1 != 2 || c2 != 2 || (len & 0x80)) { + // not run-length encoded, so we have to actually use THIS data as a decoded + // pixel (note this can't be a valid pixel--one of RGB must be >= 128) + stbi_uc rgbe[4]; + rgbe[0] = (stbi_uc)c1; + rgbe[1] = (stbi_uc)c2; + rgbe[2] = (stbi_uc)len; + rgbe[3] = (stbi_uc)stbi__get8(s); + stbi__hdr_convert(hdr_data, rgbe, req_comp); + i = 1; + j = 0; + STBI_FREE(scanline); + goto main_decode_loop; // yes, this makes no sense + } + len <<= 8; + len |= stbi__get8(s); + if (len != width) { + STBI_FREE(hdr_data); + STBI_FREE(scanline); + return stbi__errpf("invalid decoded scanline length", "corrupt HDR"); + } + if (scanline == NULL) { + scanline = (stbi_uc *)stbi__malloc_mad2(width, 4, 0); + if (!scanline) { + STBI_FREE(hdr_data); + return stbi__errpf("outofmem", "Out of memory"); + } + } + + for (k = 0; k < 4; ++k) { + int nleft; + i = 0; + while ((nleft = width - i) > 0) { + count = stbi__get8(s); + if (count > 128) { + // Run + value = stbi__get8(s); + count -= 128; + if ((count == 0) || (count > nleft)) { + STBI_FREE(hdr_data); + STBI_FREE(scanline); + return stbi__errpf("corrupt", "bad RLE data in HDR"); + } + for (z = 0; z < count; ++z) + scanline[i++ * 4 + k] = value; + } else { + // Dump + if ((count == 0) || (count > nleft)) { + STBI_FREE(hdr_data); + STBI_FREE(scanline); + return stbi__errpf("corrupt", "bad RLE data in HDR"); + } + for (z = 0; z < count; ++z) + scanline[i++ * 4 + k] = stbi__get8(s); + } + } + } + for (i = 0; i < width; ++i) + stbi__hdr_convert(hdr_data + (j * width + i) * req_comp, scanline + i * 4, + req_comp); + } + if (scanline) + STBI_FREE(scanline); + } + + return hdr_data; +} + +static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp) { + char buffer[STBI__HDR_BUFLEN]; + char *token; + int valid = 0; + int dummy; + + if (!x) + x = &dummy; + if (!y) + y = &dummy; + if (!comp) + comp = &dummy; + + if (stbi__hdr_test(s) == 0) { + stbi__rewind(s); + return 0; + } + + for (;;) { + token = stbi__hdr_gettoken(s, buffer); + if (token[0] == 0) + break; + if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) + valid = 1; + } + + if (!valid) { + stbi__rewind(s); + return 0; + } + token = stbi__hdr_gettoken(s, buffer); + if (strncmp(token, "-Y ", 3)) { + stbi__rewind(s); + return 0; + } + token += 3; + *y = (int)strtol(token, &token, 10); + while (*token == ' ') + ++token; + if (strncmp(token, "+X ", 3)) { + stbi__rewind(s); + return 0; + } + token += 3; + *x = (int)strtol(token, NULL, 10); + *comp = 3; + return 1; +} +#endif // STBI_NO_HDR + +#ifndef STBI_NO_BMP +static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp) { + void *p; + stbi__bmp_data info; + + info.all_a = 255; + p = stbi__bmp_parse_header(s, &info); + if (p == NULL) { + stbi__rewind(s); + return 0; + } + if (x) + *x = s->img_x; + if (y) + *y = s->img_y; + if (comp) { + if (info.bpp == 24 && info.ma == 0xff000000) + *comp = 3; + else + *comp = info.ma ? 4 : 3; + } + return 1; +} +#endif + +#ifndef STBI_NO_PSD +static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp) { + int channelCount, dummy, depth; + if (!x) + x = &dummy; + if (!y) + y = &dummy; + if (!comp) + comp = &dummy; + if (stbi__get32be(s) != 0x38425053) { + stbi__rewind(s); + return 0; + } + if (stbi__get16be(s) != 1) { + stbi__rewind(s); + return 0; + } + stbi__skip(s, 6); + channelCount = stbi__get16be(s); + if (channelCount < 0 || channelCount > 16) { + stbi__rewind(s); + return 0; + } + *y = stbi__get32be(s); + *x = stbi__get32be(s); + depth = stbi__get16be(s); + if (depth != 8 && depth != 16) { + stbi__rewind(s); + return 0; + } + if (stbi__get16be(s) != 3) { + stbi__rewind(s); + return 0; + } + *comp = 4; + return 1; +} + +static int stbi__psd_is16(stbi__context *s) { + int channelCount, depth; + if (stbi__get32be(s) != 0x38425053) { + stbi__rewind(s); + return 0; + } + if (stbi__get16be(s) != 1) { + stbi__rewind(s); + return 0; + } + stbi__skip(s, 6); + channelCount = stbi__get16be(s); + if (channelCount < 0 || channelCount > 16) { + stbi__rewind(s); + return 0; + } + STBI_NOTUSED(stbi__get32be(s)); + STBI_NOTUSED(stbi__get32be(s)); + depth = stbi__get16be(s); + if (depth != 16) { + stbi__rewind(s); + return 0; + } + return 1; +} +#endif + +#ifndef STBI_NO_PIC +static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp) { + int act_comp = 0, num_packets = 0, chained, dummy; + stbi__pic_packet packets[10]; + + if (!x) + x = &dummy; + if (!y) + y = &dummy; + if (!comp) + comp = &dummy; + + if (!stbi__pic_is4(s, "\x53\x80\xF6\x34")) { + stbi__rewind(s); + return 0; + } + + stbi__skip(s, 88); + + *x = stbi__get16be(s); + *y = stbi__get16be(s); + if (stbi__at_eof(s)) { + stbi__rewind(s); + return 0; + } + if ((*x) != 0 && (1 << 28) / (*x) < (*y)) { + stbi__rewind(s); + return 0; + } + + stbi__skip(s, 8); + + do { + stbi__pic_packet *packet; + + if (num_packets == sizeof(packets) / sizeof(packets[0])) + return 0; + + packet = &packets[num_packets++]; + chained = stbi__get8(s); + packet->size = stbi__get8(s); + packet->type = stbi__get8(s); + packet->channel = stbi__get8(s); + act_comp |= packet->channel; + + if (stbi__at_eof(s)) { + stbi__rewind(s); + return 0; + } + if (packet->size != 8) { + stbi__rewind(s); + return 0; + } + } while (chained); + + *comp = (act_comp & 0x10 ? 4 : 3); + + return 1; +} +#endif + +// ************************************************************************************************* +// Portable Gray Map and Portable Pixel Map loader +// by Ken Miller +// +// PGM: http://netpbm.sourceforge.net/doc/pgm.html +// PPM: http://netpbm.sourceforge.net/doc/ppm.html +// +// Known limitations: +// Does not support comments in the header section +// Does not support ASCII image data (formats P2 and P3) + +#ifndef STBI_NO_PNM + +static int stbi__pnm_test(stbi__context *s) { + char p, t; + p = (char)stbi__get8(s); + t = (char)stbi__get8(s); + if (p != 'P' || (t != '5' && t != '6')) { + stbi__rewind(s); + return 0; + } + return 1; +} + +static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, + stbi__result_info *ri) { + stbi_uc *out; + STBI_NOTUSED(ri); + + ri->bits_per_channel = stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n); + if (ri->bits_per_channel == 0) + return 0; + + if (s->img_y > STBI_MAX_DIMENSIONS) + return stbi__errpuc("too large", "Very large image (corrupt?)"); + if (s->img_x > STBI_MAX_DIMENSIONS) + return stbi__errpuc("too large", "Very large image (corrupt?)"); + + *x = s->img_x; + *y = s->img_y; + if (comp) + *comp = s->img_n; + + if (!stbi__mad4sizes_valid(s->img_n, s->img_x, s->img_y, ri->bits_per_channel / 8, 0)) + return stbi__errpuc("too large", "PNM too large"); + + out = (stbi_uc *)stbi__malloc_mad4(s->img_n, s->img_x, s->img_y, ri->bits_per_channel / 8, 0); + if (!out) + return stbi__errpuc("outofmem", "Out of memory"); + if (!stbi__getn(s, out, s->img_n * s->img_x * s->img_y * (ri->bits_per_channel / 8))) { + STBI_FREE(out); + return stbi__errpuc("bad PNM", "PNM file truncated"); + } + + if (req_comp && req_comp != s->img_n) { + if (ri->bits_per_channel == 16) { + out = (stbi_uc *)stbi__convert_format16((stbi__uint16 *)out, s->img_n, req_comp, + s->img_x, s->img_y); + } else { + out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y); + } + if (out == NULL) + return out; // stbi__convert_format frees input on failure + } + return out; +} + +static int stbi__pnm_isspace(char c) { + return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'; +} + +static void stbi__pnm_skip_whitespace(stbi__context *s, char *c) { + for (;;) { + while (!stbi__at_eof(s) && stbi__pnm_isspace(*c)) + *c = (char)stbi__get8(s); + + if (stbi__at_eof(s) || *c != '#') + break; + + while (!stbi__at_eof(s) && *c != '\n' && *c != '\r') + *c = (char)stbi__get8(s); + } +} + +static int stbi__pnm_isdigit(char c) { return c >= '0' && c <= '9'; } + +static int stbi__pnm_getinteger(stbi__context *s, char *c) { + int value = 0; + + while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) { + value = value * 10 + (*c - '0'); + *c = (char)stbi__get8(s); + if ((value > 214748364) || (value == 214748364 && *c > '7')) + return stbi__err("integer parse overflow", + "Parsing an integer in the PPM header overflowed a 32-bit int"); + } + + return value; +} + +static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp) { + int maxv, dummy; + char c, p, t; + + if (!x) + x = &dummy; + if (!y) + y = &dummy; + if (!comp) + comp = &dummy; + + stbi__rewind(s); + + // Get identifier + p = (char)stbi__get8(s); + t = (char)stbi__get8(s); + if (p != 'P' || (t != '5' && t != '6')) { + stbi__rewind(s); + return 0; + } + + *comp = (t == '6') ? 3 : 1; // '5' is 1-component .pgm; '6' is 3-component .ppm + + c = (char)stbi__get8(s); + stbi__pnm_skip_whitespace(s, &c); + + *x = stbi__pnm_getinteger(s, &c); // read width + if (*x == 0) + return stbi__err("invalid width", "PPM image header had zero or overflowing width"); + stbi__pnm_skip_whitespace(s, &c); + + *y = stbi__pnm_getinteger(s, &c); // read height + if (*y == 0) + return stbi__err("invalid width", "PPM image header had zero or overflowing width"); + stbi__pnm_skip_whitespace(s, &c); + + maxv = stbi__pnm_getinteger(s, &c); // read max value + if (maxv > 65535) + return stbi__err("max value > 65535", "PPM image supports only 8-bit and 16-bit images"); + else if (maxv > 255) + return 16; + else + return 8; +} + +static int stbi__pnm_is16(stbi__context *s) { + if (stbi__pnm_info(s, NULL, NULL, NULL) == 16) + return 1; + return 0; +} +#endif + +static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp) { +#ifndef STBI_NO_JPEG + if (stbi__jpeg_info(s, x, y, comp)) + return 1; +#endif + +#ifndef STBI_NO_PNG + if (stbi__png_info(s, x, y, comp)) + return 1; +#endif + +#ifndef STBI_NO_GIF + if (stbi__gif_info(s, x, y, comp)) + return 1; +#endif + +#ifndef STBI_NO_BMP + if (stbi__bmp_info(s, x, y, comp)) + return 1; +#endif + +#ifndef STBI_NO_PSD + if (stbi__psd_info(s, x, y, comp)) + return 1; +#endif + +#ifndef STBI_NO_PIC + if (stbi__pic_info(s, x, y, comp)) + return 1; +#endif + +#ifndef STBI_NO_PNM + if (stbi__pnm_info(s, x, y, comp)) + return 1; +#endif + +#ifndef STBI_NO_HDR + if (stbi__hdr_info(s, x, y, comp)) + return 1; +#endif + +// test tga last because it's a crappy test! +#ifndef STBI_NO_TGA + if (stbi__tga_info(s, x, y, comp)) + return 1; +#endif + return stbi__err("unknown image type", "Image not of any known type, or corrupt"); +} + +static int stbi__is_16_main(stbi__context *s) { +#ifndef STBI_NO_PNG + if (stbi__png_is16(s)) + return 1; +#endif + +#ifndef STBI_NO_PSD + if (stbi__psd_is16(s)) + return 1; +#endif + +#ifndef STBI_NO_PNM + if (stbi__pnm_is16(s)) + return 1; +#endif + return 0; +} + +#ifndef STBI_NO_STDIO +STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp) { + FILE *f = stbi__fopen(filename, "rb"); + int result; + if (!f) + return stbi__err("can't fopen", "Unable to open file"); + result = stbi_info_from_file(f, x, y, comp); + fclose(f); + return result; +} + +STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp) { + int r; + stbi__context s; + long pos = ftell(f); + stbi__start_file(&s, f); + r = stbi__info_main(&s, x, y, comp); + fseek(f, pos, SEEK_SET); + return r; +} + +STBIDEF int stbi_is_16_bit(char const *filename) { + FILE *f = stbi__fopen(filename, "rb"); + int result; + if (!f) + return stbi__err("can't fopen", "Unable to open file"); + result = stbi_is_16_bit_from_file(f); + fclose(f); + return result; +} + +STBIDEF int stbi_is_16_bit_from_file(FILE *f) { + int r; + stbi__context s; + long pos = ftell(f); + stbi__start_file(&s, f); + r = stbi__is_16_main(&s); + fseek(f, pos, SEEK_SET); + return r; +} +#endif // !STBI_NO_STDIO + +STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) { + stbi__context s; + stbi__start_mem(&s, buffer, len); + return stbi__info_main(&s, x, y, comp); +} + +STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, + int *comp) { + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)c, user); + return stbi__info_main(&s, x, y, comp); +} + +STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len) { + stbi__context s; + stbi__start_mem(&s, buffer, len); + return stbi__is_16_main(&s); +} + +STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user) { + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)c, user); + return stbi__is_16_main(&s); +} + +#endif // STB_IMAGE_IMPLEMENTATION + +/* + revision history: + 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs + 2.19 (2018-02-11) fix warning + 2.18 (2018-01-30) fix warnings + 2.17 (2018-01-29) change sbti__shiftsigned to avoid clang -O2 bug + 1-bit BMP + *_is_16_bit api + avoid warnings + 2.16 (2017-07-23) all functions have 16-bit variants; + STBI_NO_STDIO works again; + compilation fixes; + fix rounding in unpremultiply; + optimize vertical flip; + disable raw_len validation; + documentation fixes + 2.15 (2017-03-18) fix png-1,2,4 bug; now all Imagenet JPGs decode; + warning fixes; disable run-time SSE detection on gcc; + uniform handling of optional "return" values; + thread-safe initialization of zlib tables + 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs + 2.13 (2016-11-29) add 16-bit API, only supported for PNG right now + 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes + 2.11 (2016-04-02) allocate large structures on the stack + remove white matting for transparent PSD + fix reported channel count for PNG & BMP + re-enable SSE2 in non-gcc 64-bit + support RGB-formatted JPEG + read 16-bit PNGs (only as 8-bit) + 2.10 (2016-01-22) avoid warning introduced in 2.09 by STBI_REALLOC_SIZED + 2.09 (2016-01-16) allow comments in PNM files + 16-bit-per-pixel TGA (not bit-per-component) + info() for TGA could break due to .hdr handling + info() for BMP to shares code instead of sloppy parse + can use STBI_REALLOC_SIZED if allocator doesn't support realloc + code cleanup + 2.08 (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA + 2.07 (2015-09-13) fix compiler warnings + partial animated GIF support + limited 16-bpc PSD support + #ifdef unused functions + bug with < 92 byte PIC,PNM,HDR,TGA + 2.06 (2015-04-19) fix bug where PSD returns wrong '*comp' value + 2.05 (2015-04-19) fix bug in progressive JPEG handling, fix warning + 2.04 (2015-04-15) try to re-enable SIMD on MinGW 64-bit + 2.03 (2015-04-12) extra corruption checking (mmozeiko) + stbi_set_flip_vertically_on_load (nguillemot) + fix NEON support; fix mingw support + 2.02 (2015-01-19) fix incorrect assert, fix warning + 2.01 (2015-01-17) fix various warnings; suppress SIMD on gcc 32-bit without -msse2 + 2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG + 2.00 (2014-12-25) optimize JPG, including x86 SSE2 & NEON SIMD (ryg) + progressive JPEG (stb) + PGM/PPM support (Ken Miller) + STBI_MALLOC,STBI_REALLOC,STBI_FREE + GIF bugfix -- seemingly never worked + STBI_NO_*, STBI_ONLY_* + 1.48 (2014-12-14) fix incorrectly-named assert() + 1.47 (2014-12-14) 1/2/4-bit PNG support, both direct and paletted (Omar Cornut & stb) + optimize PNG (ryg) + fix bug in interlaced PNG with user-specified channel count (stb) + 1.46 (2014-08-26) + fix broken tRNS chunk (colorkey-style transparency) in non-paletted PNG + 1.45 (2014-08-16) + fix MSVC-ARM internal compiler error by wrapping malloc + 1.44 (2014-08-07) + various warning fixes from Ronny Chevalier + 1.43 (2014-07-15) + fix MSVC-only compiler problem in code changed in 1.42 + 1.42 (2014-07-09) + don't define _CRT_SECURE_NO_WARNINGS (affects user code) + fixes to stbi__cleanup_jpeg path + added STBI_ASSERT to avoid requiring assert.h + 1.41 (2014-06-25) + fix search&replace from 1.36 that messed up comments/error messages + 1.40 (2014-06-22) + fix gcc struct-initialization warning + 1.39 (2014-06-15) + fix to TGA optimization when req_comp != number of components in TGA; + fix to GIF loading because BMP wasn't rewinding (whoops, no GIFs in my test suite) + add support for BMP version 5 (more ignored fields) + 1.38 (2014-06-06) + suppress MSVC warnings on integer casts truncating values + fix accidental rename of 'skip' field of I/O + 1.37 (2014-06-04) + remove duplicate typedef + 1.36 (2014-06-03) + convert to header file single-file library + if de-iphone isn't set, load iphone images color-swapped instead of returning NULL + 1.35 (2014-05-27) + various warnings + fix broken STBI_SIMD path + fix bug where stbi_load_from_file no longer left file pointer in correct place + fix broken non-easy path for 32-bit BMP (possibly never used) + TGA optimization by Arseny Kapoulkine + 1.34 (unknown) + use STBI_NOTUSED in stbi__resample_row_generic(), fix one more leak in tga failure + case 1.33 (2011-07-14) make stbi_is_hdr work in STBI_NO_HDR (as specified), minor + compiler-friendly improvements 1.32 (2011-07-13) support for "info" function for all supported + filetypes (SpartanJ) 1.31 (2011-06-20) a few more leak fixes, bug in PNG handling (SpartanJ) + 1.30 (2011-06-11) + added ability to load files via callbacks to accomidate custom input streams (Ben + Wenger) removed deprecated format-specific test/load functions removed support for installable + file formats (stbi_loader) -- would have been broken for IO callbacks anyway error cases in bmp + and tga give messages and don't leak (Raymond Barbiero, grisha) fix inefficiency in decoding + 32-bit BMP (David Woo) 1.29 (2010-08-16) various warning fixes from Aurelien Pocheville 1.28 + (2010-08-01) fix bug in GIF palette transparency (SpartanJ) 1.27 (2010-08-01) cast-to-stbi_uc to + fix warnings 1.26 (2010-07-24) fix bug in file buffering for PNG reported by SpartanJ 1.25 + (2010-07-17) refix trans_data warning (Won Chun) 1.24 (2010-07-12) perf improvements reading + from files on platforms with lock-heavy fgetc() minor perf improvements for jpeg deprecated + type-specific functions so we'll get feedback if they're needed attempt to fix trans_data warning + (Won Chun) 1.23 fixed bug in iPhone support 1.22 (2010-07-10) removed image *writing* support + stbi_info support from Jetro Lauha + GIF support from Jean-Marc Lienher + iPhone PNG-extensions from James Brown + warning-fixes from Nicolas Schulz and Janez Zemva (i.stbi__err. Janez (U+017D)emva) + 1.21 fix use of 'stbi_uc' in header (reported by jon blow) + 1.20 added support for Softimage PIC, by Tom Seddon + 1.19 bug in interlaced PNG corruption check (found by ryg) + 1.18 (2008-08-02) + fix a threading bug (local mutable static) + 1.17 support interlaced PNG + 1.16 major bugfix - stbi__convert_format converted one too many pixels + 1.15 initialize some fields for thread safety + 1.14 fix threadsafe conversion bug + header-file-only version (#define STBI_HEADER_FILE_ONLY before including) + 1.13 threadsafe + 1.12 const qualifiers in the API + 1.11 Support installable IDCT, colorspace conversion routines + 1.10 Fixes for 64-bit (don't use "unsigned long") + optimized upsampling by Fabian "ryg" Giesen + 1.09 Fix format-conversion for PSD code (bad global variables!) + 1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz + 1.07 attempt to fix C++ warning/errors again + 1.06 attempt to fix C++ warning/errors again + 1.05 fix TGA loading to return correct *comp and use good luminance calc + 1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free + 1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR + 1.02 support for (subset of) HDR files, float interface for preferred access to them + 1.01 fix bug: possible bug in handling right-side up bmps... not sure + fix bug: the stbi__bmp_load() and stbi__tga_load() functions didn't work at all + 1.00 interface to zlib that skips zlib header + 0.99 correct handling of alpha in palette + 0.98 TGA loader by lonesock; dynamically add loaders (untested) + 0.97 jpeg errors on too large a file; also catch another malloc failure + 0.96 fix detection of invalid v value - particleman@mollyrocket forum + 0.95 during header scan, seek to markers in case of padding + 0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same + 0.93 handle jpegtran output; verbose errors + 0.92 read 4,8,16,24,32-bit BMP files of several formats + 0.91 output 24-bit Windows 3.0 BMP files + 0.90 fix a few more warnings; bump version number to approach 1.0 + 0.61 bugfixes due to Marc LeBlanc, Christopher Lloyd + 0.60 fix compiling as c++ + 0.59 fix warnings: merge Dave Moore's -Wall fixes + 0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian + 0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less than 16 available + 0.56 fix bug: zlib uncompressed mode len vs. nlen + 0.55 fix bug: restart_interval not initialized to 0 + 0.54 allow NULL for 'int *comp' + 0.53 fix bug in png 3->4; speedup png decoding + 0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments + 0.51 obey req_comp requests, 1-component jpegs return as 1-component, + on 'test' only check type, not whether we support this variant + 0.50 (2006-11-19) + first released version +*/ + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ +*/ \ No newline at end of file diff --git a/lib/stb/stb_image_resize2.h b/lib/stb/stb_image_resize2.h new file mode 100644 index 00000000..96cbc511 --- /dev/null +++ b/lib/stb/stb_image_resize2.h @@ -0,0 +1,11576 @@ +/* stb_image_resize2 - v2.11 - public domain image resizing + + by Jeff Roberts (v2) and Jorge L Rodriguez + http://github.com/nothings/stb + + Can be threaded with the extended API. SSE2, AVX, Neon and WASM SIMD support. Only + scaling and translation is supported, no rotations or shears. + + COMPILING & LINKING + In one C/C++ file that #includes this file, do this: + #define STB_IMAGE_RESIZE_IMPLEMENTATION + before the #include. That will create the implementation in that file. + + EASY API CALLS: + Easy API downsamples w/Mitchell filter, upsamples w/cubic interpolation, clamps to edge. + + stbir_resize_uint8_srgb( input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + pixel_layout_enum ) + + stbir_resize_uint8_linear( input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + pixel_layout_enum ) + + stbir_resize_float_linear( input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + pixel_layout_enum ) + + If you pass NULL or zero for the output_pixels, we will allocate the output buffer + for you and return it from the function (free with free() or STBIR_FREE). + As a special case, XX_stride_in_bytes of 0 means packed continuously in memory. + + API LEVELS + There are three levels of API - easy-to-use, medium-complexity and extended-complexity. + + See the "header file" section of the source for API documentation. + + ADDITIONAL DOCUMENTATION + + MEMORY ALLOCATION + By default, we use malloc and free for memory allocation. To override the + memory allocation, before the implementation #include, add a: + + #define STBIR_MALLOC(size,user_data) ... + #define STBIR_FREE(ptr,user_data) ... + + Each resize makes exactly one call to malloc/free (unless you use the + extended API where you can do one allocation for many resizes). Under + address sanitizer, we do separate allocations to find overread/writes. + + PERFORMANCE + This library was written with an emphasis on performance. When testing + stb_image_resize with RGBA, the fastest mode is STBIR_4CHANNEL with + STBIR_TYPE_UINT8 pixels and CLAMPed edges (which is what many other resize + libs do by default). Also, make sure SIMD is turned on of course (default + for 64-bit targets). Avoid WRAP edge mode if you want the fastest speed. + + This library also comes with profiling built-in. If you define STBIR_PROFILE, + you can use the advanced API and get low-level profiling information by + calling stbir_resize_extended_profile_info() or stbir_resize_split_profile_info() + after a resize. + + SIMD + Most of the routines have optimized SSE2, AVX, NEON and WASM versions. + + On Microsoft compilers, we automatically turn on SIMD for 64-bit x64 and + ARM; for 32-bit x86 and ARM, you select SIMD mode by defining STBIR_SSE2 or + STBIR_NEON. For AVX and AVX2, we auto-select it by detecting the /arch:AVX + or /arch:AVX2 switches. You can also always manually turn SSE2, AVX or AVX2 + support on by defining STBIR_SSE2, STBIR_AVX or STBIR_AVX2. + + On Linux, SSE2 and Neon is on by default for 64-bit x64 or ARM64. For 32-bit, + we select x86 SIMD mode by whether you have -msse2, -mavx or -mavx2 enabled + on the command line. For 32-bit ARM, you must pass -mfpu=neon-vfpv4 for both + clang and GCC, but GCC also requires an additional -mfp16-format=ieee to + automatically enable NEON. + + On x86 platforms, you can also define STBIR_FP16C to turn on FP16C instructions + for converting back and forth to half-floats. This is autoselected when we + are using AVX2. Clang and GCC also require the -mf16c switch. ARM always uses + the built-in half float hardware NEON instructions. + + You can also tell us to use multiply-add instructions with STBIR_USE_FMA. + Because x86 doesn't always have fma, we turn it off by default to maintain + determinism across all platforms. If you don't care about non-FMA determinism + and are willing to restrict yourself to more recent x86 CPUs (around the AVX + timeframe), then fma will give you around a 15% speedup. + + You can force off SIMD in all cases by defining STBIR_NO_SIMD. You can turn + off AVX or AVX2 specifically with STBIR_NO_AVX or STBIR_NO_AVX2. AVX is 10% + to 40% faster, and AVX2 is generally another 12%. + + ALPHA CHANNEL + Most of the resizing functions provide the ability to control how the alpha + channel of an image is processed. + + When alpha represents transparency, it is important that when combining + colors with filtering, the pixels should not be treated equally; they + should use a weighted average based on their alpha values. For example, + if a pixel is 1% opaque bright green and another pixel is 99% opaque + black and you average them, the average will be 50% opaque, but the + unweighted average and will be a middling green color, while the weighted + average will be nearly black. This means the unweighted version introduced + green energy that didn't exist in the source image. + + (If you want to know why this makes sense, you can work out the math for + the following: consider what happens if you alpha composite a source image + over a fixed color and then average the output, vs. if you average the + source image pixels and then composite that over the same fixed color. + Only the weighted average produces the same result as the ground truth + composite-then-average result.) + + Therefore, it is in general best to "alpha weight" the pixels when applying + filters to them. This essentially means multiplying the colors by the alpha + values before combining them, and then dividing by the alpha value at the + end. + + The computer graphics industry introduced a technique called "premultiplied + alpha" or "associated alpha" in which image colors are stored in image files + already multiplied by their alpha. This saves some math when compositing, + and also avoids the need to divide by the alpha at the end (which is quite + inefficient). However, while premultiplied alpha is common in the movie CGI + industry, it is not commonplace in other industries like videogames, and most + consumer file formats are generally expected to contain not-premultiplied + colors. For example, Photoshop saves PNG files "unpremultiplied", and web + browsers like Chrome and Firefox expect PNG images to be unpremultiplied. + + Note that there are three possibilities that might describe your image + and resize expectation: + + 1. images are not premultiplied, alpha weighting is desired + 2. images are not premultiplied, alpha weighting is not desired + 3. images are premultiplied + + Both case #2 and case #3 require the exact same math: no alpha weighting + should be applied or removed. Only case 1 requires extra math operations; + the other two cases can be handled identically. + + stb_image_resize expects case #1 by default, applying alpha weighting to + images, expecting the input images to be unpremultiplied. This is what the + COLOR+ALPHA buffer types tell the resizer to do. + + When you use the pixel layouts STBIR_RGBA, STBIR_BGRA, STBIR_ARGB, + STBIR_ABGR, STBIR_RX, or STBIR_XR you are telling us that the pixels are + non-premultiplied. In these cases, the resizer will alpha weight the colors + (effectively creating the premultiplied image), do the filtering, and then + convert back to non-premult on exit. + + When you use the pixel layouts STBIR_RGBA_PM, STBIR_RGBA_PM, STBIR_RGBA_PM, + STBIR_RGBA_PM, STBIR_RX_PM or STBIR_XR_PM, you are telling that the pixels + ARE premultiplied. In this case, the resizer doesn't have to do the + premultipling - it can filter directly on the input. This about twice as + fast as the non-premultiplied case, so it's the right option if your data is + already setup correctly. + + When you use the pixel layout STBIR_4CHANNEL or STBIR_2CHANNEL, you are + telling us that there is no channel that represents transparency; it may be + RGB and some unrelated fourth channel that has been stored in the alpha + channel, but it is actually not alpha. No special processing will be + performed. + + The difference between the generic 4 or 2 channel layouts, and the + specialized _PM versions is with the _PM versions you are telling us that + the data *is* alpha, just don't premultiply it. That's important when + using SRGB pixel formats, we need to know where the alpha is, because + it is converted linearly (rather than with the SRGB converters). + + Because alpha weighting produces the same effect as premultiplying, you + even have the option with non-premultiplied inputs to let the resizer + produce a premultiplied output. Because the intially computed alpha-weighted + output image is effectively premultiplied, this is actually more performant + than the normal path which un-premultiplies the output image as a final step. + + Finally, when converting both in and out of non-premulitplied space (for + example, when using STBIR_RGBA), we go to somewhat heroic measures to + ensure that areas with zero alpha value pixels get something reasonable + in the RGB values. If you don't care about the RGB values of zero alpha + pixels, you can call the stbir_set_non_pm_alpha_speed_over_quality() + function - this runs a premultiplied resize about 25% faster. That said, + when you really care about speed, using premultiplied pixels for both in + and out (STBIR_RGBA_PM, etc) much faster than both of these premultiplied + options. + + PIXEL LAYOUT CONVERSION + The resizer can convert from some pixel layouts to others. When using the + stbir_set_pixel_layouts(), you can, for example, specify STBIR_RGBA + on input, and STBIR_ARGB on output, and it will re-organize the channels + during the resize. Currently, you can only convert between two pixel + layouts with the same number of channels. + + DETERMINISM + We commit to being deterministic (from x64 to ARM to scalar to SIMD, etc). + This requires compiling with fast-math off (using at least /fp:precise). + Also, you must turn off fp-contracting (which turns mult+adds into fmas)! + We attempt to do this with pragmas, but with Clang, you usually want to add + -ffp-contract=off to the command line as well. + + For 32-bit x86, you must use SSE and SSE2 codegen for determinism. That is, + if the scalar x87 unit gets used at all, we immediately lose determinism. + On Microsoft Visual Studio 2008 and earlier, from what we can tell there is + no way to be deterministic in 32-bit x86 (some x87 always leaks in, even + with fp:strict). On 32-bit x86 GCC, determinism requires both -msse2 and + -fpmath=sse. + + Note that we will not be deterministic with float data containing NaNs - + the NaNs will propagate differently on different SIMD and platforms. + + If you turn on STBIR_USE_FMA, then we will be deterministic with other + fma targets, but we will differ from non-fma targets (this is unavoidable, + because a fma isn't simply an add with a mult - it also introduces a + rounding difference compared to non-fma instruction sequences. + + FLOAT PIXEL FORMAT RANGE + Any range of values can be used for the non-alpha float data that you pass + in (0 to 1, -1 to 1, whatever). However, if you are inputting float values + but *outputting* bytes or shorts, you must use a range of 0 to 1 so that we + scale back properly. The alpha channel must also be 0 to 1 for any format + that does premultiplication prior to resizing. + + Note also that with float output, using filters with negative lobes, the + output filtered values might go slightly out of range. You can define + STBIR_FLOAT_LOW_CLAMP and/or STBIR_FLOAT_HIGH_CLAMP to specify the range + to clamp to on output, if that's important. + + MAX/MIN SCALE FACTORS + The input pixel resolutions are in integers, and we do the internal pointer + resolution in size_t sized integers. However, the scale ratio from input + resolution to output resolution is calculated in float form. This means + the effective possible scale ratio is limited to 24 bits (or 16 million + to 1). As you get close to the size of the float resolution (again, 16 + million pixels wide or high), you might start seeing float inaccuracy + issues in general in the pipeline. If you have to do extreme resizes, + you can usually do this is multiple stages (using float intermediate + buffers). + + FLIPPED IMAGES + Stride is just the delta from one scanline to the next. This means you can + use a negative stride to handle inverted images (point to the final + scanline and use a negative stride). You can invert the input or output, + using negative strides. + + DEFAULT FILTERS + For functions which don't provide explicit control over what filters to + use, you can change the compile-time defaults with: + + #define STBIR_DEFAULT_FILTER_UPSAMPLE STBIR_FILTER_something + #define STBIR_DEFAULT_FILTER_DOWNSAMPLE STBIR_FILTER_something + + See stbir_filter in the header-file section for the list of filters. + + NEW FILTERS + A number of 1D filter kernels are supplied. For a list of supported + filters, see the stbir_filter enum. You can install your own filters by + using the stbir_set_filter_callbacks function. + + PROGRESS + For interactive use with slow resize operations, you can use the the + scanline callbacks in the extended API. It would have to be a *very* large + image resample to need progress though - we're very fast. + + CEIL and FLOOR + In scalar mode, the only functions we use from math.h are ceilf and floorf, + but if you have your own versions, you can define the STBIR_CEILF(v) and + STBIR_FLOORF(v) macros and we'll use them instead. In SIMD, we just use + our own versions. + + ASSERT + Define STBIR_ASSERT(boolval) to override assert() and not use assert.h + + PORTING FROM VERSION 1 + The API has changed. You can continue to use the old version of stb_image_resize.h, + which is available in the "deprecated/" directory. + + If you're using the old simple-to-use API, porting is straightforward. + (For more advanced APIs, read the documentation.) + + stbir_resize_uint8(): + - call `stbir_resize_uint8_linear`, cast channel count to `stbir_pixel_layout` + + stbir_resize_float(): + - call `stbir_resize_float_linear`, cast channel count to `stbir_pixel_layout` + + stbir_resize_uint8_srgb(): + - function name is unchanged + - cast channel count to `stbir_pixel_layout` + - above is sufficient unless your image has alpha and it's not RGBA/BGRA + - in that case, follow the below instructions for stbir_resize_uint8_srgb_edgemode + + stbir_resize_uint8_srgb_edgemode() + - switch to the "medium complexity" API + - stbir_resize(), very similar API but a few more parameters: + - pixel_layout: cast channel count to `stbir_pixel_layout` + - data_type: STBIR_TYPE_UINT8_SRGB + - edge: unchanged (STBIR_EDGE_WRAP, etc.) + - filter: STBIR_FILTER_DEFAULT + - which channel is alpha is specified in stbir_pixel_layout, see enum for details + + FUTURE TODOS + * For polyphase integral filters, we just memcpy the coeffs to dupe + them, but we should indirect and use the same coeff memory. + * Add pixel layout conversions for sensible different channel counts + (maybe, 1->3/4, 3->4, 4->1, 3->1). + * For SIMD encode and decode scanline routines, do any pre-aligning + for bad input/output buffer alignments and pitch? + * For very wide scanlines, we should we do vertical strips to stay within + L2 cache. Maybe do chunks of 1K pixels at a time. There would be + some pixel reconversion, but probably dwarfed by things falling out + of cache. Probably also something possible with alternating between + scattering and gathering at high resize scales? + * Rewrite the coefficient generator to do many at once. + * AVX-512 vertical kernels - worried about downclocking here. + * Convert the reincludes to macros when we know they aren't changing. + * Experiment with pivoting the horizontal and always using the + vertical filters (which are faster, but perhaps not enough to overcome + the pivot cost and the extra memory touches). Need to buffer the whole + image so have to balance memory use. + * Most of our code is internally function pointers, should we compile + all the SIMD stuff always and dynamically dispatch? + + CONTRIBUTORS + Jeff Roberts: 2.0 implementation, optimizations, SIMD + Martins Mozeiko: NEON simd, WASM simd, clang and GCC whisperer + Fabian Giesen: half float and srgb converters + Sean Barrett: API design, optimizations + Jorge L Rodriguez: Original 1.0 implementation + Aras Pranckevicius: bugfixes + Nathan Reed: warning fixes for 1.0 + + REVISIONS + 2.11 (2024-09-08) fix harmless asan warnings in 2-channel and 3-channel mode + with AVX-2, fix some weird scaling edge conditions with + point sample mode. + 2.10 (2024-07-27) fix the defines GCC and mingw for loop unroll control, + fix MSVC 32-bit arm half float routines. + 2.09 (2024-06-19) fix the defines for 32-bit ARM GCC builds (was selecting + hardware half floats). + 2.08 (2024-06-10) fix for RGB->BGR three channel flips and add SIMD (thanks + to Ryan Salsbury), fix for sub-rect resizes, use the + pragmas to control unrolling when they are available. + 2.07 (2024-05-24) fix for slow final split during threaded conversions of very + wide scanlines when downsampling (caused by extra input + converting), fix for wide scanline resamples with many + splits (int overflow), fix GCC warning. + 2.06 (2024-02-10) fix for identical width/height 3x or more down-scaling + undersampling a single row on rare resize ratios (about 1%). + 2.05 (2024-02-07) fix for 2 pixel to 1 pixel resizes with wrap (thanks Aras), + fix for output callback (thanks Julien Koenen). + 2.04 (2023-11-17) fix for rare AVX bug, shadowed symbol (thanks Nikola Smiljanic). + 2.03 (2023-11-01) ASAN and TSAN warnings fixed, minor tweaks. + 2.00 (2023-10-10) mostly new source: new api, optimizations, simd, vertical-first, etc + 2x-5x faster without simd, 4x-12x faster with simd, + in some cases, 20x to 40x faster esp resizing large to very small. + 0.96 (2019-03-04) fixed warnings + 0.95 (2017-07-23) fixed warnings + 0.94 (2017-03-18) fixed warnings + 0.93 (2017-03-03) fixed bug with certain combinations of heights + 0.92 (2017-01-02) fix integer overflow on large (>2GB) images + 0.91 (2016-04-02) fix warnings; fix handling of subpixel regions + 0.90 (2014-09-17) first released version + + LICENSE + See end of file for license information. +*/ + +#if !defined(STB_IMAGE_RESIZE_DO_HORIZONTALS) && !defined(STB_IMAGE_RESIZE_DO_VERTICALS) && \ + !defined(STB_IMAGE_RESIZE_DO_CODERS) // for internal re-includes + +#ifndef STBIR_INCLUDE_STB_IMAGE_RESIZE2_H +#define STBIR_INCLUDE_STB_IMAGE_RESIZE2_H + +#include +#ifdef _MSC_VER +typedef unsigned char stbir_uint8; +typedef unsigned short stbir_uint16; +typedef unsigned int stbir_uint32; +typedef unsigned __int64 stbir_uint64; +#else +#include +typedef uint8_t stbir_uint8; +typedef uint16_t stbir_uint16; +typedef uint32_t stbir_uint32; +typedef uint64_t stbir_uint64; +#endif + +#ifdef _M_IX86_FP +#if (_M_IX86_FP >= 1) +#ifndef STBIR_SSE +#define STBIR_SSE +#endif +#endif +#endif + +#if defined(_x86_64) || defined(__x86_64__) || defined(_M_X64) || defined(__x86_64) || \ + defined(_M_AMD64) || defined(__SSE2__) || defined(STBIR_SSE) || defined(STBIR_SSE2) +#ifndef STBIR_SSE2 +#define STBIR_SSE2 +#endif +#if defined(__AVX__) || defined(STBIR_AVX2) +#ifndef STBIR_AVX +#ifndef STBIR_NO_AVX +#define STBIR_AVX +#endif +#endif +#endif +#if defined(__AVX2__) || defined(STBIR_AVX2) +#ifndef STBIR_NO_AVX2 +#ifndef STBIR_AVX2 +#define STBIR_AVX2 +#endif +#if defined(_MSC_VER) && !defined(__clang__) +#ifndef STBIR_FP16C // FP16C instructions are on all AVX2 cpus, so we can autoselect it here on + // microsoft - clang needs -m16c +#define STBIR_FP16C +#endif +#endif +#endif +#endif +#ifdef __F16C__ +#ifndef STBIR_FP16C // turn on FP16C instructions if the define is set (for clang and gcc) +#define STBIR_FP16C +#endif +#endif +#endif + +#if defined(_M_ARM64) || defined(__aarch64__) || defined(__arm64__) || \ + ((__ARM_NEON_FP & 4) != 0) || defined(__ARM_NEON__) +#ifndef STBIR_NEON +#define STBIR_NEON +#endif +#endif + +#if defined(_M_ARM) || defined(__arm__) +#ifdef STBIR_USE_FMA +#undef STBIR_USE_FMA // no FMA for 32-bit arm on MSVC +#endif +#endif + +#if defined(__wasm__) && defined(__wasm_simd128__) +#ifndef STBIR_WASM +#define STBIR_WASM +#endif +#endif + +#ifndef STBIRDEF +#ifdef STB_IMAGE_RESIZE_STATIC +#define STBIRDEF static +#else +#ifdef __cplusplus +#define STBIRDEF extern "C" +#else +#define STBIRDEF extern +#endif +#endif +#endif + +////////////////////////////////////////////////////////////////////////////// +//// start "header file" /////////////////////////////////////////////////// +// +// Easy-to-use API: +// +// * stride is the offset between successive rows of image data +// in memory, in bytes. specify 0 for packed continuously in memory +// * colorspace is linear or sRGB as specified by function name +// * Uses the default filters +// * Uses edge mode clamped +// * returned result is 1 for success or 0 in case of an error. + +// stbir_pixel_layout specifies: +// number of channels +// order of channels +// whether color is premultiplied by alpha +// for back compatibility, you can cast the old channel count to an stbir_pixel_layout +typedef enum { + STBIR_1CHANNEL = 1, + STBIR_2CHANNEL = 2, + STBIR_RGB = 3, // 3-chan, with order specified (for channel flipping) + STBIR_BGR = 0, // 3-chan, with order specified (for channel flipping) + STBIR_4CHANNEL = 5, + + STBIR_RGBA = 4, // alpha formats, where alpha is NOT premultiplied into color channels + STBIR_BGRA = 6, + STBIR_ARGB = 7, + STBIR_ABGR = 8, + STBIR_RA = 9, + STBIR_AR = 10, + + STBIR_RGBA_PM = 11, // alpha formats, where alpha is premultiplied into color channels + STBIR_BGRA_PM = 12, + STBIR_ARGB_PM = 13, + STBIR_ABGR_PM = 14, + STBIR_RA_PM = 15, + STBIR_AR_PM = 16, + + STBIR_RGBA_NO_AW = 11, // alpha formats, where NO alpha weighting is applied at all! + STBIR_BGRA_NO_AW = 12, // these are just synonyms for the _PM flags (which also do + STBIR_ARGB_NO_AW = 13, // no alpha weighting). These names just make it more clear + STBIR_ABGR_NO_AW = 14, // for some folks). + STBIR_RA_NO_AW = 15, + STBIR_AR_NO_AW = 16, + +} stbir_pixel_layout; + +//=============================================================== +// Simple-complexity API +// +// If output_pixels is NULL (0), then we will allocate the buffer and return it to you. +//-------------------------------- + +STBIRDEF unsigned char *stbir_resize_uint8_srgb(const unsigned char *input_pixels, int input_w, + int input_h, int input_stride_in_bytes, + unsigned char *output_pixels, int output_w, + int output_h, int output_stride_in_bytes, + stbir_pixel_layout pixel_type); + +STBIRDEF unsigned char *stbir_resize_uint8_linear(const unsigned char *input_pixels, int input_w, + int input_h, int input_stride_in_bytes, + unsigned char *output_pixels, int output_w, + int output_h, int output_stride_in_bytes, + stbir_pixel_layout pixel_type); + +STBIRDEF float *stbir_resize_float_linear(const float *input_pixels, int input_w, int input_h, + int input_stride_in_bytes, float *output_pixels, + int output_w, int output_h, int output_stride_in_bytes, + stbir_pixel_layout pixel_type); +//=============================================================== + +//=============================================================== +// Medium-complexity API +// +// This extends the easy-to-use API as follows: +// +// * Can specify the datatype - U8, U8_SRGB, U16, FLOAT, HALF_FLOAT +// * Edge wrap can selected explicitly +// * Filter can be selected explicitly +//-------------------------------- + +typedef enum { + STBIR_EDGE_CLAMP = 0, + STBIR_EDGE_REFLECT = 1, + STBIR_EDGE_WRAP = 2, // this edge mode is slower and uses more memory + STBIR_EDGE_ZERO = 3, +} stbir_edge; + +typedef enum { + STBIR_FILTER_DEFAULT = 0, // use same filter type that easy-to-use API chooses + STBIR_FILTER_BOX = + 1, // A trapezoid w/1-pixel wide ramps, same result as box for integer scale ratios + STBIR_FILTER_TRIANGLE = + 2, // On upsampling, produces same results as bilinear texture filtering + STBIR_FILTER_CUBICBSPLINE = + 3, // The cubic b-spline (aka Mitchell-Netrevalli with B=1,C=0), gaussian-esque + STBIR_FILTER_CATMULLROM = 4, // An interpolating cubic spline + STBIR_FILTER_MITCHELL = 5, // Mitchell-Netrevalli filter with B=1/3, C=1/3 + STBIR_FILTER_POINT_SAMPLE = 6, // Simple point sampling + STBIR_FILTER_OTHER = 7, // User callback specified +} stbir_filter; + +typedef enum { + STBIR_TYPE_UINT8 = 0, + STBIR_TYPE_UINT8_SRGB = 1, + STBIR_TYPE_UINT8_SRGB_ALPHA = + 2, // alpha channel, when present, should also be SRGB (this is very unusual) + STBIR_TYPE_UINT16 = 3, + STBIR_TYPE_FLOAT = 4, + STBIR_TYPE_HALF_FLOAT = 5 +} stbir_datatype; + +// medium api +STBIRDEF void *stbir_resize(const void *input_pixels, int input_w, int input_h, + int input_stride_in_bytes, void *output_pixels, int output_w, + int output_h, int output_stride_in_bytes, + stbir_pixel_layout pixel_layout, stbir_datatype data_type, + stbir_edge edge, stbir_filter filter); +//=============================================================== + +//=============================================================== +// Extended-complexity API +// +// This API exposes all resize functionality. +// +// * Separate filter types for each axis +// * Separate edge modes for each axis +// * Separate input and output data types +// * Can specify regions with subpixel correctness +// * Can specify alpha flags +// * Can specify a memory callback +// * Can specify a callback data type for pixel input and output +// * Can be threaded for a single resize +// * Can be used to resize many frames without recalculating the sampler info +// +// Use this API as follows: +// 1) Call the stbir_resize_init function on a local STBIR_RESIZE structure +// 2) Call any of the stbir_set functions +// 3) Optionally call stbir_build_samplers() if you are going to resample multiple times +// with the same input and output dimensions (like resizing video frames) +// 4) Resample by calling stbir_resize_extended(). +// 5) Call stbir_free_samplers() if you called stbir_build_samplers() +//-------------------------------- + +// Types: + +// INPUT CALLBACK: this callback is used for input scanlines +typedef void const *stbir_input_callback(void *optional_output, void const *input_ptr, + int num_pixels, int x, int y, void *context); + +// OUTPUT CALLBACK: this callback is used for output scanlines +typedef void stbir_output_callback(void const *output_ptr, int num_pixels, int y, void *context); + +// callbacks for user installed filters +typedef float stbir__kernel_callback(float x, float scale, void *user_data); // centered at zero +typedef float stbir__support_callback(float scale, void *user_data); + +// internal structure with precomputed scaling +typedef struct stbir__info stbir__info; + +typedef struct STBIR_RESIZE // use the stbir_resize_init and stbir_override functions to set these + // values for future compatibility +{ + void *user_data; + void const *input_pixels; + int input_w, input_h; + double input_s0, input_t0, input_s1, input_t1; + stbir_input_callback *input_cb; + void *output_pixels; + int output_w, output_h; + int output_subx, output_suby, output_subw, output_subh; + stbir_output_callback *output_cb; + int input_stride_in_bytes; + int output_stride_in_bytes; + int splits; + int fast_alpha; + int needs_rebuild; + int called_alloc; + stbir_pixel_layout input_pixel_layout_public; + stbir_pixel_layout output_pixel_layout_public; + stbir_datatype input_data_type; + stbir_datatype output_data_type; + stbir_filter horizontal_filter, vertical_filter; + stbir_edge horizontal_edge, vertical_edge; + stbir__kernel_callback *horizontal_filter_kernel; + stbir__support_callback *horizontal_filter_support; + stbir__kernel_callback *vertical_filter_kernel; + stbir__support_callback *vertical_filter_support; + stbir__info *samplers; +} STBIR_RESIZE; + +// extended complexity api + +// First off, you must ALWAYS call stbir_resize_init on your resize structure before any of the +// other calls! +STBIRDEF void stbir_resize_init(STBIR_RESIZE *resize, const void *input_pixels, int input_w, + int input_h, int input_stride_in_bytes, // stride can be zero + void *output_pixels, int output_w, int output_h, + int output_stride_in_bytes, // stride can be zero + stbir_pixel_layout pixel_layout, stbir_datatype data_type); + +//=============================================================== +// You can update these parameters any time after resize_init and there is no cost +//-------------------------------- + +STBIRDEF void stbir_set_datatypes(STBIR_RESIZE *resize, stbir_datatype input_type, + stbir_datatype output_type); +STBIRDEF void +stbir_set_pixel_callbacks(STBIR_RESIZE *resize, stbir_input_callback *input_cb, + stbir_output_callback *output_cb); // no callbacks by default +STBIRDEF void stbir_set_user_data(STBIR_RESIZE *resize, + void *user_data); // pass back STBIR_RESIZE* by default +STBIRDEF void stbir_set_buffer_ptrs(STBIR_RESIZE *resize, const void *input_pixels, + int input_stride_in_bytes, void *output_pixels, + int output_stride_in_bytes); + +//=============================================================== + +//=============================================================== +// If you call any of these functions, you will trigger a sampler rebuild! +//-------------------------------- + +STBIRDEF int +stbir_set_pixel_layouts(STBIR_RESIZE *resize, stbir_pixel_layout input_pixel_layout, + stbir_pixel_layout output_pixel_layout); // sets new buffer layouts +STBIRDEF int stbir_set_edgemodes(STBIR_RESIZE *resize, stbir_edge horizontal_edge, + stbir_edge vertical_edge); // CLAMP by default + +STBIRDEF int stbir_set_filters( + STBIR_RESIZE *resize, stbir_filter horizontal_filter, + stbir_filter vertical_filter); // STBIR_DEFAULT_FILTER_UPSAMPLE/DOWNSAMPLE by default +STBIRDEF int stbir_set_filter_callbacks(STBIR_RESIZE *resize, + stbir__kernel_callback *horizontal_filter, + stbir__support_callback *horizontal_support, + stbir__kernel_callback *vertical_filter, + stbir__support_callback *vertical_support); + +STBIRDEF int stbir_set_pixel_subrect(STBIR_RESIZE *resize, int subx, int suby, int subw, + int subh); // sets both sub-regions (full regions by default) +STBIRDEF int stbir_set_input_subrect(STBIR_RESIZE *resize, double s0, double t0, double s1, + double t1); // sets input sub-region (full region by default) +STBIRDEF int +stbir_set_output_pixel_subrect(STBIR_RESIZE *resize, int subx, int suby, int subw, + int subh); // sets output sub-region (full region by default) + +// when inputting AND outputting non-premultiplied alpha pixels, we use a slower but higher quality +// technique +// that fills the zero alpha pixel's RGB values with something plausible. If you don't care about +// areas of zero alpha, you can call this function to get about a 25% speed improvement for +// STBIR_RGBA to STBIR_RGBA types of resizes. +STBIRDEF int stbir_set_non_pm_alpha_speed_over_quality(STBIR_RESIZE *resize, + int non_pma_alpha_speed_over_quality); +//=============================================================== + +//=============================================================== +// You can call build_samplers to prebuild all the internal data we need to resample. +// Then, if you call resize_extended many times with the same resize, you only pay the +// cost once. +// If you do call build_samplers, you MUST call free_samplers eventually. +//-------------------------------- + +// This builds the samplers and does one allocation +STBIRDEF int stbir_build_samplers(STBIR_RESIZE *resize); + +// You MUST call this, if you call stbir_build_samplers or stbir_build_samplers_with_splits +STBIRDEF void stbir_free_samplers(STBIR_RESIZE *resize); +//=============================================================== + +// And this is the main function to perform the resize synchronously on one thread. +STBIRDEF int stbir_resize_extended(STBIR_RESIZE *resize); + +//=============================================================== +// Use these functions for multithreading. +// 1) You call stbir_build_samplers_with_splits first on the main thread +// 2) Then stbir_resize_with_split on each thread +// 3) stbir_free_samplers when done on the main thread +//-------------------------------- + +// This will build samplers for threading. +// You can pass in the number of threads you'd like to use (try_splits). +// It returns the number of splits (threads) that you can call it with. +/// It might be less if the image resize can't be split up that many ways. + +STBIRDEF int stbir_build_samplers_with_splits(STBIR_RESIZE *resize, int try_splits); + +// This function does a split of the resizing (you call this fuction for each +// split, on multiple threads). A split is a piece of the output resize pixel space. + +// Note that you MUST call stbir_build_samplers_with_splits before stbir_resize_extended_split! + +// Usually, you will always call stbir_resize_split with split_start as the thread_index +// and "1" for the split_count. +// But, if you have a weird situation where you MIGHT want 8 threads, but sometimes +// only 4 threads, you can use 0,2,4,6 for the split_start's and use "2" for the +// split_count each time to turn in into a 4 thread resize. (This is unusual). + +STBIRDEF int stbir_resize_extended_split(STBIR_RESIZE *resize, int split_start, int split_count); +//=============================================================== + +//=============================================================== +// Pixel Callbacks info: +//-------------------------------- + +// The input callback is super flexible - it calls you with the input address +// (based on the stride and base pointer), it gives you an optional_output +// pointer that you can fill, or you can just return your own pointer into +// your own data. +// +// You can also do conversion from non-supported data types if necessary - in +// this case, you ignore the input_ptr and just use the x and y parameters to +// calculate your own input_ptr based on the size of each non-supported pixel. +// (Something like the third example below.) +// +// You can also install just an input or just an output callback by setting the +// callback that you don't want to zero. +// +// First example, progress: (getting a callback that you can monitor the progress): +// void const * my_callback( void * optional_output, void const * input_ptr, int num_pixels, +// int x, int y, void * context ) +// { +// percentage_done = y / input_height; +// return input_ptr; // use buffer from call +// } +// +// Next example, copying: (copy from some other buffer or stream): +// void const * my_callback( void * optional_output, void const * input_ptr, int num_pixels, +// int x, int y, void * context ) +// { +// CopyOrStreamData( optional_output, other_data_src, num_pixels * pixel_width_in_bytes ); +// return optional_output; // return the optional buffer that we filled +// } +// +// Third example, input another buffer without copying: (zero-copy from other buffer): +// void const * my_callback( void * optional_output, void const * input_ptr, int num_pixels, +// int x, int y, void * context ) +// { +// void * pixels = ( (char*) other_image_base ) + ( y * other_image_stride ) + ( x * +// other_pixel_width_in_bytes ); return pixels; // return pointer to your data +// without copying +// } +// +// +// The output callback is considerably simpler - it just calls you so that you can dump +// out each scanline. You could even directly copy out to disk if you have a simple format +// like TGA or BMP. You can also convert to other output types here if you want. +// +// Simple example: +// void const * my_output( void * output_ptr, int num_pixels, int y, void * context ) +// { +// percentage_done = y / output_height; +// fwrite( output_ptr, pixel_width_in_bytes, num_pixels, output_file ); +// } +//=============================================================== + +//=============================================================== +// optional built-in profiling API +//-------------------------------- + +#ifdef STBIR_PROFILE + +typedef struct STBIR_PROFILE_INFO { + stbir_uint64 total_clocks; + + // how many clocks spent (of total_clocks) in the various resize routines, along with a string + // description + // there are "resize_count" number of zones + stbir_uint64 clocks[8]; + char const **descriptions; + + // count of clocks and descriptions + stbir_uint32 count; +} STBIR_PROFILE_INFO; + +// use after calling stbir_resize_extended (or stbir_build_samplers or +// stbir_build_samplers_with_splits) +STBIRDEF void stbir_resize_build_profile_info(STBIR_PROFILE_INFO *out_info, + STBIR_RESIZE const *resize); + +// use after calling stbir_resize_extended +STBIRDEF void stbir_resize_extended_profile_info(STBIR_PROFILE_INFO *out_info, + STBIR_RESIZE const *resize); + +// use after calling stbir_resize_extended_split +STBIRDEF void stbir_resize_split_profile_info(STBIR_PROFILE_INFO *out_info, + STBIR_RESIZE const *resize, int split_start, + int split_num); + +//=============================================================== + +#endif + +//// end header file ///////////////////////////////////////////////////// +#endif // STBIR_INCLUDE_STB_IMAGE_RESIZE2_H + +#if defined(STB_IMAGE_RESIZE_IMPLEMENTATION) || defined(STB_IMAGE_RESIZE2_IMPLEMENTATION) + +#ifndef STBIR_ASSERT +#include +#define STBIR_ASSERT(x) assert(x) +#endif + +#ifndef STBIR_MALLOC +#include +#define STBIR_MALLOC(size, user_data) ((void)(user_data), malloc(size)) +#define STBIR_FREE(ptr, user_data) ((void)(user_data), free(ptr)) +// (we used the comma operator to evaluate user_data, to avoid "unused parameter" warnings) +#endif + +#ifdef _MSC_VER + +#define stbir__inline __forceinline + +#else + +#define stbir__inline __inline__ + +// Clang address sanitizer +#if defined(__has_feature) +#if __has_feature(address_sanitizer) || __has_feature(memory_sanitizer) +#ifndef STBIR__SEPARATE_ALLOCATIONS +#define STBIR__SEPARATE_ALLOCATIONS +#endif +#endif +#endif + +#endif + +// GCC and MSVC +#if defined(__SANITIZE_ADDRESS__) +#ifndef STBIR__SEPARATE_ALLOCATIONS +#define STBIR__SEPARATE_ALLOCATIONS +#endif +#endif + +// Always turn off automatic FMA use - use STBIR_USE_FMA if you want. +// Otherwise, this is a determinism disaster. +#ifndef STBIR_DONT_CHANGE_FP_CONTRACT // override in case you don't want this behavior +#if defined(_MSC_VER) && !defined(__clang__) +#if _MSC_VER > 1200 +#pragma fp_contract(off) +#endif +#elif defined(__GNUC__) && !defined(__clang__) +#pragma GCC optimize("fp-contract=off") +#else +#pragma STDC FP_CONTRACT OFF +#endif +#endif + +#ifdef _MSC_VER +#define STBIR__UNUSED(v) (void)(v) +#else +#define STBIR__UNUSED(v) (void)sizeof(v) +#endif + +#define STBIR__ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0])) + +#ifndef STBIR_DEFAULT_FILTER_UPSAMPLE +#define STBIR_DEFAULT_FILTER_UPSAMPLE STBIR_FILTER_CATMULLROM +#endif + +#ifndef STBIR_DEFAULT_FILTER_DOWNSAMPLE +#define STBIR_DEFAULT_FILTER_DOWNSAMPLE STBIR_FILTER_MITCHELL +#endif + +#ifndef STBIR__HEADER_FILENAME +#define STBIR__HEADER_FILENAME "stb_image_resize2.h" +#endif + +// the internal pixel layout enums are in a different order, so we can easily do range comparisons +// of types +// the public pixel layout is ordered in a way that if you cast num_channels (1-4) to the enum, +// you get something sensible +typedef enum { + STBIRI_1CHANNEL = 0, + STBIRI_2CHANNEL = 1, + STBIRI_RGB = 2, + STBIRI_BGR = 3, + STBIRI_4CHANNEL = 4, + + STBIRI_RGBA = 5, + STBIRI_BGRA = 6, + STBIRI_ARGB = 7, + STBIRI_ABGR = 8, + STBIRI_RA = 9, + STBIRI_AR = 10, + + STBIRI_RGBA_PM = 11, + STBIRI_BGRA_PM = 12, + STBIRI_ARGB_PM = 13, + STBIRI_ABGR_PM = 14, + STBIRI_RA_PM = 15, + STBIRI_AR_PM = 16, +} stbir_internal_pixel_layout; + +// define the public pixel layouts to not compile inside the implementation (to avoid accidental +// use) +#define STBIR_BGR bad_dont_use_in_implementation +#define STBIR_1CHANNEL STBIR_BGR +#define STBIR_2CHANNEL STBIR_BGR +#define STBIR_RGB STBIR_BGR +#define STBIR_RGBA STBIR_BGR +#define STBIR_4CHANNEL STBIR_BGR +#define STBIR_BGRA STBIR_BGR +#define STBIR_ARGB STBIR_BGR +#define STBIR_ABGR STBIR_BGR +#define STBIR_RA STBIR_BGR +#define STBIR_AR STBIR_BGR +#define STBIR_RGBA_PM STBIR_BGR +#define STBIR_BGRA_PM STBIR_BGR +#define STBIR_ARGB_PM STBIR_BGR +#define STBIR_ABGR_PM STBIR_BGR +#define STBIR_RA_PM STBIR_BGR +#define STBIR_AR_PM STBIR_BGR + +// must match stbir_datatype +static unsigned char stbir__type_size[] = { + 1, 1, 1, 2, + 4, 2 // STBIR_TYPE_UINT8,STBIR_TYPE_UINT8_SRGB,STBIR_TYPE_UINT8_SRGB_ALPHA,STBIR_TYPE_UINT16,STBIR_TYPE_FLOAT,STBIR_TYPE_HALF_FLOAT +}; + +// When gathering, the contributors are which source pixels contribute. +// When scattering, the contributors are which destination pixels are contributed to. +typedef struct { + int n0; // First contributing pixel + int n1; // Last contributing pixel +} stbir__contributors; + +typedef struct { + int lowest; // First sample index for whole filter + int highest; // Last sample index for whole filter + int widest; // widest single set of samples for an output +} stbir__filter_extent_info; + +typedef struct { + int n0; // First pixel of decode buffer to write to + int n1; // Last pixel of decode that will be written to + int pixel_offset_for_input; // Pixel offset into input_scanline +} stbir__span; + +typedef struct stbir__scale_info { + int input_full_size; + int output_sub_size; + float scale; + float inv_scale; + float pixel_shift; // starting shift in output pixel space (in pixels) + int scale_is_rational; + stbir_uint32 scale_numerator, scale_denominator; +} stbir__scale_info; + +typedef struct { + stbir__contributors *contributors; + float *coefficients; + stbir__contributors *gather_prescatter_contributors; + float *gather_prescatter_coefficients; + stbir__scale_info scale_info; + float support; + stbir_filter filter_enum; + stbir__kernel_callback *filter_kernel; + stbir__support_callback *filter_support; + stbir_edge edge; + int coefficient_width; + int filter_pixel_width; + int filter_pixel_margin; + int num_contributors; + int contributors_size; + int coefficients_size; + stbir__filter_extent_info extent_info; + int is_gather; // 0 = scatter, 1 = gather with scale >= 1, 2 = gather with scale < 1 + int gather_prescatter_num_contributors; + int gather_prescatter_coefficient_width; + int gather_prescatter_contributors_size; + int gather_prescatter_coefficients_size; +} stbir__sampler; + +typedef struct { + stbir__contributors conservative; + int edge_sizes[2]; // this can be less than filter_pixel_margin, if the filter and scaling + // falls off + stbir__span spans[2]; // can be two spans, if doing input subrect with clamp mode WRAP +} stbir__extents; + +typedef struct { +#ifdef STBIR_PROFILE + union { + struct { + stbir_uint64 total, looping, vertical, horizontal, decode, encode, alpha, unalpha; + } named; + stbir_uint64 array[8]; + } profile; + stbir_uint64 *current_zone_excluded_ptr; +#endif + float *decode_buffer; + + int ring_buffer_first_scanline; + int ring_buffer_last_scanline; + int ring_buffer_begin_index; // first_scanline is at this index in the ring buffer + int start_output_y, end_output_y; + int start_input_y, end_input_y; // used in scatter only + +#ifdef STBIR__SEPARATE_ALLOCATIONS + float **ring_buffers; // one pointer for each ring buffer +#else + float *ring_buffer; // one big buffer that we index into +#endif + + float *vertical_buffer; + + char no_cache_straddle[64]; +} stbir__per_split_info; + +typedef void stbir__decode_pixels_func(float *decode, int width_times_channels, void const *input); +typedef void stbir__alpha_weight_func(float *decode_buffer, int width_times_channels); +typedef void +stbir__horizontal_gather_channels_func(float *output_buffer, unsigned int output_sub_size, + float const *decode_buffer, + stbir__contributors const *horizontal_contributors, + float const *horizontal_coefficients, int coefficient_width); +typedef void stbir__alpha_unweight_func(float *encode_buffer, int width_times_channels); +typedef void stbir__encode_pixels_func(void *output, int width_times_channels, float const *encode); + +struct stbir__info { +#ifdef STBIR_PROFILE + union { + struct { + stbir_uint64 total, build, alloc, horizontal, vertical, cleanup, pivot; + } named; + stbir_uint64 array[7]; + } profile; + stbir_uint64 *current_zone_excluded_ptr; +#endif + stbir__sampler horizontal; + stbir__sampler vertical; + + void const *input_data; + void *output_data; + + int input_stride_bytes; + int output_stride_bytes; + int ring_buffer_length_bytes; // The length of an individual entry in the ring buffer. The + // total number of ring buffers is + // stbir__get_filter_pixel_width(filter) + int ring_buffer_num_entries; // Total number of entries in the ring buffer. + + stbir_datatype input_type; + stbir_datatype output_type; + + stbir_input_callback *in_pixels_cb; + void *user_data; + stbir_output_callback *out_pixels_cb; + + stbir__extents scanline_extents; + + void *alloced_mem; + stbir__per_split_info *split_info; // by default 1, but there will be N of these allocated + // based on the thread init you did + + stbir__decode_pixels_func *decode_pixels; + stbir__alpha_weight_func *alpha_weight; + stbir__horizontal_gather_channels_func *horizontal_gather_channels; + stbir__alpha_unweight_func *alpha_unweight; + stbir__encode_pixels_func *encode_pixels; + + int alloc_ring_buffer_num_entries; // Number of entries in the ring buffer that will be + // allocated + int splits; // count of splits + + stbir_internal_pixel_layout input_pixel_layout_internal; + stbir_internal_pixel_layout output_pixel_layout_internal; + + int input_color_and_type; + int offset_x, offset_y; // offset within output_data + int vertical_first; + int channels; + int effective_channels; // same as channels, except on RGBA/ARGB (7), or XA/AX (3) + size_t alloced_total; +}; + +#define stbir__max_uint8_as_float 255.0f +#define stbir__max_uint16_as_float 65535.0f +#define stbir__max_uint8_as_float_inverted (1.0f / 255.0f) +#define stbir__max_uint16_as_float_inverted (1.0f / 65535.0f) +#define stbir__small_float \ + ((float)1 / (1 << 20) / (1 << 20) / (1 << 20) / (1 << 20) / (1 << 20) / (1 << 20)) + +// min/max friendly +#define STBIR_CLAMP(x, xmin, xmax) \ + for (;;) { \ + if ((x) < (xmin)) \ + (x) = (xmin); \ + if ((x) > (xmax)) \ + (x) = (xmax); \ + break; \ + } + +static stbir__inline int stbir__min(int a, int b) { return a < b ? a : b; } + +static stbir__inline int stbir__max(int a, int b) { return a > b ? a : b; } + +static float stbir__srgb_uchar_to_linear_float[256] = { + 0.000000f, 0.000304f, 0.000607f, 0.000911f, 0.001214f, 0.001518f, 0.001821f, 0.002125f, + 0.002428f, 0.002732f, 0.003035f, 0.003347f, 0.003677f, 0.004025f, 0.004391f, 0.004777f, + 0.005182f, 0.005605f, 0.006049f, 0.006512f, 0.006995f, 0.007499f, 0.008023f, 0.008568f, + 0.009134f, 0.009721f, 0.010330f, 0.010960f, 0.011612f, 0.012286f, 0.012983f, 0.013702f, + 0.014444f, 0.015209f, 0.015996f, 0.016807f, 0.017642f, 0.018500f, 0.019382f, 0.020289f, + 0.021219f, 0.022174f, 0.023153f, 0.024158f, 0.025187f, 0.026241f, 0.027321f, 0.028426f, + 0.029557f, 0.030713f, 0.031896f, 0.033105f, 0.034340f, 0.035601f, 0.036889f, 0.038204f, + 0.039546f, 0.040915f, 0.042311f, 0.043735f, 0.045186f, 0.046665f, 0.048172f, 0.049707f, + 0.051269f, 0.052861f, 0.054480f, 0.056128f, 0.057805f, 0.059511f, 0.061246f, 0.063010f, + 0.064803f, 0.066626f, 0.068478f, 0.070360f, 0.072272f, 0.074214f, 0.076185f, 0.078187f, + 0.080220f, 0.082283f, 0.084376f, 0.086500f, 0.088656f, 0.090842f, 0.093059f, 0.095307f, + 0.097587f, 0.099899f, 0.102242f, 0.104616f, 0.107023f, 0.109462f, 0.111932f, 0.114435f, + 0.116971f, 0.119538f, 0.122139f, 0.124772f, 0.127438f, 0.130136f, 0.132868f, 0.135633f, + 0.138432f, 0.141263f, 0.144128f, 0.147027f, 0.149960f, 0.152926f, 0.155926f, 0.158961f, + 0.162029f, 0.165132f, 0.168269f, 0.171441f, 0.174647f, 0.177888f, 0.181164f, 0.184475f, + 0.187821f, 0.191202f, 0.194618f, 0.198069f, 0.201556f, 0.205079f, 0.208637f, 0.212231f, + 0.215861f, 0.219526f, 0.223228f, 0.226966f, 0.230740f, 0.234551f, 0.238398f, 0.242281f, + 0.246201f, 0.250158f, 0.254152f, 0.258183f, 0.262251f, 0.266356f, 0.270498f, 0.274677f, + 0.278894f, 0.283149f, 0.287441f, 0.291771f, 0.296138f, 0.300544f, 0.304987f, 0.309469f, + 0.313989f, 0.318547f, 0.323143f, 0.327778f, 0.332452f, 0.337164f, 0.341914f, 0.346704f, + 0.351533f, 0.356400f, 0.361307f, 0.366253f, 0.371238f, 0.376262f, 0.381326f, 0.386430f, + 0.391573f, 0.396755f, 0.401978f, 0.407240f, 0.412543f, 0.417885f, 0.423268f, 0.428691f, + 0.434154f, 0.439657f, 0.445201f, 0.450786f, 0.456411f, 0.462077f, 0.467784f, 0.473532f, + 0.479320f, 0.485150f, 0.491021f, 0.496933f, 0.502887f, 0.508881f, 0.514918f, 0.520996f, + 0.527115f, 0.533276f, 0.539480f, 0.545725f, 0.552011f, 0.558340f, 0.564712f, 0.571125f, + 0.577581f, 0.584078f, 0.590619f, 0.597202f, 0.603827f, 0.610496f, 0.617207f, 0.623960f, + 0.630757f, 0.637597f, 0.644480f, 0.651406f, 0.658375f, 0.665387f, 0.672443f, 0.679543f, + 0.686685f, 0.693872f, 0.701102f, 0.708376f, 0.715694f, 0.723055f, 0.730461f, 0.737911f, + 0.745404f, 0.752942f, 0.760525f, 0.768151f, 0.775822f, 0.783538f, 0.791298f, 0.799103f, + 0.806952f, 0.814847f, 0.822786f, 0.830770f, 0.838799f, 0.846873f, 0.854993f, 0.863157f, + 0.871367f, 0.879622f, 0.887923f, 0.896269f, 0.904661f, 0.913099f, 0.921582f, 0.930111f, + 0.938686f, 0.947307f, 0.955974f, 0.964686f, 0.973445f, 0.982251f, 0.991102f, 1.0f}; + +typedef union { + unsigned int u; + float f; +} stbir__FP32; + +// From https://gist.github.com/rygorous/2203834 + +static const stbir_uint32 fp32_to_srgb8_tab4[104] = { + 0x0073000d, 0x007a000d, 0x0080000d, 0x0087000d, 0x008d000d, 0x0094000d, 0x009a000d, 0x00a1000d, + 0x00a7001a, 0x00b4001a, 0x00c1001a, 0x00ce001a, 0x00da001a, 0x00e7001a, 0x00f4001a, 0x0101001a, + 0x010e0033, 0x01280033, 0x01410033, 0x015b0033, 0x01750033, 0x018f0033, 0x01a80033, 0x01c20033, + 0x01dc0067, 0x020f0067, 0x02430067, 0x02760067, 0x02aa0067, 0x02dd0067, 0x03110067, 0x03440067, + 0x037800ce, 0x03df00ce, 0x044600ce, 0x04ad00ce, 0x051400ce, 0x057b00c5, 0x05dd00bc, 0x063b00b5, + 0x06970158, 0x07420142, 0x07e30130, 0x087b0120, 0x090b0112, 0x09940106, 0x0a1700fc, 0x0a9500f2, + 0x0b0f01cb, 0x0bf401ae, 0x0ccb0195, 0x0d950180, 0x0e56016e, 0x0f0d015e, 0x0fbc0150, 0x10630143, + 0x11070264, 0x1238023e, 0x1357021d, 0x14660201, 0x156601e9, 0x165a01d3, 0x174401c0, 0x182401af, + 0x18fe0331, 0x1a9602fe, 0x1c1502d2, 0x1d7e02ad, 0x1ed4028d, 0x201a0270, 0x21520256, 0x227d0240, + 0x239f0443, 0x25c003fe, 0x27bf03c4, 0x29a10392, 0x2b6a0367, 0x2d1d0341, 0x2ebe031f, 0x304d0300, + 0x31d105b0, 0x34a80555, 0x37520507, 0x39d504c5, 0x3c37048b, 0x3e7c0458, 0x40a8042a, 0x42bd0401, + 0x44c20798, 0x488e071e, 0x4c1c06b6, 0x4f76065d, 0x52a50610, 0x55ac05cc, 0x5892058f, 0x5b590559, + 0x5e0c0a23, 0x631c0980, 0x67db08f6, 0x6c55087f, 0x70940818, 0x74a007bd, 0x787d076c, 0x7c330723, +}; + +static stbir__inline stbir_uint8 stbir__linear_to_srgb_uchar(float in) { + static const stbir__FP32 almostone = {0x3f7fffff}; // 1-eps + static const stbir__FP32 minval = {(127 - 13) << 23}; + stbir_uint32 tab, bias, scale, t; + stbir__FP32 f; + + // Clamp to [2^(-13), 1-eps]; these two values map to 0 and 1, respectively. + // The tests are carefully written so that NaNs map to 0, same as in the reference + // implementation. + if (!(in > minval.f)) // written this way to catch NaNs + return 0; + if (in > almostone.f) + return 255; + + // Do the table lookup and unpack bias, scale + f.f = in; + tab = fp32_to_srgb8_tab4[(f.u - minval.u) >> 20]; + bias = (tab >> 16) << 9; + scale = tab & 0xffff; + + // Grab next-highest mantissa bits and perform linear interpolation + t = (f.u >> 12) & 0xff; + return (unsigned char)((bias + scale * t) >> 16); +} + +#ifndef STBIR_FORCE_GATHER_FILTER_SCANLINES_AMOUNT +#define STBIR_FORCE_GATHER_FILTER_SCANLINES_AMOUNT \ + 32 // when downsampling and <= 32 scanlines of buffering, use gather. gather used down to 1/8th + // scaling for 25% win. +#endif + +#ifndef STBIR_FORCE_MINIMUM_SCANLINES_FOR_SPLITS +#define STBIR_FORCE_MINIMUM_SCANLINES_FOR_SPLITS \ + 4 // when threading, what is the minimum number of scanlines for a split? +#endif + +// restrict pointers for the output pointers, other loop and unroll control +#if defined(_MSC_VER) && !defined(__clang__) +#define STBIR_STREAMOUT_PTR(star) star __restrict +#define STBIR_NO_UNROLL(ptr) __assume(ptr) // this oddly keeps msvc from unrolling a loop +#if _MSC_VER >= 1900 +#define STBIR_NO_UNROLL_LOOP_START __pragma(loop(no_vector)) +#else +#define STBIR_NO_UNROLL_LOOP_START +#endif +#elif defined(__clang__) +#define STBIR_STREAMOUT_PTR(star) star __restrict__ +#define STBIR_NO_UNROLL(ptr) __asm__("" ::"r"(ptr)) +#if (__clang_major__ >= 4) || ((__clang_major__ >= 3) && (__clang_minor__ >= 5)) +#define STBIR_NO_UNROLL_LOOP_START \ + _Pragma("clang loop unroll(disable)") _Pragma("clang loop vectorize(disable)") +#else +#define STBIR_NO_UNROLL_LOOP_START +#endif +#elif defined(__GNUC__) +#define STBIR_STREAMOUT_PTR(star) star __restrict__ +#define STBIR_NO_UNROLL(ptr) __asm__("" ::"r"(ptr)) +#if __GNUC__ >= 14 +#define STBIR_NO_UNROLL_LOOP_START _Pragma("GCC unroll 0") _Pragma("GCC novector") +#else +#define STBIR_NO_UNROLL_LOOP_START +#endif +#define STBIR_NO_UNROLL_LOOP_START_INF_FOR +#else +#define STBIR_STREAMOUT_PTR(star) star +#define STBIR_NO_UNROLL(ptr) +#define STBIR_NO_UNROLL_LOOP_START +#endif + +#ifndef STBIR_NO_UNROLL_LOOP_START_INF_FOR +#define STBIR_NO_UNROLL_LOOP_START_INF_FOR STBIR_NO_UNROLL_LOOP_START +#endif + +#ifdef STBIR_NO_SIMD // force simd off for whatever reason + +// force simd off overrides everything else, so clear it all + +#ifdef STBIR_SSE2 +#undef STBIR_SSE2 +#endif + +#ifdef STBIR_AVX +#undef STBIR_AVX +#endif + +#ifdef STBIR_NEON +#undef STBIR_NEON +#endif + +#ifdef STBIR_AVX2 +#undef STBIR_AVX2 +#endif + +#ifdef STBIR_FP16C +#undef STBIR_FP16C +#endif + +#ifdef STBIR_WASM +#undef STBIR_WASM +#endif + +#ifdef STBIR_SIMD +#undef STBIR_SIMD +#endif + +#else // STBIR_SIMD + +#ifdef STBIR_SSE2 +#include + +#define stbir__simdf __m128 +#define stbir__simdi __m128i + +#define stbir_simdi_castf(reg) _mm_castps_si128(reg) +#define stbir_simdf_casti(reg) _mm_castsi128_ps(reg) + +#define stbir__simdf_load(reg, ptr) (reg) = _mm_loadu_ps((float const *)(ptr)) +#define stbir__simdi_load(reg, ptr) (reg) = _mm_loadu_si128((stbir__simdi const *)(ptr)) +#define stbir__simdf_load1(out, ptr) \ + (out) = _mm_load_ss( \ + (float const *)(ptr)) // top values can be random (not denormal or nan for perf) +#define stbir__simdi_load1(out, ptr) (out) = _mm_castps_si128(_mm_load_ss((float const *)(ptr))) +#define stbir__simdf_load1z(out, ptr) \ + (out) = _mm_load_ss((float const *)(ptr)) // top values must be zero +#define stbir__simdf_frep4(fvar) _mm_set_ps1(fvar) +#define stbir__simdf_load1frep4(out, fvar) (out) = _mm_set_ps1(fvar) +#define stbir__simdf_load2(out, ptr) \ + (out) = _mm_castsi128_ps(_mm_loadl_epi64( \ + (__m128i *)(ptr))) // top values can be random (not denormal or nan for perf) +#define stbir__simdf_load2z(out, ptr) \ + (out) = _mm_castsi128_ps(_mm_loadl_epi64((__m128i *)(ptr))) // top values must be zero +#define stbir__simdf_load2hmerge(out, reg, ptr) \ + (out) = _mm_castpd_ps(_mm_loadh_pd(_mm_castps_pd(reg), (double *)(ptr))) + +#define stbir__simdf_zeroP() _mm_setzero_ps() +#define stbir__simdf_zero(reg) (reg) = _mm_setzero_ps() + +#define stbir__simdf_store(ptr, reg) _mm_storeu_ps((float *)(ptr), reg) +#define stbir__simdf_store1(ptr, reg) _mm_store_ss((float *)(ptr), reg) +#define stbir__simdf_store2(ptr, reg) _mm_storel_epi64((__m128i *)(ptr), _mm_castps_si128(reg)) +#define stbir__simdf_store2h(ptr, reg) _mm_storeh_pd((double *)(ptr), _mm_castps_pd(reg)) + +#define stbir__simdi_store(ptr, reg) _mm_storeu_si128((__m128i *)(ptr), reg) +#define stbir__simdi_store1(ptr, reg) _mm_store_ss((float *)(ptr), _mm_castsi128_ps(reg)) +#define stbir__simdi_store2(ptr, reg) _mm_storel_epi64((__m128i *)(ptr), (reg)) + +#define stbir__prefetch(ptr) _mm_prefetch((char *)(ptr), _MM_HINT_T0) + +#define stbir__simdi_expand_u8_to_u32(out0, out1, out2, out3, ireg) \ + { \ + stbir__simdi zero = _mm_setzero_si128(); \ + out2 = _mm_unpacklo_epi8(ireg, zero); \ + out3 = _mm_unpackhi_epi8(ireg, zero); \ + out0 = _mm_unpacklo_epi16(out2, zero); \ + out1 = _mm_unpackhi_epi16(out2, zero); \ + out2 = _mm_unpacklo_epi16(out3, zero); \ + out3 = _mm_unpackhi_epi16(out3, zero); \ + } + +#define stbir__simdi_expand_u8_to_1u32(out, ireg) \ + { \ + stbir__simdi zero = _mm_setzero_si128(); \ + out = _mm_unpacklo_epi8(ireg, zero); \ + out = _mm_unpacklo_epi16(out, zero); \ + } + +#define stbir__simdi_expand_u16_to_u32(out0, out1, ireg) \ + { \ + stbir__simdi zero = _mm_setzero_si128(); \ + out0 = _mm_unpacklo_epi16(ireg, zero); \ + out1 = _mm_unpackhi_epi16(ireg, zero); \ + } + +#define stbir__simdf_convert_float_to_i32(i, f) (i) = _mm_cvttps_epi32(f) +#define stbir__simdf_convert_float_to_int(f) _mm_cvtt_ss2si(f) +#define stbir__simdf_convert_float_to_uint8(f) \ + ((unsigned char)_mm_cvtsi128_si32(_mm_cvttps_epi32( \ + _mm_max_ps(_mm_min_ps(f, STBIR__CONSTF(STBIR_max_uint8_as_float)), _mm_setzero_ps())))) +#define stbir__simdf_convert_float_to_short(f) \ + ((unsigned short)_mm_cvtsi128_si32(_mm_cvttps_epi32( \ + _mm_max_ps(_mm_min_ps(f, STBIR__CONSTF(STBIR_max_uint16_as_float)), _mm_setzero_ps())))) + +#define stbir__simdi_to_int(i) _mm_cvtsi128_si32(i) +#define stbir__simdi_convert_i32_to_float(out, ireg) (out) = _mm_cvtepi32_ps(ireg) +#define stbir__simdf_add(out, reg0, reg1) (out) = _mm_add_ps(reg0, reg1) +#define stbir__simdf_mult(out, reg0, reg1) (out) = _mm_mul_ps(reg0, reg1) +#define stbir__simdf_mult_mem(out, reg, ptr) \ + (out) = _mm_mul_ps(reg, _mm_loadu_ps((float const *)(ptr))) +#define stbir__simdf_mult1_mem(out, reg, ptr) \ + (out) = _mm_mul_ss(reg, _mm_load_ss((float const *)(ptr))) +#define stbir__simdf_add_mem(out, reg, ptr) \ + (out) = _mm_add_ps(reg, _mm_loadu_ps((float const *)(ptr))) +#define stbir__simdf_add1_mem(out, reg, ptr) \ + (out) = _mm_add_ss(reg, _mm_load_ss((float const *)(ptr))) + +#ifdef STBIR_USE_FMA // not on by default to maintain bit identical simd to non-simd +#include +#define stbir__simdf_madd(out, add, mul1, mul2) (out) = _mm_fmadd_ps(mul1, mul2, add) +#define stbir__simdf_madd1(out, add, mul1, mul2) (out) = _mm_fmadd_ss(mul1, mul2, add) +#define stbir__simdf_madd_mem(out, add, mul, ptr) \ + (out) = _mm_fmadd_ps(mul, _mm_loadu_ps((float const *)(ptr)), add) +#define stbir__simdf_madd1_mem(out, add, mul, ptr) \ + (out) = _mm_fmadd_ss(mul, _mm_load_ss((float const *)(ptr)), add) +#else +#define stbir__simdf_madd(out, add, mul1, mul2) (out) = _mm_add_ps(add, _mm_mul_ps(mul1, mul2)) +#define stbir__simdf_madd1(out, add, mul1, mul2) (out) = _mm_add_ss(add, _mm_mul_ss(mul1, mul2)) +#define stbir__simdf_madd_mem(out, add, mul, ptr) \ + (out) = _mm_add_ps(add, _mm_mul_ps(mul, _mm_loadu_ps((float const *)(ptr)))) +#define stbir__simdf_madd1_mem(out, add, mul, ptr) \ + (out) = _mm_add_ss(add, _mm_mul_ss(mul, _mm_load_ss((float const *)(ptr)))) +#endif + +#define stbir__simdf_add1(out, reg0, reg1) (out) = _mm_add_ss(reg0, reg1) +#define stbir__simdf_mult1(out, reg0, reg1) (out) = _mm_mul_ss(reg0, reg1) + +#define stbir__simdf_and(out, reg0, reg1) (out) = _mm_and_ps(reg0, reg1) +#define stbir__simdf_or(out, reg0, reg1) (out) = _mm_or_ps(reg0, reg1) + +#define stbir__simdf_min(out, reg0, reg1) (out) = _mm_min_ps(reg0, reg1) +#define stbir__simdf_max(out, reg0, reg1) (out) = _mm_max_ps(reg0, reg1) +#define stbir__simdf_min1(out, reg0, reg1) (out) = _mm_min_ss(reg0, reg1) +#define stbir__simdf_max1(out, reg0, reg1) (out) = _mm_max_ss(reg0, reg1) + +#define stbir__simdf_0123ABCDto3ABx(out, reg0, reg1) \ + (out) = _mm_castsi128_ps(_mm_shuffle_epi32( \ + _mm_castps_si128(_mm_shuffle_ps(reg1, reg0, (0 << 0) + (1 << 2) + (2 << 4) + (3 << 6))), \ + (3 << 0) + (0 << 2) + (1 << 4) + (2 << 6))) +#define stbir__simdf_0123ABCDto23Ax(out, reg0, reg1) \ + (out) = _mm_castsi128_ps(_mm_shuffle_epi32( \ + _mm_castps_si128(_mm_shuffle_ps(reg1, reg0, (0 << 0) + (1 << 2) + (2 << 4) + (3 << 6))), \ + (2 << 0) + (3 << 2) + (0 << 4) + (1 << 6))) + +static const stbir__simdf STBIR_zeroones = {0.0f, 1.0f, 0.0f, 1.0f}; +static const stbir__simdf STBIR_onezeros = {1.0f, 0.0f, 1.0f, 0.0f}; +#define stbir__simdf_aaa1(out, alp, ones) \ + (out) = _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(_mm_movehl_ps(ones, alp)), \ + (1 << 0) + (1 << 2) + (1 << 4) + (2 << 6))) +#define stbir__simdf_1aaa(out, alp, ones) \ + (out) = _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(_mm_movelh_ps(ones, alp)), \ + (0 << 0) + (2 << 2) + (2 << 4) + (2 << 6))) +#define stbir__simdf_a1a1(out, alp, ones) \ + (out) = _mm_or_ps(_mm_castsi128_ps(_mm_srli_epi64(_mm_castps_si128(alp), 32)), STBIR_zeroones) +#define stbir__simdf_1a1a(out, alp, ones) \ + (out) = _mm_or_ps(_mm_castsi128_ps(_mm_slli_epi64(_mm_castps_si128(alp), 32)), STBIR_onezeros) + +#define stbir__simdf_swiz(reg, one, two, three, four) \ + _mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(reg), \ + (one << 0) + (two << 2) + (three << 4) + (four << 6))) + +#define stbir__simdi_and(out, reg0, reg1) (out) = _mm_and_si128(reg0, reg1) +#define stbir__simdi_or(out, reg0, reg1) (out) = _mm_or_si128(reg0, reg1) +#define stbir__simdi_16madd(out, reg0, reg1) (out) = _mm_madd_epi16(reg0, reg1) + +#define stbir__simdf_pack_to_8bytes(out, aa, bb) \ + { \ + stbir__simdf af, bf; \ + stbir__simdi a, b; \ + af = _mm_min_ps(aa, STBIR_max_uint8_as_float); \ + bf = _mm_min_ps(bb, STBIR_max_uint8_as_float); \ + af = _mm_max_ps(af, _mm_setzero_ps()); \ + bf = _mm_max_ps(bf, _mm_setzero_ps()); \ + a = _mm_cvttps_epi32(af); \ + b = _mm_cvttps_epi32(bf); \ + a = _mm_packs_epi32(a, b); \ + out = _mm_packus_epi16(a, a); \ + } + +#define stbir__simdf_load4_transposed(o0, o1, o2, o3, ptr) \ + stbir__simdf_load(o0, (ptr)); \ + stbir__simdf_load(o1, (ptr) + 4); \ + stbir__simdf_load(o2, (ptr) + 8); \ + stbir__simdf_load(o3, (ptr) + 12); \ + { \ + __m128 tmp0, tmp1, tmp2, tmp3; \ + tmp0 = _mm_unpacklo_ps(o0, o1); \ + tmp2 = _mm_unpacklo_ps(o2, o3); \ + tmp1 = _mm_unpackhi_ps(o0, o1); \ + tmp3 = _mm_unpackhi_ps(o2, o3); \ + o0 = _mm_movelh_ps(tmp0, tmp2); \ + o1 = _mm_movehl_ps(tmp2, tmp0); \ + o2 = _mm_movelh_ps(tmp1, tmp3); \ + o3 = _mm_movehl_ps(tmp3, tmp1); \ + } + +#define stbir__interleave_pack_and_store_16_u8(ptr, r0, r1, r2, r3) \ + r0 = _mm_packs_epi32(r0, r1); \ + r2 = _mm_packs_epi32(r2, r3); \ + r1 = _mm_unpacklo_epi16(r0, r2); \ + r3 = _mm_unpackhi_epi16(r0, r2); \ + r0 = _mm_unpacklo_epi16(r1, r3); \ + r2 = _mm_unpackhi_epi16(r1, r3); \ + r0 = _mm_packus_epi16(r0, r2); \ + stbir__simdi_store(ptr, r0); + +#define stbir__simdi_32shr(out, reg, imm) out = _mm_srli_epi32(reg, imm) + +#if defined(_MSC_VER) && !defined(__clang__) +// msvc inits with 8 bytes +#define STBIR__CONST_32_TO_8(v) \ + (char)(unsigned char)((v) & 255), (char)(unsigned char)(((v) >> 8) & 255), \ + (char)(unsigned char)(((v) >> 16) & 255), (char)(unsigned char)(((v) >> 24) & 255) +#define STBIR__CONST_4_32i(v) \ + STBIR__CONST_32_TO_8(v), STBIR__CONST_32_TO_8(v), STBIR__CONST_32_TO_8(v), \ + STBIR__CONST_32_TO_8(v) +#define STBIR__CONST_4d_32i(v0, v1, v2, v3) \ + STBIR__CONST_32_TO_8(v0), STBIR__CONST_32_TO_8(v1), STBIR__CONST_32_TO_8(v2), \ + STBIR__CONST_32_TO_8(v3) +#else +// everything else inits with long long's +#define STBIR__CONST_4_32i(v) \ + (long long)((((stbir_uint64)(stbir_uint32)(v)) << 32) | ((stbir_uint64)(stbir_uint32)(v))), \ + (long long)((((stbir_uint64)(stbir_uint32)(v)) << 32) | ((stbir_uint64)(stbir_uint32)(v))) +#define STBIR__CONST_4d_32i(v0, v1, v2, v3) \ + (long long)((((stbir_uint64)(stbir_uint32)(v1)) << 32) | ((stbir_uint64)(stbir_uint32)(v0))), \ + (long long)((((stbir_uint64)(stbir_uint32)(v3)) << 32) | \ + ((stbir_uint64)(stbir_uint32)(v2))) +#endif + +#define STBIR__SIMDF_CONST(var, x) stbir__simdf var = {x, x, x, x} +#define STBIR__SIMDI_CONST(var, x) stbir__simdi var = {STBIR__CONST_4_32i(x)} +#define STBIR__CONSTF(var) (var) +#define STBIR__CONSTI(var) (var) + +#if defined(STBIR_AVX) || defined(__SSE4_1__) +#include +#define stbir__simdf_pack_to_8words(out, reg0, reg1) \ + out = _mm_packus_epi32( \ + _mm_cvttps_epi32(_mm_max_ps(_mm_min_ps(reg0, STBIR__CONSTF(STBIR_max_uint16_as_float)), \ + _mm_setzero_ps())), \ + _mm_cvttps_epi32(_mm_max_ps(_mm_min_ps(reg1, STBIR__CONSTF(STBIR_max_uint16_as_float)), \ + _mm_setzero_ps()))) +#else +STBIR__SIMDI_CONST(stbir__s32_32768, 32768); +STBIR__SIMDI_CONST(stbir__s16_32768, ((32768 << 16) | 32768)); + +#define stbir__simdf_pack_to_8words(out, reg0, reg1) \ + { \ + stbir__simdi tmp0, tmp1; \ + tmp0 = _mm_cvttps_epi32(_mm_max_ps( \ + _mm_min_ps(reg0, STBIR__CONSTF(STBIR_max_uint16_as_float)), _mm_setzero_ps())); \ + tmp1 = _mm_cvttps_epi32(_mm_max_ps( \ + _mm_min_ps(reg1, STBIR__CONSTF(STBIR_max_uint16_as_float)), _mm_setzero_ps())); \ + tmp0 = _mm_sub_epi32(tmp0, stbir__s32_32768); \ + tmp1 = _mm_sub_epi32(tmp1, stbir__s32_32768); \ + out = _mm_packs_epi32(tmp0, tmp1); \ + out = _mm_sub_epi16(out, stbir__s16_32768); \ + } + +#endif + +#define STBIR_SIMD + +// if we detect AVX, set the simd8 defines +#ifdef STBIR_AVX +#include +#define STBIR_SIMD8 +#define stbir__simdf8 __m256 +#define stbir__simdi8 __m256i +#define stbir__simdf8_load(out, ptr) (out) = _mm256_loadu_ps((float const *)(ptr)) +#define stbir__simdi8_load(out, ptr) (out) = _mm256_loadu_si256((__m256i const *)(ptr)) +#define stbir__simdf8_mult(out, a, b) (out) = _mm256_mul_ps((a), (b)) +#define stbir__simdf8_store(ptr, out) _mm256_storeu_ps((float *)(ptr), out) +#define stbir__simdi8_store(ptr, reg) _mm256_storeu_si256((__m256i *)(ptr), reg) +#define stbir__simdf8_frep8(fval) _mm256_set1_ps(fval) + +#define stbir__simdf8_min(out, reg0, reg1) (out) = _mm256_min_ps(reg0, reg1) +#define stbir__simdf8_max(out, reg0, reg1) (out) = _mm256_max_ps(reg0, reg1) + +#define stbir__simdf8_add4halves(out, bot4, top8) \ + (out) = _mm_add_ps(bot4, _mm256_extractf128_ps(top8, 1)) +#define stbir__simdf8_mult_mem(out, reg, ptr) \ + (out) = _mm256_mul_ps(reg, _mm256_loadu_ps((float const *)(ptr))) +#define stbir__simdf8_add_mem(out, reg, ptr) \ + (out) = _mm256_add_ps(reg, _mm256_loadu_ps((float const *)(ptr))) +#define stbir__simdf8_add(out, a, b) (out) = _mm256_add_ps(a, b) +#define stbir__simdf8_load1b(out, ptr) (out) = _mm256_broadcast_ss(ptr) +#define stbir__simdf_load1rep4(out, ptr) (out) = _mm_broadcast_ss(ptr) // avx load instruction + +#define stbir__simdi8_convert_i32_to_float(out, ireg) (out) = _mm256_cvtepi32_ps(ireg) +#define stbir__simdf8_convert_float_to_i32(i, f) (i) = _mm256_cvttps_epi32(f) + +#define stbir__simdf8_bot4s(out, a, b) (out) = _mm256_permute2f128_ps(a, b, (0 << 0) + (2 << 4)) +#define stbir__simdf8_top4s(out, a, b) (out) = _mm256_permute2f128_ps(a, b, (1 << 0) + (3 << 4)) + +#define stbir__simdf8_gettop4(reg) _mm256_extractf128_ps(reg, 1) + +#ifdef STBIR_AVX2 + +#define stbir__simdi8_expand_u8_to_u32(out0, out1, ireg) \ + { \ + stbir__simdi8 a, zero = _mm256_setzero_si256(); \ + a = _mm256_permute4x64_epi64( \ + _mm256_unpacklo_epi8( \ + _mm256_permute4x64_epi64(_mm256_castsi128_si256(ireg), \ + (0 << 0) + (2 << 2) + (1 << 4) + (3 << 6)), \ + zero), \ + (0 << 0) + (2 << 2) + (1 << 4) + (3 << 6)); \ + out0 = _mm256_unpacklo_epi16(a, zero); \ + out1 = _mm256_unpackhi_epi16(a, zero); \ + } + +#define stbir__simdf8_pack_to_16bytes(out, aa, bb) \ + { \ + stbir__simdi8 t; \ + stbir__simdf8 af, bf; \ + stbir__simdi8 a, b; \ + af = _mm256_min_ps(aa, STBIR_max_uint8_as_floatX); \ + bf = _mm256_min_ps(bb, STBIR_max_uint8_as_floatX); \ + af = _mm256_max_ps(af, _mm256_setzero_ps()); \ + bf = _mm256_max_ps(bf, _mm256_setzero_ps()); \ + a = _mm256_cvttps_epi32(af); \ + b = _mm256_cvttps_epi32(bf); \ + t = _mm256_permute4x64_epi64(_mm256_packs_epi32(a, b), \ + (0 << 0) + (2 << 2) + (1 << 4) + (3 << 6)); \ + out = _mm256_castsi256_si128(_mm256_permute4x64_epi64( \ + _mm256_packus_epi16(t, t), (0 << 0) + (2 << 2) + (1 << 4) + (3 << 6))); \ + } + +#define stbir__simdi8_expand_u16_to_u32(out, ireg) \ + out = \ + _mm256_unpacklo_epi16(_mm256_permute4x64_epi64(_mm256_castsi128_si256(ireg), \ + (0 << 0) + (2 << 2) + (1 << 4) + (3 << 6)), \ + _mm256_setzero_si256()); + +#define stbir__simdf8_pack_to_16words(out, aa, bb) \ + { \ + stbir__simdf8 af, bf; \ + stbir__simdi8 a, b; \ + af = _mm256_min_ps(aa, STBIR_max_uint16_as_floatX); \ + bf = _mm256_min_ps(bb, STBIR_max_uint16_as_floatX); \ + af = _mm256_max_ps(af, _mm256_setzero_ps()); \ + bf = _mm256_max_ps(bf, _mm256_setzero_ps()); \ + a = _mm256_cvttps_epi32(af); \ + b = _mm256_cvttps_epi32(bf); \ + (out) = _mm256_permute4x64_epi64(_mm256_packus_epi32(a, b), \ + (0 << 0) + (2 << 2) + (1 << 4) + (3 << 6)); \ + } + +#else + +#define stbir__simdi8_expand_u8_to_u32(out0, out1, ireg) \ + { \ + stbir__simdi a, zero = _mm_setzero_si128(); \ + a = _mm_unpacklo_epi8(ireg, zero); \ + out0 = _mm256_setr_m128i(_mm_unpacklo_epi16(a, zero), _mm_unpackhi_epi16(a, zero)); \ + a = _mm_unpackhi_epi8(ireg, zero); \ + out1 = _mm256_setr_m128i(_mm_unpacklo_epi16(a, zero), _mm_unpackhi_epi16(a, zero)); \ + } + +#define stbir__simdf8_pack_to_16bytes(out, aa, bb) \ + { \ + stbir__simdi t; \ + stbir__simdf8 af, bf; \ + stbir__simdi8 a, b; \ + af = _mm256_min_ps(aa, STBIR_max_uint8_as_floatX); \ + bf = _mm256_min_ps(bb, STBIR_max_uint8_as_floatX); \ + af = _mm256_max_ps(af, _mm256_setzero_ps()); \ + bf = _mm256_max_ps(bf, _mm256_setzero_ps()); \ + a = _mm256_cvttps_epi32(af); \ + b = _mm256_cvttps_epi32(bf); \ + out = _mm_packs_epi32(_mm256_castsi256_si128(a), _mm256_extractf128_si256(a, 1)); \ + out = _mm_packus_epi16(out, out); \ + t = _mm_packs_epi32(_mm256_castsi256_si128(b), _mm256_extractf128_si256(b, 1)); \ + t = _mm_packus_epi16(t, t); \ + out = _mm_castps_si128(_mm_shuffle_ps(_mm_castsi128_ps(out), _mm_castsi128_ps(t), \ + (0 << 0) + (1 << 2) + (0 << 4) + (1 << 6))); \ + } + +#define stbir__simdi8_expand_u16_to_u32(out, ireg) \ + { \ + stbir__simdi a, b, zero = _mm_setzero_si128(); \ + a = _mm_unpacklo_epi16(ireg, zero); \ + b = _mm_unpackhi_epi16(ireg, zero); \ + out = _mm256_insertf128_si256(_mm256_castsi128_si256(a), b, 1); \ + } + +#define stbir__simdf8_pack_to_16words(out, aa, bb) \ + { \ + stbir__simdi t0, t1; \ + stbir__simdf8 af, bf; \ + stbir__simdi8 a, b; \ + af = _mm256_min_ps(aa, STBIR_max_uint16_as_floatX); \ + bf = _mm256_min_ps(bb, STBIR_max_uint16_as_floatX); \ + af = _mm256_max_ps(af, _mm256_setzero_ps()); \ + bf = _mm256_max_ps(bf, _mm256_setzero_ps()); \ + a = _mm256_cvttps_epi32(af); \ + b = _mm256_cvttps_epi32(bf); \ + t0 = _mm_packus_epi32(_mm256_castsi256_si128(a), _mm256_extractf128_si256(a, 1)); \ + t1 = _mm_packus_epi32(_mm256_castsi256_si128(b), _mm256_extractf128_si256(b, 1)); \ + out = _mm256_setr_m128i(t0, t1); \ + } + +#endif + +static __m256i stbir_00001111 = {STBIR__CONST_4d_32i(0, 0, 0, 0), STBIR__CONST_4d_32i(1, 1, 1, 1)}; +#define stbir__simdf8_0123to00001111(out, in) (out) = _mm256_permutevar_ps(in, stbir_00001111) + +static __m256i stbir_22223333 = {STBIR__CONST_4d_32i(2, 2, 2, 2), STBIR__CONST_4d_32i(3, 3, 3, 3)}; +#define stbir__simdf8_0123to22223333(out, in) (out) = _mm256_permutevar_ps(in, stbir_22223333) + +#define stbir__simdf8_0123to2222(out, in) \ + (out) = stbir__simdf_swiz(_mm256_castps256_ps128(in), 2, 2, 2, 2) + +#define stbir__simdf8_load4b(out, ptr) (out) = _mm256_broadcast_ps((__m128 const *)(ptr)) + +static __m256i stbir_00112233 = {STBIR__CONST_4d_32i(0, 0, 1, 1), STBIR__CONST_4d_32i(2, 2, 3, 3)}; +#define stbir__simdf8_0123to00112233(out, in) (out) = _mm256_permutevar_ps(in, stbir_00112233) +#define stbir__simdf8_add4(out, a8, b) (out) = _mm256_add_ps(a8, _mm256_castps128_ps256(b)) + +static __m256i stbir_load6 = {STBIR__CONST_4_32i(0x80000000), + STBIR__CONST_4d_32i(0x80000000, 0x80000000, 0, 0)}; +#define stbir__simdf8_load6z(out, ptr) (out) = _mm256_maskload_ps(ptr, stbir_load6) + +#define stbir__simdf8_0123to00000000(out, in) \ + (out) = _mm256_shuffle_ps(in, in, (0 << 0) + (0 << 2) + (0 << 4) + (0 << 6)) +#define stbir__simdf8_0123to11111111(out, in) \ + (out) = _mm256_shuffle_ps(in, in, (1 << 0) + (1 << 2) + (1 << 4) + (1 << 6)) +#define stbir__simdf8_0123to22222222(out, in) \ + (out) = _mm256_shuffle_ps(in, in, (2 << 0) + (2 << 2) + (2 << 4) + (2 << 6)) +#define stbir__simdf8_0123to33333333(out, in) \ + (out) = _mm256_shuffle_ps(in, in, (3 << 0) + (3 << 2) + (3 << 4) + (3 << 6)) +#define stbir__simdf8_0123to21032103(out, in) \ + (out) = _mm256_shuffle_ps(in, in, (2 << 0) + (1 << 2) + (0 << 4) + (3 << 6)) +#define stbir__simdf8_0123to32103210(out, in) \ + (out) = _mm256_shuffle_ps(in, in, (3 << 0) + (2 << 2) + (1 << 4) + (0 << 6)) +#define stbir__simdf8_0123to12301230(out, in) \ + (out) = _mm256_shuffle_ps(in, in, (1 << 0) + (2 << 2) + (3 << 4) + (0 << 6)) +#define stbir__simdf8_0123to10321032(out, in) \ + (out) = _mm256_shuffle_ps(in, in, (1 << 0) + (0 << 2) + (3 << 4) + (2 << 6)) +#define stbir__simdf8_0123to30123012(out, in) \ + (out) = _mm256_shuffle_ps(in, in, (3 << 0) + (0 << 2) + (1 << 4) + (2 << 6)) + +#define stbir__simdf8_0123to11331133(out, in) \ + (out) = _mm256_shuffle_ps(in, in, (1 << 0) + (1 << 2) + (3 << 4) + (3 << 6)) +#define stbir__simdf8_0123to00220022(out, in) \ + (out) = _mm256_shuffle_ps(in, in, (0 << 0) + (0 << 2) + (2 << 4) + (2 << 6)) + +#define stbir__simdf8_aaa1(out, alp, ones) \ + (out) = _mm256_blend_ps(alp, ones, \ + (1 << 0) + (1 << 1) + (1 << 2) + (0 << 3) + (1 << 4) + (1 << 5) + \ + (1 << 6) + (0 << 7)); \ + (out) = _mm256_shuffle_ps(out, out, (3 << 0) + (3 << 2) + (3 << 4) + (0 << 6)) +#define stbir__simdf8_1aaa(out, alp, ones) \ + (out) = _mm256_blend_ps(alp, ones, \ + (0 << 0) + (1 << 1) + (1 << 2) + (1 << 3) + (0 << 4) + (1 << 5) + \ + (1 << 6) + (1 << 7)); \ + (out) = _mm256_shuffle_ps(out, out, (1 << 0) + (0 << 2) + (0 << 4) + (0 << 6)) +#define stbir__simdf8_a1a1(out, alp, ones) \ + (out) = _mm256_blend_ps(alp, ones, \ + (1 << 0) + (0 << 1) + (1 << 2) + (0 << 3) + (1 << 4) + (0 << 5) + \ + (1 << 6) + (0 << 7)); \ + (out) = _mm256_shuffle_ps(out, out, (1 << 0) + (0 << 2) + (3 << 4) + (2 << 6)) +#define stbir__simdf8_1a1a(out, alp, ones) \ + (out) = _mm256_blend_ps(alp, ones, \ + (0 << 0) + (1 << 1) + (0 << 2) + (1 << 3) + (0 << 4) + (1 << 5) + \ + (0 << 6) + (1 << 7)); \ + (out) = _mm256_shuffle_ps(out, out, (1 << 0) + (0 << 2) + (3 << 4) + (2 << 6)) + +#define stbir__simdf8_zero(reg) (reg) = _mm256_setzero_ps() + +#ifdef STBIR_USE_FMA // not on by default to maintain bit identical simd to non-simd +#define stbir__simdf8_madd(out, add, mul1, mul2) (out) = _mm256_fmadd_ps(mul1, mul2, add) +#define stbir__simdf8_madd_mem(out, add, mul, ptr) \ + (out) = _mm256_fmadd_ps(mul, _mm256_loadu_ps((float const *)(ptr)), add) +#define stbir__simdf8_madd_mem4(out, add, mul, ptr) \ + (out) = _mm256_fmadd_ps( \ + _mm256_setr_m128(mul, _mm_setzero_ps()), \ + _mm256_setr_m128(_mm_loadu_ps((float const *)(ptr)), _mm_setzero_ps()), add) +#else +#define stbir__simdf8_madd(out, add, mul1, mul2) \ + (out) = _mm256_add_ps(add, _mm256_mul_ps(mul1, mul2)) +#define stbir__simdf8_madd_mem(out, add, mul, ptr) \ + (out) = _mm256_add_ps(add, _mm256_mul_ps(mul, _mm256_loadu_ps((float const *)(ptr)))) +#define stbir__simdf8_madd_mem4(out, add, mul, ptr) \ + (out) = \ + _mm256_add_ps(add, _mm256_setr_m128(_mm_mul_ps(mul, _mm_loadu_ps((float const *)(ptr))), \ + _mm_setzero_ps())) +#endif +#define stbir__if_simdf8_cast_to_simdf4(val) _mm256_castps256_ps128(val) + +#endif + +#ifdef STBIR_FLOORF +#undef STBIR_FLOORF +#endif +#define STBIR_FLOORF stbir_simd_floorf +static stbir__inline float stbir_simd_floorf(float x) // martins floorf +{ +#if defined(STBIR_AVX) || defined(__SSE4_1__) || defined(STBIR_SSE41) + __m128 t = _mm_set_ss(x); + return _mm_cvtss_f32(_mm_floor_ss(t, t)); +#else + __m128 f = _mm_set_ss(x); + __m128 t = _mm_cvtepi32_ps(_mm_cvttps_epi32(f)); + __m128 r = _mm_add_ss(t, _mm_and_ps(_mm_cmplt_ss(f, t), _mm_set_ss(-1.0f))); + return _mm_cvtss_f32(r); +#endif +} + +#ifdef STBIR_CEILF +#undef STBIR_CEILF +#endif +#define STBIR_CEILF stbir_simd_ceilf +static stbir__inline float stbir_simd_ceilf(float x) // martins ceilf +{ +#if defined(STBIR_AVX) || defined(__SSE4_1__) || defined(STBIR_SSE41) + __m128 t = _mm_set_ss(x); + return _mm_cvtss_f32(_mm_ceil_ss(t, t)); +#else + __m128 f = _mm_set_ss(x); + __m128 t = _mm_cvtepi32_ps(_mm_cvttps_epi32(f)); + __m128 r = _mm_add_ss(t, _mm_and_ps(_mm_cmplt_ss(t, f), _mm_set_ss(1.0f))); + return _mm_cvtss_f32(r); +#endif +} + +#elif defined(STBIR_NEON) + +#include + +#define stbir__simdf float32x4_t +#define stbir__simdi uint32x4_t + +#define stbir_simdi_castf(reg) vreinterpretq_u32_f32(reg) +#define stbir_simdf_casti(reg) vreinterpretq_f32_u32(reg) + +#define stbir__simdf_load(reg, ptr) (reg) = vld1q_f32((float const *)(ptr)) +#define stbir__simdi_load(reg, ptr) (reg) = vld1q_u32((uint32_t const *)(ptr)) +#define stbir__simdf_load1(out, ptr) \ + (out) = vld1q_dup_f32( \ + (float const *)(ptr)) // top values can be random (not denormal or nan for perf) +#define stbir__simdi_load1(out, ptr) (out) = vld1q_dup_u32((uint32_t const *)(ptr)) +#define stbir__simdf_load1z(out, ptr) \ + (out) = vld1q_lane_f32((float const *)(ptr), vdupq_n_f32(0), 0) // top values must be zero +#define stbir__simdf_frep4(fvar) vdupq_n_f32(fvar) +#define stbir__simdf_load1frep4(out, fvar) (out) = vdupq_n_f32(fvar) +#define stbir__simdf_load2(out, ptr) \ + (out) = \ + vcombine_f32(vld1_f32((float const *)(ptr)), \ + vcreate_f32(0)) // top values can be random (not denormal or nan for perf) +#define stbir__simdf_load2z(out, ptr) \ + (out) = vcombine_f32(vld1_f32((float const *)(ptr)), vcreate_f32(0)) // top values must be zero +#define stbir__simdf_load2hmerge(out, reg, ptr) \ + (out) = vcombine_f32(vget_low_f32(reg), vld1_f32((float const *)(ptr))) + +#define stbir__simdf_zeroP() vdupq_n_f32(0) +#define stbir__simdf_zero(reg) (reg) = vdupq_n_f32(0) + +#define stbir__simdf_store(ptr, reg) vst1q_f32((float *)(ptr), reg) +#define stbir__simdf_store1(ptr, reg) vst1q_lane_f32((float *)(ptr), reg, 0) +#define stbir__simdf_store2(ptr, reg) vst1_f32((float *)(ptr), vget_low_f32(reg)) +#define stbir__simdf_store2h(ptr, reg) vst1_f32((float *)(ptr), vget_high_f32(reg)) + +#define stbir__simdi_store(ptr, reg) vst1q_u32((uint32_t *)(ptr), reg) +#define stbir__simdi_store1(ptr, reg) vst1q_lane_u32((uint32_t *)(ptr), reg, 0) +#define stbir__simdi_store2(ptr, reg) vst1_u32((uint32_t *)(ptr), vget_low_u32(reg)) + +#define stbir__prefetch(ptr) + +#define stbir__simdi_expand_u8_to_u32(out0, out1, out2, out3, ireg) \ + { \ + uint16x8_t l = vmovl_u8(vget_low_u8(vreinterpretq_u8_u32(ireg))); \ + uint16x8_t h = vmovl_u8(vget_high_u8(vreinterpretq_u8_u32(ireg))); \ + out0 = vmovl_u16(vget_low_u16(l)); \ + out1 = vmovl_u16(vget_high_u16(l)); \ + out2 = vmovl_u16(vget_low_u16(h)); \ + out3 = vmovl_u16(vget_high_u16(h)); \ + } + +#define stbir__simdi_expand_u8_to_1u32(out, ireg) \ + { \ + uint16x8_t tmp = vmovl_u8(vget_low_u8(vreinterpretq_u8_u32(ireg))); \ + out = vmovl_u16(vget_low_u16(tmp)); \ + } + +#define stbir__simdi_expand_u16_to_u32(out0, out1, ireg) \ + { \ + uint16x8_t tmp = vreinterpretq_u16_u32(ireg); \ + out0 = vmovl_u16(vget_low_u16(tmp)); \ + out1 = vmovl_u16(vget_high_u16(tmp)); \ + } + +#define stbir__simdf_convert_float_to_i32(i, f) (i) = vreinterpretq_u32_s32(vcvtq_s32_f32(f)) +#define stbir__simdf_convert_float_to_int(f) vgetq_lane_s32(vcvtq_s32_f32(f), 0) +#define stbir__simdi_to_int(i) (int)vgetq_lane_u32(i, 0) +#define stbir__simdf_convert_float_to_uint8(f) \ + ((unsigned char)vgetq_lane_s32( \ + vcvtq_s32_f32( \ + vmaxq_f32(vminq_f32(f, STBIR__CONSTF(STBIR_max_uint8_as_float)), vdupq_n_f32(0))), \ + 0)) +#define stbir__simdf_convert_float_to_short(f) \ + ((unsigned short)vgetq_lane_s32( \ + vcvtq_s32_f32( \ + vmaxq_f32(vminq_f32(f, STBIR__CONSTF(STBIR_max_uint16_as_float)), vdupq_n_f32(0))), \ + 0)) +#define stbir__simdi_convert_i32_to_float(out, ireg) \ + (out) = vcvtq_f32_s32(vreinterpretq_s32_u32(ireg)) +#define stbir__simdf_add(out, reg0, reg1) (out) = vaddq_f32(reg0, reg1) +#define stbir__simdf_mult(out, reg0, reg1) (out) = vmulq_f32(reg0, reg1) +#define stbir__simdf_mult_mem(out, reg, ptr) (out) = vmulq_f32(reg, vld1q_f32((float const *)(ptr))) +#define stbir__simdf_mult1_mem(out, reg, ptr) \ + (out) = vmulq_f32(reg, vld1q_dup_f32((float const *)(ptr))) +#define stbir__simdf_add_mem(out, reg, ptr) (out) = vaddq_f32(reg, vld1q_f32((float const *)(ptr))) +#define stbir__simdf_add1_mem(out, reg, ptr) \ + (out) = vaddq_f32(reg, vld1q_dup_f32((float const *)(ptr))) + +#ifdef STBIR_USE_FMA // not on by default to maintain bit identical simd to non-simd (and also x64 + // no madd to arm madd) +#define stbir__simdf_madd(out, add, mul1, mul2) (out) = vfmaq_f32(add, mul1, mul2) +#define stbir__simdf_madd1(out, add, mul1, mul2) (out) = vfmaq_f32(add, mul1, mul2) +#define stbir__simdf_madd_mem(out, add, mul, ptr) \ + (out) = vfmaq_f32(add, mul, vld1q_f32((float const *)(ptr))) +#define stbir__simdf_madd1_mem(out, add, mul, ptr) \ + (out) = vfmaq_f32(add, mul, vld1q_dup_f32((float const *)(ptr))) +#else +#define stbir__simdf_madd(out, add, mul1, mul2) (out) = vaddq_f32(add, vmulq_f32(mul1, mul2)) +#define stbir__simdf_madd1(out, add, mul1, mul2) (out) = vaddq_f32(add, vmulq_f32(mul1, mul2)) +#define stbir__simdf_madd_mem(out, add, mul, ptr) \ + (out) = vaddq_f32(add, vmulq_f32(mul, vld1q_f32((float const *)(ptr)))) +#define stbir__simdf_madd1_mem(out, add, mul, ptr) \ + (out) = vaddq_f32(add, vmulq_f32(mul, vld1q_dup_f32((float const *)(ptr)))) +#endif + +#define stbir__simdf_add1(out, reg0, reg1) (out) = vaddq_f32(reg0, reg1) +#define stbir__simdf_mult1(out, reg0, reg1) (out) = vmulq_f32(reg0, reg1) + +#define stbir__simdf_and(out, reg0, reg1) \ + (out) = \ + vreinterpretq_f32_u32(vandq_u32(vreinterpretq_u32_f32(reg0), vreinterpretq_u32_f32(reg1))) +#define stbir__simdf_or(out, reg0, reg1) \ + (out) = \ + vreinterpretq_f32_u32(vorrq_u32(vreinterpretq_u32_f32(reg0), vreinterpretq_u32_f32(reg1))) + +#define stbir__simdf_min(out, reg0, reg1) (out) = vminq_f32(reg0, reg1) +#define stbir__simdf_max(out, reg0, reg1) (out) = vmaxq_f32(reg0, reg1) +#define stbir__simdf_min1(out, reg0, reg1) (out) = vminq_f32(reg0, reg1) +#define stbir__simdf_max1(out, reg0, reg1) (out) = vmaxq_f32(reg0, reg1) + +#define stbir__simdf_0123ABCDto3ABx(out, reg0, reg1) (out) = vextq_f32(reg0, reg1, 3) +#define stbir__simdf_0123ABCDto23Ax(out, reg0, reg1) (out) = vextq_f32(reg0, reg1, 2) + +#define stbir__simdf_a1a1(out, alp, ones) (out) = vzipq_f32(vuzpq_f32(alp, alp).val[1], ones).val[0] +#define stbir__simdf_1a1a(out, alp, ones) (out) = vzipq_f32(ones, vuzpq_f32(alp, alp).val[0]).val[0] + +#if defined(_M_ARM64) || defined(__aarch64__) || defined(__arm64__) + +#define stbir__simdf_aaa1(out, alp, ones) \ + (out) = vcopyq_laneq_f32(vdupq_n_f32(vgetq_lane_f32(alp, 3)), 3, ones, 3) +#define stbir__simdf_1aaa(out, alp, ones) \ + (out) = vcopyq_laneq_f32(vdupq_n_f32(vgetq_lane_f32(alp, 0)), 0, ones, 0) + +#if defined(_MSC_VER) && !defined(__clang__) +#define stbir_make16(a, b, c, d) \ + vcombine_u8( \ + vcreate_u8((4 * a + 0) | ((4 * a + 1) << 8) | ((4 * a + 2) << 16) | ((4 * a + 3) << 24) | \ + ((stbir_uint64)(4 * b + 0) << 32) | ((stbir_uint64)(4 * b + 1) << 40) | \ + ((stbir_uint64)(4 * b + 2) << 48) | ((stbir_uint64)(4 * b + 3) << 56)), \ + vcreate_u8((4 * c + 0) | ((4 * c + 1) << 8) | ((4 * c + 2) << 16) | ((4 * c + 3) << 24) | \ + ((stbir_uint64)(4 * d + 0) << 32) | ((stbir_uint64)(4 * d + 1) << 40) | \ + ((stbir_uint64)(4 * d + 2) << 48) | ((stbir_uint64)(4 * d + 3) << 56))) + +static stbir__inline uint8x16x2_t stbir_make16x2(float32x4_t rega, float32x4_t regb) { + uint8x16x2_t r = {vreinterpretq_u8_f32(rega), vreinterpretq_u8_f32(regb)}; + return r; +} +#else +#define stbir_make16(a, b, c, d) \ + (uint8x16_t) { \ + 4 * a + 0, 4 * a + 1, 4 * a + 2, 4 * a + 3, 4 * b + 0, 4 * b + 1, 4 * b + 2, 4 * b + 3, \ + 4 * c + 0, 4 * c + 1, 4 * c + 2, 4 * c + 3, 4 * d + 0, 4 * d + 1, 4 * d + 2, 4 * d + 3 \ + } +#define stbir_make16x2(a, b) \ + (uint8x16x2_t) { \ + { vreinterpretq_u8_f32(a), vreinterpretq_u8_f32(b) } \ + } +#endif + +#define stbir__simdf_swiz(reg, one, two, three, four) \ + vreinterpretq_f32_u8(vqtbl1q_u8(vreinterpretq_u8_f32(reg), stbir_make16(one, two, three, four))) +#define stbir__simdf_swiz2(rega, regb, one, two, three, four) \ + vreinterpretq_f32_u8( \ + vqtbl2q_u8(stbir_make16x2(rega, regb), stbir_make16(one, two, three, four))) + +#define stbir__simdi_16madd(out, reg0, reg1) \ + { \ + int16x8_t r0 = vreinterpretq_s16_u32(reg0); \ + int16x8_t r1 = vreinterpretq_s16_u32(reg1); \ + int32x4_t tmp0 = vmull_s16(vget_low_s16(r0), vget_low_s16(r1)); \ + int32x4_t tmp1 = vmull_s16(vget_high_s16(r0), vget_high_s16(r1)); \ + (out) = vreinterpretq_u32_s32(vpaddq_s32(tmp0, tmp1)); \ + } + +#else + +#define stbir__simdf_aaa1(out, alp, ones) \ + (out) = vsetq_lane_f32(1.0f, vdupq_n_f32(vgetq_lane_f32(alp, 3)), 3) +#define stbir__simdf_1aaa(out, alp, ones) \ + (out) = vsetq_lane_f32(1.0f, vdupq_n_f32(vgetq_lane_f32(alp, 0)), 0) + +#if defined(_MSC_VER) && !defined(__clang__) +static stbir__inline uint8x8x2_t stbir_make8x2(float32x4_t reg) { + uint8x8x2_t r = { + {vget_low_u8(vreinterpretq_u8_f32(reg)), vget_high_u8(vreinterpretq_u8_f32(reg))} + }; + return r; +} +#define stbir_make8(a, b) \ + vcreate_u8((4 * a + 0) | ((4 * a + 1) << 8) | ((4 * a + 2) << 16) | ((4 * a + 3) << 24) | \ + ((stbir_uint64)(4 * b + 0) << 32) | ((stbir_uint64)(4 * b + 1) << 40) | \ + ((stbir_uint64)(4 * b + 2) << 48) | ((stbir_uint64)(4 * b + 3) << 56)) +#else +#define stbir_make8x2(reg) \ + (uint8x8x2_t) { \ + { vget_low_u8(vreinterpretq_u8_f32(reg)), vget_high_u8(vreinterpretq_u8_f32(reg)) } \ + } +#define stbir_make8(a, b) \ + (uint8x8_t) { \ + 4 * a + 0, 4 * a + 1, 4 * a + 2, 4 * a + 3, 4 * b + 0, 4 * b + 1, 4 * b + 2, 4 * b + 3 \ + } +#endif + +#define stbir__simdf_swiz(reg, one, two, three, four) \ + vreinterpretq_f32_u8(vcombine_u8(vtbl2_u8(stbir_make8x2(reg), stbir_make8(one, two)), \ + vtbl2_u8(stbir_make8x2(reg), stbir_make8(three, four)))) + +#define stbir__simdi_16madd(out, reg0, reg1) \ + { \ + int16x8_t r0 = vreinterpretq_s16_u32(reg0); \ + int16x8_t r1 = vreinterpretq_s16_u32(reg1); \ + int32x4_t tmp0 = vmull_s16(vget_low_s16(r0), vget_low_s16(r1)); \ + int32x4_t tmp1 = vmull_s16(vget_high_s16(r0), vget_high_s16(r1)); \ + int32x2_t out0 = vpadd_s32(vget_low_s32(tmp0), vget_high_s32(tmp0)); \ + int32x2_t out1 = vpadd_s32(vget_low_s32(tmp1), vget_high_s32(tmp1)); \ + (out) = vreinterpretq_u32_s32(vcombine_s32(out0, out1)); \ + } + +#endif + +#define stbir__simdi_and(out, reg0, reg1) (out) = vandq_u32(reg0, reg1) +#define stbir__simdi_or(out, reg0, reg1) (out) = vorrq_u32(reg0, reg1) + +#define stbir__simdf_pack_to_8bytes(out, aa, bb) \ + { \ + float32x4_t af = \ + vmaxq_f32(vminq_f32(aa, STBIR__CONSTF(STBIR_max_uint8_as_float)), vdupq_n_f32(0)); \ + float32x4_t bf = \ + vmaxq_f32(vminq_f32(bb, STBIR__CONSTF(STBIR_max_uint8_as_float)), vdupq_n_f32(0)); \ + int16x4_t ai = vqmovn_s32(vcvtq_s32_f32(af)); \ + int16x4_t bi = vqmovn_s32(vcvtq_s32_f32(bf)); \ + uint8x8_t out8 = vqmovun_s16(vcombine_s16(ai, bi)); \ + out = vreinterpretq_u32_u8(vcombine_u8(out8, out8)); \ + } + +#define stbir__simdf_pack_to_8words(out, aa, bb) \ + { \ + float32x4_t af = \ + vmaxq_f32(vminq_f32(aa, STBIR__CONSTF(STBIR_max_uint16_as_float)), vdupq_n_f32(0)); \ + float32x4_t bf = \ + vmaxq_f32(vminq_f32(bb, STBIR__CONSTF(STBIR_max_uint16_as_float)), vdupq_n_f32(0)); \ + int32x4_t ai = vcvtq_s32_f32(af); \ + int32x4_t bi = vcvtq_s32_f32(bf); \ + out = vreinterpretq_u32_u16(vcombine_u16(vqmovun_s32(ai), vqmovun_s32(bi))); \ + } + +#define stbir__interleave_pack_and_store_16_u8(ptr, r0, r1, r2, r3) \ + { \ + int16x4x2_t tmp0 = vzip_s16(vqmovn_s32(vreinterpretq_s32_u32(r0)), \ + vqmovn_s32(vreinterpretq_s32_u32(r2))); \ + int16x4x2_t tmp1 = vzip_s16(vqmovn_s32(vreinterpretq_s32_u32(r1)), \ + vqmovn_s32(vreinterpretq_s32_u32(r3))); \ + uint8x8x2_t out = { \ + { \ + vqmovun_s16(vcombine_s16(tmp0.val[0], tmp0.val[1])), \ + vqmovun_s16(vcombine_s16(tmp1.val[0], tmp1.val[1])), \ + } + }; \ + vst2_u8(ptr, out); \ + } + +#define stbir__simdf_load4_transposed(o0, o1, o2, o3, ptr) \ + { \ + float32x4x4_t tmp = vld4q_f32(ptr); \ + o0 = tmp.val[0]; \ + o1 = tmp.val[1]; \ + o2 = tmp.val[2]; \ + o3 = tmp.val[3]; \ + } + +#define stbir__simdi_32shr(out, reg, imm) out = vshrq_n_u32(reg, imm) + +#if defined(_MSC_VER) && !defined(__clang__) +#define STBIR__SIMDF_CONST(var, x) __declspec(align(8)) float var[] = {x, x, x, x} +#define STBIR__SIMDI_CONST(var, x) __declspec(align(8)) uint32_t var[] = {x, x, x, x} +#define STBIR__CONSTF(var) (*(const float32x4_t *)var) +#define STBIR__CONSTI(var) (*(const uint32x4_t *)var) +#else +#define STBIR__SIMDF_CONST(var, x) stbir__simdf var = {x, x, x, x} +#define STBIR__SIMDI_CONST(var, x) stbir__simdi var = {x, x, x, x} +#define STBIR__CONSTF(var) (var) +#define STBIR__CONSTI(var) (var) +#endif + +#ifdef STBIR_FLOORF +#undef STBIR_FLOORF +#endif +#define STBIR_FLOORF stbir_simd_floorf +static stbir__inline float stbir_simd_floorf(float x) { +#if defined(_M_ARM64) || defined(__aarch64__) || defined(__arm64__) + return vget_lane_f32(vrndm_f32(vdup_n_f32(x)), 0); +#else + float32x2_t f = vdup_n_f32(x); + float32x2_t t = vcvt_f32_s32(vcvt_s32_f32(f)); + uint32x2_t a = vclt_f32(f, t); + uint32x2_t b = vreinterpret_u32_f32(vdup_n_f32(-1.0f)); + float32x2_t r = vadd_f32(t, vreinterpret_f32_u32(vand_u32(a, b))); + return vget_lane_f32(r, 0); +#endif +} + +#ifdef STBIR_CEILF +#undef STBIR_CEILF +#endif +#define STBIR_CEILF stbir_simd_ceilf +static stbir__inline float stbir_simd_ceilf(float x) { +#if defined(_M_ARM64) || defined(__aarch64__) || defined(__arm64__) + return vget_lane_f32(vrndp_f32(vdup_n_f32(x)), 0); +#else + float32x2_t f = vdup_n_f32(x); + float32x2_t t = vcvt_f32_s32(vcvt_s32_f32(f)); + uint32x2_t a = vclt_f32(t, f); + uint32x2_t b = vreinterpret_u32_f32(vdup_n_f32(1.0f)); + float32x2_t r = vadd_f32(t, vreinterpret_f32_u32(vand_u32(a, b))); + return vget_lane_f32(r, 0); +#endif +} + +#define STBIR_SIMD + +#elif defined(STBIR_WASM) + +#include + +#define stbir__simdf v128_t +#define stbir__simdi v128_t + +#define stbir_simdi_castf(reg) (reg) +#define stbir_simdf_casti(reg) (reg) + +#define stbir__simdf_load(reg, ptr) (reg) = wasm_v128_load((void const *)(ptr)) +#define stbir__simdi_load(reg, ptr) (reg) = wasm_v128_load((void const *)(ptr)) +#define stbir__simdf_load1(out, ptr) \ + (out) = wasm_v128_load32_splat( \ + (void const *)(ptr)) // top values can be random (not denormal or nan for perf) +#define stbir__simdi_load1(out, ptr) (out) = wasm_v128_load32_splat((void const *)(ptr)) +#define stbir__simdf_load1z(out, ptr) \ + (out) = wasm_v128_load32_zero((void const *)(ptr)) // top values must be zero +#define stbir__simdf_frep4(fvar) wasm_f32x4_splat(fvar) +#define stbir__simdf_load1frep4(out, fvar) (out) = wasm_f32x4_splat(fvar) +#define stbir__simdf_load2(out, ptr) \ + (out) = wasm_v128_load64_splat( \ + (void const *)(ptr)) // top values can be random (not denormal or nan for perf) +#define stbir__simdf_load2z(out, ptr) \ + (out) = wasm_v128_load64_zero((void const *)(ptr)) // top values must be zero +#define stbir__simdf_load2hmerge(out, reg, ptr) \ + (out) = wasm_v128_load64_lane((void const *)(ptr), reg, 1) + +#define stbir__simdf_zeroP() wasm_f32x4_const_splat(0) +#define stbir__simdf_zero(reg) (reg) = wasm_f32x4_const_splat(0) + +#define stbir__simdf_store(ptr, reg) wasm_v128_store((void *)(ptr), reg) +#define stbir__simdf_store1(ptr, reg) wasm_v128_store32_lane((void *)(ptr), reg, 0) +#define stbir__simdf_store2(ptr, reg) wasm_v128_store64_lane((void *)(ptr), reg, 0) +#define stbir__simdf_store2h(ptr, reg) wasm_v128_store64_lane((void *)(ptr), reg, 1) + +#define stbir__simdi_store(ptr, reg) wasm_v128_store((void *)(ptr), reg) +#define stbir__simdi_store1(ptr, reg) wasm_v128_store32_lane((void *)(ptr), reg, 0) +#define stbir__simdi_store2(ptr, reg) wasm_v128_store64_lane((void *)(ptr), reg, 0) + +#define stbir__prefetch(ptr) + +#define stbir__simdi_expand_u8_to_u32(out0, out1, out2, out3, ireg) \ + { \ + v128_t l = wasm_u16x8_extend_low_u8x16(ireg); \ + v128_t h = wasm_u16x8_extend_high_u8x16(ireg); \ + out0 = wasm_u32x4_extend_low_u16x8(l); \ + out1 = wasm_u32x4_extend_high_u16x8(l); \ + out2 = wasm_u32x4_extend_low_u16x8(h); \ + out3 = wasm_u32x4_extend_high_u16x8(h); \ + } + +#define stbir__simdi_expand_u8_to_1u32(out, ireg) \ + { \ + v128_t tmp = wasm_u16x8_extend_low_u8x16(ireg); \ + out = wasm_u32x4_extend_low_u16x8(tmp); \ + } + +#define stbir__simdi_expand_u16_to_u32(out0, out1, ireg) \ + { \ + out0 = wasm_u32x4_extend_low_u16x8(ireg); \ + out1 = wasm_u32x4_extend_high_u16x8(ireg); \ + } + +#define stbir__simdf_convert_float_to_i32(i, f) (i) = wasm_i32x4_trunc_sat_f32x4(f) +#define stbir__simdf_convert_float_to_int(f) \ + wasm_i32x4_extract_lane(wasm_i32x4_trunc_sat_f32x4(f), 0) +#define stbir__simdi_to_int(i) wasm_i32x4_extract_lane(i, 0) +#define stbir__simdf_convert_float_to_uint8(f) \ + ((unsigned char)wasm_i32x4_extract_lane( \ + wasm_i32x4_trunc_sat_f32x4(wasm_f32x4_max(wasm_f32x4_min(f, STBIR_max_uint8_as_float), \ + wasm_f32x4_const_splat(0))), \ + 0)) +#define stbir__simdf_convert_float_to_short(f) \ + ((unsigned short)wasm_i32x4_extract_lane( \ + wasm_i32x4_trunc_sat_f32x4(wasm_f32x4_max(wasm_f32x4_min(f, STBIR_max_uint16_as_float), \ + wasm_f32x4_const_splat(0))), \ + 0)) +#define stbir__simdi_convert_i32_to_float(out, ireg) (out) = wasm_f32x4_convert_i32x4(ireg) +#define stbir__simdf_add(out, reg0, reg1) (out) = wasm_f32x4_add(reg0, reg1) +#define stbir__simdf_mult(out, reg0, reg1) (out) = wasm_f32x4_mul(reg0, reg1) +#define stbir__simdf_mult_mem(out, reg, ptr) \ + (out) = wasm_f32x4_mul(reg, wasm_v128_load((void const *)(ptr))) +#define stbir__simdf_mult1_mem(out, reg, ptr) \ + (out) = wasm_f32x4_mul(reg, wasm_v128_load32_splat((void const *)(ptr))) +#define stbir__simdf_add_mem(out, reg, ptr) \ + (out) = wasm_f32x4_add(reg, wasm_v128_load((void const *)(ptr))) +#define stbir__simdf_add1_mem(out, reg, ptr) \ + (out) = wasm_f32x4_add(reg, wasm_v128_load32_splat((void const *)(ptr))) + +#define stbir__simdf_madd(out, add, mul1, mul2) \ + (out) = wasm_f32x4_add(add, wasm_f32x4_mul(mul1, mul2)) +#define stbir__simdf_madd1(out, add, mul1, mul2) \ + (out) = wasm_f32x4_add(add, wasm_f32x4_mul(mul1, mul2)) +#define stbir__simdf_madd_mem(out, add, mul, ptr) \ + (out) = wasm_f32x4_add(add, wasm_f32x4_mul(mul, wasm_v128_load((void const *)(ptr)))) +#define stbir__simdf_madd1_mem(out, add, mul, ptr) \ + (out) = wasm_f32x4_add(add, wasm_f32x4_mul(mul, wasm_v128_load32_splat((void const *)(ptr)))) + +#define stbir__simdf_add1(out, reg0, reg1) (out) = wasm_f32x4_add(reg0, reg1) +#define stbir__simdf_mult1(out, reg0, reg1) (out) = wasm_f32x4_mul(reg0, reg1) + +#define stbir__simdf_and(out, reg0, reg1) (out) = wasm_v128_and(reg0, reg1) +#define stbir__simdf_or(out, reg0, reg1) (out) = wasm_v128_or(reg0, reg1) + +#define stbir__simdf_min(out, reg0, reg1) (out) = wasm_f32x4_min(reg0, reg1) +#define stbir__simdf_max(out, reg0, reg1) (out) = wasm_f32x4_max(reg0, reg1) +#define stbir__simdf_min1(out, reg0, reg1) (out) = wasm_f32x4_min(reg0, reg1) +#define stbir__simdf_max1(out, reg0, reg1) (out) = wasm_f32x4_max(reg0, reg1) + +#define stbir__simdf_0123ABCDto3ABx(out, reg0, reg1) \ + (out) = wasm_i32x4_shuffle(reg0, reg1, 3, 4, 5, -1) +#define stbir__simdf_0123ABCDto23Ax(out, reg0, reg1) \ + (out) = wasm_i32x4_shuffle(reg0, reg1, 2, 3, 4, -1) + +#define stbir__simdf_aaa1(out, alp, ones) (out) = wasm_i32x4_shuffle(alp, ones, 3, 3, 3, 4) +#define stbir__simdf_1aaa(out, alp, ones) (out) = wasm_i32x4_shuffle(alp, ones, 4, 0, 0, 0) +#define stbir__simdf_a1a1(out, alp, ones) (out) = wasm_i32x4_shuffle(alp, ones, 1, 4, 3, 4) +#define stbir__simdf_1a1a(out, alp, ones) (out) = wasm_i32x4_shuffle(alp, ones, 4, 0, 4, 2) + +#define stbir__simdf_swiz(reg, one, two, three, four) \ + wasm_i32x4_shuffle(reg, reg, one, two, three, four) + +#define stbir__simdi_and(out, reg0, reg1) (out) = wasm_v128_and(reg0, reg1) +#define stbir__simdi_or(out, reg0, reg1) (out) = wasm_v128_or(reg0, reg1) +#define stbir__simdi_16madd(out, reg0, reg1) (out) = wasm_i32x4_dot_i16x8(reg0, reg1) + +#define stbir__simdf_pack_to_8bytes(out, aa, bb) \ + { \ + v128_t af = wasm_f32x4_max(wasm_f32x4_min(aa, STBIR_max_uint8_as_float), \ + wasm_f32x4_const_splat(0)); \ + v128_t bf = wasm_f32x4_max(wasm_f32x4_min(bb, STBIR_max_uint8_as_float), \ + wasm_f32x4_const_splat(0)); \ + v128_t ai = wasm_i32x4_trunc_sat_f32x4(af); \ + v128_t bi = wasm_i32x4_trunc_sat_f32x4(bf); \ + v128_t out16 = wasm_i16x8_narrow_i32x4(ai, bi); \ + out = wasm_u8x16_narrow_i16x8(out16, out16); \ + } + +#define stbir__simdf_pack_to_8words(out, aa, bb) \ + { \ + v128_t af = wasm_f32x4_max(wasm_f32x4_min(aa, STBIR_max_uint16_as_float), \ + wasm_f32x4_const_splat(0)); \ + v128_t bf = wasm_f32x4_max(wasm_f32x4_min(bb, STBIR_max_uint16_as_float), \ + wasm_f32x4_const_splat(0)); \ + v128_t ai = wasm_i32x4_trunc_sat_f32x4(af); \ + v128_t bi = wasm_i32x4_trunc_sat_f32x4(bf); \ + out = wasm_u16x8_narrow_i32x4(ai, bi); \ + } + +#define stbir__interleave_pack_and_store_16_u8(ptr, r0, r1, r2, r3) \ + { \ + v128_t tmp0 = wasm_i16x8_narrow_i32x4(r0, r1); \ + v128_t tmp1 = wasm_i16x8_narrow_i32x4(r2, r3); \ + v128_t tmp = wasm_u8x16_narrow_i16x8(tmp0, tmp1); \ + tmp = wasm_i8x16_shuffle(tmp, tmp, 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15); \ + wasm_v128_store((void *)(ptr), tmp); \ + } + +#define stbir__simdf_load4_transposed(o0, o1, o2, o3, ptr) \ + { \ + v128_t t0 = wasm_v128_load(ptr); \ + v128_t t1 = wasm_v128_load(ptr + 4); \ + v128_t t2 = wasm_v128_load(ptr + 8); \ + v128_t t3 = wasm_v128_load(ptr + 12); \ + v128_t s0 = wasm_i32x4_shuffle(t0, t1, 0, 4, 2, 6); \ + v128_t s1 = wasm_i32x4_shuffle(t0, t1, 1, 5, 3, 7); \ + v128_t s2 = wasm_i32x4_shuffle(t2, t3, 0, 4, 2, 6); \ + v128_t s3 = wasm_i32x4_shuffle(t2, t3, 1, 5, 3, 7); \ + o0 = wasm_i32x4_shuffle(s0, s2, 0, 1, 4, 5); \ + o1 = wasm_i32x4_shuffle(s1, s3, 0, 1, 4, 5); \ + o2 = wasm_i32x4_shuffle(s0, s2, 2, 3, 6, 7); \ + o3 = wasm_i32x4_shuffle(s1, s3, 2, 3, 6, 7); \ + } + +#define stbir__simdi_32shr(out, reg, imm) out = wasm_u32x4_shr(reg, imm) + +typedef float stbir__f32x4 __attribute__((__vector_size__(16), __aligned__(16))); +#define STBIR__SIMDF_CONST(var, x) \ + stbir__simdf var = (v128_t)(stbir__f32x4) { x, x, x, x } +#define STBIR__SIMDI_CONST(var, x) stbir__simdi var = {x, x, x, x} +#define STBIR__CONSTF(var) (var) +#define STBIR__CONSTI(var) (var) + +#ifdef STBIR_FLOORF +#undef STBIR_FLOORF +#endif +#define STBIR_FLOORF stbir_simd_floorf +static stbir__inline float stbir_simd_floorf(float x) { + return wasm_f32x4_extract_lane(wasm_f32x4_floor(wasm_f32x4_splat(x)), 0); +} + +#ifdef STBIR_CEILF +#undef STBIR_CEILF +#endif +#define STBIR_CEILF stbir_simd_ceilf +static stbir__inline float stbir_simd_ceilf(float x) { + return wasm_f32x4_extract_lane(wasm_f32x4_ceil(wasm_f32x4_splat(x)), 0); +} + +#define STBIR_SIMD + +#endif // SSE2/NEON/WASM + +#endif // NO SIMD + +#ifdef STBIR_SIMD8 +#define stbir__simdfX stbir__simdf8 +#define stbir__simdiX stbir__simdi8 +#define stbir__simdfX_load stbir__simdf8_load +#define stbir__simdiX_load stbir__simdi8_load +#define stbir__simdfX_mult stbir__simdf8_mult +#define stbir__simdfX_add_mem stbir__simdf8_add_mem +#define stbir__simdfX_madd_mem stbir__simdf8_madd_mem +#define stbir__simdfX_store stbir__simdf8_store +#define stbir__simdiX_store stbir__simdi8_store +#define stbir__simdf_frepX stbir__simdf8_frep8 +#define stbir__simdfX_madd stbir__simdf8_madd +#define stbir__simdfX_min stbir__simdf8_min +#define stbir__simdfX_max stbir__simdf8_max +#define stbir__simdfX_aaa1 stbir__simdf8_aaa1 +#define stbir__simdfX_1aaa stbir__simdf8_1aaa +#define stbir__simdfX_a1a1 stbir__simdf8_a1a1 +#define stbir__simdfX_1a1a stbir__simdf8_1a1a +#define stbir__simdfX_convert_float_to_i32 stbir__simdf8_convert_float_to_i32 +#define stbir__simdfX_pack_to_words stbir__simdf8_pack_to_16words +#define stbir__simdfX_zero stbir__simdf8_zero +#define STBIR_onesX STBIR_ones8 +#define STBIR_max_uint8_as_floatX STBIR_max_uint8_as_float8 +#define STBIR_max_uint16_as_floatX STBIR_max_uint16_as_float8 +#define STBIR_simd_point5X STBIR_simd_point58 +#define stbir__simdfX_float_count 8 +#define stbir__simdfX_0123to1230 stbir__simdf8_0123to12301230 +#define stbir__simdfX_0123to2103 stbir__simdf8_0123to21032103 +static const stbir__simdf8 STBIR_max_uint16_as_float_inverted8 = { + stbir__max_uint16_as_float_inverted, stbir__max_uint16_as_float_inverted, + stbir__max_uint16_as_float_inverted, stbir__max_uint16_as_float_inverted, + stbir__max_uint16_as_float_inverted, stbir__max_uint16_as_float_inverted, + stbir__max_uint16_as_float_inverted, stbir__max_uint16_as_float_inverted}; +static const stbir__simdf8 STBIR_max_uint8_as_float_inverted8 = { + stbir__max_uint8_as_float_inverted, stbir__max_uint8_as_float_inverted, + stbir__max_uint8_as_float_inverted, stbir__max_uint8_as_float_inverted, + stbir__max_uint8_as_float_inverted, stbir__max_uint8_as_float_inverted, + stbir__max_uint8_as_float_inverted, stbir__max_uint8_as_float_inverted}; +static const stbir__simdf8 STBIR_ones8 = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}; +static const stbir__simdf8 STBIR_simd_point58 = {0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5}; +static const stbir__simdf8 STBIR_max_uint8_as_float8 = { + stbir__max_uint8_as_float, stbir__max_uint8_as_float, stbir__max_uint8_as_float, + stbir__max_uint8_as_float, stbir__max_uint8_as_float, stbir__max_uint8_as_float, + stbir__max_uint8_as_float, stbir__max_uint8_as_float}; +static const stbir__simdf8 STBIR_max_uint16_as_float8 = { + stbir__max_uint16_as_float, stbir__max_uint16_as_float, stbir__max_uint16_as_float, + stbir__max_uint16_as_float, stbir__max_uint16_as_float, stbir__max_uint16_as_float, + stbir__max_uint16_as_float, stbir__max_uint16_as_float}; +#else +#define stbir__simdfX stbir__simdf +#define stbir__simdiX stbir__simdi +#define stbir__simdfX_load stbir__simdf_load +#define stbir__simdiX_load stbir__simdi_load +#define stbir__simdfX_mult stbir__simdf_mult +#define stbir__simdfX_add_mem stbir__simdf_add_mem +#define stbir__simdfX_madd_mem stbir__simdf_madd_mem +#define stbir__simdfX_store stbir__simdf_store +#define stbir__simdiX_store stbir__simdi_store +#define stbir__simdf_frepX stbir__simdf_frep4 +#define stbir__simdfX_madd stbir__simdf_madd +#define stbir__simdfX_min stbir__simdf_min +#define stbir__simdfX_max stbir__simdf_max +#define stbir__simdfX_aaa1 stbir__simdf_aaa1 +#define stbir__simdfX_1aaa stbir__simdf_1aaa +#define stbir__simdfX_a1a1 stbir__simdf_a1a1 +#define stbir__simdfX_1a1a stbir__simdf_1a1a +#define stbir__simdfX_convert_float_to_i32 stbir__simdf_convert_float_to_i32 +#define stbir__simdfX_pack_to_words stbir__simdf_pack_to_8words +#define stbir__simdfX_zero stbir__simdf_zero +#define STBIR_onesX STBIR__CONSTF(STBIR_ones) +#define STBIR_simd_point5X STBIR__CONSTF(STBIR_simd_point5) +#define STBIR_max_uint8_as_floatX STBIR__CONSTF(STBIR_max_uint8_as_float) +#define STBIR_max_uint16_as_floatX STBIR__CONSTF(STBIR_max_uint16_as_float) +#define stbir__simdfX_float_count 4 +#define stbir__if_simdf8_cast_to_simdf4(val) (val) +#define stbir__simdfX_0123to1230 stbir__simdf_0123to1230 +#define stbir__simdfX_0123to2103 stbir__simdf_0123to2103 +#endif + +#if defined(STBIR_NEON) && !defined(_M_ARM) && !defined(__arm__) + +#if defined(_MSC_VER) && !defined(__clang__) +typedef __int16 stbir__FP16; +#else +typedef float16_t stbir__FP16; +#endif + +#else // no NEON, or 32-bit ARM for MSVC + +typedef union stbir__FP16 { + unsigned short u; +} stbir__FP16; + +#endif + +#if (!defined(STBIR_NEON) && !defined(STBIR_FP16C)) || (defined(STBIR_NEON) && defined(_M_ARM)) || \ + (defined(STBIR_NEON) && defined(__arm__)) + +// Fabian's half float routines, see: https://gist.github.com/rygorous/2156668 + +static stbir__inline float stbir__half_to_float(stbir__FP16 h) { + static const stbir__FP32 magic = {(254 - 15) << 23}; + static const stbir__FP32 was_infnan = {(127 + 16) << 23}; + stbir__FP32 o; + + o.u = (h.u & 0x7fff) << 13; // exponent/mantissa bits + o.f *= magic.f; // exponent adjust + if (o.f >= was_infnan.f) // make sure Inf/NaN survive + o.u |= 255 << 23; + o.u |= (h.u & 0x8000) << 16; // sign bit + return o.f; +} + +static stbir__inline stbir__FP16 stbir__float_to_half(float val) { + stbir__FP32 f32infty = {255 << 23}; + stbir__FP32 f16max = {(127 + 16) << 23}; + stbir__FP32 denorm_magic = {((127 - 15) + (23 - 10) + 1) << 23}; + unsigned int sign_mask = 0x80000000u; + stbir__FP16 o = {0}; + stbir__FP32 f; + unsigned int sign; + + f.f = val; + sign = f.u & sign_mask; + f.u ^= sign; + + if (f.u >= f16max.u) // result is Inf or NaN (all exponent bits set) + o.u = (f.u > f32infty.u) ? 0x7e00 : 0x7c00; // NaN->qNaN and Inf->Inf + else // (De)normalized number or zero + { + if (f.u < (113 << 23)) // resulting FP16 is subnormal or zero + { + // use a magic value to align our 10 mantissa bits at the bottom of + // the float. as long as FP addition is round-to-nearest-even this + // just works. + f.f += denorm_magic.f; + // and one integer subtract of the bias later, we have our final float! + o.u = (unsigned short)(f.u - denorm_magic.u); + } else { + unsigned int mant_odd = (f.u >> 13) & 1; // resulting mantissa is odd + // update exponent, rounding bias part 1 + f.u = f.u + ((15u - 127) << 23) + 0xfff; + // rounding bias part 2 + f.u += mant_odd; + // take the bits! + o.u = (unsigned short)(f.u >> 13); + } + } + + o.u |= sign >> 16; + return o; +} + +#endif + +#if defined(STBIR_FP16C) + +#include + +static stbir__inline void stbir__half_to_float_SIMD(float *output, stbir__FP16 const *input) { + _mm256_storeu_ps((float *)output, _mm256_cvtph_ps(_mm_loadu_si128((__m128i const *)input))); +} + +static stbir__inline void stbir__float_to_half_SIMD(stbir__FP16 *output, float const *input) { + _mm_storeu_si128((__m128i *)output, _mm256_cvtps_ph(_mm256_loadu_ps(input), 0)); +} + +static stbir__inline float stbir__half_to_float(stbir__FP16 h) { + return _mm_cvtss_f32(_mm_cvtph_ps(_mm_cvtsi32_si128((int)h.u))); +} + +static stbir__inline stbir__FP16 stbir__float_to_half(float f) { + stbir__FP16 h; + h.u = (unsigned short)_mm_cvtsi128_si32(_mm_cvtps_ph(_mm_set_ss(f), 0)); + return h; +} + +#elif defined(STBIR_SSE2) + +// Fabian's half float routines, see: https://gist.github.com/rygorous/2156668 +stbir__inline static void stbir__half_to_float_SIMD(float *output, void const *input) { + static const STBIR__SIMDI_CONST(mask_nosign, 0x7fff); + static const STBIR__SIMDI_CONST(smallest_normal, 0x0400); + static const STBIR__SIMDI_CONST(infinity, 0x7c00); + static const STBIR__SIMDI_CONST(expadjust_normal, (127 - 15) << 23); + static const STBIR__SIMDI_CONST(magic_denorm, 113 << 23); + + __m128i i = _mm_loadu_si128((__m128i const *)(input)); + __m128i h = _mm_unpacklo_epi16(i, _mm_setzero_si128()); + __m128i mnosign = STBIR__CONSTI(mask_nosign); + __m128i eadjust = STBIR__CONSTI(expadjust_normal); + __m128i smallest = STBIR__CONSTI(smallest_normal); + __m128i infty = STBIR__CONSTI(infinity); + __m128i expmant = _mm_and_si128(mnosign, h); + __m128i justsign = _mm_xor_si128(h, expmant); + __m128i b_notinfnan = _mm_cmpgt_epi32(infty, expmant); + __m128i b_isdenorm = _mm_cmpgt_epi32(smallest, expmant); + __m128i shifted = _mm_slli_epi32(expmant, 13); + __m128i adj_infnan = _mm_andnot_si128(b_notinfnan, eadjust); + __m128i adjusted = _mm_add_epi32(eadjust, shifted); + __m128i den1 = _mm_add_epi32(shifted, STBIR__CONSTI(magic_denorm)); + __m128i adjusted2 = _mm_add_epi32(adjusted, adj_infnan); + __m128 den2 = _mm_sub_ps(_mm_castsi128_ps(den1), *(const __m128 *)&magic_denorm); + __m128 adjusted3 = _mm_and_ps(den2, _mm_castsi128_ps(b_isdenorm)); + __m128 adjusted4 = _mm_andnot_ps(_mm_castsi128_ps(b_isdenorm), _mm_castsi128_ps(adjusted2)); + __m128 adjusted5 = _mm_or_ps(adjusted3, adjusted4); + __m128i sign = _mm_slli_epi32(justsign, 16); + __m128 final = _mm_or_ps(adjusted5, _mm_castsi128_ps(sign)); + stbir__simdf_store(output + 0, final); + + h = _mm_unpackhi_epi16(i, _mm_setzero_si128()); + expmant = _mm_and_si128(mnosign, h); + justsign = _mm_xor_si128(h, expmant); + b_notinfnan = _mm_cmpgt_epi32(infty, expmant); + b_isdenorm = _mm_cmpgt_epi32(smallest, expmant); + shifted = _mm_slli_epi32(expmant, 13); + adj_infnan = _mm_andnot_si128(b_notinfnan, eadjust); + adjusted = _mm_add_epi32(eadjust, shifted); + den1 = _mm_add_epi32(shifted, STBIR__CONSTI(magic_denorm)); + adjusted2 = _mm_add_epi32(adjusted, adj_infnan); + den2 = _mm_sub_ps(_mm_castsi128_ps(den1), *(const __m128 *)&magic_denorm); + adjusted3 = _mm_and_ps(den2, _mm_castsi128_ps(b_isdenorm)); + adjusted4 = _mm_andnot_ps(_mm_castsi128_ps(b_isdenorm), _mm_castsi128_ps(adjusted2)); + adjusted5 = _mm_or_ps(adjusted3, adjusted4); + sign = _mm_slli_epi32(justsign, 16); + final = _mm_or_ps(adjusted5, _mm_castsi128_ps(sign)); + stbir__simdf_store(output + 4, final); + + // ~38 SSE2 ops for 8 values +} + +// Fabian's round-to-nearest-even float to half +// ~48 SSE2 ops for 8 output +stbir__inline static void stbir__float_to_half_SIMD(void *output, float const *input) { + static const STBIR__SIMDI_CONST(mask_sign, 0x80000000u); + static const STBIR__SIMDI_CONST(c_f16max, (127 + 16) + << 23); // all FP32 values >=this round to +inf + static const STBIR__SIMDI_CONST(c_nanbit, 0x200); + static const STBIR__SIMDI_CONST(c_infty_as_fp16, 0x7c00); + static const STBIR__SIMDI_CONST( + c_min_normal, (127 - 14) << 23); // smallest FP32 that yields a normalized FP16 + static const STBIR__SIMDI_CONST(c_subnorm_magic, ((127 - 15) + (23 - 10) + 1) << 23); + static const STBIR__SIMDI_CONST( + c_normal_bias, 0xfff - ((127 - 15) << 23)); // adjust exponent and add mantissa rounding + + __m128 f = _mm_loadu_ps(input); + __m128 msign = _mm_castsi128_ps(STBIR__CONSTI(mask_sign)); + __m128 justsign = _mm_and_ps(msign, f); + __m128 absf = _mm_xor_ps(f, justsign); + __m128i absf_int = + _mm_castps_si128(absf); // the cast is "free" (extra bypass latency, but no thruput hit) + __m128i f16max = STBIR__CONSTI(c_f16max); + __m128 b_isnan = _mm_cmpunord_ps(absf, absf); // is this a NaN? + __m128i b_isregular = _mm_cmpgt_epi32(f16max, absf_int); // (sub)normalized or special? + __m128i nanbit = _mm_and_si128(_mm_castps_si128(b_isnan), STBIR__CONSTI(c_nanbit)); + __m128i inf_or_nan = + _mm_or_si128(nanbit, STBIR__CONSTI(c_infty_as_fp16)); // output for specials + + __m128i min_normal = STBIR__CONSTI(c_min_normal); + __m128i b_issub = _mm_cmpgt_epi32(min_normal, absf_int); + + // "result is subnormal" path + __m128 subnorm1 = _mm_add_ps( + absf, + _mm_castsi128_ps(STBIR__CONSTI(c_subnorm_magic))); // magic value to round output mantissa + __m128i subnorm2 = _mm_sub_epi32(_mm_castps_si128(subnorm1), + STBIR__CONSTI(c_subnorm_magic)); // subtract out bias + + // "result is normal" path + __m128i mantoddbit = _mm_slli_epi32(absf_int, 31 - 13); // shift bit 13 (mantissa LSB) to sign + __m128i mantodd = _mm_srai_epi32(mantoddbit, 31); // -1 if FP16 mantissa odd, else 0 + + __m128i round1 = _mm_add_epi32(absf_int, STBIR__CONSTI(c_normal_bias)); + __m128i round2 = + _mm_sub_epi32(round1, mantodd); // if mantissa LSB odd, bias towards rounding up (RTNE) + __m128i normal = _mm_srli_epi32(round2, 13); // rounded result + + // combine the two non-specials + __m128i nonspecial = + _mm_or_si128(_mm_and_si128(subnorm2, b_issub), _mm_andnot_si128(b_issub, normal)); + + // merge in specials as well + __m128i joined = _mm_or_si128(_mm_and_si128(nonspecial, b_isregular), + _mm_andnot_si128(b_isregular, inf_or_nan)); + + __m128i sign_shift = _mm_srai_epi32(_mm_castps_si128(justsign), 16); + __m128i final2, final = _mm_or_si128(joined, sign_shift); + + f = _mm_loadu_ps(input + 4); + justsign = _mm_and_ps(msign, f); + absf = _mm_xor_ps(f, justsign); + absf_int = + _mm_castps_si128(absf); // the cast is "free" (extra bypass latency, but no thruput hit) + b_isnan = _mm_cmpunord_ps(absf, absf); // is this a NaN? + b_isregular = _mm_cmpgt_epi32(f16max, absf_int); // (sub)normalized or special? + nanbit = _mm_and_si128(_mm_castps_si128(b_isnan), c_nanbit); + inf_or_nan = _mm_or_si128(nanbit, STBIR__CONSTI(c_infty_as_fp16)); // output for specials + + b_issub = _mm_cmpgt_epi32(min_normal, absf_int); + + // "result is subnormal" path + subnorm1 = _mm_add_ps(absf, _mm_castsi128_ps(STBIR__CONSTI( + c_subnorm_magic))); // magic value to round output mantissa + subnorm2 = _mm_sub_epi32(_mm_castps_si128(subnorm1), + STBIR__CONSTI(c_subnorm_magic)); // subtract out bias + + // "result is normal" path + mantoddbit = _mm_slli_epi32(absf_int, 31 - 13); // shift bit 13 (mantissa LSB) to sign + mantodd = _mm_srai_epi32(mantoddbit, 31); // -1 if FP16 mantissa odd, else 0 + + round1 = _mm_add_epi32(absf_int, STBIR__CONSTI(c_normal_bias)); + round2 = + _mm_sub_epi32(round1, mantodd); // if mantissa LSB odd, bias towards rounding up (RTNE) + normal = _mm_srli_epi32(round2, 13); // rounded result + + // combine the two non-specials + nonspecial = _mm_or_si128(_mm_and_si128(subnorm2, b_issub), _mm_andnot_si128(b_issub, normal)); + + // merge in specials as well + joined = _mm_or_si128(_mm_and_si128(nonspecial, b_isregular), + _mm_andnot_si128(b_isregular, inf_or_nan)); + + sign_shift = _mm_srai_epi32(_mm_castps_si128(justsign), 16); + final2 = _mm_or_si128(joined, sign_shift); + final = _mm_packs_epi32(final, final2); + stbir__simdi_store(output, final); +} + +#elif defined(STBIR_NEON) && defined(_MSC_VER) && defined(_M_ARM64) && \ + !defined(__clang__) // 64-bit ARM on MSVC (not clang) + +static stbir__inline void stbir__half_to_float_SIMD(float *output, stbir__FP16 const *input) { + float16x4_t in0 = vld1_f16(input + 0); + float16x4_t in1 = vld1_f16(input + 4); + vst1q_f32(output + 0, vcvt_f32_f16(in0)); + vst1q_f32(output + 4, vcvt_f32_f16(in1)); +} + +static stbir__inline void stbir__float_to_half_SIMD(stbir__FP16 *output, float const *input) { + float16x4_t out0 = vcvt_f16_f32(vld1q_f32(input + 0)); + float16x4_t out1 = vcvt_f16_f32(vld1q_f32(input + 4)); + vst1_f16(output + 0, out0); + vst1_f16(output + 4, out1); +} + +static stbir__inline float stbir__half_to_float(stbir__FP16 h) { + return vgetq_lane_f32(vcvt_f32_f16(vld1_dup_f16(&h)), 0); +} + +static stbir__inline stbir__FP16 stbir__float_to_half(float f) { + return vget_lane_f16(vcvt_f16_f32(vdupq_n_f32(f)), 0).n16_u16[0]; +} + +#elif defined(STBIR_NEON) && \ + (defined(_M_ARM64) || defined(__aarch64__) || defined(__arm64__)) // 64-bit ARM + +static stbir__inline void stbir__half_to_float_SIMD(float *output, stbir__FP16 const *input) { + float16x8_t in = vld1q_f16(input); + vst1q_f32(output + 0, vcvt_f32_f16(vget_low_f16(in))); + vst1q_f32(output + 4, vcvt_f32_f16(vget_high_f16(in))); +} + +static stbir__inline void stbir__float_to_half_SIMD(stbir__FP16 *output, float const *input) { + float16x4_t out0 = vcvt_f16_f32(vld1q_f32(input + 0)); + float16x4_t out1 = vcvt_f16_f32(vld1q_f32(input + 4)); + vst1q_f16(output, vcombine_f16(out0, out1)); +} + +static stbir__inline float stbir__half_to_float(stbir__FP16 h) { + return vgetq_lane_f32(vcvt_f32_f16(vdup_n_f16(h)), 0); +} + +static stbir__inline stbir__FP16 stbir__float_to_half(float f) { + return vget_lane_f16(vcvt_f16_f32(vdupq_n_f32(f)), 0); +} + +#elif defined(STBIR_WASM) || \ + (defined(STBIR_NEON) && (defined(_MSC_VER) || defined(_M_ARM) || \ + defined(__arm__))) // WASM or 32-bit ARM on MSVC/clang + +static stbir__inline void stbir__half_to_float_SIMD(float *output, stbir__FP16 const *input) { + for (int i = 0; i < 8; i++) { + output[i] = stbir__half_to_float(input[i]); + } +} +static stbir__inline void stbir__float_to_half_SIMD(stbir__FP16 *output, float const *input) { + for (int i = 0; i < 8; i++) { + output[i] = stbir__float_to_half(input[i]); + } +} + +#endif + +#ifdef STBIR_SIMD + +#define stbir__simdf_0123to3333(out, reg) (out) = stbir__simdf_swiz(reg, 3, 3, 3, 3) +#define stbir__simdf_0123to2222(out, reg) (out) = stbir__simdf_swiz(reg, 2, 2, 2, 2) +#define stbir__simdf_0123to1111(out, reg) (out) = stbir__simdf_swiz(reg, 1, 1, 1, 1) +#define stbir__simdf_0123to0000(out, reg) (out) = stbir__simdf_swiz(reg, 0, 0, 0, 0) +#define stbir__simdf_0123to0003(out, reg) (out) = stbir__simdf_swiz(reg, 0, 0, 0, 3) +#define stbir__simdf_0123to0001(out, reg) (out) = stbir__simdf_swiz(reg, 0, 0, 0, 1) +#define stbir__simdf_0123to1122(out, reg) (out) = stbir__simdf_swiz(reg, 1, 1, 2, 2) +#define stbir__simdf_0123to2333(out, reg) (out) = stbir__simdf_swiz(reg, 2, 3, 3, 3) +#define stbir__simdf_0123to0023(out, reg) (out) = stbir__simdf_swiz(reg, 0, 0, 2, 3) +#define stbir__simdf_0123to1230(out, reg) (out) = stbir__simdf_swiz(reg, 1, 2, 3, 0) +#define stbir__simdf_0123to2103(out, reg) (out) = stbir__simdf_swiz(reg, 2, 1, 0, 3) +#define stbir__simdf_0123to3210(out, reg) (out) = stbir__simdf_swiz(reg, 3, 2, 1, 0) +#define stbir__simdf_0123to2301(out, reg) (out) = stbir__simdf_swiz(reg, 2, 3, 0, 1) +#define stbir__simdf_0123to3012(out, reg) (out) = stbir__simdf_swiz(reg, 3, 0, 1, 2) +#define stbir__simdf_0123to0011(out, reg) (out) = stbir__simdf_swiz(reg, 0, 0, 1, 1) +#define stbir__simdf_0123to1100(out, reg) (out) = stbir__simdf_swiz(reg, 1, 1, 0, 0) +#define stbir__simdf_0123to2233(out, reg) (out) = stbir__simdf_swiz(reg, 2, 2, 3, 3) +#define stbir__simdf_0123to1133(out, reg) (out) = stbir__simdf_swiz(reg, 1, 1, 3, 3) +#define stbir__simdf_0123to0022(out, reg) (out) = stbir__simdf_swiz(reg, 0, 0, 2, 2) +#define stbir__simdf_0123to1032(out, reg) (out) = stbir__simdf_swiz(reg, 1, 0, 3, 2) + +typedef union stbir__simdi_u32 { + stbir_uint32 m128i_u32[4]; + int m128i_i32[4]; + stbir__simdi m128i_i128; +} stbir__simdi_u32; + +static const int STBIR_mask[9] = {0, 0, 0, -1, -1, -1, 0, 0, 0}; + +static const STBIR__SIMDF_CONST(STBIR_max_uint8_as_float, stbir__max_uint8_as_float); +static const STBIR__SIMDF_CONST(STBIR_max_uint16_as_float, stbir__max_uint16_as_float); +static const STBIR__SIMDF_CONST(STBIR_max_uint8_as_float_inverted, + stbir__max_uint8_as_float_inverted); +static const STBIR__SIMDF_CONST(STBIR_max_uint16_as_float_inverted, + stbir__max_uint16_as_float_inverted); + +static const STBIR__SIMDF_CONST(STBIR_simd_point5, 0.5f); +static const STBIR__SIMDF_CONST(STBIR_ones, 1.0f); +static const STBIR__SIMDI_CONST(STBIR_almost_zero, (127 - 13) << 23); +static const STBIR__SIMDI_CONST(STBIR_almost_one, 0x3f7fffff); +static const STBIR__SIMDI_CONST(STBIR_mastissa_mask, 0xff); +static const STBIR__SIMDI_CONST(STBIR_topscale, 0x02000000); + +// Basically, in simd mode, we unroll the proper amount, and we don't want +// the non-simd remnant loops to be unroll because they only run a few times +// Adding this switch saves about 5K on clang which is Captain Unroll the 3rd. +#define STBIR_SIMD_STREAMOUT_PTR(star) STBIR_STREAMOUT_PTR(star) +#define STBIR_SIMD_NO_UNROLL(ptr) STBIR_NO_UNROLL(ptr) +#define STBIR_SIMD_NO_UNROLL_LOOP_START STBIR_NO_UNROLL_LOOP_START +#define STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR STBIR_NO_UNROLL_LOOP_START_INF_FOR + +#ifdef STBIR_MEMCPY +#undef STBIR_MEMCPY +#endif +#define STBIR_MEMCPY stbir_simd_memcpy + +// override normal use of memcpy with much simpler copy (faster and smaller with our sized copies) +static void stbir_simd_memcpy(void *dest, void const *src, size_t bytes) { + char STBIR_SIMD_STREAMOUT_PTR(*) d = (char *)dest; + char STBIR_SIMD_STREAMOUT_PTR(*) d_end = ((char *)dest) + bytes; + ptrdiff_t ofs_to_src = (char *)src - (char *)dest; + + // check overlaps + STBIR_ASSERT(((d >= ((char *)src) + bytes)) || ((d + bytes) <= (char *)src)); + + if (bytes < (16 * stbir__simdfX_float_count)) { + if (bytes < 16) { + if (bytes) { + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + STBIR_SIMD_NO_UNROLL(d); + d[0] = d[ofs_to_src]; + ++d; + } while (d < d_end); + } + } else { + stbir__simdf x; + // do one unaligned to get us aligned for the stream out below + stbir__simdf_load(x, (d + ofs_to_src)); + stbir__simdf_store(d, x); + d = (char *)((((size_t)d) + 16) & ~15); + + STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR + for (;;) { + STBIR_SIMD_NO_UNROLL(d); + + if (d > (d_end - 16)) { + if (d == d_end) + return; + d = d_end - 16; + } + + stbir__simdf_load(x, (d + ofs_to_src)); + stbir__simdf_store(d, x); + d += 16; + } + } + } else { + stbir__simdfX x0, x1, x2, x3; + + // do one unaligned to get us aligned for the stream out below + stbir__simdfX_load(x0, (d + ofs_to_src) + 0 * stbir__simdfX_float_count); + stbir__simdfX_load(x1, (d + ofs_to_src) + 4 * stbir__simdfX_float_count); + stbir__simdfX_load(x2, (d + ofs_to_src) + 8 * stbir__simdfX_float_count); + stbir__simdfX_load(x3, (d + ofs_to_src) + 12 * stbir__simdfX_float_count); + stbir__simdfX_store(d + 0 * stbir__simdfX_float_count, x0); + stbir__simdfX_store(d + 4 * stbir__simdfX_float_count, x1); + stbir__simdfX_store(d + 8 * stbir__simdfX_float_count, x2); + stbir__simdfX_store(d + 12 * stbir__simdfX_float_count, x3); + d = (char *)((((size_t)d) + (16 * stbir__simdfX_float_count)) & + ~((16 * stbir__simdfX_float_count) - 1)); + + STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR + for (;;) { + STBIR_SIMD_NO_UNROLL(d); + + if (d > (d_end - (16 * stbir__simdfX_float_count))) { + if (d == d_end) + return; + d = d_end - (16 * stbir__simdfX_float_count); + } + + stbir__simdfX_load(x0, (d + ofs_to_src) + 0 * stbir__simdfX_float_count); + stbir__simdfX_load(x1, (d + ofs_to_src) + 4 * stbir__simdfX_float_count); + stbir__simdfX_load(x2, (d + ofs_to_src) + 8 * stbir__simdfX_float_count); + stbir__simdfX_load(x3, (d + ofs_to_src) + 12 * stbir__simdfX_float_count); + stbir__simdfX_store(d + 0 * stbir__simdfX_float_count, x0); + stbir__simdfX_store(d + 4 * stbir__simdfX_float_count, x1); + stbir__simdfX_store(d + 8 * stbir__simdfX_float_count, x2); + stbir__simdfX_store(d + 12 * stbir__simdfX_float_count, x3); + d += (16 * stbir__simdfX_float_count); + } + } +} + +// memcpy that is specically intentionally overlapping (src is smaller then dest, so can be +// a normal forward copy, bytes is divisible by 4 and bytes is greater than or equal to +// the diff between dest and src) +static void stbir_overlapping_memcpy(void *dest, void const *src, size_t bytes) { + char STBIR_SIMD_STREAMOUT_PTR(*) sd = (char *)src; + char STBIR_SIMD_STREAMOUT_PTR(*) s_end = ((char *)src) + bytes; + ptrdiff_t ofs_to_dest = (char *)dest - (char *)src; + + if (ofs_to_dest >= 16) // is the overlap more than 16 away? + { + char STBIR_SIMD_STREAMOUT_PTR(*) s_end16 = ((char *)src) + (bytes & ~15); + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + stbir__simdf x; + STBIR_SIMD_NO_UNROLL(sd); + stbir__simdf_load(x, sd); + stbir__simdf_store((sd + ofs_to_dest), x); + sd += 16; + } while (sd < s_end16); + + if (sd == s_end) + return; + } + + do { + STBIR_SIMD_NO_UNROLL(sd); + *(int *)(sd + ofs_to_dest) = *(int *)sd; + sd += 4; + } while (sd < s_end); +} + +#else // no SSE2 + +// when in scalar mode, we let unrolling happen, so this macro just does the __restrict +#define STBIR_SIMD_STREAMOUT_PTR(star) STBIR_STREAMOUT_PTR(star) +#define STBIR_SIMD_NO_UNROLL(ptr) +#define STBIR_SIMD_NO_UNROLL_LOOP_START +#define STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR + +#endif // SSE2 + +#ifdef STBIR_PROFILE + +#ifndef STBIR_PROFILE_FUNC + +#if defined(_x86_64) || defined(__x86_64__) || defined(_M_X64) || defined(__x86_64) || \ + defined(__SSE2__) || defined(STBIR_SSE) || defined(_M_IX86_FP) || defined(__i386) || \ + defined(__i386__) || defined(_M_IX86) || defined(_X86_) + +#ifdef _MSC_VER + +STBIRDEF stbir_uint64 __rdtsc(); +#define STBIR_PROFILE_FUNC() __rdtsc() + +#else // non msvc + +static stbir__inline stbir_uint64 STBIR_PROFILE_FUNC() { + stbir_uint32 lo, hi; + asm volatile("rdtsc" : "=a"(lo), "=d"(hi)); + return (((stbir_uint64)hi) << 32) | ((stbir_uint64)lo); +} + +#endif // msvc + +#elif defined(_M_ARM64) || defined(__aarch64__) || defined(__arm64__) || defined(__ARM_NEON__) + +#if defined(_MSC_VER) && !defined(__clang__) + +#define STBIR_PROFILE_FUNC() _ReadStatusReg(ARM64_CNTVCT) + +#else + +static stbir__inline stbir_uint64 STBIR_PROFILE_FUNC() { + stbir_uint64 tsc; + asm volatile("mrs %0, cntvct_el0" : "=r"(tsc)); + return tsc; +} + +#endif + +#else // x64, arm + +#error Unknown platform for profiling. + +#endif // x64, arm + +#endif // STBIR_PROFILE_FUNC + +#define STBIR_ONLY_PROFILE_GET_SPLIT_INFO , stbir__per_split_info *split_info +#define STBIR_ONLY_PROFILE_SET_SPLIT_INFO , split_info + +#define STBIR_ONLY_PROFILE_BUILD_GET_INFO , stbir__info *profile_info +#define STBIR_ONLY_PROFILE_BUILD_SET_INFO , profile_info + +// super light-weight micro profiler +#define STBIR_PROFILE_START_ll(info, wh) \ + { \ + stbir_uint64 wh##thiszonetime = STBIR_PROFILE_FUNC(); \ + stbir_uint64 *wh##save_parent_excluded_ptr = info->current_zone_excluded_ptr; \ + stbir_uint64 wh##current_zone_excluded = 0; \ + info->current_zone_excluded_ptr = &wh##current_zone_excluded; +#define STBIR_PROFILE_END_ll(info, wh) \ + wh##thiszonetime = STBIR_PROFILE_FUNC() - wh##thiszonetime; \ + info->profile.named.wh += wh##thiszonetime - wh##current_zone_excluded; \ + *wh##save_parent_excluded_ptr += wh##thiszonetime; \ + info->current_zone_excluded_ptr = wh##save_parent_excluded_ptr; \ + } +#define STBIR_PROFILE_FIRST_START_ll(info, wh) \ + { \ + int i; \ + info->current_zone_excluded_ptr = &info->profile.named.total; \ + for (i = 0; i < STBIR__ARRAY_SIZE(info->profile.array); i++) \ + info->profile.array[i] = 0; \ + } \ + STBIR_PROFILE_START_ll(info, wh); +#define STBIR_PROFILE_CLEAR_EXTRAS_ll(info, num) \ + { \ + int extra; \ + for (extra = 1; extra < (num); extra++) { \ + int i; \ + for (i = 0; i < STBIR__ARRAY_SIZE((info)->profile.array); i++) \ + (info)[extra].profile.array[i] = 0; \ + } \ + } + +// for thread data +#define STBIR_PROFILE_START(wh) STBIR_PROFILE_START_ll(split_info, wh) +#define STBIR_PROFILE_END(wh) STBIR_PROFILE_END_ll(split_info, wh) +#define STBIR_PROFILE_FIRST_START(wh) STBIR_PROFILE_FIRST_START_ll(split_info, wh) +#define STBIR_PROFILE_CLEAR_EXTRAS() STBIR_PROFILE_CLEAR_EXTRAS_ll(split_info, split_count) + +// for build data +#define STBIR_PROFILE_BUILD_START(wh) STBIR_PROFILE_START_ll(profile_info, wh) +#define STBIR_PROFILE_BUILD_END(wh) STBIR_PROFILE_END_ll(profile_info, wh) +#define STBIR_PROFILE_BUILD_FIRST_START(wh) STBIR_PROFILE_FIRST_START_ll(profile_info, wh) +#define STBIR_PROFILE_BUILD_CLEAR(info) \ + { \ + int i; \ + for (i = 0; i < STBIR__ARRAY_SIZE(info->profile.array); i++) \ + info->profile.array[i] = 0; \ + } + +#else // no profile + +#define STBIR_ONLY_PROFILE_GET_SPLIT_INFO +#define STBIR_ONLY_PROFILE_SET_SPLIT_INFO + +#define STBIR_ONLY_PROFILE_BUILD_GET_INFO +#define STBIR_ONLY_PROFILE_BUILD_SET_INFO + +#define STBIR_PROFILE_START(wh) +#define STBIR_PROFILE_END(wh) +#define STBIR_PROFILE_FIRST_START(wh) +#define STBIR_PROFILE_CLEAR_EXTRAS() + +#define STBIR_PROFILE_BUILD_START(wh) +#define STBIR_PROFILE_BUILD_END(wh) +#define STBIR_PROFILE_BUILD_FIRST_START(wh) +#define STBIR_PROFILE_BUILD_CLEAR(info) + +#endif // stbir_profile + +#ifndef STBIR_CEILF +#include +#if _MSC_VER <= 1200 // support VC6 for Sean +#define STBIR_CEILF(x) ((float)ceil((float)(x))) +#define STBIR_FLOORF(x) ((float)floor((float)(x))) +#else +#define STBIR_CEILF(x) ceilf(x) +#define STBIR_FLOORF(x) floorf(x) +#endif +#endif + +#ifndef STBIR_MEMCPY +// For memcpy +#include +#define STBIR_MEMCPY(dest, src, len) memcpy(dest, src, len) +#endif + +#ifndef STBIR_SIMD + +// memcpy that is specifically intentionally overlapping (src is smaller then dest, so can be +// a normal forward copy, bytes is divisible by 4 and bytes is greater than or equal to +// the diff between dest and src) +static void stbir_overlapping_memcpy(void *dest, void const *src, size_t bytes) { + char STBIR_SIMD_STREAMOUT_PTR(*) sd = (char *)src; + char STBIR_SIMD_STREAMOUT_PTR(*) s_end = ((char *)src) + bytes; + ptrdiff_t ofs_to_dest = (char *)dest - (char *)src; + + if (ofs_to_dest >= 8) // is the overlap more than 8 away? + { + char STBIR_SIMD_STREAMOUT_PTR(*) s_end8 = ((char *)src) + (bytes & ~7); + STBIR_NO_UNROLL_LOOP_START + do { + STBIR_NO_UNROLL(sd); + *(stbir_uint64 *)(sd + ofs_to_dest) = *(stbir_uint64 *)sd; + sd += 8; + } while (sd < s_end8); + + if (sd == s_end) + return; + } + + STBIR_NO_UNROLL_LOOP_START + do { + STBIR_NO_UNROLL(sd); + *(int *)(sd + ofs_to_dest) = *(int *)sd; + sd += 4; + } while (sd < s_end); +} + +#endif + +static float stbir__filter_trapezoid(float x, float scale, void *user_data) { + float halfscale = scale / 2; + float t = 0.5f + halfscale; + STBIR_ASSERT(scale <= 1); + STBIR__UNUSED(user_data); + + if (x < 0.0f) + x = -x; + + if (x >= t) + return 0.0f; + else { + float r = 0.5f - halfscale; + if (x <= r) + return 1.0f; + else + return (t - x) / scale; + } +} + +static float stbir__support_trapezoid(float scale, void *user_data) { + STBIR__UNUSED(user_data); + return 0.5f + scale / 2.0f; +} + +static float stbir__filter_triangle(float x, float s, void *user_data) { + STBIR__UNUSED(s); + STBIR__UNUSED(user_data); + + if (x < 0.0f) + x = -x; + + if (x <= 1.0f) + return 1.0f - x; + else + return 0.0f; +} + +static float stbir__filter_point(float x, float s, void *user_data) { + STBIR__UNUSED(x); + STBIR__UNUSED(s); + STBIR__UNUSED(user_data); + + return 1.0f; +} + +static float stbir__filter_cubic(float x, float s, void *user_data) { + STBIR__UNUSED(s); + STBIR__UNUSED(user_data); + + if (x < 0.0f) + x = -x; + + if (x < 1.0f) + return (4.0f + x * x * (3.0f * x - 6.0f)) / 6.0f; + else if (x < 2.0f) + return (8.0f + x * (-12.0f + x * (6.0f - x))) / 6.0f; + + return (0.0f); +} + +static float stbir__filter_catmullrom(float x, float s, void *user_data) { + STBIR__UNUSED(s); + STBIR__UNUSED(user_data); + + if (x < 0.0f) + x = -x; + + if (x < 1.0f) + return 1.0f - x * x * (2.5f - 1.5f * x); + else if (x < 2.0f) + return 2.0f - x * (4.0f + x * (0.5f * x - 2.5f)); + + return (0.0f); +} + +static float stbir__filter_mitchell(float x, float s, void *user_data) { + STBIR__UNUSED(s); + STBIR__UNUSED(user_data); + + if (x < 0.0f) + x = -x; + + if (x < 1.0f) + return (16.0f + x * x * (21.0f * x - 36.0f)) / 18.0f; + else if (x < 2.0f) + return (32.0f + x * (-60.0f + x * (36.0f - 7.0f * x))) / 18.0f; + + return (0.0f); +} + +static float stbir__support_zeropoint5(float s, void *user_data) { + STBIR__UNUSED(s); + STBIR__UNUSED(user_data); + return 0.5f; +} + +static float stbir__support_one(float s, void *user_data) { + STBIR__UNUSED(s); + STBIR__UNUSED(user_data); + return 1; +} + +static float stbir__support_two(float s, void *user_data) { + STBIR__UNUSED(s); + STBIR__UNUSED(user_data); + return 2; +} + +// This is the maximum number of input samples that can affect an output sample +// with the given filter from the output pixel's perspective +static int stbir__get_filter_pixel_width(stbir__support_callback *support, float scale, + void *user_data) { + STBIR_ASSERT(support != 0); + + if (scale >= (1.0f - stbir__small_float)) // upscale + return (int)STBIR_CEILF(support(1.0f / scale, user_data) * 2.0f); + else + return (int)STBIR_CEILF(support(scale, user_data) * 2.0f / scale); +} + +// this is how many coefficents per run of the filter (which is different +// from the filter_pixel_width depending on if we are scattering or gathering) +static int stbir__get_coefficient_width(stbir__sampler *samp, int is_gather, void *user_data) { + float scale = samp->scale_info.scale; + stbir__support_callback *support = samp->filter_support; + + switch (is_gather) { + case 1: + return (int)STBIR_CEILF(support(1.0f / scale, user_data) * 2.0f); + case 2: + return (int)STBIR_CEILF(support(scale, user_data) * 2.0f / scale); + case 0: + return (int)STBIR_CEILF(support(scale, user_data) * 2.0f); + default: + STBIR_ASSERT((is_gather >= 0) && (is_gather <= 2)); + return 0; + } +} + +static int stbir__get_contributors(stbir__sampler *samp, int is_gather) { + if (is_gather) + return samp->scale_info.output_sub_size; + else + return (samp->scale_info.input_full_size + samp->filter_pixel_margin * 2); +} + +static int stbir__edge_zero_full(int n, int max) { + STBIR__UNUSED(n); + STBIR__UNUSED(max); + return 0; // NOTREACHED +} + +static int stbir__edge_clamp_full(int n, int max) { + if (n < 0) + return 0; + + if (n >= max) + return max - 1; + + return n; // NOTREACHED +} + +static int stbir__edge_reflect_full(int n, int max) { + if (n < 0) { + if (n > -max) + return -n; + else + return max - 1; + } + + if (n >= max) { + int max2 = max * 2; + if (n >= max2) + return 0; + else + return max2 - n - 1; + } + + return n; // NOTREACHED +} + +static int stbir__edge_wrap_full(int n, int max) { + if (n >= 0) + return (n % max); + else { + int m = (-n) % max; + + if (m != 0) + m = max - m; + + return (m); + } +} + +typedef int stbir__edge_wrap_func(int n, int max); +static stbir__edge_wrap_func *stbir__edge_wrap_slow[] = { + stbir__edge_clamp_full, // STBIR_EDGE_CLAMP + stbir__edge_reflect_full, // STBIR_EDGE_REFLECT + stbir__edge_wrap_full, // STBIR_EDGE_WRAP + stbir__edge_zero_full, // STBIR_EDGE_ZERO +}; + +stbir__inline static int stbir__edge_wrap(stbir_edge edge, int n, int max) { + // avoid per-pixel switch + if (n >= 0 && n < max) + return n; + return stbir__edge_wrap_slow[edge](n, max); +} + +#define STBIR__MERGE_RUNS_PIXEL_THRESHOLD 16 + +// get information on the extents of a sampler +static void stbir__get_extents(stbir__sampler *samp, stbir__extents *scanline_extents) { + int j, stop; + int left_margin, right_margin; + int min_n = 0x7fffffff, max_n = -0x7fffffff; + int min_left = 0x7fffffff, max_left = -0x7fffffff; + int min_right = 0x7fffffff, max_right = -0x7fffffff; + stbir_edge edge = samp->edge; + stbir__contributors *contributors = samp->contributors; + int output_sub_size = samp->scale_info.output_sub_size; + int input_full_size = samp->scale_info.input_full_size; + int filter_pixel_margin = samp->filter_pixel_margin; + + STBIR_ASSERT(samp->is_gather); + + stop = output_sub_size; + for (j = 0; j < stop; j++) { + STBIR_ASSERT(contributors[j].n1 >= contributors[j].n0); + if (contributors[j].n0 < min_n) { + min_n = contributors[j].n0; + stop = j + filter_pixel_margin; // if we find a new min, only scan another filter width + if (stop > output_sub_size) + stop = output_sub_size; + } + } + + stop = 0; + for (j = output_sub_size - 1; j >= stop; j--) { + STBIR_ASSERT(contributors[j].n1 >= contributors[j].n0); + if (contributors[j].n1 > max_n) { + max_n = contributors[j].n1; + stop = j - filter_pixel_margin; // if we find a new max, only scan another filter width + if (stop < 0) + stop = 0; + } + } + + STBIR_ASSERT(scanline_extents->conservative.n0 <= min_n); + STBIR_ASSERT(scanline_extents->conservative.n1 >= max_n); + + // now calculate how much into the margins we really read + left_margin = 0; + if (min_n < 0) { + left_margin = -min_n; + min_n = 0; + } + + right_margin = 0; + if (max_n >= input_full_size) { + right_margin = max_n - input_full_size + 1; + max_n = input_full_size - 1; + } + + // index 1 is margin pixel extents (how many pixels we hang over the edge) + scanline_extents->edge_sizes[0] = left_margin; + scanline_extents->edge_sizes[1] = right_margin; + + // index 2 is pixels read from the input + scanline_extents->spans[0].n0 = min_n; + scanline_extents->spans[0].n1 = max_n; + scanline_extents->spans[0].pixel_offset_for_input = min_n; + + // default to no other input range + scanline_extents->spans[1].n0 = 0; + scanline_extents->spans[1].n1 = -1; + scanline_extents->spans[1].pixel_offset_for_input = 0; + + // don't have to do edge calc for zero clamp + if (edge == STBIR_EDGE_ZERO) + return; + + // convert margin pixels to the pixels within the input (min and max) + for (j = -left_margin; j < 0; j++) { + int p = stbir__edge_wrap(edge, j, input_full_size); + if (p < min_left) + min_left = p; + if (p > max_left) + max_left = p; + } + + for (j = input_full_size; j < (input_full_size + right_margin); j++) { + int p = stbir__edge_wrap(edge, j, input_full_size); + if (p < min_right) + min_right = p; + if (p > max_right) + max_right = p; + } + + // merge the left margin pixel region if it connects within 4 pixels of main pixel region + if (min_left != 0x7fffffff) { + if (((min_left <= min_n) && ((max_left + STBIR__MERGE_RUNS_PIXEL_THRESHOLD) >= min_n)) || + ((min_n <= min_left) && ((max_n + STBIR__MERGE_RUNS_PIXEL_THRESHOLD) >= max_left))) { + scanline_extents->spans[0].n0 = min_n = stbir__min(min_n, min_left); + scanline_extents->spans[0].n1 = max_n = stbir__max(max_n, max_left); + scanline_extents->spans[0].pixel_offset_for_input = min_n; + left_margin = 0; + } + } + + // merge the right margin pixel region if it connects within 4 pixels of main pixel region + if (min_right != 0x7fffffff) { + if (((min_right <= min_n) && ((max_right + STBIR__MERGE_RUNS_PIXEL_THRESHOLD) >= min_n)) || + ((min_n <= min_right) && ((max_n + STBIR__MERGE_RUNS_PIXEL_THRESHOLD) >= max_right))) { + scanline_extents->spans[0].n0 = min_n = stbir__min(min_n, min_right); + scanline_extents->spans[0].n1 = max_n = stbir__max(max_n, max_right); + scanline_extents->spans[0].pixel_offset_for_input = min_n; + right_margin = 0; + } + } + + STBIR_ASSERT(scanline_extents->conservative.n0 <= min_n); + STBIR_ASSERT(scanline_extents->conservative.n1 >= max_n); + + // you get two ranges when you have the WRAP edge mode and you are doing just the a piece of the + // resize + // so you need to get a second run of pixels from the opposite side of the scanline (which you + // wouldn't need except for WRAP) + + // if we can't merge the min_left range, add it as a second range + if ((left_margin) && (min_left != 0x7fffffff)) { + stbir__span *newspan = scanline_extents->spans + 1; + STBIR_ASSERT(right_margin == 0); + if (min_left < scanline_extents->spans[0].n0) { + scanline_extents->spans[1].pixel_offset_for_input = scanline_extents->spans[0].n0; + scanline_extents->spans[1].n0 = scanline_extents->spans[0].n0; + scanline_extents->spans[1].n1 = scanline_extents->spans[0].n1; + --newspan; + } + newspan->pixel_offset_for_input = min_left; + newspan->n0 = -left_margin; + newspan->n1 = (max_left - min_left) - left_margin; + scanline_extents->edge_sizes[0] = 0; // don't need to copy the left margin, since we are + // directly decoding into the margin + return; + } + + // if we can't merge the min_left range, add it as a second range + if ((right_margin) && (min_right != 0x7fffffff)) { + stbir__span *newspan = scanline_extents->spans + 1; + if (min_right < scanline_extents->spans[0].n0) { + scanline_extents->spans[1].pixel_offset_for_input = scanline_extents->spans[0].n0; + scanline_extents->spans[1].n0 = scanline_extents->spans[0].n0; + scanline_extents->spans[1].n1 = scanline_extents->spans[0].n1; + --newspan; + } + newspan->pixel_offset_for_input = min_right; + newspan->n0 = scanline_extents->spans[1].n1 + 1; + newspan->n1 = scanline_extents->spans[1].n1 + 1 + (max_right - min_right); + scanline_extents->edge_sizes[1] = 0; // don't need to copy the right margin, since we are + // directly decoding into the margin + return; + } +} + +static void stbir__calculate_in_pixel_range(int *first_pixel, int *last_pixel, + float out_pixel_center, float out_filter_radius, + float inv_scale, float out_shift, int input_size, + stbir_edge edge) { + int first, last; + float out_pixel_influence_lowerbound = out_pixel_center - out_filter_radius; + float out_pixel_influence_upperbound = out_pixel_center + out_filter_radius; + + float in_pixel_influence_lowerbound = (out_pixel_influence_lowerbound + out_shift) * inv_scale; + float in_pixel_influence_upperbound = (out_pixel_influence_upperbound + out_shift) * inv_scale; + + first = (int)(STBIR_FLOORF(in_pixel_influence_lowerbound + 0.5f)); + last = (int)(STBIR_FLOORF(in_pixel_influence_upperbound - 0.5f)); + if (last < first) + last = + first; // point sample mode can span a value *right* at 0.5, and cause these to cross + + if (edge == STBIR_EDGE_WRAP) { + if (first < -input_size) + first = -input_size; + if (last >= (input_size * 2)) + last = (input_size * 2) - 1; + } + + *first_pixel = first; + *last_pixel = last; +} + +static void stbir__calculate_coefficients_for_gather_upsample( + float out_filter_radius, stbir__kernel_callback *kernel, stbir__scale_info *scale_info, + int num_contributors, stbir__contributors *contributors, float *coefficient_group, + int coefficient_width, stbir_edge edge, void *user_data) { + int n, end; + float inv_scale = scale_info->inv_scale; + float out_shift = scale_info->pixel_shift; + int input_size = scale_info->input_full_size; + int numerator = scale_info->scale_numerator; + int polyphase = ((scale_info->scale_is_rational) && (numerator < num_contributors)); + + // Looping through out pixels + end = num_contributors; + if (polyphase) + end = numerator; + for (n = 0; n < end; n++) { + int i; + int last_non_zero; + float out_pixel_center = (float)n + 0.5f; + float in_center_of_out = (out_pixel_center + out_shift) * inv_scale; + + int in_first_pixel, in_last_pixel; + + stbir__calculate_in_pixel_range(&in_first_pixel, &in_last_pixel, out_pixel_center, + out_filter_radius, inv_scale, out_shift, input_size, edge); + + // make sure we never generate a range larger than our precalculated coeff width + // this only happens in point sample mode, but it's a good safe thing to do anyway + if ((in_last_pixel - in_first_pixel + 1) > coefficient_width) + in_last_pixel = in_first_pixel + coefficient_width - 1; + + last_non_zero = -1; + for (i = 0; i <= in_last_pixel - in_first_pixel; i++) { + float in_pixel_center = (float)(i + in_first_pixel) + 0.5f; + float coeff = kernel(in_center_of_out - in_pixel_center, inv_scale, user_data); + + // kill denormals + if (((coeff < stbir__small_float) && (coeff > -stbir__small_float))) { + if (i == 0) // if we're at the front, just eat zero contributors + { + STBIR_ASSERT((in_last_pixel - in_first_pixel) != + 0); // there should be at least one contrib + ++in_first_pixel; + i--; + continue; + } + coeff = 0; // make sure is fully zero (should keep denormals away) + } else + last_non_zero = i; + + coefficient_group[i] = coeff; + } + + in_last_pixel = last_non_zero + in_first_pixel; // kills trailing zeros + contributors->n0 = in_first_pixel; + contributors->n1 = in_last_pixel; + + STBIR_ASSERT(contributors->n1 >= contributors->n0); + + ++contributors; + coefficient_group += coefficient_width; + } +} + +static void stbir__insert_coeff(stbir__contributors *contribs, float *coeffs, int new_pixel, + float new_coeff, int max_width) { + if (new_pixel <= contribs->n1) // before the end + { + if (new_pixel < contribs->n0) // before the front? + { + if ((contribs->n1 - new_pixel + 1) <= max_width) { + int j, o = contribs->n0 - new_pixel; + for (j = contribs->n1 - contribs->n0; j <= 0; j--) + coeffs[j + o] = coeffs[j]; + for (j = 1; j < o; j--) + coeffs[j] = coeffs[0]; + coeffs[0] = new_coeff; + contribs->n0 = new_pixel; + } + } else { + coeffs[new_pixel - contribs->n0] += new_coeff; + } + } else { + if ((new_pixel - contribs->n0 + 1) <= max_width) { + int j, e = new_pixel - contribs->n0; + for (j = (contribs->n1 - contribs->n0) + 1; j < e; + j++) // clear in-betweens coeffs if there are any + coeffs[j] = 0; + + coeffs[e] = new_coeff; + contribs->n1 = new_pixel; + } + } +} + +static void stbir__calculate_out_pixel_range(int *first_pixel, int *last_pixel, + float in_pixel_center, float in_pixels_radius, + float scale, float out_shift, int out_size) { + float in_pixel_influence_lowerbound = in_pixel_center - in_pixels_radius; + float in_pixel_influence_upperbound = in_pixel_center + in_pixels_radius; + float out_pixel_influence_lowerbound = in_pixel_influence_lowerbound * scale - out_shift; + float out_pixel_influence_upperbound = in_pixel_influence_upperbound * scale - out_shift; + int out_first_pixel = (int)(STBIR_FLOORF(out_pixel_influence_lowerbound + 0.5f)); + int out_last_pixel = (int)(STBIR_FLOORF(out_pixel_influence_upperbound - 0.5f)); + + if (out_first_pixel < 0) + out_first_pixel = 0; + if (out_last_pixel >= out_size) + out_last_pixel = out_size - 1; + *first_pixel = out_first_pixel; + *last_pixel = out_last_pixel; +} + +static void stbir__calculate_coefficients_for_gather_downsample( + int start, int end, float in_pixels_radius, stbir__kernel_callback *kernel, + stbir__scale_info *scale_info, int coefficient_width, int num_contributors, + stbir__contributors *contributors, float *coefficient_group, void *user_data) { + int in_pixel; + int i; + int first_out_inited = -1; + float scale = scale_info->scale; + float out_shift = scale_info->pixel_shift; + int out_size = scale_info->output_sub_size; + int numerator = scale_info->scale_numerator; + int polyphase = ((scale_info->scale_is_rational) && (numerator < out_size)); + + STBIR__UNUSED(num_contributors); + + // Loop through the input pixels + for (in_pixel = start; in_pixel < end; in_pixel++) { + float in_pixel_center = (float)in_pixel + 0.5f; + float out_center_of_in = in_pixel_center * scale - out_shift; + int out_first_pixel, out_last_pixel; + + stbir__calculate_out_pixel_range(&out_first_pixel, &out_last_pixel, in_pixel_center, + in_pixels_radius, scale, out_shift, out_size); + + if (out_first_pixel > out_last_pixel) + continue; + + // clamp or exit if we are using polyphase filtering, and the limit is up + if (polyphase) { + // when polyphase, you only have to do coeffs up to the numerator count + if (out_first_pixel == numerator) + break; + + // don't do any extra work, clamp last pixel at numerator too + if (out_last_pixel >= numerator) + out_last_pixel = numerator - 1; + } + + for (i = 0; i <= out_last_pixel - out_first_pixel; i++) { + float out_pixel_center = (float)(i + out_first_pixel) + 0.5f; + float x = out_pixel_center - out_center_of_in; + float coeff = kernel(x, scale, user_data) * scale; + + // kill the coeff if it's too small (avoid denormals) + if (((coeff < stbir__small_float) && (coeff > -stbir__small_float))) + coeff = 0.0f; + + { + int out = i + out_first_pixel; + float *coeffs = coefficient_group + out * coefficient_width; + stbir__contributors *contribs = contributors + out; + + // is this the first time this output pixel has been seen? Init it. + if (out > first_out_inited) { + STBIR_ASSERT( + out == (first_out_inited + 1)); // ensure we have only advanced one at time + first_out_inited = out; + contribs->n0 = in_pixel; + contribs->n1 = in_pixel; + coeffs[0] = coeff; + } else { + // insert on end (always in order) + if (coeffs[0] == + 0.0f) // if the first coefficent is zero, then zap it for this coeffs + { + STBIR_ASSERT((in_pixel - contribs->n0) == + 1); // ensure that when we zap, we're at the 2nd pos + contribs->n0 = in_pixel; + } + contribs->n1 = in_pixel; + STBIR_ASSERT((in_pixel - contribs->n0) < coefficient_width); + coeffs[in_pixel - contribs->n0] = coeff; + } + } + } + } +} + +#ifdef STBIR_RENORMALIZE_IN_FLOAT +#define STBIR_RENORM_TYPE float +#else +#define STBIR_RENORM_TYPE double +#endif + +static void stbir__cleanup_gathered_coefficients(stbir_edge edge, + stbir__filter_extent_info *filter_info, + stbir__scale_info *scale_info, + int num_contributors, + stbir__contributors *contributors, + float *coefficient_group, int coefficient_width) { + int input_size = scale_info->input_full_size; + int input_last_n1 = input_size - 1; + int n, end; + int lowest = 0x7fffffff; + int highest = -0x7fffffff; + int widest = -1; + int numerator = scale_info->scale_numerator; + int denominator = scale_info->scale_denominator; + int polyphase = ((scale_info->scale_is_rational) && (numerator < num_contributors)); + float *coeffs; + stbir__contributors *contribs; + + // weight all the coeffs for each sample + coeffs = coefficient_group; + contribs = contributors; + end = num_contributors; + if (polyphase) + end = numerator; + for (n = 0; n < end; n++) { + int i; + STBIR_RENORM_TYPE filter_scale, total_filter = 0; + int e; + + // add all contribs + e = contribs->n1 - contribs->n0; + for (i = 0; i <= e; i++) { + total_filter += (STBIR_RENORM_TYPE)coeffs[i]; + STBIR_ASSERT((coeffs[i] >= -2.0f) && (coeffs[i] <= 2.0f)); // check for wonky weights + } + + // rescale + if ((total_filter < stbir__small_float) && (total_filter > -stbir__small_float)) { + // all coeffs are extremely small, just zero it + contribs->n1 = contribs->n0; + coeffs[0] = 0.0f; + } else { + // if the total isn't 1.0, rescale everything + if ((total_filter < (1.0f - stbir__small_float)) || + (total_filter > (1.0f + stbir__small_float))) { + filter_scale = ((STBIR_RENORM_TYPE)1.0) / total_filter; + + // scale them all + for (i = 0; i <= e; i++) + coeffs[i] = (float)(coeffs[i] * filter_scale); + } + } + ++contribs; + coeffs += coefficient_width; + } + + // if we have a rational for the scale, we can exploit the polyphaseness to not calculate + // most of the coefficients, so we copy them here + if (polyphase) { + stbir__contributors *prev_contribs = contributors; + stbir__contributors *cur_contribs = contributors + numerator; + + for (n = numerator; n < num_contributors; n++) { + cur_contribs->n0 = prev_contribs->n0 + denominator; + cur_contribs->n1 = prev_contribs->n1 + denominator; + ++cur_contribs; + ++prev_contribs; + } + stbir_overlapping_memcpy( + coefficient_group + numerator * coefficient_width, coefficient_group, + (num_contributors - numerator) * coefficient_width * sizeof(coeffs[0])); + } + + coeffs = coefficient_group; + contribs = contributors; + + for (n = 0; n < num_contributors; n++) { + int i; + + // in zero edge mode, just remove out of bounds contribs completely (since their weights are + // accounted for now) + if (edge == STBIR_EDGE_ZERO) { + // shrink the right side if necessary + if (contribs->n1 > input_last_n1) + contribs->n1 = input_last_n1; + + // shrink the left side + if (contribs->n0 < 0) { + int j, left, skips = 0; + + skips = -contribs->n0; + contribs->n0 = 0; + + // now move down the weights + left = contribs->n1 - contribs->n0 + 1; + if (left > 0) { + for (j = 0; j < left; j++) + coeffs[j] = coeffs[j + skips]; + } + } + } else if ((edge == STBIR_EDGE_CLAMP) || (edge == STBIR_EDGE_REFLECT)) { + // for clamp and reflect, calculate the true inbounds position (based on edge type) and + // just add that to the existing weight + + // right hand side first + if (contribs->n1 > input_last_n1) { + int start = contribs->n0; + int endi = contribs->n1; + contribs->n1 = input_last_n1; + for (i = input_size; i <= endi; i++) + stbir__insert_coeff(contribs, coeffs, + stbir__edge_wrap_slow[edge](i, input_size), + coeffs[i - start], coefficient_width); + } + + // now check left hand edge + if (contribs->n0 < 0) { + int save_n0; + float save_n0_coeff; + float *c = coeffs - (contribs->n0 + 1); + + // reinsert the coeffs with it reflected or clamped (insert accumulates, if the + // coeffs exist) + for (i = -1; i > contribs->n0; i--) + stbir__insert_coeff(contribs, coeffs, + stbir__edge_wrap_slow[edge](i, input_size), *c--, + coefficient_width); + save_n0 = contribs->n0; + save_n0_coeff = c[0]; // save it, since we didn't do the final one (i==n0), because + // there might be too many coeffs to hold (before we resize)! + + // now slide all the coeffs down (since we have accumulated them in the positive + // contribs) and reset the first contrib + contribs->n0 = 0; + for (i = 0; i <= contribs->n1; i++) + coeffs[i] = coeffs[i - save_n0]; + + // now that we have shrunk down the contribs, we insert the first one safely + stbir__insert_coeff(contribs, coeffs, + stbir__edge_wrap_slow[edge](save_n0, input_size), save_n0_coeff, + coefficient_width); + } + } + + if (contribs->n0 <= contribs->n1) { + int diff = contribs->n1 - contribs->n0 + 1; + while (diff && (coeffs[diff - 1] == 0.0f)) + --diff; + + contribs->n1 = contribs->n0 + diff - 1; + + if (contribs->n0 <= contribs->n1) { + if (contribs->n0 < lowest) + lowest = contribs->n0; + if (contribs->n1 > highest) + highest = contribs->n1; + if (diff > widest) + widest = diff; + } + + // re-zero out unused coefficients (if any) + for (i = diff; i < coefficient_width; i++) + coeffs[i] = 0.0f; + } + + ++contribs; + coeffs += coefficient_width; + } + filter_info->lowest = lowest; + filter_info->highest = highest; + filter_info->widest = widest; +} + +#undef STBIR_RENORM_TYPE + +static int stbir__pack_coefficients(int num_contributors, stbir__contributors *contributors, + float *coefficents, int coefficient_width, int widest, int row0, + int row1) { +#define STBIR_MOVE_1(dest, src) \ + { \ + STBIR_NO_UNROLL(dest); \ + ((stbir_uint32 *)(dest))[0] = ((stbir_uint32 *)(src))[0]; \ + } +#define STBIR_MOVE_2(dest, src) \ + { \ + STBIR_NO_UNROLL(dest); \ + ((stbir_uint64 *)(dest))[0] = ((stbir_uint64 *)(src))[0]; \ + } +#ifdef STBIR_SIMD +#define STBIR_MOVE_4(dest, src) \ + { \ + stbir__simdf t; \ + STBIR_NO_UNROLL(dest); \ + stbir__simdf_load(t, src); \ + stbir__simdf_store(dest, t); \ + } +#else +#define STBIR_MOVE_4(dest, src) \ + { \ + STBIR_NO_UNROLL(dest); \ + ((stbir_uint64 *)(dest))[0] = ((stbir_uint64 *)(src))[0]; \ + ((stbir_uint64 *)(dest))[1] = ((stbir_uint64 *)(src))[1]; \ + } +#endif + + int row_end = row1 + 1; + STBIR__UNUSED(row0); // only used in an assert + + if (coefficient_width != widest) { + float *pc = coefficents; + float *coeffs = coefficents; + float *pc_end = coefficents + num_contributors * widest; + switch (widest) { + case 1: + STBIR_NO_UNROLL_LOOP_START + do { + STBIR_MOVE_1(pc, coeffs); + ++pc; + coeffs += coefficient_width; + } while (pc < pc_end); + break; + case 2: + STBIR_NO_UNROLL_LOOP_START + do { + STBIR_MOVE_2(pc, coeffs); + pc += 2; + coeffs += coefficient_width; + } while (pc < pc_end); + break; + case 3: + STBIR_NO_UNROLL_LOOP_START + do { + STBIR_MOVE_2(pc, coeffs); + STBIR_MOVE_1(pc + 2, coeffs + 2); + pc += 3; + coeffs += coefficient_width; + } while (pc < pc_end); + break; + case 4: + STBIR_NO_UNROLL_LOOP_START + do { + STBIR_MOVE_4(pc, coeffs); + pc += 4; + coeffs += coefficient_width; + } while (pc < pc_end); + break; + case 5: + STBIR_NO_UNROLL_LOOP_START + do { + STBIR_MOVE_4(pc, coeffs); + STBIR_MOVE_1(pc + 4, coeffs + 4); + pc += 5; + coeffs += coefficient_width; + } while (pc < pc_end); + break; + case 6: + STBIR_NO_UNROLL_LOOP_START + do { + STBIR_MOVE_4(pc, coeffs); + STBIR_MOVE_2(pc + 4, coeffs + 4); + pc += 6; + coeffs += coefficient_width; + } while (pc < pc_end); + break; + case 7: + STBIR_NO_UNROLL_LOOP_START + do { + STBIR_MOVE_4(pc, coeffs); + STBIR_MOVE_2(pc + 4, coeffs + 4); + STBIR_MOVE_1(pc + 6, coeffs + 6); + pc += 7; + coeffs += coefficient_width; + } while (pc < pc_end); + break; + case 8: + STBIR_NO_UNROLL_LOOP_START + do { + STBIR_MOVE_4(pc, coeffs); + STBIR_MOVE_4(pc + 4, coeffs + 4); + pc += 8; + coeffs += coefficient_width; + } while (pc < pc_end); + break; + case 9: + STBIR_NO_UNROLL_LOOP_START + do { + STBIR_MOVE_4(pc, coeffs); + STBIR_MOVE_4(pc + 4, coeffs + 4); + STBIR_MOVE_1(pc + 8, coeffs + 8); + pc += 9; + coeffs += coefficient_width; + } while (pc < pc_end); + break; + case 10: + STBIR_NO_UNROLL_LOOP_START + do { + STBIR_MOVE_4(pc, coeffs); + STBIR_MOVE_4(pc + 4, coeffs + 4); + STBIR_MOVE_2(pc + 8, coeffs + 8); + pc += 10; + coeffs += coefficient_width; + } while (pc < pc_end); + break; + case 11: + STBIR_NO_UNROLL_LOOP_START + do { + STBIR_MOVE_4(pc, coeffs); + STBIR_MOVE_4(pc + 4, coeffs + 4); + STBIR_MOVE_2(pc + 8, coeffs + 8); + STBIR_MOVE_1(pc + 10, coeffs + 10); + pc += 11; + coeffs += coefficient_width; + } while (pc < pc_end); + break; + case 12: + STBIR_NO_UNROLL_LOOP_START + do { + STBIR_MOVE_4(pc, coeffs); + STBIR_MOVE_4(pc + 4, coeffs + 4); + STBIR_MOVE_4(pc + 8, coeffs + 8); + pc += 12; + coeffs += coefficient_width; + } while (pc < pc_end); + break; + default: + STBIR_NO_UNROLL_LOOP_START + do { + float *copy_end = pc + widest - 4; + float *c = coeffs; + do { + STBIR_NO_UNROLL(pc); + STBIR_MOVE_4(pc, c); + pc += 4; + c += 4; + } while (pc <= copy_end); + copy_end += 4; + STBIR_NO_UNROLL_LOOP_START + while (pc < copy_end) { + STBIR_MOVE_1(pc, c); + ++pc; + ++c; + } + coeffs += coefficient_width; + } while (pc < pc_end); + break; + } + } + + // some horizontal routines read one float off the end (which is then masked off), so put in a + // sentinal so we don't read an snan or denormal + coefficents[widest * num_contributors] = 8888.0f; + + // the minimum we might read for unrolled filters widths is 12. So, we need to + // make sure we never read outside the decode buffer, by possibly moving + // the sample area back into the scanline, and putting zeros weights first. + // we start on the right edge and check until we're well past the possible + // clip area (2*widest). + { + stbir__contributors *contribs = contributors + num_contributors - 1; + float *coeffs = coefficents + widest * (num_contributors - 1); + + // go until no chance of clipping (this is usually less than 8 lops) + while ((contribs >= contributors) && ((contribs->n0 + widest * 2) >= row_end)) { + // might we clip?? + if ((contribs->n0 + widest) > row_end) { + int stop_range = widest; + + // if range is larger than 12, it will be handled by generic loops that can + // terminate on the exact length + // of this contrib n1, instead of a fixed widest amount - so calculate this + if (widest > 12) { + int mod; + + // how far will be read in the n_coeff loop (which depends on the widest count + // mod4); + mod = widest & 3; + stop_range = (((contribs->n1 - contribs->n0 + 1) - mod + 3) & ~3) + mod; + + // the n_coeff loops do a minimum amount of coeffs, so factor that in! + if (stop_range < (8 + mod)) + stop_range = 8 + mod; + } + + // now see if we still clip with the refined range + if ((contribs->n0 + stop_range) > row_end) { + int new_n0 = row_end - stop_range; + int num = contribs->n1 - contribs->n0 + 1; + int backup = contribs->n0 - new_n0; + float *from_co = coeffs + num - 1; + float *to_co = from_co + backup; + + STBIR_ASSERT((new_n0 >= row0) && (new_n0 < contribs->n0)); + + // move the coeffs over + while (num) { + *to_co-- = *from_co--; + --num; + } + // zero new positions + while (to_co >= coeffs) + *to_co-- = 0; + // set new start point + contribs->n0 = new_n0; + if (widest > 12) { + int mod; + + // how far will be read in the n_coeff loop (which depends on the widest + // count mod4); + mod = widest & 3; + stop_range = (((contribs->n1 - contribs->n0 + 1) - mod + 3) & ~3) + mod; + + // the n_coeff loops do a minimum amount of coeffs, so factor that in! + if (stop_range < (8 + mod)) + stop_range = 8 + mod; + } + } + } + --contribs; + coeffs -= widest; + } + } + + return widest; +#undef STBIR_MOVE_1 +#undef STBIR_MOVE_2 +#undef STBIR_MOVE_4 +} + +static void stbir__calculate_filters(stbir__sampler *samp, stbir__sampler *other_axis_for_pivot, + void *user_data STBIR_ONLY_PROFILE_BUILD_GET_INFO) { + int n; + float scale = samp->scale_info.scale; + stbir__kernel_callback *kernel = samp->filter_kernel; + stbir__support_callback *support = samp->filter_support; + float inv_scale = samp->scale_info.inv_scale; + int input_full_size = samp->scale_info.input_full_size; + int gather_num_contributors = samp->num_contributors; + stbir__contributors *gather_contributors = samp->contributors; + float *gather_coeffs = samp->coefficients; + int gather_coefficient_width = samp->coefficient_width; + + switch (samp->is_gather) { + case 1: // gather upsample + { + float out_pixels_radius = support(inv_scale, user_data) * scale; + + stbir__calculate_coefficients_for_gather_upsample( + out_pixels_radius, kernel, &samp->scale_info, gather_num_contributors, + gather_contributors, gather_coeffs, gather_coefficient_width, samp->edge, user_data); + + STBIR_PROFILE_BUILD_START(cleanup); + stbir__cleanup_gathered_coefficients(samp->edge, &samp->extent_info, &samp->scale_info, + gather_num_contributors, gather_contributors, + gather_coeffs, gather_coefficient_width); + STBIR_PROFILE_BUILD_END(cleanup); + } break; + + case 0: // scatter downsample (only on vertical) + case 2: // gather downsample + { + float in_pixels_radius = support(scale, user_data) * inv_scale; + int filter_pixel_margin = samp->filter_pixel_margin; + int input_end = input_full_size + filter_pixel_margin; + + // if this is a scatter, we do a downsample gather to get the coeffs, and then pivot after + if (!samp->is_gather) { + // check if we are using the same gather downsample on the horizontal as this vertical, + // if so, then we don't have to generate them, we can just pivot from the horizontal. + if (other_axis_for_pivot) { + gather_contributors = other_axis_for_pivot->contributors; + gather_coeffs = other_axis_for_pivot->coefficients; + gather_coefficient_width = other_axis_for_pivot->coefficient_width; + gather_num_contributors = other_axis_for_pivot->num_contributors; + samp->extent_info.lowest = other_axis_for_pivot->extent_info.lowest; + samp->extent_info.highest = other_axis_for_pivot->extent_info.highest; + samp->extent_info.widest = other_axis_for_pivot->extent_info.widest; + goto jump_right_to_pivot; + } + + gather_contributors = samp->gather_prescatter_contributors; + gather_coeffs = samp->gather_prescatter_coefficients; + gather_coefficient_width = samp->gather_prescatter_coefficient_width; + gather_num_contributors = samp->gather_prescatter_num_contributors; + } + + stbir__calculate_coefficients_for_gather_downsample( + -filter_pixel_margin, input_end, in_pixels_radius, kernel, &samp->scale_info, + gather_coefficient_width, gather_num_contributors, gather_contributors, gather_coeffs, + user_data); + + STBIR_PROFILE_BUILD_START(cleanup); + stbir__cleanup_gathered_coefficients(samp->edge, &samp->extent_info, &samp->scale_info, + gather_num_contributors, gather_contributors, + gather_coeffs, gather_coefficient_width); + STBIR_PROFILE_BUILD_END(cleanup); + + if (!samp->is_gather) { + // if this is a scatter (vertical only), then we need to pivot the coeffs + stbir__contributors *scatter_contributors; + int highest_set; + + jump_right_to_pivot: + + STBIR_PROFILE_BUILD_START(pivot); + + highest_set = (-filter_pixel_margin) - 1; + for (n = 0; n < gather_num_contributors; n++) { + int k; + int gn0 = gather_contributors->n0, gn1 = gather_contributors->n1; + int scatter_coefficient_width = samp->coefficient_width; + float *scatter_coeffs = + samp->coefficients + (gn0 + filter_pixel_margin) * scatter_coefficient_width; + float *g_coeffs = gather_coeffs; + scatter_contributors = samp->contributors + (gn0 + filter_pixel_margin); + + for (k = gn0; k <= gn1; k++) { + float gc = *g_coeffs++; + + // skip zero and denormals - must skip zeros to avoid adding coeffs beyond + // scatter_coefficient_width + // (which happens when pivoting from horizontal, which might have dummy zeros) + if (((gc >= stbir__small_float) || (gc <= -stbir__small_float))) { + if ((k > highest_set) || + (scatter_contributors->n0 > scatter_contributors->n1)) { + { + // if we are skipping over several contributors, we need to clear + // the skipped ones + stbir__contributors *clear_contributors = + samp->contributors + (highest_set + filter_pixel_margin + 1); + while (clear_contributors < scatter_contributors) { + clear_contributors->n0 = 0; + clear_contributors->n1 = -1; + ++clear_contributors; + } + } + scatter_contributors->n0 = n; + scatter_contributors->n1 = n; + scatter_coeffs[0] = gc; + highest_set = k; + } else { + stbir__insert_coeff(scatter_contributors, scatter_coeffs, n, gc, + scatter_coefficient_width); + } + STBIR_ASSERT((scatter_contributors->n1 - scatter_contributors->n0 + 1) <= + scatter_coefficient_width); + } + ++scatter_contributors; + scatter_coeffs += scatter_coefficient_width; + } + + ++gather_contributors; + gather_coeffs += gather_coefficient_width; + } + + // now clear any unset contribs + { + stbir__contributors *clear_contributors = + samp->contributors + (highest_set + filter_pixel_margin + 1); + stbir__contributors *end_contributors = samp->contributors + samp->num_contributors; + while (clear_contributors < end_contributors) { + clear_contributors->n0 = 0; + clear_contributors->n1 = -1; + ++clear_contributors; + } + } + + STBIR_PROFILE_BUILD_END(pivot); + } + } break; + } +} + +//======================================================================================================== +// scanline decoders and encoders + +#define stbir__coder_min_num 1 +#define STB_IMAGE_RESIZE_DO_CODERS +#include STBIR__HEADER_FILENAME + +#define stbir__decode_suffix BGRA +#define stbir__decode_swizzle +#define stbir__decode_order0 2 +#define stbir__decode_order1 1 +#define stbir__decode_order2 0 +#define stbir__decode_order3 3 +#define stbir__encode_order0 2 +#define stbir__encode_order1 1 +#define stbir__encode_order2 0 +#define stbir__encode_order3 3 +#define stbir__coder_min_num 4 +#define STB_IMAGE_RESIZE_DO_CODERS +#include STBIR__HEADER_FILENAME + +#define stbir__decode_suffix ARGB +#define stbir__decode_swizzle +#define stbir__decode_order0 1 +#define stbir__decode_order1 2 +#define stbir__decode_order2 3 +#define stbir__decode_order3 0 +#define stbir__encode_order0 3 +#define stbir__encode_order1 0 +#define stbir__encode_order2 1 +#define stbir__encode_order3 2 +#define stbir__coder_min_num 4 +#define STB_IMAGE_RESIZE_DO_CODERS +#include STBIR__HEADER_FILENAME + +#define stbir__decode_suffix ABGR +#define stbir__decode_swizzle +#define stbir__decode_order0 3 +#define stbir__decode_order1 2 +#define stbir__decode_order2 1 +#define stbir__decode_order3 0 +#define stbir__encode_order0 3 +#define stbir__encode_order1 2 +#define stbir__encode_order2 1 +#define stbir__encode_order3 0 +#define stbir__coder_min_num 4 +#define STB_IMAGE_RESIZE_DO_CODERS +#include STBIR__HEADER_FILENAME + +#define stbir__decode_suffix AR +#define stbir__decode_swizzle +#define stbir__decode_order0 1 +#define stbir__decode_order1 0 +#define stbir__decode_order2 3 +#define stbir__decode_order3 2 +#define stbir__encode_order0 1 +#define stbir__encode_order1 0 +#define stbir__encode_order2 3 +#define stbir__encode_order3 2 +#define stbir__coder_min_num 2 +#define STB_IMAGE_RESIZE_DO_CODERS +#include STBIR__HEADER_FILENAME + +// fancy alpha means we expand to keep both premultipied and non-premultiplied color channels +static void stbir__fancy_alpha_weight_4ch(float *out_buffer, int width_times_channels) { + float STBIR_STREAMOUT_PTR(*) out = out_buffer; + float const *end_decode = + out_buffer + (width_times_channels / 4) * 7; // decode buffer aligned to end of out_buffer + float STBIR_STREAMOUT_PTR(*) decode = (float *)end_decode - width_times_channels; + + // fancy alpha is stored internally as R G B A Rpm Gpm Bpm + +#ifdef STBIR_SIMD + +#ifdef STBIR_SIMD8 + decode += 16; + STBIR_NO_UNROLL_LOOP_START + while (decode <= end_decode) { + stbir__simdf8 d0, d1, a0, a1, p0, p1; + STBIR_NO_UNROLL(decode); + stbir__simdf8_load(d0, decode - 16); + stbir__simdf8_load(d1, decode - 16 + 8); + stbir__simdf8_0123to33333333(a0, d0); + stbir__simdf8_0123to33333333(a1, d1); + stbir__simdf8_mult(p0, a0, d0); + stbir__simdf8_mult(p1, a1, d1); + stbir__simdf8_bot4s(a0, d0, p0); + stbir__simdf8_bot4s(a1, d1, p1); + stbir__simdf8_top4s(d0, d0, p0); + stbir__simdf8_top4s(d1, d1, p1); + stbir__simdf8_store(out, a0); + stbir__simdf8_store(out + 7, d0); + stbir__simdf8_store(out + 14, a1); + stbir__simdf8_store(out + 21, d1); + decode += 16; + out += 28; + } + decode -= 16; +#else + decode += 8; + STBIR_NO_UNROLL_LOOP_START + while (decode <= end_decode) { + stbir__simdf d0, a0, d1, a1, p0, p1; + STBIR_NO_UNROLL(decode); + stbir__simdf_load(d0, decode - 8); + stbir__simdf_load(d1, decode - 8 + 4); + stbir__simdf_0123to3333(a0, d0); + stbir__simdf_0123to3333(a1, d1); + stbir__simdf_mult(p0, a0, d0); + stbir__simdf_mult(p1, a1, d1); + stbir__simdf_store(out, d0); + stbir__simdf_store(out + 4, p0); + stbir__simdf_store(out + 7, d1); + stbir__simdf_store(out + 7 + 4, p1); + decode += 8; + out += 14; + } + decode -= 8; +#endif + +// might be one last odd pixel +#ifdef STBIR_SIMD8 + STBIR_NO_UNROLL_LOOP_START + while (decode < end_decode) +#else + if (decode < end_decode) +#endif + { + stbir__simdf d, a, p; + STBIR_NO_UNROLL(decode); + stbir__simdf_load(d, decode); + stbir__simdf_0123to3333(a, d); + stbir__simdf_mult(p, a, d); + stbir__simdf_store(out, d); + stbir__simdf_store(out + 4, p); + decode += 4; + out += 7; + } + +#else + + while (decode < end_decode) { + float r = decode[0], g = decode[1], b = decode[2], alpha = decode[3]; + out[0] = r; + out[1] = g; + out[2] = b; + out[3] = alpha; + out[4] = r * alpha; + out[5] = g * alpha; + out[6] = b * alpha; + out += 7; + decode += 4; + } + +#endif +} + +static void stbir__fancy_alpha_weight_2ch(float *out_buffer, int width_times_channels) { + float STBIR_STREAMOUT_PTR(*) out = out_buffer; + float const *end_decode = out_buffer + (width_times_channels / 2) * 3; + float STBIR_STREAMOUT_PTR(*) decode = (float *)end_decode - width_times_channels; + + // for fancy alpha, turns into: [X A Xpm][X A Xpm],etc + +#ifdef STBIR_SIMD + + decode += 8; + if (decode <= end_decode) { + STBIR_NO_UNROLL_LOOP_START + do { +#ifdef STBIR_SIMD8 + stbir__simdf8 d0, a0, p0; + STBIR_NO_UNROLL(decode); + stbir__simdf8_load(d0, decode - 8); + stbir__simdf8_0123to11331133(p0, d0); + stbir__simdf8_0123to00220022(a0, d0); + stbir__simdf8_mult(p0, p0, a0); + + stbir__simdf_store2(out, stbir__if_simdf8_cast_to_simdf4(d0)); + stbir__simdf_store(out + 2, stbir__if_simdf8_cast_to_simdf4(p0)); + stbir__simdf_store2h(out + 3, stbir__if_simdf8_cast_to_simdf4(d0)); + + stbir__simdf_store2(out + 6, stbir__simdf8_gettop4(d0)); + stbir__simdf_store(out + 8, stbir__simdf8_gettop4(p0)); + stbir__simdf_store2h(out + 9, stbir__simdf8_gettop4(d0)); +#else + stbir__simdf d0, a0, d1, a1, p0, p1; + STBIR_NO_UNROLL(decode); + stbir__simdf_load(d0, decode - 8); + stbir__simdf_load(d1, decode - 8 + 4); + stbir__simdf_0123to1133(p0, d0); + stbir__simdf_0123to1133(p1, d1); + stbir__simdf_0123to0022(a0, d0); + stbir__simdf_0123to0022(a1, d1); + stbir__simdf_mult(p0, p0, a0); + stbir__simdf_mult(p1, p1, a1); + + stbir__simdf_store2(out, d0); + stbir__simdf_store(out + 2, p0); + stbir__simdf_store2h(out + 3, d0); + + stbir__simdf_store2(out + 6, d1); + stbir__simdf_store(out + 8, p1); + stbir__simdf_store2h(out + 9, d1); +#endif + decode += 8; + out += 12; + } while (decode <= end_decode); + } + decode -= 8; +#endif + + STBIR_SIMD_NO_UNROLL_LOOP_START + while (decode < end_decode) { + float x = decode[0], y = decode[1]; + STBIR_SIMD_NO_UNROLL(decode); + out[0] = x; + out[1] = y; + out[2] = x * y; + out += 3; + decode += 2; + } +} + +static void stbir__fancy_alpha_unweight_4ch(float *encode_buffer, int width_times_channels) { + float STBIR_SIMD_STREAMOUT_PTR(*) encode = encode_buffer; + float STBIR_SIMD_STREAMOUT_PTR(*) input = encode_buffer; + float const *end_output = encode_buffer + width_times_channels; + + // fancy RGBA is stored internally as R G B A Rpm Gpm Bpm + + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + float alpha = input[3]; +#ifdef STBIR_SIMD + stbir__simdf i, ia; + STBIR_SIMD_NO_UNROLL(encode); + if (alpha < stbir__small_float) { + stbir__simdf_load(i, input); + stbir__simdf_store(encode, i); + } else { + stbir__simdf_load1frep4(ia, 1.0f / alpha); + stbir__simdf_load(i, input + 4); + stbir__simdf_mult(i, i, ia); + stbir__simdf_store(encode, i); + encode[3] = alpha; + } +#else + if (alpha < stbir__small_float) { + encode[0] = input[0]; + encode[1] = input[1]; + encode[2] = input[2]; + } else { + float ialpha = 1.0f / alpha; + encode[0] = input[4] * ialpha; + encode[1] = input[5] * ialpha; + encode[2] = input[6] * ialpha; + } + encode[3] = alpha; +#endif + + input += 7; + encode += 4; + } while (encode < end_output); +} + +// format: [X A Xpm][X A Xpm] etc +static void stbir__fancy_alpha_unweight_2ch(float *encode_buffer, int width_times_channels) { + float STBIR_SIMD_STREAMOUT_PTR(*) encode = encode_buffer; + float STBIR_SIMD_STREAMOUT_PTR(*) input = encode_buffer; + float const *end_output = encode_buffer + width_times_channels; + + do { + float alpha = input[1]; + encode[0] = input[0]; + if (alpha >= stbir__small_float) + encode[0] = input[2] / alpha; + encode[1] = alpha; + + input += 3; + encode += 2; + } while (encode < end_output); +} + +static void stbir__simple_alpha_weight_4ch(float *decode_buffer, int width_times_channels) { + float STBIR_STREAMOUT_PTR(*) decode = decode_buffer; + float const *end_decode = decode_buffer + width_times_channels; + +#ifdef STBIR_SIMD + { + decode += 2 * stbir__simdfX_float_count; + STBIR_NO_UNROLL_LOOP_START + while (decode <= end_decode) { + stbir__simdfX d0, a0, d1, a1; + STBIR_NO_UNROLL(decode); + stbir__simdfX_load(d0, decode - 2 * stbir__simdfX_float_count); + stbir__simdfX_load(d1, + decode - 2 * stbir__simdfX_float_count + stbir__simdfX_float_count); + stbir__simdfX_aaa1(a0, d0, STBIR_onesX); + stbir__simdfX_aaa1(a1, d1, STBIR_onesX); + stbir__simdfX_mult(d0, d0, a0); + stbir__simdfX_mult(d1, d1, a1); + stbir__simdfX_store(decode - 2 * stbir__simdfX_float_count, d0); + stbir__simdfX_store(decode - 2 * stbir__simdfX_float_count + stbir__simdfX_float_count, + d1); + decode += 2 * stbir__simdfX_float_count; + } + decode -= 2 * stbir__simdfX_float_count; + +// few last pixels remnants +#ifdef STBIR_SIMD8 + STBIR_NO_UNROLL_LOOP_START + while (decode < end_decode) +#else + if (decode < end_decode) +#endif + { + stbir__simdf d, a; + stbir__simdf_load(d, decode); + stbir__simdf_aaa1(a, d, STBIR__CONSTF(STBIR_ones)); + stbir__simdf_mult(d, d, a); + stbir__simdf_store(decode, d); + decode += 4; + } + } + +#else + + while (decode < end_decode) { + float alpha = decode[3]; + decode[0] *= alpha; + decode[1] *= alpha; + decode[2] *= alpha; + decode += 4; + } + +#endif +} + +static void stbir__simple_alpha_weight_2ch(float *decode_buffer, int width_times_channels) { + float STBIR_STREAMOUT_PTR(*) decode = decode_buffer; + float const *end_decode = decode_buffer + width_times_channels; + +#ifdef STBIR_SIMD + decode += 2 * stbir__simdfX_float_count; + STBIR_NO_UNROLL_LOOP_START + while (decode <= end_decode) { + stbir__simdfX d0, a0, d1, a1; + STBIR_NO_UNROLL(decode); + stbir__simdfX_load(d0, decode - 2 * stbir__simdfX_float_count); + stbir__simdfX_load(d1, decode - 2 * stbir__simdfX_float_count + stbir__simdfX_float_count); + stbir__simdfX_a1a1(a0, d0, STBIR_onesX); + stbir__simdfX_a1a1(a1, d1, STBIR_onesX); + stbir__simdfX_mult(d0, d0, a0); + stbir__simdfX_mult(d1, d1, a1); + stbir__simdfX_store(decode - 2 * stbir__simdfX_float_count, d0); + stbir__simdfX_store(decode - 2 * stbir__simdfX_float_count + stbir__simdfX_float_count, d1); + decode += 2 * stbir__simdfX_float_count; + } + decode -= 2 * stbir__simdfX_float_count; +#endif + + STBIR_SIMD_NO_UNROLL_LOOP_START + while (decode < end_decode) { + float alpha = decode[1]; + STBIR_SIMD_NO_UNROLL(decode); + decode[0] *= alpha; + decode += 2; + } +} + +static void stbir__simple_alpha_unweight_4ch(float *encode_buffer, int width_times_channels) { + float STBIR_SIMD_STREAMOUT_PTR(*) encode = encode_buffer; + float const *end_output = encode_buffer + width_times_channels; + + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + float alpha = encode[3]; + +#ifdef STBIR_SIMD + stbir__simdf i, ia; + STBIR_SIMD_NO_UNROLL(encode); + if (alpha >= stbir__small_float) { + stbir__simdf_load1frep4(ia, 1.0f / alpha); + stbir__simdf_load(i, encode); + stbir__simdf_mult(i, i, ia); + stbir__simdf_store(encode, i); + encode[3] = alpha; + } +#else + if (alpha >= stbir__small_float) { + float ialpha = 1.0f / alpha; + encode[0] *= ialpha; + encode[1] *= ialpha; + encode[2] *= ialpha; + } +#endif + encode += 4; + } while (encode < end_output); +} + +static void stbir__simple_alpha_unweight_2ch(float *encode_buffer, int width_times_channels) { + float STBIR_SIMD_STREAMOUT_PTR(*) encode = encode_buffer; + float const *end_output = encode_buffer + width_times_channels; + + do { + float alpha = encode[1]; + if (alpha >= stbir__small_float) + encode[0] /= alpha; + encode += 2; + } while (encode < end_output); +} + +// only used in RGB->BGR or BGR->RGB +static void stbir__simple_flip_3ch(float *decode_buffer, int width_times_channels) { + float STBIR_STREAMOUT_PTR(*) decode = decode_buffer; + float const *end_decode = decode_buffer + width_times_channels; + +#ifdef STBIR_SIMD +#ifdef stbir__simdf_swiz2 // do we have two argument swizzles? + end_decode -= 12; + STBIR_NO_UNROLL_LOOP_START + while (decode <= end_decode) { + // on arm64 8 instructions, no overlapping stores + stbir__simdf a, b, c, na, nb; + STBIR_SIMD_NO_UNROLL(decode); + stbir__simdf_load(a, decode); + stbir__simdf_load(b, decode + 4); + stbir__simdf_load(c, decode + 8); + + na = stbir__simdf_swiz2(a, b, 2, 1, 0, 5); + b = stbir__simdf_swiz2(a, b, 4, 3, 6, 7); + nb = stbir__simdf_swiz2(b, c, 0, 1, 4, 3); + c = stbir__simdf_swiz2(b, c, 2, 7, 6, 5); + + stbir__simdf_store(decode, na); + stbir__simdf_store(decode + 4, nb); + stbir__simdf_store(decode + 8, c); + decode += 12; + } + end_decode += 12; +#else + end_decode -= 24; + STBIR_NO_UNROLL_LOOP_START + while (decode <= end_decode) { + // 26 instructions on x64 + stbir__simdf a, b, c, d, e, f, g; + float i21, i23; + STBIR_SIMD_NO_UNROLL(decode); + stbir__simdf_load(a, decode); + stbir__simdf_load(b, decode + 3); + stbir__simdf_load(c, decode + 6); + stbir__simdf_load(d, decode + 9); + stbir__simdf_load(e, decode + 12); + stbir__simdf_load(f, decode + 15); + stbir__simdf_load(g, decode + 18); + + a = stbir__simdf_swiz(a, 2, 1, 0, 3); + b = stbir__simdf_swiz(b, 2, 1, 0, 3); + c = stbir__simdf_swiz(c, 2, 1, 0, 3); + d = stbir__simdf_swiz(d, 2, 1, 0, 3); + e = stbir__simdf_swiz(e, 2, 1, 0, 3); + f = stbir__simdf_swiz(f, 2, 1, 0, 3); + g = stbir__simdf_swiz(g, 2, 1, 0, 3); + + // stores overlap, need to be in order, + stbir__simdf_store(decode, a); + i21 = decode[21]; + stbir__simdf_store(decode + 3, b); + i23 = decode[23]; + stbir__simdf_store(decode + 6, c); + stbir__simdf_store(decode + 9, d); + stbir__simdf_store(decode + 12, e); + stbir__simdf_store(decode + 15, f); + stbir__simdf_store(decode + 18, g); + decode[21] = i23; + decode[23] = i21; + decode += 24; + } + end_decode += 24; +#endif +#else + end_decode -= 12; + STBIR_NO_UNROLL_LOOP_START + while (decode <= end_decode) { + // 16 instructions + float t0, t1, t2, t3; + STBIR_NO_UNROLL(decode); + t0 = decode[0]; + t1 = decode[3]; + t2 = decode[6]; + t3 = decode[9]; + decode[0] = decode[2]; + decode[3] = decode[5]; + decode[6] = decode[8]; + decode[9] = decode[11]; + decode[2] = t0; + decode[5] = t1; + decode[8] = t2; + decode[11] = t3; + decode += 12; + } + end_decode += 12; +#endif + + STBIR_NO_UNROLL_LOOP_START + while (decode < end_decode) { + float t = decode[0]; + STBIR_NO_UNROLL(decode); + decode[0] = decode[2]; + decode[2] = t; + decode += 3; + } +} + +static void stbir__decode_scanline(stbir__info const *stbir_info, int n, + float *output_buffer STBIR_ONLY_PROFILE_GET_SPLIT_INFO) { + int channels = stbir_info->channels; + int effective_channels = stbir_info->effective_channels; + int input_sample_in_bytes = stbir__type_size[stbir_info->input_type] * channels; + stbir_edge edge_horizontal = stbir_info->horizontal.edge; + stbir_edge edge_vertical = stbir_info->vertical.edge; + int row = stbir__edge_wrap(edge_vertical, n, stbir_info->vertical.scale_info.input_full_size); + const void *input_plane_data = + ((char *)stbir_info->input_data) + (size_t)row * (size_t)stbir_info->input_stride_bytes; + stbir__span const *spans = stbir_info->scanline_extents.spans; + float *full_decode_buffer = + output_buffer - stbir_info->scanline_extents.conservative.n0 * effective_channels; + + // if we are on edge_zero, and we get in here with an out of bounds n, then the calculate + // filters has failed + STBIR_ASSERT(!(edge_vertical == STBIR_EDGE_ZERO && + (n < 0 || n >= stbir_info->vertical.scale_info.input_full_size))); + + do { + float *decode_buffer; + void const *input_data; + float *end_decode; + int width_times_channels; + int width; + + if (spans->n1 < spans->n0) + break; + + width = spans->n1 + 1 - spans->n0; + decode_buffer = full_decode_buffer + spans->n0 * effective_channels; + end_decode = full_decode_buffer + (spans->n1 + 1) * effective_channels; + width_times_channels = width * channels; + + // read directly out of input plane by default + input_data = + ((char *)input_plane_data) + spans->pixel_offset_for_input * input_sample_in_bytes; + + // if we have an input callback, call it to get the input data + if (stbir_info->in_pixels_cb) { + // call the callback with a temp buffer (that they can choose to use or not). the temp + // is just right aligned memory in the decode_buffer itself + input_data = stbir_info->in_pixels_cb( + ((char *)end_decode) - (width * input_sample_in_bytes), input_plane_data, width, + spans->pixel_offset_for_input, row, stbir_info->user_data); + } + + STBIR_PROFILE_START(decode); + // convert the pixels info the float decode_buffer, (we index from end_decode, so that when + // channelsdecode_pixels((float *)end_decode - width_times_channels, width_times_channels, + input_data); + STBIR_PROFILE_END(decode); + + if (stbir_info->alpha_weight) { + STBIR_PROFILE_START(alpha); + stbir_info->alpha_weight(decode_buffer, width_times_channels); + STBIR_PROFILE_END(alpha); + } + + ++spans; + } while (spans <= (&stbir_info->scanline_extents.spans[1])); + + // handle the edge_wrap filter (all other types are handled back out at the calculate_filter + // stage) basically the idea here is that if we have the whole scanline in memory, we don't + // redecode the + // wrapped edge pixels, and instead just memcpy them from the scanline into the edge positions + if ((edge_horizontal == STBIR_EDGE_WRAP) && + (stbir_info->scanline_extents.edge_sizes[0] | stbir_info->scanline_extents.edge_sizes[1])) { + // this code only runs if we're in edge_wrap, and we're doing the entire scanline + int e, start_x[2]; + int input_full_size = stbir_info->horizontal.scale_info.input_full_size; + + start_x[0] = -stbir_info->scanline_extents.edge_sizes[0]; // left edge start x + start_x[1] = input_full_size; // right edge + + for (e = 0; e < 2; e++) { + // do each margin + int margin = stbir_info->scanline_extents.edge_sizes[e]; + if (margin) { + int x = start_x[e]; + float *marg = full_decode_buffer + x * effective_channels; + float const *src = + full_decode_buffer + + stbir__edge_wrap(edge_horizontal, x, input_full_size) * effective_channels; + STBIR_MEMCPY(marg, src, margin * effective_channels * sizeof(float)); + } + } + } +} + +//================= +// Do 1 channel horizontal routines + +#ifdef STBIR_SIMD + +#define stbir__1_coeff_only() \ + stbir__simdf tot, c; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load1(c, hc); \ + stbir__simdf_mult1_mem(tot, c, decode); + +#define stbir__2_coeff_only() \ + stbir__simdf tot, c, d; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load2z(c, hc); \ + stbir__simdf_load2(d, decode); \ + stbir__simdf_mult(tot, c, d); \ + stbir__simdf_0123to1230(c, tot); \ + stbir__simdf_add1(tot, tot, c); + +#define stbir__3_coeff_only() \ + stbir__simdf tot, c, t; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load(c, hc); \ + stbir__simdf_mult_mem(tot, c, decode); \ + stbir__simdf_0123to1230(c, tot); \ + stbir__simdf_0123to2301(t, tot); \ + stbir__simdf_add1(tot, tot, c); \ + stbir__simdf_add1(tot, tot, t); + +#define stbir__store_output_tiny() \ + stbir__simdf_store1(output, tot); \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 1; + +#define stbir__4_coeff_start() \ + stbir__simdf tot, c; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load(c, hc); \ + stbir__simdf_mult_mem(tot, c, decode); + +#define stbir__4_coeff_continue_from_4(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load(c, hc + (ofs)); \ + stbir__simdf_madd_mem(tot, tot, c, decode + (ofs)); + +#define stbir__1_coeff_remnant(ofs) \ + { \ + stbir__simdf d; \ + stbir__simdf_load1z(c, hc + (ofs)); \ + stbir__simdf_load1(d, decode + (ofs)); \ + stbir__simdf_madd(tot, tot, d, c); \ + } + +#define stbir__2_coeff_remnant(ofs) \ + { \ + stbir__simdf d; \ + stbir__simdf_load2z(c, hc + (ofs)); \ + stbir__simdf_load2(d, decode + (ofs)); \ + stbir__simdf_madd(tot, tot, d, c); \ + } + +#define stbir__3_coeff_setup() \ + stbir__simdf mask; \ + stbir__simdf_load(mask, STBIR_mask + 3); + +#define stbir__3_coeff_remnant(ofs) \ + stbir__simdf_load(c, hc + (ofs)); \ + stbir__simdf_and(c, c, mask); \ + stbir__simdf_madd_mem(tot, tot, c, decode + (ofs)); + +#define stbir__store_output() \ + stbir__simdf_0123to2301(c, tot); \ + stbir__simdf_add(tot, tot, c); \ + stbir__simdf_0123to1230(c, tot); \ + stbir__simdf_add1(tot, tot, c); \ + stbir__simdf_store1(output, tot); \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 1; + +#else + +#define stbir__1_coeff_only() \ + float tot; \ + tot = decode[0] * hc[0]; + +#define stbir__2_coeff_only() \ + float tot; \ + tot = decode[0] * hc[0]; \ + tot += decode[1] * hc[1]; + +#define stbir__3_coeff_only() \ + float tot; \ + tot = decode[0] * hc[0]; \ + tot += decode[1] * hc[1]; \ + tot += decode[2] * hc[2]; + +#define stbir__store_output_tiny() \ + output[0] = tot; \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 1; + +#define stbir__4_coeff_start() \ + float tot0, tot1, tot2, tot3; \ + tot0 = decode[0] * hc[0]; \ + tot1 = decode[1] * hc[1]; \ + tot2 = decode[2] * hc[2]; \ + tot3 = decode[3] * hc[3]; + +#define stbir__4_coeff_continue_from_4(ofs) \ + tot0 += decode[0 + (ofs)] * hc[0 + (ofs)]; \ + tot1 += decode[1 + (ofs)] * hc[1 + (ofs)]; \ + tot2 += decode[2 + (ofs)] * hc[2 + (ofs)]; \ + tot3 += decode[3 + (ofs)] * hc[3 + (ofs)]; + +#define stbir__1_coeff_remnant(ofs) tot0 += decode[0 + (ofs)] * hc[0 + (ofs)]; + +#define stbir__2_coeff_remnant(ofs) \ + tot0 += decode[0 + (ofs)] * hc[0 + (ofs)]; \ + tot1 += decode[1 + (ofs)] * hc[1 + (ofs)]; + +#define stbir__3_coeff_remnant(ofs) \ + tot0 += decode[0 + (ofs)] * hc[0 + (ofs)]; \ + tot1 += decode[1 + (ofs)] * hc[1 + (ofs)]; \ + tot2 += decode[2 + (ofs)] * hc[2 + (ofs)]; + +#define stbir__store_output() \ + output[0] = (tot0 + tot2) + (tot1 + tot3); \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 1; + +#endif + +#define STBIR__horizontal_channels 1 +#define STB_IMAGE_RESIZE_DO_HORIZONTALS +#include STBIR__HEADER_FILENAME + +//================= +// Do 2 channel horizontal routines + +#ifdef STBIR_SIMD + +#define stbir__1_coeff_only() \ + stbir__simdf tot, c, d; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load1z(c, hc); \ + stbir__simdf_0123to0011(c, c); \ + stbir__simdf_load2(d, decode); \ + stbir__simdf_mult(tot, d, c); + +#define stbir__2_coeff_only() \ + stbir__simdf tot, c; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load2(c, hc); \ + stbir__simdf_0123to0011(c, c); \ + stbir__simdf_mult_mem(tot, c, decode); + +#define stbir__3_coeff_only() \ + stbir__simdf tot, c, cs, d; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load(cs, hc); \ + stbir__simdf_0123to0011(c, cs); \ + stbir__simdf_mult_mem(tot, c, decode); \ + stbir__simdf_0123to2222(c, cs); \ + stbir__simdf_load2z(d, decode + 4); \ + stbir__simdf_madd(tot, tot, d, c); + +#define stbir__store_output_tiny() \ + stbir__simdf_0123to2301(c, tot); \ + stbir__simdf_add(tot, tot, c); \ + stbir__simdf_store2(output, tot); \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 2; + +#ifdef STBIR_SIMD8 + +#define stbir__4_coeff_start() \ + stbir__simdf8 tot0, c, cs; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf8_load4b(cs, hc); \ + stbir__simdf8_0123to00112233(c, cs); \ + stbir__simdf8_mult_mem(tot0, c, decode); + +#define stbir__4_coeff_continue_from_4(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf8_load4b(cs, hc + (ofs)); \ + stbir__simdf8_0123to00112233(c, cs); \ + stbir__simdf8_madd_mem(tot0, tot0, c, decode + (ofs) * 2); + +#define stbir__1_coeff_remnant(ofs) \ + { \ + stbir__simdf t, d; \ + stbir__simdf_load1z(t, hc + (ofs)); \ + stbir__simdf_load2(d, decode + (ofs) * 2); \ + stbir__simdf_0123to0011(t, t); \ + stbir__simdf_mult(t, t, d); \ + stbir__simdf8_add4(tot0, tot0, t); \ + } + +#define stbir__2_coeff_remnant(ofs) \ + { \ + stbir__simdf t; \ + stbir__simdf_load2(t, hc + (ofs)); \ + stbir__simdf_0123to0011(t, t); \ + stbir__simdf_mult_mem(t, t, decode + (ofs) * 2); \ + stbir__simdf8_add4(tot0, tot0, t); \ + } + +#define stbir__3_coeff_remnant(ofs) \ + { \ + stbir__simdf8 d; \ + stbir__simdf8_load4b(cs, hc + (ofs)); \ + stbir__simdf8_0123to00112233(c, cs); \ + stbir__simdf8_load6z(d, decode + (ofs) * 2); \ + stbir__simdf8_madd(tot0, tot0, c, d); \ + } + +#define stbir__store_output() \ + { \ + stbir__simdf t, d; \ + stbir__simdf8_add4halves(t, stbir__if_simdf8_cast_to_simdf4(tot0), tot0); \ + stbir__simdf_0123to2301(d, t); \ + stbir__simdf_add(t, t, d); \ + stbir__simdf_store2(output, t); \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 2; \ + } + +#else + +#define stbir__4_coeff_start() \ + stbir__simdf tot0, tot1, c, cs; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load(cs, hc); \ + stbir__simdf_0123to0011(c, cs); \ + stbir__simdf_mult_mem(tot0, c, decode); \ + stbir__simdf_0123to2233(c, cs); \ + stbir__simdf_mult_mem(tot1, c, decode + 4); + +#define stbir__4_coeff_continue_from_4(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load(cs, hc + (ofs)); \ + stbir__simdf_0123to0011(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + (ofs) * 2); \ + stbir__simdf_0123to2233(c, cs); \ + stbir__simdf_madd_mem(tot1, tot1, c, decode + (ofs) * 2 + 4); + +#define stbir__1_coeff_remnant(ofs) \ + { \ + stbir__simdf d; \ + stbir__simdf_load1z(cs, hc + (ofs)); \ + stbir__simdf_0123to0011(c, cs); \ + stbir__simdf_load2(d, decode + (ofs) * 2); \ + stbir__simdf_madd(tot0, tot0, d, c); \ + } + +#define stbir__2_coeff_remnant(ofs) \ + stbir__simdf_load2(cs, hc + (ofs)); \ + stbir__simdf_0123to0011(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + (ofs) * 2); + +#define stbir__3_coeff_remnant(ofs) \ + { \ + stbir__simdf d; \ + stbir__simdf_load(cs, hc + (ofs)); \ + stbir__simdf_0123to0011(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + (ofs) * 2); \ + stbir__simdf_0123to2222(c, cs); \ + stbir__simdf_load2z(d, decode + (ofs) * 2 + 4); \ + stbir__simdf_madd(tot1, tot1, d, c); \ + } + +#define stbir__store_output() \ + stbir__simdf_add(tot0, tot0, tot1); \ + stbir__simdf_0123to2301(c, tot0); \ + stbir__simdf_add(tot0, tot0, c); \ + stbir__simdf_store2(output, tot0); \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 2; + +#endif + +#else + +#define stbir__1_coeff_only() \ + float tota, totb, c; \ + c = hc[0]; \ + tota = decode[0] * c; \ + totb = decode[1] * c; + +#define stbir__2_coeff_only() \ + float tota, totb, c; \ + c = hc[0]; \ + tota = decode[0] * c; \ + totb = decode[1] * c; \ + c = hc[1]; \ + tota += decode[2] * c; \ + totb += decode[3] * c; + +// this weird order of add matches the simd +#define stbir__3_coeff_only() \ + float tota, totb, c; \ + c = hc[0]; \ + tota = decode[0] * c; \ + totb = decode[1] * c; \ + c = hc[2]; \ + tota += decode[4] * c; \ + totb += decode[5] * c; \ + c = hc[1]; \ + tota += decode[2] * c; \ + totb += decode[3] * c; + +#define stbir__store_output_tiny() \ + output[0] = tota; \ + output[1] = totb; \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 2; + +#define stbir__4_coeff_start() \ + float tota0, tota1, tota2, tota3, totb0, totb1, totb2, totb3, c; \ + c = hc[0]; \ + tota0 = decode[0] * c; \ + totb0 = decode[1] * c; \ + c = hc[1]; \ + tota1 = decode[2] * c; \ + totb1 = decode[3] * c; \ + c = hc[2]; \ + tota2 = decode[4] * c; \ + totb2 = decode[5] * c; \ + c = hc[3]; \ + tota3 = decode[6] * c; \ + totb3 = decode[7] * c; + +#define stbir__4_coeff_continue_from_4(ofs) \ + c = hc[0 + (ofs)]; \ + tota0 += decode[0 + (ofs) * 2] * c; \ + totb0 += decode[1 + (ofs) * 2] * c; \ + c = hc[1 + (ofs)]; \ + tota1 += decode[2 + (ofs) * 2] * c; \ + totb1 += decode[3 + (ofs) * 2] * c; \ + c = hc[2 + (ofs)]; \ + tota2 += decode[4 + (ofs) * 2] * c; \ + totb2 += decode[5 + (ofs) * 2] * c; \ + c = hc[3 + (ofs)]; \ + tota3 += decode[6 + (ofs) * 2] * c; \ + totb3 += decode[7 + (ofs) * 2] * c; + +#define stbir__1_coeff_remnant(ofs) \ + c = hc[0 + (ofs)]; \ + tota0 += decode[0 + (ofs) * 2] * c; \ + totb0 += decode[1 + (ofs) * 2] * c; + +#define stbir__2_coeff_remnant(ofs) \ + c = hc[0 + (ofs)]; \ + tota0 += decode[0 + (ofs) * 2] * c; \ + totb0 += decode[1 + (ofs) * 2] * c; \ + c = hc[1 + (ofs)]; \ + tota1 += decode[2 + (ofs) * 2] * c; \ + totb1 += decode[3 + (ofs) * 2] * c; + +#define stbir__3_coeff_remnant(ofs) \ + c = hc[0 + (ofs)]; \ + tota0 += decode[0 + (ofs) * 2] * c; \ + totb0 += decode[1 + (ofs) * 2] * c; \ + c = hc[1 + (ofs)]; \ + tota1 += decode[2 + (ofs) * 2] * c; \ + totb1 += decode[3 + (ofs) * 2] * c; \ + c = hc[2 + (ofs)]; \ + tota2 += decode[4 + (ofs) * 2] * c; \ + totb2 += decode[5 + (ofs) * 2] * c; + +#define stbir__store_output() \ + output[0] = (tota0 + tota2) + (tota1 + tota3); \ + output[1] = (totb0 + totb2) + (totb1 + totb3); \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 2; + +#endif + +#define STBIR__horizontal_channels 2 +#define STB_IMAGE_RESIZE_DO_HORIZONTALS +#include STBIR__HEADER_FILENAME + +//================= +// Do 3 channel horizontal routines + +#ifdef STBIR_SIMD + +#define stbir__1_coeff_only() \ + stbir__simdf tot, c, d; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load1z(c, hc); \ + stbir__simdf_0123to0001(c, c); \ + stbir__simdf_load(d, decode); \ + stbir__simdf_mult(tot, d, c); + +#define stbir__2_coeff_only() \ + stbir__simdf tot, c, cs, d; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load2(cs, hc); \ + stbir__simdf_0123to0000(c, cs); \ + stbir__simdf_load(d, decode); \ + stbir__simdf_mult(tot, d, c); \ + stbir__simdf_0123to1111(c, cs); \ + stbir__simdf_load(d, decode + 3); \ + stbir__simdf_madd(tot, tot, d, c); + +#define stbir__3_coeff_only() \ + stbir__simdf tot, c, d, cs; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load(cs, hc); \ + stbir__simdf_0123to0000(c, cs); \ + stbir__simdf_load(d, decode); \ + stbir__simdf_mult(tot, d, c); \ + stbir__simdf_0123to1111(c, cs); \ + stbir__simdf_load(d, decode + 3); \ + stbir__simdf_madd(tot, tot, d, c); \ + stbir__simdf_0123to2222(c, cs); \ + stbir__simdf_load(d, decode + 6); \ + stbir__simdf_madd(tot, tot, d, c); + +#define stbir__store_output_tiny() \ + stbir__simdf_store2(output, tot); \ + stbir__simdf_0123to2301(tot, tot); \ + stbir__simdf_store1(output + 2, tot); \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 3; + +#ifdef STBIR_SIMD8 + +// we're loading from the XXXYYY decode by -1 to get the XXXYYY into different halves of the AVX reg +// fyi +#define stbir__4_coeff_start() \ + stbir__simdf8 tot0, tot1, c, cs; \ + stbir__simdf t; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf8_load4b(cs, hc); \ + stbir__simdf8_0123to00001111(c, cs); \ + stbir__simdf8_mult_mem(tot0, c, decode - 1); \ + stbir__simdf8_0123to22223333(c, cs); \ + stbir__simdf8_mult_mem(tot1, c, decode + 6 - 1); + +#define stbir__4_coeff_continue_from_4(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf8_load4b(cs, hc + (ofs)); \ + stbir__simdf8_0123to00001111(c, cs); \ + stbir__simdf8_madd_mem(tot0, tot0, c, decode + (ofs) * 3 - 1); \ + stbir__simdf8_0123to22223333(c, cs); \ + stbir__simdf8_madd_mem(tot1, tot1, c, decode + (ofs) * 3 + 6 - 1); + +#define stbir__1_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load1rep4(t, hc + (ofs)); \ + stbir__simdf8_madd_mem4(tot0, tot0, t, decode + (ofs) * 3 - 1); + +#define stbir__2_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf8_load4b(cs, hc + (ofs)-2); \ + stbir__simdf8_0123to22223333(c, cs); \ + stbir__simdf8_madd_mem(tot0, tot0, c, decode + (ofs) * 3 - 1); + +#define stbir__3_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf8_load4b(cs, hc + (ofs)); \ + stbir__simdf8_0123to00001111(c, cs); \ + stbir__simdf8_madd_mem(tot0, tot0, c, decode + (ofs) * 3 - 1); \ + stbir__simdf8_0123to2222(t, cs); \ + stbir__simdf8_madd_mem4(tot1, tot1, t, decode + (ofs) * 3 + 6 - 1); + +#define stbir__store_output() \ + stbir__simdf8_add(tot0, tot0, tot1); \ + stbir__simdf_0123to1230(t, stbir__if_simdf8_cast_to_simdf4(tot0)); \ + stbir__simdf8_add4halves(t, t, tot0); \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 3; \ + if (output < output_end) { \ + stbir__simdf_store(output - 3, t); \ + continue; \ + } \ + { \ + stbir__simdf tt; \ + stbir__simdf_0123to2301(tt, t); \ + stbir__simdf_store2(output - 3, t); \ + stbir__simdf_store1(output + 2 - 3, tt); \ + } \ + break; + +#else + +#define stbir__4_coeff_start() \ + stbir__simdf tot0, tot1, tot2, c, cs; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load(cs, hc); \ + stbir__simdf_0123to0001(c, cs); \ + stbir__simdf_mult_mem(tot0, c, decode); \ + stbir__simdf_0123to1122(c, cs); \ + stbir__simdf_mult_mem(tot1, c, decode + 4); \ + stbir__simdf_0123to2333(c, cs); \ + stbir__simdf_mult_mem(tot2, c, decode + 8); + +#define stbir__4_coeff_continue_from_4(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load(cs, hc + (ofs)); \ + stbir__simdf_0123to0001(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + (ofs) * 3); \ + stbir__simdf_0123to1122(c, cs); \ + stbir__simdf_madd_mem(tot1, tot1, c, decode + (ofs) * 3 + 4); \ + stbir__simdf_0123to2333(c, cs); \ + stbir__simdf_madd_mem(tot2, tot2, c, decode + (ofs) * 3 + 8); + +#define stbir__1_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load1z(c, hc + (ofs)); \ + stbir__simdf_0123to0001(c, c); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + (ofs) * 3); + +#define stbir__2_coeff_remnant(ofs) \ + { \ + stbir__simdf d; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load2z(cs, hc + (ofs)); \ + stbir__simdf_0123to0001(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + (ofs) * 3); \ + stbir__simdf_0123to1122(c, cs); \ + stbir__simdf_load2z(d, decode + (ofs) * 3 + 4); \ + stbir__simdf_madd(tot1, tot1, c, d); \ + } + +#define stbir__3_coeff_remnant(ofs) \ + { \ + stbir__simdf d; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load(cs, hc + (ofs)); \ + stbir__simdf_0123to0001(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + (ofs) * 3); \ + stbir__simdf_0123to1122(c, cs); \ + stbir__simdf_madd_mem(tot1, tot1, c, decode + (ofs) * 3 + 4); \ + stbir__simdf_0123to2222(c, cs); \ + stbir__simdf_load1z(d, decode + (ofs) * 3 + 8); \ + stbir__simdf_madd(tot2, tot2, c, d); \ + } + +#define stbir__store_output() \ + stbir__simdf_0123ABCDto3ABx(c, tot0, tot1); \ + stbir__simdf_0123ABCDto23Ax(cs, tot1, tot2); \ + stbir__simdf_0123to1230(tot2, tot2); \ + stbir__simdf_add(tot0, tot0, cs); \ + stbir__simdf_add(c, c, tot2); \ + stbir__simdf_add(tot0, tot0, c); \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 3; \ + if (output < output_end) { \ + stbir__simdf_store(output - 3, tot0); \ + continue; \ + } \ + stbir__simdf_0123to2301(tot1, tot0); \ + stbir__simdf_store2(output - 3, tot0); \ + stbir__simdf_store1(output + 2 - 3, tot1); \ + break; + +#endif + +#else + +#define stbir__1_coeff_only() \ + float tot0, tot1, tot2, c; \ + c = hc[0]; \ + tot0 = decode[0] * c; \ + tot1 = decode[1] * c; \ + tot2 = decode[2] * c; + +#define stbir__2_coeff_only() \ + float tot0, tot1, tot2, c; \ + c = hc[0]; \ + tot0 = decode[0] * c; \ + tot1 = decode[1] * c; \ + tot2 = decode[2] * c; \ + c = hc[1]; \ + tot0 += decode[3] * c; \ + tot1 += decode[4] * c; \ + tot2 += decode[5] * c; + +#define stbir__3_coeff_only() \ + float tot0, tot1, tot2, c; \ + c = hc[0]; \ + tot0 = decode[0] * c; \ + tot1 = decode[1] * c; \ + tot2 = decode[2] * c; \ + c = hc[1]; \ + tot0 += decode[3] * c; \ + tot1 += decode[4] * c; \ + tot2 += decode[5] * c; \ + c = hc[2]; \ + tot0 += decode[6] * c; \ + tot1 += decode[7] * c; \ + tot2 += decode[8] * c; + +#define stbir__store_output_tiny() \ + output[0] = tot0; \ + output[1] = tot1; \ + output[2] = tot2; \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 3; + +#define stbir__4_coeff_start() \ + float tota0, tota1, tota2, totb0, totb1, totb2, totc0, totc1, totc2, totd0, totd1, totd2, c; \ + c = hc[0]; \ + tota0 = decode[0] * c; \ + tota1 = decode[1] * c; \ + tota2 = decode[2] * c; \ + c = hc[1]; \ + totb0 = decode[3] * c; \ + totb1 = decode[4] * c; \ + totb2 = decode[5] * c; \ + c = hc[2]; \ + totc0 = decode[6] * c; \ + totc1 = decode[7] * c; \ + totc2 = decode[8] * c; \ + c = hc[3]; \ + totd0 = decode[9] * c; \ + totd1 = decode[10] * c; \ + totd2 = decode[11] * c; + +#define stbir__4_coeff_continue_from_4(ofs) \ + c = hc[0 + (ofs)]; \ + tota0 += decode[0 + (ofs) * 3] * c; \ + tota1 += decode[1 + (ofs) * 3] * c; \ + tota2 += decode[2 + (ofs) * 3] * c; \ + c = hc[1 + (ofs)]; \ + totb0 += decode[3 + (ofs) * 3] * c; \ + totb1 += decode[4 + (ofs) * 3] * c; \ + totb2 += decode[5 + (ofs) * 3] * c; \ + c = hc[2 + (ofs)]; \ + totc0 += decode[6 + (ofs) * 3] * c; \ + totc1 += decode[7 + (ofs) * 3] * c; \ + totc2 += decode[8 + (ofs) * 3] * c; \ + c = hc[3 + (ofs)]; \ + totd0 += decode[9 + (ofs) * 3] * c; \ + totd1 += decode[10 + (ofs) * 3] * c; \ + totd2 += decode[11 + (ofs) * 3] * c; + +#define stbir__1_coeff_remnant(ofs) \ + c = hc[0 + (ofs)]; \ + tota0 += decode[0 + (ofs) * 3] * c; \ + tota1 += decode[1 + (ofs) * 3] * c; \ + tota2 += decode[2 + (ofs) * 3] * c; + +#define stbir__2_coeff_remnant(ofs) \ + c = hc[0 + (ofs)]; \ + tota0 += decode[0 + (ofs) * 3] * c; \ + tota1 += decode[1 + (ofs) * 3] * c; \ + tota2 += decode[2 + (ofs) * 3] * c; \ + c = hc[1 + (ofs)]; \ + totb0 += decode[3 + (ofs) * 3] * c; \ + totb1 += decode[4 + (ofs) * 3] * c; \ + totb2 += decode[5 + (ofs) * 3] * c; + +#define stbir__3_coeff_remnant(ofs) \ + c = hc[0 + (ofs)]; \ + tota0 += decode[0 + (ofs) * 3] * c; \ + tota1 += decode[1 + (ofs) * 3] * c; \ + tota2 += decode[2 + (ofs) * 3] * c; \ + c = hc[1 + (ofs)]; \ + totb0 += decode[3 + (ofs) * 3] * c; \ + totb1 += decode[4 + (ofs) * 3] * c; \ + totb2 += decode[5 + (ofs) * 3] * c; \ + c = hc[2 + (ofs)]; \ + totc0 += decode[6 + (ofs) * 3] * c; \ + totc1 += decode[7 + (ofs) * 3] * c; \ + totc2 += decode[8 + (ofs) * 3] * c; + +#define stbir__store_output() \ + output[0] = (tota0 + totc0) + (totb0 + totd0); \ + output[1] = (tota1 + totc1) + (totb1 + totd1); \ + output[2] = (tota2 + totc2) + (totb2 + totd2); \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 3; + +#endif + +#define STBIR__horizontal_channels 3 +#define STB_IMAGE_RESIZE_DO_HORIZONTALS +#include STBIR__HEADER_FILENAME + +//================= +// Do 4 channel horizontal routines + +#ifdef STBIR_SIMD + +#define stbir__1_coeff_only() \ + stbir__simdf tot, c; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load1(c, hc); \ + stbir__simdf_0123to0000(c, c); \ + stbir__simdf_mult_mem(tot, c, decode); + +#define stbir__2_coeff_only() \ + stbir__simdf tot, c, cs; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load2(cs, hc); \ + stbir__simdf_0123to0000(c, cs); \ + stbir__simdf_mult_mem(tot, c, decode); \ + stbir__simdf_0123to1111(c, cs); \ + stbir__simdf_madd_mem(tot, tot, c, decode + 4); + +#define stbir__3_coeff_only() \ + stbir__simdf tot, c, cs; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load(cs, hc); \ + stbir__simdf_0123to0000(c, cs); \ + stbir__simdf_mult_mem(tot, c, decode); \ + stbir__simdf_0123to1111(c, cs); \ + stbir__simdf_madd_mem(tot, tot, c, decode + 4); \ + stbir__simdf_0123to2222(c, cs); \ + stbir__simdf_madd_mem(tot, tot, c, decode + 8); + +#define stbir__store_output_tiny() \ + stbir__simdf_store(output, tot); \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 4; + +#ifdef STBIR_SIMD8 + +#define stbir__4_coeff_start() \ + stbir__simdf8 tot0, c, cs; \ + stbir__simdf t; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf8_load4b(cs, hc); \ + stbir__simdf8_0123to00001111(c, cs); \ + stbir__simdf8_mult_mem(tot0, c, decode); \ + stbir__simdf8_0123to22223333(c, cs); \ + stbir__simdf8_madd_mem(tot0, tot0, c, decode + 8); + +#define stbir__4_coeff_continue_from_4(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf8_load4b(cs, hc + (ofs)); \ + stbir__simdf8_0123to00001111(c, cs); \ + stbir__simdf8_madd_mem(tot0, tot0, c, decode + (ofs) * 4); \ + stbir__simdf8_0123to22223333(c, cs); \ + stbir__simdf8_madd_mem(tot0, tot0, c, decode + (ofs) * 4 + 8); + +#define stbir__1_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load1rep4(t, hc + (ofs)); \ + stbir__simdf8_madd_mem4(tot0, tot0, t, decode + (ofs) * 4); + +#define stbir__2_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf8_load4b(cs, hc + (ofs)-2); \ + stbir__simdf8_0123to22223333(c, cs); \ + stbir__simdf8_madd_mem(tot0, tot0, c, decode + (ofs) * 4); + +#define stbir__3_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf8_load4b(cs, hc + (ofs)); \ + stbir__simdf8_0123to00001111(c, cs); \ + stbir__simdf8_madd_mem(tot0, tot0, c, decode + (ofs) * 4); \ + stbir__simdf8_0123to2222(t, cs); \ + stbir__simdf8_madd_mem4(tot0, tot0, t, decode + (ofs) * 4 + 8); + +#define stbir__store_output() \ + stbir__simdf8_add4halves(t, stbir__if_simdf8_cast_to_simdf4(tot0), tot0); \ + stbir__simdf_store(output, t); \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 4; + +#else + +#define stbir__4_coeff_start() \ + stbir__simdf tot0, tot1, c, cs; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load(cs, hc); \ + stbir__simdf_0123to0000(c, cs); \ + stbir__simdf_mult_mem(tot0, c, decode); \ + stbir__simdf_0123to1111(c, cs); \ + stbir__simdf_mult_mem(tot1, c, decode + 4); \ + stbir__simdf_0123to2222(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + 8); \ + stbir__simdf_0123to3333(c, cs); \ + stbir__simdf_madd_mem(tot1, tot1, c, decode + 12); + +#define stbir__4_coeff_continue_from_4(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load(cs, hc + (ofs)); \ + stbir__simdf_0123to0000(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + (ofs) * 4); \ + stbir__simdf_0123to1111(c, cs); \ + stbir__simdf_madd_mem(tot1, tot1, c, decode + (ofs) * 4 + 4); \ + stbir__simdf_0123to2222(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + (ofs) * 4 + 8); \ + stbir__simdf_0123to3333(c, cs); \ + stbir__simdf_madd_mem(tot1, tot1, c, decode + (ofs) * 4 + 12); + +#define stbir__1_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load1(c, hc + (ofs)); \ + stbir__simdf_0123to0000(c, c); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + (ofs) * 4); + +#define stbir__2_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load2(cs, hc + (ofs)); \ + stbir__simdf_0123to0000(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + (ofs) * 4); \ + stbir__simdf_0123to1111(c, cs); \ + stbir__simdf_madd_mem(tot1, tot1, c, decode + (ofs) * 4 + 4); + +#define stbir__3_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load(cs, hc + (ofs)); \ + stbir__simdf_0123to0000(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + (ofs) * 4); \ + stbir__simdf_0123to1111(c, cs); \ + stbir__simdf_madd_mem(tot1, tot1, c, decode + (ofs) * 4 + 4); \ + stbir__simdf_0123to2222(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + (ofs) * 4 + 8); + +#define stbir__store_output() \ + stbir__simdf_add(tot0, tot0, tot1); \ + stbir__simdf_store(output, tot0); \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 4; + +#endif + +#else + +#define stbir__1_coeff_only() \ + float p0, p1, p2, p3, c; \ + STBIR_SIMD_NO_UNROLL(decode); \ + c = hc[0]; \ + p0 = decode[0] * c; \ + p1 = decode[1] * c; \ + p2 = decode[2] * c; \ + p3 = decode[3] * c; + +#define stbir__2_coeff_only() \ + float p0, p1, p2, p3, c; \ + STBIR_SIMD_NO_UNROLL(decode); \ + c = hc[0]; \ + p0 = decode[0] * c; \ + p1 = decode[1] * c; \ + p2 = decode[2] * c; \ + p3 = decode[3] * c; \ + c = hc[1]; \ + p0 += decode[4] * c; \ + p1 += decode[5] * c; \ + p2 += decode[6] * c; \ + p3 += decode[7] * c; + +#define stbir__3_coeff_only() \ + float p0, p1, p2, p3, c; \ + STBIR_SIMD_NO_UNROLL(decode); \ + c = hc[0]; \ + p0 = decode[0] * c; \ + p1 = decode[1] * c; \ + p2 = decode[2] * c; \ + p3 = decode[3] * c; \ + c = hc[1]; \ + p0 += decode[4] * c; \ + p1 += decode[5] * c; \ + p2 += decode[6] * c; \ + p3 += decode[7] * c; \ + c = hc[2]; \ + p0 += decode[8] * c; \ + p1 += decode[9] * c; \ + p2 += decode[10] * c; \ + p3 += decode[11] * c; + +#define stbir__store_output_tiny() \ + output[0] = p0; \ + output[1] = p1; \ + output[2] = p2; \ + output[3] = p3; \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 4; + +#define stbir__4_coeff_start() \ + float x0, x1, x2, x3, y0, y1, y2, y3, c; \ + STBIR_SIMD_NO_UNROLL(decode); \ + c = hc[0]; \ + x0 = decode[0] * c; \ + x1 = decode[1] * c; \ + x2 = decode[2] * c; \ + x3 = decode[3] * c; \ + c = hc[1]; \ + y0 = decode[4] * c; \ + y1 = decode[5] * c; \ + y2 = decode[6] * c; \ + y3 = decode[7] * c; \ + c = hc[2]; \ + x0 += decode[8] * c; \ + x1 += decode[9] * c; \ + x2 += decode[10] * c; \ + x3 += decode[11] * c; \ + c = hc[3]; \ + y0 += decode[12] * c; \ + y1 += decode[13] * c; \ + y2 += decode[14] * c; \ + y3 += decode[15] * c; + +#define stbir__4_coeff_continue_from_4(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + c = hc[0 + (ofs)]; \ + x0 += decode[0 + (ofs) * 4] * c; \ + x1 += decode[1 + (ofs) * 4] * c; \ + x2 += decode[2 + (ofs) * 4] * c; \ + x3 += decode[3 + (ofs) * 4] * c; \ + c = hc[1 + (ofs)]; \ + y0 += decode[4 + (ofs) * 4] * c; \ + y1 += decode[5 + (ofs) * 4] * c; \ + y2 += decode[6 + (ofs) * 4] * c; \ + y3 += decode[7 + (ofs) * 4] * c; \ + c = hc[2 + (ofs)]; \ + x0 += decode[8 + (ofs) * 4] * c; \ + x1 += decode[9 + (ofs) * 4] * c; \ + x2 += decode[10 + (ofs) * 4] * c; \ + x3 += decode[11 + (ofs) * 4] * c; \ + c = hc[3 + (ofs)]; \ + y0 += decode[12 + (ofs) * 4] * c; \ + y1 += decode[13 + (ofs) * 4] * c; \ + y2 += decode[14 + (ofs) * 4] * c; \ + y3 += decode[15 + (ofs) * 4] * c; + +#define stbir__1_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + c = hc[0 + (ofs)]; \ + x0 += decode[0 + (ofs) * 4] * c; \ + x1 += decode[1 + (ofs) * 4] * c; \ + x2 += decode[2 + (ofs) * 4] * c; \ + x3 += decode[3 + (ofs) * 4] * c; + +#define stbir__2_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + c = hc[0 + (ofs)]; \ + x0 += decode[0 + (ofs) * 4] * c; \ + x1 += decode[1 + (ofs) * 4] * c; \ + x2 += decode[2 + (ofs) * 4] * c; \ + x3 += decode[3 + (ofs) * 4] * c; \ + c = hc[1 + (ofs)]; \ + y0 += decode[4 + (ofs) * 4] * c; \ + y1 += decode[5 + (ofs) * 4] * c; \ + y2 += decode[6 + (ofs) * 4] * c; \ + y3 += decode[7 + (ofs) * 4] * c; + +#define stbir__3_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + c = hc[0 + (ofs)]; \ + x0 += decode[0 + (ofs) * 4] * c; \ + x1 += decode[1 + (ofs) * 4] * c; \ + x2 += decode[2 + (ofs) * 4] * c; \ + x3 += decode[3 + (ofs) * 4] * c; \ + c = hc[1 + (ofs)]; \ + y0 += decode[4 + (ofs) * 4] * c; \ + y1 += decode[5 + (ofs) * 4] * c; \ + y2 += decode[6 + (ofs) * 4] * c; \ + y3 += decode[7 + (ofs) * 4] * c; \ + c = hc[2 + (ofs)]; \ + x0 += decode[8 + (ofs) * 4] * c; \ + x1 += decode[9 + (ofs) * 4] * c; \ + x2 += decode[10 + (ofs) * 4] * c; \ + x3 += decode[11 + (ofs) * 4] * c; + +#define stbir__store_output() \ + output[0] = x0 + y0; \ + output[1] = x1 + y1; \ + output[2] = x2 + y2; \ + output[3] = x3 + y3; \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 4; + +#endif + +#define STBIR__horizontal_channels 4 +#define STB_IMAGE_RESIZE_DO_HORIZONTALS +#include STBIR__HEADER_FILENAME + +//================= +// Do 7 channel horizontal routines + +#ifdef STBIR_SIMD + +#define stbir__1_coeff_only() \ + stbir__simdf tot0, tot1, c; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load1(c, hc); \ + stbir__simdf_0123to0000(c, c); \ + stbir__simdf_mult_mem(tot0, c, decode); \ + stbir__simdf_mult_mem(tot1, c, decode + 3); + +#define stbir__2_coeff_only() \ + stbir__simdf tot0, tot1, c, cs; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load2(cs, hc); \ + stbir__simdf_0123to0000(c, cs); \ + stbir__simdf_mult_mem(tot0, c, decode); \ + stbir__simdf_mult_mem(tot1, c, decode + 3); \ + stbir__simdf_0123to1111(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + 7); \ + stbir__simdf_madd_mem(tot1, tot1, c, decode + 10); + +#define stbir__3_coeff_only() \ + stbir__simdf tot0, tot1, c, cs; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load(cs, hc); \ + stbir__simdf_0123to0000(c, cs); \ + stbir__simdf_mult_mem(tot0, c, decode); \ + stbir__simdf_mult_mem(tot1, c, decode + 3); \ + stbir__simdf_0123to1111(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + 7); \ + stbir__simdf_madd_mem(tot1, tot1, c, decode + 10); \ + stbir__simdf_0123to2222(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + 14); \ + stbir__simdf_madd_mem(tot1, tot1, c, decode + 17); + +#define stbir__store_output_tiny() \ + stbir__simdf_store(output + 3, tot1); \ + stbir__simdf_store(output, tot0); \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 7; + +#ifdef STBIR_SIMD8 + +#define stbir__4_coeff_start() \ + stbir__simdf8 tot0, tot1, c, cs; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf8_load4b(cs, hc); \ + stbir__simdf8_0123to00000000(c, cs); \ + stbir__simdf8_mult_mem(tot0, c, decode); \ + stbir__simdf8_0123to11111111(c, cs); \ + stbir__simdf8_mult_mem(tot1, c, decode + 7); \ + stbir__simdf8_0123to22222222(c, cs); \ + stbir__simdf8_madd_mem(tot0, tot0, c, decode + 14); \ + stbir__simdf8_0123to33333333(c, cs); \ + stbir__simdf8_madd_mem(tot1, tot1, c, decode + 21); + +#define stbir__4_coeff_continue_from_4(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf8_load4b(cs, hc + (ofs)); \ + stbir__simdf8_0123to00000000(c, cs); \ + stbir__simdf8_madd_mem(tot0, tot0, c, decode + (ofs) * 7); \ + stbir__simdf8_0123to11111111(c, cs); \ + stbir__simdf8_madd_mem(tot1, tot1, c, decode + (ofs) * 7 + 7); \ + stbir__simdf8_0123to22222222(c, cs); \ + stbir__simdf8_madd_mem(tot0, tot0, c, decode + (ofs) * 7 + 14); \ + stbir__simdf8_0123to33333333(c, cs); \ + stbir__simdf8_madd_mem(tot1, tot1, c, decode + (ofs) * 7 + 21); + +#define stbir__1_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf8_load1b(c, hc + (ofs)); \ + stbir__simdf8_madd_mem(tot0, tot0, c, decode + (ofs) * 7); + +#define stbir__2_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf8_load1b(c, hc + (ofs)); \ + stbir__simdf8_madd_mem(tot0, tot0, c, decode + (ofs) * 7); \ + stbir__simdf8_load1b(c, hc + (ofs) + 1); \ + stbir__simdf8_madd_mem(tot1, tot1, c, decode + (ofs) * 7 + 7); + +#define stbir__3_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf8_load4b(cs, hc + (ofs)); \ + stbir__simdf8_0123to00000000(c, cs); \ + stbir__simdf8_madd_mem(tot0, tot0, c, decode + (ofs) * 7); \ + stbir__simdf8_0123to11111111(c, cs); \ + stbir__simdf8_madd_mem(tot1, tot1, c, decode + (ofs) * 7 + 7); \ + stbir__simdf8_0123to22222222(c, cs); \ + stbir__simdf8_madd_mem(tot0, tot0, c, decode + (ofs) * 7 + 14); + +#define stbir__store_output() \ + stbir__simdf8_add(tot0, tot0, tot1); \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 7; \ + if (output < output_end) { \ + stbir__simdf8_store(output - 7, tot0); \ + continue; \ + } \ + stbir__simdf_store(output - 7 + 3, \ + stbir__simdf_swiz(stbir__simdf8_gettop4(tot0), 0, 0, 1, 2)); \ + stbir__simdf_store(output - 7, stbir__if_simdf8_cast_to_simdf4(tot0)); \ + break; + +#else + +#define stbir__4_coeff_start() \ + stbir__simdf tot0, tot1, tot2, tot3, c, cs; \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load(cs, hc); \ + stbir__simdf_0123to0000(c, cs); \ + stbir__simdf_mult_mem(tot0, c, decode); \ + stbir__simdf_mult_mem(tot1, c, decode + 3); \ + stbir__simdf_0123to1111(c, cs); \ + stbir__simdf_mult_mem(tot2, c, decode + 7); \ + stbir__simdf_mult_mem(tot3, c, decode + 10); \ + stbir__simdf_0123to2222(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + 14); \ + stbir__simdf_madd_mem(tot1, tot1, c, decode + 17); \ + stbir__simdf_0123to3333(c, cs); \ + stbir__simdf_madd_mem(tot2, tot2, c, decode + 21); \ + stbir__simdf_madd_mem(tot3, tot3, c, decode + 24); + +#define stbir__4_coeff_continue_from_4(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load(cs, hc + (ofs)); \ + stbir__simdf_0123to0000(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + (ofs) * 7); \ + stbir__simdf_madd_mem(tot1, tot1, c, decode + (ofs) * 7 + 3); \ + stbir__simdf_0123to1111(c, cs); \ + stbir__simdf_madd_mem(tot2, tot2, c, decode + (ofs) * 7 + 7); \ + stbir__simdf_madd_mem(tot3, tot3, c, decode + (ofs) * 7 + 10); \ + stbir__simdf_0123to2222(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + (ofs) * 7 + 14); \ + stbir__simdf_madd_mem(tot1, tot1, c, decode + (ofs) * 7 + 17); \ + stbir__simdf_0123to3333(c, cs); \ + stbir__simdf_madd_mem(tot2, tot2, c, decode + (ofs) * 7 + 21); \ + stbir__simdf_madd_mem(tot3, tot3, c, decode + (ofs) * 7 + 24); + +#define stbir__1_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load1(c, hc + (ofs)); \ + stbir__simdf_0123to0000(c, c); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + (ofs) * 7); \ + stbir__simdf_madd_mem(tot1, tot1, c, decode + (ofs) * 7 + 3); + +#define stbir__2_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load2(cs, hc + (ofs)); \ + stbir__simdf_0123to0000(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + (ofs) * 7); \ + stbir__simdf_madd_mem(tot1, tot1, c, decode + (ofs) * 7 + 3); \ + stbir__simdf_0123to1111(c, cs); \ + stbir__simdf_madd_mem(tot2, tot2, c, decode + (ofs) * 7 + 7); \ + stbir__simdf_madd_mem(tot3, tot3, c, decode + (ofs) * 7 + 10); + +#define stbir__3_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + stbir__simdf_load(cs, hc + (ofs)); \ + stbir__simdf_0123to0000(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + (ofs) * 7); \ + stbir__simdf_madd_mem(tot1, tot1, c, decode + (ofs) * 7 + 3); \ + stbir__simdf_0123to1111(c, cs); \ + stbir__simdf_madd_mem(tot2, tot2, c, decode + (ofs) * 7 + 7); \ + stbir__simdf_madd_mem(tot3, tot3, c, decode + (ofs) * 7 + 10); \ + stbir__simdf_0123to2222(c, cs); \ + stbir__simdf_madd_mem(tot0, tot0, c, decode + (ofs) * 7 + 14); \ + stbir__simdf_madd_mem(tot1, tot1, c, decode + (ofs) * 7 + 17); + +#define stbir__store_output() \ + stbir__simdf_add(tot0, tot0, tot2); \ + stbir__simdf_add(tot1, tot1, tot3); \ + stbir__simdf_store(output + 3, tot1); \ + stbir__simdf_store(output, tot0); \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 7; + +#endif + +#else + +#define stbir__1_coeff_only() \ + float tot0, tot1, tot2, tot3, tot4, tot5, tot6, c; \ + c = hc[0]; \ + tot0 = decode[0] * c; \ + tot1 = decode[1] * c; \ + tot2 = decode[2] * c; \ + tot3 = decode[3] * c; \ + tot4 = decode[4] * c; \ + tot5 = decode[5] * c; \ + tot6 = decode[6] * c; + +#define stbir__2_coeff_only() \ + float tot0, tot1, tot2, tot3, tot4, tot5, tot6, c; \ + c = hc[0]; \ + tot0 = decode[0] * c; \ + tot1 = decode[1] * c; \ + tot2 = decode[2] * c; \ + tot3 = decode[3] * c; \ + tot4 = decode[4] * c; \ + tot5 = decode[5] * c; \ + tot6 = decode[6] * c; \ + c = hc[1]; \ + tot0 += decode[7] * c; \ + tot1 += decode[8] * c; \ + tot2 += decode[9] * c; \ + tot3 += decode[10] * c; \ + tot4 += decode[11] * c; \ + tot5 += decode[12] * c; \ + tot6 += decode[13] * c; + +#define stbir__3_coeff_only() \ + float tot0, tot1, tot2, tot3, tot4, tot5, tot6, c; \ + c = hc[0]; \ + tot0 = decode[0] * c; \ + tot1 = decode[1] * c; \ + tot2 = decode[2] * c; \ + tot3 = decode[3] * c; \ + tot4 = decode[4] * c; \ + tot5 = decode[5] * c; \ + tot6 = decode[6] * c; \ + c = hc[1]; \ + tot0 += decode[7] * c; \ + tot1 += decode[8] * c; \ + tot2 += decode[9] * c; \ + tot3 += decode[10] * c; \ + tot4 += decode[11] * c; \ + tot5 += decode[12] * c; \ + tot6 += decode[13] * c; \ + c = hc[2]; \ + tot0 += decode[14] * c; \ + tot1 += decode[15] * c; \ + tot2 += decode[16] * c; \ + tot3 += decode[17] * c; \ + tot4 += decode[18] * c; \ + tot5 += decode[19] * c; \ + tot6 += decode[20] * c; + +#define stbir__store_output_tiny() \ + output[0] = tot0; \ + output[1] = tot1; \ + output[2] = tot2; \ + output[3] = tot3; \ + output[4] = tot4; \ + output[5] = tot5; \ + output[6] = tot6; \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 7; + +#define stbir__4_coeff_start() \ + float x0, x1, x2, x3, x4, x5, x6, y0, y1, y2, y3, y4, y5, y6, c; \ + STBIR_SIMD_NO_UNROLL(decode); \ + c = hc[0]; \ + x0 = decode[0] * c; \ + x1 = decode[1] * c; \ + x2 = decode[2] * c; \ + x3 = decode[3] * c; \ + x4 = decode[4] * c; \ + x5 = decode[5] * c; \ + x6 = decode[6] * c; \ + c = hc[1]; \ + y0 = decode[7] * c; \ + y1 = decode[8] * c; \ + y2 = decode[9] * c; \ + y3 = decode[10] * c; \ + y4 = decode[11] * c; \ + y5 = decode[12] * c; \ + y6 = decode[13] * c; \ + c = hc[2]; \ + x0 += decode[14] * c; \ + x1 += decode[15] * c; \ + x2 += decode[16] * c; \ + x3 += decode[17] * c; \ + x4 += decode[18] * c; \ + x5 += decode[19] * c; \ + x6 += decode[20] * c; \ + c = hc[3]; \ + y0 += decode[21] * c; \ + y1 += decode[22] * c; \ + y2 += decode[23] * c; \ + y3 += decode[24] * c; \ + y4 += decode[25] * c; \ + y5 += decode[26] * c; \ + y6 += decode[27] * c; + +#define stbir__4_coeff_continue_from_4(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + c = hc[0 + (ofs)]; \ + x0 += decode[0 + (ofs) * 7] * c; \ + x1 += decode[1 + (ofs) * 7] * c; \ + x2 += decode[2 + (ofs) * 7] * c; \ + x3 += decode[3 + (ofs) * 7] * c; \ + x4 += decode[4 + (ofs) * 7] * c; \ + x5 += decode[5 + (ofs) * 7] * c; \ + x6 += decode[6 + (ofs) * 7] * c; \ + c = hc[1 + (ofs)]; \ + y0 += decode[7 + (ofs) * 7] * c; \ + y1 += decode[8 + (ofs) * 7] * c; \ + y2 += decode[9 + (ofs) * 7] * c; \ + y3 += decode[10 + (ofs) * 7] * c; \ + y4 += decode[11 + (ofs) * 7] * c; \ + y5 += decode[12 + (ofs) * 7] * c; \ + y6 += decode[13 + (ofs) * 7] * c; \ + c = hc[2 + (ofs)]; \ + x0 += decode[14 + (ofs) * 7] * c; \ + x1 += decode[15 + (ofs) * 7] * c; \ + x2 += decode[16 + (ofs) * 7] * c; \ + x3 += decode[17 + (ofs) * 7] * c; \ + x4 += decode[18 + (ofs) * 7] * c; \ + x5 += decode[19 + (ofs) * 7] * c; \ + x6 += decode[20 + (ofs) * 7] * c; \ + c = hc[3 + (ofs)]; \ + y0 += decode[21 + (ofs) * 7] * c; \ + y1 += decode[22 + (ofs) * 7] * c; \ + y2 += decode[23 + (ofs) * 7] * c; \ + y3 += decode[24 + (ofs) * 7] * c; \ + y4 += decode[25 + (ofs) * 7] * c; \ + y5 += decode[26 + (ofs) * 7] * c; \ + y6 += decode[27 + (ofs) * 7] * c; + +#define stbir__1_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + c = hc[0 + (ofs)]; \ + x0 += decode[0 + (ofs) * 7] * c; \ + x1 += decode[1 + (ofs) * 7] * c; \ + x2 += decode[2 + (ofs) * 7] * c; \ + x3 += decode[3 + (ofs) * 7] * c; \ + x4 += decode[4 + (ofs) * 7] * c; \ + x5 += decode[5 + (ofs) * 7] * c; \ + x6 += decode[6 + (ofs) * 7] * c; + +#define stbir__2_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + c = hc[0 + (ofs)]; \ + x0 += decode[0 + (ofs) * 7] * c; \ + x1 += decode[1 + (ofs) * 7] * c; \ + x2 += decode[2 + (ofs) * 7] * c; \ + x3 += decode[3 + (ofs) * 7] * c; \ + x4 += decode[4 + (ofs) * 7] * c; \ + x5 += decode[5 + (ofs) * 7] * c; \ + x6 += decode[6 + (ofs) * 7] * c; \ + c = hc[1 + (ofs)]; \ + y0 += decode[7 + (ofs) * 7] * c; \ + y1 += decode[8 + (ofs) * 7] * c; \ + y2 += decode[9 + (ofs) * 7] * c; \ + y3 += decode[10 + (ofs) * 7] * c; \ + y4 += decode[11 + (ofs) * 7] * c; \ + y5 += decode[12 + (ofs) * 7] * c; \ + y6 += decode[13 + (ofs) * 7] * c; + +#define stbir__3_coeff_remnant(ofs) \ + STBIR_SIMD_NO_UNROLL(decode); \ + c = hc[0 + (ofs)]; \ + x0 += decode[0 + (ofs) * 7] * c; \ + x1 += decode[1 + (ofs) * 7] * c; \ + x2 += decode[2 + (ofs) * 7] * c; \ + x3 += decode[3 + (ofs) * 7] * c; \ + x4 += decode[4 + (ofs) * 7] * c; \ + x5 += decode[5 + (ofs) * 7] * c; \ + x6 += decode[6 + (ofs) * 7] * c; \ + c = hc[1 + (ofs)]; \ + y0 += decode[7 + (ofs) * 7] * c; \ + y1 += decode[8 + (ofs) * 7] * c; \ + y2 += decode[9 + (ofs) * 7] * c; \ + y3 += decode[10 + (ofs) * 7] * c; \ + y4 += decode[11 + (ofs) * 7] * c; \ + y5 += decode[12 + (ofs) * 7] * c; \ + y6 += decode[13 + (ofs) * 7] * c; \ + c = hc[2 + (ofs)]; \ + x0 += decode[14 + (ofs) * 7] * c; \ + x1 += decode[15 + (ofs) * 7] * c; \ + x2 += decode[16 + (ofs) * 7] * c; \ + x3 += decode[17 + (ofs) * 7] * c; \ + x4 += decode[18 + (ofs) * 7] * c; \ + x5 += decode[19 + (ofs) * 7] * c; \ + x6 += decode[20 + (ofs) * 7] * c; + +#define stbir__store_output() \ + output[0] = x0 + y0; \ + output[1] = x1 + y1; \ + output[2] = x2 + y2; \ + output[3] = x3 + y3; \ + output[4] = x4 + y4; \ + output[5] = x5 + y5; \ + output[6] = x6 + y6; \ + horizontal_coefficients += coefficient_width; \ + ++horizontal_contributors; \ + output += 7; + +#endif + +#define STBIR__horizontal_channels 7 +#define STB_IMAGE_RESIZE_DO_HORIZONTALS +#include STBIR__HEADER_FILENAME + +// include all of the vertical resamplers (both scatter and gather versions) + +#define STBIR__vertical_channels 1 +#define STB_IMAGE_RESIZE_DO_VERTICALS +#include STBIR__HEADER_FILENAME + +#define STBIR__vertical_channels 1 +#define STB_IMAGE_RESIZE_DO_VERTICALS +#define STB_IMAGE_RESIZE_VERTICAL_CONTINUE +#include STBIR__HEADER_FILENAME + +#define STBIR__vertical_channels 2 +#define STB_IMAGE_RESIZE_DO_VERTICALS +#include STBIR__HEADER_FILENAME + +#define STBIR__vertical_channels 2 +#define STB_IMAGE_RESIZE_DO_VERTICALS +#define STB_IMAGE_RESIZE_VERTICAL_CONTINUE +#include STBIR__HEADER_FILENAME + +#define STBIR__vertical_channels 3 +#define STB_IMAGE_RESIZE_DO_VERTICALS +#include STBIR__HEADER_FILENAME + +#define STBIR__vertical_channels 3 +#define STB_IMAGE_RESIZE_DO_VERTICALS +#define STB_IMAGE_RESIZE_VERTICAL_CONTINUE +#include STBIR__HEADER_FILENAME + +#define STBIR__vertical_channels 4 +#define STB_IMAGE_RESIZE_DO_VERTICALS +#include STBIR__HEADER_FILENAME + +#define STBIR__vertical_channels 4 +#define STB_IMAGE_RESIZE_DO_VERTICALS +#define STB_IMAGE_RESIZE_VERTICAL_CONTINUE +#include STBIR__HEADER_FILENAME + +#define STBIR__vertical_channels 5 +#define STB_IMAGE_RESIZE_DO_VERTICALS +#include STBIR__HEADER_FILENAME + +#define STBIR__vertical_channels 5 +#define STB_IMAGE_RESIZE_DO_VERTICALS +#define STB_IMAGE_RESIZE_VERTICAL_CONTINUE +#include STBIR__HEADER_FILENAME + +#define STBIR__vertical_channels 6 +#define STB_IMAGE_RESIZE_DO_VERTICALS +#include STBIR__HEADER_FILENAME + +#define STBIR__vertical_channels 6 +#define STB_IMAGE_RESIZE_DO_VERTICALS +#define STB_IMAGE_RESIZE_VERTICAL_CONTINUE +#include STBIR__HEADER_FILENAME + +#define STBIR__vertical_channels 7 +#define STB_IMAGE_RESIZE_DO_VERTICALS +#include STBIR__HEADER_FILENAME + +#define STBIR__vertical_channels 7 +#define STB_IMAGE_RESIZE_DO_VERTICALS +#define STB_IMAGE_RESIZE_VERTICAL_CONTINUE +#include STBIR__HEADER_FILENAME + +#define STBIR__vertical_channels 8 +#define STB_IMAGE_RESIZE_DO_VERTICALS +#include STBIR__HEADER_FILENAME + +#define STBIR__vertical_channels 8 +#define STB_IMAGE_RESIZE_DO_VERTICALS +#define STB_IMAGE_RESIZE_VERTICAL_CONTINUE +#include STBIR__HEADER_FILENAME + +typedef void STBIR_VERTICAL_GATHERFUNC(float *output, float const *coeffs, float const **inputs, + float const *input0_end); + +static STBIR_VERTICAL_GATHERFUNC *stbir__vertical_gathers[8] = { + stbir__vertical_gather_with_1_coeffs, stbir__vertical_gather_with_2_coeffs, + stbir__vertical_gather_with_3_coeffs, stbir__vertical_gather_with_4_coeffs, + stbir__vertical_gather_with_5_coeffs, stbir__vertical_gather_with_6_coeffs, + stbir__vertical_gather_with_7_coeffs, stbir__vertical_gather_with_8_coeffs}; + +static STBIR_VERTICAL_GATHERFUNC *stbir__vertical_gathers_continues[8] = { + stbir__vertical_gather_with_1_coeffs_cont, stbir__vertical_gather_with_2_coeffs_cont, + stbir__vertical_gather_with_3_coeffs_cont, stbir__vertical_gather_with_4_coeffs_cont, + stbir__vertical_gather_with_5_coeffs_cont, stbir__vertical_gather_with_6_coeffs_cont, + stbir__vertical_gather_with_7_coeffs_cont, stbir__vertical_gather_with_8_coeffs_cont}; + +typedef void STBIR_VERTICAL_SCATTERFUNC(float **outputs, float const *coeffs, float const *input, + float const *input_end); + +static STBIR_VERTICAL_SCATTERFUNC *stbir__vertical_scatter_sets[8] = { + stbir__vertical_scatter_with_1_coeffs, stbir__vertical_scatter_with_2_coeffs, + stbir__vertical_scatter_with_3_coeffs, stbir__vertical_scatter_with_4_coeffs, + stbir__vertical_scatter_with_5_coeffs, stbir__vertical_scatter_with_6_coeffs, + stbir__vertical_scatter_with_7_coeffs, stbir__vertical_scatter_with_8_coeffs}; + +static STBIR_VERTICAL_SCATTERFUNC *stbir__vertical_scatter_blends[8] = { + stbir__vertical_scatter_with_1_coeffs_cont, stbir__vertical_scatter_with_2_coeffs_cont, + stbir__vertical_scatter_with_3_coeffs_cont, stbir__vertical_scatter_with_4_coeffs_cont, + stbir__vertical_scatter_with_5_coeffs_cont, stbir__vertical_scatter_with_6_coeffs_cont, + stbir__vertical_scatter_with_7_coeffs_cont, stbir__vertical_scatter_with_8_coeffs_cont}; + +static void stbir__encode_scanline(stbir__info const *stbir_info, void *output_buffer_data, + float *encode_buffer, + int row STBIR_ONLY_PROFILE_GET_SPLIT_INFO) { + int num_pixels = stbir_info->horizontal.scale_info.output_sub_size; + int channels = stbir_info->channels; + int width_times_channels = num_pixels * channels; + void *output_buffer; + + // un-alpha weight if we need to + if (stbir_info->alpha_unweight) { + STBIR_PROFILE_START(unalpha); + stbir_info->alpha_unweight(encode_buffer, width_times_channels); + STBIR_PROFILE_END(unalpha); + } + + // write directly into output by default + output_buffer = output_buffer_data; + + // if we have an output callback, we first convert the decode buffer in place (and then hand + // that to the callback) + if (stbir_info->out_pixels_cb) + output_buffer = encode_buffer; + + STBIR_PROFILE_START(encode); + // convert into the output buffer + stbir_info->encode_pixels(output_buffer, width_times_channels, encode_buffer); + STBIR_PROFILE_END(encode); + + // if we have an output callback, call it to send the data + if (stbir_info->out_pixels_cb) + stbir_info->out_pixels_cb(output_buffer, num_pixels, row, stbir_info->user_data); +} + +// Get the ring buffer pointer for an index +static float *stbir__get_ring_buffer_entry(stbir__info const *stbir_info, + stbir__per_split_info const *split_info, int index) { + STBIR_ASSERT(index < stbir_info->ring_buffer_num_entries); + +#ifdef STBIR__SEPARATE_ALLOCATIONS + return split_info->ring_buffers[index]; +#else + return (float *)(((char *)split_info->ring_buffer) + + (index * stbir_info->ring_buffer_length_bytes)); +#endif +} + +// Get the specified scan line from the ring buffer +static float *stbir__get_ring_buffer_scanline(stbir__info const *stbir_info, + stbir__per_split_info const *split_info, + int get_scanline) { + int ring_buffer_index = (split_info->ring_buffer_begin_index + + (get_scanline - split_info->ring_buffer_first_scanline)) % + stbir_info->ring_buffer_num_entries; + return stbir__get_ring_buffer_entry(stbir_info, split_info, ring_buffer_index); +} + +static void +stbir__resample_horizontal_gather(stbir__info const *stbir_info, float *output_buffer, + float const *input_buffer STBIR_ONLY_PROFILE_GET_SPLIT_INFO) { + float const *decode_buffer = input_buffer - (stbir_info->scanline_extents.conservative.n0 * + stbir_info->effective_channels); + + STBIR_PROFILE_START(horizontal); + if ((stbir_info->horizontal.filter_enum == STBIR_FILTER_POINT_SAMPLE) && + (stbir_info->horizontal.scale_info.scale == 1.0f)) + STBIR_MEMCPY(output_buffer, input_buffer, + stbir_info->horizontal.scale_info.output_sub_size * sizeof(float) * + stbir_info->effective_channels); + else + stbir_info->horizontal_gather_channels( + output_buffer, stbir_info->horizontal.scale_info.output_sub_size, decode_buffer, + stbir_info->horizontal.contributors, stbir_info->horizontal.coefficients, + stbir_info->horizontal.coefficient_width); + STBIR_PROFILE_END(horizontal); +} + +static void stbir__resample_vertical_gather(stbir__info const *stbir_info, + stbir__per_split_info *split_info, int n, + int contrib_n0, int contrib_n1, + float const *vertical_coefficients) { + float *encode_buffer = split_info->vertical_buffer; + float *decode_buffer = split_info->decode_buffer; + int vertical_first = stbir_info->vertical_first; + int width = (vertical_first) ? (stbir_info->scanline_extents.conservative.n1 - + stbir_info->scanline_extents.conservative.n0 + 1) + : stbir_info->horizontal.scale_info.output_sub_size; + int width_times_channels = stbir_info->effective_channels * width; + + STBIR_ASSERT(stbir_info->vertical.is_gather); + + // loop over the contributing scanlines and scale into the buffer + STBIR_PROFILE_START(vertical); + { + int k = 0, total = contrib_n1 - contrib_n0 + 1; + STBIR_ASSERT(total > 0); + do { + float const *inputs[8]; + int i, cnt = total; + if (cnt > 8) + cnt = 8; + for (i = 0; i < cnt; i++) + inputs[i] = + stbir__get_ring_buffer_scanline(stbir_info, split_info, k + i + contrib_n0); + + // call the N scanlines at a time function (up to 8 scanlines of blending at once) + ((k == 0) ? stbir__vertical_gathers : stbir__vertical_gathers_continues)[cnt - 1]( + (vertical_first) ? decode_buffer : encode_buffer, vertical_coefficients + k, inputs, + inputs[0] + width_times_channels); + k += cnt; + total -= cnt; + } while (total); + } + STBIR_PROFILE_END(vertical); + + if (vertical_first) { + // Now resample the gathered vertical data in the horizontal axis into the encode buffer + stbir__resample_horizontal_gather(stbir_info, encode_buffer, + decode_buffer STBIR_ONLY_PROFILE_SET_SPLIT_INFO); + } + + stbir__encode_scanline(stbir_info, + ((char *)stbir_info->output_data) + + ((size_t)n * (size_t)stbir_info->output_stride_bytes), + encode_buffer, n STBIR_ONLY_PROFILE_SET_SPLIT_INFO); +} + +static void stbir__decode_and_resample_for_vertical_gather_loop(stbir__info const *stbir_info, + stbir__per_split_info *split_info, + int n) { + int ring_buffer_index; + float *ring_buffer; + + // Decode the nth scanline from the source image into the decode buffer. + stbir__decode_scanline(stbir_info, n, + split_info->decode_buffer STBIR_ONLY_PROFILE_SET_SPLIT_INFO); + + // update new end scanline + split_info->ring_buffer_last_scanline = n; + + // get ring buffer + ring_buffer_index = + (split_info->ring_buffer_begin_index + + (split_info->ring_buffer_last_scanline - split_info->ring_buffer_first_scanline)) % + stbir_info->ring_buffer_num_entries; + ring_buffer = stbir__get_ring_buffer_entry(stbir_info, split_info, ring_buffer_index); + + // Now resample it into the ring buffer. + stbir__resample_horizontal_gather(stbir_info, ring_buffer, + split_info->decode_buffer STBIR_ONLY_PROFILE_SET_SPLIT_INFO); + + // Now it's sitting in the ring buffer ready to be used as source for the vertical sampling. +} + +static void stbir__vertical_gather_loop(stbir__info const *stbir_info, + stbir__per_split_info *split_info, int split_count) { + int y, start_output_y, end_output_y; + stbir__contributors *vertical_contributors = stbir_info->vertical.contributors; + float const *vertical_coefficients = stbir_info->vertical.coefficients; + + STBIR_ASSERT(stbir_info->vertical.is_gather); + + start_output_y = split_info->start_output_y; + end_output_y = split_info[split_count - 1].end_output_y; + + vertical_contributors += start_output_y; + vertical_coefficients += start_output_y * stbir_info->vertical.coefficient_width; + + // initialize the ring buffer for gathering + split_info->ring_buffer_begin_index = 0; + split_info->ring_buffer_first_scanline = vertical_contributors->n0; + split_info->ring_buffer_last_scanline = + split_info->ring_buffer_first_scanline - 1; // means "empty" + + for (y = start_output_y; y < end_output_y; y++) { + int in_first_scanline, in_last_scanline; + + in_first_scanline = vertical_contributors->n0; + in_last_scanline = vertical_contributors->n1; + + // make sure the indexing hasn't broken + STBIR_ASSERT(in_first_scanline >= split_info->ring_buffer_first_scanline); + + // Load in new scanlines + while (in_last_scanline > split_info->ring_buffer_last_scanline) { + STBIR_ASSERT((split_info->ring_buffer_last_scanline - + split_info->ring_buffer_first_scanline + 1) <= + stbir_info->ring_buffer_num_entries); + + // make sure there was room in the ring buffer when we add new scanlines + if ((split_info->ring_buffer_last_scanline - split_info->ring_buffer_first_scanline + + 1) == stbir_info->ring_buffer_num_entries) { + split_info->ring_buffer_first_scanline++; + split_info->ring_buffer_begin_index++; + } + + if (stbir_info->vertical_first) { + float *ring_buffer = stbir__get_ring_buffer_scanline( + stbir_info, split_info, ++split_info->ring_buffer_last_scanline); + // Decode the nth scanline from the source image into the decode buffer. + stbir__decode_scanline(stbir_info, split_info->ring_buffer_last_scanline, + ring_buffer STBIR_ONLY_PROFILE_SET_SPLIT_INFO); + } else { + stbir__decode_and_resample_for_vertical_gather_loop( + stbir_info, split_info, split_info->ring_buffer_last_scanline + 1); + } + } + + // Now all buffers should be ready to write a row of vertical sampling, so do it. + stbir__resample_vertical_gather(stbir_info, split_info, y, in_first_scanline, + in_last_scanline, vertical_coefficients); + + ++vertical_contributors; + vertical_coefficients += stbir_info->vertical.coefficient_width; + } +} + +#define STBIR__FLOAT_EMPTY_MARKER 3.0e+38F +#define STBIR__FLOAT_BUFFER_IS_EMPTY(ptr) ((ptr)[0] == STBIR__FLOAT_EMPTY_MARKER) + +static void stbir__encode_first_scanline_from_scatter(stbir__info const *stbir_info, + stbir__per_split_info *split_info) { + // evict a scanline out into the output buffer + float *ring_buffer_entry = + stbir__get_ring_buffer_entry(stbir_info, split_info, split_info->ring_buffer_begin_index); + + // dump the scanline out + stbir__encode_scanline( + stbir_info, + ((char *)stbir_info->output_data) + ((size_t)split_info->ring_buffer_first_scanline * + (size_t)stbir_info->output_stride_bytes), + ring_buffer_entry, + split_info->ring_buffer_first_scanline STBIR_ONLY_PROFILE_SET_SPLIT_INFO); + + // mark it as empty + ring_buffer_entry[0] = STBIR__FLOAT_EMPTY_MARKER; + + // advance the first scanline + split_info->ring_buffer_first_scanline++; + if (++split_info->ring_buffer_begin_index == stbir_info->ring_buffer_num_entries) + split_info->ring_buffer_begin_index = 0; +} + +static void stbir__horizontal_resample_and_encode_first_scanline_from_scatter( + stbir__info const *stbir_info, stbir__per_split_info *split_info) { + // evict a scanline out into the output buffer + + float *ring_buffer_entry = + stbir__get_ring_buffer_entry(stbir_info, split_info, split_info->ring_buffer_begin_index); + + // Now resample it into the buffer. + stbir__resample_horizontal_gather(stbir_info, split_info->vertical_buffer, + ring_buffer_entry STBIR_ONLY_PROFILE_SET_SPLIT_INFO); + + // dump the scanline out + stbir__encode_scanline( + stbir_info, + ((char *)stbir_info->output_data) + ((size_t)split_info->ring_buffer_first_scanline * + (size_t)stbir_info->output_stride_bytes), + split_info->vertical_buffer, + split_info->ring_buffer_first_scanline STBIR_ONLY_PROFILE_SET_SPLIT_INFO); + + // mark it as empty + ring_buffer_entry[0] = STBIR__FLOAT_EMPTY_MARKER; + + // advance the first scanline + split_info->ring_buffer_first_scanline++; + if (++split_info->ring_buffer_begin_index == stbir_info->ring_buffer_num_entries) + split_info->ring_buffer_begin_index = 0; +} + +static void stbir__resample_vertical_scatter(stbir__info const *stbir_info, + stbir__per_split_info *split_info, int n0, int n1, + float const *vertical_coefficients, + float const *vertical_buffer, + float const *vertical_buffer_end) { + STBIR_ASSERT(!stbir_info->vertical.is_gather); + + STBIR_PROFILE_START(vertical); + { + int k = 0, total = n1 - n0 + 1; + STBIR_ASSERT(total > 0); + do { + float *outputs[8]; + int i, n = total; + if (n > 8) + n = 8; + for (i = 0; i < n; i++) { + outputs[i] = stbir__get_ring_buffer_scanline(stbir_info, split_info, k + i + n0); + if ((i) && (STBIR__FLOAT_BUFFER_IS_EMPTY(outputs[i]) != + STBIR__FLOAT_BUFFER_IS_EMPTY( + outputs[0]))) // make sure runs are of the same type + { + n = i; + break; + } + } + // call the scatter to N scanlines at a time function (up to 8 scanlines of scattering + // at once) + ((STBIR__FLOAT_BUFFER_IS_EMPTY(outputs[0])) ? stbir__vertical_scatter_sets + : stbir__vertical_scatter_blends)[n - 1]( + outputs, vertical_coefficients + k, vertical_buffer, vertical_buffer_end); + k += n; + total -= n; + } while (total); + } + + STBIR_PROFILE_END(vertical); +} + +typedef void stbir__handle_scanline_for_scatter_func(stbir__info const *stbir_info, + stbir__per_split_info *split_info); + +static void stbir__vertical_scatter_loop(stbir__info const *stbir_info, + stbir__per_split_info *split_info, int split_count) { + int y, start_output_y, end_output_y, start_input_y, end_input_y; + stbir__contributors *vertical_contributors = stbir_info->vertical.contributors; + float const *vertical_coefficients = stbir_info->vertical.coefficients; + stbir__handle_scanline_for_scatter_func *handle_scanline_for_scatter; + void *scanline_scatter_buffer; + void *scanline_scatter_buffer_end; + int on_first_input_y, last_input_y; + + STBIR_ASSERT(!stbir_info->vertical.is_gather); + + start_output_y = split_info->start_output_y; + end_output_y = split_info[split_count - 1].end_output_y; // may do multiple split counts + + start_input_y = split_info->start_input_y; + end_input_y = split_info[split_count - 1].end_input_y; + + // adjust for starting offset start_input_y + y = start_input_y + stbir_info->vertical.filter_pixel_margin; + vertical_contributors += y; + vertical_coefficients += stbir_info->vertical.coefficient_width * y; + + if (stbir_info->vertical_first) { + handle_scanline_for_scatter = + stbir__horizontal_resample_and_encode_first_scanline_from_scatter; + scanline_scatter_buffer = split_info->decode_buffer; + scanline_scatter_buffer_end = ((char *)scanline_scatter_buffer) + + sizeof(float) * stbir_info->effective_channels * + (stbir_info->scanline_extents.conservative.n1 - + stbir_info->scanline_extents.conservative.n0 + 1); + } else { + handle_scanline_for_scatter = stbir__encode_first_scanline_from_scatter; + scanline_scatter_buffer = split_info->vertical_buffer; + scanline_scatter_buffer_end = ((char *)scanline_scatter_buffer) + + sizeof(float) * stbir_info->effective_channels * + stbir_info->horizontal.scale_info.output_sub_size; + } + + // initialize the ring buffer for scattering + split_info->ring_buffer_first_scanline = start_output_y; + split_info->ring_buffer_last_scanline = -1; + split_info->ring_buffer_begin_index = -1; + + // mark all the buffers as empty to start + for (y = 0; y < stbir_info->ring_buffer_num_entries; y++) + stbir__get_ring_buffer_entry(stbir_info, split_info, y)[0] = + STBIR__FLOAT_EMPTY_MARKER; // only used on scatter + + // do the loop in input space + on_first_input_y = 1; + last_input_y = start_input_y; + for (y = start_input_y; y < end_input_y; y++) { + int out_first_scanline, out_last_scanline; + + out_first_scanline = vertical_contributors->n0; + out_last_scanline = vertical_contributors->n1; + + STBIR_ASSERT(out_last_scanline - out_first_scanline + 1 <= + stbir_info->ring_buffer_num_entries); + + if ((out_last_scanline >= out_first_scanline) && + (((out_first_scanline >= start_output_y) && (out_first_scanline < end_output_y)) || + ((out_last_scanline >= start_output_y) && (out_last_scanline < end_output_y)))) { + float const *vc = vertical_coefficients; + + // keep track of the range actually seen for the next resize + last_input_y = y; + if ((on_first_input_y) && (y > start_input_y)) + split_info->start_input_y = y; + on_first_input_y = 0; + + // clip the region + if (out_first_scanline < start_output_y) { + vc += start_output_y - out_first_scanline; + out_first_scanline = start_output_y; + } + + if (out_last_scanline >= end_output_y) + out_last_scanline = end_output_y - 1; + + // if very first scanline, init the index + if (split_info->ring_buffer_begin_index < 0) + split_info->ring_buffer_begin_index = out_first_scanline - start_output_y; + + STBIR_ASSERT(split_info->ring_buffer_begin_index <= out_first_scanline); + + // Decode the nth scanline from the source image into the decode buffer. + stbir__decode_scanline(stbir_info, y, + split_info->decode_buffer STBIR_ONLY_PROFILE_SET_SPLIT_INFO); + + // When horizontal first, we resample horizontally into the vertical buffer before we + // scatter it out + if (!stbir_info->vertical_first) + stbir__resample_horizontal_gather( + stbir_info, split_info->vertical_buffer, + split_info->decode_buffer STBIR_ONLY_PROFILE_SET_SPLIT_INFO); + + // Now it's sitting in the buffer ready to be distributed into the ring buffers. + + // evict from the ringbuffer, if we need are full + if (((split_info->ring_buffer_last_scanline - split_info->ring_buffer_first_scanline + + 1) == stbir_info->ring_buffer_num_entries) && + (out_last_scanline > split_info->ring_buffer_last_scanline)) + handle_scanline_for_scatter(stbir_info, split_info); + + // Now the horizontal buffer is ready to write to all ring buffer rows, so do it. + stbir__resample_vertical_scatter( + stbir_info, split_info, out_first_scanline, out_last_scanline, vc, + (float *)scanline_scatter_buffer, (float *)scanline_scatter_buffer_end); + + // update the end of the buffer + if (out_last_scanline > split_info->ring_buffer_last_scanline) + split_info->ring_buffer_last_scanline = out_last_scanline; + } + ++vertical_contributors; + vertical_coefficients += stbir_info->vertical.coefficient_width; + } + + // now evict the scanlines that are left over in the ring buffer + while (split_info->ring_buffer_first_scanline < end_output_y) + handle_scanline_for_scatter(stbir_info, split_info); + + // update the end_input_y if we do multiple resizes with the same data + ++last_input_y; + for (y = 0; y < split_count; y++) + if (split_info[y].end_input_y > last_input_y) + split_info[y].end_input_y = last_input_y; +} + +static stbir__kernel_callback *stbir__builtin_kernels[] = {0, + stbir__filter_trapezoid, + stbir__filter_triangle, + stbir__filter_cubic, + stbir__filter_catmullrom, + stbir__filter_mitchell, + stbir__filter_point}; +static stbir__support_callback *stbir__builtin_supports[] = {0, + stbir__support_trapezoid, + stbir__support_one, + stbir__support_two, + stbir__support_two, + stbir__support_two, + stbir__support_zeropoint5}; + +static void stbir__set_sampler(stbir__sampler *samp, stbir_filter filter, + stbir__kernel_callback *kernel, stbir__support_callback *support, + stbir_edge edge, stbir__scale_info *scale_info, int always_gather, + void *user_data) { + // set filter + if (filter == 0) { + filter = STBIR_DEFAULT_FILTER_DOWNSAMPLE; // default to downsample + if (scale_info->scale >= (1.0f - stbir__small_float)) { + if ((scale_info->scale <= (1.0f + stbir__small_float)) && + (STBIR_CEILF(scale_info->pixel_shift) == scale_info->pixel_shift)) + filter = STBIR_FILTER_POINT_SAMPLE; + else + filter = STBIR_DEFAULT_FILTER_UPSAMPLE; + } + } + samp->filter_enum = filter; + + STBIR_ASSERT(samp->filter_enum != 0); + STBIR_ASSERT((unsigned)samp->filter_enum < STBIR_FILTER_OTHER); + samp->filter_kernel = stbir__builtin_kernels[filter]; + samp->filter_support = stbir__builtin_supports[filter]; + + if (kernel && support) { + samp->filter_kernel = kernel; + samp->filter_support = support; + samp->filter_enum = STBIR_FILTER_OTHER; + } + + samp->edge = edge; + samp->filter_pixel_width = + stbir__get_filter_pixel_width(samp->filter_support, scale_info->scale, user_data); + // Gather is always better, but in extreme downsamples, you have to most or all of the data in + // memory + // For horizontal, we always have all the pixels, so we always use gather here + // (always_gather==1). For vertical, we use gather if scaling up (which means we will have + // samp->filter_pixel_width scanlines in memory at once). + samp->is_gather = 0; + if (scale_info->scale >= (1.0f - stbir__small_float)) + samp->is_gather = 1; + else if ((always_gather) || + (samp->filter_pixel_width <= STBIR_FORCE_GATHER_FILTER_SCANLINES_AMOUNT)) + samp->is_gather = 2; + + // pre calculate stuff based on the above + samp->coefficient_width = stbir__get_coefficient_width(samp, samp->is_gather, user_data); + + // filter_pixel_width is the conservative size in pixels of input that affect an output pixel. + // In rare cases (only with 2 pix to 1 pix with the default filters), it's possible that the + // filter will extend before or after the scanline beyond just one extra entire copy of the + // scanline (we would hit the edge twice). We don't let you do that, so we clamp the total + // width to 3x the total of input pixel (once for the scanline, once for the left side + // overhang, and once for the right side). We only do this for edge mode, since the other + // modes can just re-edge clamp back in again. + if (edge == STBIR_EDGE_WRAP) + if (samp->filter_pixel_width > (scale_info->input_full_size * 3)) + samp->filter_pixel_width = scale_info->input_full_size * 3; + + // This is how much to expand buffers to account for filters seeking outside + // the image boundaries. + samp->filter_pixel_margin = samp->filter_pixel_width / 2; + + // filter_pixel_margin is the amount that this filter can overhang on just one side of either + // end of the scanline (left or the right). Since we only allow you to overhang 1 scanline's + // worth of pixels, we clamp this one side of overhang to the input scanline size. Again, + // this clamping only happens in rare cases with the default filters (2 pix to 1 pix). + if (edge == STBIR_EDGE_WRAP) + if (samp->filter_pixel_margin > scale_info->input_full_size) + samp->filter_pixel_margin = scale_info->input_full_size; + + samp->num_contributors = stbir__get_contributors(samp, samp->is_gather); + + samp->contributors_size = samp->num_contributors * sizeof(stbir__contributors); + samp->coefficients_size = samp->num_contributors * samp->coefficient_width * sizeof(float) + + sizeof(float); // extra sizeof(float) is padding + + samp->gather_prescatter_contributors = 0; + samp->gather_prescatter_coefficients = 0; + if (samp->is_gather == 0) { + samp->gather_prescatter_coefficient_width = samp->filter_pixel_width; + samp->gather_prescatter_num_contributors = stbir__get_contributors(samp, 2); + samp->gather_prescatter_contributors_size = + samp->gather_prescatter_num_contributors * sizeof(stbir__contributors); + samp->gather_prescatter_coefficients_size = samp->gather_prescatter_num_contributors * + samp->gather_prescatter_coefficient_width * + sizeof(float); + } +} + +static void stbir__get_conservative_extents(stbir__sampler *samp, stbir__contributors *range, + void *user_data) { + float scale = samp->scale_info.scale; + float out_shift = samp->scale_info.pixel_shift; + stbir__support_callback *support = samp->filter_support; + int input_full_size = samp->scale_info.input_full_size; + stbir_edge edge = samp->edge; + float inv_scale = samp->scale_info.inv_scale; + + STBIR_ASSERT(samp->is_gather != 0); + + if (samp->is_gather == 1) { + int in_first_pixel, in_last_pixel; + float out_filter_radius = support(inv_scale, user_data) * scale; + + stbir__calculate_in_pixel_range(&in_first_pixel, &in_last_pixel, 0.5, out_filter_radius, + inv_scale, out_shift, input_full_size, edge); + range->n0 = in_first_pixel; + stbir__calculate_in_pixel_range( + &in_first_pixel, &in_last_pixel, ((float)(samp->scale_info.output_sub_size - 1)) + 0.5f, + out_filter_radius, inv_scale, out_shift, input_full_size, edge); + range->n1 = in_last_pixel; + } else if (samp->is_gather == 2) // downsample gather, refine + { + float in_pixels_radius = support(scale, user_data) * inv_scale; + int filter_pixel_margin = samp->filter_pixel_margin; + int output_sub_size = samp->scale_info.output_sub_size; + int input_end; + int n; + int in_first_pixel, in_last_pixel; + + // get a conservative area of the input range + stbir__calculate_in_pixel_range(&in_first_pixel, &in_last_pixel, 0, 0, inv_scale, out_shift, + input_full_size, edge); + range->n0 = in_first_pixel; + stbir__calculate_in_pixel_range(&in_first_pixel, &in_last_pixel, (float)output_sub_size, 0, + inv_scale, out_shift, input_full_size, edge); + range->n1 = in_last_pixel; + + // now go through the margin to the start of area to find bottom + n = range->n0 + 1; + input_end = -filter_pixel_margin; + while (n >= input_end) { + int out_first_pixel, out_last_pixel; + stbir__calculate_out_pixel_range(&out_first_pixel, &out_last_pixel, ((float)n) + 0.5f, + in_pixels_radius, scale, out_shift, output_sub_size); + if (out_first_pixel > out_last_pixel) + break; + + if ((out_first_pixel < output_sub_size) || (out_last_pixel >= 0)) + range->n0 = n; + --n; + } + + // now go through the end of the area through the margin to find top + n = range->n1 - 1; + input_end = n + 1 + filter_pixel_margin; + while (n <= input_end) { + int out_first_pixel, out_last_pixel; + stbir__calculate_out_pixel_range(&out_first_pixel, &out_last_pixel, ((float)n) + 0.5f, + in_pixels_radius, scale, out_shift, output_sub_size); + if (out_first_pixel > out_last_pixel) + break; + if ((out_first_pixel < output_sub_size) || (out_last_pixel >= 0)) + range->n1 = n; + ++n; + } + } + + if (samp->edge == STBIR_EDGE_WRAP) { + // if we are wrapping, and we are very close to the image size (so the edges might merge), + // just use the scanline up to the edge + if ((range->n0 > 0) && (range->n1 >= input_full_size)) { + int marg = range->n1 - input_full_size + 1; + if ((marg + STBIR__MERGE_RUNS_PIXEL_THRESHOLD) >= range->n0) + range->n0 = 0; + } + if ((range->n0 < 0) && (range->n1 < (input_full_size - 1))) { + int marg = -range->n0; + if ((input_full_size - marg - STBIR__MERGE_RUNS_PIXEL_THRESHOLD - 1) <= range->n1) + range->n1 = input_full_size - 1; + } + } else { + // for non-edge-wrap modes, we never read over the edge, so clamp + if (range->n0 < 0) + range->n0 = 0; + if (range->n1 >= input_full_size) + range->n1 = input_full_size - 1; + } +} + +static void stbir__get_split_info(stbir__per_split_info *split_info, int splits, int output_height, + int vertical_pixel_margin, int input_full_height) { + int i, cur; + int left = output_height; + + cur = 0; + for (i = 0; i < splits; i++) { + int each; + split_info[i].start_output_y = cur; + each = left / (splits - i); + split_info[i].end_output_y = cur + each; + cur += each; + left -= each; + + // scatter range (updated to minimum as you run it) + split_info[i].start_input_y = -vertical_pixel_margin; + split_info[i].end_input_y = input_full_height + vertical_pixel_margin; + } +} + +static void stbir__free_internal_mem(stbir__info *info) { +#define STBIR__FREE_AND_CLEAR(ptr) \ + { \ + if (ptr) { \ + void *p = (ptr); \ + (ptr) = 0; \ + STBIR_FREE(p, info->user_data); \ + } \ + } + + if (info) { +#ifndef STBIR__SEPARATE_ALLOCATIONS + STBIR__FREE_AND_CLEAR(info->alloced_mem); +#else + int i, j; + + if ((info->vertical.gather_prescatter_contributors) && + ((void *)info->vertical.gather_prescatter_contributors != + (void *)info->split_info[0].decode_buffer)) { + STBIR__FREE_AND_CLEAR(info->vertical.gather_prescatter_coefficients); + STBIR__FREE_AND_CLEAR(info->vertical.gather_prescatter_contributors); + } + for (i = 0; i < info->splits; i++) { + for (j = 0; j < info->alloc_ring_buffer_num_entries; j++) { +#ifdef STBIR_SIMD8 + if (info->effective_channels == 3) + --info->split_info[i].ring_buffers[j]; // avx in 3 channel mode needs one float + // at the start of the buffer +#endif + STBIR__FREE_AND_CLEAR(info->split_info[i].ring_buffers[j]); + } + +#ifdef STBIR_SIMD8 + if (info->effective_channels == 3) + --info->split_info[i].decode_buffer; // avx in 3 channel mode needs one float at + // the start of the buffer +#endif + STBIR__FREE_AND_CLEAR(info->split_info[i].decode_buffer); + STBIR__FREE_AND_CLEAR(info->split_info[i].ring_buffers); + STBIR__FREE_AND_CLEAR(info->split_info[i].vertical_buffer); + } + STBIR__FREE_AND_CLEAR(info->split_info); + if (info->vertical.coefficients != info->horizontal.coefficients) { + STBIR__FREE_AND_CLEAR(info->vertical.coefficients); + STBIR__FREE_AND_CLEAR(info->vertical.contributors); + } + STBIR__FREE_AND_CLEAR(info->horizontal.coefficients); + STBIR__FREE_AND_CLEAR(info->horizontal.contributors); + STBIR__FREE_AND_CLEAR(info->alloced_mem); + STBIR__FREE_AND_CLEAR(info); +#endif + } + +#undef STBIR__FREE_AND_CLEAR +} + +static int stbir__get_max_split(int splits, int height) { + int i; + int max = 0; + + for (i = 0; i < splits; i++) { + int each = height / (splits - i); + if (each > max) + max = each; + height -= each; + } + return max; +} + +static stbir__horizontal_gather_channels_func **stbir__horizontal_gather_n_coeffs_funcs[8] = { + 0, + stbir__horizontal_gather_1_channels_with_n_coeffs_funcs, + stbir__horizontal_gather_2_channels_with_n_coeffs_funcs, + stbir__horizontal_gather_3_channels_with_n_coeffs_funcs, + stbir__horizontal_gather_4_channels_with_n_coeffs_funcs, + 0, + 0, + stbir__horizontal_gather_7_channels_with_n_coeffs_funcs}; + +static stbir__horizontal_gather_channels_func **stbir__horizontal_gather_channels_funcs[8] = { + 0, + stbir__horizontal_gather_1_channels_funcs, + stbir__horizontal_gather_2_channels_funcs, + stbir__horizontal_gather_3_channels_funcs, + stbir__horizontal_gather_4_channels_funcs, + 0, + 0, + stbir__horizontal_gather_7_channels_funcs}; + +// there are six resize classifications: 0 == vertical scatter, 1 == vertical gather < 1x scale, 2 +// == vertical gather 1x-2x scale, 4 == vertical gather < 3x scale, 4 == vertical gather > 3x scale, +// 5 == <=4 pixel height, 6 == <=4 pixel wide column +#define STBIR_RESIZE_CLASSIFICATIONS 8 + +static float stbir__compute_weights[5][STBIR_RESIZE_CLASSIFICATIONS] + [4] = // 5 = 0=1chan, 1=2chan, 2=3chan, 3=4chan, 4=7chan + { + { + {1.00000f, 1.00000f, 0.31250f, 1.00000f}, + {0.56250f, 0.59375f, 0.00000f, 0.96875f}, + {1.00000f, 0.06250f, 0.00000f, 1.00000f}, + {0.00000f, 0.09375f, 1.00000f, 1.00000f}, + {1.00000f, 1.00000f, 1.00000f, 1.00000f}, + {0.03125f, 0.12500f, 1.00000f, 1.00000f}, + {0.06250f, 0.12500f, 0.00000f, 1.00000f}, + {0.00000f, 1.00000f, 0.00000f, 0.03125f}, + }, + { + {0.00000f, 0.84375f, 0.00000f, 0.03125f}, + {0.09375f, 0.93750f, 0.00000f, 0.78125f}, + {0.87500f, 0.21875f, 0.00000f, 0.96875f}, + {0.09375f, 0.09375f, 1.00000f, 1.00000f}, + {1.00000f, 1.00000f, 1.00000f, 1.00000f}, + {0.03125f, 0.12500f, 1.00000f, 1.00000f}, + {0.06250f, 0.12500f, 0.00000f, 1.00000f}, + {0.00000f, 1.00000f, 0.00000f, 0.53125f}, + }, + { + {0.00000f, 0.53125f, 0.00000f, 0.03125f}, + {0.06250f, 0.96875f, 0.00000f, 0.53125f}, + {0.87500f, 0.18750f, 0.00000f, 0.93750f}, + {0.00000f, 0.09375f, 1.00000f, 1.00000f}, + {1.00000f, 1.00000f, 1.00000f, 1.00000f}, + {0.03125f, 0.12500f, 1.00000f, 1.00000f}, + {0.06250f, 0.12500f, 0.00000f, 1.00000f}, + {0.00000f, 1.00000f, 0.00000f, 0.56250f}, + }, + { + {0.00000f, 0.50000f, 0.00000f, 0.71875f}, + {0.06250f, 0.84375f, 0.00000f, 0.87500f}, + {1.00000f, 0.50000f, 0.50000f, 0.96875f}, + {1.00000f, 0.09375f, 0.31250f, 0.50000f}, + {1.00000f, 1.00000f, 1.00000f, 1.00000f}, + {1.00000f, 0.03125f, 0.03125f, 0.53125f}, + {0.18750f, 0.12500f, 0.00000f, 1.00000f}, + {0.00000f, 1.00000f, 0.03125f, 0.18750f}, + }, + { + {0.00000f, 0.59375f, 0.00000f, 0.96875f}, + {0.06250f, 0.81250f, 0.06250f, 0.59375f}, + {0.75000f, 0.43750f, 0.12500f, 0.96875f}, + {0.87500f, 0.06250f, 0.18750f, 0.43750f}, + {1.00000f, 1.00000f, 1.00000f, 1.00000f}, + {0.15625f, 0.12500f, 1.00000f, 1.00000f}, + {0.06250f, 0.12500f, 0.00000f, 1.00000f}, + {0.00000f, 1.00000f, 0.03125f, 0.34375f}, + } +}; + +// structure that allow us to query and override info for training the costs +typedef struct STBIR__V_FIRST_INFO { + double v_cost, h_cost; + int control_v_first; // 0 = no control, 1 = force hori, 2 = force vert + int v_first; + int v_resize_classification; + int is_gather; +} STBIR__V_FIRST_INFO; + +#ifdef STBIR__V_FIRST_INFO_BUFFER +static STBIR__V_FIRST_INFO STBIR__V_FIRST_INFO_BUFFER = {0}; +#define STBIR__V_FIRST_INFO_POINTER &STBIR__V_FIRST_INFO_BUFFER +#else +#define STBIR__V_FIRST_INFO_POINTER 0 +#endif + +// Figure out whether to scale along the horizontal or vertical first. +// This only *super* important when you are scaling by a massively +// different amount in the vertical vs the horizontal (for example, if +// you are scaling by 2x in the width, and 0.5x in the height, then you +// want to do the vertical scale first, because it's around 3x faster +// in that order. +// +// In more normal circumstances, this makes a 20-40% differences, so +// it's good to get right, but not critical. The normal way that you +// decide which direction goes first is just figuring out which +// direction does more multiplies. But with modern CPUs with their +// fancy caches and SIMD and high IPC abilities, so there's just a lot +// more that goes into it. +// +// My handwavy sort of solution is to have an app that does a whole +// bunch of timing for both vertical and horizontal first modes, +// and then another app that can read lots of these timing files +// and try to search for the best weights to use. Dotimings.c +// is the app that does a bunch of timings, and vf_train.c is the +// app that solves for the best weights (and shows how well it +// does currently). + +static int stbir__should_do_vertical_first(float weights_table[STBIR_RESIZE_CLASSIFICATIONS][4], + int horizontal_filter_pixel_width, + float horizontal_scale, int horizontal_output_size, + int vertical_filter_pixel_width, float vertical_scale, + int vertical_output_size, int is_gather, + STBIR__V_FIRST_INFO *info) { + double v_cost, h_cost; + float *weights; + int vertical_first; + int v_classification; + + // categorize the resize into buckets + if ((vertical_output_size <= 4) || (horizontal_output_size <= 4)) + v_classification = (vertical_output_size < horizontal_output_size) ? 6 : 7; + else if (vertical_scale <= 1.0f) + v_classification = (is_gather) ? 1 : 0; + else if (vertical_scale <= 2.0f) + v_classification = 2; + else if (vertical_scale <= 3.0f) + v_classification = 3; + else if (vertical_scale <= 4.0f) + v_classification = 5; + else + v_classification = 6; + + // use the right weights + weights = weights_table[v_classification]; + + // this is the costs when you don't take into account modern CPUs with high ipc and simd and + // caches - wish we had a better estimate + h_cost = (float)horizontal_filter_pixel_width * weights[0] + + horizontal_scale * (float)vertical_filter_pixel_width * weights[1]; + v_cost = (float)vertical_filter_pixel_width * weights[2] + + vertical_scale * (float)horizontal_filter_pixel_width * weights[3]; + + // use computation estimate to decide vertical first or not + vertical_first = (v_cost <= h_cost) ? 1 : 0; + + // save these, if requested + if (info) { + info->h_cost = h_cost; + info->v_cost = v_cost; + info->v_resize_classification = v_classification; + info->v_first = vertical_first; + info->is_gather = is_gather; + } + + // and this allows us to override everything for testing (see dotiming.c) + if ((info) && (info->control_v_first)) + vertical_first = (info->control_v_first == 2) ? 1 : 0; + + return vertical_first; +} + +// layout lookups - must match stbir_internal_pixel_layout +static unsigned char stbir__pixel_channels[] = { + 1, 2, 3, 3, 4, // 1ch, 2ch, rgb, bgr, 4ch + 4, 4, 4, 4, 2, 2, // RGBA,BGRA,ARGB,ABGR,RA,AR + 4, 4, 4, 4, 2, 2, // RGBA_PM,BGRA_PM,ARGB_PM,ABGR_PM,RA_PM,AR_PM +}; + +// the internal pixel layout enums are in a different order, so we can easily do range comparisons +// of types +// the public pixel layout is ordered in a way that if you cast num_channels (1-4) to the enum, +// you get something sensible +static stbir_internal_pixel_layout stbir__pixel_layout_convert_public_to_internal[] = { + STBIRI_BGR, STBIRI_1CHANNEL, STBIRI_2CHANNEL, STBIRI_RGB, STBIRI_RGBA, STBIRI_4CHANNEL, + STBIRI_BGRA, STBIRI_ARGB, STBIRI_ABGR, STBIRI_RA, STBIRI_AR, STBIRI_RGBA_PM, + STBIRI_BGRA_PM, STBIRI_ARGB_PM, STBIRI_ABGR_PM, STBIRI_RA_PM, STBIRI_AR_PM, +}; + +static stbir__info *stbir__alloc_internal_mem_and_build_samplers( + stbir__sampler *horizontal, stbir__sampler *vertical, stbir__contributors *conservative, + stbir_pixel_layout input_pixel_layout_public, stbir_pixel_layout output_pixel_layout_public, + int splits, int new_x, int new_y, int fast_alpha, + void *user_data STBIR_ONLY_PROFILE_BUILD_GET_INFO) { + static char stbir_channel_count_index[8] = {9, 0, 1, 2, 3, 9, 9, 4}; + + stbir__info *info = 0; + void *alloced = 0; + size_t alloced_total = 0; + int vertical_first; + int decode_buffer_size, ring_buffer_length_bytes, ring_buffer_size, vertical_buffer_size, + alloc_ring_buffer_num_entries; + + int alpha_weighting_type = 0; // 0=none, 1=simple, 2=fancy + int conservative_split_output_size = + stbir__get_max_split(splits, vertical->scale_info.output_sub_size); + stbir_internal_pixel_layout input_pixel_layout = + stbir__pixel_layout_convert_public_to_internal[input_pixel_layout_public]; + stbir_internal_pixel_layout output_pixel_layout = + stbir__pixel_layout_convert_public_to_internal[output_pixel_layout_public]; + int channels = stbir__pixel_channels[input_pixel_layout]; + int effective_channels = channels; + + // first figure out what type of alpha weighting to use (if any) + if ((horizontal->filter_enum != STBIR_FILTER_POINT_SAMPLE) || + (vertical->filter_enum != + STBIR_FILTER_POINT_SAMPLE)) // no alpha weighting on point sampling + { + if ((input_pixel_layout >= STBIRI_RGBA) && (input_pixel_layout <= STBIRI_AR) && + (output_pixel_layout >= STBIRI_RGBA) && (output_pixel_layout <= STBIRI_AR)) { + if (fast_alpha) { + alpha_weighting_type = 4; + } else { + static int fancy_alpha_effective_cnts[6] = {7, 7, 7, 7, 3, 3}; + alpha_weighting_type = 2; + effective_channels = fancy_alpha_effective_cnts[input_pixel_layout - STBIRI_RGBA]; + } + } else if ((input_pixel_layout >= STBIRI_RGBA_PM) && (input_pixel_layout <= STBIRI_AR_PM) && + (output_pixel_layout >= STBIRI_RGBA) && (output_pixel_layout <= STBIRI_AR)) { + // input premult, output non-premult + alpha_weighting_type = 3; + } else if ((input_pixel_layout >= STBIRI_RGBA) && (input_pixel_layout <= STBIRI_AR) && + (output_pixel_layout >= STBIRI_RGBA_PM) && + (output_pixel_layout <= STBIRI_AR_PM)) { + // input non-premult, output premult + alpha_weighting_type = 1; + } + } + + // channel in and out count must match currently + if (channels != stbir__pixel_channels[output_pixel_layout]) + return 0; + + // get vertical first + vertical_first = stbir__should_do_vertical_first( + stbir__compute_weights[(int)stbir_channel_count_index[effective_channels]], + horizontal->filter_pixel_width, horizontal->scale_info.scale, + horizontal->scale_info.output_sub_size, vertical->filter_pixel_width, + vertical->scale_info.scale, vertical->scale_info.output_sub_size, vertical->is_gather, + STBIR__V_FIRST_INFO_POINTER); + + // sometimes read one float off in some of the unrolled loops (with a weight of zero coeff, so + // it doesn't have an effect) + decode_buffer_size = + (conservative->n1 - conservative->n0 + 1) * effective_channels * sizeof(float) + + sizeof(float); // extra float for padding + +#if defined(STBIR__SEPARATE_ALLOCATIONS) && defined(STBIR_SIMD8) + if (effective_channels == 3) + decode_buffer_size += sizeof(float); // avx in 3 channel mode needs one float at the start + // of the buffer (only with separate allocations) +#endif + + ring_buffer_length_bytes = + horizontal->scale_info.output_sub_size * effective_channels * sizeof(float) + + sizeof(float); // extra float for padding + + // if we do vertical first, the ring buffer holds a whole decoded line + if (vertical_first) + ring_buffer_length_bytes = (decode_buffer_size + 15) & ~15; + + if ((ring_buffer_length_bytes & 4095) == 0) + ring_buffer_length_bytes += 64 * 3; // avoid 4k alias + + // One extra entry because floating point precision problems sometimes cause an extra to be + // necessary. + alloc_ring_buffer_num_entries = vertical->filter_pixel_width + 1; + + // we never need more ring buffer entries than the scanlines we're outputting when in scatter + // mode + if ((!vertical->is_gather) && (alloc_ring_buffer_num_entries > conservative_split_output_size)) + alloc_ring_buffer_num_entries = conservative_split_output_size; + + ring_buffer_size = alloc_ring_buffer_num_entries * ring_buffer_length_bytes; + + // The vertical buffer is used differently, depending on whether we are scattering + // the vertical scanlines, or gathering them. + // If scattering, it's used at the temp buffer to accumulate each output. + // If gathering, it's just the output buffer. + vertical_buffer_size = + horizontal->scale_info.output_sub_size * effective_channels * sizeof(float) + + sizeof(float); // extra float for padding + + // we make two passes through this loop, 1st to add everything up, 2nd to allocate and init + for (;;) { + int i; + void *advance_mem = alloced; + int copy_horizontal = 0; + stbir__sampler *possibly_use_horizontal_for_pivot = 0; + +#ifdef STBIR__SEPARATE_ALLOCATIONS +#define STBIR__NEXT_PTR(ptr, size, ntype) \ + if (alloced) { \ + void *p = STBIR_MALLOC(size, user_data); \ + if (p == 0) { \ + stbir__free_internal_mem(info); \ + return 0; \ + } \ + (ptr) = (ntype *)p; \ + } +#else +#define STBIR__NEXT_PTR(ptr, size, ntype) \ + advance_mem = (void *)((((size_t)advance_mem) + 15) & ~15); \ + if (alloced) \ + ptr = (ntype *)advance_mem; \ + advance_mem = ((char *)advance_mem) + (size); +#endif + + STBIR__NEXT_PTR(info, sizeof(stbir__info), stbir__info); + + STBIR__NEXT_PTR(info->split_info, sizeof(stbir__per_split_info) * splits, + stbir__per_split_info); + + if (info) { + static stbir__alpha_weight_func *fancy_alpha_weights[6] = { + stbir__fancy_alpha_weight_4ch, stbir__fancy_alpha_weight_4ch, + stbir__fancy_alpha_weight_4ch, stbir__fancy_alpha_weight_4ch, + stbir__fancy_alpha_weight_2ch, stbir__fancy_alpha_weight_2ch}; + static stbir__alpha_unweight_func *fancy_alpha_unweights[6] = { + stbir__fancy_alpha_unweight_4ch, stbir__fancy_alpha_unweight_4ch, + stbir__fancy_alpha_unweight_4ch, stbir__fancy_alpha_unweight_4ch, + stbir__fancy_alpha_unweight_2ch, stbir__fancy_alpha_unweight_2ch}; + static stbir__alpha_weight_func *simple_alpha_weights[6] = { + stbir__simple_alpha_weight_4ch, stbir__simple_alpha_weight_4ch, + stbir__simple_alpha_weight_4ch, stbir__simple_alpha_weight_4ch, + stbir__simple_alpha_weight_2ch, stbir__simple_alpha_weight_2ch}; + static stbir__alpha_unweight_func *simple_alpha_unweights[6] = { + stbir__simple_alpha_unweight_4ch, stbir__simple_alpha_unweight_4ch, + stbir__simple_alpha_unweight_4ch, stbir__simple_alpha_unweight_4ch, + stbir__simple_alpha_unweight_2ch, stbir__simple_alpha_unweight_2ch}; + + // initialize info fields + info->alloced_mem = alloced; + info->alloced_total = alloced_total; + + info->channels = channels; + info->effective_channels = effective_channels; + + info->offset_x = new_x; + info->offset_y = new_y; + info->alloc_ring_buffer_num_entries = alloc_ring_buffer_num_entries; + info->ring_buffer_num_entries = 0; + info->ring_buffer_length_bytes = ring_buffer_length_bytes; + info->splits = splits; + info->vertical_first = vertical_first; + + info->input_pixel_layout_internal = input_pixel_layout; + info->output_pixel_layout_internal = output_pixel_layout; + + // setup alpha weight functions + info->alpha_weight = 0; + info->alpha_unweight = 0; + + // handle alpha weighting functions and overrides + if (alpha_weighting_type == 2) { + // high quality alpha multiplying on the way in, dividing on the way out + info->alpha_weight = fancy_alpha_weights[input_pixel_layout - STBIRI_RGBA]; + info->alpha_unweight = fancy_alpha_unweights[output_pixel_layout - STBIRI_RGBA]; + } else if (alpha_weighting_type == 4) { + // fast alpha multiplying on the way in, dividing on the way out + info->alpha_weight = simple_alpha_weights[input_pixel_layout - STBIRI_RGBA]; + info->alpha_unweight = simple_alpha_unweights[output_pixel_layout - STBIRI_RGBA]; + } else if (alpha_weighting_type == 1) { + // fast alpha on the way in, leave in premultiplied form on way out + info->alpha_weight = simple_alpha_weights[input_pixel_layout - STBIRI_RGBA]; + } else if (alpha_weighting_type == 3) { + // incoming is premultiplied, fast alpha dividing on the way out - non-premultiplied + // output + info->alpha_unweight = simple_alpha_unweights[output_pixel_layout - STBIRI_RGBA]; + } + + // handle 3-chan color flipping, using the alpha weight path + if (((input_pixel_layout == STBIRI_RGB) && (output_pixel_layout == STBIRI_BGR)) || + ((input_pixel_layout == STBIRI_BGR) && (output_pixel_layout == STBIRI_RGB))) { + // do the flipping on the smaller of the two ends + if (horizontal->scale_info.scale < 1.0f) + info->alpha_unweight = stbir__simple_flip_3ch; + else + info->alpha_weight = stbir__simple_flip_3ch; + } + } + + // get all the per-split buffers + for (i = 0; i < splits; i++) { + STBIR__NEXT_PTR(info->split_info[i].decode_buffer, decode_buffer_size, float); + +#ifdef STBIR__SEPARATE_ALLOCATIONS + +#ifdef STBIR_SIMD8 + if ((info) && (effective_channels == 3)) + ++info->split_info[i].decode_buffer; // avx in 3 channel mode needs one float at + // the start of the buffer +#endif + + STBIR__NEXT_PTR(info->split_info[i].ring_buffers, + alloc_ring_buffer_num_entries * sizeof(float *), float *); + { + int j; + for (j = 0; j < alloc_ring_buffer_num_entries; j++) { + STBIR__NEXT_PTR(info->split_info[i].ring_buffers[j], ring_buffer_length_bytes, + float); +#ifdef STBIR_SIMD8 + if ((info) && (effective_channels == 3)) + ++info->split_info[i].ring_buffers[j]; // avx in 3 channel mode needs one + // float at the start of the buffer +#endif + } + } +#else + STBIR__NEXT_PTR(info->split_info[i].ring_buffer, ring_buffer_size, float); +#endif + STBIR__NEXT_PTR(info->split_info[i].vertical_buffer, vertical_buffer_size, float); + } + + // alloc memory for to-be-pivoted coeffs (if necessary) + if (vertical->is_gather == 0) { + int both; + int temp_mem_amt; + + // when in vertical scatter mode, we first build the coefficients in gather mode, and + // then pivot after, + // that means we need two buffers, so we try to use the decode buffer and ring buffer + // for this. if that is too small, we just allocate extra memory to use as this temp. + + both = vertical->gather_prescatter_contributors_size + + vertical->gather_prescatter_coefficients_size; + +#ifdef STBIR__SEPARATE_ALLOCATIONS + temp_mem_amt = decode_buffer_size; + +#ifdef STBIR_SIMD8 + if (effective_channels == 3) + --temp_mem_amt; // avx in 3 channel mode needs one float at the start of the buffer +#endif +#else + temp_mem_amt = (decode_buffer_size + ring_buffer_size + vertical_buffer_size) * splits; +#endif + if (temp_mem_amt >= both) { + if (info) { + vertical->gather_prescatter_contributors = + (stbir__contributors *)info->split_info[0].decode_buffer; + vertical->gather_prescatter_coefficients = + (float *)(((char *)info->split_info[0].decode_buffer) + + vertical->gather_prescatter_contributors_size); + } + } else { + // ring+decode memory is too small, so allocate temp memory + STBIR__NEXT_PTR(vertical->gather_prescatter_contributors, + vertical->gather_prescatter_contributors_size, stbir__contributors); + STBIR__NEXT_PTR(vertical->gather_prescatter_coefficients, + vertical->gather_prescatter_coefficients_size, float); + } + } + + STBIR__NEXT_PTR(horizontal->contributors, horizontal->contributors_size, + stbir__contributors); + STBIR__NEXT_PTR(horizontal->coefficients, horizontal->coefficients_size, float); + + // are the two filters identical?? (happens a lot with mipmap generation) + if ((horizontal->filter_kernel == vertical->filter_kernel) && + (horizontal->filter_support == vertical->filter_support) && + (horizontal->edge == vertical->edge) && + (horizontal->scale_info.output_sub_size == vertical->scale_info.output_sub_size)) { + float diff_scale = horizontal->scale_info.scale - vertical->scale_info.scale; + float diff_shift = + horizontal->scale_info.pixel_shift - vertical->scale_info.pixel_shift; + if (diff_scale < 0.0f) + diff_scale = -diff_scale; + if (diff_shift < 0.0f) + diff_shift = -diff_shift; + if ((diff_scale <= stbir__small_float) && (diff_shift <= stbir__small_float)) { + if (horizontal->is_gather == vertical->is_gather) { + copy_horizontal = 1; + goto no_vert_alloc; + } + // everything matches, but vertical is scatter, horizontal is gather, use horizontal + // coeffs for vertical pivot coeffs + possibly_use_horizontal_for_pivot = horizontal; + } + } + + STBIR__NEXT_PTR(vertical->contributors, vertical->contributors_size, stbir__contributors); + STBIR__NEXT_PTR(vertical->coefficients, vertical->coefficients_size, float); + + no_vert_alloc: + + if (info) { + STBIR_PROFILE_BUILD_START(horizontal); + + stbir__calculate_filters(horizontal, 0, user_data STBIR_ONLY_PROFILE_BUILD_SET_INFO); + + // setup the horizontal gather functions + // start with defaulting to the n_coeffs functions (specialized on channels and remnant + // leftover) + info->horizontal_gather_channels = + stbir__horizontal_gather_n_coeffs_funcs[effective_channels] + [horizontal->extent_info.widest & 3]; + // but if the number of coeffs <= 12, use another set of special cases. <=12 coeffs is + // any enlarging resize, or shrinking resize down to about 1/3 size + if (horizontal->extent_info.widest <= 12) + info->horizontal_gather_channels = + stbir__horizontal_gather_channels_funcs[effective_channels] + [horizontal->extent_info.widest - 1]; + + info->scanline_extents.conservative.n0 = conservative->n0; + info->scanline_extents.conservative.n1 = conservative->n1; + + // get exact extents + stbir__get_extents(horizontal, &info->scanline_extents); + + // pack the horizontal coeffs + horizontal->coefficient_width = stbir__pack_coefficients( + horizontal->num_contributors, horizontal->contributors, horizontal->coefficients, + horizontal->coefficient_width, horizontal->extent_info.widest, + info->scanline_extents.conservative.n0, info->scanline_extents.conservative.n1); + + STBIR_MEMCPY(&info->horizontal, horizontal, sizeof(stbir__sampler)); + + STBIR_PROFILE_BUILD_END(horizontal); + + if (copy_horizontal) { + STBIR_MEMCPY(&info->vertical, horizontal, sizeof(stbir__sampler)); + } else { + STBIR_PROFILE_BUILD_START(vertical); + + stbir__calculate_filters(vertical, possibly_use_horizontal_for_pivot, + user_data STBIR_ONLY_PROFILE_BUILD_SET_INFO); + STBIR_MEMCPY(&info->vertical, vertical, sizeof(stbir__sampler)); + + STBIR_PROFILE_BUILD_END(vertical); + } + + // setup the vertical split ranges + stbir__get_split_info( + info->split_info, info->splits, info->vertical.scale_info.output_sub_size, + info->vertical.filter_pixel_margin, info->vertical.scale_info.input_full_size); + + // now we know precisely how many entries we need + info->ring_buffer_num_entries = info->vertical.extent_info.widest; + + // we never need more ring buffer entries than the scanlines we're outputting + if ((!info->vertical.is_gather) && + (info->ring_buffer_num_entries > conservative_split_output_size)) + info->ring_buffer_num_entries = conservative_split_output_size; + STBIR_ASSERT(info->ring_buffer_num_entries <= info->alloc_ring_buffer_num_entries); + + // a few of the horizontal gather functions read past the end of the decode (but mask it + // out), + // so put in normal values so no snans or denormals accidentally sneak in (also, in + // the ring buffer for vertical first) + for (i = 0; i < splits; i++) { + int t, ofs, start; + + ofs = decode_buffer_size / 4; + +#if defined(STBIR__SEPARATE_ALLOCATIONS) && defined(STBIR_SIMD8) + if (effective_channels == 3) + --ofs; // avx in 3 channel mode needs one float at the start of the buffer, so + // we snap back for clearing +#endif + + start = ofs - 4; + if (start < 0) + start = 0; + + for (t = start; t < ofs; t++) + info->split_info[i].decode_buffer[t] = 9999.0f; + + if (vertical_first) { + int j; + for (j = 0; j < info->ring_buffer_num_entries; j++) { + for (t = start; t < ofs; t++) + stbir__get_ring_buffer_entry(info, info->split_info + i, j)[t] = + 9999.0f; + } + } + } + } + +#undef STBIR__NEXT_PTR + + // is this the first time through loop? + if (info == 0) { + alloced_total = (15 + (size_t)advance_mem); + alloced = STBIR_MALLOC(alloced_total, user_data); + if (alloced == 0) + return 0; + } else + return info; // success + } +} + +static int stbir__perform_resize(stbir__info const *info, int split_start, int split_count) { + stbir__per_split_info *split_info = info->split_info + split_start; + + STBIR_PROFILE_CLEAR_EXTRAS(); + + STBIR_PROFILE_FIRST_START(looping); + if (info->vertical.is_gather) + stbir__vertical_gather_loop(info, split_info, split_count); + else + stbir__vertical_scatter_loop(info, split_info, split_count); + STBIR_PROFILE_END(looping); + + return 1; +} + +static void stbir__update_info_from_resize(stbir__info *info, STBIR_RESIZE *resize) { + static stbir__decode_pixels_func + *decode_simple[STBIR_TYPE_HALF_FLOAT - STBIR_TYPE_UINT8_SRGB + 1] = { + /* 1ch-4ch */ stbir__decode_uint8_srgb, + stbir__decode_uint8_srgb, + 0, + stbir__decode_float_linear, + stbir__decode_half_float_linear, + }; + + static stbir__decode_pixels_func + *decode_alphas[STBIRI_AR - STBIRI_RGBA + 1][STBIR_TYPE_HALF_FLOAT - STBIR_TYPE_UINT8_SRGB + + 1] = { + {/* RGBA */ stbir__decode_uint8_srgb4_linearalpha, stbir__decode_uint8_srgb, 0, + stbir__decode_float_linear, stbir__decode_half_float_linear }, + {/* BGRA */ stbir__decode_uint8_srgb4_linearalpha_BGRA, stbir__decode_uint8_srgb_BGRA, + 0, stbir__decode_float_linear_BGRA, stbir__decode_half_float_linear_BGRA}, + {/* ARGB */ stbir__decode_uint8_srgb4_linearalpha_ARGB, stbir__decode_uint8_srgb_ARGB, + 0, stbir__decode_float_linear_ARGB, stbir__decode_half_float_linear_ARGB}, + {/* ABGR */ stbir__decode_uint8_srgb4_linearalpha_ABGR, stbir__decode_uint8_srgb_ABGR, + 0, stbir__decode_float_linear_ABGR, stbir__decode_half_float_linear_ABGR}, + {/* RA */ stbir__decode_uint8_srgb2_linearalpha, stbir__decode_uint8_srgb, 0, + stbir__decode_float_linear, stbir__decode_half_float_linear }, + {/* AR */ stbir__decode_uint8_srgb2_linearalpha_AR, stbir__decode_uint8_srgb_AR, 0, + stbir__decode_float_linear_AR, stbir__decode_half_float_linear_AR }, + }; + + static stbir__decode_pixels_func *decode_simple_scaled_or_not[2][2] = { + {stbir__decode_uint8_linear_scaled, stbir__decode_uint8_linear }, + {stbir__decode_uint16_linear_scaled, stbir__decode_uint16_linear}, + }; + + static stbir__decode_pixels_func + *decode_alphas_scaled_or_not[STBIRI_AR - STBIRI_RGBA + 1][2][2] = { + {/* RGBA */ {stbir__decode_uint8_linear_scaled, stbir__decode_uint8_linear}, + {stbir__decode_uint16_linear_scaled, stbir__decode_uint16_linear} }, + {/* BGRA */ {stbir__decode_uint8_linear_scaled_BGRA, stbir__decode_uint8_linear_BGRA}, + {stbir__decode_uint16_linear_scaled_BGRA, stbir__decode_uint16_linear_BGRA}}, + {/* ARGB */ {stbir__decode_uint8_linear_scaled_ARGB, stbir__decode_uint8_linear_ARGB}, + {stbir__decode_uint16_linear_scaled_ARGB, stbir__decode_uint16_linear_ARGB}}, + {/* ABGR */ {stbir__decode_uint8_linear_scaled_ABGR, stbir__decode_uint8_linear_ABGR}, + {stbir__decode_uint16_linear_scaled_ABGR, stbir__decode_uint16_linear_ABGR}}, + {/* RA */ {stbir__decode_uint8_linear_scaled, stbir__decode_uint8_linear}, + {stbir__decode_uint16_linear_scaled, stbir__decode_uint16_linear} }, + {/* AR */ {stbir__decode_uint8_linear_scaled_AR, stbir__decode_uint8_linear_AR}, + {stbir__decode_uint16_linear_scaled_AR, stbir__decode_uint16_linear_AR} } + }; + + static stbir__encode_pixels_func + *encode_simple[STBIR_TYPE_HALF_FLOAT - STBIR_TYPE_UINT8_SRGB + 1] = { + /* 1ch-4ch */ stbir__encode_uint8_srgb, + stbir__encode_uint8_srgb, + 0, + stbir__encode_float_linear, + stbir__encode_half_float_linear, + }; + + static stbir__encode_pixels_func + *encode_alphas[STBIRI_AR - STBIRI_RGBA + 1][STBIR_TYPE_HALF_FLOAT - STBIR_TYPE_UINT8_SRGB + + 1] = { + {/* RGBA */ stbir__encode_uint8_srgb4_linearalpha, stbir__encode_uint8_srgb, 0, + stbir__encode_float_linear, stbir__encode_half_float_linear }, + {/* BGRA */ stbir__encode_uint8_srgb4_linearalpha_BGRA, stbir__encode_uint8_srgb_BGRA, + 0, stbir__encode_float_linear_BGRA, stbir__encode_half_float_linear_BGRA}, + {/* ARGB */ stbir__encode_uint8_srgb4_linearalpha_ARGB, stbir__encode_uint8_srgb_ARGB, + 0, stbir__encode_float_linear_ARGB, stbir__encode_half_float_linear_ARGB}, + {/* ABGR */ stbir__encode_uint8_srgb4_linearalpha_ABGR, stbir__encode_uint8_srgb_ABGR, + 0, stbir__encode_float_linear_ABGR, stbir__encode_half_float_linear_ABGR}, + {/* RA */ stbir__encode_uint8_srgb2_linearalpha, stbir__encode_uint8_srgb, 0, + stbir__encode_float_linear, stbir__encode_half_float_linear }, + {/* AR */ stbir__encode_uint8_srgb2_linearalpha_AR, stbir__encode_uint8_srgb_AR, 0, + stbir__encode_float_linear_AR, stbir__encode_half_float_linear_AR } + }; + + static stbir__encode_pixels_func *encode_simple_scaled_or_not[2][2] = { + {stbir__encode_uint8_linear_scaled, stbir__encode_uint8_linear }, + {stbir__encode_uint16_linear_scaled, stbir__encode_uint16_linear}, + }; + + static stbir__encode_pixels_func + *encode_alphas_scaled_or_not[STBIRI_AR - STBIRI_RGBA + 1][2][2] = { + {/* RGBA */ {stbir__encode_uint8_linear_scaled, stbir__encode_uint8_linear}, + {stbir__encode_uint16_linear_scaled, stbir__encode_uint16_linear} }, + {/* BGRA */ {stbir__encode_uint8_linear_scaled_BGRA, stbir__encode_uint8_linear_BGRA}, + {stbir__encode_uint16_linear_scaled_BGRA, stbir__encode_uint16_linear_BGRA}}, + {/* ARGB */ {stbir__encode_uint8_linear_scaled_ARGB, stbir__encode_uint8_linear_ARGB}, + {stbir__encode_uint16_linear_scaled_ARGB, stbir__encode_uint16_linear_ARGB}}, + {/* ABGR */ {stbir__encode_uint8_linear_scaled_ABGR, stbir__encode_uint8_linear_ABGR}, + {stbir__encode_uint16_linear_scaled_ABGR, stbir__encode_uint16_linear_ABGR}}, + {/* RA */ {stbir__encode_uint8_linear_scaled, stbir__encode_uint8_linear}, + {stbir__encode_uint16_linear_scaled, stbir__encode_uint16_linear} }, + {/* AR */ {stbir__encode_uint8_linear_scaled_AR, stbir__encode_uint8_linear_AR}, + {stbir__encode_uint16_linear_scaled_AR, stbir__encode_uint16_linear_AR} } + }; + + stbir__decode_pixels_func *decode_pixels = 0; + stbir__encode_pixels_func *encode_pixels = 0; + stbir_datatype input_type, output_type; + + input_type = resize->input_data_type; + output_type = resize->output_data_type; + info->input_data = resize->input_pixels; + info->input_stride_bytes = resize->input_stride_in_bytes; + info->output_stride_bytes = resize->output_stride_in_bytes; + + // if we're completely point sampling, then we can turn off SRGB + if ((info->horizontal.filter_enum == STBIR_FILTER_POINT_SAMPLE) && + (info->vertical.filter_enum == STBIR_FILTER_POINT_SAMPLE)) { + if (((input_type == STBIR_TYPE_UINT8_SRGB) || + (input_type == STBIR_TYPE_UINT8_SRGB_ALPHA)) && + ((output_type == STBIR_TYPE_UINT8_SRGB) || + (output_type == STBIR_TYPE_UINT8_SRGB_ALPHA))) { + input_type = STBIR_TYPE_UINT8; + output_type = STBIR_TYPE_UINT8; + } + } + + // recalc the output and input strides + if (info->input_stride_bytes == 0) + info->input_stride_bytes = info->channels * info->horizontal.scale_info.input_full_size * + stbir__type_size[input_type]; + + if (info->output_stride_bytes == 0) + info->output_stride_bytes = info->channels * info->horizontal.scale_info.output_sub_size * + stbir__type_size[output_type]; + + // calc offset + info->output_data = ((char *)resize->output_pixels) + + ((size_t)info->offset_y * (size_t)resize->output_stride_in_bytes) + + (info->offset_x * info->channels * stbir__type_size[output_type]); + + info->in_pixels_cb = resize->input_cb; + info->user_data = resize->user_data; + info->out_pixels_cb = resize->output_cb; + + // setup the input format converters + if ((input_type == STBIR_TYPE_UINT8) || (input_type == STBIR_TYPE_UINT16)) { + int non_scaled = 0; + + // check if we can run unscaled - 0-255.0/0-65535.0 instead of 0-1.0 (which is a tiny bit + // faster when doing linear 8->8 or 16->16) + if ((!info->alpha_weight) && + (!info->alpha_unweight)) // don't short circuit when alpha weighting (get everything to + // 0-1.0 as usual) + if (((input_type == STBIR_TYPE_UINT8) && (output_type == STBIR_TYPE_UINT8)) || + ((input_type == STBIR_TYPE_UINT16) && (output_type == STBIR_TYPE_UINT16))) + non_scaled = 1; + + if (info->input_pixel_layout_internal <= STBIRI_4CHANNEL) + decode_pixels = + decode_simple_scaled_or_not[input_type == STBIR_TYPE_UINT16][non_scaled]; + else + decode_pixels = + decode_alphas_scaled_or_not[(info->input_pixel_layout_internal - STBIRI_RGBA) % + (STBIRI_AR - STBIRI_RGBA + 1)] + [input_type == STBIR_TYPE_UINT16][non_scaled]; + } else { + if (info->input_pixel_layout_internal <= STBIRI_4CHANNEL) + decode_pixels = decode_simple[input_type - STBIR_TYPE_UINT8_SRGB]; + else + decode_pixels = + decode_alphas[(info->input_pixel_layout_internal - STBIRI_RGBA) % + (STBIRI_AR - STBIRI_RGBA + 1)][input_type - STBIR_TYPE_UINT8_SRGB]; + } + + // setup the output format converters + if ((output_type == STBIR_TYPE_UINT8) || (output_type == STBIR_TYPE_UINT16)) { + int non_scaled = 0; + + // check if we can run unscaled - 0-255.0/0-65535.0 instead of 0-1.0 (which is a tiny bit + // faster when doing linear 8->8 or 16->16) + if ((!info->alpha_weight) && + (!info->alpha_unweight)) // don't short circuit when alpha weighting (get everything to + // 0-1.0 as usual) + if (((input_type == STBIR_TYPE_UINT8) && (output_type == STBIR_TYPE_UINT8)) || + ((input_type == STBIR_TYPE_UINT16) && (output_type == STBIR_TYPE_UINT16))) + non_scaled = 1; + + if (info->output_pixel_layout_internal <= STBIRI_4CHANNEL) + encode_pixels = + encode_simple_scaled_or_not[output_type == STBIR_TYPE_UINT16][non_scaled]; + else + encode_pixels = + encode_alphas_scaled_or_not[(info->output_pixel_layout_internal - STBIRI_RGBA) % + (STBIRI_AR - STBIRI_RGBA + 1)] + [output_type == STBIR_TYPE_UINT16][non_scaled]; + } else { + if (info->output_pixel_layout_internal <= STBIRI_4CHANNEL) + encode_pixels = encode_simple[output_type - STBIR_TYPE_UINT8_SRGB]; + else + encode_pixels = + encode_alphas[(info->output_pixel_layout_internal - STBIRI_RGBA) % + (STBIRI_AR - STBIRI_RGBA + 1)][output_type - STBIR_TYPE_UINT8_SRGB]; + } + + info->input_type = input_type; + info->output_type = output_type; + info->decode_pixels = decode_pixels; + info->encode_pixels = encode_pixels; +} + +static void stbir__clip(int *outx, int *outsubw, int outw, double *u0, double *u1) { + double per, adj; + int over; + + // do left/top edge + if (*outx < 0) { + per = ((double)*outx) / ((double)*outsubw); // is negative + adj = per * (*u1 - *u0); + *u0 -= adj; // increases u0 + *outx = 0; + } + + // do right/bot edge + over = outw - (*outx + *outsubw); + if (over < 0) { + per = ((double)over) / ((double)*outsubw); // is negative + adj = per * (*u1 - *u0); + *u1 += adj; // decrease u1 + *outsubw = outw - *outx; + } +} + +// converts a double to a rational that has less than one float bit of error (returns 0 if unable to +// do so) +static int stbir__double_to_rational(double f, stbir_uint32 limit, stbir_uint32 *numer, + stbir_uint32 *denom, + int limit_denom) // limit_denom (1) or limit numer (0) +{ + double err; + stbir_uint64 top, bot; + stbir_uint64 numer_last = 0; + stbir_uint64 denom_last = 1; + stbir_uint64 numer_estimate = 1; + stbir_uint64 denom_estimate = 0; + + // scale to past float error range + top = (stbir_uint64)(f * (double)(1 << 25)); + bot = 1 << 25; + + // keep refining, but usually stops in a few loops - usually 5 for bad cases + for (;;) { + stbir_uint64 est, temp; + + // hit limit, break out and do best full range estimate + if (((limit_denom) ? denom_estimate : numer_estimate) >= limit) + break; + + // is the current error less than 1 bit of a float? if so, we're done + if (denom_estimate) { + err = ((double)numer_estimate / (double)denom_estimate) - f; + if (err < 0.0) + err = -err; + if (err < (1.0 / (double)(1 << 24))) { + // yup, found it + *numer = (stbir_uint32)numer_estimate; + *denom = (stbir_uint32)denom_estimate; + return 1; + } + } + + // no more refinement bits left? break out and do full range estimate + if (bot == 0) + break; + + // gcd the estimate bits + est = top / bot; + temp = top % bot; + top = bot; + bot = temp; + + // move remainders + temp = est * denom_estimate + denom_last; + denom_last = denom_estimate; + denom_estimate = temp; + + // move remainders + temp = est * numer_estimate + numer_last; + numer_last = numer_estimate; + numer_estimate = temp; + } + + // we didn't fine anything good enough for float, use a full range estimate + if (limit_denom) { + numer_estimate = (stbir_uint64)(f * (double)limit + 0.5); + denom_estimate = limit; + } else { + numer_estimate = limit; + denom_estimate = (stbir_uint64)(((double)limit / f) + 0.5); + } + + *numer = (stbir_uint32)numer_estimate; + *denom = (stbir_uint32)denom_estimate; + + err = (denom_estimate) + ? (((double)(stbir_uint32)numer_estimate / (double)(stbir_uint32)denom_estimate) - f) + : 1.0; + if (err < 0.0) + err = -err; + return (err < (1.0 / (double)(1 << 24))) ? 1 : 0; +} + +static int stbir__calculate_region_transform(stbir__scale_info *scale_info, int output_full_range, + int *output_offset, int output_sub_range, + int input_full_range, double input_s0, + double input_s1) { + double output_range, input_range, output_s, input_s, ratio, scale; + + input_s = input_s1 - input_s0; + + // null area + if ((output_full_range == 0) || (input_full_range == 0) || (output_sub_range == 0) || + (input_s <= stbir__small_float)) + return 0; + + // are either of the ranges completely out of bounds? + if ((*output_offset >= output_full_range) || ((*output_offset + output_sub_range) <= 0) || + (input_s0 >= (1.0f - stbir__small_float)) || (input_s1 <= stbir__small_float)) + return 0; + + output_range = (double)output_full_range; + input_range = (double)input_full_range; + + output_s = ((double)output_sub_range) / output_range; + + // figure out the scaling to use + ratio = output_s / input_s; + + // save scale before clipping + scale = (output_range / input_range) * ratio; + scale_info->scale = (float)scale; + scale_info->inv_scale = (float)(1.0 / scale); + + // clip output area to left/right output edges (and adjust input area) + stbir__clip(output_offset, &output_sub_range, output_full_range, &input_s0, &input_s1); + + // recalc input area + input_s = input_s1 - input_s0; + + // after clipping do we have zero input area? + if (input_s <= stbir__small_float) + return 0; + + // calculate and store the starting source offsets in output pixel space + scale_info->pixel_shift = (float)(input_s0 * ratio * output_range); + + scale_info->scale_is_rational = stbir__double_to_rational( + scale, (scale <= 1.0) ? output_full_range : input_full_range, &scale_info->scale_numerator, + &scale_info->scale_denominator, (scale >= 1.0)); + + scale_info->input_full_size = input_full_range; + scale_info->output_sub_size = output_sub_range; + + return 1; +} + +static void stbir__init_and_set_layout(STBIR_RESIZE *resize, stbir_pixel_layout pixel_layout, + stbir_datatype data_type) { + resize->input_cb = 0; + resize->output_cb = 0; + resize->user_data = resize; + resize->samplers = 0; + resize->called_alloc = 0; + resize->horizontal_filter = STBIR_FILTER_DEFAULT; + resize->horizontal_filter_kernel = 0; + resize->horizontal_filter_support = 0; + resize->vertical_filter = STBIR_FILTER_DEFAULT; + resize->vertical_filter_kernel = 0; + resize->vertical_filter_support = 0; + resize->horizontal_edge = STBIR_EDGE_CLAMP; + resize->vertical_edge = STBIR_EDGE_CLAMP; + resize->input_s0 = 0; + resize->input_t0 = 0; + resize->input_s1 = 1; + resize->input_t1 = 1; + resize->output_subx = 0; + resize->output_suby = 0; + resize->output_subw = resize->output_w; + resize->output_subh = resize->output_h; + resize->input_data_type = data_type; + resize->output_data_type = data_type; + resize->input_pixel_layout_public = pixel_layout; + resize->output_pixel_layout_public = pixel_layout; + resize->needs_rebuild = 1; +} + +STBIRDEF void stbir_resize_init(STBIR_RESIZE *resize, const void *input_pixels, int input_w, + int input_h, int input_stride_in_bytes, // stride can be zero + void *output_pixels, int output_w, int output_h, + int output_stride_in_bytes, // stride can be zero + stbir_pixel_layout pixel_layout, stbir_datatype data_type) { + resize->input_pixels = input_pixels; + resize->input_w = input_w; + resize->input_h = input_h; + resize->input_stride_in_bytes = input_stride_in_bytes; + resize->output_pixels = output_pixels; + resize->output_w = output_w; + resize->output_h = output_h; + resize->output_stride_in_bytes = output_stride_in_bytes; + resize->fast_alpha = 0; + + stbir__init_and_set_layout(resize, pixel_layout, data_type); +} + +// You can update parameters any time after resize_init +STBIRDEF void +stbir_set_datatypes(STBIR_RESIZE *resize, stbir_datatype input_type, + stbir_datatype output_type) // by default, datatype from resize_init +{ + resize->input_data_type = input_type; + resize->output_data_type = output_type; + if ((resize->samplers) && (!resize->needs_rebuild)) + stbir__update_info_from_resize(resize->samplers, resize); +} + +STBIRDEF void +stbir_set_pixel_callbacks(STBIR_RESIZE *resize, stbir_input_callback *input_cb, + stbir_output_callback *output_cb) // no callbacks by default +{ + resize->input_cb = input_cb; + resize->output_cb = output_cb; + + if ((resize->samplers) && (!resize->needs_rebuild)) { + resize->samplers->in_pixels_cb = input_cb; + resize->samplers->out_pixels_cb = output_cb; + } +} + +STBIRDEF void stbir_set_user_data(STBIR_RESIZE *resize, + void *user_data) // pass back STBIR_RESIZE* by default +{ + resize->user_data = user_data; + if ((resize->samplers) && (!resize->needs_rebuild)) + resize->samplers->user_data = user_data; +} + +STBIRDEF void stbir_set_buffer_ptrs(STBIR_RESIZE *resize, const void *input_pixels, + int input_stride_in_bytes, void *output_pixels, + int output_stride_in_bytes) { + resize->input_pixels = input_pixels; + resize->input_stride_in_bytes = input_stride_in_bytes; + resize->output_pixels = output_pixels; + resize->output_stride_in_bytes = output_stride_in_bytes; + if ((resize->samplers) && (!resize->needs_rebuild)) + stbir__update_info_from_resize(resize->samplers, resize); +} + +STBIRDEF int stbir_set_edgemodes(STBIR_RESIZE *resize, stbir_edge horizontal_edge, + stbir_edge vertical_edge) // CLAMP by default +{ + resize->horizontal_edge = horizontal_edge; + resize->vertical_edge = vertical_edge; + resize->needs_rebuild = 1; + return 1; +} + +STBIRDEF int stbir_set_filters( + STBIR_RESIZE *resize, stbir_filter horizontal_filter, + stbir_filter vertical_filter) // STBIR_DEFAULT_FILTER_UPSAMPLE/DOWNSAMPLE by default +{ + resize->horizontal_filter = horizontal_filter; + resize->vertical_filter = vertical_filter; + resize->needs_rebuild = 1; + return 1; +} + +STBIRDEF int stbir_set_filter_callbacks(STBIR_RESIZE *resize, + stbir__kernel_callback *horizontal_filter, + stbir__support_callback *horizontal_support, + stbir__kernel_callback *vertical_filter, + stbir__support_callback *vertical_support) { + resize->horizontal_filter_kernel = horizontal_filter; + resize->horizontal_filter_support = horizontal_support; + resize->vertical_filter_kernel = vertical_filter; + resize->vertical_filter_support = vertical_support; + resize->needs_rebuild = 1; + return 1; +} + +STBIRDEF int +stbir_set_pixel_layouts(STBIR_RESIZE *resize, stbir_pixel_layout input_pixel_layout, + stbir_pixel_layout output_pixel_layout) // sets new pixel layouts +{ + resize->input_pixel_layout_public = input_pixel_layout; + resize->output_pixel_layout_public = output_pixel_layout; + resize->needs_rebuild = 1; + return 1; +} + +STBIRDEF int +stbir_set_non_pm_alpha_speed_over_quality(STBIR_RESIZE *resize, + int non_pma_alpha_speed_over_quality) // sets alpha speed +{ + resize->fast_alpha = non_pma_alpha_speed_over_quality; + resize->needs_rebuild = 1; + return 1; +} + +STBIRDEF int stbir_set_input_subrect(STBIR_RESIZE *resize, double s0, double t0, double s1, + double t1) // sets input region (full region by default) +{ + resize->input_s0 = s0; + resize->input_t0 = t0; + resize->input_s1 = s1; + resize->input_t1 = t1; + resize->needs_rebuild = 1; + + // are we inbounds? + if ((s1 < stbir__small_float) || ((s1 - s0) < stbir__small_float) || + (t1 < stbir__small_float) || ((t1 - t0) < stbir__small_float) || + (s0 > (1.0f - stbir__small_float)) || (t0 > (1.0f - stbir__small_float))) + return 0; + + return 1; +} + +STBIRDEF int stbir_set_output_pixel_subrect(STBIR_RESIZE *resize, int subx, int suby, int subw, + int subh) // sets input region (full region by default) +{ + resize->output_subx = subx; + resize->output_suby = suby; + resize->output_subw = subw; + resize->output_subh = subh; + resize->needs_rebuild = 1; + + // are we inbounds? + if ((subx >= resize->output_w) || ((subx + subw) <= 0) || (suby >= resize->output_h) || + ((suby + subh) <= 0) || (subw == 0) || (subh == 0)) + return 0; + + return 1; +} + +STBIRDEF int stbir_set_pixel_subrect(STBIR_RESIZE *resize, int subx, int suby, int subw, + int subh) // sets both regions (full regions by default) +{ + double s0, t0, s1, t1; + + s0 = ((double)subx) / ((double)resize->output_w); + t0 = ((double)suby) / ((double)resize->output_h); + s1 = ((double)(subx + subw)) / ((double)resize->output_w); + t1 = ((double)(suby + subh)) / ((double)resize->output_h); + + resize->input_s0 = s0; + resize->input_t0 = t0; + resize->input_s1 = s1; + resize->input_t1 = t1; + resize->output_subx = subx; + resize->output_suby = suby; + resize->output_subw = subw; + resize->output_subh = subh; + resize->needs_rebuild = 1; + + // are we inbounds? + if ((subx >= resize->output_w) || ((subx + subw) <= 0) || (suby >= resize->output_h) || + ((suby + subh) <= 0) || (subw == 0) || (subh == 0)) + return 0; + + return 1; +} + +static int stbir__perform_build(STBIR_RESIZE *resize, int splits) { + stbir__contributors conservative = {0, 0}; + stbir__sampler horizontal, vertical; + int new_output_subx, new_output_suby; + stbir__info *out_info; +#ifdef STBIR_PROFILE + stbir__info + profile_infod; // used to contain building profile info before everything is allocated + stbir__info *profile_info = &profile_infod; +#endif + + // have we already built the samplers? + if (resize->samplers) + return 0; + +#define STBIR_RETURN_ERROR_AND_ASSERT(exp) \ + STBIR_ASSERT(!(exp)); \ + if (exp) \ + return 0; + STBIR_RETURN_ERROR_AND_ASSERT((unsigned)resize->horizontal_filter >= STBIR_FILTER_OTHER) + STBIR_RETURN_ERROR_AND_ASSERT((unsigned)resize->vertical_filter >= STBIR_FILTER_OTHER) +#undef STBIR_RETURN_ERROR_AND_ASSERT + + if (splits <= 0) + return 0; + + STBIR_PROFILE_BUILD_FIRST_START(build); + + new_output_subx = resize->output_subx; + new_output_suby = resize->output_suby; + + // do horizontal clip and scale calcs + if (!stbir__calculate_region_transform(&horizontal.scale_info, resize->output_w, + &new_output_subx, resize->output_subw, resize->input_w, + resize->input_s0, resize->input_s1)) + return 0; + + // do vertical clip and scale calcs + if (!stbir__calculate_region_transform(&vertical.scale_info, resize->output_h, &new_output_suby, + resize->output_subh, resize->input_h, resize->input_t0, + resize->input_t1)) + return 0; + + // if nothing to do, just return + if ((horizontal.scale_info.output_sub_size == 0) || (vertical.scale_info.output_sub_size == 0)) + return 0; + + stbir__set_sampler(&horizontal, resize->horizontal_filter, resize->horizontal_filter_kernel, + resize->horizontal_filter_support, resize->horizontal_edge, + &horizontal.scale_info, 1, resize->user_data); + stbir__get_conservative_extents(&horizontal, &conservative, resize->user_data); + stbir__set_sampler(&vertical, resize->vertical_filter, resize->horizontal_filter_kernel, + resize->vertical_filter_support, resize->vertical_edge, &vertical.scale_info, + 0, resize->user_data); + + if ((vertical.scale_info.output_sub_size / splits) < + STBIR_FORCE_MINIMUM_SCANLINES_FOR_SPLITS) // each split should be a minimum of 4 scanlines + // (handwavey choice) + { + splits = vertical.scale_info.output_sub_size / STBIR_FORCE_MINIMUM_SCANLINES_FOR_SPLITS; + if (splits == 0) + splits = 1; + } + + STBIR_PROFILE_BUILD_START(alloc); + out_info = stbir__alloc_internal_mem_and_build_samplers( + &horizontal, &vertical, &conservative, resize->input_pixel_layout_public, + resize->output_pixel_layout_public, splits, new_output_subx, new_output_suby, + resize->fast_alpha, resize->user_data STBIR_ONLY_PROFILE_BUILD_SET_INFO); + STBIR_PROFILE_BUILD_END(alloc); + STBIR_PROFILE_BUILD_END(build); + + if (out_info) { + resize->splits = splits; + resize->samplers = out_info; + resize->needs_rebuild = 0; +#ifdef STBIR_PROFILE + STBIR_MEMCPY(&out_info->profile, &profile_infod.profile, sizeof(out_info->profile)); +#endif + + // update anything that can be changed without recalcing samplers + stbir__update_info_from_resize(out_info, resize); + + return splits; + } + + return 0; +} + +void stbir_free_samplers(STBIR_RESIZE *resize) { + if (resize->samplers) { + stbir__free_internal_mem(resize->samplers); + resize->samplers = 0; + resize->called_alloc = 0; + } +} + +STBIRDEF int stbir_build_samplers_with_splits(STBIR_RESIZE *resize, int splits) { + if ((resize->samplers == 0) || (resize->needs_rebuild)) { + if (resize->samplers) + stbir_free_samplers(resize); + + resize->called_alloc = 1; + return stbir__perform_build(resize, splits); + } + + STBIR_PROFILE_BUILD_CLEAR(resize->samplers); + + return 1; +} + +STBIRDEF int stbir_build_samplers(STBIR_RESIZE *resize) { + return stbir_build_samplers_with_splits(resize, 1); +} + +STBIRDEF int stbir_resize_extended(STBIR_RESIZE *resize) { + int result; + + if ((resize->samplers == 0) || (resize->needs_rebuild)) { + int alloc_state = resize->called_alloc; // remember allocated state + + if (resize->samplers) { + stbir__free_internal_mem(resize->samplers); + resize->samplers = 0; + } + + if (!stbir_build_samplers(resize)) + return 0; + + resize->called_alloc = alloc_state; + + // if build_samplers succeeded (above), but there are no samplers set, then + // the area to stretch into was zero pixels, so don't do anything and return + // success + if (resize->samplers == 0) + return 1; + } else { + // didn't build anything - clear it + STBIR_PROFILE_BUILD_CLEAR(resize->samplers); + } + + // do resize + result = stbir__perform_resize(resize->samplers, 0, resize->splits); + + // if we alloced, then free + if (!resize->called_alloc) { + stbir_free_samplers(resize); + resize->samplers = 0; + } + + return result; +} + +STBIRDEF int stbir_resize_extended_split(STBIR_RESIZE *resize, int split_start, int split_count) { + STBIR_ASSERT(resize->samplers); + + // if we're just doing the whole thing, call full + if ((split_start == -1) || ((split_start == 0) && (split_count == resize->splits))) + return stbir_resize_extended(resize); + + // you **must** build samplers first when using split resize + if ((resize->samplers == 0) || (resize->needs_rebuild)) + return 0; + + if ((split_start >= resize->splits) || (split_start < 0) || + ((split_start + split_count) > resize->splits) || (split_count <= 0)) + return 0; + + // do resize + return stbir__perform_resize(resize->samplers, split_start, split_count); +} + +static int stbir__check_output_stuff(void **ret_ptr, int *ret_pitch, void *output_pixels, + int type_size, int output_w, int output_h, + int output_stride_in_bytes, + stbir_internal_pixel_layout pixel_layout) { + size_t size; + int pitch; + void *ptr; + + pitch = output_w * type_size * stbir__pixel_channels[pixel_layout]; + if (pitch == 0) + return 0; + + if (output_stride_in_bytes == 0) + output_stride_in_bytes = pitch; + + if (output_stride_in_bytes < pitch) + return 0; + + size = (size_t)output_stride_in_bytes * (size_t)output_h; + if (size == 0) + return 0; + + *ret_ptr = 0; + *ret_pitch = output_stride_in_bytes; + + if (output_pixels == 0) { + ptr = STBIR_MALLOC(size, 0); + if (ptr == 0) + return 0; + + *ret_ptr = ptr; + *ret_pitch = pitch; + } + + return 1; +} + +STBIRDEF unsigned char *stbir_resize_uint8_linear(const unsigned char *input_pixels, int input_w, + int input_h, int input_stride_in_bytes, + unsigned char *output_pixels, int output_w, + int output_h, int output_stride_in_bytes, + stbir_pixel_layout pixel_layout) { + STBIR_RESIZE resize; + unsigned char *optr; + int opitch; + + if (!stbir__check_output_stuff((void **)&optr, &opitch, output_pixels, sizeof(unsigned char), + output_w, output_h, output_stride_in_bytes, + stbir__pixel_layout_convert_public_to_internal[pixel_layout])) + return 0; + + stbir_resize_init(&resize, input_pixels, input_w, input_h, input_stride_in_bytes, + (optr) ? optr : output_pixels, output_w, output_h, opitch, pixel_layout, + STBIR_TYPE_UINT8); + + if (!stbir_resize_extended(&resize)) { + if (optr) + STBIR_FREE(optr, 0); + return 0; + } + + return (optr) ? optr : output_pixels; +} + +STBIRDEF unsigned char *stbir_resize_uint8_srgb(const unsigned char *input_pixels, int input_w, + int input_h, int input_stride_in_bytes, + unsigned char *output_pixels, int output_w, + int output_h, int output_stride_in_bytes, + stbir_pixel_layout pixel_layout) { + STBIR_RESIZE resize; + unsigned char *optr; + int opitch; + + if (!stbir__check_output_stuff((void **)&optr, &opitch, output_pixels, sizeof(unsigned char), + output_w, output_h, output_stride_in_bytes, + stbir__pixel_layout_convert_public_to_internal[pixel_layout])) + return 0; + + stbir_resize_init(&resize, input_pixels, input_w, input_h, input_stride_in_bytes, + (optr) ? optr : output_pixels, output_w, output_h, opitch, pixel_layout, + STBIR_TYPE_UINT8_SRGB); + + if (!stbir_resize_extended(&resize)) { + if (optr) + STBIR_FREE(optr, 0); + return 0; + } + + return (optr) ? optr : output_pixels; +} + +STBIRDEF float *stbir_resize_float_linear(const float *input_pixels, int input_w, int input_h, + int input_stride_in_bytes, float *output_pixels, + int output_w, int output_h, int output_stride_in_bytes, + stbir_pixel_layout pixel_layout) { + STBIR_RESIZE resize; + float *optr; + int opitch; + + if (!stbir__check_output_stuff((void **)&optr, &opitch, output_pixels, sizeof(float), output_w, + output_h, output_stride_in_bytes, + stbir__pixel_layout_convert_public_to_internal[pixel_layout])) + return 0; + + stbir_resize_init(&resize, input_pixels, input_w, input_h, input_stride_in_bytes, + (optr) ? optr : output_pixels, output_w, output_h, opitch, pixel_layout, + STBIR_TYPE_FLOAT); + + if (!stbir_resize_extended(&resize)) { + if (optr) + STBIR_FREE(optr, 0); + return 0; + } + + return (optr) ? optr : output_pixels; +} + +STBIRDEF void *stbir_resize(const void *input_pixels, int input_w, int input_h, + int input_stride_in_bytes, void *output_pixels, int output_w, + int output_h, int output_stride_in_bytes, + stbir_pixel_layout pixel_layout, stbir_datatype data_type, + stbir_edge edge, stbir_filter filter) { + STBIR_RESIZE resize; + float *optr; + int opitch; + + if (!stbir__check_output_stuff( + (void **)&optr, &opitch, output_pixels, stbir__type_size[data_type], output_w, output_h, + output_stride_in_bytes, stbir__pixel_layout_convert_public_to_internal[pixel_layout])) + return 0; + + stbir_resize_init(&resize, input_pixels, input_w, input_h, input_stride_in_bytes, + (optr) ? optr : output_pixels, output_w, output_h, output_stride_in_bytes, + pixel_layout, data_type); + + resize.horizontal_edge = edge; + resize.vertical_edge = edge; + resize.horizontal_filter = filter; + resize.vertical_filter = filter; + + if (!stbir_resize_extended(&resize)) { + if (optr) + STBIR_FREE(optr, 0); + return 0; + } + + return (optr) ? optr : output_pixels; +} + +#ifdef STBIR_PROFILE + +STBIRDEF void stbir_resize_build_profile_info(STBIR_PROFILE_INFO *info, + STBIR_RESIZE const *resize) { + static char const *bdescriptions[6] = { + "Building", "Allocating", "Horizontal sampler", + "Vertical sampler", "Coefficient cleanup", "Coefficient piovot"}; + stbir__info *samp = resize->samplers; + int i; + + typedef int + testa[(STBIR__ARRAY_SIZE(bdescriptions) == (STBIR__ARRAY_SIZE(samp->profile.array) - 1)) + ? 1 + : -1]; + typedef int testb[(sizeof(samp->profile.array) == (sizeof(samp->profile.named))) ? 1 : -1]; + typedef int testc[(sizeof(info->clocks) >= (sizeof(samp->profile.named))) ? 1 : -1]; + + for (i = 0; i < STBIR__ARRAY_SIZE(bdescriptions); i++) + info->clocks[i] = samp->profile.array[i + 1]; + + info->total_clocks = samp->profile.named.total; + info->descriptions = bdescriptions; + info->count = STBIR__ARRAY_SIZE(bdescriptions); +} + +STBIRDEF void stbir_resize_split_profile_info(STBIR_PROFILE_INFO *info, STBIR_RESIZE const *resize, + int split_start, int split_count) { + static char const *descriptions[7] = { + "Looping", "Vertical sampling", "Horizontal sampling", "Scanline input", + "Scanline output", "Alpha weighting", "Alpha unweighting"}; + stbir__per_split_info *split_info; + int s, i; + + typedef int testa[(STBIR__ARRAY_SIZE(descriptions) == + (STBIR__ARRAY_SIZE(split_info->profile.array) - 1)) + ? 1 + : -1]; + typedef int + testb[(sizeof(split_info->profile.array) == (sizeof(split_info->profile.named))) ? 1 : -1]; + typedef int testc[(sizeof(info->clocks) >= (sizeof(split_info->profile.named))) ? 1 : -1]; + + if (split_start == -1) { + split_start = 0; + split_count = resize->samplers->splits; + } + + if ((split_start >= resize->splits) || (split_start < 0) || + ((split_start + split_count) > resize->splits) || (split_count <= 0)) { + info->total_clocks = 0; + info->descriptions = 0; + info->count = 0; + return; + } + + split_info = resize->samplers->split_info + split_start; + + // sum up the profile from all the splits + for (i = 0; i < STBIR__ARRAY_SIZE(descriptions); i++) { + stbir_uint64 sum = 0; + for (s = 0; s < split_count; s++) + sum += split_info[s].profile.array[i + 1]; + info->clocks[i] = sum; + } + + info->total_clocks = split_info->profile.named.total; + info->descriptions = descriptions; + info->count = STBIR__ARRAY_SIZE(descriptions); +} + +STBIRDEF void stbir_resize_extended_profile_info(STBIR_PROFILE_INFO *info, + STBIR_RESIZE const *resize) { + stbir_resize_split_profile_info(info, resize, -1, 0); +} + +#endif // STBIR_PROFILE + +#undef STBIR_BGR +#undef STBIR_1CHANNEL +#undef STBIR_2CHANNEL +#undef STBIR_RGB +#undef STBIR_RGBA +#undef STBIR_4CHANNEL +#undef STBIR_BGRA +#undef STBIR_ARGB +#undef STBIR_ABGR +#undef STBIR_RA +#undef STBIR_AR +#undef STBIR_RGBA_PM +#undef STBIR_BGRA_PM +#undef STBIR_ARGB_PM +#undef STBIR_ABGR_PM +#undef STBIR_RA_PM +#undef STBIR_AR_PM + +#endif // STB_IMAGE_RESIZE_IMPLEMENTATION + +#else // STB_IMAGE_RESIZE_HORIZONTALS&STB_IMAGE_RESIZE_DO_VERTICALS + +// we reinclude the header file to define all the horizontal functions +// specializing each function for the number of coeffs is 20-40% faster *OVERALL* + +// by including the header file again this way, we can still debug the functions + +#define STBIR_strs_join2(start, mid, end) start##mid##end +#define STBIR_strs_join1(start, mid, end) STBIR_strs_join2(start, mid, end) + +#define STBIR_strs_join24(start, mid1, mid2, end) start##mid1##mid2##end +#define STBIR_strs_join14(start, mid1, mid2, end) STBIR_strs_join24(start, mid1, mid2, end) + +#ifdef STB_IMAGE_RESIZE_DO_CODERS + +#ifdef stbir__decode_suffix +#define STBIR__CODER_NAME(name) STBIR_strs_join1(name, _, stbir__decode_suffix) +#else +#define STBIR__CODER_NAME(name) name +#endif + +#ifdef stbir__decode_swizzle +#define stbir__decode_simdf8_flip(reg) \ + STBIR_strs_join1( \ + STBIR_strs_join1( \ + STBIR_strs_join1(STBIR_strs_join1(stbir__simdf8_0123to, stbir__decode_order0, \ + stbir__decode_order1), \ + stbir__decode_order2, stbir__decode_order3), \ + stbir__decode_order0, stbir__decode_order1), \ + stbir__decode_order2, stbir__decode_order3)(reg, reg) +#define stbir__decode_simdf4_flip(reg) \ + STBIR_strs_join1( \ + STBIR_strs_join1(stbir__simdf_0123to, stbir__decode_order0, stbir__decode_order1), \ + stbir__decode_order2, stbir__decode_order3)(reg, reg) +#define stbir__encode_simdf8_unflip(reg) \ + STBIR_strs_join1( \ + STBIR_strs_join1( \ + STBIR_strs_join1(STBIR_strs_join1(stbir__simdf8_0123to, stbir__encode_order0, \ + stbir__encode_order1), \ + stbir__encode_order2, stbir__encode_order3), \ + stbir__encode_order0, stbir__encode_order1), \ + stbir__encode_order2, stbir__encode_order3)(reg, reg) +#define stbir__encode_simdf4_unflip(reg) \ + STBIR_strs_join1( \ + STBIR_strs_join1(stbir__simdf_0123to, stbir__encode_order0, stbir__encode_order1), \ + stbir__encode_order2, stbir__encode_order3)(reg, reg) +#else +#define stbir__decode_order0 0 +#define stbir__decode_order1 1 +#define stbir__decode_order2 2 +#define stbir__decode_order3 3 +#define stbir__encode_order0 0 +#define stbir__encode_order1 1 +#define stbir__encode_order2 2 +#define stbir__encode_order3 3 +#define stbir__decode_simdf8_flip(reg) +#define stbir__decode_simdf4_flip(reg) +#define stbir__encode_simdf8_unflip(reg) +#define stbir__encode_simdf4_unflip(reg) +#endif + +#ifdef STBIR_SIMD8 +#define stbir__encode_simdfX_unflip stbir__encode_simdf8_unflip +#else +#define stbir__encode_simdfX_unflip stbir__encode_simdf4_unflip +#endif + +static void STBIR__CODER_NAME(stbir__decode_uint8_linear_scaled)(float *decodep, + int width_times_channels, + void const *inputp) { + float STBIR_STREAMOUT_PTR(*) decode = decodep; + float *decode_end = (float *)decode + width_times_channels; + unsigned char const *input = (unsigned char const *)inputp; + +#ifdef STBIR_SIMD + unsigned char const *end_input_m16 = input + width_times_channels - 16; + if (width_times_channels >= 16) { + decode_end -= 16; + STBIR_NO_UNROLL_LOOP_START_INF_FOR + for (;;) { +#ifdef STBIR_SIMD8 + stbir__simdi i; + stbir__simdi8 o0, o1; + stbir__simdf8 of0, of1; + STBIR_NO_UNROLL(decode); + stbir__simdi_load(i, input); + stbir__simdi8_expand_u8_to_u32(o0, o1, i); + stbir__simdi8_convert_i32_to_float(of0, o0); + stbir__simdi8_convert_i32_to_float(of1, o1); + stbir__simdf8_mult(of0, of0, STBIR_max_uint8_as_float_inverted8); + stbir__simdf8_mult(of1, of1, STBIR_max_uint8_as_float_inverted8); + stbir__decode_simdf8_flip(of0); + stbir__decode_simdf8_flip(of1); + stbir__simdf8_store(decode + 0, of0); + stbir__simdf8_store(decode + 8, of1); +#else + stbir__simdi i, o0, o1, o2, o3; + stbir__simdf of0, of1, of2, of3; + STBIR_NO_UNROLL(decode); + stbir__simdi_load(i, input); + stbir__simdi_expand_u8_to_u32(o0, o1, o2, o3, i); + stbir__simdi_convert_i32_to_float(of0, o0); + stbir__simdi_convert_i32_to_float(of1, o1); + stbir__simdi_convert_i32_to_float(of2, o2); + stbir__simdi_convert_i32_to_float(of3, o3); + stbir__simdf_mult(of0, of0, STBIR__CONSTF(STBIR_max_uint8_as_float_inverted)); + stbir__simdf_mult(of1, of1, STBIR__CONSTF(STBIR_max_uint8_as_float_inverted)); + stbir__simdf_mult(of2, of2, STBIR__CONSTF(STBIR_max_uint8_as_float_inverted)); + stbir__simdf_mult(of3, of3, STBIR__CONSTF(STBIR_max_uint8_as_float_inverted)); + stbir__decode_simdf4_flip(of0); + stbir__decode_simdf4_flip(of1); + stbir__decode_simdf4_flip(of2); + stbir__decode_simdf4_flip(of3); + stbir__simdf_store(decode + 0, of0); + stbir__simdf_store(decode + 4, of1); + stbir__simdf_store(decode + 8, of2); + stbir__simdf_store(decode + 12, of3); +#endif + decode += 16; + input += 16; + if (decode <= decode_end) + continue; + if (decode == (decode_end + 16)) + break; + decode = decode_end; // backup and do last couple + input = end_input_m16; + } + return; + } +#endif + +// try to do blocks of 4 when you can +#if stbir__coder_min_num != 3 // doesn't divide cleanly by four + decode += 4; + STBIR_SIMD_NO_UNROLL_LOOP_START + while (decode <= decode_end) { + STBIR_SIMD_NO_UNROLL(decode); + decode[0 - 4] = ((float)(input[stbir__decode_order0])) * stbir__max_uint8_as_float_inverted; + decode[1 - 4] = ((float)(input[stbir__decode_order1])) * stbir__max_uint8_as_float_inverted; + decode[2 - 4] = ((float)(input[stbir__decode_order2])) * stbir__max_uint8_as_float_inverted; + decode[3 - 4] = ((float)(input[stbir__decode_order3])) * stbir__max_uint8_as_float_inverted; + decode += 4; + input += 4; + } + decode -= 4; +#endif + +// do the remnants +#if stbir__coder_min_num < 4 + STBIR_NO_UNROLL_LOOP_START + while (decode < decode_end) { + STBIR_NO_UNROLL(decode); + decode[0] = ((float)(input[stbir__decode_order0])) * stbir__max_uint8_as_float_inverted; +#if stbir__coder_min_num >= 2 + decode[1] = ((float)(input[stbir__decode_order1])) * stbir__max_uint8_as_float_inverted; +#endif +#if stbir__coder_min_num >= 3 + decode[2] = ((float)(input[stbir__decode_order2])) * stbir__max_uint8_as_float_inverted; +#endif + decode += stbir__coder_min_num; + input += stbir__coder_min_num; + } +#endif +} + +static void STBIR__CODER_NAME(stbir__encode_uint8_linear_scaled)(void *outputp, + int width_times_channels, + float const *encode) { + unsigned char STBIR_SIMD_STREAMOUT_PTR(*) output = (unsigned char *)outputp; + unsigned char *end_output = ((unsigned char *)output) + width_times_channels; + +#ifdef STBIR_SIMD + if (width_times_channels >= stbir__simdfX_float_count * 2) { + float const *end_encode_m8 = encode + width_times_channels - stbir__simdfX_float_count * 2; + end_output -= stbir__simdfX_float_count * 2; + STBIR_NO_UNROLL_LOOP_START_INF_FOR + for (;;) { + stbir__simdfX e0, e1; + stbir__simdi i; + STBIR_SIMD_NO_UNROLL(encode); + stbir__simdfX_madd_mem(e0, STBIR_simd_point5X, STBIR_max_uint8_as_floatX, encode); + stbir__simdfX_madd_mem(e1, STBIR_simd_point5X, STBIR_max_uint8_as_floatX, + encode + stbir__simdfX_float_count); + stbir__encode_simdfX_unflip(e0); + stbir__encode_simdfX_unflip(e1); +#ifdef STBIR_SIMD8 + stbir__simdf8_pack_to_16bytes(i, e0, e1); + stbir__simdi_store(output, i); +#else + stbir__simdf_pack_to_8bytes(i, e0, e1); + stbir__simdi_store2(output, i); +#endif + encode += stbir__simdfX_float_count * 2; + output += stbir__simdfX_float_count * 2; + if (output <= end_output) + continue; + if (output == (end_output + stbir__simdfX_float_count * 2)) + break; + output = end_output; // backup and do last couple + encode = end_encode_m8; + } + return; + } + +// try to do blocks of 4 when you can +#if stbir__coder_min_num != 3 // doesn't divide cleanly by four + output += 4; + STBIR_NO_UNROLL_LOOP_START + while (output <= end_output) { + stbir__simdf e0; + stbir__simdi i0; + STBIR_NO_UNROLL(encode); + stbir__simdf_load(e0, encode); + stbir__simdf_madd(e0, STBIR__CONSTF(STBIR_simd_point5), + STBIR__CONSTF(STBIR_max_uint8_as_float), e0); + stbir__encode_simdf4_unflip(e0); + stbir__simdf_pack_to_8bytes(i0, e0, e0); // only use first 4 + *(int *)(output - 4) = stbir__simdi_to_int(i0); + output += 4; + encode += 4; + } + output -= 4; +#endif + +// do the remnants +#if stbir__coder_min_num < 4 + STBIR_NO_UNROLL_LOOP_START + while (output < end_output) { + stbir__simdf e0; + STBIR_NO_UNROLL(encode); + stbir__simdf_madd1_mem(e0, STBIR__CONSTF(STBIR_simd_point5), + STBIR__CONSTF(STBIR_max_uint8_as_float), + encode + stbir__encode_order0); + output[0] = stbir__simdf_convert_float_to_uint8(e0); +#if stbir__coder_min_num >= 2 + stbir__simdf_madd1_mem(e0, STBIR__CONSTF(STBIR_simd_point5), + STBIR__CONSTF(STBIR_max_uint8_as_float), + encode + stbir__encode_order1); + output[1] = stbir__simdf_convert_float_to_uint8(e0); +#endif +#if stbir__coder_min_num >= 3 + stbir__simdf_madd1_mem(e0, STBIR__CONSTF(STBIR_simd_point5), + STBIR__CONSTF(STBIR_max_uint8_as_float), + encode + stbir__encode_order2); + output[2] = stbir__simdf_convert_float_to_uint8(e0); +#endif + output += stbir__coder_min_num; + encode += stbir__coder_min_num; + } +#endif + +#else + +// try to do blocks of 4 when you can +#if stbir__coder_min_num != 3 // doesn't divide cleanly by four + output += 4; + while (output <= end_output) { + float f; + f = encode[stbir__encode_order0] * stbir__max_uint8_as_float + 0.5f; + STBIR_CLAMP(f, 0, 255); + output[0 - 4] = (unsigned char)f; + f = encode[stbir__encode_order1] * stbir__max_uint8_as_float + 0.5f; + STBIR_CLAMP(f, 0, 255); + output[1 - 4] = (unsigned char)f; + f = encode[stbir__encode_order2] * stbir__max_uint8_as_float + 0.5f; + STBIR_CLAMP(f, 0, 255); + output[2 - 4] = (unsigned char)f; + f = encode[stbir__encode_order3] * stbir__max_uint8_as_float + 0.5f; + STBIR_CLAMP(f, 0, 255); + output[3 - 4] = (unsigned char)f; + output += 4; + encode += 4; + } + output -= 4; +#endif + +// do the remnants +#if stbir__coder_min_num < 4 + STBIR_NO_UNROLL_LOOP_START + while (output < end_output) { + float f; + STBIR_NO_UNROLL(encode); + f = encode[stbir__encode_order0] * stbir__max_uint8_as_float + 0.5f; + STBIR_CLAMP(f, 0, 255); + output[0] = (unsigned char)f; +#if stbir__coder_min_num >= 2 + f = encode[stbir__encode_order1] * stbir__max_uint8_as_float + 0.5f; + STBIR_CLAMP(f, 0, 255); + output[1] = (unsigned char)f; +#endif +#if stbir__coder_min_num >= 3 + f = encode[stbir__encode_order2] * stbir__max_uint8_as_float + 0.5f; + STBIR_CLAMP(f, 0, 255); + output[2] = (unsigned char)f; +#endif + output += stbir__coder_min_num; + encode += stbir__coder_min_num; + } +#endif +#endif +} + +static void STBIR__CODER_NAME(stbir__decode_uint8_linear)(float *decodep, int width_times_channels, + void const *inputp) { + float STBIR_STREAMOUT_PTR(*) decode = decodep; + float *decode_end = (float *)decode + width_times_channels; + unsigned char const *input = (unsigned char const *)inputp; + +#ifdef STBIR_SIMD + unsigned char const *end_input_m16 = input + width_times_channels - 16; + if (width_times_channels >= 16) { + decode_end -= 16; + STBIR_NO_UNROLL_LOOP_START_INF_FOR + for (;;) { +#ifdef STBIR_SIMD8 + stbir__simdi i; + stbir__simdi8 o0, o1; + stbir__simdf8 of0, of1; + STBIR_NO_UNROLL(decode); + stbir__simdi_load(i, input); + stbir__simdi8_expand_u8_to_u32(o0, o1, i); + stbir__simdi8_convert_i32_to_float(of0, o0); + stbir__simdi8_convert_i32_to_float(of1, o1); + stbir__decode_simdf8_flip(of0); + stbir__decode_simdf8_flip(of1); + stbir__simdf8_store(decode + 0, of0); + stbir__simdf8_store(decode + 8, of1); +#else + stbir__simdi i, o0, o1, o2, o3; + stbir__simdf of0, of1, of2, of3; + STBIR_NO_UNROLL(decode); + stbir__simdi_load(i, input); + stbir__simdi_expand_u8_to_u32(o0, o1, o2, o3, i); + stbir__simdi_convert_i32_to_float(of0, o0); + stbir__simdi_convert_i32_to_float(of1, o1); + stbir__simdi_convert_i32_to_float(of2, o2); + stbir__simdi_convert_i32_to_float(of3, o3); + stbir__decode_simdf4_flip(of0); + stbir__decode_simdf4_flip(of1); + stbir__decode_simdf4_flip(of2); + stbir__decode_simdf4_flip(of3); + stbir__simdf_store(decode + 0, of0); + stbir__simdf_store(decode + 4, of1); + stbir__simdf_store(decode + 8, of2); + stbir__simdf_store(decode + 12, of3); +#endif + decode += 16; + input += 16; + if (decode <= decode_end) + continue; + if (decode == (decode_end + 16)) + break; + decode = decode_end; // backup and do last couple + input = end_input_m16; + } + return; + } +#endif + +// try to do blocks of 4 when you can +#if stbir__coder_min_num != 3 // doesn't divide cleanly by four + decode += 4; + STBIR_SIMD_NO_UNROLL_LOOP_START + while (decode <= decode_end) { + STBIR_SIMD_NO_UNROLL(decode); + decode[0 - 4] = ((float)(input[stbir__decode_order0])); + decode[1 - 4] = ((float)(input[stbir__decode_order1])); + decode[2 - 4] = ((float)(input[stbir__decode_order2])); + decode[3 - 4] = ((float)(input[stbir__decode_order3])); + decode += 4; + input += 4; + } + decode -= 4; +#endif + +// do the remnants +#if stbir__coder_min_num < 4 + STBIR_NO_UNROLL_LOOP_START + while (decode < decode_end) { + STBIR_NO_UNROLL(decode); + decode[0] = ((float)(input[stbir__decode_order0])); +#if stbir__coder_min_num >= 2 + decode[1] = ((float)(input[stbir__decode_order1])); +#endif +#if stbir__coder_min_num >= 3 + decode[2] = ((float)(input[stbir__decode_order2])); +#endif + decode += stbir__coder_min_num; + input += stbir__coder_min_num; + } +#endif +} + +static void STBIR__CODER_NAME(stbir__encode_uint8_linear)(void *outputp, int width_times_channels, + float const *encode) { + unsigned char STBIR_SIMD_STREAMOUT_PTR(*) output = (unsigned char *)outputp; + unsigned char *end_output = ((unsigned char *)output) + width_times_channels; + +#ifdef STBIR_SIMD + if (width_times_channels >= stbir__simdfX_float_count * 2) { + float const *end_encode_m8 = encode + width_times_channels - stbir__simdfX_float_count * 2; + end_output -= stbir__simdfX_float_count * 2; + STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR + for (;;) { + stbir__simdfX e0, e1; + stbir__simdi i; + STBIR_SIMD_NO_UNROLL(encode); + stbir__simdfX_add_mem(e0, STBIR_simd_point5X, encode); + stbir__simdfX_add_mem(e1, STBIR_simd_point5X, encode + stbir__simdfX_float_count); + stbir__encode_simdfX_unflip(e0); + stbir__encode_simdfX_unflip(e1); +#ifdef STBIR_SIMD8 + stbir__simdf8_pack_to_16bytes(i, e0, e1); + stbir__simdi_store(output, i); +#else + stbir__simdf_pack_to_8bytes(i, e0, e1); + stbir__simdi_store2(output, i); +#endif + encode += stbir__simdfX_float_count * 2; + output += stbir__simdfX_float_count * 2; + if (output <= end_output) + continue; + if (output == (end_output + stbir__simdfX_float_count * 2)) + break; + output = end_output; // backup and do last couple + encode = end_encode_m8; + } + return; + } + +// try to do blocks of 4 when you can +#if stbir__coder_min_num != 3 // doesn't divide cleanly by four + output += 4; + STBIR_NO_UNROLL_LOOP_START + while (output <= end_output) { + stbir__simdf e0; + stbir__simdi i0; + STBIR_NO_UNROLL(encode); + stbir__simdf_load(e0, encode); + stbir__simdf_add(e0, STBIR__CONSTF(STBIR_simd_point5), e0); + stbir__encode_simdf4_unflip(e0); + stbir__simdf_pack_to_8bytes(i0, e0, e0); // only use first 4 + *(int *)(output - 4) = stbir__simdi_to_int(i0); + output += 4; + encode += 4; + } + output -= 4; +#endif + +#else + +// try to do blocks of 4 when you can +#if stbir__coder_min_num != 3 // doesn't divide cleanly by four + output += 4; + while (output <= end_output) { + float f; + f = encode[stbir__encode_order0] + 0.5f; + STBIR_CLAMP(f, 0, 255); + output[0 - 4] = (unsigned char)f; + f = encode[stbir__encode_order1] + 0.5f; + STBIR_CLAMP(f, 0, 255); + output[1 - 4] = (unsigned char)f; + f = encode[stbir__encode_order2] + 0.5f; + STBIR_CLAMP(f, 0, 255); + output[2 - 4] = (unsigned char)f; + f = encode[stbir__encode_order3] + 0.5f; + STBIR_CLAMP(f, 0, 255); + output[3 - 4] = (unsigned char)f; + output += 4; + encode += 4; + } + output -= 4; +#endif + +#endif + +// do the remnants +#if stbir__coder_min_num < 4 + STBIR_NO_UNROLL_LOOP_START + while (output < end_output) { + float f; + STBIR_NO_UNROLL(encode); + f = encode[stbir__encode_order0] + 0.5f; + STBIR_CLAMP(f, 0, 255); + output[0] = (unsigned char)f; +#if stbir__coder_min_num >= 2 + f = encode[stbir__encode_order1] + 0.5f; + STBIR_CLAMP(f, 0, 255); + output[1] = (unsigned char)f; +#endif +#if stbir__coder_min_num >= 3 + f = encode[stbir__encode_order2] + 0.5f; + STBIR_CLAMP(f, 0, 255); + output[2] = (unsigned char)f; +#endif + output += stbir__coder_min_num; + encode += stbir__coder_min_num; + } +#endif +} + +static void STBIR__CODER_NAME(stbir__decode_uint8_srgb)(float *decodep, int width_times_channels, + void const *inputp) { + float STBIR_STREAMOUT_PTR(*) decode = decodep; + float const *decode_end = (float *)decode + width_times_channels; + unsigned char const *input = (unsigned char const *)inputp; + +// try to do blocks of 4 when you can +#if stbir__coder_min_num != 3 // doesn't divide cleanly by four + decode += 4; + while (decode <= decode_end) { + decode[0 - 4] = stbir__srgb_uchar_to_linear_float[input[stbir__decode_order0]]; + decode[1 - 4] = stbir__srgb_uchar_to_linear_float[input[stbir__decode_order1]]; + decode[2 - 4] = stbir__srgb_uchar_to_linear_float[input[stbir__decode_order2]]; + decode[3 - 4] = stbir__srgb_uchar_to_linear_float[input[stbir__decode_order3]]; + decode += 4; + input += 4; + } + decode -= 4; +#endif + +// do the remnants +#if stbir__coder_min_num < 4 + STBIR_NO_UNROLL_LOOP_START + while (decode < decode_end) { + STBIR_NO_UNROLL(decode); + decode[0] = stbir__srgb_uchar_to_linear_float[input[stbir__decode_order0]]; +#if stbir__coder_min_num >= 2 + decode[1] = stbir__srgb_uchar_to_linear_float[input[stbir__decode_order1]]; +#endif +#if stbir__coder_min_num >= 3 + decode[2] = stbir__srgb_uchar_to_linear_float[input[stbir__decode_order2]]; +#endif + decode += stbir__coder_min_num; + input += stbir__coder_min_num; + } +#endif +} + +#define stbir__min_max_shift20(i, f) \ + stbir__simdf_max(f, f, stbir_simdf_casti(STBIR__CONSTI(STBIR_almost_zero))); \ + stbir__simdf_min(f, f, stbir_simdf_casti(STBIR__CONSTI(STBIR_almost_one))); \ + stbir__simdi_32shr(i, stbir_simdi_castf(f), 20); + +#define stbir__scale_and_convert(i, f) \ + stbir__simdf_madd(f, STBIR__CONSTF(STBIR_simd_point5), \ + STBIR__CONSTF(STBIR_max_uint8_as_float), f); \ + stbir__simdf_max(f, f, stbir__simdf_zeroP()); \ + stbir__simdf_min(f, f, STBIR__CONSTF(STBIR_max_uint8_as_float)); \ + stbir__simdf_convert_float_to_i32(i, f); + +#define stbir__linear_to_srgb_finish(i, f) \ + { \ + stbir__simdi temp; \ + stbir__simdi_32shr(temp, stbir_simdi_castf(f), 12); \ + stbir__simdi_and(temp, temp, STBIR__CONSTI(STBIR_mastissa_mask)); \ + stbir__simdi_or(temp, temp, STBIR__CONSTI(STBIR_topscale)); \ + stbir__simdi_16madd(i, i, temp); \ + stbir__simdi_32shr(i, i, 16); \ + } + +#define stbir__simdi_table_lookup2(v0, v1, table) \ + { \ + stbir__simdi_u32 temp0, temp1; \ + temp0.m128i_i128 = v0; \ + temp1.m128i_i128 = v1; \ + temp0.m128i_u32[0] = table[temp0.m128i_i32[0]]; \ + temp0.m128i_u32[1] = table[temp0.m128i_i32[1]]; \ + temp0.m128i_u32[2] = table[temp0.m128i_i32[2]]; \ + temp0.m128i_u32[3] = table[temp0.m128i_i32[3]]; \ + temp1.m128i_u32[0] = table[temp1.m128i_i32[0]]; \ + temp1.m128i_u32[1] = table[temp1.m128i_i32[1]]; \ + temp1.m128i_u32[2] = table[temp1.m128i_i32[2]]; \ + temp1.m128i_u32[3] = table[temp1.m128i_i32[3]]; \ + v0 = temp0.m128i_i128; \ + v1 = temp1.m128i_i128; \ + } + +#define stbir__simdi_table_lookup3(v0, v1, v2, table) \ + { \ + stbir__simdi_u32 temp0, temp1, temp2; \ + temp0.m128i_i128 = v0; \ + temp1.m128i_i128 = v1; \ + temp2.m128i_i128 = v2; \ + temp0.m128i_u32[0] = table[temp0.m128i_i32[0]]; \ + temp0.m128i_u32[1] = table[temp0.m128i_i32[1]]; \ + temp0.m128i_u32[2] = table[temp0.m128i_i32[2]]; \ + temp0.m128i_u32[3] = table[temp0.m128i_i32[3]]; \ + temp1.m128i_u32[0] = table[temp1.m128i_i32[0]]; \ + temp1.m128i_u32[1] = table[temp1.m128i_i32[1]]; \ + temp1.m128i_u32[2] = table[temp1.m128i_i32[2]]; \ + temp1.m128i_u32[3] = table[temp1.m128i_i32[3]]; \ + temp2.m128i_u32[0] = table[temp2.m128i_i32[0]]; \ + temp2.m128i_u32[1] = table[temp2.m128i_i32[1]]; \ + temp2.m128i_u32[2] = table[temp2.m128i_i32[2]]; \ + temp2.m128i_u32[3] = table[temp2.m128i_i32[3]]; \ + v0 = temp0.m128i_i128; \ + v1 = temp1.m128i_i128; \ + v2 = temp2.m128i_i128; \ + } + +#define stbir__simdi_table_lookup4(v0, v1, v2, v3, table) \ + { \ + stbir__simdi_u32 temp0, temp1, temp2, temp3; \ + temp0.m128i_i128 = v0; \ + temp1.m128i_i128 = v1; \ + temp2.m128i_i128 = v2; \ + temp3.m128i_i128 = v3; \ + temp0.m128i_u32[0] = table[temp0.m128i_i32[0]]; \ + temp0.m128i_u32[1] = table[temp0.m128i_i32[1]]; \ + temp0.m128i_u32[2] = table[temp0.m128i_i32[2]]; \ + temp0.m128i_u32[3] = table[temp0.m128i_i32[3]]; \ + temp1.m128i_u32[0] = table[temp1.m128i_i32[0]]; \ + temp1.m128i_u32[1] = table[temp1.m128i_i32[1]]; \ + temp1.m128i_u32[2] = table[temp1.m128i_i32[2]]; \ + temp1.m128i_u32[3] = table[temp1.m128i_i32[3]]; \ + temp2.m128i_u32[0] = table[temp2.m128i_i32[0]]; \ + temp2.m128i_u32[1] = table[temp2.m128i_i32[1]]; \ + temp2.m128i_u32[2] = table[temp2.m128i_i32[2]]; \ + temp2.m128i_u32[3] = table[temp2.m128i_i32[3]]; \ + temp3.m128i_u32[0] = table[temp3.m128i_i32[0]]; \ + temp3.m128i_u32[1] = table[temp3.m128i_i32[1]]; \ + temp3.m128i_u32[2] = table[temp3.m128i_i32[2]]; \ + temp3.m128i_u32[3] = table[temp3.m128i_i32[3]]; \ + v0 = temp0.m128i_i128; \ + v1 = temp1.m128i_i128; \ + v2 = temp2.m128i_i128; \ + v3 = temp3.m128i_i128; \ + } + +static void STBIR__CODER_NAME(stbir__encode_uint8_srgb)(void *outputp, int width_times_channels, + float const *encode) { + unsigned char STBIR_SIMD_STREAMOUT_PTR(*) output = (unsigned char *)outputp; + unsigned char *end_output = ((unsigned char *)output) + width_times_channels; + +#ifdef STBIR_SIMD + + if (width_times_channels >= 16) { + float const *end_encode_m16 = encode + width_times_channels - 16; + end_output -= 16; + STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR + for (;;) { + stbir__simdf f0, f1, f2, f3; + stbir__simdi i0, i1, i2, i3; + STBIR_SIMD_NO_UNROLL(encode); + + stbir__simdf_load4_transposed(f0, f1, f2, f3, encode); + + stbir__min_max_shift20(i0, f0); + stbir__min_max_shift20(i1, f1); + stbir__min_max_shift20(i2, f2); + stbir__min_max_shift20(i3, f3); + + stbir__simdi_table_lookup4(i0, i1, i2, i3, (fp32_to_srgb8_tab4 - (127 - 13) * 8)); + + stbir__linear_to_srgb_finish(i0, f0); + stbir__linear_to_srgb_finish(i1, f1); + stbir__linear_to_srgb_finish(i2, f2); + stbir__linear_to_srgb_finish(i3, f3); + + stbir__interleave_pack_and_store_16_u8(output, + STBIR_strs_join1(i, , stbir__encode_order0), + STBIR_strs_join1(i, , stbir__encode_order1), + STBIR_strs_join1(i, , stbir__encode_order2), + STBIR_strs_join1(i, , stbir__encode_order3)); + + encode += 16; + output += 16; + if (output <= end_output) + continue; + if (output == (end_output + 16)) + break; + output = end_output; // backup and do last couple + encode = end_encode_m16; + } + return; + } +#endif + +// try to do blocks of 4 when you can +#if stbir__coder_min_num != 3 // doesn't divide cleanly by four + output += 4; + STBIR_SIMD_NO_UNROLL_LOOP_START + while (output <= end_output) { + STBIR_SIMD_NO_UNROLL(encode); + + output[0 - 4] = stbir__linear_to_srgb_uchar(encode[stbir__encode_order0]); + output[1 - 4] = stbir__linear_to_srgb_uchar(encode[stbir__encode_order1]); + output[2 - 4] = stbir__linear_to_srgb_uchar(encode[stbir__encode_order2]); + output[3 - 4] = stbir__linear_to_srgb_uchar(encode[stbir__encode_order3]); + + output += 4; + encode += 4; + } + output -= 4; +#endif + +// do the remnants +#if stbir__coder_min_num < 4 + STBIR_NO_UNROLL_LOOP_START + while (output < end_output) { + STBIR_NO_UNROLL(encode); + output[0] = stbir__linear_to_srgb_uchar(encode[stbir__encode_order0]); +#if stbir__coder_min_num >= 2 + output[1] = stbir__linear_to_srgb_uchar(encode[stbir__encode_order1]); +#endif +#if stbir__coder_min_num >= 3 + output[2] = stbir__linear_to_srgb_uchar(encode[stbir__encode_order2]); +#endif + output += stbir__coder_min_num; + encode += stbir__coder_min_num; + } +#endif +} + +#if (stbir__coder_min_num == 4) || \ + ((stbir__coder_min_num == 1) && (!defined(stbir__decode_swizzle))) + +static void STBIR__CODER_NAME(stbir__decode_uint8_srgb4_linearalpha)(float *decodep, + int width_times_channels, + void const *inputp) { + float STBIR_STREAMOUT_PTR(*) decode = decodep; + float const *decode_end = (float *)decode + width_times_channels; + unsigned char const *input = (unsigned char const *)inputp; + do { + decode[0] = stbir__srgb_uchar_to_linear_float[input[stbir__decode_order0]]; + decode[1] = stbir__srgb_uchar_to_linear_float[input[stbir__decode_order1]]; + decode[2] = stbir__srgb_uchar_to_linear_float[input[stbir__decode_order2]]; + decode[3] = ((float)input[stbir__decode_order3]) * stbir__max_uint8_as_float_inverted; + input += 4; + decode += 4; + } while (decode < decode_end); +} + +static void STBIR__CODER_NAME(stbir__encode_uint8_srgb4_linearalpha)(void *outputp, + int width_times_channels, + float const *encode) { + unsigned char STBIR_SIMD_STREAMOUT_PTR(*) output = (unsigned char *)outputp; + unsigned char *end_output = ((unsigned char *)output) + width_times_channels; + +#ifdef STBIR_SIMD + + if (width_times_channels >= 16) { + float const *end_encode_m16 = encode + width_times_channels - 16; + end_output -= 16; + STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR + for (;;) { + stbir__simdf f0, f1, f2, f3; + stbir__simdi i0, i1, i2, i3; + + STBIR_SIMD_NO_UNROLL(encode); + stbir__simdf_load4_transposed(f0, f1, f2, f3, encode); + + stbir__min_max_shift20(i0, f0); + stbir__min_max_shift20(i1, f1); + stbir__min_max_shift20(i2, f2); + stbir__scale_and_convert(i3, f3); + + stbir__simdi_table_lookup3(i0, i1, i2, (fp32_to_srgb8_tab4 - (127 - 13) * 8)); + + stbir__linear_to_srgb_finish(i0, f0); + stbir__linear_to_srgb_finish(i1, f1); + stbir__linear_to_srgb_finish(i2, f2); + + stbir__interleave_pack_and_store_16_u8(output, + STBIR_strs_join1(i, , stbir__encode_order0), + STBIR_strs_join1(i, , stbir__encode_order1), + STBIR_strs_join1(i, , stbir__encode_order2), + STBIR_strs_join1(i, , stbir__encode_order3)); + + output += 16; + encode += 16; + + if (output <= end_output) + continue; + if (output == (end_output + 16)) + break; + output = end_output; // backup and do last couple + encode = end_encode_m16; + } + return; + } +#endif + + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + float f; + STBIR_SIMD_NO_UNROLL(encode); + + output[stbir__decode_order0] = stbir__linear_to_srgb_uchar(encode[0]); + output[stbir__decode_order1] = stbir__linear_to_srgb_uchar(encode[1]); + output[stbir__decode_order2] = stbir__linear_to_srgb_uchar(encode[2]); + + f = encode[3] * stbir__max_uint8_as_float + 0.5f; + STBIR_CLAMP(f, 0, 255); + output[stbir__decode_order3] = (unsigned char)f; + + output += 4; + encode += 4; + } while (output < end_output); +} + +#endif + +#if (stbir__coder_min_num == 2) || \ + ((stbir__coder_min_num == 1) && (!defined(stbir__decode_swizzle))) + +static void STBIR__CODER_NAME(stbir__decode_uint8_srgb2_linearalpha)(float *decodep, + int width_times_channels, + void const *inputp) { + float STBIR_STREAMOUT_PTR(*) decode = decodep; + float const *decode_end = (float *)decode + width_times_channels; + unsigned char const *input = (unsigned char const *)inputp; + decode += 4; + while (decode <= decode_end) { + decode[0 - 4] = stbir__srgb_uchar_to_linear_float[input[stbir__decode_order0]]; + decode[1 - 4] = ((float)input[stbir__decode_order1]) * stbir__max_uint8_as_float_inverted; + decode[2 - 4] = stbir__srgb_uchar_to_linear_float[input[stbir__decode_order0 + 2]]; + decode[3 - 4] = + ((float)input[stbir__decode_order1 + 2]) * stbir__max_uint8_as_float_inverted; + input += 4; + decode += 4; + } + decode -= 4; + if (decode < decode_end) { + decode[0] = stbir__srgb_uchar_to_linear_float[stbir__decode_order0]; + decode[1] = ((float)input[stbir__decode_order1]) * stbir__max_uint8_as_float_inverted; + } +} + +static void STBIR__CODER_NAME(stbir__encode_uint8_srgb2_linearalpha)(void *outputp, + int width_times_channels, + float const *encode) { + unsigned char STBIR_SIMD_STREAMOUT_PTR(*) output = (unsigned char *)outputp; + unsigned char *end_output = ((unsigned char *)output) + width_times_channels; + +#ifdef STBIR_SIMD + + if (width_times_channels >= 16) { + float const *end_encode_m16 = encode + width_times_channels - 16; + end_output -= 16; + STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR + for (;;) { + stbir__simdf f0, f1, f2, f3; + stbir__simdi i0, i1, i2, i3; + + STBIR_SIMD_NO_UNROLL(encode); + stbir__simdf_load4_transposed(f0, f1, f2, f3, encode); + + stbir__min_max_shift20(i0, f0); + stbir__scale_and_convert(i1, f1); + stbir__min_max_shift20(i2, f2); + stbir__scale_and_convert(i3, f3); + + stbir__simdi_table_lookup2(i0, i2, (fp32_to_srgb8_tab4 - (127 - 13) * 8)); + + stbir__linear_to_srgb_finish(i0, f0); + stbir__linear_to_srgb_finish(i2, f2); + + stbir__interleave_pack_and_store_16_u8(output, + STBIR_strs_join1(i, , stbir__encode_order0), + STBIR_strs_join1(i, , stbir__encode_order1), + STBIR_strs_join1(i, , stbir__encode_order2), + STBIR_strs_join1(i, , stbir__encode_order3)); + + output += 16; + encode += 16; + if (output <= end_output) + continue; + if (output == (end_output + 16)) + break; + output = end_output; // backup and do last couple + encode = end_encode_m16; + } + return; + } +#endif + + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + float f; + STBIR_SIMD_NO_UNROLL(encode); + + output[stbir__decode_order0] = stbir__linear_to_srgb_uchar(encode[0]); + + f = encode[1] * stbir__max_uint8_as_float + 0.5f; + STBIR_CLAMP(f, 0, 255); + output[stbir__decode_order1] = (unsigned char)f; + + output += 2; + encode += 2; + } while (output < end_output); +} + +#endif + +static void STBIR__CODER_NAME(stbir__decode_uint16_linear_scaled)(float *decodep, + int width_times_channels, + void const *inputp) { + float STBIR_STREAMOUT_PTR(*) decode = decodep; + float *decode_end = (float *)decode + width_times_channels; + unsigned short const *input = (unsigned short const *)inputp; + +#ifdef STBIR_SIMD + unsigned short const *end_input_m8 = input + width_times_channels - 8; + if (width_times_channels >= 8) { + decode_end -= 8; + STBIR_NO_UNROLL_LOOP_START_INF_FOR + for (;;) { +#ifdef STBIR_SIMD8 + stbir__simdi i; + stbir__simdi8 o; + stbir__simdf8 of; + STBIR_NO_UNROLL(decode); + stbir__simdi_load(i, input); + stbir__simdi8_expand_u16_to_u32(o, i); + stbir__simdi8_convert_i32_to_float(of, o); + stbir__simdf8_mult(of, of, STBIR_max_uint16_as_float_inverted8); + stbir__decode_simdf8_flip(of); + stbir__simdf8_store(decode + 0, of); +#else + stbir__simdi i, o0, o1; + stbir__simdf of0, of1; + STBIR_NO_UNROLL(decode); + stbir__simdi_load(i, input); + stbir__simdi_expand_u16_to_u32(o0, o1, i); + stbir__simdi_convert_i32_to_float(of0, o0); + stbir__simdi_convert_i32_to_float(of1, o1); + stbir__simdf_mult(of0, of0, STBIR__CONSTF(STBIR_max_uint16_as_float_inverted)); + stbir__simdf_mult(of1, of1, STBIR__CONSTF(STBIR_max_uint16_as_float_inverted)); + stbir__decode_simdf4_flip(of0); + stbir__decode_simdf4_flip(of1); + stbir__simdf_store(decode + 0, of0); + stbir__simdf_store(decode + 4, of1); +#endif + decode += 8; + input += 8; + if (decode <= decode_end) + continue; + if (decode == (decode_end + 8)) + break; + decode = decode_end; // backup and do last couple + input = end_input_m8; + } + return; + } +#endif + +// try to do blocks of 4 when you can +#if stbir__coder_min_num != 3 // doesn't divide cleanly by four + decode += 4; + STBIR_SIMD_NO_UNROLL_LOOP_START + while (decode <= decode_end) { + STBIR_SIMD_NO_UNROLL(decode); + decode[0 - 4] = + ((float)(input[stbir__decode_order0])) * stbir__max_uint16_as_float_inverted; + decode[1 - 4] = + ((float)(input[stbir__decode_order1])) * stbir__max_uint16_as_float_inverted; + decode[2 - 4] = + ((float)(input[stbir__decode_order2])) * stbir__max_uint16_as_float_inverted; + decode[3 - 4] = + ((float)(input[stbir__decode_order3])) * stbir__max_uint16_as_float_inverted; + decode += 4; + input += 4; + } + decode -= 4; +#endif + +// do the remnants +#if stbir__coder_min_num < 4 + STBIR_NO_UNROLL_LOOP_START + while (decode < decode_end) { + STBIR_NO_UNROLL(decode); + decode[0] = ((float)(input[stbir__decode_order0])) * stbir__max_uint16_as_float_inverted; +#if stbir__coder_min_num >= 2 + decode[1] = ((float)(input[stbir__decode_order1])) * stbir__max_uint16_as_float_inverted; +#endif +#if stbir__coder_min_num >= 3 + decode[2] = ((float)(input[stbir__decode_order2])) * stbir__max_uint16_as_float_inverted; +#endif + decode += stbir__coder_min_num; + input += stbir__coder_min_num; + } +#endif +} + +static void STBIR__CODER_NAME(stbir__encode_uint16_linear_scaled)(void *outputp, + int width_times_channels, + float const *encode) { + unsigned short STBIR_SIMD_STREAMOUT_PTR(*) output = (unsigned short *)outputp; + unsigned short *end_output = ((unsigned short *)output) + width_times_channels; + +#ifdef STBIR_SIMD + { + if (width_times_channels >= stbir__simdfX_float_count * 2) { + float const *end_encode_m8 = + encode + width_times_channels - stbir__simdfX_float_count * 2; + end_output -= stbir__simdfX_float_count * 2; + STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR + for (;;) { + stbir__simdfX e0, e1; + stbir__simdiX i; + STBIR_SIMD_NO_UNROLL(encode); + stbir__simdfX_madd_mem(e0, STBIR_simd_point5X, STBIR_max_uint16_as_floatX, encode); + stbir__simdfX_madd_mem(e1, STBIR_simd_point5X, STBIR_max_uint16_as_floatX, + encode + stbir__simdfX_float_count); + stbir__encode_simdfX_unflip(e0); + stbir__encode_simdfX_unflip(e1); + stbir__simdfX_pack_to_words(i, e0, e1); + stbir__simdiX_store(output, i); + encode += stbir__simdfX_float_count * 2; + output += stbir__simdfX_float_count * 2; + if (output <= end_output) + continue; + if (output == (end_output + stbir__simdfX_float_count * 2)) + break; + output = end_output; // backup and do last couple + encode = end_encode_m8; + } + return; + } + } + +// try to do blocks of 4 when you can +#if stbir__coder_min_num != 3 // doesn't divide cleanly by four + output += 4; + STBIR_NO_UNROLL_LOOP_START + while (output <= end_output) { + stbir__simdf e; + stbir__simdi i; + STBIR_NO_UNROLL(encode); + stbir__simdf_load(e, encode); + stbir__simdf_madd(e, STBIR__CONSTF(STBIR_simd_point5), + STBIR__CONSTF(STBIR_max_uint16_as_float), e); + stbir__encode_simdf4_unflip(e); + stbir__simdf_pack_to_8words(i, e, e); // only use first 4 + stbir__simdi_store2(output - 4, i); + output += 4; + encode += 4; + } + output -= 4; +#endif + +// do the remnants +#if stbir__coder_min_num < 4 + STBIR_NO_UNROLL_LOOP_START + while (output < end_output) { + stbir__simdf e; + STBIR_NO_UNROLL(encode); + stbir__simdf_madd1_mem(e, STBIR__CONSTF(STBIR_simd_point5), + STBIR__CONSTF(STBIR_max_uint16_as_float), + encode + stbir__encode_order0); + output[0] = stbir__simdf_convert_float_to_short(e); +#if stbir__coder_min_num >= 2 + stbir__simdf_madd1_mem(e, STBIR__CONSTF(STBIR_simd_point5), + STBIR__CONSTF(STBIR_max_uint16_as_float), + encode + stbir__encode_order1); + output[1] = stbir__simdf_convert_float_to_short(e); +#endif +#if stbir__coder_min_num >= 3 + stbir__simdf_madd1_mem(e, STBIR__CONSTF(STBIR_simd_point5), + STBIR__CONSTF(STBIR_max_uint16_as_float), + encode + stbir__encode_order2); + output[2] = stbir__simdf_convert_float_to_short(e); +#endif + output += stbir__coder_min_num; + encode += stbir__coder_min_num; + } +#endif + +#else + +// try to do blocks of 4 when you can +#if stbir__coder_min_num != 3 // doesn't divide cleanly by four + output += 4; + STBIR_SIMD_NO_UNROLL_LOOP_START + while (output <= end_output) { + float f; + STBIR_SIMD_NO_UNROLL(encode); + f = encode[stbir__encode_order0] * stbir__max_uint16_as_float + 0.5f; + STBIR_CLAMP(f, 0, 65535); + output[0 - 4] = (unsigned short)f; + f = encode[stbir__encode_order1] * stbir__max_uint16_as_float + 0.5f; + STBIR_CLAMP(f, 0, 65535); + output[1 - 4] = (unsigned short)f; + f = encode[stbir__encode_order2] * stbir__max_uint16_as_float + 0.5f; + STBIR_CLAMP(f, 0, 65535); + output[2 - 4] = (unsigned short)f; + f = encode[stbir__encode_order3] * stbir__max_uint16_as_float + 0.5f; + STBIR_CLAMP(f, 0, 65535); + output[3 - 4] = (unsigned short)f; + output += 4; + encode += 4; + } + output -= 4; +#endif + +// do the remnants +#if stbir__coder_min_num < 4 + STBIR_NO_UNROLL_LOOP_START + while (output < end_output) { + float f; + STBIR_NO_UNROLL(encode); + f = encode[stbir__encode_order0] * stbir__max_uint16_as_float + 0.5f; + STBIR_CLAMP(f, 0, 65535); + output[0] = (unsigned short)f; +#if stbir__coder_min_num >= 2 + f = encode[stbir__encode_order1] * stbir__max_uint16_as_float + 0.5f; + STBIR_CLAMP(f, 0, 65535); + output[1] = (unsigned short)f; +#endif +#if stbir__coder_min_num >= 3 + f = encode[stbir__encode_order2] * stbir__max_uint16_as_float + 0.5f; + STBIR_CLAMP(f, 0, 65535); + output[2] = (unsigned short)f; +#endif + output += stbir__coder_min_num; + encode += stbir__coder_min_num; + } +#endif +#endif +} + +static void STBIR__CODER_NAME(stbir__decode_uint16_linear)(float *decodep, int width_times_channels, + void const *inputp) { + float STBIR_STREAMOUT_PTR(*) decode = decodep; + float *decode_end = (float *)decode + width_times_channels; + unsigned short const *input = (unsigned short const *)inputp; + +#ifdef STBIR_SIMD + unsigned short const *end_input_m8 = input + width_times_channels - 8; + if (width_times_channels >= 8) { + decode_end -= 8; + STBIR_NO_UNROLL_LOOP_START_INF_FOR + for (;;) { +#ifdef STBIR_SIMD8 + stbir__simdi i; + stbir__simdi8 o; + stbir__simdf8 of; + STBIR_NO_UNROLL(decode); + stbir__simdi_load(i, input); + stbir__simdi8_expand_u16_to_u32(o, i); + stbir__simdi8_convert_i32_to_float(of, o); + stbir__decode_simdf8_flip(of); + stbir__simdf8_store(decode + 0, of); +#else + stbir__simdi i, o0, o1; + stbir__simdf of0, of1; + STBIR_NO_UNROLL(decode); + stbir__simdi_load(i, input); + stbir__simdi_expand_u16_to_u32(o0, o1, i); + stbir__simdi_convert_i32_to_float(of0, o0); + stbir__simdi_convert_i32_to_float(of1, o1); + stbir__decode_simdf4_flip(of0); + stbir__decode_simdf4_flip(of1); + stbir__simdf_store(decode + 0, of0); + stbir__simdf_store(decode + 4, of1); +#endif + decode += 8; + input += 8; + if (decode <= decode_end) + continue; + if (decode == (decode_end + 8)) + break; + decode = decode_end; // backup and do last couple + input = end_input_m8; + } + return; + } +#endif + +// try to do blocks of 4 when you can +#if stbir__coder_min_num != 3 // doesn't divide cleanly by four + decode += 4; + STBIR_SIMD_NO_UNROLL_LOOP_START + while (decode <= decode_end) { + STBIR_SIMD_NO_UNROLL(decode); + decode[0 - 4] = ((float)(input[stbir__decode_order0])); + decode[1 - 4] = ((float)(input[stbir__decode_order1])); + decode[2 - 4] = ((float)(input[stbir__decode_order2])); + decode[3 - 4] = ((float)(input[stbir__decode_order3])); + decode += 4; + input += 4; + } + decode -= 4; +#endif + +// do the remnants +#if stbir__coder_min_num < 4 + STBIR_NO_UNROLL_LOOP_START + while (decode < decode_end) { + STBIR_NO_UNROLL(decode); + decode[0] = ((float)(input[stbir__decode_order0])); +#if stbir__coder_min_num >= 2 + decode[1] = ((float)(input[stbir__decode_order1])); +#endif +#if stbir__coder_min_num >= 3 + decode[2] = ((float)(input[stbir__decode_order2])); +#endif + decode += stbir__coder_min_num; + input += stbir__coder_min_num; + } +#endif +} + +static void STBIR__CODER_NAME(stbir__encode_uint16_linear)(void *outputp, int width_times_channels, + float const *encode) { + unsigned short STBIR_SIMD_STREAMOUT_PTR(*) output = (unsigned short *)outputp; + unsigned short *end_output = ((unsigned short *)output) + width_times_channels; + +#ifdef STBIR_SIMD + { + if (width_times_channels >= stbir__simdfX_float_count * 2) { + float const *end_encode_m8 = + encode + width_times_channels - stbir__simdfX_float_count * 2; + end_output -= stbir__simdfX_float_count * 2; + STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR + for (;;) { + stbir__simdfX e0, e1; + stbir__simdiX i; + STBIR_SIMD_NO_UNROLL(encode); + stbir__simdfX_add_mem(e0, STBIR_simd_point5X, encode); + stbir__simdfX_add_mem(e1, STBIR_simd_point5X, encode + stbir__simdfX_float_count); + stbir__encode_simdfX_unflip(e0); + stbir__encode_simdfX_unflip(e1); + stbir__simdfX_pack_to_words(i, e0, e1); + stbir__simdiX_store(output, i); + encode += stbir__simdfX_float_count * 2; + output += stbir__simdfX_float_count * 2; + if (output <= end_output) + continue; + if (output == (end_output + stbir__simdfX_float_count * 2)) + break; + output = end_output; // backup and do last couple + encode = end_encode_m8; + } + return; + } + } + +// try to do blocks of 4 when you can +#if stbir__coder_min_num != 3 // doesn't divide cleanly by four + output += 4; + STBIR_NO_UNROLL_LOOP_START + while (output <= end_output) { + stbir__simdf e; + stbir__simdi i; + STBIR_NO_UNROLL(encode); + stbir__simdf_load(e, encode); + stbir__simdf_add(e, STBIR__CONSTF(STBIR_simd_point5), e); + stbir__encode_simdf4_unflip(e); + stbir__simdf_pack_to_8words(i, e, e); // only use first 4 + stbir__simdi_store2(output - 4, i); + output += 4; + encode += 4; + } + output -= 4; +#endif + +#else + +// try to do blocks of 4 when you can +#if stbir__coder_min_num != 3 // doesn't divide cleanly by four + output += 4; + STBIR_SIMD_NO_UNROLL_LOOP_START + while (output <= end_output) { + float f; + STBIR_SIMD_NO_UNROLL(encode); + f = encode[stbir__encode_order0] + 0.5f; + STBIR_CLAMP(f, 0, 65535); + output[0 - 4] = (unsigned short)f; + f = encode[stbir__encode_order1] + 0.5f; + STBIR_CLAMP(f, 0, 65535); + output[1 - 4] = (unsigned short)f; + f = encode[stbir__encode_order2] + 0.5f; + STBIR_CLAMP(f, 0, 65535); + output[2 - 4] = (unsigned short)f; + f = encode[stbir__encode_order3] + 0.5f; + STBIR_CLAMP(f, 0, 65535); + output[3 - 4] = (unsigned short)f; + output += 4; + encode += 4; + } + output -= 4; +#endif + +#endif + +// do the remnants +#if stbir__coder_min_num < 4 + STBIR_NO_UNROLL_LOOP_START + while (output < end_output) { + float f; + STBIR_NO_UNROLL(encode); + f = encode[stbir__encode_order0] + 0.5f; + STBIR_CLAMP(f, 0, 65535); + output[0] = (unsigned short)f; +#if stbir__coder_min_num >= 2 + f = encode[stbir__encode_order1] + 0.5f; + STBIR_CLAMP(f, 0, 65535); + output[1] = (unsigned short)f; +#endif +#if stbir__coder_min_num >= 3 + f = encode[stbir__encode_order2] + 0.5f; + STBIR_CLAMP(f, 0, 65535); + output[2] = (unsigned short)f; +#endif + output += stbir__coder_min_num; + encode += stbir__coder_min_num; + } +#endif +} + +static void STBIR__CODER_NAME(stbir__decode_half_float_linear)(float *decodep, + int width_times_channels, + void const *inputp) { + float STBIR_STREAMOUT_PTR(*) decode = decodep; + float *decode_end = (float *)decode + width_times_channels; + stbir__FP16 const *input = (stbir__FP16 const *)inputp; + +#ifdef STBIR_SIMD + if (width_times_channels >= 8) { + stbir__FP16 const *end_input_m8 = input + width_times_channels - 8; + decode_end -= 8; + STBIR_NO_UNROLL_LOOP_START_INF_FOR + for (;;) { + STBIR_NO_UNROLL(decode); + + stbir__half_to_float_SIMD(decode, input); +#ifdef stbir__decode_swizzle +#ifdef STBIR_SIMD8 + { + stbir__simdf8 of; + stbir__simdf8_load(of, decode); + stbir__decode_simdf8_flip(of); + stbir__simdf8_store(decode, of); + } +#else + { + stbir__simdf of0, of1; + stbir__simdf_load(of0, decode); + stbir__simdf_load(of1, decode + 4); + stbir__decode_simdf4_flip(of0); + stbir__decode_simdf4_flip(of1); + stbir__simdf_store(decode, of0); + stbir__simdf_store(decode + 4, of1); + } +#endif +#endif + decode += 8; + input += 8; + if (decode <= decode_end) + continue; + if (decode == (decode_end + 8)) + break; + decode = decode_end; // backup and do last couple + input = end_input_m8; + } + return; + } +#endif + +// try to do blocks of 4 when you can +#if stbir__coder_min_num != 3 // doesn't divide cleanly by four + decode += 4; + STBIR_SIMD_NO_UNROLL_LOOP_START + while (decode <= decode_end) { + STBIR_SIMD_NO_UNROLL(decode); + decode[0 - 4] = stbir__half_to_float(input[stbir__decode_order0]); + decode[1 - 4] = stbir__half_to_float(input[stbir__decode_order1]); + decode[2 - 4] = stbir__half_to_float(input[stbir__decode_order2]); + decode[3 - 4] = stbir__half_to_float(input[stbir__decode_order3]); + decode += 4; + input += 4; + } + decode -= 4; +#endif + +// do the remnants +#if stbir__coder_min_num < 4 + STBIR_NO_UNROLL_LOOP_START + while (decode < decode_end) { + STBIR_NO_UNROLL(decode); + decode[0] = stbir__half_to_float(input[stbir__decode_order0]); +#if stbir__coder_min_num >= 2 + decode[1] = stbir__half_to_float(input[stbir__decode_order1]); +#endif +#if stbir__coder_min_num >= 3 + decode[2] = stbir__half_to_float(input[stbir__decode_order2]); +#endif + decode += stbir__coder_min_num; + input += stbir__coder_min_num; + } +#endif +} + +static void STBIR__CODER_NAME(stbir__encode_half_float_linear)(void *outputp, + int width_times_channels, + float const *encode) { + stbir__FP16 STBIR_SIMD_STREAMOUT_PTR(*) output = (stbir__FP16 *)outputp; + stbir__FP16 *end_output = ((stbir__FP16 *)output) + width_times_channels; + +#ifdef STBIR_SIMD + if (width_times_channels >= 8) { + float const *end_encode_m8 = encode + width_times_channels - 8; + end_output -= 8; + STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR + for (;;) { + STBIR_SIMD_NO_UNROLL(encode); +#ifdef stbir__decode_swizzle +#ifdef STBIR_SIMD8 + { + stbir__simdf8 of; + stbir__simdf8_load(of, encode); + stbir__encode_simdf8_unflip(of); + stbir__float_to_half_SIMD(output, (float *)&of); + } +#else + { + stbir__simdf of[2]; + stbir__simdf_load(of[0], encode); + stbir__simdf_load(of[1], encode + 4); + stbir__encode_simdf4_unflip(of[0]); + stbir__encode_simdf4_unflip(of[1]); + stbir__float_to_half_SIMD(output, (float *)of); + } +#endif +#else + stbir__float_to_half_SIMD(output, encode); +#endif + encode += 8; + output += 8; + if (output <= end_output) + continue; + if (output == (end_output + 8)) + break; + output = end_output; // backup and do last couple + encode = end_encode_m8; + } + return; + } +#endif + +// try to do blocks of 4 when you can +#if stbir__coder_min_num != 3 // doesn't divide cleanly by four + output += 4; + STBIR_SIMD_NO_UNROLL_LOOP_START + while (output <= end_output) { + STBIR_SIMD_NO_UNROLL(output); + output[0 - 4] = stbir__float_to_half(encode[stbir__encode_order0]); + output[1 - 4] = stbir__float_to_half(encode[stbir__encode_order1]); + output[2 - 4] = stbir__float_to_half(encode[stbir__encode_order2]); + output[3 - 4] = stbir__float_to_half(encode[stbir__encode_order3]); + output += 4; + encode += 4; + } + output -= 4; +#endif + +// do the remnants +#if stbir__coder_min_num < 4 + STBIR_NO_UNROLL_LOOP_START + while (output < end_output) { + STBIR_NO_UNROLL(output); + output[0] = stbir__float_to_half(encode[stbir__encode_order0]); +#if stbir__coder_min_num >= 2 + output[1] = stbir__float_to_half(encode[stbir__encode_order1]); +#endif +#if stbir__coder_min_num >= 3 + output[2] = stbir__float_to_half(encode[stbir__encode_order2]); +#endif + output += stbir__coder_min_num; + encode += stbir__coder_min_num; + } +#endif +} + +static void STBIR__CODER_NAME(stbir__decode_float_linear)(float *decodep, int width_times_channels, + void const *inputp) { +#ifdef stbir__decode_swizzle + float STBIR_STREAMOUT_PTR(*) decode = decodep; + float *decode_end = (float *)decode + width_times_channels; + float const *input = (float const *)inputp; + +#ifdef STBIR_SIMD + if (width_times_channels >= 16) { + float const *end_input_m16 = input + width_times_channels - 16; + decode_end -= 16; + STBIR_NO_UNROLL_LOOP_START_INF_FOR + for (;;) { + STBIR_NO_UNROLL(decode); +#ifdef stbir__decode_swizzle +#ifdef STBIR_SIMD8 + { + stbir__simdf8 of0, of1; + stbir__simdf8_load(of0, input); + stbir__simdf8_load(of1, input + 8); + stbir__decode_simdf8_flip(of0); + stbir__decode_simdf8_flip(of1); + stbir__simdf8_store(decode, of0); + stbir__simdf8_store(decode + 8, of1); + } +#else + { + stbir__simdf of0, of1, of2, of3; + stbir__simdf_load(of0, input); + stbir__simdf_load(of1, input + 4); + stbir__simdf_load(of2, input + 8); + stbir__simdf_load(of3, input + 12); + stbir__decode_simdf4_flip(of0); + stbir__decode_simdf4_flip(of1); + stbir__decode_simdf4_flip(of2); + stbir__decode_simdf4_flip(of3); + stbir__simdf_store(decode, of0); + stbir__simdf_store(decode + 4, of1); + stbir__simdf_store(decode + 8, of2); + stbir__simdf_store(decode + 12, of3); + } +#endif +#endif + decode += 16; + input += 16; + if (decode <= decode_end) + continue; + if (decode == (decode_end + 16)) + break; + decode = decode_end; // backup and do last couple + input = end_input_m16; + } + return; + } +#endif + +// try to do blocks of 4 when you can +#if stbir__coder_min_num != 3 // doesn't divide cleanly by four + decode += 4; + STBIR_SIMD_NO_UNROLL_LOOP_START + while (decode <= decode_end) { + STBIR_SIMD_NO_UNROLL(decode); + decode[0 - 4] = input[stbir__decode_order0]; + decode[1 - 4] = input[stbir__decode_order1]; + decode[2 - 4] = input[stbir__decode_order2]; + decode[3 - 4] = input[stbir__decode_order3]; + decode += 4; + input += 4; + } + decode -= 4; +#endif + +// do the remnants +#if stbir__coder_min_num < 4 + STBIR_NO_UNROLL_LOOP_START + while (decode < decode_end) { + STBIR_NO_UNROLL(decode); + decode[0] = input[stbir__decode_order0]; +#if stbir__coder_min_num >= 2 + decode[1] = input[stbir__decode_order1]; +#endif +#if stbir__coder_min_num >= 3 + decode[2] = input[stbir__decode_order2]; +#endif + decode += stbir__coder_min_num; + input += stbir__coder_min_num; + } +#endif + +#else + + if ((void *)decodep != inputp) + STBIR_MEMCPY(decodep, inputp, width_times_channels * sizeof(float)); + +#endif +} + +static void STBIR__CODER_NAME(stbir__encode_float_linear)(void *outputp, int width_times_channels, + float const *encode) { +#if !defined(STBIR_FLOAT_HIGH_CLAMP) && !defined(STBIR_FLOAT_LO_CLAMP) && \ + !defined(stbir__decode_swizzle) + + if ((void *)outputp != (void *)encode) + STBIR_MEMCPY(outputp, encode, width_times_channels * sizeof(float)); + +#else + + float STBIR_SIMD_STREAMOUT_PTR(*) output = (float *)outputp; + float *end_output = ((float *)output) + width_times_channels; + +#ifdef STBIR_FLOAT_HIGH_CLAMP +#define stbir_scalar_hi_clamp(v) \ + if (v > STBIR_FLOAT_HIGH_CLAMP) \ + v = STBIR_FLOAT_HIGH_CLAMP; +#else +#define stbir_scalar_hi_clamp(v) +#endif +#ifdef STBIR_FLOAT_LOW_CLAMP +#define stbir_scalar_lo_clamp(v) \ + if (v < STBIR_FLOAT_LOW_CLAMP) \ + v = STBIR_FLOAT_LOW_CLAMP; +#else +#define stbir_scalar_lo_clamp(v) +#endif + +#ifdef STBIR_SIMD + +#ifdef STBIR_FLOAT_HIGH_CLAMP + const stbir__simdfX high_clamp = stbir__simdf_frepX(STBIR_FLOAT_HIGH_CLAMP); +#endif +#ifdef STBIR_FLOAT_LOW_CLAMP + const stbir__simdfX low_clamp = stbir__simdf_frepX(STBIR_FLOAT_LOW_CLAMP); +#endif + + if (width_times_channels >= (stbir__simdfX_float_count * 2)) { + float const *end_encode_m8 = + encode + width_times_channels - (stbir__simdfX_float_count * 2); + end_output -= (stbir__simdfX_float_count * 2); + STBIR_SIMD_NO_UNROLL_LOOP_START_INF_FOR + for (;;) { + stbir__simdfX e0, e1; + STBIR_SIMD_NO_UNROLL(encode); + stbir__simdfX_load(e0, encode); + stbir__simdfX_load(e1, encode + stbir__simdfX_float_count); +#ifdef STBIR_FLOAT_HIGH_CLAMP + stbir__simdfX_min(e0, e0, high_clamp); + stbir__simdfX_min(e1, e1, high_clamp); +#endif +#ifdef STBIR_FLOAT_LOW_CLAMP + stbir__simdfX_max(e0, e0, low_clamp); + stbir__simdfX_max(e1, e1, low_clamp); +#endif + stbir__encode_simdfX_unflip(e0); + stbir__encode_simdfX_unflip(e1); + stbir__simdfX_store(output, e0); + stbir__simdfX_store(output + stbir__simdfX_float_count, e1); + encode += stbir__simdfX_float_count * 2; + output += stbir__simdfX_float_count * 2; + if (output < end_output) + continue; + if (output == (end_output + (stbir__simdfX_float_count * 2))) + break; + output = end_output; // backup and do last couple + encode = end_encode_m8; + } + return; + } + +// try to do blocks of 4 when you can +#if stbir__coder_min_num != 3 // doesn't divide cleanly by four + output += 4; + STBIR_NO_UNROLL_LOOP_START + while (output <= end_output) { + stbir__simdf e0; + STBIR_NO_UNROLL(encode); + stbir__simdf_load(e0, encode); +#ifdef STBIR_FLOAT_HIGH_CLAMP + stbir__simdf_min(e0, e0, high_clamp); +#endif +#ifdef STBIR_FLOAT_LOW_CLAMP + stbir__simdf_max(e0, e0, low_clamp); +#endif + stbir__encode_simdf4_unflip(e0); + stbir__simdf_store(output - 4, e0); + output += 4; + encode += 4; + } + output -= 4; +#endif + +#else + +// try to do blocks of 4 when you can +#if stbir__coder_min_num != 3 // doesn't divide cleanly by four + output += 4; + STBIR_SIMD_NO_UNROLL_LOOP_START + while (output <= end_output) { + float e; + STBIR_SIMD_NO_UNROLL(encode); + e = encode[stbir__encode_order0]; + stbir_scalar_hi_clamp(e); + stbir_scalar_lo_clamp(e); + output[0 - 4] = e; + e = encode[stbir__encode_order1]; + stbir_scalar_hi_clamp(e); + stbir_scalar_lo_clamp(e); + output[1 - 4] = e; + e = encode[stbir__encode_order2]; + stbir_scalar_hi_clamp(e); + stbir_scalar_lo_clamp(e); + output[2 - 4] = e; + e = encode[stbir__encode_order3]; + stbir_scalar_hi_clamp(e); + stbir_scalar_lo_clamp(e); + output[3 - 4] = e; + output += 4; + encode += 4; + } + output -= 4; + +#endif + +#endif + +// do the remnants +#if stbir__coder_min_num < 4 + STBIR_NO_UNROLL_LOOP_START + while (output < end_output) { + float e; + STBIR_NO_UNROLL(encode); + e = encode[stbir__encode_order0]; + stbir_scalar_hi_clamp(e); + stbir_scalar_lo_clamp(e); + output[0] = e; +#if stbir__coder_min_num >= 2 + e = encode[stbir__encode_order1]; + stbir_scalar_hi_clamp(e); + stbir_scalar_lo_clamp(e); + output[1] = e; +#endif +#if stbir__coder_min_num >= 3 + e = encode[stbir__encode_order2]; + stbir_scalar_hi_clamp(e); + stbir_scalar_lo_clamp(e); + output[2] = e; +#endif + output += stbir__coder_min_num; + encode += stbir__coder_min_num; + } +#endif + +#endif +} + +#undef stbir__decode_suffix +#undef stbir__decode_simdf8_flip +#undef stbir__decode_simdf4_flip +#undef stbir__decode_order0 +#undef stbir__decode_order1 +#undef stbir__decode_order2 +#undef stbir__decode_order3 +#undef stbir__encode_order0 +#undef stbir__encode_order1 +#undef stbir__encode_order2 +#undef stbir__encode_order3 +#undef stbir__encode_simdf8_unflip +#undef stbir__encode_simdf4_unflip +#undef stbir__encode_simdfX_unflip +#undef STBIR__CODER_NAME +#undef stbir__coder_min_num +#undef stbir__decode_swizzle +#undef stbir_scalar_hi_clamp +#undef stbir_scalar_lo_clamp +#undef STB_IMAGE_RESIZE_DO_CODERS + +#elif defined(STB_IMAGE_RESIZE_DO_VERTICALS) + +#ifdef STB_IMAGE_RESIZE_VERTICAL_CONTINUE +#define STBIR_chans(start, end) STBIR_strs_join14(start, STBIR__vertical_channels, end, _cont) +#else +#define STBIR_chans(start, end) STBIR_strs_join1(start, STBIR__vertical_channels, end) +#endif + +#if STBIR__vertical_channels >= 1 +#define stbIF0(code) code +#else +#define stbIF0(code) +#endif +#if STBIR__vertical_channels >= 2 +#define stbIF1(code) code +#else +#define stbIF1(code) +#endif +#if STBIR__vertical_channels >= 3 +#define stbIF2(code) code +#else +#define stbIF2(code) +#endif +#if STBIR__vertical_channels >= 4 +#define stbIF3(code) code +#else +#define stbIF3(code) +#endif +#if STBIR__vertical_channels >= 5 +#define stbIF4(code) code +#else +#define stbIF4(code) +#endif +#if STBIR__vertical_channels >= 6 +#define stbIF5(code) code +#else +#define stbIF5(code) +#endif +#if STBIR__vertical_channels >= 7 +#define stbIF6(code) code +#else +#define stbIF6(code) +#endif +#if STBIR__vertical_channels >= 8 +#define stbIF7(code) code +#else +#define stbIF7(code) +#endif + +static void STBIR_chans(stbir__vertical_scatter_with_, + _coeffs)(float **outputs, float const *vertical_coefficients, + float const *input, float const *input_end) { + stbIF0(float STBIR_SIMD_STREAMOUT_PTR(*) output0 = outputs[0]; + float c0s = vertical_coefficients[0];) + stbIF1(float STBIR_SIMD_STREAMOUT_PTR(*) output1 = outputs[1]; + float c1s = vertical_coefficients[1];) + stbIF2(float STBIR_SIMD_STREAMOUT_PTR(*) output2 = outputs[2]; + float c2s = vertical_coefficients[2];) + stbIF3(float STBIR_SIMD_STREAMOUT_PTR(*) output3 = outputs[3]; + float c3s = vertical_coefficients[3];) + stbIF4(float STBIR_SIMD_STREAMOUT_PTR(*) output4 = outputs[4]; + float c4s = vertical_coefficients[4];) + stbIF5(float STBIR_SIMD_STREAMOUT_PTR(*) output5 = outputs[5]; + float c5s = vertical_coefficients[5];) + stbIF6(float STBIR_SIMD_STREAMOUT_PTR(*) output6 = outputs[6]; + float c6s = vertical_coefficients[6];) + stbIF7(float STBIR_SIMD_STREAMOUT_PTR(*) output7 = outputs[7]; + float c7s = vertical_coefficients[7];) + +#ifdef STBIR_SIMD + { + stbIF0(stbir__simdfX c0 = stbir__simdf_frepX(c0s);) + stbIF1(stbir__simdfX c1 = stbir__simdf_frepX(c1s);) + stbIF2(stbir__simdfX c2 = stbir__simdf_frepX(c2s);) + stbIF3(stbir__simdfX c3 = stbir__simdf_frepX(c3s);) + stbIF4(stbir__simdfX c4 = stbir__simdf_frepX(c4s);) + stbIF5(stbir__simdfX c5 = stbir__simdf_frepX(c5s);) + stbIF6(stbir__simdfX c6 = stbir__simdf_frepX(c6s);) + stbIF7(stbir__simdfX c7 = stbir__simdf_frepX(c7s);) + STBIR_SIMD_NO_UNROLL_LOOP_START while ( + ((char *)input_end - (char *)input) >= + (16 * stbir__simdfX_float_count)) { + stbir__simdfX o0, o1, o2, o3, r0, r1, r2, r3; + STBIR_SIMD_NO_UNROLL(output0); + + stbir__simdfX_load(r0, input); + stbir__simdfX_load(r1, input + stbir__simdfX_float_count); + stbir__simdfX_load(r2, input + (2 * stbir__simdfX_float_count)); + stbir__simdfX_load(r3, input + (3 * stbir__simdfX_float_count)); + +#ifdef STB_IMAGE_RESIZE_VERTICAL_CONTINUE + stbIF0( + stbir__simdfX_load(o0, output0); + stbir__simdfX_load(o1, output0 + stbir__simdfX_float_count); + stbir__simdfX_load(o2, output0 + (2 * stbir__simdfX_float_count)); + stbir__simdfX_load(o3, output0 + (3 * stbir__simdfX_float_count)); + stbir__simdfX_madd(o0, o0, r0, c0); stbir__simdfX_madd(o1, o1, r1, c0); + stbir__simdfX_madd(o2, o2, r2, c0); stbir__simdfX_madd(o3, o3, r3, c0); + stbir__simdfX_store(output0, o0); + stbir__simdfX_store(output0 + stbir__simdfX_float_count, o1); + stbir__simdfX_store(output0 + (2 * stbir__simdfX_float_count), o2); + stbir__simdfX_store( + output0 + (3 * stbir__simdfX_float_count), + o3);) stbIF1(stbir__simdfX_load(o0, output1); + stbir__simdfX_load(o1, output1 + stbir__simdfX_float_count); + stbir__simdfX_load(o2, output1 + (2 * stbir__simdfX_float_count)); + stbir__simdfX_load(o3, output1 + (3 * stbir__simdfX_float_count)); + stbir__simdfX_madd(o0, o0, r0, c1); + stbir__simdfX_madd(o1, o1, r1, c1); + stbir__simdfX_madd(o2, o2, r2, c1); + stbir__simdfX_madd(o3, o3, r3, c1); + stbir__simdfX_store(output1, o0); + stbir__simdfX_store(output1 + stbir__simdfX_float_count, o1); + stbir__simdfX_store(output1 + (2 * stbir__simdfX_float_count), o2); + stbir__simdfX_store(output1 + (3 * stbir__simdfX_float_count), + o3);) + stbIF2(stbir__simdfX_load(o0, output2); + stbir__simdfX_load(o1, output2 + stbir__simdfX_float_count); + stbir__simdfX_load(o2, output2 + (2 * stbir__simdfX_float_count)); + stbir__simdfX_load(o3, output2 + (3 * stbir__simdfX_float_count)); + stbir__simdfX_madd(o0, o0, r0, c2); stbir__simdfX_madd(o1, o1, r1, c2); + stbir__simdfX_madd(o2, o2, r2, c2); stbir__simdfX_madd(o3, o3, r3, c2); + stbir__simdfX_store(output2, o0); + stbir__simdfX_store(output2 + stbir__simdfX_float_count, o1); + stbir__simdfX_store(output2 + (2 * stbir__simdfX_float_count), o2); + stbir__simdfX_store(output2 + (3 * stbir__simdfX_float_count), o3);) + stbIF3(stbir__simdfX_load(o0, output3); + stbir__simdfX_load(o1, output3 + stbir__simdfX_float_count); + stbir__simdfX_load(o2, output3 + (2 * stbir__simdfX_float_count)); + stbir__simdfX_load(o3, output3 + (3 * stbir__simdfX_float_count)); + stbir__simdfX_madd(o0, o0, r0, c3); stbir__simdfX_madd(o1, o1, r1, c3); + stbir__simdfX_madd(o2, o2, r2, c3); stbir__simdfX_madd(o3, o3, r3, c3); + stbir__simdfX_store(output3, o0); + stbir__simdfX_store(output3 + stbir__simdfX_float_count, o1); + stbir__simdfX_store(output3 + (2 * stbir__simdfX_float_count), o2); + stbir__simdfX_store(output3 + (3 * stbir__simdfX_float_count), o3);) + stbIF4(stbir__simdfX_load(o0, output4); + stbir__simdfX_load(o1, output4 + stbir__simdfX_float_count); + stbir__simdfX_load(o2, output4 + (2 * stbir__simdfX_float_count)); + stbir__simdfX_load(o3, output4 + (3 * stbir__simdfX_float_count)); + stbir__simdfX_madd(o0, o0, r0, c4); + stbir__simdfX_madd(o1, o1, r1, c4); + stbir__simdfX_madd(o2, o2, r2, c4); + stbir__simdfX_madd(o3, o3, r3, c4); stbir__simdfX_store(output4, o0); + stbir__simdfX_store(output4 + stbir__simdfX_float_count, o1); + stbir__simdfX_store(output4 + (2 * stbir__simdfX_float_count), o2); + stbir__simdfX_store(output4 + (3 * stbir__simdfX_float_count), o3);) + stbIF5( + stbir__simdfX_load(o0, output5); + stbir__simdfX_load(o1, output5 + stbir__simdfX_float_count); + stbir__simdfX_load(o2, output5 + (2 * stbir__simdfX_float_count)); + stbir__simdfX_load(o3, output5 + (3 * stbir__simdfX_float_count)); + stbir__simdfX_madd(o0, o0, r0, c5); + stbir__simdfX_madd(o1, o1, r1, c5); + stbir__simdfX_madd(o2, o2, r2, c5); + stbir__simdfX_madd(o3, o3, r3, c5); + stbir__simdfX_store(output5, o0); + stbir__simdfX_store(output5 + stbir__simdfX_float_count, o1); + stbir__simdfX_store(output5 + (2 * stbir__simdfX_float_count), o2); + stbir__simdfX_store(output5 + (3 * stbir__simdfX_float_count), o3);) + stbIF6(stbir__simdfX_load(o0, output6); + stbir__simdfX_load(o1, output6 + stbir__simdfX_float_count); + stbir__simdfX_load(o2, output6 + + (2 * stbir__simdfX_float_count)); + stbir__simdfX_load(o3, output6 + + (3 * stbir__simdfX_float_count)); + stbir__simdfX_madd(o0, o0, r0, c6); + stbir__simdfX_madd(o1, o1, r1, c6); + stbir__simdfX_madd(o2, o2, r2, c6); + stbir__simdfX_madd(o3, o3, r3, c6); + stbir__simdfX_store(output6, o0); + stbir__simdfX_store(output6 + stbir__simdfX_float_count, o1); + stbir__simdfX_store( + output6 + (2 * stbir__simdfX_float_count), o2); + stbir__simdfX_store( + output6 + (3 * stbir__simdfX_float_count), o3);) + stbIF7(stbir__simdfX_load(o0, output7); stbir__simdfX_load( + o1, output7 + stbir__simdfX_float_count); + stbir__simdfX_load( + o2, output7 + (2 * stbir__simdfX_float_count)); + stbir__simdfX_load( + o3, output7 + (3 * stbir__simdfX_float_count)); + stbir__simdfX_madd(o0, o0, r0, c7); + stbir__simdfX_madd(o1, o1, r1, c7); + stbir__simdfX_madd(o2, o2, r2, c7); + stbir__simdfX_madd(o3, o3, r3, c7); + stbir__simdfX_store(output7, o0); stbir__simdfX_store( + output7 + stbir__simdfX_float_count, o1); + stbir__simdfX_store( + output7 + (2 * stbir__simdfX_float_count), o2); + stbir__simdfX_store( + output7 + (3 * stbir__simdfX_float_count), o3);) +#else + stbIF0( + stbir__simdfX_mult(o0, r0, c0); stbir__simdfX_mult(o1, r1, c0); + stbir__simdfX_mult(o2, r2, c0); stbir__simdfX_mult(o3, r3, c0); + stbir__simdfX_store(output0, o0); + stbir__simdfX_store(output0 + stbir__simdfX_float_count, o1); + stbir__simdfX_store(output0 + (2 * stbir__simdfX_float_count), o2); + stbir__simdfX_store( + output0 + (3 * stbir__simdfX_float_count), + o3);) stbIF1(stbir__simdfX_mult(o0, r0, c1); stbir__simdfX_mult(o1, r1, c1); + stbir__simdfX_mult(o2, r2, c1); stbir__simdfX_mult(o3, r3, c1); + stbir__simdfX_store(output1, o0); + stbir__simdfX_store(output1 + stbir__simdfX_float_count, o1); + stbir__simdfX_store(output1 + (2 * stbir__simdfX_float_count), o2); + stbir__simdfX_store(output1 + (3 * stbir__simdfX_float_count), + o3);) + stbIF2(stbir__simdfX_mult(o0, r0, c2); stbir__simdfX_mult(o1, r1, c2); + stbir__simdfX_mult(o2, r2, c2); stbir__simdfX_mult(o3, r3, c2); + stbir__simdfX_store(output2, o0); + stbir__simdfX_store(output2 + stbir__simdfX_float_count, o1); + stbir__simdfX_store(output2 + (2 * stbir__simdfX_float_count), o2); + stbir__simdfX_store(output2 + (3 * stbir__simdfX_float_count), o3);) + stbIF3(stbir__simdfX_mult(o0, r0, c3); stbir__simdfX_mult(o1, r1, c3); + stbir__simdfX_mult(o2, r2, c3); stbir__simdfX_mult(o3, r3, c3); + stbir__simdfX_store(output3, o0); + stbir__simdfX_store(output3 + stbir__simdfX_float_count, o1); + stbir__simdfX_store(output3 + (2 * stbir__simdfX_float_count), o2); + stbir__simdfX_store(output3 + (3 * stbir__simdfX_float_count), o3);) + stbIF4(stbir__simdfX_mult(o0, r0, c4); stbir__simdfX_mult(o1, r1, c4); + stbir__simdfX_mult(o2, r2, c4); stbir__simdfX_mult(o3, r3, c4); + stbir__simdfX_store(output4, o0); + stbir__simdfX_store(output4 + stbir__simdfX_float_count, o1); + stbir__simdfX_store(output4 + (2 * stbir__simdfX_float_count), o2); + stbir__simdfX_store(output4 + (3 * stbir__simdfX_float_count), o3);) + stbIF5( + stbir__simdfX_mult(o0, r0, c5); stbir__simdfX_mult(o1, r1, c5); + stbir__simdfX_mult(o2, r2, c5); stbir__simdfX_mult(o3, r3, c5); + stbir__simdfX_store(output5, o0); + stbir__simdfX_store(output5 + stbir__simdfX_float_count, o1); + stbir__simdfX_store(output5 + (2 * stbir__simdfX_float_count), o2); + stbir__simdfX_store(output5 + (3 * stbir__simdfX_float_count), o3);) + stbIF6( + stbir__simdfX_mult(o0, r0, c6); stbir__simdfX_mult(o1, r1, c6); + stbir__simdfX_mult(o2, r2, c6); stbir__simdfX_mult(o3, r3, c6); + stbir__simdfX_store(output6, o0); + stbir__simdfX_store(output6 + stbir__simdfX_float_count, o1); + stbir__simdfX_store(output6 + (2 * stbir__simdfX_float_count), + o2); + stbir__simdfX_store(output6 + (3 * stbir__simdfX_float_count), + o3);) + stbIF7(stbir__simdfX_mult(o0, r0, c7); + stbir__simdfX_mult(o1, r1, c7); + stbir__simdfX_mult(o2, r2, c7); + stbir__simdfX_mult(o3, r3, c7); + stbir__simdfX_store(output7, o0); stbir__simdfX_store( + output7 + stbir__simdfX_float_count, o1); + stbir__simdfX_store( + output7 + (2 * stbir__simdfX_float_count), o2); + stbir__simdfX_store( + output7 + (3 * stbir__simdfX_float_count), o3);) +#endif + + input += (4 * stbir__simdfX_float_count); + stbIF0(output0 += (4 * stbir__simdfX_float_count);) + stbIF1(output1 += (4 * stbir__simdfX_float_count);) + stbIF2(output2 += (4 * stbir__simdfX_float_count);) + stbIF3(output3 += (4 * stbir__simdfX_float_count);) + stbIF4(output4 += (4 * stbir__simdfX_float_count);) + stbIF5(output5 += (4 * stbir__simdfX_float_count);) + stbIF6(output6 += (4 * stbir__simdfX_float_count);) + stbIF7(output7 += (4 * stbir__simdfX_float_count);) + } + STBIR_SIMD_NO_UNROLL_LOOP_START + while (((char *)input_end - (char *)input) >= 16) { + stbir__simdf o0, r0; + STBIR_SIMD_NO_UNROLL(output0); + + stbir__simdf_load(r0, input); + +#ifdef STB_IMAGE_RESIZE_VERTICAL_CONTINUE + stbIF0(stbir__simdf_load(o0, output0); + stbir__simdf_madd(o0, o0, r0, stbir__if_simdf8_cast_to_simdf4(c0)); + stbir__simdf_store(output0, o0);) + stbIF1(stbir__simdf_load(o0, output1); + stbir__simdf_madd(o0, o0, r0, stbir__if_simdf8_cast_to_simdf4(c1)); + stbir__simdf_store(output1, o0);) + stbIF2(stbir__simdf_load(o0, output2); + stbir__simdf_madd(o0, o0, r0, stbir__if_simdf8_cast_to_simdf4(c2)); + stbir__simdf_store(output2, o0);) + stbIF3(stbir__simdf_load(o0, output3); + stbir__simdf_madd(o0, o0, r0, stbir__if_simdf8_cast_to_simdf4(c3)); + stbir__simdf_store(output3, o0);) + stbIF4(stbir__simdf_load(o0, output4); stbir__simdf_madd( + o0, o0, r0, stbir__if_simdf8_cast_to_simdf4(c4)); + stbir__simdf_store(output4, o0);) + stbIF5(stbir__simdf_load(o0, output5); stbir__simdf_madd( + o0, o0, r0, stbir__if_simdf8_cast_to_simdf4(c5)); + stbir__simdf_store(output5, o0);) + stbIF6(stbir__simdf_load(o0, output6); stbir__simdf_madd( + o0, o0, r0, stbir__if_simdf8_cast_to_simdf4(c6)); + stbir__simdf_store(output6, o0);) + stbIF7(stbir__simdf_load(o0, output7); stbir__simdf_madd( + o0, o0, r0, stbir__if_simdf8_cast_to_simdf4(c7)); + stbir__simdf_store(output7, o0);) +#else + stbIF0(stbir__simdf_mult(o0, r0, stbir__if_simdf8_cast_to_simdf4(c0)); + stbir__simdf_store(output0, o0);) + stbIF1(stbir__simdf_mult(o0, r0, stbir__if_simdf8_cast_to_simdf4(c1)); + stbir__simdf_store(output1, o0);) + stbIF2(stbir__simdf_mult(o0, r0, stbir__if_simdf8_cast_to_simdf4(c2)); + stbir__simdf_store(output2, o0);) + stbIF3(stbir__simdf_mult(o0, r0, stbir__if_simdf8_cast_to_simdf4(c3)); + stbir__simdf_store(output3, o0);) + stbIF4(stbir__simdf_mult(o0, r0, stbir__if_simdf8_cast_to_simdf4(c4)); + stbir__simdf_store(output4, o0);) + stbIF5( + stbir__simdf_mult(o0, r0, stbir__if_simdf8_cast_to_simdf4(c5)); + stbir__simdf_store(output5, o0);) + stbIF6(stbir__simdf_mult(o0, r0, + stbir__if_simdf8_cast_to_simdf4(c6)); + stbir__simdf_store(output6, o0);) + stbIF7(stbir__simdf_mult( + o0, r0, stbir__if_simdf8_cast_to_simdf4(c7)); + stbir__simdf_store(output7, o0);) +#endif + + input += 4; + stbIF0(output0 += 4;) stbIF1(output1 += 4;) stbIF2(output2 += 4;) stbIF3(output3 += 4;) + stbIF4(output4 += 4;) stbIF5(output5 += 4;) stbIF6(output6 += 4;) + stbIF7(output7 += 4;) + } + } +#else + STBIR_NO_UNROLL_LOOP_START while ( + ((char *)input_end - (char *)input) >= 16) { + float r0, r1, r2, r3; + STBIR_NO_UNROLL(input); + + r0 = input[0], r1 = input[1], r2 = input[2], r3 = input[3]; + +#ifdef STB_IMAGE_RESIZE_VERTICAL_CONTINUE + stbIF0(output0[0] += (r0 * c0s); output0[1] += (r1 * c0s); output0[2] += (r2 * c0s); + output0[3] += (r3 * c0s);) + stbIF1(output1[0] += (r0 * c1s); output1[1] += (r1 * c1s); output1[2] += (r2 * c1s); + output1[3] += (r3 * c1s);) + stbIF2(output2[0] += (r0 * c2s); output2[1] += (r1 * c2s); output2[2] += (r2 * c2s); + output2[3] += (r3 * c2s);) + stbIF3(output3[0] += (r0 * c3s); output3[1] += (r1 * c3s); + output3[2] += (r2 * c3s); output3[3] += (r3 * c3s);) + stbIF4(output4[0] += (r0 * c4s); output4[1] += (r1 * c4s); + output4[2] += (r2 * c4s); output4[3] += (r3 * c4s);) + stbIF5(output5[0] += (r0 * c5s); output5[1] += (r1 * c5s); + output5[2] += (r2 * c5s); output5[3] += (r3 * c5s);) + stbIF6(output6[0] += (r0 * c6s); output6[1] += (r1 * c6s); + output6[2] += (r2 * c6s); output6[3] += (r3 * c6s);) + stbIF7(output7[0] += (r0 * c7s); output7[1] += (r1 * c7s); + output7[2] += (r2 * c7s); output7[3] += (r3 * c7s);) +#else + stbIF0(output0[0] = (r0 * c0s); output0[1] = (r1 * c0s); output0[2] = (r2 * c0s); + output0[3] = (r3 * c0s);) stbIF1(output1[0] = (r0 * c1s); output1[1] = (r1 * c1s); + output1[2] = (r2 * c1s); output1[3] = (r3 * c1s);) + stbIF2(output2[0] = (r0 * c2s); output2[1] = (r1 * c2s); output2[2] = (r2 * c2s); + output2[3] = (r3 * c2s);) + stbIF3(output3[0] = (r0 * c3s); output3[1] = (r1 * c3s); output3[2] = (r2 * c3s); + output3[3] = (r3 * c3s);) + stbIF4(output4[0] = (r0 * c4s); output4[1] = (r1 * c4s); + output4[2] = (r2 * c4s); output4[3] = (r3 * c4s);) + stbIF5(output5[0] = (r0 * c5s); output5[1] = (r1 * c5s); + output5[2] = (r2 * c5s); output5[3] = (r3 * c5s);) + stbIF6(output6[0] = (r0 * c6s); output6[1] = (r1 * c6s); + output6[2] = (r2 * c6s); output6[3] = (r3 * c6s);) + stbIF7(output7[0] = (r0 * c7s); output7[1] = (r1 * c7s); + output7[2] = (r2 * c7s); output7[3] = (r3 * c7s);) +#endif + + input += 4; + stbIF0(output0 += 4;) stbIF1(output1 += 4;) stbIF2(output2 += 4;) stbIF3(output3 += 4;) + stbIF4(output4 += 4;) stbIF5(output5 += 4;) stbIF6(output6 += 4;) stbIF7(output7 += 4;) + } +#endif + STBIR_NO_UNROLL_LOOP_START + while (input < input_end) { + float r = input[0]; + STBIR_NO_UNROLL(output0); + +#ifdef STB_IMAGE_RESIZE_VERTICAL_CONTINUE + stbIF0(output0[0] += (r * c0s);) stbIF1(output1[0] += (r * c1s);) + stbIF2(output2[0] += (r * c2s);) stbIF3(output3[0] += (r * c3s);) + stbIF4(output4[0] += (r * c4s);) stbIF5(output5[0] += (r * c5s);) + stbIF6(output6[0] += (r * c6s);) stbIF7(output7[0] += (r * c7s);) +#else + stbIF0(output0[0] = (r * c0s);) stbIF1(output1[0] = (r * c1s);) + stbIF2(output2[0] = (r * c2s);) stbIF3(output3[0] = (r * c3s);) + stbIF4(output4[0] = (r * c4s);) stbIF5(output5[0] = (r * c5s);) + stbIF6(output6[0] = (r * c6s);) stbIF7(output7[0] = (r * c7s);) +#endif + + ++ input; + stbIF0(++output0;) stbIF1(++output1;) stbIF2(++output2;) stbIF3(++output3;) + stbIF4(++output4;) stbIF5(++output5;) stbIF6(++output6;) stbIF7(++output7;) + } +} + +static void STBIR_chans(stbir__vertical_gather_with_, + _coeffs)(float *outputp, float const *vertical_coefficients, + float const **inputs, float const *input0_end) { + float STBIR_SIMD_STREAMOUT_PTR(*) output = outputp; + + stbIF0(float const *input0 = inputs[0]; float c0s = vertical_coefficients[0];) stbIF1( + float const *input1 = inputs[1]; float c1s = vertical_coefficients[1];) + stbIF2(float const *input2 = inputs[2]; float c2s = vertical_coefficients[2];) stbIF3( + float const *input3 = inputs[3]; float c3s = vertical_coefficients[3];) + stbIF4(float const *input4 = inputs[4]; float c4s = vertical_coefficients[4];) stbIF5( + float const *input5 = inputs[5]; float c5s = vertical_coefficients[5];) + stbIF6(float const *input6 = inputs[6]; float c6s = vertical_coefficients[6];) + stbIF7(float const *input7 = inputs[7]; float c7s = vertical_coefficients[7];) + +#if (STBIR__vertical_channels == 1) && !defined(STB_IMAGE_RESIZE_VERTICAL_CONTINUE) + // check single channel one weight + if ((c0s >= (1.0f - 0.000001f)) && (c0s <= (1.0f + 0.000001f))) { + STBIR_MEMCPY(output, input0, (char *)input0_end - (char *)input0); + return; + } +#endif + +#ifdef STBIR_SIMD + { + stbIF0(stbir__simdfX c0 = stbir__simdf_frepX(c0s);) + stbIF1(stbir__simdfX c1 = stbir__simdf_frepX(c1s);) + stbIF2(stbir__simdfX c2 = stbir__simdf_frepX(c2s);) + stbIF3(stbir__simdfX c3 = stbir__simdf_frepX(c3s);) + stbIF4(stbir__simdfX c4 = stbir__simdf_frepX(c4s);) + stbIF5(stbir__simdfX c5 = stbir__simdf_frepX(c5s);) + stbIF6(stbir__simdfX c6 = stbir__simdf_frepX(c6s);) + stbIF7(stbir__simdfX c7 = stbir__simdf_frepX(c7s);) + + STBIR_SIMD_NO_UNROLL_LOOP_START while ( + ((char *)input0_end - (char *)input0) >= + (16 * stbir__simdfX_float_count)) { + stbir__simdfX o0, o1, o2, o3, r0, r1, r2, r3; + STBIR_SIMD_NO_UNROLL(output); + + // prefetch four loop iterations ahead (doesn't affect much for small resizes, but helps + // with big ones) + stbIF0(stbir__prefetch(input0 + (16 * stbir__simdfX_float_count));) stbIF1( + stbir__prefetch(input1 + (16 * stbir__simdfX_float_count));) + stbIF2(stbir__prefetch(input2 + (16 * stbir__simdfX_float_count));) stbIF3( + stbir__prefetch(input3 + (16 * stbir__simdfX_float_count));) + stbIF4(stbir__prefetch(input4 + (16 * stbir__simdfX_float_count));) stbIF5( + stbir__prefetch(input5 + (16 * stbir__simdfX_float_count));) + stbIF6(stbir__prefetch(input6 + (16 * stbir__simdfX_float_count));) stbIF7( + stbir__prefetch(input7 + (16 * stbir__simdfX_float_count));) + +#ifdef STB_IMAGE_RESIZE_VERTICAL_CONTINUE + stbIF0(stbir__simdfX_load(o0, output); + stbir__simdfX_load(o1, output + stbir__simdfX_float_count); + stbir__simdfX_load(o2, output + (2 * stbir__simdfX_float_count)); + stbir__simdfX_load(o3, output + (3 * stbir__simdfX_float_count)); + stbir__simdfX_load(r0, input0); + stbir__simdfX_load(r1, input0 + stbir__simdfX_float_count); + stbir__simdfX_load(r2, input0 + (2 * stbir__simdfX_float_count)); + stbir__simdfX_load(r3, input0 + (3 * stbir__simdfX_float_count)); + stbir__simdfX_madd(o0, o0, r0, c0); + stbir__simdfX_madd(o1, o1, r1, c0); + stbir__simdfX_madd(o2, o2, r2, c0); + stbir__simdfX_madd(o3, o3, r3, c0);) +#else + stbIF0(stbir__simdfX_load(r0, input0); + stbir__simdfX_load(r1, input0 + stbir__simdfX_float_count); + stbir__simdfX_load(r2, input0 + (2 * stbir__simdfX_float_count)); + stbir__simdfX_load(r3, input0 + (3 * stbir__simdfX_float_count)); + stbir__simdfX_mult(o0, r0, c0); stbir__simdfX_mult(o1, r1, c0); + stbir__simdfX_mult(o2, r2, c0); stbir__simdfX_mult(o3, r3, c0);) +#endif + + stbIF1( + stbir__simdfX_load(r0, input1); + stbir__simdfX_load(r1, input1 + stbir__simdfX_float_count); + stbir__simdfX_load(r2, + input1 + (2 * stbir__simdfX_float_count)); + stbir__simdfX_load(r3, + input1 + (3 * stbir__simdfX_float_count)); + stbir__simdfX_madd(o0, o0, r0, c1); + stbir__simdfX_madd(o1, o1, r1, c1); + stbir__simdfX_madd(o2, o2, r2, c1); stbir__simdfX_madd( + o3, o3, r3, + c1);) stbIF2(stbir__simdfX_load(r0, input2); + stbir__simdfX_load( + r1, input2 + stbir__simdfX_float_count); + stbir__simdfX_load( + r2, + input2 + (2 * stbir__simdfX_float_count)); + stbir__simdfX_load( + r3, + input2 + (3 * stbir__simdfX_float_count)); + stbir__simdfX_madd(o0, o0, r0, c2); + stbir__simdfX_madd(o1, o1, r1, c2); + stbir__simdfX_madd(o2, o2, r2, c2); + stbir__simdfX_madd(o3, o3, r3, c2);) + stbIF3(stbir__simdfX_load(r0, input3); stbir__simdfX_load( + r1, input3 + stbir__simdfX_float_count); + stbir__simdfX_load( + r2, input3 + (2 * stbir__simdfX_float_count)); + stbir__simdfX_load( + r3, input3 + (3 * stbir__simdfX_float_count)); + stbir__simdfX_madd(o0, o0, r0, c3); + stbir__simdfX_madd(o1, o1, r1, c3); + stbir__simdfX_madd(o2, o2, r2, c3); + stbir__simdfX_madd(o3, o3, r3, c3);) + stbIF4(stbir__simdfX_load(r0, input4); stbir__simdfX_load( + r1, input4 + stbir__simdfX_float_count); + stbir__simdfX_load( + r2, input4 + (2 * stbir__simdfX_float_count)); + stbir__simdfX_load( + r3, input4 + (3 * stbir__simdfX_float_count)); + stbir__simdfX_madd(o0, o0, r0, c4); + stbir__simdfX_madd(o1, o1, r1, c4); + stbir__simdfX_madd(o2, o2, r2, c4); + stbir__simdfX_madd(o3, o3, r3, c4);) + stbIF5( + stbir__simdfX_load(r0, input5); stbir__simdfX_load( + r1, input5 + stbir__simdfX_float_count); + stbir__simdfX_load( + r2, input5 + (2 * stbir__simdfX_float_count)); + stbir__simdfX_load( + r3, input5 + (3 * stbir__simdfX_float_count)); + stbir__simdfX_madd(o0, o0, r0, c5); + stbir__simdfX_madd(o1, o1, r1, c5); + stbir__simdfX_madd(o2, o2, r2, c5); + stbir__simdfX_madd(o3, o3, r3, c5);) + stbIF6( + stbir__simdfX_load(r0, input6); + stbir__simdfX_load( + r1, input6 + stbir__simdfX_float_count); + stbir__simdfX_load( + r2, + input6 + (2 * stbir__simdfX_float_count)); + stbir__simdfX_load( + r3, + input6 + (3 * stbir__simdfX_float_count)); + stbir__simdfX_madd(o0, o0, r0, c6); + stbir__simdfX_madd(o1, o1, r1, c6); + stbir__simdfX_madd(o2, o2, r2, c6); + stbir__simdfX_madd(o3, o3, r3, c6);) + stbIF7( + stbir__simdfX_load(r0, input7); + stbir__simdfX_load( + r1, input7 + stbir__simdfX_float_count); + stbir__simdfX_load( + r2, + input7 + + (2 * stbir__simdfX_float_count)); + stbir__simdfX_load( + r3, + input7 + + (3 * stbir__simdfX_float_count)); + stbir__simdfX_madd(o0, o0, r0, c7); + stbir__simdfX_madd(o1, o1, r1, c7); + stbir__simdfX_madd(o2, o2, r2, c7); + stbir__simdfX_madd(o3, o3, r3, c7);) + + stbir__simdfX_store(output, o0); + stbir__simdfX_store(output + stbir__simdfX_float_count, o1); + stbir__simdfX_store(output + (2 * stbir__simdfX_float_count), o2); + stbir__simdfX_store(output + (3 * stbir__simdfX_float_count), o3); + output += (4 * stbir__simdfX_float_count); + stbIF0(input0 += (4 * stbir__simdfX_float_count);) + stbIF1(input1 += (4 * stbir__simdfX_float_count);) + stbIF2(input2 += (4 * stbir__simdfX_float_count);) + stbIF3(input3 += (4 * stbir__simdfX_float_count);) + stbIF4(input4 += (4 * stbir__simdfX_float_count);) + stbIF5(input5 += (4 * stbir__simdfX_float_count);) + stbIF6(input6 += (4 * stbir__simdfX_float_count);) + stbIF7(input7 += (4 * stbir__simdfX_float_count);) + } + + STBIR_SIMD_NO_UNROLL_LOOP_START + while (((char *)input0_end - (char *)input0) >= 16) { + stbir__simdf o0, r0; + STBIR_SIMD_NO_UNROLL(output); + +#ifdef STB_IMAGE_RESIZE_VERTICAL_CONTINUE + stbIF0(stbir__simdf_load(o0, output); stbir__simdf_load(r0, input0); + stbir__simdf_madd(o0, o0, r0, stbir__if_simdf8_cast_to_simdf4(c0));) +#else + stbIF0(stbir__simdf_load(r0, input0); + stbir__simdf_mult(o0, r0, stbir__if_simdf8_cast_to_simdf4(c0));) +#endif + stbIF1(stbir__simdf_load(r0, input1); + stbir__simdf_madd(o0, o0, r0, stbir__if_simdf8_cast_to_simdf4(c1));) + stbIF2(stbir__simdf_load(r0, input2); + stbir__simdf_madd(o0, o0, r0, stbir__if_simdf8_cast_to_simdf4(c2));) + stbIF3(stbir__simdf_load(r0, input3); + stbir__simdf_madd(o0, o0, r0, stbir__if_simdf8_cast_to_simdf4(c3));) + stbIF4(stbir__simdf_load(r0, input4); stbir__simdf_madd( + o0, o0, r0, stbir__if_simdf8_cast_to_simdf4(c4));) + stbIF5(stbir__simdf_load(r0, input5); stbir__simdf_madd( + o0, o0, r0, stbir__if_simdf8_cast_to_simdf4(c5));) + stbIF6(stbir__simdf_load(r0, input6); stbir__simdf_madd( + o0, o0, r0, stbir__if_simdf8_cast_to_simdf4(c6));) + stbIF7( + stbir__simdf_load(r0, input7); stbir__simdf_madd( + o0, o0, r0, stbir__if_simdf8_cast_to_simdf4(c7));) + + stbir__simdf_store(output, o0); + output += 4; + stbIF0(input0 += 4;) stbIF1(input1 += 4;) stbIF2(input2 += 4;) stbIF3(input3 += 4;) + stbIF4(input4 += 4;) stbIF5(input5 += 4;) stbIF6(input6 += 4;) stbIF7(input7 += 4;) + } + } +#else + STBIR_NO_UNROLL_LOOP_START while (((char *)input0_end - (char *)input0) >= + 16) { + float o0, o1, o2, o3; + STBIR_NO_UNROLL(output); +#ifdef STB_IMAGE_RESIZE_VERTICAL_CONTINUE + stbIF0(o0 = output[0] + input0[0] * c0s; o1 = output[1] + input0[1] * c0s; + o2 = output[2] + input0[2] * c0s; o3 = output[3] + input0[3] * c0s;) +#else + stbIF0(o0 = input0[0] * c0s; o1 = input0[1] * c0s; o2 = input0[2] * c0s; + o3 = input0[3] * c0s;) +#endif + stbIF1(o0 += input1[0] * c1s; o1 += input1[1] * c1s; o2 += input1[2] * c1s; + o3 += input1[3] * c1s;) stbIF2(o0 += input2[0] * c2s; o1 += input2[1] * c2s; + o2 += input2[2] * c2s; o3 += input2[3] * c2s;) + stbIF3(o0 += input3[0] * c3s; o1 += input3[1] * c3s; o2 += input3[2] * c3s; + o3 += input3[3] * c3s;) stbIF4(o0 += input4[0] * c4s; o1 += input4[1] * c4s; + o2 += input4[2] * c4s; o3 += input4[3] * c4s;) + stbIF5(o0 += input5[0] * c5s; o1 += input5[1] * c5s; o2 += input5[2] * c5s; + o3 += input5[3] * c5s;) + stbIF6(o0 += input6[0] * c6s; o1 += input6[1] * c6s; o2 += input6[2] * c6s; + o3 += input6[3] * c6s;) + stbIF7(o0 += input7[0] * c7s; o1 += input7[1] * c7s; + o2 += input7[2] * c7s; o3 += input7[3] * c7s;) output[0] = o0; + output[1] = o1; + output[2] = o2; + output[3] = o3; + output += 4; + stbIF0(input0 += 4;) stbIF1(input1 += 4;) stbIF2(input2 += 4;) stbIF3(input3 += 4;) + stbIF4(input4 += 4;) stbIF5(input5 += 4;) stbIF6(input6 += 4;) stbIF7(input7 += 4;) + } +#endif + STBIR_NO_UNROLL_LOOP_START + while (input0 < input0_end) { + float o0; + STBIR_NO_UNROLL(output); +#ifdef STB_IMAGE_RESIZE_VERTICAL_CONTINUE + stbIF0(o0 = output[0] + input0[0] * c0s;) +#else + stbIF0(o0 = input0[0] * c0s;) +#endif + stbIF1(o0 += input1[0] * c1s;) stbIF2(o0 += input2[0] * c2s;) + stbIF3(o0 += input3[0] * c3s;) stbIF4(o0 += input4[0] * c4s;) + stbIF5(o0 += input5[0] * c5s;) stbIF6(o0 += input6[0] * c6s;) + stbIF7(o0 += input7[0] * c7s;) output[0] = o0; + ++output; + stbIF0(++input0;) stbIF1(++input1;) stbIF2(++input2;) stbIF3(++input3;) stbIF4(++input4;) + stbIF5(++input5;) stbIF6(++input6;) stbIF7(++input7;) + } +} + +#undef stbIF0 +#undef stbIF1 +#undef stbIF2 +#undef stbIF3 +#undef stbIF4 +#undef stbIF5 +#undef stbIF6 +#undef stbIF7 +#undef STB_IMAGE_RESIZE_DO_VERTICALS +#undef STBIR__vertical_channels +#undef STB_IMAGE_RESIZE_DO_HORIZONTALS +#undef STBIR_strs_join24 +#undef STBIR_strs_join14 +#undef STBIR_chans +#ifdef STB_IMAGE_RESIZE_VERTICAL_CONTINUE +#undef STB_IMAGE_RESIZE_VERTICAL_CONTINUE +#endif + +#else // !STB_IMAGE_RESIZE_DO_VERTICALS + +#define STBIR_chans(start, end) STBIR_strs_join1(start, STBIR__horizontal_channels, end) + +#ifndef stbir__2_coeff_only +#define stbir__2_coeff_only() \ + stbir__1_coeff_only(); \ + stbir__1_coeff_remnant(1); +#endif + +#ifndef stbir__2_coeff_remnant +#define stbir__2_coeff_remnant(ofs) \ + stbir__1_coeff_remnant(ofs); \ + stbir__1_coeff_remnant((ofs) + 1); +#endif + +#ifndef stbir__3_coeff_only +#define stbir__3_coeff_only() \ + stbir__2_coeff_only(); \ + stbir__1_coeff_remnant(2); +#endif + +#ifndef stbir__3_coeff_remnant +#define stbir__3_coeff_remnant(ofs) \ + stbir__2_coeff_remnant(ofs); \ + stbir__1_coeff_remnant((ofs) + 2); +#endif + +#ifndef stbir__3_coeff_setup +#define stbir__3_coeff_setup() +#endif + +#ifndef stbir__4_coeff_start +#define stbir__4_coeff_start() \ + stbir__2_coeff_only(); \ + stbir__2_coeff_remnant(2); +#endif + +#ifndef stbir__4_coeff_continue_from_4 +#define stbir__4_coeff_continue_from_4(ofs) \ + stbir__2_coeff_remnant(ofs); \ + stbir__2_coeff_remnant((ofs) + 2); +#endif + +#ifndef stbir__store_output_tiny +#define stbir__store_output_tiny stbir__store_output +#endif + +static void STBIR_chans(stbir__horizontal_gather_, + _channels_with_1_coeff)(float *output_buffer, unsigned int output_sub_size, + float const *decode_buffer, + stbir__contributors const *horizontal_contributors, + float const *horizontal_coefficients, + int coefficient_width) { + float const *output_end = output_buffer + output_sub_size * STBIR__horizontal_channels; + float STBIR_SIMD_STREAMOUT_PTR(*) output = output_buffer; + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + float const *decode = + decode_buffer + horizontal_contributors->n0 * STBIR__horizontal_channels; + float const *hc = horizontal_coefficients; + stbir__1_coeff_only(); + stbir__store_output_tiny(); + } while (output < output_end); +} + +static void STBIR_chans(stbir__horizontal_gather_, + _channels_with_2_coeffs)(float *output_buffer, unsigned int output_sub_size, + float const *decode_buffer, + stbir__contributors const *horizontal_contributors, + float const *horizontal_coefficients, + int coefficient_width) { + float const *output_end = output_buffer + output_sub_size * STBIR__horizontal_channels; + float STBIR_SIMD_STREAMOUT_PTR(*) output = output_buffer; + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + float const *decode = + decode_buffer + horizontal_contributors->n0 * STBIR__horizontal_channels; + float const *hc = horizontal_coefficients; + stbir__2_coeff_only(); + stbir__store_output_tiny(); + } while (output < output_end); +} + +static void STBIR_chans(stbir__horizontal_gather_, + _channels_with_3_coeffs)(float *output_buffer, unsigned int output_sub_size, + float const *decode_buffer, + stbir__contributors const *horizontal_contributors, + float const *horizontal_coefficients, + int coefficient_width) { + float const *output_end = output_buffer + output_sub_size * STBIR__horizontal_channels; + float STBIR_SIMD_STREAMOUT_PTR(*) output = output_buffer; + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + float const *decode = + decode_buffer + horizontal_contributors->n0 * STBIR__horizontal_channels; + float const *hc = horizontal_coefficients; + stbir__3_coeff_only(); + stbir__store_output_tiny(); + } while (output < output_end); +} + +static void STBIR_chans(stbir__horizontal_gather_, + _channels_with_4_coeffs)(float *output_buffer, unsigned int output_sub_size, + float const *decode_buffer, + stbir__contributors const *horizontal_contributors, + float const *horizontal_coefficients, + int coefficient_width) { + float const *output_end = output_buffer + output_sub_size * STBIR__horizontal_channels; + float STBIR_SIMD_STREAMOUT_PTR(*) output = output_buffer; + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + float const *decode = + decode_buffer + horizontal_contributors->n0 * STBIR__horizontal_channels; + float const *hc = horizontal_coefficients; + stbir__4_coeff_start(); + stbir__store_output(); + } while (output < output_end); +} + +static void STBIR_chans(stbir__horizontal_gather_, + _channels_with_5_coeffs)(float *output_buffer, unsigned int output_sub_size, + float const *decode_buffer, + stbir__contributors const *horizontal_contributors, + float const *horizontal_coefficients, + int coefficient_width) { + float const *output_end = output_buffer + output_sub_size * STBIR__horizontal_channels; + float STBIR_SIMD_STREAMOUT_PTR(*) output = output_buffer; + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + float const *decode = + decode_buffer + horizontal_contributors->n0 * STBIR__horizontal_channels; + float const *hc = horizontal_coefficients; + stbir__4_coeff_start(); + stbir__1_coeff_remnant(4); + stbir__store_output(); + } while (output < output_end); +} + +static void STBIR_chans(stbir__horizontal_gather_, + _channels_with_6_coeffs)(float *output_buffer, unsigned int output_sub_size, + float const *decode_buffer, + stbir__contributors const *horizontal_contributors, + float const *horizontal_coefficients, + int coefficient_width) { + float const *output_end = output_buffer + output_sub_size * STBIR__horizontal_channels; + float STBIR_SIMD_STREAMOUT_PTR(*) output = output_buffer; + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + float const *decode = + decode_buffer + horizontal_contributors->n0 * STBIR__horizontal_channels; + float const *hc = horizontal_coefficients; + stbir__4_coeff_start(); + stbir__2_coeff_remnant(4); + stbir__store_output(); + } while (output < output_end); +} + +static void STBIR_chans(stbir__horizontal_gather_, + _channels_with_7_coeffs)(float *output_buffer, unsigned int output_sub_size, + float const *decode_buffer, + stbir__contributors const *horizontal_contributors, + float const *horizontal_coefficients, + int coefficient_width) { + float const *output_end = output_buffer + output_sub_size * STBIR__horizontal_channels; + float STBIR_SIMD_STREAMOUT_PTR(*) output = output_buffer; + stbir__3_coeff_setup(); + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + float const *decode = + decode_buffer + horizontal_contributors->n0 * STBIR__horizontal_channels; + float const *hc = horizontal_coefficients; + + stbir__4_coeff_start(); + stbir__3_coeff_remnant(4); + stbir__store_output(); + } while (output < output_end); +} + +static void STBIR_chans(stbir__horizontal_gather_, + _channels_with_8_coeffs)(float *output_buffer, unsigned int output_sub_size, + float const *decode_buffer, + stbir__contributors const *horizontal_contributors, + float const *horizontal_coefficients, + int coefficient_width) { + float const *output_end = output_buffer + output_sub_size * STBIR__horizontal_channels; + float STBIR_SIMD_STREAMOUT_PTR(*) output = output_buffer; + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + float const *decode = + decode_buffer + horizontal_contributors->n0 * STBIR__horizontal_channels; + float const *hc = horizontal_coefficients; + stbir__4_coeff_start(); + stbir__4_coeff_continue_from_4(4); + stbir__store_output(); + } while (output < output_end); +} + +static void STBIR_chans(stbir__horizontal_gather_, + _channels_with_9_coeffs)(float *output_buffer, unsigned int output_sub_size, + float const *decode_buffer, + stbir__contributors const *horizontal_contributors, + float const *horizontal_coefficients, + int coefficient_width) { + float const *output_end = output_buffer + output_sub_size * STBIR__horizontal_channels; + float STBIR_SIMD_STREAMOUT_PTR(*) output = output_buffer; + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + float const *decode = + decode_buffer + horizontal_contributors->n0 * STBIR__horizontal_channels; + float const *hc = horizontal_coefficients; + stbir__4_coeff_start(); + stbir__4_coeff_continue_from_4(4); + stbir__1_coeff_remnant(8); + stbir__store_output(); + } while (output < output_end); +} + +static void STBIR_chans(stbir__horizontal_gather_, _channels_with_10_coeffs)( + float *output_buffer, unsigned int output_sub_size, float const *decode_buffer, + stbir__contributors const *horizontal_contributors, float const *horizontal_coefficients, + int coefficient_width) { + float const *output_end = output_buffer + output_sub_size * STBIR__horizontal_channels; + float STBIR_SIMD_STREAMOUT_PTR(*) output = output_buffer; + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + float const *decode = + decode_buffer + horizontal_contributors->n0 * STBIR__horizontal_channels; + float const *hc = horizontal_coefficients; + stbir__4_coeff_start(); + stbir__4_coeff_continue_from_4(4); + stbir__2_coeff_remnant(8); + stbir__store_output(); + } while (output < output_end); +} + +static void STBIR_chans(stbir__horizontal_gather_, _channels_with_11_coeffs)( + float *output_buffer, unsigned int output_sub_size, float const *decode_buffer, + stbir__contributors const *horizontal_contributors, float const *horizontal_coefficients, + int coefficient_width) { + float const *output_end = output_buffer + output_sub_size * STBIR__horizontal_channels; + float STBIR_SIMD_STREAMOUT_PTR(*) output = output_buffer; + stbir__3_coeff_setup(); + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + float const *decode = + decode_buffer + horizontal_contributors->n0 * STBIR__horizontal_channels; + float const *hc = horizontal_coefficients; + stbir__4_coeff_start(); + stbir__4_coeff_continue_from_4(4); + stbir__3_coeff_remnant(8); + stbir__store_output(); + } while (output < output_end); +} + +static void STBIR_chans(stbir__horizontal_gather_, _channels_with_12_coeffs)( + float *output_buffer, unsigned int output_sub_size, float const *decode_buffer, + stbir__contributors const *horizontal_contributors, float const *horizontal_coefficients, + int coefficient_width) { + float const *output_end = output_buffer + output_sub_size * STBIR__horizontal_channels; + float STBIR_SIMD_STREAMOUT_PTR(*) output = output_buffer; + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + float const *decode = + decode_buffer + horizontal_contributors->n0 * STBIR__horizontal_channels; + float const *hc = horizontal_coefficients; + stbir__4_coeff_start(); + stbir__4_coeff_continue_from_4(4); + stbir__4_coeff_continue_from_4(8); + stbir__store_output(); + } while (output < output_end); +} + +static void STBIR_chans(stbir__horizontal_gather_, _channels_with_n_coeffs_mod0)( + float *output_buffer, unsigned int output_sub_size, float const *decode_buffer, + stbir__contributors const *horizontal_contributors, float const *horizontal_coefficients, + int coefficient_width) { + float const *output_end = output_buffer + output_sub_size * STBIR__horizontal_channels; + float STBIR_SIMD_STREAMOUT_PTR(*) output = output_buffer; + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + float const *decode = + decode_buffer + horizontal_contributors->n0 * STBIR__horizontal_channels; + int n = ((horizontal_contributors->n1 - horizontal_contributors->n0 + 1) - 4 + 3) >> 2; + float const *hc = horizontal_coefficients; + + stbir__4_coeff_start(); + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + hc += 4; + decode += STBIR__horizontal_channels * 4; + stbir__4_coeff_continue_from_4(0); + --n; + } while (n > 0); + stbir__store_output(); + } while (output < output_end); +} + +static void STBIR_chans(stbir__horizontal_gather_, _channels_with_n_coeffs_mod1)( + float *output_buffer, unsigned int output_sub_size, float const *decode_buffer, + stbir__contributors const *horizontal_contributors, float const *horizontal_coefficients, + int coefficient_width) { + float const *output_end = output_buffer + output_sub_size * STBIR__horizontal_channels; + float STBIR_SIMD_STREAMOUT_PTR(*) output = output_buffer; + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + float const *decode = + decode_buffer + horizontal_contributors->n0 * STBIR__horizontal_channels; + int n = ((horizontal_contributors->n1 - horizontal_contributors->n0 + 1) - 5 + 3) >> 2; + float const *hc = horizontal_coefficients; + + stbir__4_coeff_start(); + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + hc += 4; + decode += STBIR__horizontal_channels * 4; + stbir__4_coeff_continue_from_4(0); + --n; + } while (n > 0); + stbir__1_coeff_remnant(4); + stbir__store_output(); + } while (output < output_end); +} + +static void STBIR_chans(stbir__horizontal_gather_, _channels_with_n_coeffs_mod2)( + float *output_buffer, unsigned int output_sub_size, float const *decode_buffer, + stbir__contributors const *horizontal_contributors, float const *horizontal_coefficients, + int coefficient_width) { + float const *output_end = output_buffer + output_sub_size * STBIR__horizontal_channels; + float STBIR_SIMD_STREAMOUT_PTR(*) output = output_buffer; + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + float const *decode = + decode_buffer + horizontal_contributors->n0 * STBIR__horizontal_channels; + int n = ((horizontal_contributors->n1 - horizontal_contributors->n0 + 1) - 6 + 3) >> 2; + float const *hc = horizontal_coefficients; + + stbir__4_coeff_start(); + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + hc += 4; + decode += STBIR__horizontal_channels * 4; + stbir__4_coeff_continue_from_4(0); + --n; + } while (n > 0); + stbir__2_coeff_remnant(4); + + stbir__store_output(); + } while (output < output_end); +} + +static void STBIR_chans(stbir__horizontal_gather_, _channels_with_n_coeffs_mod3)( + float *output_buffer, unsigned int output_sub_size, float const *decode_buffer, + stbir__contributors const *horizontal_contributors, float const *horizontal_coefficients, + int coefficient_width) { + float const *output_end = output_buffer + output_sub_size * STBIR__horizontal_channels; + float STBIR_SIMD_STREAMOUT_PTR(*) output = output_buffer; + stbir__3_coeff_setup(); + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + float const *decode = + decode_buffer + horizontal_contributors->n0 * STBIR__horizontal_channels; + int n = ((horizontal_contributors->n1 - horizontal_contributors->n0 + 1) - 7 + 3) >> 2; + float const *hc = horizontal_coefficients; + + stbir__4_coeff_start(); + STBIR_SIMD_NO_UNROLL_LOOP_START + do { + hc += 4; + decode += STBIR__horizontal_channels * 4; + stbir__4_coeff_continue_from_4(0); + --n; + } while (n > 0); + stbir__3_coeff_remnant(4); + + stbir__store_output(); + } while (output < output_end); +} + +static stbir__horizontal_gather_channels_func *STBIR_chans(stbir__horizontal_gather_, + _channels_with_n_coeffs_funcs)[4] = { + STBIR_chans(stbir__horizontal_gather_, _channels_with_n_coeffs_mod0), + STBIR_chans(stbir__horizontal_gather_, _channels_with_n_coeffs_mod1), + STBIR_chans(stbir__horizontal_gather_, _channels_with_n_coeffs_mod2), + STBIR_chans(stbir__horizontal_gather_, _channels_with_n_coeffs_mod3), +}; + +static stbir__horizontal_gather_channels_func *STBIR_chans(stbir__horizontal_gather_, + _channels_funcs)[12] = { + STBIR_chans(stbir__horizontal_gather_, _channels_with_1_coeff), + STBIR_chans(stbir__horizontal_gather_, _channels_with_2_coeffs), + STBIR_chans(stbir__horizontal_gather_, _channels_with_3_coeffs), + STBIR_chans(stbir__horizontal_gather_, _channels_with_4_coeffs), + STBIR_chans(stbir__horizontal_gather_, _channels_with_5_coeffs), + STBIR_chans(stbir__horizontal_gather_, _channels_with_6_coeffs), + STBIR_chans(stbir__horizontal_gather_, _channels_with_7_coeffs), + STBIR_chans(stbir__horizontal_gather_, _channels_with_8_coeffs), + STBIR_chans(stbir__horizontal_gather_, _channels_with_9_coeffs), + STBIR_chans(stbir__horizontal_gather_, _channels_with_10_coeffs), + STBIR_chans(stbir__horizontal_gather_, _channels_with_11_coeffs), + STBIR_chans(stbir__horizontal_gather_, _channels_with_12_coeffs), +}; + +#undef STBIR__horizontal_channels +#undef STB_IMAGE_RESIZE_DO_HORIZONTALS +#undef stbir__1_coeff_only +#undef stbir__1_coeff_remnant +#undef stbir__2_coeff_only +#undef stbir__2_coeff_remnant +#undef stbir__3_coeff_only +#undef stbir__3_coeff_remnant +#undef stbir__3_coeff_setup +#undef stbir__4_coeff_start +#undef stbir__4_coeff_continue_from_4 +#undef stbir__store_output +#undef stbir__store_output_tiny +#undef STBIR_chans + +#endif // HORIZONALS + +#undef STBIR_strs_join2 +#undef STBIR_strs_join1 + +#endif // STB_IMAGE_RESIZE_DO_HORIZONTALS/VERTICALS/CODERS + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ +*/ \ No newline at end of file diff --git a/lib/stb/stb_image_write.h b/lib/stb/stb_image_write.h new file mode 100644 index 00000000..f9d7865e --- /dev/null +++ b/lib/stb/stb_image_write.h @@ -0,0 +1,2398 @@ +/* stb_image_write - v1.16 - public domain - http://nothings.org/stb + writes out PNG/BMP/TGA/JPEG/HDR images to C stdio - Sean Barrett 2010-2015 + no warranty implied; use at your own risk + + Before #including, + + #define STB_IMAGE_WRITE_IMPLEMENTATION + + in the file that you want to have the implementation. + + Will probably not work correctly with strict-aliasing optimizations. + +ABOUT: + + This header file is a library for writing images to C stdio or a callback. + + The PNG output is not optimal; it is 20-50% larger than the file + written by a decent optimizing implementation; though providing a custom + zlib compress function (see STBIW_ZLIB_COMPRESS) can mitigate that. + This library is designed for source code compactness and simplicity, + not optimal image file size or run-time performance. + +BUILDING: + + You can #define STBIW_ASSERT(x) before the #include to avoid using assert.h. + You can #define STBIW_MALLOC(), STBIW_REALLOC(), and STBIW_FREE() to replace + malloc,realloc,free. + You can #define STBIW_MEMMOVE() to replace memmove() + You can #define STBIW_ZLIB_COMPRESS to use a custom zlib-style compress function + for PNG compression (instead of the builtin one), it must have the following signature: + unsigned char * my_compress(unsigned char *data, int data_len, int *out_len, int quality); + The returned data will be freed with STBIW_FREE() (free() by default), + so it must be heap allocated with STBIW_MALLOC() (malloc() by default), + +UNICODE: + + If compiling for Windows and you wish to use Unicode filenames, compile + with + #define STBIW_WINDOWS_UTF8 + and pass utf8-encoded filenames. Call stbiw_convert_wchar_to_utf8 to convert + Windows wchar_t filenames to utf8. + +USAGE: + + There are five functions, one for each image file format: + + int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int +stride_in_bytes); int stbi_write_bmp(char const *filename, int w, int h, int comp, const void +*data); int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); int +stbi_write_jpg(char const *filename, int w, int h, int comp, const void *data, int quality); int +stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); + + void stbi_flip_vertically_on_write(int flag); // flag is non-zero to flip data vertically + + There are also five equivalent functions that use an arbitrary write function. You are + expected to open/close your file-equivalent before and after calling these: + + int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const +void *data, int stride_in_bytes); int stbi_write_bmp_to_func(stbi_write_func *func, void *context, +int w, int h, int comp, const void *data); int stbi_write_tga_to_func(stbi_write_func *func, void +*context, int w, int h, int comp, const void *data); int stbi_write_hdr_to_func(stbi_write_func +*func, void *context, int w, int h, int comp, const float *data); int +stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void +*data, int quality); + + where the callback is: + void stbi_write_func(void *context, void *data, int size); + + You can configure it with these global variables: + int stbi_write_tga_with_rle; // defaults to true; set to 0 to disable RLE + int stbi_write_png_compression_level; // defaults to 8; set to higher for more compression + int stbi_write_force_png_filter; // defaults to -1; set to 0..5 to force a filter mode + + + You can define STBI_WRITE_NO_STDIO to disable the file variant of these + functions, so the library will not use stdio.h at all. However, this will + also disable HDR writing, because it requires stdio for formatted output. + + Each function returns 0 on failure and non-0 on success. + + The functions create an image file defined by the parameters. The image + is a rectangle of pixels stored from left-to-right, top-to-bottom. + Each pixel contains 'comp' channels of data stored interleaved with 8-bits + per channel, in the following order: 1=Y, 2=YA, 3=RGB, 4=RGBA. (Y is + monochrome color.) The rectangle is 'w' pixels wide and 'h' pixels tall. + The *data pointer points to the first byte of the top-left-most pixel. + For PNG, "stride_in_bytes" is the distance in bytes from the first byte of + a row of pixels to the first byte of the next row of pixels. + + PNG creates output files with the same number of components as the input. + The BMP format expands Y to RGB in the file format and does not + output alpha. + + PNG supports writing rectangles of data even when the bytes storing rows of + data are not consecutive in memory (e.g. sub-rectangles of a larger image), + by supplying the stride between the beginning of adjacent rows. The other + formats do not. (Thus you cannot write a native-format BMP through the BMP + writer, both because it is in BGR order and because it may have padding + at the end of the line.) + + PNG allows you to set the deflate compression level by setting the global + variable 'stbi_write_png_compression_level' (it defaults to 8). + + HDR expects linear float data. Since the format is always 32-bit rgb(e) + data, alpha (if provided) is discarded, and for monochrome data it is + replicated across all three channels. + + TGA supports RLE or non-RLE compressed data. To use non-RLE-compressed + data, set the global variable 'stbi_write_tga_with_rle' to 0. + + JPEG does ignore alpha channels in input data; quality is between 1 and 100. + Higher quality looks better but results in a bigger image. + JPEG baseline (no JPEG progressive). + +CREDITS: + + + Sean Barrett - PNG/BMP/TGA + Baldur Karlsson - HDR + Jean-Sebastien Guay - TGA monochrome + Tim Kelsey - misc enhancements + Alan Hickman - TGA RLE + Emmanuel Julien - initial file IO callback implementation + Jon Olick - original jo_jpeg.cpp code + Daniel Gibson - integrate JPEG, allow external zlib + Aarni Koskela - allow choosing PNG filter + + bugfixes: + github:Chribba + Guillaume Chereau + github:jry2 + github:romigrou + Sergio Gonzalez + Jonas Karlsson + Filip Wasil + Thatcher Ulrich + github:poppolopoppo + Patrick Boettcher + github:xeekworx + Cap Petschulat + Simon Rodriguez + Ivan Tikhonov + github:ignotion + Adam Schackart + Andrew Kensler + +LICENSE + + See end of file for license information. + +*/ + +#ifndef INCLUDE_STB_IMAGE_WRITE_H +#define INCLUDE_STB_IMAGE_WRITE_H + +#include + +// if STB_IMAGE_WRITE_STATIC causes problems, try defining STBIWDEF to 'inline' or 'static inline' +#ifndef STBIWDEF +#ifdef STB_IMAGE_WRITE_STATIC +#define STBIWDEF static +#else +#ifdef __cplusplus +#define STBIWDEF extern "C" +#else +#define STBIWDEF extern +#endif +#endif +#endif + +#ifndef STB_IMAGE_WRITE_STATIC // C++ forbids static forward declarations +STBIWDEF int stbi_write_tga_with_rle; +STBIWDEF int stbi_write_png_compression_level; +STBIWDEF int stbi_write_force_png_filter; +#endif + +#ifndef STBI_WRITE_NO_STDIO +STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, + int stride_in_bytes); +STBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); +STBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); +STBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); +STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, + int quality); + +#ifdef STBIW_WINDOWS_UTF8 +STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t *input); +#endif +#endif + +typedef void stbi_write_func(void *context, void *data, int size); + +STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, + const void *data, int stride_in_bytes); +STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, + const void *data); +STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, + const void *data); +STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, + const float *data); +STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, + const void *data, int quality); + +STBIWDEF void stbi_flip_vertically_on_write(int flip_boolean); + +#endif // INCLUDE_STB_IMAGE_WRITE_H + +#ifdef STB_IMAGE_WRITE_IMPLEMENTATION + +#ifdef _WIN32 +#ifndef _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_WARNINGS +#endif +#ifndef _CRT_NONSTDC_NO_DEPRECATE +#define _CRT_NONSTDC_NO_DEPRECATE +#endif +#endif + +#ifndef STBI_WRITE_NO_STDIO +#include +#endif // STBI_WRITE_NO_STDIO + +#include +#include +#include +#include + +#if defined(STBIW_MALLOC) && defined(STBIW_FREE) && \ + (defined(STBIW_REALLOC) || defined(STBIW_REALLOC_SIZED)) +// ok +#elif !defined(STBIW_MALLOC) && !defined(STBIW_FREE) && !defined(STBIW_REALLOC) && \ + !defined(STBIW_REALLOC_SIZED) +// ok +#else +#error \ + "Must define all or none of STBIW_MALLOC, STBIW_FREE, and STBIW_REALLOC (or STBIW_REALLOC_SIZED)." +#endif + +#ifndef STBIW_MALLOC +#define STBIW_MALLOC(sz) malloc(sz) +#define STBIW_REALLOC(p, newsz) realloc(p, newsz) +#define STBIW_FREE(p) free(p) +#endif + +#ifndef STBIW_REALLOC_SIZED +#define STBIW_REALLOC_SIZED(p, oldsz, newsz) STBIW_REALLOC(p, newsz) +#endif + +#ifndef STBIW_MEMMOVE +#define STBIW_MEMMOVE(a, b, sz) memmove(a, b, sz) +#endif + +#ifndef STBIW_ASSERT +#include +#define STBIW_ASSERT(x) assert(x) +#endif + +#define STBIW_UCHAR(x) (unsigned char)((x) & 0xff) + +#ifdef STB_IMAGE_WRITE_STATIC +static int stbi_write_png_compression_level = 8; +static int stbi_write_tga_with_rle = 1; +static int stbi_write_force_png_filter = -1; +#else +int stbi_write_png_compression_level = 8; +int stbi_write_tga_with_rle = 1; +int stbi_write_force_png_filter = -1; +#endif + +static int stbi__flip_vertically_on_write = 0; + +STBIWDEF void stbi_flip_vertically_on_write(int flag) { stbi__flip_vertically_on_write = flag; } + +typedef struct { + stbi_write_func *func; + void *context; + unsigned char buffer[64]; + int buf_used; +} stbi__write_context; + +// initialize a callback-based context +static void stbi__start_write_callbacks(stbi__write_context *s, stbi_write_func *c, void *context) { + s->func = c; + s->context = context; +} + +#ifndef STBI_WRITE_NO_STDIO + +static void stbi__stdio_write(void *context, void *data, int size) { + fwrite(data, 1, size, (FILE *)context); +} + +#if defined(_WIN32) && defined(STBIW_WINDOWS_UTF8) +#ifdef __cplusplus +#define STBIW_EXTERN extern "C" +#else +#define STBIW_EXTERN extern +#endif +STBIW_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, + unsigned long flags, + const char *str, int cbmb, + wchar_t *widestr, int cchwide); +STBIW_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte( + unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, + const char *defchar, int *used_default); + +STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t *input) { + return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int)bufferlen, NULL, NULL); +} +#endif + +static FILE *stbiw__fopen(char const *filename, char const *mode) { + FILE *f; +#if defined(_WIN32) && defined(STBIW_WINDOWS_UTF8) + wchar_t wMode[64]; + wchar_t wFilename[1024]; + if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, + sizeof(wFilename) / sizeof(*wFilename))) + return 0; + + if (0 == + MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode) / sizeof(*wMode))) + return 0; + +#if defined(_MSC_VER) && _MSC_VER >= 1400 + if (0 != _wfopen_s(&f, wFilename, wMode)) + f = 0; +#else + f = _wfopen(wFilename, wMode); +#endif + +#elif defined(_MSC_VER) && _MSC_VER >= 1400 + if (0 != fopen_s(&f, filename, mode)) + f = 0; +#else + f = fopen(filename, mode); +#endif + return f; +} + +static int stbi__start_write_file(stbi__write_context *s, const char *filename) { + FILE *f = stbiw__fopen(filename, "wb"); + stbi__start_write_callbacks(s, stbi__stdio_write, (void *)f); + return f != NULL; +} + +static void stbi__end_write_file(stbi__write_context *s) { fclose((FILE *)s->context); } + +#endif // !STBI_WRITE_NO_STDIO + +typedef unsigned int stbiw_uint32; +typedef int stb_image_write_test[sizeof(stbiw_uint32) == 4 ? 1 : -1]; + +static void stbiw__writefv(stbi__write_context *s, const char *fmt, va_list v) { + while (*fmt) { + switch (*fmt++) { + case ' ': + break; + case '1': { + unsigned char x = STBIW_UCHAR(va_arg(v, int)); + s->func(s->context, &x, 1); + break; + } + case '2': { + int x = va_arg(v, int); + unsigned char b[2]; + b[0] = STBIW_UCHAR(x); + b[1] = STBIW_UCHAR(x >> 8); + s->func(s->context, b, 2); + break; + } + case '4': { + stbiw_uint32 x = va_arg(v, int); + unsigned char b[4]; + b[0] = STBIW_UCHAR(x); + b[1] = STBIW_UCHAR(x >> 8); + b[2] = STBIW_UCHAR(x >> 16); + b[3] = STBIW_UCHAR(x >> 24); + s->func(s->context, b, 4); + break; + } + default: + STBIW_ASSERT(0); + return; + } + } +} + +static void stbiw__writef(stbi__write_context *s, const char *fmt, ...) { + va_list v; + va_start(v, fmt); + stbiw__writefv(s, fmt, v); + va_end(v); +} + +static void stbiw__write_flush(stbi__write_context *s) { + if (s->buf_used) { + s->func(s->context, &s->buffer, s->buf_used); + s->buf_used = 0; + } +} + +static void stbiw__putc(stbi__write_context *s, unsigned char c) { s->func(s->context, &c, 1); } + +static void stbiw__write1(stbi__write_context *s, unsigned char a) { + if ((size_t)s->buf_used + 1 > sizeof(s->buffer)) + stbiw__write_flush(s); + s->buffer[s->buf_used++] = a; +} + +static void stbiw__write3(stbi__write_context *s, unsigned char a, unsigned char b, + unsigned char c) { + int n; + if ((size_t)s->buf_used + 3 > sizeof(s->buffer)) + stbiw__write_flush(s); + n = s->buf_used; + s->buf_used = n + 3; + s->buffer[n + 0] = a; + s->buffer[n + 1] = b; + s->buffer[n + 2] = c; +} + +static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, + int expand_mono, unsigned char *d) { + unsigned char bg[3] = {255, 0, 255}, px[3]; + int k; + + if (write_alpha < 0) + stbiw__write1(s, d[comp - 1]); + + switch (comp) { + case 2: // 2 pixels = mono + alpha, alpha is written separately, so same as 1-channel case + case 1: + if (expand_mono) + stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp + else + stbiw__write1(s, d[0]); // monochrome TGA + break; + case 4: + if (!write_alpha) { + // composite against pink background + for (k = 0; k < 3; ++k) + px[k] = bg[k] + ((d[k] - bg[k]) * d[3]) / 255; + stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]); + break; + } + /* FALLTHROUGH */ + case 3: + stbiw__write3(s, d[1 - rgb_dir], d[1], d[1 + rgb_dir]); + break; + } + if (write_alpha > 0) + stbiw__write1(s, d[comp - 1]); +} + +static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, + int comp, void *data, int write_alpha, int scanline_pad, + int expand_mono) { + stbiw_uint32 zero = 0; + int i, j, j_end; + + if (y <= 0) + return; + + if (stbi__flip_vertically_on_write) + vdir *= -1; + + if (vdir < 0) { + j_end = -1; + j = y - 1; + } else { + j_end = y; + j = 0; + } + + for (; j != j_end; j += vdir) { + for (i = 0; i < x; ++i) { + unsigned char *d = (unsigned char *)data + (j * x + i) * comp; + stbiw__write_pixel(s, rgb_dir, comp, write_alpha, expand_mono, d); + } + stbiw__write_flush(s); + s->func(s->context, &zero, scanline_pad); + } +} + +static int stbiw__outfile(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, + int expand_mono, void *data, int alpha, int pad, const char *fmt, ...) { + if (y < 0 || x < 0) { + return 0; + } else { + va_list v; + va_start(v, fmt); + stbiw__writefv(s, fmt, v); + va_end(v); + stbiw__write_pixels(s, rgb_dir, vdir, x, y, comp, data, alpha, pad, expand_mono); + return 1; + } +} + +static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data) { + if (comp != 4) { + // write RGB bitmap + int pad = (-x * 3) & 3; + return stbiw__outfile(s, -1, -1, x, y, comp, 1, (void *)data, 0, pad, + "11 4 22 4" + "4 44 22 444444", + 'B', 'M', 14 + 40 + (x * 3 + pad) * y, 0, 0, 14 + 40, // file header + 40, x, y, 1, 24, 0, 0, 0, 0, 0, 0); // bitmap header + } else { + // RGBA bitmaps need a v4 header + // use BI_BITFIELDS mode with 32bpp and alpha mask + // (straight BI_RGB with alpha mask doesn't work in most readers) + return stbiw__outfile(s, -1, -1, x, y, comp, 1, (void *)data, 1, 0, + "11 4 22 4" + "4 44 22 444444 4444 4 444 444 444 444", + 'B', 'M', 14 + 108 + x * y * 4, 0, 0, 14 + 108, // file header + 108, x, y, 1, 32, 3, 0, 0, 0, 0, 0, 0xff0000, 0xff00, 0xff, + 0xff000000u, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0); // bitmap V4 header + } +} + +STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, + const void *data) { + stbi__write_context s = {0}; + stbi__start_write_callbacks(&s, func, context); + return stbi_write_bmp_core(&s, x, y, comp, data); +} + +#ifndef STBI_WRITE_NO_STDIO +STBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data) { + stbi__write_context s = {0}; + if (stbi__start_write_file(&s, filename)) { + int r = stbi_write_bmp_core(&s, x, y, comp, data); + stbi__end_write_file(&s); + return r; + } else + return 0; +} +#endif //! STBI_WRITE_NO_STDIO + +static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, void *data) { + int has_alpha = (comp == 2 || comp == 4); + int colorbytes = has_alpha ? comp - 1 : comp; + int format = colorbytes < 2 ? 3 + : 2; // 3 color channels (RGB/RGBA) = 2, 1 color channel (Y/YA) = 3 + + if (y < 0 || x < 0) + return 0; + + if (!stbi_write_tga_with_rle) { + return stbiw__outfile(s, -1, -1, x, y, comp, 0, (void *)data, has_alpha, 0, + "111 221 2222 11", 0, 0, format, 0, 0, 0, 0, 0, x, y, + (colorbytes + has_alpha) * 8, has_alpha * 8); + } else { + int i, j, k; + int jend, jdir; + + stbiw__writef(s, "111 221 2222 11", 0, 0, format + 8, 0, 0, 0, 0, 0, x, y, + (colorbytes + has_alpha) * 8, has_alpha * 8); + + if (stbi__flip_vertically_on_write) { + j = 0; + jend = y; + jdir = 1; + } else { + j = y - 1; + jend = -1; + jdir = -1; + } + for (; j != jend; j += jdir) { + unsigned char *row = (unsigned char *)data + j * x * comp; + int len; + + for (i = 0; i < x; i += len) { + unsigned char *begin = row + i * comp; + int diff = 1; + len = 1; + + if (i < x - 1) { + ++len; + diff = memcmp(begin, row + (i + 1) * comp, comp); + if (diff) { + const unsigned char *prev = begin; + for (k = i + 2; k < x && len < 128; ++k) { + if (memcmp(prev, row + k * comp, comp)) { + prev += comp; + ++len; + } else { + --len; + break; + } + } + } else { + for (k = i + 2; k < x && len < 128; ++k) { + if (!memcmp(begin, row + k * comp, comp)) { + ++len; + } else { + break; + } + } + } + } + + if (diff) { + unsigned char header = STBIW_UCHAR(len - 1); + stbiw__write1(s, header); + for (k = 0; k < len; ++k) { + stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin + k * comp); + } + } else { + unsigned char header = STBIW_UCHAR(len - 129); + stbiw__write1(s, header); + stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin); + } + } + } + stbiw__write_flush(s); + } + return 1; +} + +STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, int y, int comp, + const void *data) { + stbi__write_context s = {0}; + stbi__start_write_callbacks(&s, func, context); + return stbi_write_tga_core(&s, x, y, comp, (void *)data); +} + +#ifndef STBI_WRITE_NO_STDIO +STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data) { + stbi__write_context s = {0}; + if (stbi__start_write_file(&s, filename)) { + int r = stbi_write_tga_core(&s, x, y, comp, (void *)data); + stbi__end_write_file(&s); + return r; + } else + return 0; +} +#endif + +// ************************************************************************************************* +// Radiance RGBE HDR writer +// by Baldur Karlsson + +#define stbiw__max(a, b) ((a) > (b) ? (a) : (b)) + +#ifndef STBI_WRITE_NO_STDIO + +static void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear) { + int exponent; + float maxcomp = stbiw__max(linear[0], stbiw__max(linear[1], linear[2])); + + if (maxcomp < 1e-32f) { + rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0; + } else { + float normalize = (float)frexp(maxcomp, &exponent) * 256.0f / maxcomp; + + rgbe[0] = (unsigned char)(linear[0] * normalize); + rgbe[1] = (unsigned char)(linear[1] * normalize); + rgbe[2] = (unsigned char)(linear[2] * normalize); + rgbe[3] = (unsigned char)(exponent + 128); + } +} + +static void stbiw__write_run_data(stbi__write_context *s, int length, unsigned char databyte) { + unsigned char lengthbyte = STBIW_UCHAR(length + 128); + STBIW_ASSERT(length + 128 <= 255); + s->func(s->context, &lengthbyte, 1); + s->func(s->context, &databyte, 1); +} + +static void stbiw__write_dump_data(stbi__write_context *s, int length, unsigned char *data) { + unsigned char lengthbyte = STBIW_UCHAR(length); + STBIW_ASSERT(length <= 128); // inconsistent with spec but consistent with official code + s->func(s->context, &lengthbyte, 1); + s->func(s->context, data, length); +} + +static void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, + unsigned char *scratch, float *scanline) { + unsigned char scanlineheader[4] = {2, 2, 0, 0}; + unsigned char rgbe[4]; + float linear[3]; + int x; + + scanlineheader[2] = (width & 0xff00) >> 8; + scanlineheader[3] = (width & 0x00ff); + + /* skip RLE for images too small or large */ + if (width < 8 || width >= 32768) { + for (x = 0; x < width; x++) { + switch (ncomp) { + case 4: /* fallthrough */ + case 3: + linear[2] = scanline[x * ncomp + 2]; + linear[1] = scanline[x * ncomp + 1]; + linear[0] = scanline[x * ncomp + 0]; + break; + default: + linear[0] = linear[1] = linear[2] = scanline[x * ncomp + 0]; + break; + } + stbiw__linear_to_rgbe(rgbe, linear); + s->func(s->context, rgbe, 4); + } + } else { + int c, r; + /* encode into scratch buffer */ + for (x = 0; x < width; x++) { + switch (ncomp) { + case 4: /* fallthrough */ + case 3: + linear[2] = scanline[x * ncomp + 2]; + linear[1] = scanline[x * ncomp + 1]; + linear[0] = scanline[x * ncomp + 0]; + break; + default: + linear[0] = linear[1] = linear[2] = scanline[x * ncomp + 0]; + break; + } + stbiw__linear_to_rgbe(rgbe, linear); + scratch[x + width * 0] = rgbe[0]; + scratch[x + width * 1] = rgbe[1]; + scratch[x + width * 2] = rgbe[2]; + scratch[x + width * 3] = rgbe[3]; + } + + s->func(s->context, scanlineheader, 4); + + /* RLE each component separately */ + for (c = 0; c < 4; c++) { + unsigned char *comp = &scratch[width * c]; + + x = 0; + while (x < width) { + // find first run + r = x; + while (r + 2 < width) { + if (comp[r] == comp[r + 1] && comp[r] == comp[r + 2]) + break; + ++r; + } + if (r + 2 >= width) + r = width; + // dump up to first run + while (x < r) { + int len = r - x; + if (len > 128) + len = 128; + stbiw__write_dump_data(s, len, &comp[x]); + x += len; + } + // if there's a run, output it + if (r + 2 < width) { // same test as what we break out of in search loop, so only + // true if we break'd + // find next byte after run + while (r < width && comp[r] == comp[x]) + ++r; + // output run up to r + while (x < r) { + int len = r - x; + if (len > 127) + len = 127; + stbiw__write_run_data(s, len, comp[x]); + x += len; + } + } + } + } + } +} + +static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, float *data) { + if (y <= 0 || x <= 0 || data == NULL) + return 0; + else { + // Each component is stored separately. Allocate scratch space for full output scanline. + unsigned char *scratch = (unsigned char *)STBIW_MALLOC(x * 4); + int i, len; + char buffer[128]; + char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n"; + s->func(s->context, header, sizeof(header) - 1); + +#ifdef __STDC_LIB_EXT1__ + len = sprintf_s(buffer, sizeof(buffer), + "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); +#else + len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); +#endif + s->func(s->context, buffer, len); + + for (i = 0; i < y; i++) + stbiw__write_hdr_scanline(s, x, comp, scratch, + data + comp * x * + (stbi__flip_vertically_on_write ? y - 1 - i : i)); + STBIW_FREE(scratch); + return 1; + } +} + +STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, + const float *data) { + stbi__write_context s = {0}; + stbi__start_write_callbacks(&s, func, context); + return stbi_write_hdr_core(&s, x, y, comp, (float *)data); +} + +STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data) { + stbi__write_context s = {0}; + if (stbi__start_write_file(&s, filename)) { + int r = stbi_write_hdr_core(&s, x, y, comp, (float *)data); + stbi__end_write_file(&s); + return r; + } else + return 0; +} +#endif // STBI_WRITE_NO_STDIO + +////////////////////////////////////////////////////////////////////////////// +// +// PNG writer +// + +#ifndef STBIW_ZLIB_COMPRESS +// stretchy buffer; stbiw__sbpush() == vector<>::push_back() -- stbiw__sbcount() == vector<>::size() +#define stbiw__sbraw(a) ((int *)(void *)(a)-2) +#define stbiw__sbm(a) stbiw__sbraw(a)[0] +#define stbiw__sbn(a) stbiw__sbraw(a)[1] + +#define stbiw__sbneedgrow(a, n) ((a) == 0 || stbiw__sbn(a) + n >= stbiw__sbm(a)) +#define stbiw__sbmaybegrow(a, n) (stbiw__sbneedgrow(a, (n)) ? stbiw__sbgrow(a, n) : 0) +#define stbiw__sbgrow(a, n) stbiw__sbgrowf((void **)&(a), (n), sizeof(*(a))) + +#define stbiw__sbpush(a, v) (stbiw__sbmaybegrow(a, 1), (a)[stbiw__sbn(a)++] = (v)) +#define stbiw__sbcount(a) ((a) ? stbiw__sbn(a) : 0) +#define stbiw__sbfree(a) ((a) ? STBIW_FREE(stbiw__sbraw(a)), 0 : 0) + +static void *stbiw__sbgrowf(void **arr, int increment, int itemsize) { + int m = *arr ? 2 * stbiw__sbm(*arr) + increment : increment + 1; + void *p = STBIW_REALLOC_SIZED(*arr ? stbiw__sbraw(*arr) : 0, + *arr ? (stbiw__sbm(*arr) * itemsize + sizeof(int) * 2) : 0, + itemsize * m + sizeof(int) * 2); + STBIW_ASSERT(p); + if (p) { + if (!*arr) + ((int *)p)[1] = 0; + *arr = (void *)((int *)p + 2); + stbiw__sbm(*arr) = m; + } + return *arr; +} + +static unsigned char *stbiw__zlib_flushf(unsigned char *data, unsigned int *bitbuffer, + int *bitcount) { + while (*bitcount >= 8) { + stbiw__sbpush(data, STBIW_UCHAR(*bitbuffer)); + *bitbuffer >>= 8; + *bitcount -= 8; + } + return data; +} + +static int stbiw__zlib_bitrev(int code, int codebits) { + int res = 0; + while (codebits--) { + res = (res << 1) | (code & 1); + code >>= 1; + } + return res; +} + +static unsigned int stbiw__zlib_countm(unsigned char *a, unsigned char *b, int limit) { + int i; + for (i = 0; i < limit && i < 258; ++i) + if (a[i] != b[i]) + break; + return i; +} + +static unsigned int stbiw__zhash(unsigned char *data) { + stbiw_uint32 hash = data[0] + (data[1] << 8) + (data[2] << 16); + hash ^= hash << 3; + hash += hash >> 5; + hash ^= hash << 4; + hash += hash >> 17; + hash ^= hash << 25; + hash += hash >> 6; + return hash; +} + +#define stbiw__zlib_flush() (out = stbiw__zlib_flushf(out, &bitbuf, &bitcount)) +#define stbiw__zlib_add(code, codebits) \ + (bitbuf |= (code) << bitcount, bitcount += (codebits), stbiw__zlib_flush()) +#define stbiw__zlib_huffa(b, c) stbiw__zlib_add(stbiw__zlib_bitrev(b, c), c) +// default huffman tables +#define stbiw__zlib_huff1(n) stbiw__zlib_huffa(0x30 + (n), 8) +#define stbiw__zlib_huff2(n) stbiw__zlib_huffa(0x190 + (n)-144, 9) +#define stbiw__zlib_huff3(n) stbiw__zlib_huffa(0 + (n)-256, 7) +#define stbiw__zlib_huff4(n) stbiw__zlib_huffa(0xc0 + (n)-280, 8) +#define stbiw__zlib_huff(n) \ + ((n) <= 143 ? stbiw__zlib_huff1(n) \ + : (n) <= 255 ? stbiw__zlib_huff2(n) \ + : (n) <= 279 ? stbiw__zlib_huff3(n) \ + : stbiw__zlib_huff4(n)) +#define stbiw__zlib_huffb(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : stbiw__zlib_huff2(n)) + +#define stbiw__ZHASH 16384 + +#endif // STBIW_ZLIB_COMPRESS + +STBIWDEF unsigned char *stbi_zlib_compress(unsigned char *data, int data_len, int *out_len, + int quality) { +#ifdef STBIW_ZLIB_COMPRESS + // user provided a zlib compress implementation, use that + return STBIW_ZLIB_COMPRESS(data, data_len, out_len, quality); +#else // use builtin + static unsigned short lengthc[] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 13, + 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, + 67, 83, 99, 115, 131, 163, 195, 227, 258, 259}; + static unsigned char lengtheb[] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, + 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0}; + static unsigned short distc[] = {1, 2, 3, 4, 5, 7, 9, 13, + 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, + 4097, 6145, 8193, 12289, 16385, 24577, 32768}; + static unsigned char disteb[] = {0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, + 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13}; + unsigned int bitbuf = 0; + int i, j, bitcount = 0; + unsigned char *out = NULL; + unsigned char ***hash_table = + (unsigned char ***)STBIW_MALLOC(stbiw__ZHASH * sizeof(unsigned char **)); + if (hash_table == NULL) + return NULL; + if (quality < 5) + quality = 5; + + stbiw__sbpush(out, 0x78); // DEFLATE 32K window + stbiw__sbpush(out, 0x5e); // FLEVEL = 1 + stbiw__zlib_add(1, 1); // BFINAL = 1 + stbiw__zlib_add(1, 2); // BTYPE = 1 -- fixed huffman + + for (i = 0; i < stbiw__ZHASH; ++i) + hash_table[i] = NULL; + + i = 0; + while (i < data_len - 3) { + // hash next 3 bytes of data to be compressed + int h = stbiw__zhash(data + i) & (stbiw__ZHASH - 1), best = 3; + unsigned char *bestloc = 0; + unsigned char **hlist = hash_table[h]; + int n = stbiw__sbcount(hlist); + for (j = 0; j < n; ++j) { + if (hlist[j] - data > i - 32768) { // if entry lies within window + int d = stbiw__zlib_countm(hlist[j], data + i, data_len - i); + if (d >= best) { + best = d; + bestloc = hlist[j]; + } + } + } + // when hash table entry is too long, delete half the entries + if (hash_table[h] && stbiw__sbn(hash_table[h]) == 2 * quality) { + STBIW_MEMMOVE(hash_table[h], hash_table[h] + quality, + sizeof(hash_table[h][0]) * quality); + stbiw__sbn(hash_table[h]) = quality; + } + stbiw__sbpush(hash_table[h], data + i); + + if (bestloc) { + // "lazy matching" - check match at *next* byte, and if it's better, do cur byte as + // literal + h = stbiw__zhash(data + i + 1) & (stbiw__ZHASH - 1); + hlist = hash_table[h]; + n = stbiw__sbcount(hlist); + for (j = 0; j < n; ++j) { + if (hlist[j] - data > i - 32767) { + int e = stbiw__zlib_countm(hlist[j], data + i + 1, data_len - i - 1); + if (e > best) { // if next match is better, bail on current match + bestloc = NULL; + break; + } + } + } + } + + if (bestloc) { + int d = (int)(data + i - bestloc); // distance back + STBIW_ASSERT(d <= 32767 && best <= 258); + for (j = 0; best > lengthc[j + 1] - 1; ++j) + ; + stbiw__zlib_huff(j + 257); + if (lengtheb[j]) + stbiw__zlib_add(best - lengthc[j], lengtheb[j]); + for (j = 0; d > distc[j + 1] - 1; ++j) + ; + stbiw__zlib_add(stbiw__zlib_bitrev(j, 5), 5); + if (disteb[j]) + stbiw__zlib_add(d - distc[j], disteb[j]); + i += best; + } else { + stbiw__zlib_huffb(data[i]); + ++i; + } + } + // write out final bytes + for (; i < data_len; ++i) + stbiw__zlib_huffb(data[i]); + stbiw__zlib_huff(256); // end of block + // pad with 0 bits to byte boundary + while (bitcount) + stbiw__zlib_add(0, 1); + + for (i = 0; i < stbiw__ZHASH; ++i) + (void)stbiw__sbfree(hash_table[i]); + STBIW_FREE(hash_table); + + // store uncompressed instead if compression was worse + if (stbiw__sbn(out) > data_len + 2 + ((data_len + 32766) / 32767) * 5) { + stbiw__sbn(out) = 2; // truncate to DEFLATE 32K window and FLEVEL = 1 + for (j = 0; j < data_len;) { + int blocklen = data_len - j; + if (blocklen > 32767) + blocklen = 32767; + stbiw__sbpush(out, + data_len - j == blocklen); // BFINAL = ?, BTYPE = 0 -- no compression + stbiw__sbpush(out, STBIW_UCHAR(blocklen)); // LEN + stbiw__sbpush(out, STBIW_UCHAR(blocklen >> 8)); + stbiw__sbpush(out, STBIW_UCHAR(~blocklen)); // NLEN + stbiw__sbpush(out, STBIW_UCHAR(~blocklen >> 8)); + memcpy(out + stbiw__sbn(out), data + j, blocklen); + stbiw__sbn(out) += blocklen; + j += blocklen; + } + } + + { + // compute adler32 on input + unsigned int s1 = 1, s2 = 0; + int blocklen = (int)(data_len % 5552); + j = 0; + while (j < data_len) { + for (i = 0; i < blocklen; ++i) { + s1 += data[j + i]; + s2 += s1; + } + s1 %= 65521; + s2 %= 65521; + j += blocklen; + blocklen = 5552; + } + stbiw__sbpush(out, STBIW_UCHAR(s2 >> 8)); + stbiw__sbpush(out, STBIW_UCHAR(s2)); + stbiw__sbpush(out, STBIW_UCHAR(s1 >> 8)); + stbiw__sbpush(out, STBIW_UCHAR(s1)); + } + *out_len = stbiw__sbn(out); + // make returned pointer freeable + STBIW_MEMMOVE(stbiw__sbraw(out), out, *out_len); + return (unsigned char *)stbiw__sbraw(out); +#endif // STBIW_ZLIB_COMPRESS +} + +static unsigned int stbiw__crc32(unsigned char *buffer, int len) { +#ifdef STBIW_CRC32 + return STBIW_CRC32(buffer, len); +#else + static unsigned int crc_table[256] = { + 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, + 0x9E6495A3, 0x0eDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, + 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, + 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, + 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, + 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, + 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, + 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, + 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, + 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, + 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, + 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, + 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, + 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, + 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, + 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, + 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, + 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, + 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, + 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, + 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, + 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, + 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, + 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, + 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, + 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, + 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, + 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, + 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, + 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, + 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, + 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, + 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, + 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, + 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, + 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D}; + + unsigned int crc = ~0u; + int i; + for (i = 0; i < len; ++i) + crc = (crc >> 8) ^ crc_table[buffer[i] ^ (crc & 0xff)]; + return ~crc; +#endif +} + +#define stbiw__wpng4(o, a, b, c, d) \ + ((o)[0] = STBIW_UCHAR(a), (o)[1] = STBIW_UCHAR(b), (o)[2] = STBIW_UCHAR(c), \ + (o)[3] = STBIW_UCHAR(d), (o) += 4) +#define stbiw__wp32(data, v) stbiw__wpng4(data, (v) >> 24, (v) >> 16, (v) >> 8, (v)); +#define stbiw__wptag(data, s) stbiw__wpng4(data, s[0], s[1], s[2], s[3]) + +static void stbiw__wpcrc(unsigned char **data, int len) { + unsigned int crc = stbiw__crc32(*data - len - 4, len + 4); + stbiw__wp32(*data, crc); +} + +static unsigned char stbiw__paeth(int a, int b, int c) { + int p = a + b - c, pa = abs(p - a), pb = abs(p - b), pc = abs(p - c); + if (pa <= pb && pa <= pc) + return STBIW_UCHAR(a); + if (pb <= pc) + return STBIW_UCHAR(b); + return STBIW_UCHAR(c); +} + +// @OPTIMIZE: provide an option that always forces left-predict or paeth predict +static void stbiw__encode_png_line(unsigned char *pixels, int stride_bytes, int width, int height, + int y, int n, int filter_type, signed char *line_buffer) { + static int mapping[] = {0, 1, 2, 3, 4}; + static int firstmap[] = {0, 1, 0, 5, 6}; + int *mymap = (y != 0) ? mapping : firstmap; + int i; + int type = mymap[filter_type]; + unsigned char *z = + pixels + stride_bytes * (stbi__flip_vertically_on_write ? height - 1 - y : y); + int signed_stride = stbi__flip_vertically_on_write ? -stride_bytes : stride_bytes; + + if (type == 0) { + memcpy(line_buffer, z, width * n); + return; + } + + // first loop isn't optimized since it's just one pixel + for (i = 0; i < n; ++i) { + switch (type) { + case 1: + line_buffer[i] = z[i]; + break; + case 2: + line_buffer[i] = z[i] - z[i - signed_stride]; + break; + case 3: + line_buffer[i] = z[i] - (z[i - signed_stride] >> 1); + break; + case 4: + line_buffer[i] = (signed char)(z[i] - stbiw__paeth(0, z[i - signed_stride], 0)); + break; + case 5: + line_buffer[i] = z[i]; + break; + case 6: + line_buffer[i] = z[i]; + break; + } + } + switch (type) { + case 1: + for (i = n; i < width * n; ++i) + line_buffer[i] = z[i] - z[i - n]; + break; + case 2: + for (i = n; i < width * n; ++i) + line_buffer[i] = z[i] - z[i - signed_stride]; + break; + case 3: + for (i = n; i < width * n; ++i) + line_buffer[i] = z[i] - ((z[i - n] + z[i - signed_stride]) >> 1); + break; + case 4: + for (i = n; i < width * n; ++i) + line_buffer[i] = + z[i] - stbiw__paeth(z[i - n], z[i - signed_stride], z[i - signed_stride - n]); + break; + case 5: + for (i = n; i < width * n; ++i) + line_buffer[i] = z[i] - (z[i - n] >> 1); + break; + case 6: + for (i = n; i < width * n; ++i) + line_buffer[i] = z[i] - stbiw__paeth(z[i - n], 0, 0); + break; + } +} + +STBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_bytes, int x, + int y, int n, int *out_len) { + int force_filter = stbi_write_force_png_filter; + int ctype[5] = {-1, 0, 4, 2, 6}; + unsigned char sig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; + unsigned char *out, *o, *filt, *zlib; + signed char *line_buffer; + int j, zlen; + + if (stride_bytes == 0) + stride_bytes = x * n; + + if (force_filter >= 5) { + force_filter = -1; + } + + filt = (unsigned char *)STBIW_MALLOC((x * n + 1) * y); + if (!filt) + return 0; + line_buffer = (signed char *)STBIW_MALLOC(x * n); + if (!line_buffer) { + STBIW_FREE(filt); + return 0; + } + for (j = 0; j < y; ++j) { + int filter_type; + if (force_filter > -1) { + filter_type = force_filter; + stbiw__encode_png_line((unsigned char *)(pixels), stride_bytes, x, y, j, n, + force_filter, line_buffer); + } else { // Estimate the best filter by running through all of them: + int best_filter = 0, best_filter_val = 0x7fffffff, est, i; + for (filter_type = 0; filter_type < 5; filter_type++) { + stbiw__encode_png_line((unsigned char *)(pixels), stride_bytes, x, y, j, n, + filter_type, line_buffer); + + // Estimate the entropy of the line using this filter; the less, the better. + est = 0; + for (i = 0; i < x * n; ++i) { + est += abs((signed char)line_buffer[i]); + } + if (est < best_filter_val) { + best_filter_val = est; + best_filter = filter_type; + } + } + if (filter_type != best_filter) { // If the last iteration already got us the best + // filter, don't redo it + stbiw__encode_png_line((unsigned char *)(pixels), stride_bytes, x, y, j, n, + best_filter, line_buffer); + filter_type = best_filter; + } + } + // when we get here, filter_type contains the filter type, and line_buffer contains the data + filt[j * (x * n + 1)] = (unsigned char)filter_type; + STBIW_MEMMOVE(filt + j * (x * n + 1) + 1, line_buffer, x * n); + } + STBIW_FREE(line_buffer); + zlib = stbi_zlib_compress(filt, y * (x * n + 1), &zlen, stbi_write_png_compression_level); + STBIW_FREE(filt); + if (!zlib) + return 0; + + // each tag requires 12 bytes of overhead + out = (unsigned char *)STBIW_MALLOC(8 + 12 + 13 + 12 + zlen + 12); + if (!out) + return 0; + *out_len = 8 + 12 + 13 + 12 + zlen + 12; + + o = out; + STBIW_MEMMOVE(o, sig, 8); + o += 8; + stbiw__wp32(o, 13); // header length + stbiw__wptag(o, "IHDR"); + stbiw__wp32(o, x); + stbiw__wp32(o, y); + *o++ = 8; + *o++ = STBIW_UCHAR(ctype[n]); + *o++ = 0; + *o++ = 0; + *o++ = 0; + stbiw__wpcrc(&o, 13); + + stbiw__wp32(o, zlen); + stbiw__wptag(o, "IDAT"); + STBIW_MEMMOVE(o, zlib, zlen); + o += zlen; + STBIW_FREE(zlib); + stbiw__wpcrc(&o, zlen); + + stbiw__wp32(o, 0); + stbiw__wptag(o, "IEND"); + stbiw__wpcrc(&o, 0); + + STBIW_ASSERT(o == out + *out_len); + + return out; +} + +#ifndef STBI_WRITE_NO_STDIO +STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const void *data, + int stride_bytes) { + FILE *f; + int len; + unsigned char *png = + stbi_write_png_to_mem((const unsigned char *)data, stride_bytes, x, y, comp, &len); + if (png == NULL) + return 0; + + f = stbiw__fopen(filename, "wb"); + if (!f) { + STBIW_FREE(png); + return 0; + } + fwrite(png, 1, len, f); + fclose(f); + STBIW_FREE(png); + return 1; +} +#endif + +STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, int y, int comp, + const void *data, int stride_bytes) { + int len; + unsigned char *png = + stbi_write_png_to_mem((const unsigned char *)data, stride_bytes, x, y, comp, &len); + if (png == NULL) + return 0; + func(context, png, len); + STBIW_FREE(png); + return 1; +} + +/* *************************************************************************** + * + * JPEG writer + * + * This is based on Jon Olick's jo_jpeg.cpp: + * public domain Simple, Minimalistic JPEG writer - http://www.jonolick.com/code.html + */ + +static const unsigned char stbiw__jpg_ZigZag[] = { + 0, 1, 5, 6, 14, 15, 27, 28, 2, 4, 7, 13, 16, 26, 29, 42, 3, 8, 12, 17, 25, 30, + 41, 43, 9, 11, 18, 24, 31, 40, 44, 53, 10, 19, 23, 32, 39, 45, 52, 54, 20, 22, 33, 38, + 46, 51, 55, 60, 21, 34, 37, 47, 50, 56, 59, 61, 35, 36, 48, 49, 57, 58, 62, 63}; + +static void stbiw__jpg_writeBits(stbi__write_context *s, int *bitBufP, int *bitCntP, + const unsigned short *bs) { + int bitBuf = *bitBufP, bitCnt = *bitCntP; + bitCnt += bs[1]; + bitBuf |= bs[0] << (24 - bitCnt); + while (bitCnt >= 8) { + unsigned char c = (bitBuf >> 16) & 255; + stbiw__putc(s, c); + if (c == 255) { + stbiw__putc(s, 0); + } + bitBuf <<= 8; + bitCnt -= 8; + } + *bitBufP = bitBuf; + *bitCntP = bitCnt; +} + +static void stbiw__jpg_DCT(float *d0p, float *d1p, float *d2p, float *d3p, float *d4p, float *d5p, + float *d6p, float *d7p) { + float d0 = *d0p, d1 = *d1p, d2 = *d2p, d3 = *d3p, d4 = *d4p, d5 = *d5p, d6 = *d6p, d7 = *d7p; + float z1, z2, z3, z4, z5, z11, z13; + + float tmp0 = d0 + d7; + float tmp7 = d0 - d7; + float tmp1 = d1 + d6; + float tmp6 = d1 - d6; + float tmp2 = d2 + d5; + float tmp5 = d2 - d5; + float tmp3 = d3 + d4; + float tmp4 = d3 - d4; + + // Even part + float tmp10 = tmp0 + tmp3; // phase 2 + float tmp13 = tmp0 - tmp3; + float tmp11 = tmp1 + tmp2; + float tmp12 = tmp1 - tmp2; + + d0 = tmp10 + tmp11; // phase 3 + d4 = tmp10 - tmp11; + + z1 = (tmp12 + tmp13) * 0.707106781f; // c4 + d2 = tmp13 + z1; // phase 5 + d6 = tmp13 - z1; + + // Odd part + tmp10 = tmp4 + tmp5; // phase 2 + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + // The rotator is modified from fig 4-8 to avoid extra negations. + z5 = (tmp10 - tmp12) * 0.382683433f; // c6 + z2 = tmp10 * 0.541196100f + z5; // c2-c6 + z4 = tmp12 * 1.306562965f + z5; // c2+c6 + z3 = tmp11 * 0.707106781f; // c4 + + z11 = tmp7 + z3; // phase 5 + z13 = tmp7 - z3; + + *d5p = z13 + z2; // phase 6 + *d3p = z13 - z2; + *d1p = z11 + z4; + *d7p = z11 - z4; + + *d0p = d0; + *d2p = d2; + *d4p = d4; + *d6p = d6; +} + +static void stbiw__jpg_calcBits(int val, unsigned short bits[2]) { + int tmp1 = val < 0 ? -val : val; + val = val < 0 ? val - 1 : val; + bits[1] = 1; + while (tmp1 >>= 1) { + ++bits[1]; + } + bits[0] = val & ((1 << bits[1]) - 1); +} + +static int stbiw__jpg_processDU(stbi__write_context *s, int *bitBuf, int *bitCnt, float *CDU, + int du_stride, float *fdtbl, int DC, + const unsigned short HTDC[256][2], + const unsigned short HTAC[256][2]) { + const unsigned short EOB[2] = {HTAC[0x00][0], HTAC[0x00][1]}; + const unsigned short M16zeroes[2] = {HTAC[0xF0][0], HTAC[0xF0][1]}; + int dataOff, i, j, n, diff, end0pos, x, y; + int DU[64]; + + // DCT rows + for (dataOff = 0, n = du_stride * 8; dataOff < n; dataOff += du_stride) { + stbiw__jpg_DCT(&CDU[dataOff], &CDU[dataOff + 1], &CDU[dataOff + 2], &CDU[dataOff + 3], + &CDU[dataOff + 4], &CDU[dataOff + 5], &CDU[dataOff + 6], &CDU[dataOff + 7]); + } + // DCT columns + for (dataOff = 0; dataOff < 8; ++dataOff) { + stbiw__jpg_DCT(&CDU[dataOff], &CDU[dataOff + du_stride], &CDU[dataOff + du_stride * 2], + &CDU[dataOff + du_stride * 3], &CDU[dataOff + du_stride * 4], + &CDU[dataOff + du_stride * 5], &CDU[dataOff + du_stride * 6], + &CDU[dataOff + du_stride * 7]); + } + // Quantize/descale/zigzag the coefficients + for (y = 0, j = 0; y < 8; ++y) { + for (x = 0; x < 8; ++x, ++j) { + float v; + i = y * du_stride + x; + v = CDU[i] * fdtbl[j]; + // DU[stbiw__jpg_ZigZag[j]] = (int)(v < 0 ? ceilf(v - 0.5f) : floorf(v + 0.5f)); + // ceilf() and floorf() are C99, not C89, but I /think/ they're not needed here anyway? + DU[stbiw__jpg_ZigZag[j]] = (int)(v < 0 ? v - 0.5f : v + 0.5f); + } + } + + // Encode DC + diff = DU[0] - DC; + if (diff == 0) { + stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTDC[0]); + } else { + unsigned short bits[2]; + stbiw__jpg_calcBits(diff, bits); + stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTDC[bits[1]]); + stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits); + } + // Encode ACs + end0pos = 63; + for (; (end0pos > 0) && (DU[end0pos] == 0); --end0pos) { + } + // end0pos = first element in reverse order !=0 + if (end0pos == 0) { + stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); + return DU[0]; + } + for (i = 1; i <= end0pos; ++i) { + int startpos = i; + int nrzeroes; + unsigned short bits[2]; + for (; DU[i] == 0 && i <= end0pos; ++i) { + } + nrzeroes = i - startpos; + if (nrzeroes >= 16) { + int lng = nrzeroes >> 4; + int nrmarker; + for (nrmarker = 1; nrmarker <= lng; ++nrmarker) + stbiw__jpg_writeBits(s, bitBuf, bitCnt, M16zeroes); + nrzeroes &= 15; + } + stbiw__jpg_calcBits(DU[i], bits); + stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTAC[(nrzeroes << 4) + bits[1]]); + stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits); + } + if (end0pos != 63) { + stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); + } + return DU[0]; +} + +static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, int comp, + const void *data, int quality) { + // Constants that don't pollute global namespace + static const unsigned char std_dc_luminance_nrcodes[] = {0, 0, 1, 5, 1, 1, 1, 1, 1, + 1, 0, 0, 0, 0, 0, 0, 0}; + static const unsigned char std_dc_luminance_values[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; + static const unsigned char std_ac_luminance_nrcodes[] = {0, 0, 2, 1, 3, 3, 2, 4, 3, + 5, 5, 4, 4, 0, 0, 1, 0x7d}; + static const unsigned char std_ac_luminance_values[] = { + 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, + 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, + 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25, + 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, + 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, + 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83, + 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, + 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, + 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, + 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, + 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa}; + static const unsigned char std_dc_chrominance_nrcodes[] = {0, 0, 3, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0}; + static const unsigned char std_dc_chrominance_values[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; + static const unsigned char std_ac_chrominance_nrcodes[] = {0, 0, 2, 1, 2, 4, 4, 3, 4, + 7, 5, 4, 4, 0, 1, 2, 0x77}; + static const unsigned char std_ac_chrominance_values[] = { + 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, + 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, + 0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, + 0x19, 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, + 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, + 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, + 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, + 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, + 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, + 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa}; + // Huffman tables + static const unsigned short YDC_HT[256][2] = { + {0, 2}, + {2, 3}, + {3, 3}, + {4, 3}, + {5, 3}, + {6, 3}, + {14, 4}, + {30, 5}, + {62, 6}, + {126, 7}, + {254, 8}, + {510, 9} + }; + static const unsigned short UVDC_HT[256][2] = { + {0, 2 }, + {1, 2 }, + {2, 2 }, + {6, 3 }, + {14, 4 }, + {30, 5 }, + {62, 6 }, + {126, 7 }, + {254, 8 }, + {510, 9 }, + {1022, 10}, + {2046, 11} + }; + static const unsigned short YAC_HT[256][2] = { + {10, 4 }, + {0, 2 }, + {1, 2 }, + {4, 3 }, + {11, 4 }, + {26, 5 }, + {120, 7 }, + {248, 8 }, + {1014, 10}, + {65410, 16}, + {65411, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {12, 4 }, + {27, 5 }, + {121, 7 }, + {502, 9 }, + {2038, 11}, + {65412, 16}, + {65413, 16}, + {65414, 16}, + {65415, 16}, + {65416, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {28, 5 }, + {249, 8 }, + {1015, 10}, + {4084, 12}, + {65417, 16}, + {65418, 16}, + {65419, 16}, + {65420, 16}, + {65421, 16}, + {65422, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {58, 6 }, + {503, 9 }, + {4085, 12}, + {65423, 16}, + {65424, 16}, + {65425, 16}, + {65426, 16}, + {65427, 16}, + {65428, 16}, + {65429, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {59, 6 }, + {1016, 10}, + {65430, 16}, + {65431, 16}, + {65432, 16}, + {65433, 16}, + {65434, 16}, + {65435, 16}, + {65436, 16}, + {65437, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {122, 7 }, + {2039, 11}, + {65438, 16}, + {65439, 16}, + {65440, 16}, + {65441, 16}, + {65442, 16}, + {65443, 16}, + {65444, 16}, + {65445, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {123, 7 }, + {4086, 12}, + {65446, 16}, + {65447, 16}, + {65448, 16}, + {65449, 16}, + {65450, 16}, + {65451, 16}, + {65452, 16}, + {65453, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {250, 8 }, + {4087, 12}, + {65454, 16}, + {65455, 16}, + {65456, 16}, + {65457, 16}, + {65458, 16}, + {65459, 16}, + {65460, 16}, + {65461, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {504, 9 }, + {32704, 15}, + {65462, 16}, + {65463, 16}, + {65464, 16}, + {65465, 16}, + {65466, 16}, + {65467, 16}, + {65468, 16}, + {65469, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {505, 9 }, + {65470, 16}, + {65471, 16}, + {65472, 16}, + {65473, 16}, + {65474, 16}, + {65475, 16}, + {65476, 16}, + {65477, 16}, + {65478, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {506, 9 }, + {65479, 16}, + {65480, 16}, + {65481, 16}, + {65482, 16}, + {65483, 16}, + {65484, 16}, + {65485, 16}, + {65486, 16}, + {65487, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {1017, 10}, + {65488, 16}, + {65489, 16}, + {65490, 16}, + {65491, 16}, + {65492, 16}, + {65493, 16}, + {65494, 16}, + {65495, 16}, + {65496, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {1018, 10}, + {65497, 16}, + {65498, 16}, + {65499, 16}, + {65500, 16}, + {65501, 16}, + {65502, 16}, + {65503, 16}, + {65504, 16}, + {65505, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {2040, 11}, + {65506, 16}, + {65507, 16}, + {65508, 16}, + {65509, 16}, + {65510, 16}, + {65511, 16}, + {65512, 16}, + {65513, 16}, + {65514, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {65515, 16}, + {65516, 16}, + {65517, 16}, + {65518, 16}, + {65519, 16}, + {65520, 16}, + {65521, 16}, + {65522, 16}, + {65523, 16}, + {65524, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {2041, 11}, + {65525, 16}, + {65526, 16}, + {65527, 16}, + {65528, 16}, + {65529, 16}, + {65530, 16}, + {65531, 16}, + {65532, 16}, + {65533, 16}, + {65534, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 } + }; + static const unsigned short UVAC_HT[256][2] = { + {0, 2 }, + {1, 2 }, + {4, 3 }, + {10, 4 }, + {24, 5 }, + {25, 5 }, + {56, 6 }, + {120, 7 }, + {500, 9 }, + {1014, 10}, + {4084, 12}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {11, 4 }, + {57, 6 }, + {246, 8 }, + {501, 9 }, + {2038, 11}, + {4085, 12}, + {65416, 16}, + {65417, 16}, + {65418, 16}, + {65419, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {26, 5 }, + {247, 8 }, + {1015, 10}, + {4086, 12}, + {32706, 15}, + {65420, 16}, + {65421, 16}, + {65422, 16}, + {65423, 16}, + {65424, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {27, 5 }, + {248, 8 }, + {1016, 10}, + {4087, 12}, + {65425, 16}, + {65426, 16}, + {65427, 16}, + {65428, 16}, + {65429, 16}, + {65430, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {58, 6 }, + {502, 9 }, + {65431, 16}, + {65432, 16}, + {65433, 16}, + {65434, 16}, + {65435, 16}, + {65436, 16}, + {65437, 16}, + {65438, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {59, 6 }, + {1017, 10}, + {65439, 16}, + {65440, 16}, + {65441, 16}, + {65442, 16}, + {65443, 16}, + {65444, 16}, + {65445, 16}, + {65446, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {121, 7 }, + {2039, 11}, + {65447, 16}, + {65448, 16}, + {65449, 16}, + {65450, 16}, + {65451, 16}, + {65452, 16}, + {65453, 16}, + {65454, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {122, 7 }, + {2040, 11}, + {65455, 16}, + {65456, 16}, + {65457, 16}, + {65458, 16}, + {65459, 16}, + {65460, 16}, + {65461, 16}, + {65462, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {249, 8 }, + {65463, 16}, + {65464, 16}, + {65465, 16}, + {65466, 16}, + {65467, 16}, + {65468, 16}, + {65469, 16}, + {65470, 16}, + {65471, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {503, 9 }, + {65472, 16}, + {65473, 16}, + {65474, 16}, + {65475, 16}, + {65476, 16}, + {65477, 16}, + {65478, 16}, + {65479, 16}, + {65480, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {504, 9 }, + {65481, 16}, + {65482, 16}, + {65483, 16}, + {65484, 16}, + {65485, 16}, + {65486, 16}, + {65487, 16}, + {65488, 16}, + {65489, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {505, 9 }, + {65490, 16}, + {65491, 16}, + {65492, 16}, + {65493, 16}, + {65494, 16}, + {65495, 16}, + {65496, 16}, + {65497, 16}, + {65498, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {506, 9 }, + {65499, 16}, + {65500, 16}, + {65501, 16}, + {65502, 16}, + {65503, 16}, + {65504, 16}, + {65505, 16}, + {65506, 16}, + {65507, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {2041, 11}, + {65508, 16}, + {65509, 16}, + {65510, 16}, + {65511, 16}, + {65512, 16}, + {65513, 16}, + {65514, 16}, + {65515, 16}, + {65516, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {16352, 14}, + {65517, 16}, + {65518, 16}, + {65519, 16}, + {65520, 16}, + {65521, 16}, + {65522, 16}, + {65523, 16}, + {65524, 16}, + {65525, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {1018, 10}, + {32707, 15}, + {65526, 16}, + {65527, 16}, + {65528, 16}, + {65529, 16}, + {65530, 16}, + {65531, 16}, + {65532, 16}, + {65533, 16}, + {65534, 16}, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 }, + {0, 0 } + }; + static const int YQT[] = {16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19, 26, + 58, 60, 55, 14, 13, 16, 24, 40, 57, 69, 56, 14, 17, + 22, 29, 51, 87, 80, 62, 18, 22, 37, 56, 68, 109, 103, + 77, 24, 35, 55, 64, 81, 104, 113, 92, 49, 64, 78, 87, + 103, 121, 120, 101, 72, 92, 95, 98, 112, 100, 103, 99}; + static const int UVQT[] = {17, 18, 24, 47, 99, 99, 99, 99, 18, 21, 26, 66, 99, 99, 99, 99, + 24, 26, 56, 99, 99, 99, 99, 99, 47, 66, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}; + static const float aasf[] = {1.0f * 2.828427125f, 1.387039845f * 2.828427125f, + 1.306562965f * 2.828427125f, 1.175875602f * 2.828427125f, + 1.0f * 2.828427125f, 0.785694958f * 2.828427125f, + 0.541196100f * 2.828427125f, 0.275899379f * 2.828427125f}; + + int row, col, i, k, subsample; + float fdtbl_Y[64], fdtbl_UV[64]; + unsigned char YTable[64], UVTable[64]; + + if (!data || !width || !height || comp > 4 || comp < 1) { + return 0; + } + + quality = quality ? quality : 90; + subsample = quality <= 90 ? 1 : 0; + quality = quality < 1 ? 1 : quality > 100 ? 100 : quality; + quality = quality < 50 ? 5000 / quality : 200 - quality * 2; + + for (i = 0; i < 64; ++i) { + int uvti, yti = (YQT[i] * quality + 50) / 100; + YTable[stbiw__jpg_ZigZag[i]] = (unsigned char)(yti < 1 ? 1 : yti > 255 ? 255 : yti); + uvti = (UVQT[i] * quality + 50) / 100; + UVTable[stbiw__jpg_ZigZag[i]] = (unsigned char)(uvti < 1 ? 1 : uvti > 255 ? 255 : uvti); + } + + for (row = 0, k = 0; row < 8; ++row) { + for (col = 0; col < 8; ++col, ++k) { + fdtbl_Y[k] = 1 / (YTable[stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); + fdtbl_UV[k] = 1 / (UVTable[stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); + } + } + + // Write Headers + { + static const unsigned char head0[] = {0xFF, 0xD8, 0xFF, 0xE0, 0, 0x10, 'J', 'F', 'I', + 'F', 0, 1, 1, 0, 0, 1, 0, 1, + 0, 0, 0xFF, 0xDB, 0, 0x84, 0}; + static const unsigned char head2[] = {0xFF, 0xDA, 0, 0xC, 3, 1, 0, + 2, 0x11, 3, 0x11, 0, 0x3F, 0}; + const unsigned char head1[] = {0xFF, + 0xC0, + 0, + 0x11, + 8, + (unsigned char)(height >> 8), + STBIW_UCHAR(height), + (unsigned char)(width >> 8), + STBIW_UCHAR(width), + 3, + 1, + (unsigned char)(subsample ? 0x22 : 0x11), + 0, + 2, + 0x11, + 1, + 3, + 0x11, + 1, + 0xFF, + 0xC4, + 0x01, + 0xA2, + 0}; + s->func(s->context, (void *)head0, sizeof(head0)); + s->func(s->context, (void *)YTable, sizeof(YTable)); + stbiw__putc(s, 1); + s->func(s->context, UVTable, sizeof(UVTable)); + s->func(s->context, (void *)head1, sizeof(head1)); + s->func(s->context, (void *)(std_dc_luminance_nrcodes + 1), + sizeof(std_dc_luminance_nrcodes) - 1); + s->func(s->context, (void *)std_dc_luminance_values, sizeof(std_dc_luminance_values)); + stbiw__putc(s, 0x10); // HTYACinfo + s->func(s->context, (void *)(std_ac_luminance_nrcodes + 1), + sizeof(std_ac_luminance_nrcodes) - 1); + s->func(s->context, (void *)std_ac_luminance_values, sizeof(std_ac_luminance_values)); + stbiw__putc(s, 1); // HTUDCinfo + s->func(s->context, (void *)(std_dc_chrominance_nrcodes + 1), + sizeof(std_dc_chrominance_nrcodes) - 1); + s->func(s->context, (void *)std_dc_chrominance_values, sizeof(std_dc_chrominance_values)); + stbiw__putc(s, 0x11); // HTUACinfo + s->func(s->context, (void *)(std_ac_chrominance_nrcodes + 1), + sizeof(std_ac_chrominance_nrcodes) - 1); + s->func(s->context, (void *)std_ac_chrominance_values, sizeof(std_ac_chrominance_values)); + s->func(s->context, (void *)head2, sizeof(head2)); + } + + // Encode 8x8 macroblocks + { + static const unsigned short fillBits[] = {0x7F, 7}; + int DCY = 0, DCU = 0, DCV = 0; + int bitBuf = 0, bitCnt = 0; + // comp == 2 is grey+alpha (alpha is ignored) + int ofsG = comp > 2 ? 1 : 0, ofsB = comp > 2 ? 2 : 0; + const unsigned char *dataR = (const unsigned char *)data; + const unsigned char *dataG = dataR + ofsG; + const unsigned char *dataB = dataR + ofsB; + int x, y, pos; + if (subsample) { + for (y = 0; y < height; y += 16) { + for (x = 0; x < width; x += 16) { + float Y[256], U[256], V[256]; + for (row = y, pos = 0; row < y + 16; ++row) { + // row >= height => use last input row + int clamped_row = (row < height) ? row : height - 1; + int base_p = (stbi__flip_vertically_on_write ? (height - 1 - clamped_row) + : clamped_row) * + width * comp; + for (col = x; col < x + 16; ++col, ++pos) { + // if col >= width => use pixel from last input column + int p = base_p + ((col < width) ? col : (width - 1)) * comp; + float r = dataR[p], g = dataG[p], b = dataB[p]; + Y[pos] = +0.29900f * r + 0.58700f * g + 0.11400f * b - 128; + U[pos] = -0.16874f * r - 0.33126f * g + 0.50000f * b; + V[pos] = +0.50000f * r - 0.41869f * g - 0.08131f * b; + } + } + DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y + 0, 16, fdtbl_Y, DCY, YDC_HT, + YAC_HT); + DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y + 8, 16, fdtbl_Y, DCY, YDC_HT, + YAC_HT); + DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y + 128, 16, fdtbl_Y, DCY, + YDC_HT, YAC_HT); + DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y + 136, 16, fdtbl_Y, DCY, + YDC_HT, YAC_HT); + + // subsample U,V + { + float subU[64], subV[64]; + int yy, xx; + for (yy = 0, pos = 0; yy < 8; ++yy) { + for (xx = 0; xx < 8; ++xx, ++pos) { + int j = yy * 32 + xx * 2; + subU[pos] = (U[j + 0] + U[j + 1] + U[j + 16] + U[j + 17]) * 0.25f; + subV[pos] = (V[j + 0] + V[j + 1] + V[j + 16] + V[j + 17]) * 0.25f; + } + } + DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subU, 8, fdtbl_UV, DCU, + UVDC_HT, UVAC_HT); + DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subV, 8, fdtbl_UV, DCV, + UVDC_HT, UVAC_HT); + } + } + } + } else { + for (y = 0; y < height; y += 8) { + for (x = 0; x < width; x += 8) { + float Y[64], U[64], V[64]; + for (row = y, pos = 0; row < y + 8; ++row) { + // row >= height => use last input row + int clamped_row = (row < height) ? row : height - 1; + int base_p = (stbi__flip_vertically_on_write ? (height - 1 - clamped_row) + : clamped_row) * + width * comp; + for (col = x; col < x + 8; ++col, ++pos) { + // if col >= width => use pixel from last input column + int p = base_p + ((col < width) ? col : (width - 1)) * comp; + float r = dataR[p], g = dataG[p], b = dataB[p]; + Y[pos] = +0.29900f * r + 0.58700f * g + 0.11400f * b - 128; + U[pos] = -0.16874f * r - 0.33126f * g + 0.50000f * b; + V[pos] = +0.50000f * r - 0.41869f * g - 0.08131f * b; + } + } + + DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y, 8, fdtbl_Y, DCY, YDC_HT, + YAC_HT); + DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, U, 8, fdtbl_UV, DCU, UVDC_HT, + UVAC_HT); + DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, V, 8, fdtbl_UV, DCV, UVDC_HT, + UVAC_HT); + } + } + } + + // Do the bit alignment of the EOI marker + stbiw__jpg_writeBits(s, &bitBuf, &bitCnt, fillBits); + } + + // EOI + stbiw__putc(s, 0xFF); + stbiw__putc(s, 0xD9); + + return 1; +} + +STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, + const void *data, int quality) { + stbi__write_context s = {0}; + stbi__start_write_callbacks(&s, func, context); + return stbi_write_jpg_core(&s, x, y, comp, (void *)data, quality); +} + +#ifndef STBI_WRITE_NO_STDIO +STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, + int quality) { + stbi__write_context s = {0}; + if (stbi__start_write_file(&s, filename)) { + int r = stbi_write_jpg_core(&s, x, y, comp, data, quality); + stbi__end_write_file(&s); + return r; + } else + return 0; +} +#endif + +#endif // STB_IMAGE_WRITE_IMPLEMENTATION + +/* Revision history + 1.16 (2021-07-11) + make Deflate code emit uncompressed blocks when it would otherwise expand + support writing BMPs with alpha channel + 1.15 (2020-07-13) unknown + 1.14 (2020-02-02) updated JPEG writer to downsample chroma channels + 1.13 + 1.12 + 1.11 (2019-08-11) + + 1.10 (2019-02-07) + support utf8 filenames in Windows; fix warnings and platform ifdefs + 1.09 (2018-02-11) + fix typo in zlib quality API, improve STB_I_W_STATIC in C++ + 1.08 (2018-01-29) + add stbi__flip_vertically_on_write, external zlib, zlib quality, choose PNG filter + 1.07 (2017-07-24) + doc fix + 1.06 (2017-07-23) + writing JPEG (using Jon Olick's code) + 1.05 ??? + 1.04 (2017-03-03) + monochrome BMP expansion + 1.03 ??? + 1.02 (2016-04-02) + avoid allocating large structures on the stack + 1.01 (2016-01-16) + STBIW_REALLOC_SIZED: support allocators with no realloc support + avoid race-condition in crc initialization + minor compile issues + 1.00 (2015-09-14) + installable file IO function + 0.99 (2015-09-13) + warning fixes; TGA rle support + 0.98 (2015-04-08) + added STBIW_MALLOC, STBIW_ASSERT etc + 0.97 (2015-01-18) + fixed HDR asserts, rewrote HDR rle logic + 0.96 (2015-01-17) + add HDR output + fix monochrome BMP + 0.95 (2014-08-17) + add monochrome TGA output + 0.94 (2014-05-31) + rename private functions to avoid conflicts with stb_image.h + 0.93 (2014-05-27) + warning fixes + 0.92 (2010-08-01) + casts to unsigned char to fix warnings + 0.91 (2010-07-17) + first public release + 0.90 first internal release +*/ + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ +*/ \ No newline at end of file diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 01e5ae84..96dc6d0f 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -16,6 +16,10 @@ #include #include #include + +#ifndef STB_IMAGE_IMPLEMENTATION +#define STB_IMAGE_IMPLEMENTATION +#endif #include #include "core/core.hpp" @@ -473,7 +477,7 @@ namespace Toolbox { ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoInputs)) { ImagePainter painter; - painter.renderOverlay(*action->getImage(), pos, size); + painter.render(*action->getImage(), pos, size); if (ImGuiWindow *win = ImGui::GetCurrentWindow()) { if (win->Viewport != ImGui::GetMainViewport()) { diff --git a/src/gui/dragdrop/target.cpp b/src/gui/dragdrop/target.cpp index c8e943e1..45cc8246 100644 --- a/src/gui/dragdrop/target.cpp +++ b/src/gui/dragdrop/target.cpp @@ -5,6 +5,8 @@ #include "gui/event/dropevent.hpp" #include "gui/window.hpp" +#include "image/imagebuilder.hpp" + namespace Toolbox::UI { static UUID64 searchDropTarget(const ImVec2 &mouse_pos) { @@ -246,7 +248,7 @@ namespace Toolbox::UI { DragDropManager::instance().setSystemAction(false); } - action->setHotSpot(ImVec2(pt.x, pt.y)); + action->setHotSpot(ImVec2((float)pt.x, (float)pt.y)); DropTypes supported_drop_types = DropType::ACTION_NONE; if ((*pdwEffect & DROPEFFECT_COPY)) { @@ -267,7 +269,7 @@ namespace Toolbox::UI { HRESULT __stdcall WindowsDragDropTarget::DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect) { RefPtr action = DragDropManager::instance().getCurrentDragAction(); - action->setHotSpot(ImVec2(pt.x, pt.y)); + action->setHotSpot(ImVec2((float)pt.x, (float)pt.y)); m_delegate->onDragMove(action); return S_OK; } @@ -286,7 +288,7 @@ namespace Toolbox::UI { action = DragDropManager::instance().createDragAction(0, std::move(mime_data)); } - action->setHotSpot(ImVec2(pt.x, pt.y)); + action->setHotSpot(ImVec2((float)pt.x, (float)pt.y)); DropTypes supported_drop_types = DropType::ACTION_NONE; if ((*pdwEffect & DROPEFFECT_COPY)) { @@ -309,13 +311,6 @@ namespace Toolbox::UI { UUID64 prev_uuid = action->getTargetUUID(); UUID64 new_uuid = searchDropTarget(mouse_pos); - ResourceManager &resource_manager = GUIApplication::instance().getResourceManager(); - RefPtr image = - resource_manager - .getImageHandle("toolbox.png", resource_manager.getResourcePathUUID("Images/Icons")) - .value_or(nullptr); - action->setImage(image); - if (prev_uuid != new_uuid) { if (prev_uuid != 0) { GUIApplication::instance().dispatchEvent( @@ -336,13 +331,6 @@ namespace Toolbox::UI { UUID64 prev_uuid = action->getTargetUUID(); UUID64 new_uuid = searchDropTarget(mouse_pos); - ResourceManager &resource_manager = GUIApplication::instance().getResourceManager(); - RefPtr image = - resource_manager - .getImageHandle("toolbox.png", resource_manager.getResourcePathUUID("Images/Icons")) - .value_or(nullptr); - action->setImage(image); - if (prev_uuid != new_uuid && prev_uuid != 0) { GUIApplication::instance().dispatchEvent(EVENT_DRAG_LEAVE, mouse_pos.x, mouse_pos.y, action); @@ -356,13 +344,6 @@ namespace Toolbox::UI { UUID64 prev_uuid = action->getTargetUUID(); UUID64 new_uuid = searchDropTarget(mouse_pos); - ResourceManager &resource_manager = GUIApplication::instance().getResourceManager(); - RefPtr image = - resource_manager - .getImageHandle("toolbox.png", resource_manager.getResourcePathUUID("Images/Icons")) - .value_or(nullptr); - action->setImage(image); - if (prev_uuid != new_uuid) { if (!m_block_implicit_drag_events && prev_uuid != 0) { GUIApplication::instance().dispatchEvent( @@ -387,13 +368,6 @@ namespace Toolbox::UI { void WindowsDragDropTargetDelegate::onDrop(RefPtr action) { ImVec2 mouse_pos = action->getHotSpot(); - ResourceManager &resource_manager = GUIApplication::instance().getResourceManager(); - RefPtr image = - resource_manager - .getImageHandle("toolbox.png", resource_manager.getResourcePathUUID("Images/Icons")) - .value_or(nullptr); - action->setImage(image); - UUID64 new_uuid = searchDropTarget(mouse_pos); action->setTargetUUID(new_uuid); diff --git a/src/gui/pad/window.cpp b/src/gui/pad/window.cpp index 840e3472..084aac23 100644 --- a/src/gui/pad/window.cpp +++ b/src/gui/pad/window.cpp @@ -31,8 +31,8 @@ #include "gui/window.hpp" #include "gui/logging/errors.hpp" -#include "gui/stb_image.h" +#include #include #include diff --git a/src/gui/scene/billboard.cpp b/src/gui/scene/billboard.cpp index 30f66169..f7131a40 100644 --- a/src/gui/scene/billboard.cpp +++ b/src/gui/scene/billboard.cpp @@ -1,7 +1,7 @@ #include "gui/scene/billboard.hpp" #include #include -#include "gui/stb_image.h" +#include #include namespace Toolbox::UI { diff --git a/src/image/imagebuilder.cpp b/src/image/imagebuilder.cpp new file mode 100644 index 00000000..d4b9fed9 --- /dev/null +++ b/src/image/imagebuilder.cpp @@ -0,0 +1,353 @@ +#include "image/imagebuilder.hpp" +#include "image/imagehandle.hpp" + +#include + +#ifndef STB_IMAGE_RESIZE_IMPLEMENTATION +#define STB_IMAGE_RESIZE_IMPLEMENTATION +#endif +#include + +#include +#include + +namespace Toolbox::UI { + + using pixel_pix_op_t = std::function; + using pixel_color_op_t = std::function; + + static ScopePtr _ImageApplyOperationPix(const ImageData &a, const ImageData &b, + pixel_pix_op_t operation) { + const u8 *A = a.getData(); + const u8 *B = b.getData(); + + int chan_a = a.getChannels(); + int chan_b = b.getChannels(); + + int rows_a = a.getHeight(); + int cols_a = a.getWidth(); + int rows_b = b.getHeight(); + int cols_b = b.getWidth(); + + // Determine the intersection size + int min_height = std::min(rows_a, rows_b); + int min_width = std::min(cols_a, cols_b); + + int max_height = std::max(rows_a, rows_b); + int max_width = std::max(cols_a, cols_b); + int result_channels = std::max(chan_a, chan_b); + + Buffer result_buf; + result_buf.alloc(max_width * max_height * result_channels); + + // Apply the operation to the overlapping region + for (int row = 0; row < min_height; ++row) { + for (int col = 0; col < min_width; ++col) { + // Process for channels in A and B + for (int ch = 0; ch < result_channels; ++ch) { + int ind_a = row * cols_a * chan_a + col * chan_a + ch; + int ind_b = row * cols_b * chan_b + col * chan_b + ch; + u8 pixel_A = (ch < chan_a) ? A[ind_a] : 0; + u8 pixel_B = (ch < chan_b) ? B[ind_b] : 0; + + // Store in the result image + int ind_res = row * max_width * result_channels + col * result_channels + ch; + result_buf[ind_res] = operation(pixel_A, pixel_B); + } + } + } + + // Copy the rest of A if it's bigger than B + for (int row = min_height; row < rows_a; ++row) { + for (int col = min_width; col < cols_a; ++col) { + // Skip pixels that are already handled in the overlap region + if (row < min_height && col < min_width) + continue; + + for (int ch = 0; ch < result_channels; ++ch) { + u8 pixel_A = (ch < chan_a) ? A[row * cols_a * chan_a + col * chan_a + ch] : 0; + result_buf[row * max_width * result_channels + col * result_channels + ch] = + pixel_A; + } + } + } + + // Copy the rest of B if it's bigger than A + for (int row = min_height; row < rows_b; ++row) { + for (int col = min_width; col < cols_b; ++col) { + // Skip pixels that are already handled in the overlap region + if (row < min_height && col < min_width) + continue; + + for (int ch = 0; ch < result_channels; ++ch) { + u8 pixel_B = (ch < chan_b) ? B[row * cols_b * chan_b + col * chan_b + ch] : 0; + result_buf[row * max_width * result_channels + col * result_channels + ch] = + pixel_B; + } + } + } + + return make_scoped(std::move(result_buf), result_channels, max_width, + max_height); + } + + static ScopePtr _ImageApplyOperationColor(const ImageData &a, const ImageData &b, + pixel_color_op_t operation) { + const u8 *A = a.getData(); + const u8 *B = b.getData(); + + int chan_a = a.getChannels(); + int chan_b = b.getChannels(); + + int rows_a = a.getHeight(); + int cols_a = a.getWidth(); + int rows_b = b.getHeight(); + int cols_b = b.getWidth(); + + // Determine the intersection size + int min_height = std::min(rows_a, rows_b); + int min_width = std::min(cols_a, cols_b); + + int max_height = std::max(rows_a, rows_b); + int max_width = std::max(cols_a, cols_b); + int result_channels = std::max(chan_a, chan_b); + + Buffer result_buf; + result_buf.alloc(max_width * max_height * result_channels); + + // Apply the operation to the overlapping region + for (int row = 0; row < min_height; ++row) { + for (int col = 0; col < min_width; ++col) { + // Process for channels in A and B + int ind_a = row * cols_a * chan_a + col * chan_a; + int ind_b = row * cols_b * chan_b + col * chan_b; + int ind_res = row * max_width * result_channels + col * result_channels; + operation(result_buf.buf() + ind_res, A + ind_a, B + ind_b, result_channels, + chan_a, chan_b); + } + } + + // Copy the rest of A if it's bigger than B + for (int row = min_height; row < rows_a; ++row) { + for (int col = min_width; col < cols_a; ++col) { + // Skip pixels that are already handled in the overlap region + if (row < min_height && col < min_width) + continue; + + for (int ch = 0; ch < result_channels; ++ch) { + u8 pixel_A = (ch < chan_a) ? A[row * cols_a * chan_a + col * chan_a + ch] : 0; + result_buf[row * max_width * result_channels + col * result_channels + ch] = + pixel_A; + } + } + } + + // Copy the rest of B if it's bigger than A + for (int row = min_height; row < rows_b; ++row) { + for (int col = min_width; col < cols_b; ++col) { + // Skip pixels that are already handled in the overlap region + if (row < min_height && col < min_width) + continue; + + for (int ch = 0; ch < result_channels; ++ch) { + u8 pixel_B = (ch < chan_b) ? B[row * cols_b * chan_b + col * chan_b + ch] : 0; + result_buf[row * max_width * result_channels + col * result_channels + ch] = + pixel_B; + } + } + } + + return make_scoped(std::move(result_buf), result_channels, max_width, + max_height); + } + + ScopePtr ImageBuilder::ImageAdd(const ImageData &a, const ImageData &b, float scale, + float offset) { + // Function to add two pixels safely (with clamping) + auto add_pixel = [scale, offset](u8 px_a, u8 px_b) -> u8 { + int sum = (static_cast(px_a) + static_cast(px_b)) / scale + (offset * 255.0f); + return static_cast(std::min(255, sum)); // Clamp to 255 + }; + + return _ImageApplyOperationPix(a, b, add_pixel); + } + + ScopePtr ImageBuilder::ImageAddModulo(const ImageData &a, const ImageData &b) { + // Function to add two pixels safely (with clamping) + auto add_pixel = [](u8 px_a, u8 px_b) -> u8 { + int sum = (static_cast(px_a) + static_cast(px_b)); + return static_cast(sum % 256); + }; + + return _ImageApplyOperationPix(a, b, add_pixel); + } + + ScopePtr ImageBuilder::ImageBlend(const ImageData &a, const ImageData &b, + float alpha) { + auto blend = [alpha](u8 px_a, u8 px_b) -> u8 { + return static_cast( + std::lerp(static_cast(px_a), static_cast(px_b), alpha)); + }; + + return _ImageApplyOperationPix(a, b, blend); + } + + ScopePtr ImageBuilder::ImageComposite(const ImageData &a, const ImageData &b) { + auto composite = [](u8 *dst, const u8 *a, const u8 *b, int ch_dst, int ch_a, + int ch_b) -> void { + // Composite the two images + if (ch_b < 4) { + for (int i = 0; i < ch_dst; ++i) { + dst[i] = (i < ch_b) ? b[i] : 0; + } + return; + } + + float alpha = static_cast(b[3]) / 255.0f; + + for (int ch = 0; ch < ch_dst; ++ch) { + float pa = (ch < ch_a) ? static_cast(a[ch]) : 0.0f; + float pb = (ch < ch_b) ? static_cast(b[ch]) : 0.0f; + dst[ch] = static_cast(std::lerp(pa, pb, alpha)); + } + }; + + return _ImageApplyOperationColor(a, b, composite); + } + + ScopePtr ImageBuilder::ImageDarker(const ImageData &a, const ImageData &b) { + auto darker = [](u8 px_a, u8 px_b) -> u8 { return std::min(px_a, px_b); }; + + return _ImageApplyOperationPix(a, b, darker); + } + + ScopePtr ImageBuilder::ImageDifference(const ImageData &a, const ImageData &b) { + auto darker = [](u8 px_a, u8 px_b) -> u8 { return std::abs(px_a - px_b); }; + + return _ImageApplyOperationPix(a, b, darker); + } + + ScopePtr ImageBuilder::ImageDivide(const ImageData &a, const ImageData &b) { + auto divide = [](u8 px_a, u8 px_b) -> u8 { + float a = static_cast(px_a) / 255.0f; + float b = static_cast(px_b) / 255.0f; + int div = static_cast((static_cast(a) / static_cast(b) * 255.0f)); + return static_cast(std::min(255, div)); + }; + + return _ImageApplyOperationPix(a, b, divide); + } + + ScopePtr ImageBuilder::ImageLighter(const ImageData &a, const ImageData &b) { + auto lighter = [](u8 px_a, u8 px_b) -> u8 { return std::max(px_a, px_b); }; + + return _ImageApplyOperationPix(a, b, lighter); + } + + ScopePtr ImageBuilder::ImageMultiply(const ImageData &a, const ImageData &b) { + auto divide = [](u8 px_a, u8 px_b) -> u8 { + float a = static_cast(px_a) / 255.0f; + float b = static_cast(px_b) / 255.0f; + return static_cast((static_cast(a) * static_cast(b) * 255.0f)); + }; + + return _ImageApplyOperationPix(a, b, divide); + } + + ScopePtr ImageBuilder::ImageOffset(const ImageData &image, int d_x, int d_y) { + int width = image.getWidth(); + int height = image.getHeight(); + int ch = image.getChannels(); + + const u8 *A = image.getData(); + + Buffer result_buf; + result_buf.alloc(width * height * ch); + result_buf.initTo(0); + + for (int y = 0; (y + d_y) < height; ++y) { + for (int x = 0; (x + d_x) < width; ++x) { + for (int c = 0; c < ch; ++ch) { + int src_ind = y * width * c + x * c + c; + int dst_ind = (y + d_y) * width * c + (x + d_x) * c + c; + result_buf[dst_ind] = A[src_ind]; + } + } + } + + return make_scoped(std::move(result_buf), ch, width, height); + } + + ScopePtr ImageBuilder::ImageOverlay(const ImageData &a, const ImageData &b) { + auto overlay = [](u8 px_a, u8 px_b) -> u8 { + float a = static_cast(px_a) / 255.0f; + float b = static_cast(px_b) / 255.0f; + if (px_b < 128) + return 2.0f * a * b * 255.0f; + return (1.0f - 2.0f * (1.0f - a) * (1.0f - b)) * 255.0f; + }; + + return _ImageApplyOperationPix(a, b, overlay); + } + + ScopePtr ImageBuilder::ImageResize(const ImageData &image, int width, int height) { + Buffer result_buf; + result_buf.alloc(width * height * image.getChannels()); + + stbir_pixel_layout layouts[] = {STBIR_1CHANNEL, STBIR_2CHANNEL, STBIR_RGB, STBIR_RGBA}; + + stbir_resize_uint8_linear(image.getData(), image.getWidth(), image.getHeight(), 0, + result_buf.buf(), width, height, 0, + layouts[image.getChannels()]); + + return make_scoped(std::move(result_buf), image.getChannels(), width, height); + } + + ScopePtr ImageBuilder::ImageScreen(const ImageData &a, const ImageData &b) { + auto screen = [](u8 px_a, u8 px_b) -> u8 { + float a = static_cast(px_a) / 255.0f; + float b = static_cast(px_b) / 255.0f; + return (1.0f - (1.0f - a) * (1.0f - b)) * 255.0f; + }; + + return _ImageApplyOperationPix(a, b, screen); + } + + ScopePtr ImageBuilder::ImageSubtract(const ImageData &a, const ImageData &b, + float scale, float offset) { + auto sub_pixel = [scale, offset](u8 px_a, u8 px_b) -> u8 { + int sum = (static_cast(px_a) - static_cast(px_b)) / scale + (offset * 255.0f); + return static_cast(std::min(255, sum)); // Clamp to 255 + }; + + return _ImageApplyOperationPix(a, b, sub_pixel); + } + + ScopePtr ImageBuilder::ImageSubtractModulo(const ImageData &a, const ImageData &b) { + auto sub_pixel = [](u8 px_a, u8 px_b) -> u8 { + int diff = (static_cast(px_a) - static_cast(px_b)); + return static_cast(((diff % 256) + 256) % 256); + }; + + return _ImageApplyOperationPix(a, b, sub_pixel); + } + + ScopePtr ImageBuilder::ImageAND(const ImageData &a, const ImageData &b) { + auto sub_pixel = [](u8 px_a, u8 px_b) -> u8 { return px_a & px_b; }; + + return _ImageApplyOperationPix(a, b, sub_pixel); + } + + ScopePtr ImageBuilder::ImageOR(const ImageData &a, const ImageData &b) { + auto sub_pixel = [](u8 px_a, u8 px_b) -> u8 { return px_a | px_b; }; + + return _ImageApplyOperationPix(a, b, sub_pixel); + } + + ScopePtr ImageBuilder::ImageXOR(const ImageData &a, const ImageData &b) { + auto sub_pixel = [](u8 px_a, u8 px_b) -> u8 { return px_a ^ px_b; }; + + return _ImageApplyOperationPix(a, b, sub_pixel); + } + +} // namespace Toolbox::UI diff --git a/src/image/imagedata.cpp b/src/image/imagedata.cpp new file mode 100644 index 00000000..8753d796 --- /dev/null +++ b/src/image/imagedata.cpp @@ -0,0 +1,52 @@ +#include "image/imagedata.hpp" + +#include + +#ifndef STB_IMAGE_WRITE_IMPLEMENTATION +#define STB_IMAGE_WRITE_IMPLEMENTATION +#endif +#include + +namespace Toolbox { + + ImageData::ImageData(const fs_path &res_path) { + stbi_uc *data = stbi_load(res_path.string().c_str(), &m_width, &m_height, &m_channels, 0); + m_data.setBuf(data, static_cast(m_width * m_height * m_channels)); + } + + ImageData::ImageData(std::span data) { + stbi_uc *stbi_buf = + stbi_load_from_memory(data.data(), data.size(), &m_width, &m_height, &m_channels, 0); + m_data.setBuf(stbi_buf, static_cast(m_width * m_height * m_channels)); + } + + ImageData::ImageData(std::span data, int channels, int dx, int dy) + : m_channels(channels), m_width(dx), m_height(dy) { + m_data.setBuf(data.data(), data.size()); + } + + ImageData::ImageData(const Buffer &data) { + stbi_uc *stbi_buf = + stbi_load_from_memory(data.buf(), data.size(), &m_width, &m_height, &m_channels, 0); + m_data.setBuf(stbi_buf, static_cast(m_width * m_height * m_channels)); + } + + ImageData::ImageData(Buffer &&data, int channels, int dx, int dy) + : m_channels(channels), m_width(dx), m_height(dy) { + m_data = std::move(data); + } + + ImageData::~ImageData() { + if (m_data) { + //stbi_image_free(m_data.buf()); + m_data.free(); + } + } + + bool ImageData::save(const fs_path &filename) const { + stbi_write_png(filename.string().c_str(), m_width, m_height, m_channels, m_data.buf(), + 0); + return true; + } + +} // namespace Toolbox diff --git a/src/image/imagehandle.cpp b/src/image/imagehandle.cpp index b135d8d5..70d9e9f0 100644 --- a/src/image/imagehandle.cpp +++ b/src/image/imagehandle.cpp @@ -1,5 +1,3 @@ -#pragma once - #include #include "image/imagehandle.hpp" @@ -7,13 +5,11 @@ #include "core/memory.hpp" #include "fsystem.hpp" -#define STB_IMAGE_IMPLEMENTATION -#include "gui/stb_image.h" -#include "stb/stb_image_resize.h" - #include #include +#include + namespace Toolbox { ImageHandle::ImageHandle(const ImageHandle &other) { copyGL(other); } @@ -65,6 +61,10 @@ namespace Toolbox { stbi_image_free(stbi_buf); } + ImageHandle::ImageHandle(const ImageData &data) { + loadGL(data.m_data, data.getChannels(), data.getWidth(), data.getHeight()); + } + ImageHandle::ImageHandle(const Buffer &data, int channels, int dx, int dy) { loadGL(data, channels, dx, dy); } diff --git a/src/resource/resource.cpp b/src/resource/resource.cpp index 54e04756..13e602af 100644 --- a/src/resource/resource.cpp +++ b/src/resource/resource.cpp @@ -149,6 +149,72 @@ namespace Toolbox { return result; } + Result, FSError> + ResourceManager::getImageData(const fs_path &path, const UUID64 &resource_path_uuid) const { + if (!hasDataPath(path, resource_path_uuid)) { + return make_fs_error>(std::error_code(), + {"Resource path not found"}); + } + + if (m_data_preload_cache.find(path) != m_data_preload_cache.end()) { + const ResourceData &data = m_data_preload_cache[path]; + + std::span data_span(static_cast(data.m_data_ptr), data.m_data_size); + RefPtr handle = make_referable(data_span); + + if (!handle->isValid()) { + return make_fs_error>(std::error_code(), + {"Failed to load image"}); + } + + return handle; + } + + fs_path resource_path = getResourcePath(resource_path_uuid).value_or(fs_path()); + fs_path abs_path = resource_path / path; + + RefPtr handle = make_referable(abs_path); + if (!handle->isValid()) { + return make_fs_error>(std::error_code(), + {"Failed to load image"}); + } + + return handle; + } + + Result, FSError> + ResourceManager::getImageData(fs_path &&path, const UUID64 &resource_path_uuid) const { + if (!hasDataPath(path, resource_path_uuid)) { + return make_fs_error>(std::error_code(), + {"Resource path not found"}); + } + + if (m_data_preload_cache.find(path) != m_data_preload_cache.end()) { + const ResourceData &data = m_data_preload_cache[path]; + + std::span data_span(static_cast(data.m_data_ptr), data.m_data_size); + RefPtr handle = make_referable(data_span); + + if (!handle->isValid()) { + return make_fs_error>(std::error_code(), + {"Failed to load image"}); + } + + return handle; + } + + fs_path resource_path = getResourcePath(resource_path_uuid).value_or(fs_path()); + fs_path abs_path = resource_path / path; + + RefPtr handle = make_referable(abs_path); + if (!handle->isValid()) { + return make_fs_error>(std::error_code(), + {"Failed to load image"}); + } + + return handle; + } + Result, FSError> ResourceManager::getImageHandle(const fs_path &path, const UUID64 &resource_path_uuid) const { if (m_image_handle_cache.find(path) != m_image_handle_cache.end()) { From c7ca9a57e2dd13f81c5f8fba27fe99cda5830ea9 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Tue, 8 Oct 2024 23:56:54 -0500 Subject: [PATCH 085/129] Enhance drag icon rendering --- include/gui/dragdrop/dragaction.hpp | 23 ++++++---- src/gui/application.cpp | 67 +++++++++++++---------------- src/gui/dragdrop/target.cpp | 49 ++++++++++++++++++++- 3 files changed, 94 insertions(+), 45 deletions(-) diff --git a/include/gui/dragdrop/dragaction.hpp b/include/gui/dragdrop/dragaction.hpp index a23fe281..7c7d1128 100644 --- a/include/gui/dragdrop/dragaction.hpp +++ b/include/gui/dragdrop/dragaction.hpp @@ -1,10 +1,10 @@ #pragma once -#include -#include "unique.hpp" #include "core/mimedata/mimedata.hpp" -#include "image/imagehandle.hpp" #include "gui/dragdrop/dropaction.hpp" +#include "image/imagehandle.hpp" +#include "unique.hpp" +#include namespace Toolbox::UI { @@ -12,15 +12,22 @@ namespace Toolbox::UI { friend class DragDropManager; protected: - DragAction() = default; + DragAction() = default; public: + using render_fn = std::function; + DragAction(UUID64 source_uuid) : m_source_uuid(source_uuid) {} DragAction(const DragAction &) = default; DragAction(DragAction &&) = default; + void render(const ImVec2 &size) const { + if (m_render) { + m_render(ImGui::GetWindowPos(), size); + } + } + [[nodiscard]] const ImVec2 &getHotSpot() const { return m_hot_spot; } - [[nodiscard]] RefPtr getImage() { return m_image_handle; } [[nodiscard]] const MimeData &getPayload() const { return m_mime_data; } [[nodiscard]] DropType getDefaultDropType() const { m_default_drop_type; } @@ -30,17 +37,17 @@ namespace Toolbox::UI { [[nodiscard]] UUID64 getTargetUUID() const { return m_target_uuid; } void setHotSpot(const ImVec2 &absp) { m_hot_spot = absp; } - void setImage(RefPtr image) { m_image_handle = image; } + void setRender(render_fn render) { m_render = render; } void setPayload(const MimeData &data) { m_mime_data = data; } void setTargetUUID(const UUID64 &uuid) { m_target_uuid = uuid; } void setSupportedDropTypes(DropTypes types) { m_supported_drop_types = types; } private: ImVec2 m_hot_spot; - RefPtr m_image_handle; + render_fn m_render; MimeData m_mime_data; - DropType m_default_drop_type = DropType::ACTION_MOVE; + DropType m_default_drop_type = DropType::ACTION_MOVE; DropTypes m_supported_drop_types = DropType::ACTION_COPY | DropType::ACTION_MOVE; UUID64 m_source_uuid = 0; diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 96dc6d0f..6183b41e 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -456,45 +456,40 @@ namespace Toolbox { action->setHotSpot({(float)x, (float)y}); - if (RefPtr image = action->getImage()) { - const ImVec2 &hotspot = action->getHotSpot(); - - ImGuiViewportP *viewport = - ImGui::FindHoveredViewportFromPlatformWindowStack(hotspot); - if (viewport) { - const ImVec2 size = {96, 96}; - const ImVec2 pos = {hotspot.x - size.x / 2.0f, hotspot.y - size.y / 1.1f}; - - ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); - // ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 5.0f); - ImGui::PushStyleColor(ImGuiCol_WindowBg, - ImGui::GetStyleColorVec4(ImGuiCol_HeaderHovered)); - - ImGui::SetNextWindowBgAlpha(1.0f); - ImGui::SetNextWindowPos(pos); - ImGui::SetNextWindowSize(size); - if (ImGui::Begin("###Drag Icon", nullptr, - ImGuiWindowFlags_NoDecoration | - ImGuiWindowFlags_NoInputs)) { - ImagePainter painter; - painter.render(*action->getImage(), pos, size); - - if (ImGuiWindow *win = ImGui::GetCurrentWindow()) { - if (win->Viewport != ImGui::GetMainViewport()) { - Platform::SetWindowClickThrough( - (Platform::LowWindow)win->Viewport->PlatformHandleRaw, - true); - m_drag_drop_viewport = win->Viewport; - } else { - m_drag_drop_viewport = nullptr; - } + const ImVec2 &hotspot = action->getHotSpot(); + + ImGuiViewportP *viewport = + ImGui::FindHoveredViewportFromPlatformWindowStack(hotspot); + if (viewport) { + const ImVec2 size = {96, 96}; + const ImVec2 pos = {hotspot.x - size.x / 2.0f, hotspot.y - size.y / 1.1f}; + + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); + // ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 5.0f); + ImGui::PushStyleColor(ImGuiCol_WindowBg, + ImGui::GetStyleColorVec4(ImGuiCol_Text)); + + ImGui::SetNextWindowBgAlpha(1.0f); + ImGui::SetNextWindowPos(pos); + ImGui::SetNextWindowSize(size); + if (ImGui::Begin("###Drag Icon", nullptr, + ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoInputs)) { + action->render(size); + + if (ImGuiWindow *win = ImGui::GetCurrentWindow()) { + if (win->Viewport != ImGui::GetMainViewport()) { + Platform::SetWindowClickThrough( + (Platform::LowWindow)win->Viewport->PlatformHandleRaw, true); + m_drag_drop_viewport = win->Viewport; + } else { + m_drag_drop_viewport = nullptr; } } - ImGui::End(); - - ImGui::PopStyleColor(1); - ImGui::PopStyleVar(1); } + ImGui::End(); + + ImGui::PopStyleColor(1); + ImGui::PopStyleVar(1); } } } diff --git a/src/gui/dragdrop/target.cpp b/src/gui/dragdrop/target.cpp index 45cc8246..f04736b4 100644 --- a/src/gui/dragdrop/target.cpp +++ b/src/gui/dragdrop/target.cpp @@ -7,6 +7,8 @@ #include "image/imagebuilder.hpp" +#include + namespace Toolbox::UI { static UUID64 searchDropTarget(const ImVec2 &mouse_pos) { @@ -246,6 +248,29 @@ namespace Toolbox::UI { MimeData mime_data = createMimeDataFromDataObject(pDataObj); action = DragDropManager::instance().createDragAction(0, std::move(mime_data)); DragDropManager::instance().setSystemAction(false); + + action->setRender([action](const ImVec2 &pos, const ImVec2 &size) { + std::string urls = action->getPayload().get_urls().value_or(""); + if (urls.empty()) { + return; + } + + ImGuiStyle &style = ImGui::GetStyle(); + + size_t num_files = std::count(urls.begin(), urls.end(), '\n'); + std::string file_count = std::format("{}", num_files); + ImVec2 text_size = ImGui::CalcTextSize(file_count.c_str()); + + ImDrawList *draw_list = ImGui::GetWindowDrawList(); + ImVec2 center = pos + (size / 2.0f); + + ImGui::DrawSquare( + (size / 2.0f), size.x / 5.0f, IM_COL32_WHITE, + ImGui::ColorConvertFloat4ToU32(style.Colors[ImGuiCol_HeaderActive]), 1.0f); + + draw_list->AddText(pos + (size / 2.0f) - (text_size / 2.0f), IM_COL32_WHITE, + file_count.c_str(), file_count.c_str() + file_count.size()); + }); } action->setHotSpot(ImVec2((float)pt.x, (float)pt.y)); @@ -286,6 +311,26 @@ namespace Toolbox::UI { if (!action) { MimeData mime_data = createMimeDataFromDataObject(pDataObj); action = DragDropManager::instance().createDragAction(0, std::move(mime_data)); + + action->setRender([action](const ImVec2 &pos, const ImVec2 &size) { + std::string urls = action->getPayload().get_urls().value_or(""); + if (urls.empty()) { + return; + } + + size_t num_files = std::count(urls.begin(), urls.end(), '\n'); + + ImDrawList *draw_list = ImGui::GetBackgroundDrawList(); + ImVec2 center = pos + (size / 2.0f); + + ImGui::DrawSquare(center, size.x / 6.0f, IM_COL32_BLACK, IM_COL32_WHITE, 2.0f); + + std::string file_count = std::format("{}", num_files); + ImVec2 text_size = ImGui::CalcTextSize(file_count.c_str()); + + draw_list->AddText(pos + (size / 2.0f) - (text_size / 2.0f), IM_COL32_WHITE, + file_count.c_str(), file_count.c_str() + file_count.size()); + }); } action->setHotSpot(ImVec2((float)pt.x, (float)pt.y)); @@ -424,7 +469,9 @@ namespace Toolbox::UI { void LinuxDragDropTargetDelegate::onDrop(RefPtr action) {} - bool LinuxDragDropTargetDelegate::initializeForWindow(Platform::LowWindow window) { return false; } + bool LinuxDragDropTargetDelegate::initializeForWindow(Platform::LowWindow window) { + return false; + } void LinuxDragDropTargetDelegate::shutdownForWindow(Platform::LowWindow window) {} From 7f92715d4b57bffacd0bc1989d789cff16939f31 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Wed, 9 Oct 2024 19:29:09 -0500 Subject: [PATCH 086/129] Drag internal wip --- include/gui/dragdrop/dragdropmanager.hpp | 2 +- include/gui/project/window.hpp | 3 ++ src/gui/dragdrop/dragdropmanager.cpp | 13 ++----- src/gui/dragdrop/target.cpp | 2 +- src/gui/project/window.cpp | 47 +++++++++++++++++++++++- 5 files changed, 55 insertions(+), 12 deletions(-) diff --git a/include/gui/dragdrop/dragdropmanager.hpp b/include/gui/dragdrop/dragdropmanager.hpp index e698686d..1aa0a25e 100644 --- a/include/gui/dragdrop/dragdropmanager.hpp +++ b/include/gui/dragdrop/dragdropmanager.hpp @@ -27,7 +27,7 @@ namespace Toolbox::UI { void setSystemAction(bool is_system) { m_is_system_action = is_system; } - RefPtr createDragAction(UUID64 source_uuid, MimeData &&data); + RefPtr createDragAction(UUID64 source_uuid, MimeData &&data, bool system_level = true); RefPtr getCurrentDragAction() const { return m_current_drag_action; } void destroyDragAction(RefPtr action); diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 5c9f6f39..692aa123 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -91,6 +91,7 @@ namespace Toolbox::UI { void onDropEvent(RefPtr ev) override; void buildContextMenu(); + MimeData &&buildFolderViewMimeData(); // Selection actions void actionDeleteIndexes(std::vector &indices); @@ -132,6 +133,8 @@ namespace Toolbox::UI { bool m_delete_without_request = false; bool m_delete_requested = false; + + ImVec2 m_last_reg_mouse_pos; }; } // namespace Toolbox::UI \ No newline at end of file diff --git a/src/gui/dragdrop/dragdropmanager.cpp b/src/gui/dragdrop/dragdropmanager.cpp index 5b9a238d..049824dd 100644 --- a/src/gui/dragdrop/dragdropmanager.cpp +++ b/src/gui/dragdrop/dragdropmanager.cpp @@ -40,9 +40,12 @@ static std::vector splitLines(std::string_view s) { namespace Toolbox::UI { - RefPtr DragDropManager::createDragAction(UUID64 source_uuid, MimeData &&data) { + RefPtr DragDropManager::createDragAction(UUID64 source_uuid, MimeData &&data, bool system_level) { m_current_drag_action = make_referable(source_uuid); m_current_drag_action->setPayload(data); + if (system_level) { + createSystemDragDropSource(std::move(data)); + } return m_current_drag_action; } @@ -56,14 +59,6 @@ namespace Toolbox::UI { void DragDropManager::shutdown() { OleUninitialize(); } Result DragDropManager::createSystemDragDropSource(MimeData &&data) { - std::vector formats = - SystemClipboard::instance().getAvailableContentFormats().value_or( - std::vector()); - - if (std::find(formats.begin(), formats.end(), "text/uri-list") == formats.end()) { - return make_error("DRAG_DROP", "No paths available in mimedata"); - } - std::string paths = data.get_urls().value_or(""); std::vector pidls; diff --git a/src/gui/dragdrop/target.cpp b/src/gui/dragdrop/target.cpp index f04736b4..82b8c4d8 100644 --- a/src/gui/dragdrop/target.cpp +++ b/src/gui/dragdrop/target.cpp @@ -246,7 +246,7 @@ namespace Toolbox::UI { if (!action) { DragDropManager::instance().setSystemAction(true); MimeData mime_data = createMimeDataFromDataObject(pDataObj); - action = DragDropManager::instance().createDragAction(0, std::move(mime_data)); + action = DragDropManager::instance().createDragAction(0, std::move(mime_data), false); DragDropManager::instance().setSystemAction(false); action->setRender([action](const ImVec2 &pos, const ImVec2 &size) { diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index e0e3db1f..ce700ea4 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -1,5 +1,6 @@ #include "gui/project/window.hpp" #include "gui/application.hpp" +#include "gui/dragdrop/dragdropmanager.hpp" #include "model/fsmodel.hpp" #include @@ -37,7 +38,21 @@ namespace Toolbox::UI { const ImGuiStyle &style = ImGui::GetStyle(); - bool is_left_click = Input::GetMouseButtonDown(MouseButton::BUTTON_LEFT); + ImVec2 mouse_pos; + { + double mouse_x, mouse_y; + Input::GetMousePosition(mouse_x, mouse_y); + mouse_pos.x = mouse_x; + mouse_pos.y = mouse_y; + } + + bool is_left_click = Input::GetMouseButtonDown(MouseButton::BUTTON_LEFT); + bool is_left_drag = Input::GetMouseButton(MouseButton::BUTTON_LEFT); + + if (!is_left_drag) { + m_last_reg_mouse_pos = mouse_pos; + } + bool is_double_left_click = ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left); bool is_right_click = Input::GetMouseButtonDown(MouseButton::BUTTON_RIGHT); @@ -84,6 +99,17 @@ namespace Toolbox::UI { ImGui::PushStyleColor(ImGuiCol_ChildBg, ImGui::ColorConvertFloat4ToU32( ImGui::GetStyleColorVec4(ImGuiCol_TabSelected))); + + if (is_left_drag && ImLengthSqr(mouse_pos - m_last_reg_mouse_pos) > 10.0f) { + if (DragDropManager::instance().getCurrentDragAction() == nullptr) { + RefPtr action = DragDropManager::instance().createDragAction( + getUUID(), buildFolderViewMimeData()); + if (action) { + // action->setHotspot() + // action->setImage() + } + } + } } else { ImGui::PushStyleColor(ImGuiCol_ChildBg, ImGui::ColorConvertFloat4ToU32( @@ -429,6 +455,23 @@ namespace Toolbox::UI { }); } + MimeData &&ProjectViewWindow::buildFolderViewMimeData() { + MimeData &&result = MimeData(); + + std::string paths; + for (const ModelIndex &index : m_selected_indices_ctx) { + fs_path path = m_file_system_model->getPath(index); +#ifdef TOOLBOX_PLATFORM_WINDOWS + paths += std::format("file:///{}\n", path.string()); +#elif defined(TOOLBOX_PLATFORM_LINUX) + paths += std::format("file://{}\n", path.string()); +#endif + } + + result.set_urls(paths); + return std::move(result); + } + void ProjectViewWindow::actionDeleteIndexes(std::vector &indices) { for (auto &item_index : indices) { m_file_system_model->remove(item_index); @@ -608,6 +651,8 @@ namespace Toolbox::UI { return true; } + + return false; } bool ProjectViewWindow::actionOpenPad(const ModelIndex &index) { From 581c3cacd1d1b14c5cb5c9ac0c42fd0c79d701f6 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Wed, 9 Oct 2024 19:29:18 -0500 Subject: [PATCH 087/129] UI drag stuff --- include/core/event/event.hpp | 4 +- include/gui/dragdrop/dragaction.hpp | 12 +++ include/gui/event/dragevent.hpp | 10 +++ include/gui/project/window.hpp | 6 +- src/gui/application.cpp | 15 ++++ src/gui/project/window.cpp | 114 +++++++++++++++++++++++----- 6 files changed, 139 insertions(+), 22 deletions(-) diff --git a/include/core/event/event.hpp b/include/core/event/event.hpp index b1563199..8f390bab 100644 --- a/include/core/event/event.hpp +++ b/include/core/event/event.hpp @@ -59,8 +59,8 @@ namespace Toolbox { [[nodiscard]] bool isSystemEvent() const noexcept { return m_is_system_event; } - void accept(); - void ignore(); + virtual void accept(); + virtual void ignore(); ScopePtr clone(bool deep) const override; diff --git a/include/gui/dragdrop/dragaction.hpp b/include/gui/dragdrop/dragaction.hpp index 7c7d1128..78c881f5 100644 --- a/include/gui/dragdrop/dragaction.hpp +++ b/include/gui/dragdrop/dragaction.hpp @@ -10,6 +10,7 @@ namespace Toolbox::UI { class DragAction { friend class DragDropManager; + friend class DragEvent; protected: DragAction() = default; @@ -27,6 +28,13 @@ namespace Toolbox::UI { } } + struct DropState { + bool m_valid_target; + DropType m_pending_action; + }; + + const DropState &getDropState() const { return m_drop_state; } + [[nodiscard]] const ImVec2 &getHotSpot() const { return m_hot_spot; } [[nodiscard]] const MimeData &getPayload() const { return m_mime_data; } @@ -42,9 +50,13 @@ namespace Toolbox::UI { void setTargetUUID(const UUID64 &uuid) { m_target_uuid = uuid; } void setSupportedDropTypes(DropTypes types) { m_supported_drop_types = types; } + protected: + void setDropState(DropState &&state) { m_drop_state = std::move(state); } + private: ImVec2 m_hot_spot; render_fn m_render; + DropState m_drop_state; MimeData m_mime_data; DropType m_default_drop_type = DropType::ACTION_MOVE; diff --git a/include/gui/event/dragevent.hpp b/include/gui/event/dragevent.hpp index 258036fd..6d6d5c51 100644 --- a/include/gui/event/dragevent.hpp +++ b/include/gui/event/dragevent.hpp @@ -23,6 +23,16 @@ namespace Toolbox::UI { [[nodiscard]] RefPtr getDragAction() const noexcept { return m_drag_action; } [[nodiscard]] UUID64 getSourceId() const noexcept { return m_drag_action->getSourceUUID(); } + void accept() override { + BaseEvent::accept(); + m_drag_action->m_drop_state.m_valid_target = true; + } + + void ignore() override { + BaseEvent::ignore(); + m_drag_action->m_drop_state.m_valid_target = false; + } + ScopePtr clone(bool deep) const override; DragEvent &operator=(const DragEvent &) = default; diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 692aa123..6d58e920 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -91,7 +91,7 @@ namespace Toolbox::UI { void onDropEvent(RefPtr ev) override; void buildContextMenu(); - MimeData &&buildFolderViewMimeData(); + MimeData buildFolderViewMimeData() const; // Selection actions void actionDeleteIndexes(std::vector &indices); @@ -102,6 +102,8 @@ namespace Toolbox::UI { void actionLeftClickIndex(const ModelIndex &view_index, const ModelIndex &child_index, bool is_selected); + void actionClearRequestExcIndex(const ModelIndex &view_index, + const ModelIndex &child_index, bool is_left_button); bool actionOpenScene(const ModelIndex &index); bool actionOpenPad(const ModelIndex &index); @@ -134,6 +136,8 @@ namespace Toolbox::UI { bool m_delete_without_request = false; bool m_delete_requested = false; + bool m_did_drag_drop = false; + ImVec2 m_last_reg_mouse_pos; }; diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 6183b41e..7638a37e 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -464,6 +464,8 @@ namespace Toolbox { const ImVec2 size = {96, 96}; const ImVec2 pos = {hotspot.x - size.x / 2.0f, hotspot.y - size.y / 1.1f}; + ImGuiStyle &style = ImGui::GetStyle(); + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); // ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 5.0f); ImGui::PushStyleColor(ImGuiCol_WindowBg, @@ -476,6 +478,19 @@ namespace Toolbox { ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoInputs)) { action->render(size); + ImVec2 status_size = {16, 16}; + ImGui::SetCursorScreenPos(pos + size - status_size); + + ImGui::DrawSquare( + pos + size - (status_size / 2), status_size.x, IM_COL32_WHITE, + ImGui::ColorConvertFloat4ToU32(style.Colors[ImGuiCol_HeaderActive])); + + const DragAction::DropState &state = action->getDropState(); + if (state.m_valid_target) { + + } else { + } + if (ImGuiWindow *win = ImGui::GetCurrentWindow()) { if (win->Viewport != ImGui::GetMainViewport()) { Platform::SetWindowClickThrough( diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index ce700ea4..eaad3363 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -20,6 +20,8 @@ namespace Toolbox::UI { renderProjectFolderView(); renderProjectFolderButton(); renderProjectFileButton(); + + m_did_drag_drop = DragDropManager::instance().getCurrentDragAction() != nullptr; } void ProjectViewWindow::renderProjectTreeView() { @@ -46,8 +48,9 @@ namespace Toolbox::UI { mouse_pos.y = mouse_y; } - bool is_left_click = Input::GetMouseButtonDown(MouseButton::BUTTON_LEFT); - bool is_left_drag = Input::GetMouseButton(MouseButton::BUTTON_LEFT); + bool is_left_click = Input::GetMouseButtonDown(MouseButton::BUTTON_LEFT); + bool is_left_click_release = Input::GetMouseButtonUp(MouseButton::BUTTON_LEFT); + bool is_left_drag = Input::GetMouseButton(MouseButton::BUTTON_LEFT); if (!is_left_drag) { m_last_reg_mouse_pos = mouse_pos; @@ -55,6 +58,7 @@ namespace Toolbox::UI { bool is_double_left_click = ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left); bool is_right_click = Input::GetMouseButtonDown(MouseButton::BUTTON_RIGHT); + bool is_right_click_release = Input::GetMouseButtonUp(MouseButton::BUTTON_RIGHT); if (ImGui::BeginChild("Folder View", {0, 0}, true, ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoDecoration)) { @@ -102,11 +106,39 @@ namespace Toolbox::UI { if (is_left_drag && ImLengthSqr(mouse_pos - m_last_reg_mouse_pos) > 10.0f) { if (DragDropManager::instance().getCurrentDragAction() == nullptr) { - RefPtr action = DragDropManager::instance().createDragAction( - getUUID(), buildFolderViewMimeData()); + RefPtr action = + DragDropManager::instance().createDragAction( + getUUID(), std::move(buildFolderViewMimeData())); if (action) { - // action->setHotspot() - // action->setImage() + action->setHotSpot(mouse_pos); + action->setRender([action](const ImVec2 &pos, + const ImVec2 &size) { + std::string urls = + action->getPayload().get_urls().value_or(""); + if (urls.empty()) { + return; + } + + ImGuiStyle &style = ImGui::GetStyle(); + + size_t num_files = + std::count(urls.begin(), urls.end(), '\n'); + std::string file_count = std::format("{}", num_files); + ImVec2 text_size = ImGui::CalcTextSize(file_count.c_str()); + + ImDrawList *draw_list = ImGui::GetWindowDrawList(); + ImVec2 center = pos + (size / 2.0f); + + ImGui::DrawSquare((size / 2.0f), size.x / 5.0f, + IM_COL32_WHITE, + ImGui::ColorConvertFloat4ToU32( + style.Colors[ImGuiCol_HeaderActive]), + 1.0f); + + draw_list->AddText(pos + (size / 2.0f) - (text_size / 2.0f), + IM_COL32_WHITE, file_count.c_str(), + file_count.c_str() + file_count.size()); + }); } } } @@ -186,9 +218,14 @@ namespace Toolbox::UI { ImGui::PopStyleColor(1); break; } - } else if (is_left_click) { - m_is_renaming = false; - actionLeftClickIndex(view_index, child_index, is_selected); + } else { + if (is_left_click && !is_left_click_release) { + m_is_renaming = false; + actionLeftClickIndex(view_index, child_index, is_selected); + } else if (is_left_click_release || is_right_click_release) { + actionClearRequestExcIndex(view_index, child_index, + is_left_click_release); + } } } } @@ -202,6 +239,11 @@ namespace Toolbox::UI { } } + if (!any_items_hovered && (is_left_click_release || is_right_click_release)) { + actionClearRequestExcIndex(view_index, ModelIndex(), is_left_click_release); + m_is_renaming = false; + } + ImVec2 center = ImGui::GetMainViewport()->GetCenter(); ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f)); @@ -235,11 +277,6 @@ namespace Toolbox::UI { } ImGui::EndPopup(); } else { - // Clearing the selection - if (!any_items_hovered && ImGui::IsMouseClicked(0)) { - m_selected_indices.clear(); - m_is_renaming = false; - } // Delete stuff if (m_delete_requested) { ImGui::OpenPopup("Delete?"); @@ -455,11 +492,11 @@ namespace Toolbox::UI { }); } - MimeData &&ProjectViewWindow::buildFolderViewMimeData() { - MimeData &&result = MimeData(); + MimeData ProjectViewWindow::buildFolderViewMimeData() const { + MimeData result; std::string paths; - for (const ModelIndex &index : m_selected_indices_ctx) { + for (const ModelIndex &index : m_selected_indices) { fs_path path = m_file_system_model->getPath(index); #ifdef TOOLBOX_PLATFORM_WINDOWS paths += std::format("file:///{}\n", path.string()); @@ -469,7 +506,7 @@ namespace Toolbox::UI { } result.set_urls(paths); - return std::move(result); + return result; } void ProjectViewWindow::actionDeleteIndexes(std::vector &indices) { @@ -560,6 +597,10 @@ namespace Toolbox::UI { void ProjectViewWindow::actionLeftClickIndex(const ModelIndex &view_index, const ModelIndex &child_index, bool is_selected) { + if (m_did_drag_drop) { + return; + } + ModelIndex source_child_index = m_view_proxy.toSourceIndex(child_index); if (Input::GetKey(KeyCode::KEY_LEFTCONTROL) || Input::GetKey(KeyCode::KEY_RIGHTCONTROL)) { if (is_selected) { @@ -571,8 +612,8 @@ namespace Toolbox::UI { m_last_selected_index = source_child_index; } } else { - m_selected_indices.clear(); if (Input::GetKey(KeyCode::KEY_LEFTSHIFT) || Input::GetKey(KeyCode::KEY_RIGHTSHIFT)) { + m_selected_indices.clear(); if (m_file_system_model->validateIndex(m_last_selected_index)) { int64_t this_row = m_view_proxy.getRow(child_index); int64_t last_row = @@ -592,12 +633,47 @@ namespace Toolbox::UI { m_selected_indices.push_back(source_child_index); } } else { + if (m_selected_indices.size() < 2) { + m_selected_indices.clear(); + } m_selected_indices.push_back(source_child_index); m_last_selected_index = source_child_index; } } } + void ProjectViewWindow::actionClearRequestExcIndex(const ModelIndex &view_index, + const ModelIndex &child_index, + bool is_left_button) { + if (m_did_drag_drop) { + return; + } + + if (Input::GetKey(KeyCode::KEY_LEFTCONTROL) || Input::GetKey(KeyCode::KEY_RIGHTCONTROL)) { + return; + } + + if (Input::GetKey(KeyCode::KEY_LEFTSHIFT) || Input::GetKey(KeyCode::KEY_RIGHTSHIFT)) { + return; + } + + if (is_left_button) { + m_selected_indices.clear(); + m_last_selected_index = ModelIndex(); + if (m_view_proxy.validateIndex(child_index)) { + ModelIndex source_index = m_view_proxy.toSourceIndex(child_index); + m_selected_indices.push_back(source_index); + m_last_selected_index = source_index; + } + } else { + if (!m_view_proxy.validateIndex(child_index)) { + m_selected_indices.clear(); + m_last_selected_index = ModelIndex(); + } + m_selected_indices_ctx = m_selected_indices; + } + } + bool ProjectViewWindow::actionOpenScene(const ModelIndex &index) { if (!m_file_system_model->validateIndex(index)) { return false; From 3f418e1093a99037c87e3ff5d29cddbe29b80662 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Wed, 9 Oct 2024 21:35:27 -0500 Subject: [PATCH 088/129] Further polish project interactions --- include/gui/project/window.hpp | 2 +- src/gui/project/window.cpp | 141 +++++++++++++++++++-------------- 2 files changed, 84 insertions(+), 59 deletions(-) diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 6d58e920..3a0cb492 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -100,7 +100,7 @@ namespace Toolbox::UI { void actionPasteIntoIndex(const ModelIndex &index, const MimeData &data); void actionCopyIndexes(const std::vector &indices); - void actionLeftClickIndex(const ModelIndex &view_index, const ModelIndex &child_index, + void actionSelectIndex(const ModelIndex &view_index, const ModelIndex &child_index, bool is_selected); void actionClearRequestExcIndex(const ModelIndex &view_index, const ModelIndex &child_index, bool is_left_button); diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index eaad3363..b661eb52 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -56,8 +56,8 @@ namespace Toolbox::UI { m_last_reg_mouse_pos = mouse_pos; } - bool is_double_left_click = ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left); - bool is_right_click = Input::GetMouseButtonDown(MouseButton::BUTTON_RIGHT); + bool is_double_left_click = ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left); + bool is_right_click = Input::GetMouseButtonDown(MouseButton::BUTTON_RIGHT); bool is_right_click_release = Input::GetMouseButtonUp(MouseButton::BUTTON_RIGHT); if (ImGui::BeginChild("Folder View", {0, 0}, true, @@ -74,6 +74,7 @@ namespace Toolbox::UI { ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 3.0f); const float box_width = 76.0f; + const float box_height = 100.0f; const float label_width = box_width - style.WindowPadding.x * 4.0f; ImVec2 size = ImGui::GetContentRegionAvail(); @@ -95,6 +96,9 @@ namespace Toolbox::UI { ModelIndex source_child_index = m_view_proxy.toSourceIndex(child_index); + ImVec2 win_min = ImGui::GetCursorScreenPos(); + ImVec2 win_max = win_min + ImVec2(box_width, box_height); + bool is_selected = std::find(m_selected_indices.begin(), m_selected_indices.end(), source_child_index) != m_selected_indices.end(); @@ -103,50 +107,16 @@ namespace Toolbox::UI { ImGui::PushStyleColor(ImGuiCol_ChildBg, ImGui::ColorConvertFloat4ToU32( ImGui::GetStyleColorVec4(ImGuiCol_TabSelected))); - - if (is_left_drag && ImLengthSqr(mouse_pos - m_last_reg_mouse_pos) > 10.0f) { - if (DragDropManager::instance().getCurrentDragAction() == nullptr) { - RefPtr action = - DragDropManager::instance().createDragAction( - getUUID(), std::move(buildFolderViewMimeData())); - if (action) { - action->setHotSpot(mouse_pos); - action->setRender([action](const ImVec2 &pos, - const ImVec2 &size) { - std::string urls = - action->getPayload().get_urls().value_or(""); - if (urls.empty()) { - return; - } - - ImGuiStyle &style = ImGui::GetStyle(); - - size_t num_files = - std::count(urls.begin(), urls.end(), '\n'); - std::string file_count = std::format("{}", num_files); - ImVec2 text_size = ImGui::CalcTextSize(file_count.c_str()); - - ImDrawList *draw_list = ImGui::GetWindowDrawList(); - ImVec2 center = pos + (size / 2.0f); - - ImGui::DrawSquare((size / 2.0f), size.x / 5.0f, - IM_COL32_WHITE, - ImGui::ColorConvertFloat4ToU32( - style.Colors[ImGuiCol_HeaderActive]), - 1.0f); - - draw_list->AddText(pos + (size / 2.0f) - (text_size / 2.0f), - IM_COL32_WHITE, file_count.c_str(), - file_count.c_str() + file_count.size()); - }); - } - } - } + } else if (ImGui::IsMouseHoveringRect(win_min, win_max)) { + ImGui::PushStyleColor(ImGuiCol_ChildBg, + ImGui::ColorConvertFloat4ToU32( + ImGui::GetStyleColorVec4(ImGuiCol_TabHovered))); } else { ImGui::PushStyleColor(ImGuiCol_ChildBg, ImGui::ColorConvertFloat4ToU32( ImGui::GetStyleColorVec4(ImGuiCol_ChildBg))); } + const bool is_selected_rename = m_is_renaming && is_selected; // Get the label and it's size @@ -158,9 +128,20 @@ namespace Toolbox::UI { ? std::min(rename_size.x, label_width) : std::min(text_size.x, label_width); + ImGuiWindowFlags window_flags = ImGuiWindowFlags_ChildWindow | + ImGuiWindowFlags_NoDecoration | + ImGuiWindowFlags_NoScrollWithMouse; + + if (source_child_index == m_last_selected_index) { + ImGui::GetWindowDrawList()->AddRect( + win_min - (style.FramePadding / 2.0f), + win_max + (style.FramePadding / 2.0f), + ImGui::ColorConvertFloat4ToU32(style.Colors[ImGuiCol_Text]), 3.0f, + ImDrawFlags_RoundCornersAll, 2.0f); + } + if (ImGui::BeginChild(child_index.getUUID(), {box_width, 100.0f}, true, - ImGuiWindowFlags_ChildWindow | - ImGuiWindowFlags_NoDecoration)) { + window_flags)) { ImVec2 pos = ImGui::GetCursorScreenPos() + style.WindowPadding; ImVec2 icon_size = ImVec2(box_width - style.WindowPadding.x * 2.0f, box_width - style.WindowPadding.x * 2.0f); @@ -219,9 +200,10 @@ namespace Toolbox::UI { break; } } else { - if (is_left_click && !is_left_click_release) { + if ((is_left_click && !is_left_click_release) || + (is_right_click && !is_right_click_release)) { m_is_renaming = false; - actionLeftClickIndex(view_index, child_index, is_selected); + actionSelectIndex(view_index, child_index, is_selected); } else if (is_left_click_release || is_right_click_release) { actionClearRequestExcIndex(view_index, child_index, is_left_click_release); @@ -244,6 +226,41 @@ namespace Toolbox::UI { m_is_renaming = false; } + if (any_items_hovered && is_left_drag && m_selected_indices.size() > 0 && + ImLengthSqr(mouse_pos - m_last_reg_mouse_pos) > 10.0f) { + if (DragDropManager::instance().getCurrentDragAction() == nullptr) { + RefPtr action = DragDropManager::instance().createDragAction( + getUUID(), std::move(buildFolderViewMimeData())); + if (action) { + action->setHotSpot(mouse_pos); + action->setRender([action](const ImVec2 &pos, const ImVec2 &size) { + std::string urls = action->getPayload().get_urls().value_or(""); + if (urls.empty()) { + return; + } + + ImGuiStyle &style = ImGui::GetStyle(); + + size_t num_files = std::count(urls.begin(), urls.end(), '\n'); + std::string file_count = std::format("{}", num_files); + ImVec2 text_size = ImGui::CalcTextSize(file_count.c_str()); + + ImDrawList *draw_list = ImGui::GetWindowDrawList(); + ImVec2 center = pos + (size / 2.0f); + + ImGui::DrawSquare((size / 2.0f), size.x / 5.0f, IM_COL32_WHITE, + ImGui::ColorConvertFloat4ToU32( + style.Colors[ImGuiCol_HeaderActive]), + 1.0f); + + draw_list->AddText(pos + (size / 2.0f) - (text_size / 2.0f), + IM_COL32_WHITE, file_count.c_str(), + file_count.c_str() + file_count.size()); + }); + } + } + } + ImVec2 center = ImGui::GetMainViewport()->GetCenter(); ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f)); @@ -595,8 +612,8 @@ namespace Toolbox::UI { } } - void ProjectViewWindow::actionLeftClickIndex(const ModelIndex &view_index, - const ModelIndex &child_index, bool is_selected) { + void ProjectViewWindow::actionSelectIndex(const ModelIndex &view_index, + const ModelIndex &child_index, bool is_selected) { if (m_did_drag_drop) { return; } @@ -606,11 +623,10 @@ namespace Toolbox::UI { if (is_selected) { m_selected_indices.erase(std::remove(m_selected_indices.begin(), m_selected_indices.end(), source_child_index)); - m_last_selected_index = ModelIndex(); } else { m_selected_indices.push_back(source_child_index); - m_last_selected_index = source_child_index; } + m_last_selected_index = source_child_index; } else { if (Input::GetKey(KeyCode::KEY_LEFTSHIFT) || Input::GetKey(KeyCode::KEY_RIGHTSHIFT)) { m_selected_indices.clear(); @@ -633,11 +649,17 @@ namespace Toolbox::UI { m_selected_indices.push_back(source_child_index); } } else { - if (m_selected_indices.size() < 2) { + if (is_selected) { + if (m_selected_indices.size() < 2) { + m_selected_indices.clear(); + m_selected_indices.push_back(source_child_index); + } + m_last_selected_index = source_child_index; + } else { m_selected_indices.clear(); + m_selected_indices.push_back(source_child_index); + m_last_selected_index = source_child_index; } - m_selected_indices.push_back(source_child_index); - m_last_selected_index = source_child_index; } } } @@ -658,12 +680,14 @@ namespace Toolbox::UI { } if (is_left_button) { - m_selected_indices.clear(); - m_last_selected_index = ModelIndex(); - if (m_view_proxy.validateIndex(child_index)) { - ModelIndex source_index = m_view_proxy.toSourceIndex(child_index); - m_selected_indices.push_back(source_index); - m_last_selected_index = source_index; + if (m_selected_indices.size() > 1) { + m_selected_indices.clear(); + m_last_selected_index = ModelIndex(); + if (m_view_proxy.validateIndex(child_index)) { + ModelIndex source_index = m_view_proxy.toSourceIndex(child_index); + m_selected_indices.push_back(source_index); + m_last_selected_index = source_index; + } } } else { if (!m_view_proxy.validateIndex(child_index)) { @@ -671,6 +695,7 @@ namespace Toolbox::UI { m_last_selected_index = ModelIndex(); } m_selected_indices_ctx = m_selected_indices; + m_last_selected_index = ModelIndex(); } } From 7ecd7c1d2b56ae43fe7d0f5459dcb5f98a4544c5 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Fri, 11 Oct 2024 14:28:54 -0700 Subject: [PATCH 089/129] Don't fight the window manager This code assumed that the user had exclusive control over the size and position of all windows. While this is generally true of most window managers, for users with a tiling window manager, this meant that the code was constantly fighting the window manager for control, causing the window to flash back and forth between multiple places. The fix is to not assume that m_is_resized == (window->size != m_prev_size), and instead only try to set the size once when m_is_resized is set to true, and the same for m_is_repositioned and positions. --- src/gui/window.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 5d8f8bbf..aefdd749 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -221,18 +221,20 @@ namespace Toolbox::UI { // Establish window constraints if (window) { - if (window->Size != m_prev_size) { + if (window->Size != m_prev_size && m_is_resized) { if (m_next_size.x >= 0.0f && m_next_size.y >= 0.0f) { GUIApplication::instance().dispatchEvent( getUUID(), EVENT_WINDOW_RESIZE, window->Size); } ImGui::SetWindowSize(window, m_prev_size, ImGuiCond_Always); + m_is_resized = false; } - if (window->Pos != m_prev_pos) { + if (window->Pos != m_prev_pos && m_is_repositioned) { GUIApplication::instance().dispatchEvent( getUUID(), EVENT_WINDOW_MOVE, window->Pos); ImGui::SetWindowPos(window, m_prev_pos, ImGuiCond_Always); + m_is_repositioned = false; } } From 4dde55f3c21f011ce4b7bdc0fb23b0c77651fca0 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Fri, 11 Oct 2024 16:08:58 -0700 Subject: [PATCH 090/129] Reuse the GLFW display connection for everything --- src/core/input/input.cpp | 11 ++++------- src/platform/process.cpp | 10 ++++++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/core/input/input.cpp b/src/core/input/input.cpp index 2438cc70..7c2401e3 100644 --- a/src/core/input/input.cpp +++ b/src/core/input/input.cpp @@ -12,6 +12,8 @@ #elif defined(TOOLBOX_PLATFORM_LINUX) #include #include +#define GLFW_EXPOSE_NATIVE_X11 +#include #else #error "Unsupported OS" #endif @@ -181,16 +183,13 @@ namespace Toolbox::Input { #ifdef TOOLBOX_PLATFORM_WINDOWS SetCursorPos((int)pos_x, (int)pos_y); #elif defined(TOOLBOX_PLATFORM_LINUX) - Display *display = XOpenDisplay(0); - if (display == nullptr) - return; + Display *display = getGLFWDisplay(); float rel_pos_x = s_mouse_position_x - pos_x; float rel_pos_y = s_mouse_position_y - pos_y; XWarpPointer(display, 0, 0, 0, 0, 0, 0, rel_pos_x, rel_pos_y); XFlush(display); - XCloseDisplay(display); #else #error "Unsupported OS" #endif @@ -213,9 +212,7 @@ namespace Toolbox::Input { #elif defined(TOOLBOX_PLATFORM_LINUX) // TODO: Check that this actually works - Display *display = XOpenDisplay(0); - if (display == nullptr) - return; + Display *display = getGLFWDisplay(); Window root = DefaultRootWindow(display); Window child; diff --git a/src/platform/process.cpp b/src/platform/process.cpp index 7d17f783..93efa066 100644 --- a/src/platform/process.cpp +++ b/src/platform/process.cpp @@ -20,6 +20,8 @@ #include #include #include +#define GLFW_EXPOSE_NATIVE_X11 +#include #endif namespace Toolbox::Platform { @@ -326,7 +328,7 @@ namespace Toolbox::Platform { return true; } std::string GetWindowTitle(LowWindow window) { - Display* display = XOpenDisplay(0); + Display* display = getGLFWDisplay(); XTextProperty title; XGetWMName(display, (Window)window, &title); char** stringList; @@ -345,7 +347,7 @@ namespace Toolbox::Platform { return false; } bool ForceWindowToFront(LowWindow window) { - Display* display = XOpenDisplay(0); + Display* display = getGLFWDisplay(); return XRaiseWindow(display, (Window)window); } bool ForceWindowToFront(LowWindow window, LowWindow target) { @@ -360,7 +362,7 @@ namespace Toolbox::Platform { bool GetWindowClientRect(LowWindow window, int &x, int &y, int &width, int &height) { XWindowAttributes attribs; - Display* display = XOpenDisplay(0); + Display* display = getGLFWDisplay(); if (!XGetWindowAttributes(display, (Window)window, &attribs)) { return false; } @@ -374,7 +376,7 @@ namespace Toolbox::Platform { const Atom PIDAtom, const int pid, std::vector &result); std::vector FindWindowsOfProcess(const ProcessInformation &process) { - Display* display = XOpenDisplay(0); + Display* display = getGLFWDisplay(); Atom PIDAtom = XInternAtom(display, "_NET_WM_PID", True); if(PIDAtom == None) From 5c771af12e46a6574ed7892e29ff3cf67f1bbe3b Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Sun, 13 Oct 2024 14:37:45 -0700 Subject: [PATCH 091/129] Oops fix the linux build --- src/platform/process.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/platform/process.cpp b/src/platform/process.cpp index 93efa066..df980289 100644 --- a/src/platform/process.cpp +++ b/src/platform/process.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #define GLFW_EXPOSE_NATIVE_X11 #include #endif From 125bdf059be85b6c7acede4d6fbccc3b35feb586 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Sun, 13 Oct 2024 21:34:47 -0700 Subject: [PATCH 092/129] Set the variables that indicate whether size and pos have changed. --- src/gui/window.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/window.cpp b/src/gui/window.cpp index aefdd749..bcef87c9 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -33,6 +33,7 @@ namespace Toolbox::UI { if (size == getSize()) { return; } + m_is_resized = true; GUIApplication::instance().dispatchEvent(getUUID(), EVENT_WINDOW_RESIZE, size); } @@ -40,6 +41,7 @@ namespace Toolbox::UI { if (pos == getPos()) { return; } + m_is_repositioned = true; GUIApplication::instance().dispatchEvent(getUUID(), EVENT_WINDOW_MOVE, pos); } From 3ba83e3fe90557546b985476e48b3ddc5666392b Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Mon, 14 Oct 2024 10:33:44 -0700 Subject: [PATCH 093/129] Clipboard api refactor (#36) * New clipboard api for linux * Fix some formatting stuff * Add a bunch of comments and refactor a bit * Remove unused undeclared function * Adhere windows implementaiton to new clipboard api * Add getFiles to Windows * Oops weird backslash * Fix incorrect reservation of paths vector * Use references in more places * Simplify this weird conversion back and forth code --- include/core/clipboard.hpp | 6 +- include/core/mimedata/mimedata.hpp | 9 +- include/gui/project/window.hpp | 2 +- include/strutil.hpp | 38 ++- src/core/mimedata/mimedata.cpp | 20 +- src/gui/clipboard.cpp | 373 +++++++++++++++++++---------- src/gui/project/window.cpp | 84 ++----- src/gui/window.cpp | 2 +- 8 files changed, 339 insertions(+), 195 deletions(-) diff --git a/include/core/clipboard.hpp b/include/core/clipboard.hpp index 468b1b1c..a3c7efa4 100644 --- a/include/core/clipboard.hpp +++ b/include/core/clipboard.hpp @@ -7,6 +7,7 @@ #include "core/error.hpp" #include "core/mimedata/mimedata.hpp" #include "tristate.hpp" +#include "fsystem.hpp" namespace Toolbox { @@ -40,8 +41,9 @@ namespace Toolbox { Result getText() const; Result setText(const std::string &text); - Result getContent(const std::string &type) const; - Result setContent(const std::string &type, const MimeData &mimedata); + Result getContent() const; + Result, ClipboardError> getFiles() const; + Result setContent(const MimeData &mimedata); #ifdef TOOLBOX_PLATFORM_WINDOWS diff --git a/include/core/mimedata/mimedata.hpp b/include/core/mimedata/mimedata.hpp index 74c22896..f0565fea 100644 --- a/include/core/mimedata/mimedata.hpp +++ b/include/core/mimedata/mimedata.hpp @@ -59,8 +59,8 @@ namespace Toolbox { [[nodiscard]] std::optional get_text() const; void set_text(std::string_view data); - [[nodiscard]] std::optional get_urls() const; - void set_urls(std::string_view data); + [[nodiscard]] std::optional> get_urls() const; + void set_urls(const std::vector &data); void clear(); @@ -74,6 +74,11 @@ namespace Toolbox { return *this; } + static bool isMimeTarget(const std::string &target) { + return target.starts_with("image/") || target.starts_with("application/") || + target.starts_with("text/"); + } + private: mutable std::unordered_map m_data_map; }; diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index 3a0cb492..dc4a2013 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -97,7 +97,7 @@ namespace Toolbox::UI { void actionDeleteIndexes(std::vector &indices); void actionOpenIndexes(const std::vector &indices); void actionRenameIndex(const ModelIndex &index); - void actionPasteIntoIndex(const ModelIndex &index, const MimeData &data); + void actionPasteIntoIndex(const ModelIndex &index, const std::vector &data); void actionCopyIndexes(const std::vector &indices); void actionSelectIndex(const ModelIndex &view_index, const ModelIndex &child_index, diff --git a/include/strutil.hpp b/include/strutil.hpp index 770e439f..b2a3883d 100644 --- a/include/strutil.hpp +++ b/include/strutil.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "core/error.hpp" @@ -62,5 +63,40 @@ namespace Toolbox::String { inline Result toGameEncoding(std::string_view value) { return asEncoding(value, IMGUI_ENCODING, GAME_ENCODING); } + inline std::vector splitLines(std::string_view s) { + std::vector result; + size_t last_pos = 0; + size_t next_newline_pos = s.find('\n', 0); + while (next_newline_pos != std::string::npos) { + if (s[next_newline_pos - 1] == '\r') { + result.push_back(s.substr(last_pos, next_newline_pos - last_pos - 1)); + } else { + result.push_back(s.substr(last_pos, next_newline_pos - last_pos)); + } + last_pos = next_newline_pos + 1; + next_newline_pos = s.find('\n', last_pos); + } + if (last_pos < s.size()) { + if (s[s.size() - 1] == '\r') { + result.push_back(s.substr(last_pos, s.size() - last_pos - 1)); + } else { + result.push_back(s.substr(last_pos)); + } + } + return result; + } + inline std::string joinStrings(std::vector strings, const char *const delimiter) { + std::ostringstream os; + auto b = strings.begin(), e = strings.end(); -} // namespace Toolbox::String \ No newline at end of file + if (b != e) { + std::copy(b, prev(e), std::ostream_iterator(os, delimiter)); + b = prev(e); + } + if (b != e) { + os << *b; + } + + return os.str(); + } +} // namespace Toolbox::String diff --git a/src/core/mimedata/mimedata.cpp b/src/core/mimedata/mimedata.cpp index 4bef8d12..b56540e1 100644 --- a/src/core/mimedata/mimedata.cpp +++ b/src/core/mimedata/mimedata.cpp @@ -16,6 +16,8 @@ #include "core/mimedata/mimedata.hpp" +#include "strutil.hpp" + namespace Toolbox { static std::vector s_image_formats = { @@ -114,19 +116,25 @@ namespace Toolbox { set_data("text/plain", std::move(_tmp)); } - [[nodiscard]] std::optional MimeData::get_urls() const { + [[nodiscard]] std::optional> MimeData::get_urls() const{ if (!has_urls()) { return std::nullopt; } const Buffer &data_buf = m_data_map["text/uri-list"]; - return std::string(data_buf.buf(), data_buf.size() - 1); + std::string data_string(data_buf.buf(), data_buf.size() - 1); + std::vector result; + for (auto line : splitLines(data_string)) { + result.push_back(std::string(line)); + } + return result; } - void MimeData::set_urls(std::string_view data) { + void MimeData::set_urls(const std::vector &data){ + std::string url_data = joinStrings(data, "\r\n"); Buffer _tmp; - _tmp.alloc(data.size() + 1); - std::memcpy(_tmp.buf(), data.data(), data.size()); - _tmp.get(data.size()) = '\0'; + _tmp.alloc(url_data.size() + 1); + std::memcpy(_tmp.buf(), url_data.data(), url_data.size()); + _tmp.get(url_data.size()) = '\0'; set_data("text/uri-list", std::move(_tmp)); } diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index 12ee12de..4e23a7e9 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -9,6 +9,7 @@ #include #include #define GLFW_EXPOSE_NATIVE_X11 +#include "strutil.hpp" #include #endif @@ -81,6 +82,35 @@ namespace Toolbox { return result; } + // Assume the clipboard contains file paths and return them in a + // vector. Returns a clipboardError if the clipboard doesn't have + // files in it. + Result, ClipboardError> SystemClipboard::getFiles() const { + // Get the file list target. + auto data = getContentType("text/uri-list"); + // If the clipboard doesn't have a file list, propogate the + // error. + if (!data) { + return std::unexpected(data.error()); + } + auto lines = data.value().get_urls(); + // Allocate a vector of paths, and convert the vector of + // strings to it. When doing so, strip off the "file://" + // prefix. + std::vector result((int)lines.size()); + for (int i = 0; i < lines.size(); ++i) { + if (line.starts_with("file:/")) { + if (src_path_str.starts_with("file:///")) { + result[i] = src_path_str.substr(8); + } else { + result[i] = src_path_str.substr(7); + } + } else { + return make_clipboard_error>("Can't copy non file uri"); + } + } + return result; + } Result SystemClipboard::setText(const std::string &text) { if (!OpenClipboard(nullptr)) { @@ -115,20 +145,22 @@ namespace Toolbox { return {}; } - Result SystemClipboard::getContent(const std::string &type) const { + Result + getContentType(std::unordered_map &mime_to_format, + const std::string &type) const { if (!OpenClipboard(nullptr)) { return make_clipboard_error("Failed to open the clipboard!"); } UINT format = CF_NULL; - if (m_mime_to_format.find(type) == m_mime_to_format.end()) { + if (mime_to_format.find(type) == mime_to_format.end()) { format = FormatForMime(type); if (format == CF_NULL) { - m_mime_to_format[type] = RegisterClipboardFormat(type.c_str()); - format = m_mime_to_format[type]; + mime_to_format[type] = RegisterClipboardFormat(type.c_str()); + format = mime_to_format[type]; } } else { - format = m_mime_to_format[type]; + format = mime_to_format[type]; } if (format == CF_NULL) { @@ -208,9 +240,27 @@ namespace Toolbox { return make_clipboard_error("Unimplemented MIME type!"); } + Result SystemClipboard::getContent(const std::string &type) const { + // Figure out all possible formats the content can be in. + auto formats = getAvailableContentFormats(); + // If that didn't work, propogate the error. + if (!formats) { + return std::unexpected(formats.error()); + } + // For each possible data type... + MimeData result; + for (std::string &target : formats.value()) { + // Get the target of each type. + auto data = getContenttype(target, m_mime_to_format); + if (!data) { + return std::unexpected(data.error()); + } + result.set_data(target, std::move(data.value().get_data(target).value())); + } + return result; + } - Result SystemClipboard::setContent(const std::string &type, - const MimeData &mimedata) { + Result SystemClipboard::setContent(const MimeData &mimedata) { if (!OpenClipboard(nullptr)) { return make_clipboard_error("Failed to open the clipboard!"); } @@ -219,7 +269,13 @@ namespace Toolbox { return make_clipboard_error("Failed to clear the clipboard!"); } - std::optional result = mimedata.get_data(type); + std::vector formats = mimedata.get_all_formats(); + if (formats.size() > 1) { + return make_clipboard_error("Can't set clipboard to mulitple types at once on Windows!"); + } + TOOLBOX_ASSERT(formats.size() > 0); + + std::optional result = mimedata.get_data(formats[0]); if (!result) { return make_clipboard_error( std::format("Failed to find MIME data type \"{}\"", type)); @@ -388,7 +444,7 @@ namespace Toolbox { void (*glfwSelectionRequestHandler)(XEvent *); // Sends a notification that we're done responding to a given // request. - void sendRequestNotify(Display* dpy, const XSelectionRequestEvent *request) { + void sendRequestNotify(Display *dpy, const XSelectionRequestEvent *request) { XSelectionEvent response; response.type = SelectionNotify; response.requestor = request->requestor; @@ -408,18 +464,18 @@ namespace Toolbox { // instance. This function can't be a method on that object // because we're going to be passing it as a function pointer // into GLFW, so we have to do everything externally. - MimeData clipboard_contents = SystemClipboard::instance().m_clipboard_contents; + MimeData clipboard_contents = SystemClipboard::instance().m_clipboard_contents; // Get the display object from GLFW so we can intern our // strings in its namespace. - Display *dpy = getGLFWDisplay(); + Display *dpy = getGLFWDisplay(); // Pull out the specific event from the general one. const XSelectionRequestEvent *request = &event->xselectionrequest; // Start our targets array with just the "TARGET" target, // since we'll generate the rest in a loop. - Atom TARGETS = XInternAtom(dpy, "TARGETS", False); - // If they + Atom TARGETS = XInternAtom(dpy, "TARGETS", False); if (request->target == TARGETS) { - std::vector targets = {TARGETS}; + // If they requested the targets... + std::vector targets = {TARGETS}; // For each format the selection data supports, intern it into // an atom and add it to the targets array. for (auto &string_format : clipboard_contents.get_all_formats()) { @@ -447,7 +503,8 @@ namespace Toolbox { // Then set the property, and notify of a response. XChangeProperty(dpy, request->requestor, request->property, request->target, 8 /* is this ever wrong? */, PropModeReplace, - reinterpret_cast(data.value().buf()), data.value().size()); + reinterpret_cast(data.value().buf()), + data.value().size()); sendRequestNotify(dpy, request); } else { // If we don't recognize the data, or it's a legacy @@ -469,136 +526,208 @@ namespace Toolbox { // Set our handler as the new handler. setSelectionRequestHandler(handleSelectionRequest); } + // Requests that the selection owner send us the data in the + // `target` format, by putting it on the `target_property` + // property of the `target_window` window. + void requestTarget(std::string target, Window target_window, Atom target_property) { + Display *dpy = getGLFWDisplay(); + Atom requested_target = XInternAtom(dpy, target.c_str(), False); + Atom sel = XInternAtom(dpy, "CLIPBOARD", False); + XConvertSelection(dpy, sel, requested_target, target_property, target_window, CurrentTime); + } + // Get all possible content types for the system clipboard. Result, ClipboardError> SystemClipboard::getAvailableContentFormats() const { Display *dpy = getGLFWDisplay(); - Atom sel = XInternAtom(dpy, "CLIPBOARD", False); - Atom targets = XInternAtom(dpy, "TARGETS", False); - Atom target_property = XInternAtom(dpy, "CLIP_TYPES", False); Window target_window = getGLFWHelperWindow(); - XConvertSelection(dpy, sel, targets, target_property, target_window, CurrentTime); + Atom target_property = XInternAtom(dpy, "CLIP", False); + // Request that the "TARGETS" info be sent to the CLIP + // property on the glfw helper window. + requestTarget("TARGETS", target_window, target_property); + // Keep waiting for X events until we get a SelectionNotify XEvent ev; - XSelectionEvent *sev; - // This unconditional while loop looks pretty dangerous but - // this is how glfw does it, and how the examples online do - // it, so :shrug: - while (true) { + while (ev.type != SelectionNotify) { XNextEvent(dpy, &ev); - switch (ev.type) { - case SelectionNotify: - sev = (XSelectionEvent *)&ev.xselection; - if (sev->property == None) { - return make_clipboard_error>( - "Conversion could not be performed.\n"); - } else { - std::vector types; - unsigned long nitems; - unsigned char *prop_ret = nullptr; - // We won't use these. - Atom _type; - int _di; - unsigned long _dul; - XGetWindowProperty(dpy, target_window, target_property, 0, 1024 * sizeof(Atom), - False, XA_ATOM, &_type, &_di, &nitems, &_dul, &prop_ret); - - Atom *targets = (Atom *)prop_ret; - for (int i = 0; i < nitems; ++i) { - char *an = XGetAtomName(dpy, targets[i]); - types.push_back(std::string(an)); - if (an) - XFree(an); - } - XFree(prop_ret); - XDeleteProperty(dpy, target_window, target_property); - return types; - } - break; - } } - return {}; + XSelectionEvent *sev = &ev.xselection; + // We can only copy from clients that give us a property to + // put the data on. + if (sev->property == None) { + return make_clipboard_error>( + "Conversion could not be performed.\n"); + } + // Get the value on the property that the source told us. + std::vector types; + unsigned long nitems; + unsigned char *prop_ret = nullptr; + // We won't use these. + Atom _type; + int _di; + unsigned long _dul; + XGetWindowProperty(dpy, target_window, target_property, 0, 1024 * sizeof(Atom), False, + XA_ATOM, &_type, &_di, &nitems, &_dul, &prop_ret); + + // Iterate through the returned atoms and convert them + // into strings to return. + Atom *targets = (Atom *)prop_ret; + for (int i = 0; i < nitems; ++i) { + char *an = XGetAtomName(dpy, targets[i]); + types.push_back(std::string(an)); + if (an) + XFree(an); + } + // Free up the X11 resources we used. + XFree(prop_ret); + XDeleteProperty(dpy, target_window, target_property); + return types; } - Result SystemClipboard::getText() const { - auto data = getContent("text/plain"); - if (!data || !data.value().has_text()) { - return make_clipboard_error("No text in clipboard!"); + + // Get the bytes corresponding to a particular target. This is a + // higher-level function than requestTarget, which only sends the + // request and doesn't return anything. + Result getTarget(std::string target) { + // Request the target from the clipboard owner. + Display *dpy = getGLFWDisplay(); + Window target_window = getGLFWHelperWindow(); + Atom target_property = XInternAtom(dpy, "CLIP", False); + requestTarget(target, target_window, target_property); + + // Keep waiting for X events until we get a SelectionNotify + XEvent ev; + while (ev.type != SelectionNotify) { + XNextEvent(dpy, &ev); } - return data.value().get_text().value(); + XSelectionEvent *sev = &ev.xselection; + // Throw an error on old clients who don't tell you where they + // put stuff. + if (sev->property == None) { + return make_clipboard_error("Conversion could not be performed."); + } + Atom type_received; + unsigned long size; + unsigned char *prop_ret = nullptr; + // These are unused + int _di; + unsigned long _dul; + Atom _da; + + // Use an initial X11 request to figure out how big the data is + // and whether it's requesting multiple batches. + XGetWindowProperty(dpy, target_window, target_property, 0, 0, False, AnyPropertyType, + &type_received, &_di, &_dul, &size, &prop_ret); + // Don't use the return data, it's zero sized anyway. + XFree(prop_ret); + + // If the data needs multiple batches, throw an error for now. + Atom incr = XInternAtom(dpy, "INCR", False); + if (type_received == incr) { + return make_clipboard_error("Data over 256kb, this isn't supported yet"); + } + // Request that X11 copy the property data to an internal + // buffer and put a pointer to that buffer in prop_ret, using + // the size we got earlier. + XGetWindowProperty(dpy, target_window, target_property, 0, size, False, AnyPropertyType, + &_da, &_di, &_dul, &_dul, &prop_ret); + // Allocate our own Buffer object and copy the data into + // it. Make sure to null-terminate the data in case it's a + // c string (which it often is). + Buffer data_buffer; + if (!data_buffer.alloc(size + 1)) { + return make_clipboard_error("Couldn't allocate buffer of big enough size"); + } + std::memcpy(data_buffer.buf(), prop_ret, size); + data_buffer.buf()[size] = '\0'; + // Free the X11 data buffer + XFree(prop_ret); + // Free the window property + XDeleteProperty(dpy, target_window, target_property); + return data_buffer; + } + // Assume the clipboard has plain text and return it as a + // string. Returns a ClipboardError if the clipboard doesn't have + // plain text. + Result SystemClipboard::getText() const { + // Request the plain text target from the clipboard owner. + auto data = getTarget("text/plain"); + // If the clipboard doesn't have plain text, propogate the + // error. + if (!data) { + return std::unexpected(data.error()); + } + // Reinterpret the received buffer as a c-string, then wrap it + // in a c++ string to return. + return std::string(reinterpret_cast(data.value().buf())); } + // Set the contents of the cilpboard to the given string. This + // can't fail at this step on Linux, but we return Result to be + // consistent with the Windows code. Result SystemClipboard::setText(const std::string &text) { MimeData data; data.set_text(text); - return setContent("text/plain", data); + return setContent(data); + } + // Assume the clipboard contains file paths and return them in a + // vector. Returns a clipboardError if the clipboard doesn't have + // files in it. + Result, ClipboardError> SystemClipboard::getFiles() const { + // Get the file list target. + auto data = getTarget("text/uri-list"); + // If the clipboard doesn't have a file list, propogate the + // error. + if (!data) { + return std::unexpected(data.error()); + } + // Reinterpret the received buffer as a c-string, then wrap it + // in a c++ string. + std::string data_string(data.value().buf()); + // Split the string into lines, one for each path. + auto lines = String::splitLines(data_string); + // Allocate a vector of paths, and convert the vector of + // strings to it. When doing so, strip off the "file://" + // prefix. + std::vector result((int)lines.size()); + for (int i = 0; i < lines.size(); ++i) { + if (!lines[i].starts_with("file:///")) { + TOOLBOX_ERROR_V("Can't copy non-local uri \"{}\"", lines[i]); + } + result[i] = lines[i].substr(7); + } + return result; } // Get the contents of the system clipboard. - Result SystemClipboard::getContent(const std::string &type) const { - Display *dpy = getGLFWDisplay(); - Atom requested_type = XInternAtom(dpy, type.c_str(), False); - Atom sel = XInternAtom(dpy, "CLIPBOARD", False); - Window clipboard_owner = XGetSelectionOwner(dpy, sel); - if (clipboard_owner == None) { - return make_clipboard_error("Clipboard isn't owned by anyone"); - } - Window target_window = getGLFWHelperWindow(); - Atom target_property = XInternAtom(dpy, "CLIP_CONTENTS", False); - XConvertSelection(dpy, sel, requested_type, target_property, target_window, CurrentTime); - XEvent ev; - XSelectionEvent *sev; - // This unconditional while loop looks pretty dangerous but - // this is how glfw does it, and how the examples online do - // it, so :shrug: - while (true) { - XNextEvent(dpy, &ev); - switch (ev.type) { - case SelectionNotify: - sev = (XSelectionEvent *)&ev.xselection; - if (sev->property == None) { - return make_clipboard_error("Conversion could not be performed."); - } else { - Atom type_received; - unsigned long size; - unsigned char *prop_ret = nullptr; - // These are unused - int _di; - unsigned long _dul; - Atom _da; - - XGetWindowProperty(dpy, target_window, target_property, 0, 0, False, - AnyPropertyType, &type_received, &_di, &_dul, &size, - &prop_ret); - XFree(prop_ret); - - Atom incr = XInternAtom(dpy, "INCR", False); - if (type_received == incr) { - return make_clipboard_error( - "Data over 256kb, this isn't supported yet"); - } - XGetWindowProperty(dpy, target_window, target_property, 0, size, False, - AnyPropertyType, &_da, &_di, &_dul, &_dul, &prop_ret); - Buffer data_buffer; - if (!data_buffer.alloc(size)) { - return make_clipboard_error( - "Couldn't allocate buffer of big enough size"); - } - std::memcpy(data_buffer.buf(), prop_ret, size); - XFree(prop_ret); - XDeleteProperty(dpy, target_window, target_property); - - MimeData result; - result.set_data(type, std::move(data_buffer)); - return result; - } + Result SystemClipboard::getContent() const { + // Figure out all possible formats the content can be in. + auto formats = getAvailableContentFormats(); + // If that didn't work, propogate the error. + if (!formats) { + return std::unexpected(formats.error()); + } + // For each possible data type... + MimeData result; + for (std::string &target : formats.value()) { + // Skip targets that aren't MIME types. These will pretty + // much always be redundant with a mime-type target + // (except TARGETS, which we don't want to do here anyway. + if (!MimeData::isMimeTarget(target)) + continue; + // Get the target of each type. + auto data = getTarget(target); + if (!data) { + return std::unexpected(data.error()); } + // Put that into the returned mime data indexed by the + // type. + result.set_data(target, std::move(data.value())); } - return {}; + return result; } // Set the contents of the system clipboard. - Result SystemClipboard::setContent(const std::string &_type, - const MimeData &content) { + Result SystemClipboard::setContent(const MimeData &content) { // Get the display and helper window from GLFW using our custom hooks. Display *dpy = getGLFWDisplay(); Window target_window = getGLFWHelperWindow(); @@ -607,7 +736,7 @@ namespace Toolbox { // Set ourselves as the owner of the clipboard. We'll do all // the actual data transfer once someone asks us for data, in // our event handling hook. - Atom CLIPBOARD = XInternAtom(dpy, "CLIPBOARD", False); + Atom CLIPBOARD = XInternAtom(dpy, "CLIPBOARD", False); XSetSelectionOwner(dpy, CLIPBOARD, target_window, CurrentTime); return {}; } diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index b661eb52..bc1a250c 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -356,31 +356,19 @@ namespace Toolbox::UI { } void ProjectViewWindow::onDropEvent(RefPtr ev) { - actionPasteIntoIndex(m_view_index, ev->getMimeData()); - ev->accept(); - } - - std::vector splitLines(std::string_view s) { - std::vector result; - size_t last_pos = 0; - size_t next_newline_pos = s.find('\n', 0); - while (next_newline_pos != std::string::npos) { - if (s[next_newline_pos - 1] == '\r') { - result.push_back(s.substr(last_pos, next_newline_pos - last_pos - 1)); - } else { - result.push_back(s.substr(last_pos, next_newline_pos - last_pos)); - } - last_pos = next_newline_pos + 1; - next_newline_pos = s.find('\n', last_pos); + MimeData data = ev->getMimeData(); + auto urls = data.get_urls(); + if (!urls) { + TOOLBOX_ERROR("Passed mime data did not represent files!"); + return; } - if (last_pos < s.size()) { - if (s[s.size() - 1] == '\r') { - result.push_back(s.substr(last_pos, s.size() - last_pos - 1)); - } else { - result.push_back(s.substr(last_pos)); - } + std::vector paths; + paths.reserve(urls.value().size()); + for (auto &url : urls.value()) { + paths.push_back(url); } - return result; + actionPasteIntoIndex(m_view_index, paths); + ev->accept(); } void ProjectViewWindow::buildContextMenu() { @@ -492,9 +480,9 @@ namespace Toolbox::UI { std::string("text/uri-list")) == content_types.value().end()) { return; } + auto maybe_data = SystemClipboard::instance().getFiles(); - MimeData data = - SystemClipboard::instance().getContent("text/uri-list").value_or(MimeData()); + std::vector data = maybe_data.value(); actionPasteIntoIndex(m_view_index, data); }); @@ -559,54 +547,30 @@ namespace Toolbox::UI { std::strncpy(m_rename_buffer, file_name.c_str(), IM_ARRAYSIZE(m_rename_buffer)); } - void ProjectViewWindow::actionPasteIntoIndex(const ModelIndex &index, const MimeData &data) { - std::optional text = data.get_urls(); - if (!text) { - TOOLBOX_ERROR("Mime data wouldn't return uri list"); - return; - } - - std::vector urls = splitLines(text.value()); - for (std::string_view src_path_str : urls) { - if (src_path_str.starts_with("file:/")) { -#ifdef TOOLBOX_PLATFORM_LINUX - src_path_str = src_path_str.substr(7); -#elif defined TOOLBOX_PLATFORM_WINDOWS - if (src_path_str.starts_with("file:///")) { - src_path_str = src_path_str.substr(8); - } else { - src_path_str = src_path_str.substr(7); - } -#endif - } else { - TOOLBOX_ERROR_V("Can't copy non-local uri {}", src_path_str); - continue; - } - - fs_path src_path = src_path_str; - m_file_system_model->copy(src_path, index, src_path.filename().string()); + void ProjectViewWindow::actionPasteIntoIndex(const ModelIndex &index, + const std::vector &paths) { + for (fs_path &src_path : paths) { + m_file_system_model->copy(src_path, index, + src_path.filename().string()); } } void ProjectViewWindow::actionCopyIndexes(const std::vector &indices) { - std::string copied_paths; + + std::vector copied_paths; for (const ModelIndex &index : indices) { #ifdef TOOLBOX_PLATFORM_LINUX - copied_paths += "file://"; + const char *prefix = "file://"; #elif defined TOOLBOX_PLATFORM_WINDOWS - copied_paths += "file:///"; -#endif - copied_paths += m_file_system_model->getPath(index).string(); -#ifdef TOOLBOX_PLATFORM_LINUX - copied_paths += "\r"; + const char *prefix = "file:///"; #endif - copied_paths += "\n"; + copied_paths.push_back(prefix + m_file_system_model->getPath(index).string()); } MimeData data; data.set_urls(copied_paths); - auto result = SystemClipboard::instance().setContent("text/uri-list", data); + auto result = SystemClipboard::instance().setContent(data); if (!result) { TOOLBOX_ERROR("[PROJECT] Failed to set contents of clipboard"); } diff --git a/src/gui/window.cpp b/src/gui/window.cpp index bcef87c9..53af641b 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -301,4 +301,4 @@ namespace Toolbox::UI { return t; } -} // namespace Toolbox::UI \ No newline at end of file +} // namespace Toolbox::UI From f722dd35536ff8f20b78d66e8ff9deb7cfc53a76 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Mon, 14 Oct 2024 13:14:37 -0700 Subject: [PATCH 094/129] Fix up project-system to use new clipboard api --- src/gui/project/window.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index bc1a250c..6a8a3c39 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -234,14 +234,15 @@ namespace Toolbox::UI { if (action) { action->setHotSpot(mouse_pos); action->setRender([action](const ImVec2 &pos, const ImVec2 &size) { - std::string urls = action->getPayload().get_urls().value_or(""); - if (urls.empty()) { + auto urls_maybe = action->getPayload().get_urls(); + if (!urls_maybe) { return; } + std::vector urls = urls_maybe.value(); ImGuiStyle &style = ImGui::GetStyle(); - size_t num_files = std::count(urls.begin(), urls.end(), '\n'); + size_t num_files = urls.size(); std::string file_count = std::format("{}", num_files); ImVec2 text_size = ImGui::CalcTextSize(file_count.c_str()); @@ -500,14 +501,9 @@ namespace Toolbox::UI { MimeData ProjectViewWindow::buildFolderViewMimeData() const { MimeData result; - std::string paths; + std::vector paths; for (const ModelIndex &index : m_selected_indices) { - fs_path path = m_file_system_model->getPath(index); -#ifdef TOOLBOX_PLATFORM_WINDOWS - paths += std::format("file:///{}\n", path.string()); -#elif defined(TOOLBOX_PLATFORM_LINUX) - paths += std::format("file://{}\n", path.string()); -#endif + paths.push_back(m_file_system_model->getPath(index)); } result.set_urls(paths); @@ -549,7 +545,7 @@ namespace Toolbox::UI { void ProjectViewWindow::actionPasteIntoIndex(const ModelIndex &index, const std::vector &paths) { - for (fs_path &src_path : paths) { + for (const fs_path &src_path : paths) { m_file_system_model->copy(src_path, index, src_path.filename().string()); } From dd129ca00754b04312b55a8ff5e972b8b14240b4 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Mon, 14 Oct 2024 15:35:02 -0700 Subject: [PATCH 095/129] Fixes for the windows code in clipboard api --- src/gui/clipboard.cpp | 193 ++++++++++++++++++------------------ src/gui/dragdrop/target.cpp | 21 ++-- src/gui/project/window.cpp | 2 +- 3 files changed, 108 insertions(+), 108 deletions(-) diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index 4e23a7e9..b751806e 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -54,96 +54,6 @@ namespace Toolbox { return types; } - Result SystemClipboard::getText() const { - if (!OpenClipboard(nullptr)) { - return make_clipboard_error("Failed to open the clipboard!"); - } - - HANDLE clipboard_data = GetClipboardData(CF_TEXT); - if (!clipboard_data) { - return make_clipboard_error("Failed to retrieve the data handle!"); - } - - const char *text_data = static_cast(GlobalLock(clipboard_data)); - if (!text_data) { - return make_clipboard_error( - "Failed to retrieve the buffer from the handle!"); - } - - std::string result = text_data; - - if (!GlobalUnlock(clipboard_data)) { - return make_clipboard_error("Failed to unlock the data handle!"); - } - - if (!CloseClipboard()) { - return make_clipboard_error("Failed to close the clipboard!"); - } - - return result; - } - // Assume the clipboard contains file paths and return them in a - // vector. Returns a clipboardError if the clipboard doesn't have - // files in it. - Result, ClipboardError> SystemClipboard::getFiles() const { - // Get the file list target. - auto data = getContentType("text/uri-list"); - // If the clipboard doesn't have a file list, propogate the - // error. - if (!data) { - return std::unexpected(data.error()); - } - auto lines = data.value().get_urls(); - // Allocate a vector of paths, and convert the vector of - // strings to it. When doing so, strip off the "file://" - // prefix. - std::vector result((int)lines.size()); - for (int i = 0; i < lines.size(); ++i) { - if (line.starts_with("file:/")) { - if (src_path_str.starts_with("file:///")) { - result[i] = src_path_str.substr(8); - } else { - result[i] = src_path_str.substr(7); - } - } else { - return make_clipboard_error>("Can't copy non file uri"); - } - } - return result; - } - - Result SystemClipboard::setText(const std::string &text) { - if (!OpenClipboard(nullptr)) { - return make_clipboard_error("Failed to open the clipboard!"); - } - - if (!EmptyClipboard()) { - return make_clipboard_error("Failed to clear the clipboard!"); - } - - HANDLE data_handle = GlobalAlloc(GMEM_DDESHARE, text.size() + 1); - if (!data_handle) { - return make_clipboard_error("Failed to alloc new data handle!"); - } - - char *data_buffer = static_cast(GlobalLock(data_handle)); - if (!data_buffer) { - return make_clipboard_error("Failed to retrieve the buffer from the handle!"); - } - - strncpy_s(data_buffer, text.size() + 1, text.c_str(), text.size() + 1); - - if (!GlobalUnlock(data_handle)) { - return make_clipboard_error("Failed to unlock the data handle!"); - } - - SetClipboardData(CF_TEXT, data_handle); - - if (!CloseClipboard()) { - return make_clipboard_error("Failed to close the clipboard!"); - } - return {}; - } Result getContentType(std::unordered_map &mime_to_format, @@ -197,15 +107,13 @@ namespace Toolbox { if (format == CF_HDROP) { HDROP hdrop = static_cast(data_handle); UINT num_files = DragQueryFile(hdrop, 0xFFFFFFFF, nullptr, 0); - std::string uri_list; + std::vector uri_list; + uri_list.reserve(num_files); for (UINT i = 0; i < num_files; ++i) { UINT size = DragQueryFile(hdrop, i, nullptr, 0); std::string file(size, '\0'); DragQueryFile(hdrop, i, file.data(), size + 1); - uri_list += std::format("file:///{}", file); - if (i != num_files - 1) { - uri_list += "\r\n"; - } + uri_list.push_back(file); } if (!GlobalUnlock(clipboard_data)) { @@ -240,7 +148,98 @@ namespace Toolbox { return make_clipboard_error("Unimplemented MIME type!"); } - Result SystemClipboard::getContent(const std::string &type) const { + Result SystemClipboard::getText() const { + if (!OpenClipboard(nullptr)) { + return make_clipboard_error("Failed to open the clipboard!"); + } + + HANDLE clipboard_data = GetClipboardData(CF_TEXT); + if (!clipboard_data) { + return make_clipboard_error("Failed to retrieve the data handle!"); + } + + const char *text_data = static_cast(GlobalLock(clipboard_data)); + if (!text_data) { + return make_clipboard_error( + "Failed to retrieve the buffer from the handle!"); + } + + std::string result = text_data; + + if (!GlobalUnlock(clipboard_data)) { + return make_clipboard_error("Failed to unlock the data handle!"); + } + + if (!CloseClipboard()) { + return make_clipboard_error("Failed to close the clipboard!"); + } + + return result; + } + // Assume the clipboard contains file paths and return them in a + // vector. Returns a clipboardError if the clipboard doesn't have + // files in it. + Result, ClipboardError> SystemClipboard::getFiles() const { + // Get the file list target. + auto data = getContentType(m_mime_to_format, "text/uri-list"); + // If the clipboard doesn't have a file list, propogate the + // error. + if (!data) { + return std::unexpected(data.error()); + } + auto lines = data.value().get_urls().value(); + // Allocate a vector of paths, and convert the vector of + // strings to it. When doing so, strip off the "file://" + // prefix. + std::vector result; + result.reserve((int)lines.size()); + for (auto &line : lines) { + if (line.starts_with("file:/")) { + if (line.starts_with("file:///")) { + result.push_back(line.substr(8)); + } else { + result.push_back(line.substr(7)); + } + } else { + return make_clipboard_error>("Can't copy non file uri"); + } + } + return result; + } + + Result SystemClipboard::setText(const std::string &text) { + if (!OpenClipboard(nullptr)) { + return make_clipboard_error("Failed to open the clipboard!"); + } + + if (!EmptyClipboard()) { + return make_clipboard_error("Failed to clear the clipboard!"); + } + + HANDLE data_handle = GlobalAlloc(GMEM_DDESHARE, text.size() + 1); + if (!data_handle) { + return make_clipboard_error("Failed to alloc new data handle!"); + } + + char *data_buffer = static_cast(GlobalLock(data_handle)); + if (!data_buffer) { + return make_clipboard_error("Failed to retrieve the buffer from the handle!"); + } + + strncpy_s(data_buffer, text.size() + 1, text.c_str(), text.size() + 1); + + if (!GlobalUnlock(data_handle)) { + return make_clipboard_error("Failed to unlock the data handle!"); + } + + SetClipboardData(CF_TEXT, data_handle); + + if (!CloseClipboard()) { + return make_clipboard_error("Failed to close the clipboard!"); + } + return {}; + } + Result SystemClipboard::getContent() const { // Figure out all possible formats the content can be in. auto formats = getAvailableContentFormats(); // If that didn't work, propogate the error. @@ -251,7 +250,7 @@ namespace Toolbox { MimeData result; for (std::string &target : formats.value()) { // Get the target of each type. - auto data = getContenttype(target, m_mime_to_format); + auto data = getContentType(m_mime_to_format, target); if (!data) { return std::unexpected(data.error()); } diff --git a/src/gui/dragdrop/target.cpp b/src/gui/dragdrop/target.cpp index 82b8c4d8..d3619524 100644 --- a/src/gui/dragdrop/target.cpp +++ b/src/gui/dragdrop/target.cpp @@ -72,17 +72,17 @@ namespace Toolbox::UI { } } - std::string uri_paths; + std::vector uri_paths; HDROP hdrop = (HDROP)GlobalLock(stg_medium.hGlobal); if (hdrop) { UINT num_files = DragQueryFile(hdrop, 0xFFFFFFFF, nullptr, 0); + uri_paths.reserve(num_files); for (UINT i = 0; i < num_files; ++i) { TCHAR file_path[MAX_PATH]; if (UINT length = DragQueryFile(hdrop, i, file_path, MAX_PATH)) { - uri_paths += - std::format("file:///{}\n", std::string(file_path, length)); + uri_paths.push_back(std::string(file_path, length)); } } } @@ -250,14 +250,15 @@ namespace Toolbox::UI { DragDropManager::instance().setSystemAction(false); action->setRender([action](const ImVec2 &pos, const ImVec2 &size) { - std::string urls = action->getPayload().get_urls().value_or(""); - if (urls.empty()) { + auto maybe_urls = action->getPayload().get_urls(); + if (!maybe_urls) { return; } + std::vector urls = maybe_urls.value(); ImGuiStyle &style = ImGui::GetStyle(); - size_t num_files = std::count(urls.begin(), urls.end(), '\n'); + size_t num_files = urls.size(); std::string file_count = std::format("{}", num_files); ImVec2 text_size = ImGui::CalcTextSize(file_count.c_str()); @@ -313,12 +314,12 @@ namespace Toolbox::UI { action = DragDropManager::instance().createDragAction(0, std::move(mime_data)); action->setRender([action](const ImVec2 &pos, const ImVec2 &size) { - std::string urls = action->getPayload().get_urls().value_or(""); - if (urls.empty()) { + auto maybe_urls = action->getPayload().get_urls(); + if (!maybe_urls) { return; } - size_t num_files = std::count(urls.begin(), urls.end(), '\n'); + size_t num_files = maybe_urls.value().size(); ImDrawList *draw_list = ImGui::GetBackgroundDrawList(); ImVec2 center = pos + (size / 2.0f); @@ -477,4 +478,4 @@ namespace Toolbox::UI { #endif -} // namespace Toolbox::UI \ No newline at end of file +} // namespace Toolbox::UI diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 6a8a3c39..e5e29dba 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -503,7 +503,7 @@ namespace Toolbox::UI { std::vector paths; for (const ModelIndex &index : m_selected_indices) { - paths.push_back(m_file_system_model->getPath(index)); + paths.push_back(m_file_system_model->getPath(index).string()); } result.set_urls(paths); From 675f576c4839b2d4c204dceb219151d8347e5e87 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Mon, 14 Oct 2024 18:09:16 -0700 Subject: [PATCH 096/129] Oops fix some more windows issues I swear my VS in VM compiled fine before this, but these are definitely problems. --- src/gui/clipboard.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index b751806e..96af5104 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -57,14 +57,14 @@ namespace Toolbox { Result getContentType(std::unordered_map &mime_to_format, - const std::string &type) const { + const std::string &type) { if (!OpenClipboard(nullptr)) { return make_clipboard_error("Failed to open the clipboard!"); } UINT format = CF_NULL; if (mime_to_format.find(type) == mime_to_format.end()) { - format = FormatForMime(type); + format = SystemClipboard::FormatForMime(type); if (format == CF_NULL) { mime_to_format[type] = RegisterClipboardFormat(type.c_str()); format = mime_to_format[type]; @@ -273,8 +273,9 @@ namespace Toolbox { return make_clipboard_error("Can't set clipboard to mulitple types at once on Windows!"); } TOOLBOX_ASSERT(formats.size() > 0); + auto type = formats[0]; - std::optional result = mimedata.get_data(formats[0]); + std::optional result = mimedata.get_data(type); if (!result) { return make_clipboard_error( std::format("Failed to find MIME data type \"{}\"", type)); @@ -284,7 +285,7 @@ namespace Toolbox { UINT format = CF_NULL; if (m_mime_to_format.find(type) == m_mime_to_format.end()) { - format = FormatForMime(type); + format = SystemClipboard::FormatForMime(type); if (format == CF_NULL) { m_mime_to_format[type] = RegisterClipboardFormat(type.c_str()); format = m_mime_to_format[type]; From c786d282e41a760441b5829dc72d11466fedf9d3 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Mon, 14 Oct 2024 18:16:00 -0700 Subject: [PATCH 097/129] Make getContentType a friend function --- include/core/clipboard.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/core/clipboard.hpp b/include/core/clipboard.hpp index a3c7efa4..f4a3bc5b 100644 --- a/include/core/clipboard.hpp +++ b/include/core/clipboard.hpp @@ -45,8 +45,11 @@ namespace Toolbox { Result, ClipboardError> getFiles() const; Result setContent(const MimeData &mimedata); - #ifdef TOOLBOX_PLATFORM_WINDOWS + friend Result + getContentType(std::unordered_map &mime_to_format, + const std::string &type); + protected: static UINT FormatForMime(std::string_view mimetype); static std::string MimeForFormat(UINT format); @@ -68,9 +71,10 @@ namespace Toolbox { // of names we like to use in other places. MimeData m_clipboard_contents; #endif - }; - void hookClipboardIntoGLFW(void) ; + Result + getContentType(std::unordered_map &mime_to_format, const std::string &type); + void hookClipboardIntoGLFW(void); class DataClipboard { public: From d29053c529818a74cbb34bd6db2527cceeba6cf1 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Mon, 14 Oct 2024 18:16:19 -0700 Subject: [PATCH 098/129] Some clang-format stuff --- include/core/clipboard.hpp | 2 +- src/gui/clipboard.cpp | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/include/core/clipboard.hpp b/include/core/clipboard.hpp index f4a3bc5b..bf679c85 100644 --- a/include/core/clipboard.hpp +++ b/include/core/clipboard.hpp @@ -6,8 +6,8 @@ #include "core/error.hpp" #include "core/mimedata/mimedata.hpp" -#include "tristate.hpp" #include "fsystem.hpp" +#include "tristate.hpp" namespace Toolbox { diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index 96af5104..e9a3523d 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -54,10 +54,8 @@ namespace Toolbox { return types; } - Result - getContentType(std::unordered_map &mime_to_format, - const std::string &type) { + getContentType(std::unordered_map &mime_to_format, const std::string &type) { if (!OpenClipboard(nullptr)) { return make_clipboard_error("Failed to open the clipboard!"); } @@ -67,7 +65,7 @@ namespace Toolbox { format = SystemClipboard::FormatForMime(type); if (format == CF_NULL) { mime_to_format[type] = RegisterClipboardFormat(type.c_str()); - format = mime_to_format[type]; + format = mime_to_format[type]; } } else { format = mime_to_format[type]; @@ -270,7 +268,8 @@ namespace Toolbox { std::vector formats = mimedata.get_all_formats(); if (formats.size() > 1) { - return make_clipboard_error("Can't set clipboard to mulitple types at once on Windows!"); + return make_clipboard_error( + "Can't set clipboard to mulitple types at once on Windows!"); } TOOLBOX_ASSERT(formats.size() > 0); auto type = formats[0]; @@ -331,7 +330,7 @@ namespace Toolbox { } } - path_list_ptr[data_buf.size()] = L'\0'; + path_list_ptr[data_buf.size()] = L'\0'; path_list_ptr[data_buf.size() + 1] = L'\0'; } else if (format == CF_TEXT) { wchar_t *path_list_ptr = (wchar_t *)data_buffer; From c5bd30d38b40de9a3404c37e2b54170257daf80c Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Mon, 14 Oct 2024 18:24:22 -0700 Subject: [PATCH 099/129] Oops don't declare windows-specific function on Linux --- include/core/clipboard.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/core/clipboard.hpp b/include/core/clipboard.hpp index bf679c85..83e2d567 100644 --- a/include/core/clipboard.hpp +++ b/include/core/clipboard.hpp @@ -72,8 +72,10 @@ namespace Toolbox { MimeData m_clipboard_contents; #endif }; +#ifdef TOOLBOX_PLATFORM_WINDOWS Result getContentType(std::unordered_map &mime_to_format, const std::string &type); +#endif void hookClipboardIntoGLFW(void); class DataClipboard { From 8a06024bd2f8d64349689432f6ac308ca36f99f9 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Mon, 14 Oct 2024 19:29:43 -0700 Subject: [PATCH 100/129] Fix some more windows build errors --- src/gui/clipboard.cpp | 4 ++- src/gui/dragdrop/dragdropmanager.cpp | 37 ++++++---------------------- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/src/gui/clipboard.cpp b/src/gui/clipboard.cpp index e9a3523d..3bc6149a 100644 --- a/src/gui/clipboard.cpp +++ b/src/gui/clipboard.cpp @@ -271,7 +271,9 @@ namespace Toolbox { return make_clipboard_error( "Can't set clipboard to mulitple types at once on Windows!"); } - TOOLBOX_ASSERT(formats.size() > 0); + if (formats.size() == 0) { + return make_clipboard_error("The mimedata set on the clipboard has no formats!"); + } auto type = formats[0]; std::optional result = mimedata.get_data(type); diff --git a/src/gui/dragdrop/dragdropmanager.cpp b/src/gui/dragdrop/dragdropmanager.cpp index 049824dd..4172be0b 100644 --- a/src/gui/dragdrop/dragdropmanager.cpp +++ b/src/gui/dragdrop/dragdropmanager.cpp @@ -15,29 +15,6 @@ #elif defined(TOOLBOX_PLATFORM_LINUX) #endif -static std::vector splitLines(std::string_view s) { - std::vector result; - size_t last_pos = 0; - size_t next_newline_pos = s.find('\n', 0); - while (next_newline_pos != std::string::npos) { - if (s[next_newline_pos - 1] == '\r') { - result.push_back(s.substr(last_pos, next_newline_pos - last_pos - 1)); - } else { - result.push_back(s.substr(last_pos, next_newline_pos - last_pos)); - } - last_pos = next_newline_pos + 1; - next_newline_pos = s.find('\n', last_pos); - } - if (last_pos < s.size()) { - if (s[s.size() - 1] == '\r') { - result.push_back(s.substr(last_pos, s.size() - last_pos - 1)); - } else { - result.push_back(s.substr(last_pos)); - } - } - return result; -} - namespace Toolbox::UI { RefPtr DragDropManager::createDragAction(UUID64 source_uuid, MimeData &&data, bool system_level) { @@ -59,18 +36,18 @@ namespace Toolbox::UI { void DragDropManager::shutdown() { OleUninitialize(); } Result DragDropManager::createSystemDragDropSource(MimeData &&data) { - std::string paths = data.get_urls().value_or(""); + auto maybe_paths = data.get_urls(); + if (!maybe_paths) { + return make_error("DRAG_DROP", "Passed Mimedata did not include urls"); + } + std::vector paths = maybe_paths.value(); std::vector pidls; - std::vector lines = splitLines(paths); size_t next_newline_pos = 0; - for (const std::string_view &line : lines) { - if (line.empty()) { - continue; - } + for (const std::string_view &path : paths) { - std::wstring wpath = std::wstring(line.begin(), line.end()); + std::wstring wpath = std::wstring(path.begin(), path.end()); PIDLIST_ABSOLUTE pidl = ILCreateFromPathW(wpath.c_str()); if (pidl == NULL) { From f54836ae0dfb7a9c720ffcc3b50056e5bc14c380 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Tue, 15 Oct 2024 17:43:37 -0500 Subject: [PATCH 101/129] Stuff --- include/gui/dragdrop/dragdropmanager.hpp | 1 + src/gui/dragdrop/dragdropmanager.cpp | 214 ++++++++++++++++++----- 2 files changed, 171 insertions(+), 44 deletions(-) diff --git a/include/gui/dragdrop/dragdropmanager.hpp b/include/gui/dragdrop/dragdropmanager.hpp index 1aa0a25e..4f922b8d 100644 --- a/include/gui/dragdrop/dragdropmanager.hpp +++ b/include/gui/dragdrop/dragdropmanager.hpp @@ -41,6 +41,7 @@ namespace Toolbox::UI { #ifdef TOOLBOX_PLATFORM_WINDOWS IDataObject *m_data_object = nullptr; IDropSource *m_drop_source = nullptr; + std::thread m_drag_thread; #elif defined(TOOLBOX_PLATFORM_LINUX) #endif diff --git a/src/gui/dragdrop/dragdropmanager.cpp b/src/gui/dragdrop/dragdropmanager.cpp index 049824dd..24ea771c 100644 --- a/src/gui/dragdrop/dragdropmanager.cpp +++ b/src/gui/dragdrop/dragdropmanager.cpp @@ -15,32 +15,10 @@ #elif defined(TOOLBOX_PLATFORM_LINUX) #endif -static std::vector splitLines(std::string_view s) { - std::vector result; - size_t last_pos = 0; - size_t next_newline_pos = s.find('\n', 0); - while (next_newline_pos != std::string::npos) { - if (s[next_newline_pos - 1] == '\r') { - result.push_back(s.substr(last_pos, next_newline_pos - last_pos - 1)); - } else { - result.push_back(s.substr(last_pos, next_newline_pos - last_pos)); - } - last_pos = next_newline_pos + 1; - next_newline_pos = s.find('\n', last_pos); - } - if (last_pos < s.size()) { - if (s[s.size() - 1] == '\r') { - result.push_back(s.substr(last_pos, s.size() - last_pos - 1)); - } else { - result.push_back(s.substr(last_pos)); - } - } - return result; -} - namespace Toolbox::UI { - RefPtr DragDropManager::createDragAction(UUID64 source_uuid, MimeData &&data, bool system_level) { + RefPtr DragDropManager::createDragAction(UUID64 source_uuid, MimeData &&data, + bool system_level) { m_current_drag_action = make_referable(source_uuid); m_current_drag_action->setPayload(data); if (system_level) { @@ -56,7 +34,165 @@ namespace Toolbox::UI { #ifdef TOOLBOX_PLATFORM_WINDOWS bool DragDropManager::initialize() { return OleInitialize(nullptr) >= 0; } - void DragDropManager::shutdown() { OleUninitialize(); } + void DragDropManager::shutdown() { + OleUninitialize(); + m_drag_thread.join(); + } + + static std::vector splitLines(std::string_view s) { + std::vector result; + size_t last_pos = 0; + size_t next_newline_pos = s.find('\n', 0); + while (next_newline_pos != std::string::npos) { + if (s[next_newline_pos - 1] == '\r') { + result.push_back(s.substr(last_pos, next_newline_pos - last_pos - 1)); + } else { + result.push_back(s.substr(last_pos, next_newline_pos - last_pos)); + } + last_pos = next_newline_pos + 1; + next_newline_pos = s.find('\n', last_pos); + } + if (last_pos < s.size()) { + if (s[s.size() - 1] == '\r') { + result.push_back(s.substr(last_pos, s.size() - last_pos - 1)); + } else { + result.push_back(s.substr(last_pos)); + } + } + return result; + } + + class DropSource : public IDropSource { + public: + STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject) { + if (riid == IID_IUnknown || riid == IID_IDropSource) { + *ppvObject = static_cast(this); + AddRef(); + return S_OK; + } + *ppvObject = nullptr; + return E_NOINTERFACE; + } + + STDMETHODIMP_(ULONG) AddRef() { return ++m_refCount; } + + STDMETHODIMP_(ULONG) Release() { + if (--m_refCount == 0) { + delete this; + return 0; + } + return m_refCount; + } + + STDMETHODIMP QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState) { + if (fEscapePressed) + return DRAGDROP_S_CANCEL; + if (!(grfKeyState & MK_LBUTTON)) + return DRAGDROP_S_DROP; + return S_OK; + } + + STDMETHODIMP GiveFeedback(DWORD dwEffect) { + return DRAGDROP_S_USEDEFAULTCURSORS; // Use default drag-and-drop cursors + } + + private: + ULONG m_refCount = 1; + }; + + // Create an IDataObject with CF_HDROP for file drag-and-drop + class FileDropDataObject : public IDataObject { + public: + FileDropDataObject(LPCWSTR filePath) { + m_refCount = 1; + m_filePath = filePath; + } + + STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject) { + if (riid == IID_IUnknown || riid == IID_IDataObject) { + *ppvObject = static_cast(this); + AddRef(); + return S_OK; + } + *ppvObject = nullptr; + return E_NOINTERFACE; + } + + STDMETHODIMP_(ULONG) AddRef() { return ++m_refCount; } + + STDMETHODIMP_(ULONG) Release() { + if (--m_refCount == 0) { + delete this; + return 0; + } + return m_refCount; + } + + STDMETHODIMP GetData(FORMATETC *pFormatEtc, STGMEDIUM *pMedium) { + if (pFormatEtc->cfFormat == CF_HDROP && pFormatEtc->tymed & TYMED_HGLOBAL) { + // Allocate global memory for the file list + SIZE_T filePathSize = (wcslen(m_filePath) + 1) * sizeof(WCHAR); + SIZE_T totalSize = sizeof(DROPFILES) + filePathSize; + + HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, totalSize); + if (!hGlobal) + return E_OUTOFMEMORY; + + // Fill in the DROPFILES structure + DROPFILES *pDropFiles = (DROPFILES *)GlobalLock(hGlobal); + pDropFiles->pFiles = sizeof(DROPFILES); // Offset to the file list + pDropFiles->fWide = TRUE; // Using Unicode (WCHAR) + + // Copy the file path to the memory block + WCHAR *pDst = (WCHAR *)((BYTE *)pDropFiles + sizeof(DROPFILES)); + wcscpy(pDst, m_filePath); + + GlobalUnlock(hGlobal); + + // Set the STGMEDIUM + pMedium->tymed = TYMED_HGLOBAL; + pMedium->hGlobal = hGlobal; + pMedium->pUnkForRelease = nullptr; + return S_OK; + } + + return DV_E_FORMATETC; // Unsupported format + } + + STDMETHODIMP GetDataHere(FORMATETC *pFormatEtc, STGMEDIUM *pMedium) { return E_NOTIMPL; } + + STDMETHODIMP QueryGetData(FORMATETC *pFormatEtc) { + if (pFormatEtc->cfFormat == CF_HDROP && pFormatEtc->tymed & TYMED_HGLOBAL) { + return S_OK; + } + return DV_E_FORMATETC; + } + + STDMETHODIMP GetCanonicalFormatEtc(FORMATETC *pFormatEtcIn, FORMATETC *pFormatEtcOut) { + return DATA_S_SAMEFORMATETC; + } + + STDMETHODIMP SetData(FORMATETC *pFormatEtc, STGMEDIUM *pMedium, BOOL fRelease) { + return E_NOTIMPL; + } + + STDMETHODIMP EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC **ppEnumFormatEtc) { + return E_NOTIMPL; + } + + STDMETHODIMP DAdvise(FORMATETC *pFormatEtc, DWORD advf, IAdviseSink *pAdvSink, + DWORD *pdwConnection) { + return E_NOTIMPL; + } + + STDMETHODIMP DUnadvise(DWORD dwConnection) { return E_NOTIMPL; } + + STDMETHODIMP EnumDAdvise(IEnumSTATDATA **ppEnumAdvise) { return E_NOTIMPL; } + + private: + ULONG m_refCount; + LPCWSTR m_filePath; + }; Result DragDropManager::createSystemDragDropSource(MimeData &&data) { std::string paths = data.get_urls().value_or(""); @@ -85,8 +221,9 @@ namespace Toolbox::UI { IDataObject *data_object = nullptr; { - HRESULT hr = SHCreateDataObject(NULL, static_cast(pidls.size()), (PCIDLIST_ABSOLUTE *)pidls.data(), - nullptr, IID_IDataObject, (void **)&data_object); + HRESULT hr = SHCreateDataObject(NULL, static_cast(pidls.size()), + (PCIDLIST_ABSOLUTE *)pidls.data(), nullptr, + IID_IDataObject, (void **)&data_object); for (PIDLIST_ABSOLUTE pidl : pidls) { ILFree(pidl); @@ -97,24 +234,15 @@ namespace Toolbox::UI { } } - IDropSource *drop_source = nullptr; - { - HRESULT hr = CoCreateInstance(CLSID_DragDropHelper, nullptr, CLSCTX_INPROC_SERVER, - IID_IDropSource, (void **)&drop_source); - if (FAILED(hr)) { - data_object->Release(); - return make_error("DRAG_DROP", "Failed to create drop source"); - } - } + DropSource *drop_source = new DropSource(); - DWORD effect; { - HRESULT hr = DoDragDrop(data_object, drop_source, DROPEFFECT_COPY, &effect); - if (FAILED(hr)) { + m_drag_thread = std::thread([data_object, drop_source]() { + DWORD effect; + DoDragDrop(data_object, drop_source, DROPEFFECT_MOVE, &effect); drop_source->Release(); data_object->Release(); - return make_error("DRAG_DROP", "Failed to perform drag drop operation"); - } + }); } m_data_object = data_object; @@ -142,9 +270,7 @@ namespace Toolbox::UI { return {}; } - Result DragDropManager::destroySystemDragDropSource() { - return {}; - } + Result DragDropManager::destroySystemDragDropSource() { return {}; } #endif From 78f9158b01ad452f5ae9c699578db931cd127a7d Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Fri, 18 Oct 2024 00:45:38 -0500 Subject: [PATCH 102/129] Disable system drag from app for now --- include/gui/dragdrop/dragdropmanager.hpp | 1 + src/gui/dragdrop/dragdropmanager.cpp | 159 ++++++++++++----------- 2 files changed, 87 insertions(+), 73 deletions(-) diff --git a/include/gui/dragdrop/dragdropmanager.hpp b/include/gui/dragdrop/dragdropmanager.hpp index 4f922b8d..12c03e21 100644 --- a/include/gui/dragdrop/dragdropmanager.hpp +++ b/include/gui/dragdrop/dragdropmanager.hpp @@ -42,6 +42,7 @@ namespace Toolbox::UI { IDataObject *m_data_object = nullptr; IDropSource *m_drop_source = nullptr; std::thread m_drag_thread; + bool m_is_thread_running; #elif defined(TOOLBOX_PLATFORM_LINUX) #endif diff --git a/src/gui/dragdrop/dragdropmanager.cpp b/src/gui/dragdrop/dragdropmanager.cpp index bf3e9ef2..fbef7221 100644 --- a/src/gui/dragdrop/dragdropmanager.cpp +++ b/src/gui/dragdrop/dragdropmanager.cpp @@ -74,14 +74,14 @@ namespace Toolbox::UI { return E_NOINTERFACE; } - STDMETHODIMP_(ULONG) AddRef() { return ++m_refCount; } + STDMETHODIMP_(ULONG) AddRef() { return ++m_ref_count; } STDMETHODIMP_(ULONG) Release() { - if (--m_refCount == 0) { + if (--m_ref_count == 0) { delete this; return 0; } - return m_refCount; + return m_ref_count; } STDMETHODIMP QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState) { @@ -97,18 +97,60 @@ namespace Toolbox::UI { } private: - ULONG m_refCount = 1; + ULONG m_ref_count = 1; }; // Create an IDataObject with CF_HDROP for file drag-and-drop class FileDropDataObject : public IDataObject { public: - FileDropDataObject(LPCWSTR filePath) { - m_refCount = 1; - m_filePath = filePath; + FileDropDataObject(const std::vector &file_paths) : m_ref_count(1) { + size_t total_path_size = 2; // Double null-terminator + for (const std::string &path : file_paths) { + total_path_size += path.size() + 1; // +1 for null-terminator + } + + m_format_etc.cfFormat = CF_HDROP; + m_format_etc.ptd = nullptr; + m_format_etc.dwAspect = DVASPECT_CONTENT; + m_format_etc.lindex = -1; + m_format_etc.tymed = TYMED_HGLOBAL; + + m_stg_medium.tymed = TYMED_HGLOBAL; + m_stg_medium.hGlobal = + GlobalAlloc(GHND, sizeof(DROPFILES) + total_path_size * sizeof(WCHAR)); + m_stg_medium.pUnkForRelease = nullptr; + + DROPFILES *drop_files = static_cast(GlobalLock(m_stg_medium.hGlobal)); + if (!drop_files) { + TOOLBOX_ERROR("Failed to lock global memory for DROPFILES structure"); + return; + } + + drop_files->pFiles = sizeof(DROPFILES); + drop_files->fWide = TRUE; + + WCHAR *file_path_buffer = + reinterpret_cast((CHAR *)drop_files + drop_files->pFiles); + for (const std::string &file_path : file_paths) { + size_t path_size = file_path.size(); + std::mbstowcs(file_path_buffer, file_path.c_str(), path_size); + file_path_buffer += path_size; + *file_path_buffer++ = L'\0'; + } + + *file_path_buffer = L'\0'; + + GlobalUnlock(m_stg_medium.hGlobal); } - STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject) { + ~FileDropDataObject() { + if (m_stg_medium.hGlobal) { + GlobalFree(m_stg_medium.hGlobal); + } + } + + STDMETHODIMP + QueryInterface(REFIID riid, void **ppvObject) { if (riid == IID_IUnknown || riid == IID_IDataObject) { *ppvObject = static_cast(this); AddRef(); @@ -118,40 +160,24 @@ namespace Toolbox::UI { return E_NOINTERFACE; } - STDMETHODIMP_(ULONG) AddRef() { return ++m_refCount; } + STDMETHODIMP_(ULONG) AddRef() { return ++m_ref_count; } STDMETHODIMP_(ULONG) Release() { - if (--m_refCount == 0) { + if (--m_ref_count == 0) { delete this; return 0; } - return m_refCount; + return m_ref_count; } STDMETHODIMP GetData(FORMATETC *pFormatEtc, STGMEDIUM *pMedium) { - if (pFormatEtc->cfFormat == CF_HDROP && pFormatEtc->tymed & TYMED_HGLOBAL) { - // Allocate global memory for the file list - SIZE_T filePathSize = (wcslen(m_filePath) + 1) * sizeof(WCHAR); - SIZE_T totalSize = sizeof(DROPFILES) + filePathSize; - - HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, totalSize); - if (!hGlobal) - return E_OUTOFMEMORY; - - // Fill in the DROPFILES structure - DROPFILES *pDropFiles = (DROPFILES *)GlobalLock(hGlobal); - pDropFiles->pFiles = sizeof(DROPFILES); // Offset to the file list - pDropFiles->fWide = TRUE; // Using Unicode (WCHAR) - - // Copy the file path to the memory block - WCHAR *pDst = (WCHAR *)((BYTE *)pDropFiles + sizeof(DROPFILES)); - wcscpy(pDst, m_filePath); - - GlobalUnlock(hGlobal); + if ((pFormatEtc->tymed & TYMED_HGLOBAL) == 0) { + return DV_E_TYMED; // Unsupported medium + } - // Set the STGMEDIUM + if (pFormatEtc->cfFormat == CF_HDROP) { pMedium->tymed = TYMED_HGLOBAL; - pMedium->hGlobal = hGlobal; + pMedium->hGlobal = m_stg_medium.hGlobal; pMedium->pUnkForRelease = nullptr; return S_OK; } @@ -162,7 +188,12 @@ namespace Toolbox::UI { STDMETHODIMP GetDataHere(FORMATETC *pFormatEtc, STGMEDIUM *pMedium) { return E_NOTIMPL; } STDMETHODIMP QueryGetData(FORMATETC *pFormatEtc) { - if (pFormatEtc->cfFormat == CF_HDROP && pFormatEtc->tymed & TYMED_HGLOBAL) { + if ((pFormatEtc->tymed & TYMED_HGLOBAL) == 0) { + return DV_E_TYMED; + } + if (pFormatEtc->cfFormat == CF_HDROP || + pFormatEtc->cfFormat == RegisterClipboardFormat(CFSTR_FILECONTENTS) || + pFormatEtc->cfFormat == RegisterClipboardFormat(CFSTR_FILEDESCRIPTOR)) { return S_OK; } return DV_E_FORMATETC; @@ -177,7 +208,7 @@ namespace Toolbox::UI { } STDMETHODIMP EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC **ppEnumFormatEtc) { - return E_NOTIMPL; + return OLE_S_USEREG; } STDMETHODIMP DAdvise(FORMATETC *pFormatEtc, DWORD advf, IAdviseSink *pAdvSink, @@ -190,8 +221,9 @@ namespace Toolbox::UI { STDMETHODIMP EnumDAdvise(IEnumSTATDATA **ppEnumAdvise) { return E_NOTIMPL; } private: - ULONG m_refCount; - LPCWSTR m_filePath; + ULONG m_ref_count; + FORMATETC m_format_etc; + STGMEDIUM m_stg_medium; }; Result DragDropManager::createSystemDragDropSource(MimeData &&data) { @@ -199,54 +231,35 @@ namespace Toolbox::UI { if (!maybe_paths) { return make_error("DRAG_DROP", "Passed Mimedata did not include urls"); } - std::vector paths = maybe_paths.value(); - - std::vector pidls; - - size_t next_newline_pos = 0; - for (const std::string_view &path : paths) { - std::wstring wpath = std::wstring(path.begin(), path.end()); - - PIDLIST_ABSOLUTE pidl = ILCreateFromPathW(wpath.c_str()); - if (pidl == NULL) { - for (PIDLIST_ABSOLUTE pidl : pidls) { - ILFree(pidl); - } - return make_error("DRAG_DROP", "Failed to create PIDL from path"); - } + IDataObject *data_object = new FileDropDataObject(std::move(maybe_paths.value())); + IDropSource *drop_source = new DropSource(); - pidls.push_back(pidl); - } - - IDataObject *data_object = nullptr; + #if 0 { - HRESULT hr = SHCreateDataObject(NULL, static_cast(pidls.size()), - (PCIDLIST_ABSOLUTE *)pidls.data(), nullptr, - IID_IDataObject, (void **)&data_object); - - for (PIDLIST_ABSOLUTE pidl : pidls) { - ILFree(pidl); + if (m_is_thread_running) { + m_drag_thread.join(); } - if (FAILED(hr)) { - return make_error("DRAG_DROP", "Failed to create data object"); - } - } - - DropSource *drop_source = new DropSource(); - - { m_drag_thread = std::thread([data_object, drop_source]() { DWORD effect; - DoDragDrop(data_object, drop_source, DROPEFFECT_MOVE, &effect); + DoDragDrop(data_object, drop_source, DROPEFFECT_COPY | DROPEFFECT_MOVE, &effect); drop_source->Release(); data_object->Release(); }); - } - m_data_object = data_object; - m_drop_source = drop_source; + m_data_object = data_object; + m_drop_source = drop_source; + } + #elif 0 + { + DWORD effect; + DoDragDrop(data_object, drop_source, DROPEFFECT_COPY | DROPEFFECT_MOVE, &effect); + drop_source->Release(); + data_object->Release(); + } + #else + #endif return {}; } From fa0b767ec2f4265fb2f46016e2e0809b2d36f698 Mon Sep 17 00:00:00 2001 From: JoshuaMK <60854312+JoshuaMKW@users.noreply.github.com> Date: Sun, 20 Oct 2024 19:24:19 -0500 Subject: [PATCH 103/129] New dialog (#37) * Outline new item window * Fix wrong file modified * Some things * Idk more stuff * Update gitignore * Button behavior is underlaying? * Fix rendering issues * Add idea of context path for convenient saving * Adjust code --- .gitignore | 1 + CMakeLists.txt | 2 + include/gui/new_item/window.hpp | 99 +++++++++++ include/gui/scene/window.hpp | 5 + src/gui/new_item/window.cpp | 304 ++++++++++++++++++++++++++++++++ src/gui/project/window.cpp | 12 +- src/gui/scene/window.cpp | 15 +- 7 files changed, 429 insertions(+), 9 deletions(-) create mode 100644 include/gui/new_item/window.hpp create mode 100644 src/gui/new_item/window.cpp diff --git a/.gitignore b/.gitignore index 470633de..63a11346 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ .vs/* out/* /enc_temp_folder +/.idea diff --git a/CMakeLists.txt b/CMakeLists.txt index 38a5c141..26fcad8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,8 @@ file(GLOB TOOLBOX_SRC "include/gui/image/*.hpp" "src/gui/layer/*.cpp" "include/gui/layer/*.hpp" + "src/gui/new_item/*.cpp" + "include/gui/new_item/*.hpp" "src/gui/pad/*.cpp" "include/gui/pad/*.hpp" "src/gui/project/*.cpp" diff --git a/include/gui/new_item/window.hpp b/include/gui/new_item/window.hpp new file mode 100644 index 00000000..17eda1d2 --- /dev/null +++ b/include/gui/new_item/window.hpp @@ -0,0 +1,99 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "core/memory.hpp" +#include "fsystem.hpp" +#include "objlib/object.hpp" +#include "objlib/template.hpp" +#include "scene/scene.hpp" +#include "smart_resource.hpp" + +#include "core/clipboard.hpp" +#include "game/task.hpp" +#include "gui/context_menu.hpp" +#include "gui/event/event.hpp" +#include "gui/image/imagepainter.hpp" +#include "gui/project/asset.hpp" +#include "gui/window.hpp" + +#include "model/fsmodel.hpp" + +#include + +namespace Toolbox::UI { + + class NewItemWindow final : public ImWindow { + public: + NewItemWindow(const std::string &name); + ~NewItemWindow() = default; + + using window_constructor = std::function(const fs_path &context_path)>; + + struct ItemInfo { + std::string m_name; + std::string m_extension; + std::string m_description; + RefPtr m_icon; + window_constructor m_win_factory; + }; + + void setContextPath(const fs_path &path) { + m_context_path = path; + } + + protected: + void onRenderBody(TimeStep delta_time) override; + + void renderItemRow(const ItemInfo &info, bool selected, bool pressed, bool hovered, const ImVec2 &pos, const ImVec2 &size); + void renderItemDescription(const ItemInfo &info, const ImVec2 &pos, const ImVec2 &size); + void renderControlPanel(); + + public: + ImGuiWindowFlags flags() const override { return ImWindow::flags(); } + + const ImGuiWindowClass *windowClass() const override { + ImGuiWindow *currentWindow = ImGui::GetCurrentWindow(); + m_window_class.ClassId = (ImGuiID)getUUID(); + m_window_class.ParentViewportId = currentWindow->ViewportId; + m_window_class.DockingAllowUnclassed = false; + m_window_class.DockingAlwaysTabBar = false; + return nullptr; + } + + std::optional minSize() const override { + return { + {650, 400} + }; + } + + [[nodiscard]] std::string context() const override { return m_context_path.string(); } + + [[nodiscard]] bool unsaved() const override { return false; } + + // Returns the supported file types, empty string is designed for a folder. + [[nodiscard]] std::vector extensions() const override { return {}; } + + [[nodiscard]] bool onLoadData(const std::filesystem::path &path) override { return false; } + + [[nodiscard]] bool onSaveData(std::optional path) override { + return false; + } + + void onAttach() override; + void onDetach() override; + void onImGuiUpdate(TimeStep delta_time) override; + + private: + fs_path m_context_path; + std::vector m_item_infos; + std::string m_search_buffer; + int m_selected_item_index; + }; + +} // namespace Toolbox::UI \ No newline at end of file diff --git a/include/gui/scene/window.hpp b/include/gui/scene/window.hpp index d2586b98..c11b8e51 100644 --- a/include/gui/scene/window.hpp +++ b/include/gui/scene/window.hpp @@ -80,6 +80,9 @@ namespace Toolbox::UI { void deregisterOverlay(const std::string &layer_name) { m_render_layers.erase(layer_name); } + void initToBasic() { m_current_scene = SceneInstance::BasicScene(); } + void setIOContextPath(const fs_path &path) { m_io_context_path = path; } + protected: ImGuiID onBuildDockspace() override; void onRenderMenuBar() override; @@ -191,6 +194,8 @@ namespace Toolbox::UI { private: ScopePtr m_current_scene; + fs_path m_io_context_path; + // Hierarchy view ImGuiTextFilter m_hierarchy_filter; std::vector> m_hierarchy_selected_nodes = {}; diff --git a/src/gui/new_item/window.cpp b/src/gui/new_item/window.cpp new file mode 100644 index 00000000..d445c798 --- /dev/null +++ b/src/gui/new_item/window.cpp @@ -0,0 +1,304 @@ +#include "gui/new_item/window.hpp" +#include "gui/application.hpp" +#include "gui/scene/window.hpp" + +#include "resource/resource.hpp" + +namespace Toolbox::UI { + + struct _BuiltinItemInfo { + std::string m_name; + std::string m_extension; + std::string m_description; + std::string m_icon_name; + NewItemWindow::window_constructor m_win_factory; + }; + + static std::array<_BuiltinItemInfo, 10> s_default_items = { + _BuiltinItemInfo("Basic Scene", "", "A minimal scene that runs in game.", "toolbox.png", + [](const fs_path &context_path) -> RefPtr { + RefPtr window = + GUIApplication::instance().createWindow( + "Scene Editor"); + window->initToBasic(); + window->setIOContextPath(context_path); + return window; + }), + _BuiltinItemInfo("Message Data", ".bmg", "A message list with metadata descriptors.", + "FileSystem/fs_bmg.png", + [](const fs_path &context_path) -> RefPtr { return nullptr; }), + _BuiltinItemInfo( + "Parameter Data", ".prm", "A parameter sheet for tuning behaviors.", + "FileSystem/fs_prm.png", + [](const fs_path &context_path) -> RefPtr { return nullptr; }), + _BuiltinItemInfo( + "Sunscript", ".sb", "A script format for defining high-level scene behaviors.", + "FileSystem/fs_sb.png", + [](const fs_path &context_path) -> RefPtr { return nullptr; }), + _BuiltinItemInfo( + "DolphinOS Movie Data", ".thp", + "A video format that displays JPEGs and plays adpcm audio.", "FileSystem/fs_thp.png", + [](const fs_path &context_path) -> RefPtr { return nullptr; }), + _BuiltinItemInfo( + "J2D Texture Image", ".bti", "A texture resource for models and UI.", + "FileSystem/fs_bti.png", + [](const fs_path &context_path) -> RefPtr { return nullptr; }), + _BuiltinItemInfo( + "J2D Texture UV Anim", ".btk", "A texture coordinate animation for models and UI.", + "FileSystem/fs_btk.png", + [](const fs_path &context_path) -> RefPtr { return nullptr; }), + _BuiltinItemInfo( + "J2D Texture Pattern Anim", ".btp", "A texture pattern animation for models and UI.", + "FileSystem/fs_btp.png", + [](const fs_path &context_path) -> RefPtr { return nullptr; }), + _BuiltinItemInfo( + "J3D Model Data", ".bmd", "A 3D model format for Nintendo games.", + "FileSystem/fs_bmd.png", + [](const fs_path &context_path) -> RefPtr { return nullptr; }), + _BuiltinItemInfo( + "JParticle Data", ".jpa", + "A particle format defining texture resources, physics parameters, and more.", + "FileSystem/fs_jpa.png", + [](const fs_path &context_path) -> RefPtr { return nullptr; }), + }; + + NewItemWindow::NewItemWindow(const std::string &name) + : ImWindow(name), m_selected_item_index(-1) { + ResourceManager &res_manager = GUIApplication::instance().getResourceManager(); + UUID64 icon_path_uuid = res_manager.getResourcePathUUID("Images/Icons"); + m_item_infos.resize(s_default_items.size()); + std::transform( + s_default_items.begin(), s_default_items.end(), m_item_infos.begin(), + [&res_manager, &icon_path_uuid](const _BuiltinItemInfo &info) { + auto result = res_manager.getImageHandle(info.m_icon_name, icon_path_uuid); + if (!result) { + TOOLBOX_ERROR_V("[NEW_ITEM_WINDOW] Failed to find icon \"{}\" for item \"{}\"", + info.m_icon_name, info.m_name); + return ItemInfo(info.m_name, info.m_extension, info.m_description, nullptr, + info.m_win_factory); + } + return ItemInfo(info.m_name, info.m_extension, info.m_description, result.value(), + info.m_win_factory); + }); + } + + void NewItemWindow::onRenderBody(TimeStep delta_time) { + ImGuiStyle &style = ImGui::GetStyle(); + + bool regex_valid = true; + + std::regex search_regex; + try { + search_regex = std::regex(m_search_buffer, std::regex::icase | std::regex::grep); + } catch (std::regex_error &e) { + TOOLBOX_DEBUG_LOG_V("[NEW_ITEM_WINDOW] Failed to compile regex: {}", e.what()); + regex_valid = false; + } + + float window_height = ImGui::GetWindowSize().y; + float table_height = window_height - style.WindowPadding.y * 4 - style.FramePadding.y * 2; + + const ImVec2 row_size = {400, 60}; + + ImGui::GetWindowDrawList()->AddRectFilled( + ImGui::GetCursorScreenPos(), + ImGui::GetCursorScreenPos() + ImVec2(row_size.x, table_height), + ImGui::ColorConvertFloat4ToU32(style.Colors[ImGuiCol_TableRowBgAlt])); + + if (ImGui::BeginTable("##item_list", 1, + ImGuiTableFlags_BordersOuter | ImGuiTableFlags_ScrollY, + ImVec2(row_size.x, table_height))) { + for (size_t i = 0; i < m_item_infos.size(); ++i) { + const ItemInfo &info = m_item_infos[i]; + +#ifndef TOOLBOX_DEBUG + if (info.m_win_factory == nullptr) { + continue; + } +#endif + + bool matches_search = false; + if (regex_valid) { + matches_search = std::regex_search(info.m_name, search_regex); + } else { + matches_search = info.m_name.find(m_search_buffer) != std::string::npos; + } + + if (!matches_search) { + continue; + } + + ImGui::TableNextRow(ImGuiTableRowFlags_None, row_size.y); + + ImGui::GetCurrentWindow()->SkipItems = + false; // Fix issue caused by table for future rows. + + bool selected = m_selected_item_index == i; + + std::string id_name = std::format("item_{}", i); + ImGuiID bb_id = ImGui::GetID(id_name.c_str(), id_name.c_str() + id_name.size()); + + ImVec2 bb_pos = ImGui::GetCursorScreenPos(); + + const ImRect bb(bb_pos, bb_pos + row_size); + if (!ImGui::ItemAdd(bb, bb_id)) { + TOOLBOX_DEBUG_LOG_V("[NEW_ITEM_WINDOW] Item {} is failed to add interactor", i); + } + + bool hovered, held; + bool pressed = ImGui::ButtonBehavior(bb, bb_id, &hovered, &held); + + if (pressed) { + m_selected_item_index = i; + selected = true; + } + + if (hovered) { + ImGui::SetMouseCursor(ImGuiMouseCursor_Hand); + } + + ImGui::BeginGroup(); + renderItemRow(info, selected, pressed, hovered, bb_pos, row_size); + ImGui::EndGroup(); + + // ImGui::SetCursorScreenPos({pos.x, pos.y + row_size.y + style.ItemSpacing.y}); + } + ImGui::EndTable(); + } + + ImGui::SameLine(); + + ImGui::BeginGroup(); + + char search_buffer[256]; + std::strncpy(search_buffer, m_search_buffer.c_str(), sizeof(search_buffer)); + + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (ImGui::InputTextWithHint("##search", "Search...", search_buffer, + sizeof(search_buffer))) { + m_search_buffer = search_buffer; + } + + ImGui::Separator(); + + if (m_selected_item_index >= 0) { + const ItemInfo &info = m_item_infos[m_selected_item_index]; + ImGui::BeginGroup(); + renderItemDescription(info, ImGui::GetCursorScreenPos(), {500, 500}); + ImGui::EndGroup(); + } + + renderControlPanel(); + + ImGui::EndGroup(); + } + + void NewItemWindow::renderItemRow(const ItemInfo &info, bool selected, bool pressed, + bool hovered, const ImVec2 &row_pos, const ImVec2 &row_size) { + ImGuiStyle &style = ImGui::GetStyle(); + ImDrawList *draw_list = ImGui::GetWindowDrawList(); + + ImVec4 bg_color; + if (hovered || pressed) { + bg_color = style.Colors[ImGuiCol_ButtonHovered]; + } else if (selected) { + bg_color = style.Colors[ImGuiCol_ButtonActive]; + } else { + bg_color = style.Colors[ImGuiCol_TableRowBg]; + } + + draw_list->AddRectFilled(row_pos, row_pos + row_size, + ImGui::ColorConvertFloat4ToU32(bg_color)); + + const ImVec2 icon_size = {48, 48}; + + // Render icon + { + ImVec2 icon_pos = ImVec2(style.WindowPadding.x, row_size.y / 2 - icon_size.x / 2); + + ImagePainter painter; + painter.render(*info.m_icon, row_pos + icon_pos, icon_size); + } + + // Render name text + { + ImVec2 name_text_size = ImGui::CalcTextSize( + info.m_name.c_str(), info.m_name.c_str() + info.m_name.size(), false, 0); + ImVec2 name_text_pos = ImVec2(style.WindowPadding.x + icon_size.x + style.ItemSpacing.x, + row_size.y / 2 - name_text_size.y / 2); + + draw_list->AddText(row_pos + name_text_pos, + ImGui::ColorConvertFloat4ToU32(style.Colors[ImGuiCol_Text]), + info.m_name.c_str(), info.m_name.c_str() + info.m_name.size()); + } + + // Render extension text + { + const std::string &type = info.m_extension.empty() ? "General" : info.m_extension; + + ImVec2 ext_text_size = + ImGui::CalcTextSize(type.c_str(), type.c_str() + type.size(), false, 0); + ImVec2 ext_text_pos = ImVec2(row_size.x - ext_text_size.x - style.WindowPadding.x - 16, + row_size.y / 2 - ext_text_size.y / 2); + + draw_list->AddText(row_pos + ext_text_pos, + ImGui::ColorConvertFloat4ToU32(style.Colors[ImGuiCol_Text]), + type.c_str(), type.c_str() + type.size()); + } + } + + void NewItemWindow::renderItemDescription(const ItemInfo &info, const ImVec2 &pos, + const ImVec2 &size) { + ImGui::Text("Type:"); + ImGui::SameLine(); + + const std::string &type = info.m_extension.empty() ? "General" : info.m_extension; + ImGui::TextWrapped(type.c_str()); + + ImGui::TextWrapped(info.m_description.c_str()); + } + + void NewItemWindow::renderControlPanel() { + ImGuiStyle &style = ImGui::GetStyle(); + + ImVec2 win_size = ImGui::GetWindowSize(); + + ImVec2 cancel_text_size = ImGui::CalcTextSize("Cancel"); + ImVec2 open_text_size = ImGui::CalcTextSize("Open"); + + ImVec2 cancel_button_size = cancel_text_size + (style.FramePadding * 2); + ImVec2 open_button_size = open_text_size + (style.FramePadding * 2); + + float y_pos = + win_size.y - style.WindowPadding.y - (style.FramePadding.y * 2) - ImGui::GetFontSize(); + ImVec2 cancel_button_pos = {win_size.x - cancel_button_size.x - style.WindowPadding.x, + y_pos}; + ImVec2 open_button_pos = {cancel_button_pos.x - open_button_size.x - style.ItemSpacing.x, + y_pos}; + + ImGui::SetCursorPos(open_button_pos); + if (ImGui::Button("Open", open_button_size)) { + if (m_selected_item_index >= 0) { + const ItemInfo &info = m_item_infos[m_selected_item_index]; + RefPtr window = info.m_win_factory(m_context_path); + if (!window) { + TOOLBOX_DEBUG_LOG("[NEW_ITEM_WINDOW] Failed to create window"); + } else { + close(); + } + } + } + + ImGui::SetCursorPos(cancel_button_pos); + if (ImGui::Button("Cancel", cancel_button_size)) { + close(); + } + } + + void NewItemWindow::onAttach() {} + + void NewItemWindow::onDetach() {} + + void NewItemWindow::onImGuiUpdate(TimeStep delta_time) {} + +} // namespace Toolbox::UI \ No newline at end of file diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index e5e29dba..97ff2106 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -1,6 +1,7 @@ #include "gui/project/window.hpp" #include "gui/application.hpp" #include "gui/dragdrop/dragdropmanager.hpp" +#include "gui/new_item/window.hpp" #include "model/fsmodel.hpp" #include @@ -325,7 +326,7 @@ namespace Toolbox::UI { m_tree_proxy.setDirsOnly(true); m_view_proxy.setSourceModel(m_file_system_model); m_view_proxy.setSortRole(FileSystemModelSortRole::SORT_ROLE_NAME); - m_view_index = m_view_proxy.getIndex(0, 0); + m_view_index = m_file_system_model->getIndex(0, 0); return true; } @@ -494,7 +495,11 @@ namespace Toolbox::UI { "New...", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_N}), [this]() { return m_selected_indices_ctx.size() == 0; }, [this](const ModelIndex &view_index) { - // TODO: Open a dialog that gives the user different file types to create. + RefPtr window = + GUIApplication::instance().createWindow("New Item"); + if (window) { + window->setContextPath(m_file_system_model->getPath(view_index)); + } }); } @@ -546,8 +551,7 @@ namespace Toolbox::UI { void ProjectViewWindow::actionPasteIntoIndex(const ModelIndex &index, const std::vector &paths) { for (const fs_path &src_path : paths) { - m_file_system_model->copy(src_path, index, - src_path.filename().string()); + m_file_system_model->copy(src_path, index, src_path.filename().string()); } } diff --git a/src/gui/scene/window.cpp b/src/gui/scene/window.cpp index 18cda6d8..bcc9b71b 100644 --- a/src/gui/scene/window.cpp +++ b/src/gui/scene/window.cpp @@ -152,6 +152,10 @@ namespace Toolbox::UI { return Result(); }); + if (result) { + m_io_context_path = path; + } + return result; } @@ -2679,15 +2683,16 @@ void SceneWindow::onRenderMenuBar() { if (m_is_save_default_ready) { m_is_save_default_ready = false; - if (m_current_scene->rootPath()) - (void)onSaveData(m_current_scene->rootPath()); - else + if (!m_io_context_path.empty()) { + (void)onSaveData(m_io_context_path); + } else { m_is_save_as_dialog_open = true; + } } if (m_is_save_as_dialog_open) { - ImGuiFileDialog::Instance()->OpenDialog("SaveSceneDialog", "Choose Directory", nullptr, "", - ""); + ImGuiFileDialog::Instance()->OpenDialog("SaveSceneDialog", "Choose Directory", nullptr, + m_io_context_path.string(), ""); } if (ImGuiFileDialog::Instance()->Display("SaveSceneDialog")) { From 966250675665df12a2aecdc4984c31c69a7716db Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Mon, 21 Oct 2024 09:59:30 -0500 Subject: [PATCH 104/129] Make some adjustments and add folder creation --- include/model/fsmodel.hpp | 6 +++ src/gui/dragdrop/dragdropmanager.cpp | 4 +- src/gui/project/window.cpp | 23 +++++++++-- src/model/fsmodel.cpp | 59 ++++++++++++++++++++++++++-- 4 files changed, 84 insertions(+), 8 deletions(-) diff --git a/include/model/fsmodel.hpp b/include/model/fsmodel.hpp index 7400dea7..d654a41c 100644 --- a/include/model/fsmodel.hpp +++ b/include/model/fsmodel.hpp @@ -103,6 +103,9 @@ namespace Toolbox { [[nodiscard]] std::any getData(const ModelIndex &index, int role) const override; + [[nodiscard]] std::string findUniqueName(const ModelIndex &index, + const std::string &name) const; + ModelIndex mkdir(const ModelIndex &parent, const std::string &name); ModelIndex touch(const ModelIndex &parent, const std::string &name); ModelIndex rename(const ModelIndex &file, const std::string &new_name); @@ -157,6 +160,9 @@ namespace Toolbox { // Implementation of public API for mutex locking reasons [[nodiscard]] std::any getData_(const ModelIndex &index, int role) const; + [[nodiscard]] std::string findUniqueName_(const ModelIndex &index, + const std::string &name) const; + ModelIndex mkdir_(const ModelIndex &parent, const std::string &name); ModelIndex touch_(const ModelIndex &parent, const std::string &name); ModelIndex rename_(const ModelIndex &file, const std::string &new_name); diff --git a/src/gui/dragdrop/dragdropmanager.cpp b/src/gui/dragdrop/dragdropmanager.cpp index fbef7221..3c6bb970 100644 --- a/src/gui/dragdrop/dragdropmanager.cpp +++ b/src/gui/dragdrop/dragdropmanager.cpp @@ -36,7 +36,9 @@ namespace Toolbox::UI { void DragDropManager::shutdown() { OleUninitialize(); - m_drag_thread.join(); + if (m_is_thread_running) { + m_drag_thread.join(); + } } static std::vector splitLines(std::string_view s) { diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 97ff2106..e90d9483 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -492,7 +492,19 @@ namespace Toolbox::UI { m_folder_view_context_menu.addDivider(); m_folder_view_context_menu.addOption( - "New...", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_N}), + "New Folder", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_LEFTSHIFT, KeyCode::KEY_N}), + [this]() { return m_selected_indices_ctx.size() == 0; }, + [this](const ModelIndex &view_index) { + std::string folder_name = + m_file_system_model->findUniqueName(view_index, "New Folder"); + ModelIndex new_index = m_file_system_model->mkdir(view_index, folder_name); + if (m_file_system_model->validateIndex(new_index)) { + actionRenameIndex(new_index); + } + }); + + m_folder_view_context_menu.addOption( + "New Item...", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_N}), [this]() { return m_selected_indices_ctx.size() == 0; }, [this](const ModelIndex &view_index) { RefPtr window = @@ -786,11 +798,16 @@ namespace Toolbox::UI { void ProjectViewWindow::renderFolderTree(const ModelIndex &index) { bool is_open = false; - if (m_tree_proxy.hasChildren(index)) { + if (m_tree_proxy.isDirectory(index)) { if (m_tree_proxy.canFetchMore(index)) { m_tree_proxy.fetchMore(index); } - ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_OpenOnArrow; + ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_None; + if (m_tree_proxy.hasChildren(index)) { + flags |= ImGuiTreeNodeFlags_OpenOnArrow; + } else { + flags |= ImGuiTreeNodeFlags_Leaf; + } if (m_view_index == m_tree_proxy.toSourceIndex(index)) { flags |= ImGuiTreeNodeFlags_Selected; diff --git a/src/model/fsmodel.cpp b/src/model/fsmodel.cpp index 0a65ddde..2119e4ad 100644 --- a/src/model/fsmodel.cpp +++ b/src/model/fsmodel.cpp @@ -206,6 +206,12 @@ namespace Toolbox { return getData_(index, role); } + std::string FileSystemModel::findUniqueName(const ModelIndex &index, + const std::string &name) const { + std::scoped_lock lock(m_mutex); + return findUniqueName_(index, name); + } + ModelIndex FileSystemModel::mkdir(const ModelIndex &parent, const std::string &name) { std::scoped_lock lock(m_mutex); return mkdir_(parent, name); @@ -484,6 +490,45 @@ namespace Toolbox { } } + std::string FileSystemModel::findUniqueName_(const ModelIndex &parent, + const std::string &name) const { + if (!validateIndex(parent)) { + return name; + } + + if (isFile_(parent)) { + return name; + } + + if (isArchive_(parent)) { + // TODO: Implement for virtual FS + TOOLBOX_ERROR("[FileSystemModel] Archive probing is unimplemented!"); + return name; + } + + std::string result_name = name; + size_t collisions = 0; + std::vector child_paths; + + size_t dir_size = getDirSize_(parent, false); + for (size_t i = 0; i < dir_size; ++i) { + ModelIndex child = getIndex_(i, 0, parent); + child_paths.emplace_back(std::move(getPath_(child).filename().string())); + } + + for (size_t i = 0; i < child_paths.size();) { + if (child_paths[i] == result_name) { + collisions += 1; + result_name = std::format("{} ({})", name, collisions); + i = 0; + continue; + } + ++i; + } + + return result_name; + } + ModelIndex FileSystemModel::mkdir_(const ModelIndex &parent, const std::string &name) { if (!validateIndex(parent)) { return ModelIndex(); @@ -519,7 +564,7 @@ namespace Toolbox { return ModelIndex(); } - return makeIndex(parent.data<_FileSystemIndexData>()->m_path / name, getRowCount(parent), + return makeIndex(parent.data<_FileSystemIndexData>()->m_path / name, getRowCount_(parent), parent); } @@ -549,7 +594,7 @@ namespace Toolbox { return ModelIndex(); } - return makeIndex(parent.data<_FileSystemIndexData>()->m_path / name, getRowCount(parent), + return makeIndex(parent.data<_FileSystemIndexData>()->m_path / name, getRowCount_(parent), parent); } @@ -604,6 +649,7 @@ namespace Toolbox { parent_data->m_children.end(), index.getUUID()), parent_data->m_children.end()); + parent_data->m_size -= 1; } delete index.data<_FileSystemIndexData>(); m_index_map.erase(index.getUUID()); @@ -649,6 +695,7 @@ namespace Toolbox { parent_data->m_children.end(), index.getUUID()), parent_data->m_children.end()); + parent_data->m_size -= 1; } delete index.data<_FileSystemIndexData>(); m_index_map.erase(index.getUUID()); @@ -681,6 +728,7 @@ namespace Toolbox { parent_data->m_children.erase(std::remove(parent_data->m_children.begin(), parent_data->m_children.end(), file.getUUID()), parent_data->m_children.end()); + parent_data->m_size -= 1; return makeIndex(to, dest_index, parent); } ModelIndex FileSystemModel::copy_(const fs_path &file, const ModelIndex &new_parent, @@ -690,8 +738,7 @@ namespace Toolbox { return ModelIndex(); } if (!Filesystem::exists(file)) { - TOOLBOX_ERROR_V("[FileSystemModel] \"{}\" is not a directory or file!", - file.string()); + TOOLBOX_ERROR_V("[FileSystemModel] \"{}\" is not a directory or file!", file.string()); return ModelIndex(); } fs_path to = new_parent.data<_FileSystemIndexData>()->m_path / new_name; @@ -941,6 +988,7 @@ namespace Toolbox { if (parent_data) { parent_data->m_children.insert(parent_data->m_children.begin() + row, index.getUUID()); + parent_data->m_size += 1; } m_index_map[index.getUUID()] = std::move(index); @@ -1130,6 +1178,7 @@ namespace Toolbox { old_parent_data->m_children.end(), index.getUUID()), old_parent_data->m_children.end()); + old_parent_data->m_size -= 1; ModelIndex new_parent = getIndex_(new_path.parent_path()); if (!validateIndex(new_parent)) { @@ -1138,6 +1187,7 @@ namespace Toolbox { _FileSystemIndexData *new_parent_data = new_parent.data<_FileSystemIndexData>(); new_parent_data->m_children.push_back(index.getUUID()); + new_parent_data->m_size += 1; } } @@ -1169,6 +1219,7 @@ namespace Toolbox { parent_data->m_children.end(), index.getUUID()), parent_data->m_children.end()); + parent_data->m_size -= 1; delete index.data<_FileSystemIndexData>(); m_index_map.erase(index.getUUID()); } From 7011bec30f041c8ca8562e77acb24c934d6eadb0 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Mon, 21 Oct 2024 11:30:33 -0500 Subject: [PATCH 105/129] Enhance fsmodel logic and signaling process --- include/model/fsmodel.hpp | 3 + include/watchdog/fswatchdog.hpp | 14 +- src/gui/project/window.cpp | 12 +- src/model/fsmodel.cpp | 238 +++++++++++++++++++++++++------- src/watchdog/fswatchdog.cpp | 38 ++++- 5 files changed, 241 insertions(+), 64 deletions(-) diff --git a/include/model/fsmodel.hpp b/include/model/fsmodel.hpp index d654a41c..ccf323fc 100644 --- a/include/model/fsmodel.hpp +++ b/include/model/fsmodel.hpp @@ -42,6 +42,7 @@ namespace Toolbox { EVENT_FOLDER_MODIFIED = BIT(3), EVENT_PATH_RENAMED = BIT(4), EVENT_PATH_REMOVED = BIT(5), + EVENT_IS_VIRTUAL = BIT(6), EVENT_FILE_ANY = EVENT_FILE_ADDED | EVENT_FILE_MODIFIED | EVENT_PATH_RENAMED | EVENT_PATH_REMOVED, EVENT_FOLDER_ANY = @@ -214,6 +215,8 @@ namespace Toolbox { void pathRemoved(const fs_path &path); + void signalEventListeners(const fs_path &path, FileSystemModelEventFlags flags); + private: UUID64 m_uuid; diff --git a/include/watchdog/fswatchdog.hpp b/include/watchdog/fswatchdog.hpp index 064eb54e..d96d1b0a 100644 --- a/include/watchdog/fswatchdog.hpp +++ b/include/watchdog/fswatchdog.hpp @@ -41,9 +41,7 @@ namespace Toolbox { ScopePtr> m_watch; }; -} - - +} // namespace Toolbox namespace std { @@ -73,6 +71,9 @@ namespace Toolbox { void sleep(); void wake(); + void ignorePathOnce(const fs_path &path); + void ignorePathOnce(fs_path &&path); + void addPath(const fs_path &path); void addPath(fs_path &&path); @@ -93,8 +94,7 @@ namespace Toolbox { protected: void tRun(void *param) override; - void observePath(const fs_path &path); - void observePathF(const fs_path &path); + bool wasSleepingForAlert(const fs_path &path); struct FileInfo { Filesystem::file_status m_status; @@ -109,6 +109,10 @@ namespace Toolbox { private: bool m_asleep = false; + std::chrono::time_point m_sleep_start; + std::chrono::time_point m_sleep_end; + + std::unordered_set m_ignore_paths; std::unordered_map m_path_infos; diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index e90d9483..915b08b1 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -492,13 +492,17 @@ namespace Toolbox::UI { m_folder_view_context_menu.addDivider(); m_folder_view_context_menu.addOption( - "New Folder", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_LEFTSHIFT, KeyCode::KEY_N}), + "New Folder", + KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_LEFTSHIFT, KeyCode::KEY_N}), [this]() { return m_selected_indices_ctx.size() == 0; }, [this](const ModelIndex &view_index) { std::string folder_name = m_file_system_model->findUniqueName(view_index, "New Folder"); ModelIndex new_index = m_file_system_model->mkdir(view_index, folder_name); if (m_file_system_model->validateIndex(new_index)) { + m_selected_indices.clear(); + m_selected_indices.push_back(new_index); + m_selected_indices_ctx = m_selected_indices; actionRenameIndex(new_index); } }); @@ -529,7 +533,11 @@ namespace Toolbox::UI { void ProjectViewWindow::actionDeleteIndexes(std::vector &indices) { for (auto &item_index : indices) { - m_file_system_model->remove(item_index); + if (m_file_system_model->isDirectory(item_index)) { + m_file_system_model->rmdir(item_index); + } else { + m_file_system_model->remove(item_index); + } } indices.clear(); } diff --git a/src/model/fsmodel.cpp b/src/model/fsmodel.cpp index 2119e4ad..8eed0455 100644 --- a/src/model/fsmodel.cpp +++ b/src/model/fsmodel.cpp @@ -5,6 +5,10 @@ #include "gui/application.hpp" #include "model/fsmodel.hpp" +#ifndef TOOLBOX_FS_WATCHDOG_SLEEP_ON_SELF_UPDATE +#define TOOLBOX_FS_WATCHDOG_SLEEP_ON_SELF_UPDATE 0 +#endif + namespace Toolbox { struct _FileSystemIndexData { @@ -507,7 +511,7 @@ namespace Toolbox { } std::string result_name = name; - size_t collisions = 0; + size_t collisions = 0; std::vector child_paths; size_t dir_size = getDirSize_(parent, false); @@ -536,9 +540,21 @@ namespace Toolbox { bool result = false; +#if TOOLBOX_FS_WATCHDOG_SLEEP_ON_SELF_UPDATE + m_watchdog.sleep(); +#endif + fs_path path = getPath_(parent) / name; + +#if !TOOLBOX_FS_WATCHDOG_SLEEP_ON_SELF_UPDATE + m_watchdog.ignorePathOnce(path); +#endif + + FileSystemModelEventFlags event_flags = FileSystemModelEventFlags::EVENT_FOLDER_ADDED; + if (isArchive_(parent) || validateIndex(getParentArchive(parent))) { + event_flags |= FileSystemModelEventFlags::EVENT_IS_VIRTUAL; + } + if (isDirectory_(parent)) { - fs_path path = getPath_(parent); - path /= name; Filesystem::create_directory(path) .and_then([&](bool created) { if (!created) { @@ -560,12 +576,18 @@ namespace Toolbox { TOOLBOX_ERROR("[FileSystemModel] Parent index is not a directory!"); } +#if TOOLBOX_FS_WATCHDOG_SLEEP_ON_SELF_UPDATE + m_watchdog.wake(); +#endif + if (!result) { return ModelIndex(); } - return makeIndex(parent.data<_FileSystemIndexData>()->m_path / name, getRowCount_(parent), - parent); + ModelIndex ret_index = makeIndex(parent.data<_FileSystemIndexData>()->m_path / name, + getRowCount_(parent), parent); + signalEventListeners(path, event_flags); + return ret_index; } ModelIndex FileSystemModel::touch_(const ModelIndex &parent, const std::string &name) { @@ -575,8 +597,22 @@ namespace Toolbox { bool result = false; +#if TOOLBOX_FS_WATCHDOG_SLEEP_ON_SELF_UPDATE + m_watchdog.sleep(); +#endif + + fs_path path = parent.data<_FileSystemIndexData>()->m_path / name; + +#if !TOOLBOX_FS_WATCHDOG_SLEEP_ON_SELF_UPDATE + m_watchdog.ignorePathOnce(path); +#endif + + FileSystemModelEventFlags event_flags = FileSystemModelEventFlags::EVENT_FILE_ADDED; + if (isArchive_(parent) || validateIndex(getParentArchive(parent))) { + event_flags |= FileSystemModelEventFlags::EVENT_IS_VIRTUAL; + } + if (isDirectory_(parent)) { - fs_path path = parent.data<_FileSystemIndexData>()->m_path / name; std::ofstream file(path); if (!file.is_open()) { TOOLBOX_ERROR_V("[FileSystemModel] Failed to create file: {}", path.string()); @@ -590,12 +626,18 @@ namespace Toolbox { TOOLBOX_ERROR("[FileSystemModel] Parent index is not a directory!"); } +#if TOOLBOX_FS_WATCHDOG_SLEEP_ON_SELF_UPDATE + m_watchdog.wake(); +#endif + if (!result) { return ModelIndex(); } - return makeIndex(parent.data<_FileSystemIndexData>()->m_path / name, getRowCount_(parent), - parent); + ModelIndex ret_index = makeIndex(parent.data<_FileSystemIndexData>()->m_path / name, + getRowCount_(parent), parent); + signalEventListeners(path, event_flags); + return ret_index; } bool FileSystemModel::rmdir_(const ModelIndex &index) { @@ -603,14 +645,26 @@ namespace Toolbox { return false; } - bool result = false; + bool result = false; + fs_path index_path = getPath_(index); + +#if TOOLBOX_FS_WATCHDOG_SLEEP_ON_SELF_UPDATE + m_watchdog.sleep(); +#else + m_watchdog.ignorePathOnce(index_path); +#endif + + FileSystemModelEventFlags event_flags = FileSystemModelEventFlags::EVENT_PATH_REMOVED; + if (validateIndex(getParentArchive(index))) { + event_flags |= FileSystemModelEventFlags::EVENT_IS_VIRTUAL; + } if (isDirectory_(index)) { - Filesystem::remove_all(getPath_(index)) + Filesystem::remove_all(index_path) .and_then([&](bool removed) { if (!removed) { TOOLBOX_ERROR_V("[FileSystemModel] Failed to remove directory: {}", - getPath(index).string()); + index_path.string()); return Result(); } result = true; @@ -622,11 +676,11 @@ namespace Toolbox { return Result(); }); } else if (isArchive_(index)) { - Filesystem::remove(getPath_(index)) + Filesystem::remove(index_path) .and_then([&](bool removed) { if (!removed) { TOOLBOX_ERROR_V("[FileSystemModel] Failed to remove archive: {}", - getPath(index).string()); + index_path.string()); return Result(); } result = true; @@ -641,6 +695,10 @@ namespace Toolbox { TOOLBOX_ERROR("[FileSystemModel] Index is not a directory!"); } +#if TOOLBOX_FS_WATCHDOG_SLEEP_ON_SELF_UPDATE + m_watchdog.wake(); +#endif + if (result) { ModelIndex parent = getParent_(index); if (validateIndex(parent)) { @@ -653,6 +711,8 @@ namespace Toolbox { } delete index.data<_FileSystemIndexData>(); m_index_map.erase(index.getUUID()); + + signalEventListeners(index_path, event_flags); } return result; @@ -663,7 +723,19 @@ namespace Toolbox { return false; } - bool result = false; + bool result = false; + fs_path index_path = getPath_(index); + +#if TOOLBOX_FS_WATCHDOG_SLEEP_ON_SELF_UPDATE + m_watchdog.sleep(); +#else + m_watchdog.ignorePathOnce(index_path); +#endif + + FileSystemModelEventFlags event_flags = FileSystemModelEventFlags::EVENT_PATH_REMOVED; + if (validateIndex(getParentArchive(index))) { + event_flags |= FileSystemModelEventFlags::EVENT_IS_VIRTUAL; + } if (isFile_(index)) { Filesystem::remove(getPath_(index)) @@ -687,6 +759,10 @@ namespace Toolbox { TOOLBOX_ERROR("[FileSystemModel] Index is not a file!"); } +#if TOOLBOX_FS_WATCHDOG_SLEEP_ON_SELF_UPDATE + m_watchdog.wake(); +#endif + if (result) { ModelIndex parent = getParent_(index); if (validateIndex(parent)) { @@ -699,6 +775,8 @@ namespace Toolbox { } delete index.data<_FileSystemIndexData>(); m_index_map.erase(index.getUUID()); + + signalEventListeners(index_path, event_flags); } return result; @@ -712,7 +790,10 @@ namespace Toolbox { TOOLBOX_ERROR("[FileSystemModel] Not a directory or file!"); return ModelIndex(); } - fs_path from = file.data<_FileSystemIndexData>()->m_path; + + bool result = false; + + fs_path from = getPath_(file); fs_path to = from.parent_path() / new_name; ModelIndex parent = getParent_(file); _FileSystemIndexData *parent_data = parent.data<_FileSystemIndexData>(); @@ -721,7 +802,35 @@ namespace Toolbox { file.getUUID()) - parent_data->m_children.begin(); - Filesystem::rename(from, to); +#if TOOLBOX_FS_WATCHDOG_SLEEP_ON_SELF_UPDATE + m_watchdog.sleep(); +#else + m_watchdog.ignorePathOnce(from); + m_watchdog.ignorePathOnce(to); +#endif + + FileSystemModelEventFlags event_flags = FileSystemModelEventFlags::EVENT_PATH_RENAMED; + if (validateIndex(getParentArchive(file))) { + event_flags |= FileSystemModelEventFlags::EVENT_IS_VIRTUAL; + } + + Filesystem::rename(from, to) + .and_then([&result]() { + result = true; + return Result(); + }) + .or_else([&](const FSError &error) { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to rename file: {}", error.m_message[0]); + return Result(); + }); + +#if TOOLBOX_FS_WATCHDOG_SLEEP_ON_SELF_UPDATE + m_watchdog.wake(); +#endif + + if (!result) { + return ModelIndex(); + } delete file.data<_FileSystemIndexData>(); m_index_map.erase(file.getUUID()); @@ -729,8 +838,12 @@ namespace Toolbox { parent_data->m_children.end(), file.getUUID()), parent_data->m_children.end()); parent_data->m_size -= 1; - return makeIndex(to, dest_index, parent); + + ModelIndex ret_index = makeIndex(to, dest_index, parent); + signalEventListeners(to, event_flags); + return ret_index; } + ModelIndex FileSystemModel::copy_(const fs_path &file, const ModelIndex &new_parent, const std::string &new_name) { if (!validateIndex(new_parent)) { @@ -741,13 +854,53 @@ namespace Toolbox { TOOLBOX_ERROR_V("[FileSystemModel] \"{}\" is not a directory or file!", file.string()); return ModelIndex(); } - fs_path to = new_parent.data<_FileSystemIndexData>()->m_path / new_name; + + FileSystemModelEventFlags event_flags = FileSystemModelEventFlags::EVENT_FOLDER_ADDED; + { + ModelIndex src_index = getIndex_(file); + if (validateIndex(src_index)) { + if (isFile_(src_index)) { + // TODO: Detect when destination path is part of a valid archive. + if (false) { + event_flags |= FileSystemModelEventFlags::EVENT_IS_VIRTUAL; + } + event_flags = FileSystemModelEventFlags::EVENT_FILE_ADDED; + } + } else { + if (Filesystem::is_regular_file(file).value_or(false)) { + event_flags = FileSystemModelEventFlags::EVENT_FILE_ADDED; + } + } + } + + bool result = false; + fs_path to = new_parent.data<_FileSystemIndexData>()->m_path / new_name; int dest_index = getRowCount_(new_parent); - Filesystem::copy(file, to); +#if TOOLBOX_FS_WATCHDOG_SLEEP_ON_SELF_UPDATE + m_watchdog.sleep(); +#else + m_watchdog.ignorePathOnce(to); +#endif + + Filesystem::copy(file, to) + .and_then([&result]() { + result = true; + return Result(); + }) + .or_else([&](const FSError &error) { + TOOLBOX_ERROR_V("[FileSystemModel] Failed to copy file: {}", error.m_message[0]); + return Result(); + }); + +#if TOOLBOX_FS_WATCHDOG_SLEEP_ON_SELF_UPDATE + m_watchdog.wake(); +#endif - return getIndex_(to); + ModelIndex ret_index = makeIndex(to, getRowCount_(new_parent), new_parent); + signalEventListeners(to, event_flags); + return ret_index; } ModelIndex FileSystemModel::getIndex_(const fs_path &path) const { @@ -1047,12 +1200,7 @@ namespace Toolbox { makeIndex(path, getRowCount_(parent), parent); } - for (const auto &[key, listener] : m_listeners) { - if ((listener.second & FileSystemModelEventFlags::EVENT_FOLDER_ADDED) != - FileSystemModelEventFlags::NONE) { - listener.first(path, FileSystemModelEventFlags::EVENT_FOLDER_ADDED); - } - } + signalEventListeners(path, FileSystemModelEventFlags::EVENT_FOLDER_ADDED); } void FileSystemModel::folderModified(const fs_path &path) { @@ -1078,12 +1226,7 @@ namespace Toolbox { }); } - for (const auto &[key, listener] : m_listeners) { - if ((listener.second & FileSystemModelEventFlags::EVENT_FOLDER_MODIFIED) != - FileSystemModelEventFlags::NONE) { - listener.first(path, FileSystemModelEventFlags::EVENT_FOLDER_MODIFIED); - } - } + signalEventListeners(path, FileSystemModelEventFlags::EVENT_FOLDER_MODIFIED); } void FileSystemModel::fileAdded(const fs_path &path) { @@ -1098,12 +1241,7 @@ namespace Toolbox { makeIndex(path, getRowCount_(parent), parent); } - for (const auto &[key, listener] : m_listeners) { - if ((listener.second & FileSystemModelEventFlags::EVENT_FILE_ADDED) != - FileSystemModelEventFlags::NONE) { - listener.first(path, FileSystemModelEventFlags::EVENT_FILE_ADDED); - } - } + signalEventListeners(path, FileSystemModelEventFlags::EVENT_FILE_ADDED); } void FileSystemModel::fileModified(const fs_path &path) { @@ -1140,12 +1278,7 @@ namespace Toolbox { }); } - for (const auto &[key, listener] : m_listeners) { - if ((listener.second & FileSystemModelEventFlags::EVENT_FILE_MODIFIED) != - FileSystemModelEventFlags::NONE) { - listener.first(path, FileSystemModelEventFlags::EVENT_FILE_MODIFIED); - } - } + signalEventListeners(path, FileSystemModelEventFlags::EVENT_FILE_MODIFIED); } void FileSystemModel::pathRenamedSrc(const fs_path &old_path) { @@ -1191,12 +1324,7 @@ namespace Toolbox { } } - for (const auto &[key, listener] : m_listeners) { - if ((listener.second & FileSystemModelEventFlags::EVENT_PATH_RENAMED) != - FileSystemModelEventFlags::NONE) { - listener.first(new_path, FileSystemModelEventFlags::EVENT_PATH_RENAMED); - } - } + signalEventListeners(new_path, FileSystemModelEventFlags::EVENT_PATH_RENAMED); } void FileSystemModel::pathRemoved(const fs_path &path) { @@ -1225,10 +1353,14 @@ namespace Toolbox { } } + signalEventListeners(path, FileSystemModelEventFlags::EVENT_PATH_REMOVED); + } + + void FileSystemModel::signalEventListeners(const fs_path &path, + FileSystemModelEventFlags flags) { for (const auto &[key, listener] : m_listeners) { - if ((listener.second & FileSystemModelEventFlags::EVENT_PATH_REMOVED) != - FileSystemModelEventFlags::NONE) { - listener.first(path, FileSystemModelEventFlags::EVENT_PATH_REMOVED); + if ((listener.second & flags) != FileSystemModelEventFlags::NONE) { + listener.first(path, flags); } } } diff --git a/src/watchdog/fswatchdog.cpp b/src/watchdog/fswatchdog.cpp index 69dea6ba..6ae9841a 100644 --- a/src/watchdog/fswatchdog.cpp +++ b/src/watchdog/fswatchdog.cpp @@ -15,12 +15,20 @@ namespace Toolbox { void FileSystemWatchdog::sleep() { std::scoped_lock lock(m_mutex); - m_asleep = true; + m_asleep = true; + m_sleep_start = std::chrono::system_clock::now(); } void FileSystemWatchdog::wake() { std::scoped_lock lock(m_mutex); - m_asleep = false; + m_asleep = false; + m_sleep_end = std::chrono::system_clock::now(); + } + + void FileSystemWatchdog::ignorePathOnce(const fs_path &path) { m_ignore_paths.emplace(path); } + + void FileSystemWatchdog::ignorePathOnce(fs_path &&path) { + m_ignore_paths.emplace(std::move(path)); } void FileSystemWatchdog::addPath(const fs_path &path) { @@ -133,6 +141,22 @@ namespace Toolbox { } } + bool FileSystemWatchdog::wasSleepingForAlert(const fs_path &path) { + if (m_asleep) { + return true; + } + + bool result = false; + Filesystem::last_write_time(path).and_then( + [this, &result](const Filesystem::file_time_type &file_time) { + auto system_file_time = + std::chrono::clock_cast(file_time); + result = m_sleep_start <= system_file_time && m_sleep_end >= system_file_time; + return Result(); + }); + return result; + } + PathWatcher_::PathWatcher_(FileSystemWatchdog *watchdog, const fs_path &path) { m_watchdog = watchdog; m_path = path; @@ -172,11 +196,17 @@ namespace Toolbox { void PathWatcher_::callback_(const fs_path &path, const filewatch::Event event) { std::scoped_lock lock(m_watchdog->m_mutex); - if (m_watchdog->m_asleep) { + fs_path abs_path = m_path / path; + + if (m_watchdog->wasSleepingForAlert(abs_path)) { + return; + } + + if (m_watchdog->m_ignore_paths.contains(abs_path)) { + m_watchdog->m_ignore_paths.erase(abs_path); return; } - fs_path abs_path = m_path / path; bool is_dir = Filesystem::is_directory(abs_path).value_or(false); switch (event) { From 69ac1f8eea594bf173da3af514146679d3032632 Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Mon, 21 Oct 2024 13:04:20 -0500 Subject: [PATCH 106/129] Adjust code to hopefully make Linux compatible --- include/watchdog/fswatchdog.hpp | 4 ++-- src/watchdog/fswatchdog.cpp | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/include/watchdog/fswatchdog.hpp b/include/watchdog/fswatchdog.hpp index d96d1b0a..3f87fdf5 100644 --- a/include/watchdog/fswatchdog.hpp +++ b/include/watchdog/fswatchdog.hpp @@ -109,8 +109,8 @@ namespace Toolbox { private: bool m_asleep = false; - std::chrono::time_point m_sleep_start; - std::chrono::time_point m_sleep_end; + Filesystem::file_time_type m_sleep_start; + Filesystem::file_time_type m_sleep_end; std::unordered_set m_ignore_paths; diff --git a/src/watchdog/fswatchdog.cpp b/src/watchdog/fswatchdog.cpp index 6ae9841a..aff4f48c 100644 --- a/src/watchdog/fswatchdog.cpp +++ b/src/watchdog/fswatchdog.cpp @@ -16,13 +16,13 @@ namespace Toolbox { void FileSystemWatchdog::sleep() { std::scoped_lock lock(m_mutex); m_asleep = true; - m_sleep_start = std::chrono::system_clock::now(); + m_sleep_start = Filesystem::file_time_type::clock::now(); } void FileSystemWatchdog::wake() { std::scoped_lock lock(m_mutex); m_asleep = false; - m_sleep_end = std::chrono::system_clock::now(); + m_sleep_end = Filesystem::file_time_type::clock::now(); } void FileSystemWatchdog::ignorePathOnce(const fs_path &path) { m_ignore_paths.emplace(path); } @@ -149,9 +149,7 @@ namespace Toolbox { bool result = false; Filesystem::last_write_time(path).and_then( [this, &result](const Filesystem::file_time_type &file_time) { - auto system_file_time = - std::chrono::clock_cast(file_time); - result = m_sleep_start <= system_file_time && m_sleep_end >= system_file_time; + result = m_sleep_start <= file_time && m_sleep_end >= file_time; return Result(); }); return result; From 0ee4920b136ea26803679c7980962f96762be26d Mon Sep 17 00:00:00 2001 From: JoshuaMKW Date: Tue, 22 Oct 2024 11:43:48 -0500 Subject: [PATCH 107/129] Remove old comments --- src/gui/project/window.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 915b08b1..d1e2e7f6 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -401,7 +401,6 @@ namespace Toolbox::UI { }, [this](auto) { if (m_selected_indices_ctx.size() == 0) { - // TODO: Implement this interface Toolbox::Platform::OpenFileExplorer(m_file_system_model->getPath(m_view_index)); } else { std::set paths; @@ -414,7 +413,6 @@ namespace Toolbox::UI { } } for (const fs_path &path : paths) { - // TODO: Implement this interface Toolbox::Platform::OpenFileExplorer(path); } } From ed266519824c0ccf292e4ea15c07da770b2d1caf Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Wed, 23 Oct 2024 15:43:54 -0700 Subject: [PATCH 108/129] Undo the bad window sizing fix and introduce a new one --- src/gui/window.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 53af641b..155d5931 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -33,7 +33,6 @@ namespace Toolbox::UI { if (size == getSize()) { return; } - m_is_resized = true; GUIApplication::instance().dispatchEvent(getUUID(), EVENT_WINDOW_RESIZE, size); } @@ -41,7 +40,6 @@ namespace Toolbox::UI { if (pos == getPos()) { return; } - m_is_repositioned = true; GUIApplication::instance().dispatchEvent(getUUID(), EVENT_WINDOW_MOVE, pos); } @@ -223,20 +221,18 @@ namespace Toolbox::UI { // Establish window constraints if (window) { - if (window->Size != m_prev_size && m_is_resized) { + if (window->Size != m_prev_size) { if (m_next_size.x >= 0.0f && m_next_size.y >= 0.0f) { GUIApplication::instance().dispatchEvent( getUUID(), EVENT_WINDOW_RESIZE, window->Size); } ImGui::SetWindowSize(window, m_prev_size, ImGuiCond_Always); - m_is_resized = false; } - if (window->Pos != m_prev_pos && m_is_repositioned) { + if (window->Pos != m_prev_pos) { GUIApplication::instance().dispatchEvent( getUUID(), EVENT_WINDOW_MOVE, window->Pos); ImGui::SetWindowPos(window, m_prev_pos, ImGuiCond_Always); - m_is_repositioned = false; } } @@ -268,6 +264,8 @@ namespace Toolbox::UI { case EVENT_WINDOW_MOVE: { ImVec2 win_pos = ev->getGlobalPoint(); setLayerPos(win_pos); + std::string window_name = std::format("{}###{}", title(), ev->getTargetId()); + ImGui::SetWindowPos(window_name.c_str(), win_pos, ImGuiCond_Always); ev->accept(); break; } @@ -282,6 +280,8 @@ namespace Toolbox::UI { win_size.y = std::min(win_size.y, m_max_size->y); } setLayerSize(win_size); + std::string window_name = std::format("{}###{}", title(), ev->getTargetId()); + ImGui::SetWindowSize(window_name.c_str(), win_size, ImGuiCond_Always); ev->accept(); break; } From 8c97e201474bc3e7826583fc38c3aea49973dd50 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Thu, 24 Oct 2024 14:30:52 -0700 Subject: [PATCH 109/129] Fix file watching in subdirectories on Linux --- lib/FileWatch.hpp | 56 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/lib/FileWatch.hpp b/lib/FileWatch.hpp index 8df7621e..8f7fe44f 100644 --- a/lib/FileWatch.hpp +++ b/lib/FileWatch.hpp @@ -251,8 +251,8 @@ namespace filewatch { #if __unix__ struct FolderInfo { - int folder; - int watch; + int inotify_handle; + std::unordered_map watches; }; FolderInfo _directory; @@ -340,7 +340,9 @@ namespace filewatch { #ifdef _WIN32 SetEvent(_close_event); #elif __unix__ - inotify_rm_watch(_directory.folder, _directory.watch); + for (auto &[wd, path] : _directory.watches) { + inotify_rm_watch(_directory.inotify_handle, wd); + } #elif FILEWATCH_PLATFORM_MAC if (_run_loop) { CFRunLoopStop(_run_loop); @@ -354,7 +356,7 @@ namespace filewatch { #ifdef _WIN32 CloseHandle(_directory); #elif __unix__ - close(_directory.folder); + close(_directory.inotify_handle); #elif FILEWATCH_PLATFORM_MAC FSEventStreamStop(_directory); FSEventStreamInvalidate(_directory); @@ -560,10 +562,24 @@ namespace filewatch { } return S_ISREG(statbuf.st_mode); } + std::vector get_subdirectories(const std::filesystem::path &path) { + std::vector result; + result.push_back(path); + for (const auto &entry : + std::filesystem::directory_iterator(std::filesystem::path(path))) { + if (entry.is_directory()) { + for (const auto &sub_path : get_subdirectories(entry.path())) { + result.push_back(sub_path); + } + result.push_back(entry.path()); + } + } + return result; + } FolderInfo get_directory(const StringType &path) { - const auto folder = inotify_init(); - if (folder < 0) { + const auto inotify_handle = inotify_init(); + if (inotify_handle < 0) { throw std::system_error(errno, std::system_category()); } @@ -579,12 +595,16 @@ namespace filewatch { } }(); - const auto watch = - inotify_add_watch(folder, watch_path.c_str(), IN_MODIFY | IN_CREATE | IN_DELETE); - if (watch < 0) { - throw std::system_error(errno, std::system_category()); + std::unordered_map watches; + for (auto &subdir_path : get_subdirectories(watch_path)) { + const auto watch_fd = inotify_add_watch(inotify_handle, watch_path.c_str(), + IN_MODIFY | IN_CREATE | IN_DELETE); + watches[watch_fd] = subdir_path; + if (watch_fd < 0) { + throw std::system_error(errno, std::system_category()); + } } - return {folder, watch}; + return {inotify_handle, watches}; } void monitor_directory() { @@ -593,7 +613,7 @@ namespace filewatch { _running.set_value(); while (_destory == false) { const auto length = - read(_directory.folder, static_cast(buffer.data()), buffer.size()); + read(_directory.inotify_handle, static_cast(buffer.data()), buffer.size()); if (length > 0) { int i = 0; std::vector> parsed_information; @@ -601,14 +621,22 @@ namespace filewatch { struct inotify_event *event = reinterpret_cast(&buffer[i]); // NOLINT if (event->len) { - const UnderpinningString changed_file{event->name}; + const UnderpinningString changed_file{(_directory.watches[event->wd] / event->name).c_str()}; if (pass_filter(changed_file)) { if (event->mask & IN_CREATE) { parsed_information.emplace_back(StringType{changed_file}, Event::added); + if (std::filesystem::is_directory(changed_file)) { + int new_watch_fd = inotify_add_watch(_directory.inotify_handle, changed_file.c_str(), IN_MODIFY | IN_CREATE | IN_DELETE); + _directory.watches[new_watch_fd] = changed_file; + } } else if (event->mask & IN_DELETE) { parsed_information.emplace_back(StringType{changed_file}, Event::removed); + if (std::filesystem::is_directory(changed_file)) { + inotify_rm_watch(_directory.inotify_handle, event->wd); + _directory.watches.erase(event->wd); + } } else if (event->mask & IN_MODIFY) { parsed_information.emplace_back(StringType{changed_file}, Event::modified); @@ -698,7 +726,7 @@ namespace filewatch { #elif _WIN32 static StringType absolute_path_of(const StringType &path) { constexpr size_t size = IsWChar::value ? MAX_PATH : 32767 * sizeof(wchar_t); - char buf[size * 10] = {}; + char buf[size * 10] = {}; DWORD length = IsWChar::value From 6a05975c2c77b1650a43ad0011fe2c731810a645 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Sat, 26 Oct 2024 13:35:36 -0700 Subject: [PATCH 110/129] Oops not sure how I didn't catch this. --- lib/FileWatch.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/FileWatch.hpp b/lib/FileWatch.hpp index 8f7fe44f..723e0905 100644 --- a/lib/FileWatch.hpp +++ b/lib/FileWatch.hpp @@ -597,7 +597,7 @@ namespace filewatch { std::unordered_map watches; for (auto &subdir_path : get_subdirectories(watch_path)) { - const auto watch_fd = inotify_add_watch(inotify_handle, watch_path.c_str(), + const auto watch_fd = inotify_add_watch(inotify_handle, subdir_path.c_str(), IN_MODIFY | IN_CREATE | IN_DELETE); watches[watch_fd] = subdir_path; if (watch_fd < 0) { From 0d90943c95574f8044142ab5ab4e4e293e0a59eb Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Mon, 28 Oct 2024 10:59:15 -0700 Subject: [PATCH 111/129] Debug message instead of error on empty string rename --- src/gui/project/window.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index d1e2e7f6..8a3b5523 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -166,8 +166,12 @@ namespace Toolbox::UI { ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_EnterReturnsTrue); if (done) { - m_file_system_model->rename( - m_view_proxy.toSourceIndex(child_index), m_rename_buffer); + if (std::strlen(m_rename_buffer) == 0) { + TOOLBOX_DEBUG_LOG("Attempted to rename to the empty string, ignoring."); + } else { + m_file_system_model->rename( + m_view_proxy.toSourceIndex(child_index), m_rename_buffer); + } } ImGui::SetCursorScreenPos(pos); ImGui::PopItemWidth(); From 7ed8650c101e63ace998a3d51e1c5cbd368e1015 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Mon, 28 Oct 2024 11:31:25 -0700 Subject: [PATCH 112/129] Update glfw fork to include the docs --- lib/glfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/glfw b/lib/glfw index 1014db47..06f21df2 160000 --- a/lib/glfw +++ b/lib/glfw @@ -1 +1 @@ -Subproject commit 1014db47dc27708d3f71f790579bc67b79ea4ea5 +Subproject commit 06f21df20e7e816acc121636226c878c76addeda From 5ddc437fda85bdd8ebb46bac7ff4548968ddf62d Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Mon, 28 Oct 2024 12:38:29 -0700 Subject: [PATCH 113/129] Visual indicator for invalid rename targets --- include/gui/project/window.hpp | 3 ++ src/gui/project/window.cpp | 52 +++++++++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index dc4a2013..f4113281 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -111,6 +111,8 @@ namespace Toolbox::UI { bool isPathForScene(const ModelIndex &index) const; private: + + bool isValidName(const char* name, const std::vector &selected_indices) const; fs_path m_project_root; // TODO: Have filesystem model. @@ -132,6 +134,7 @@ namespace Toolbox::UI { bool m_is_renaming = false; char m_rename_buffer[128]; + bool m_is_valid_name = true; bool m_delete_without_request = false; bool m_delete_requested = false; diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 8a3b5523..2afd4b5b 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -160,12 +160,24 @@ namespace Toolbox::UI { ImGui::SetCursorScreenPos(rename_pos); ImGui::SetKeyboardFocusHere(); + if (m_is_valid_name) { + ImGui::PushStyleColor(ImGuiCol_Text, + ImGui::ColorConvertFloat4ToU32( + ImGui::GetStyleColorVec4(ImGuiCol_Text))); + } else { + ImGui::PushStyleColor(ImGuiCol_Text, + ImGui::ColorConvertFloat4ToU32(ImVec4(1.0, 0.3, 0.3, 1.0))); + } ImGui::PushItemWidth(label_width); - bool done = ImGui::InputText( + bool edited = ImGui::InputText( "##rename", m_rename_buffer, IM_ARRAYSIZE(m_rename_buffer), - ImGuiInputTextFlags_AutoSelectAll | - ImGuiInputTextFlags_EnterReturnsTrue); - if (done) { + ImGuiInputTextFlags_AutoSelectAll); + // Pop text color + ImGui::PopStyleColor(1); + if (edited) { + m_is_valid_name = isValidName(m_rename_buffer, m_selected_indices); + } + if (ImGui::IsItemDeactivatedAfterEdit() && m_is_valid_name) { if (std::strlen(m_rename_buffer) == 0) { TOOLBOX_DEBUG_LOG("Attempted to rename to the empty string, ignoring."); } else { @@ -850,5 +862,37 @@ namespace Toolbox::UI { } void ProjectViewWindow::initFolderAssets(const ModelIndex &index) {} + bool ProjectViewWindow::isValidName(const char* name, const std::vector &selected_indices) const { + TOOLBOX_ASSERT(selected_indices.size() == 1, "Can't rename more than one file!"); + + ModelIndex parent = m_file_system_model->getParent(selected_indices[0]); + for (size_t i = 0; i < m_file_system_model->getRowCount(parent); ++i) { + ModelIndex child_index = m_file_system_model->getIndex(i, 0, parent); + if (child_index == selected_indices[0]) { + continue; + } + std::string child_name = m_file_system_model->getDisplayText(child_index); + if (std::strcmp(child_name.c_str(), name) == 0) { + return false; + } + } + if (std::strchr(name, '/')) { + return false; + } + //#ifdef TOOLBOX_PLATFORM_WINDOWS + if (std::strchr(name, '\\') || + std::strchr(name, '<') || + std::strchr(name, '>') || + std::strchr(name, ':') || + std::strchr(name, '"') || + std::strchr(name, '|') || + std::strchr(name, '?') || + std::strchr(name, '*')) { + return false; + } + //#endif + + return true; + } } // namespace Toolbox::UI From 9d8ad1758d41d6ab2ceb1900efe732623102755f Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Tue, 29 Oct 2024 16:23:59 -0700 Subject: [PATCH 114/129] Don't put windows file restrictions on Linux builds --- src/gui/project/window.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 2afd4b5b..6c1584c1 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -879,7 +879,7 @@ namespace Toolbox::UI { if (std::strchr(name, '/')) { return false; } - //#ifdef TOOLBOX_PLATFORM_WINDOWS + #ifdef TOOLBOX_PLATFORM_WINDOWS if (std::strchr(name, '\\') || std::strchr(name, '<') || std::strchr(name, '>') || @@ -890,7 +890,7 @@ namespace Toolbox::UI { std::strchr(name, '*')) { return false; } - //#endif + #endif return true; } From 90664b789901edd5ae46686a1907891d15e1bdfa Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Tue, 29 Oct 2024 18:09:52 -0700 Subject: [PATCH 115/129] Case insensitive file name matching for rename on windows --- include/gui/project/window.hpp | 2 +- src/gui/project/window.cpp | 32 +++++++++++++++++++++----------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/include/gui/project/window.hpp b/include/gui/project/window.hpp index f4113281..8e1a4fc9 100644 --- a/include/gui/project/window.hpp +++ b/include/gui/project/window.hpp @@ -112,7 +112,7 @@ namespace Toolbox::UI { private: - bool isValidName(const char* name, const std::vector &selected_indices) const; + bool isValidName(const std::string &name, const std::vector &selected_indices) const; fs_path m_project_root; // TODO: Have filesystem model. diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 6c1584c1..59188c57 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -862,7 +862,16 @@ namespace Toolbox::UI { } void ProjectViewWindow::initFolderAssets(const ModelIndex &index) {} - bool ProjectViewWindow::isValidName(const char* name, const std::vector &selected_indices) const { + bool char_equals(char a, char b) + { +#ifdef TOOLBOX_PLATFORM_WINDOWS + return std::tolower(static_cast(a)) == + std::tolower(static_cast(b)); +#else + return a == b; +#endif + } + bool ProjectViewWindow::isValidName(const std::string &name, const std::vector &selected_indices) const { TOOLBOX_ASSERT(selected_indices.size() == 1, "Can't rename more than one file!"); ModelIndex parent = m_file_system_model->getParent(selected_indices[0]); @@ -872,22 +881,23 @@ namespace Toolbox::UI { continue; } std::string child_name = m_file_system_model->getDisplayText(child_index); - if (std::strcmp(child_name.c_str(), name) == 0) { + if (std::equal(child_name.begin(), child_name.end(), + name.begin(), name.end(), char_equals)){ return false; } } - if (std::strchr(name, '/')) { + if (name.contains('/')) { return false; } #ifdef TOOLBOX_PLATFORM_WINDOWS - if (std::strchr(name, '\\') || - std::strchr(name, '<') || - std::strchr(name, '>') || - std::strchr(name, ':') || - std::strchr(name, '"') || - std::strchr(name, '|') || - std::strchr(name, '?') || - std::strchr(name, '*')) { + if (name.contains('\\') || + name.contains('<') || + name.contains('>') || + name.contains(':') || + name.contains('"') || + name.contains('|') || + name.contains('?') || + name.contains('*')) { return false; } #endif From 42111638fc77d3ba0cfb253920ae6c772e7479b0 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Tue, 29 Oct 2024 18:13:27 -0700 Subject: [PATCH 116/129] Document where the windows filename constraints came from --- src/gui/project/window.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 59188c57..f3f4ecc7 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -890,6 +890,8 @@ namespace Toolbox::UI { return false; } #ifdef TOOLBOX_PLATFORM_WINDOWS + // Windows naming constraints sourced from here: + // https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file if (name.contains('\\') || name.contains('<') || name.contains('>') || From 68713e5bbb4cccf092600b14f98f3e8f9e6561a8 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Tue, 29 Oct 2024 18:13:43 -0700 Subject: [PATCH 117/129] Windows filenames cannot end with a space or period --- src/gui/project/window.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index f3f4ecc7..8be008f1 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -902,6 +902,10 @@ namespace Toolbox::UI { name.contains('*')) { return false; } + if (name.back() == ' ' || + name.back() == '.') { + return false; + } #endif return true; From c1e228bc36dbd58ec1fa2175ac22687cb2836ac4 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Tue, 29 Oct 2024 18:29:10 -0700 Subject: [PATCH 118/129] More windows file constraints --- src/gui/project/window.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 8be008f1..3e1c95b5 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -6,6 +6,7 @@ #include #include +#include namespace Toolbox::UI { @@ -906,6 +907,29 @@ namespace Toolbox::UI { name.back() == '.') { return false; } + if (name == "CON" || + name == "PRN" || + name == "AUX" || + name == "NUL"){ + return false; + } + if (name.starts_with("CON.") || + name.starts_with("PRN.") || + name.starts_with("AUX.") || + name.starts_with("NUL.")) { + return false; + } + if ((name.starts_with("COM") || + name.starts_with("LPT")) && + name.length() == 4 && + (isdigit(name.back()) || + // The escapes for superscript 1, 2, and 3, which are + // also disallowed after these patterns. + name.back() == '\XB6' || + name.back() == '\XB2' || + name.back() == '\XB3'){ + return false; + } #endif return true; From 25eb30d1d353fc0bff0ebe54090ba7f82c825b58 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Tue, 29 Oct 2024 18:29:45 -0700 Subject: [PATCH 119/129] Clang formatting rename validation code --- src/gui/project/window.cpp | 40 +++++++++++++------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 3e1c95b5..49b28b24 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -4,9 +4,9 @@ #include "gui/new_item/window.hpp" #include "model/fsmodel.hpp" +#include #include #include -#include namespace Toolbox::UI { @@ -863,16 +863,16 @@ namespace Toolbox::UI { } void ProjectViewWindow::initFolderAssets(const ModelIndex &index) {} - bool char_equals(char a, char b) - { + bool char_equals(char a, char b) { #ifdef TOOLBOX_PLATFORM_WINDOWS return std::tolower(static_cast(a)) == - std::tolower(static_cast(b)); + std::tolower(static_cast(b)); #else return a == b; #endif } - bool ProjectViewWindow::isValidName(const std::string &name, const std::vector &selected_indices) const { + bool ProjectViewWindow::isValidName(const std::string &name, + const std::vector &selected_indices) const { TOOLBOX_ASSERT(selected_indices.size() == 1, "Can't rename more than one file!"); ModelIndex parent = m_file_system_model->getParent(selected_indices[0]); @@ -882,40 +882,28 @@ namespace Toolbox::UI { continue; } std::string child_name = m_file_system_model->getDisplayText(child_index); - if (std::equal(child_name.begin(), child_name.end(), - name.begin(), name.end(), char_equals)){ + if (std::equal(child_name.begin(), child_name.end(), name.begin(), name.end(), + char_equals)) { return false; } } if (name.contains('/')) { return false; } - #ifdef TOOLBOX_PLATFORM_WINDOWS +#ifdef TOOLBOX_PLATFORM_WINDOWS // Windows naming constraints sourced from here: // https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file - if (name.contains('\\') || - name.contains('<') || - name.contains('>') || - name.contains(':') || - name.contains('"') || - name.contains('|') || - name.contains('?') || - name.contains('*')) { + if (name.contains('\\') || name.contains('<') || name.contains('>') || name.contains(':') || + name.contains('"') || name.contains('|') || name.contains('?') || name.contains('*')) { return false; } - if (name.back() == ' ' || - name.back() == '.') { + if (name.back() == ' ' || name.back() == '.') { return false; } - if (name == "CON" || - name == "PRN" || - name == "AUX" || - name == "NUL"){ + if (name == "CON" || name == "PRN" || name == "AUX" || name == "NUL") { return false; } - if (name.starts_with("CON.") || - name.starts_with("PRN.") || - name.starts_with("AUX.") || + if (name.starts_with("CON.") || name.starts_with("PRN.") || name.starts_with("AUX.") || name.starts_with("NUL.")) { return false; } @@ -930,7 +918,7 @@ namespace Toolbox::UI { name.back() == '\XB3'){ return false; } - #endif +#endif return true; } From 49ec8176d815df5d34401fe77bd4460798dc921b Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Tue, 29 Oct 2024 18:29:59 -0700 Subject: [PATCH 120/129] Clang format some of the naming checking code --- src/gui/project/window.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 49b28b24..09fb5d35 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -162,28 +162,33 @@ namespace Toolbox::UI { ImGui::SetKeyboardFocusHere(); if (m_is_valid_name) { - ImGui::PushStyleColor(ImGuiCol_Text, - ImGui::ColorConvertFloat4ToU32( - ImGui::GetStyleColorVec4(ImGuiCol_Text))); - } else { - ImGui::PushStyleColor(ImGuiCol_Text, - ImGui::ColorConvertFloat4ToU32(ImVec4(1.0, 0.3, 0.3, 1.0))); + ImGui::PushStyleColor( + ImGuiCol_Text, + ImGui::ColorConvertFloat4ToU32( + ImGui::GetStyleColorVec4(ImGuiCol_Text))); + } else { + ImGui::PushStyleColor( + ImGuiCol_Text, + ImGui::ColorConvertFloat4ToU32(ImVec4(1.0, 0.3, 0.3, 1.0))); } ImGui::PushItemWidth(label_width); - bool edited = ImGui::InputText( - "##rename", m_rename_buffer, IM_ARRAYSIZE(m_rename_buffer), - ImGuiInputTextFlags_AutoSelectAll); + bool edited = ImGui::InputText("##rename", m_rename_buffer, + IM_ARRAYSIZE(m_rename_buffer), + ImGuiInputTextFlags_AutoSelectAll); // Pop text color ImGui::PopStyleColor(1); if (edited) { - m_is_valid_name = isValidName(m_rename_buffer, m_selected_indices); + m_is_valid_name = + isValidName(m_rename_buffer, m_selected_indices); } if (ImGui::IsItemDeactivatedAfterEdit() && m_is_valid_name) { if (std::strlen(m_rename_buffer) == 0) { - TOOLBOX_DEBUG_LOG("Attempted to rename to the empty string, ignoring."); + TOOLBOX_DEBUG_LOG( + "Attempted to rename to the empty string, ignoring."); } else { m_file_system_model->rename( - m_view_proxy.toSourceIndex(child_index), m_rename_buffer); + m_view_proxy.toSourceIndex(child_index), + m_rename_buffer); } } ImGui::SetCursorScreenPos(pos); From e9e3fc029d4d902441a8f276656177cb92434e7e Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Tue, 29 Oct 2024 18:57:24 -0700 Subject: [PATCH 121/129] Oops bad syntax --- src/gui/project/window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 09fb5d35..27d7b45b 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -920,7 +920,7 @@ namespace Toolbox::UI { // also disallowed after these patterns. name.back() == '\XB6' || name.back() == '\XB2' || - name.back() == '\XB3'){ + name.back() == '\XB3')){ return false; } #endif From 2c371d0e05a45fa395d720d159d2879f9fbac263 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Wed, 30 Oct 2024 14:20:42 -0700 Subject: [PATCH 122/129] Check condition on keybind actions *after* taking open action --- include/gui/context_menu.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/gui/context_menu.hpp b/include/gui/context_menu.hpp index 0edcb6c0..5b5c7084 100644 --- a/include/gui/context_menu.hpp +++ b/include/gui/context_menu.hpp @@ -134,12 +134,16 @@ namespace Toolbox::UI { bool keybind_pressed = option.m_keybind.isInputMatching(); if (keybind_pressed && !option.m_keybind_used) { - m_open_event(ctx); - option.m_keybind_used = true; - option.m_op(ctx); + if (m_open_event) { + m_open_event(ctx); + } + if (option.m_condition()) { + option.m_keybind_used = true; + option.m_op(ctx); + } } - if (!keybind_pressed) { + if (!keybind_pressed || !option.m_condition()) { option.m_keybind_used = false; } } From 6d8875749b653cd8e5f7918b4b7ef598b42c5037 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Wed, 30 Oct 2024 14:57:47 -0700 Subject: [PATCH 123/129] Allow deselecting a single item in project view --- src/gui/project/window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 27d7b45b..ed7cff63 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -684,7 +684,7 @@ namespace Toolbox::UI { } if (is_left_button) { - if (m_selected_indices.size() > 1) { + if (m_selected_indices.size() > 0) { m_selected_indices.clear(); m_last_selected_index = ModelIndex(); if (m_view_proxy.validateIndex(child_index)) { From 58471a5294e85dcc4d7ab9804968b757f5f24f76 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Mon, 4 Nov 2024 14:59:34 -0800 Subject: [PATCH 124/129] Allow adding modifiers to keybindings --- include/core/input/keycode.hpp | 1 + include/core/keybind/keybind.hpp | 4 +++- src/core/input/input.cpp | 3 +++ src/core/keybind/keybind.cpp | 36 ++++++++++++++++++++++++++------ src/gui/project/window.cpp | 20 ++++++++---------- 5 files changed, 46 insertions(+), 18 deletions(-) diff --git a/include/core/input/keycode.hpp b/include/core/input/keycode.hpp index 642e79f6..5e023237 100644 --- a/include/core/input/keycode.hpp +++ b/include/core/input/keycode.hpp @@ -146,6 +146,7 @@ namespace Toolbox::Input { KEY_SUPER = (1 << 3), }; TOOLBOX_BITWISE_ENUM(KeyModifier); + bool operator!(KeyModifier mod); using KeyModifiers = KeyModifier; diff --git a/include/core/keybind/keybind.hpp b/include/core/keybind/keybind.hpp index 8090f322..0fa2df16 100644 --- a/include/core/keybind/keybind.hpp +++ b/include/core/keybind/keybind.hpp @@ -19,7 +19,8 @@ namespace Toolbox { ~KeyBind() = default; KeyBind(std::initializer_list keys); - explicit KeyBind(const Input::KeyCodes &keys); + explicit KeyBind(const Input::KeyCodes &keys, + const Input::KeyModifiers &mods = Input::KeyModifiers::KEY_NONE); [[nodiscard]] static KeyBind FromString(const std::string &); @@ -45,6 +46,7 @@ namespace Toolbox { private: Input::KeyCodes m_key_combo; + Input::KeyModifiers m_key_mods = Input::KeyModifiers::KEY_NONE; }; } // namespace Toolbox \ No newline at end of file diff --git a/src/core/input/input.cpp b/src/core/input/input.cpp index 7c2401e3..24b7791f 100644 --- a/src/core/input/input.cpp +++ b/src/core/input/input.cpp @@ -294,5 +294,8 @@ namespace Toolbox::Input { ImGui_ImplGlfw_ScrollCallback(window, xoffset, yoffset); } + bool operator!(KeyModifier mod) { + return ((u8)mod == 0); + } } // namespace Toolbox::Input diff --git a/src/core/keybind/keybind.cpp b/src/core/keybind/keybind.cpp index f700f6e4..6adbaa9d 100644 --- a/src/core/keybind/keybind.cpp +++ b/src/core/keybind/keybind.cpp @@ -12,7 +12,8 @@ namespace Toolbox { KeyBind::KeyBind(std::initializer_list keys) : m_key_combo(keys) {} - KeyBind::KeyBind(const Input::KeyCodes &keys) : m_key_combo(keys) {} + KeyBind::KeyBind(const Input::KeyCodes &keys, const Input::KeyModifiers &mods) + : m_key_combo(keys), m_key_mods(mods) {} KeyBind KeyBind::FromString(const std::string &bind_str) { KeyBind result; @@ -22,7 +23,17 @@ namespace Toolbox { size_t next_delimiter_index = bind_str.find('+', key_begin_index); std::string key_name = bind_str.substr(key_begin_index, next_delimiter_index - key_begin_index); - result.m_key_combo.push_back(KeyNameToEnum(key_name)); + if (key_name == "Shift") { + result.m_key_mods |= Input::KeyModifier::KEY_SHIFT; + } else if (key_name == "Ctrl") { + result.m_key_mods |= Input::KeyModifier::KEY_CTRL; + } else if (key_name == "Alt") { + result.m_key_mods |= Input::KeyModifier::KEY_ALT; + } else if (key_name == "Super") { + result.m_key_mods |= Input::KeyModifier::KEY_SUPER; + } else { + result.m_key_combo.push_back(KeyNameToEnum(key_name)); + } // Last character is + or we reached end of string if (next_delimiter_index >= std::string::npos - 1) { @@ -37,11 +48,24 @@ namespace Toolbox { bool KeyBind::isInputMatching() const { return std::all_of(m_key_combo.begin(), m_key_combo.end(), - [](Input::KeyCode keybind) { return Input::GetKey(keybind); }); + [](Input::KeyCode keybind) { return Input::GetKey(keybind); }) && + (Input::GetPressedKeyModifiers() & m_key_mods) == m_key_mods; } std::string KeyBind::toString() const { std::string keybind_name = ""; + if (!!(m_key_mods & Input::KeyModifier::KEY_CTRL)) { + keybind_name += "Ctrl+"; + } + if (!!(m_key_mods & Input::KeyModifier::KEY_SHIFT)) { + keybind_name += "Shift+"; + } + if (!!(m_key_mods & Input::KeyModifier::KEY_ALT)) { + keybind_name += "Alt+"; + } + if (!!(m_key_mods & Input::KeyModifier::KEY_SUPER)) { + keybind_name += "Super+"; + } for (size_t j = 0; j < m_key_combo.size(); ++j) { Input::KeyCode key = m_key_combo.at(j); keybind_name += KeyNameFromEnum(key); @@ -55,7 +79,7 @@ namespace Toolbox { bool KeyBind::scanNextInputKey() { // Check if any of the keys are still being held bool any_keys_held = std::any_of(m_key_combo.begin(), m_key_combo.end(), - [](Input::KeyCode key) { return Input::GetKey(key); }); + [](Input::KeyCode key) { return Input::GetKey(key); }) || !!(Input::GetPressedKeyModifiers() & m_key_mods); if (m_key_combo.size() > 0 && !any_keys_held) { return true; } @@ -73,11 +97,11 @@ namespace Toolbox { } bool KeyBind::operator==(const KeyBind &other) const { - return m_key_combo == other.m_key_combo; + return m_key_combo == other.m_key_combo && m_key_mods == other.m_key_mods; } bool KeyBind::operator!=(const KeyBind &other) const { - return m_key_combo != other.m_key_combo; + return m_key_combo != other.m_key_combo || m_key_mods != other.m_key_mods; } } // namespace Toolbox \ No newline at end of file diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index ed7cff63..2ec87cf1 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -402,7 +402,7 @@ namespace Toolbox::UI { [this](const ModelIndex &index) { m_selected_indices_ctx = m_selected_indices; }); m_folder_view_context_menu.addOption( - "Open", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_O}), + "Open", KeyBind({KeyCode::KEY_O}, KeyModifier::KEY_CTRL), [this]() { return m_selected_indices_ctx.size() > 0 && std::all_of(m_selected_indices_ctx.begin(), m_selected_indices_ctx.end(), @@ -415,7 +415,7 @@ namespace Toolbox::UI { m_folder_view_context_menu.addOption( "Open in Explorer", - KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_LEFTSHIFT, KeyCode::KEY_O}), + KeyBind({KeyCode::KEY_O}, KeyModifier::KEY_CTRL | KeyModifier::KEY_SHIFT), [this]() { return std::all_of( m_selected_indices_ctx.begin(), m_selected_indices_ctx.end(), @@ -443,8 +443,7 @@ namespace Toolbox::UI { m_folder_view_context_menu.addDivider(); m_folder_view_context_menu.addOption( - "Copy Path", - KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_LEFTSHIFT, KeyCode::KEY_C}), + "Copy Path", KeyBind({KeyCode::KEY_C}, KeyModifier::KEY_CTRL | KeyModifier::KEY_SHIFT), [this]() { return true; }, [this](auto) { std::string paths; @@ -462,11 +461,11 @@ namespace Toolbox::UI { m_folder_view_context_menu.addDivider(); m_folder_view_context_menu.addOption( - "Cut", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_X}), + "Cut", KeyBind({KeyCode::KEY_X}, KeyModifier::KEY_CTRL), [this]() { return m_selected_indices_ctx.size() > 0; }, [this](auto) {}); m_folder_view_context_menu.addOption( - "Copy", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_C}), + "Copy", KeyBind({KeyCode::KEY_C}, KeyModifier::KEY_CTRL), [this]() { return m_selected_indices_ctx.size() > 0; }, [this](auto) { actionCopyIndexes(m_selected_indices_ctx); }); @@ -484,12 +483,12 @@ namespace Toolbox::UI { }); m_folder_view_context_menu.addOption( - "Rename", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_R}), + "Rename", KeyBind({KeyCode::KEY_R}, KeyModifier::KEY_CTRL), [this]() { return m_selected_indices_ctx.size() == 1; }, [this](auto) { actionRenameIndex(m_selected_indices_ctx[0]); }); m_folder_view_context_menu.addOption( - "Paste", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_V}), + "Paste", KeyBind({KeyCode::KEY_V}, KeyModifier::KEY_CTRL), [this]() { return m_selected_indices_ctx.size() == 0; }, [this](auto) { auto content_types = SystemClipboard::instance().getAvailableContentFormats(); @@ -512,8 +511,7 @@ namespace Toolbox::UI { m_folder_view_context_menu.addDivider(); m_folder_view_context_menu.addOption( - "New Folder", - KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_LEFTSHIFT, KeyCode::KEY_N}), + "New Folder", KeyBind({KeyCode::KEY_N}, KeyModifier::KEY_CTRL | KeyModifier::KEY_SHIFT), [this]() { return m_selected_indices_ctx.size() == 0; }, [this](const ModelIndex &view_index) { std::string folder_name = @@ -528,7 +526,7 @@ namespace Toolbox::UI { }); m_folder_view_context_menu.addOption( - "New Item...", KeyBind({KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_N}), + "New Item...", KeyBind({KeyCode::KEY_N}, KeyModifier::KEY_CTRL), [this]() { return m_selected_indices_ctx.size() == 0; }, [this](const ModelIndex &view_index) { RefPtr window = From 97d9523afd72872e57303da4e7caffccc843fd8c Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Mon, 4 Nov 2024 15:00:01 -0800 Subject: [PATCH 125/129] Some clang format stuff --- src/gui/project/window.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/gui/project/window.cpp b/src/gui/project/window.cpp index 2ec87cf1..f31cd591 100644 --- a/src/gui/project/window.cpp +++ b/src/gui/project/window.cpp @@ -910,15 +910,11 @@ namespace Toolbox::UI { name.starts_with("NUL.")) { return false; } - if ((name.starts_with("COM") || - name.starts_with("LPT")) && - name.length() == 4 && + if ((name.starts_with("COM") || name.starts_with("LPT")) && name.length() == 4 && (isdigit(name.back()) || // The escapes for superscript 1, 2, and 3, which are // also disallowed after these patterns. - name.back() == '\XB6' || - name.back() == '\XB2' || - name.back() == '\XB3')){ + name.back() == '\XB6' || name.back() == '\XB2' || name.back() == '\XB3')) { return false; } #endif From fa8922e125fe9a65e17ecee891ed0470961b1920 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Mon, 4 Nov 2024 15:10:28 -0800 Subject: [PATCH 126/129] Assert that modifier keys aren't passed as normal keys --- src/core/keybind/keybind.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/core/keybind/keybind.cpp b/src/core/keybind/keybind.cpp index 6adbaa9d..b8f1653c 100644 --- a/src/core/keybind/keybind.cpp +++ b/src/core/keybind/keybind.cpp @@ -6,14 +6,37 @@ #include #include +#include "core/assert.hpp" #include "core/input/input.hpp" #include "core/keybind/keybind.hpp" namespace Toolbox { - KeyBind::KeyBind(std::initializer_list keys) : m_key_combo(keys) {} + KeyBind::KeyBind(std::initializer_list keys) : m_key_combo(keys) { + for (auto &key : keys) { + TOOLBOX_ASSERT( + key != Input::KeyCode::KEY_LEFTSHIFT && key != Input::KeyCode::KEY_RIGHTSHIFT && + key != Input::KeyCode::KEY_LEFTCONTROL && + key != Input::KeyCode::KEY_RIGHTCONTROL && key != Input::KeyCode::KEY_LEFTALT && + key != Input::KeyCode::KEY_RIGHTALT && key != Input::KeyCode::KEY_LEFTSUPER && + key != Input::KeyCode::KEY_RIGHTSUPER, + "Cannot use explicit modifier keys as part of keybind, pass them as modifiers " + "instead as a second argument bitmask") + } + } KeyBind::KeyBind(const Input::KeyCodes &keys, const Input::KeyModifiers &mods) - : m_key_combo(keys), m_key_mods(mods) {} + : m_key_combo(keys), m_key_mods(mods) { + for (auto &key : keys) { + TOOLBOX_ASSERT( + key != Input::KeyCode::KEY_LEFTSHIFT && key != Input::KeyCode::KEY_RIGHTSHIFT && + key != Input::KeyCode::KEY_LEFTCONTROL && + key != Input::KeyCode::KEY_RIGHTCONTROL && key != Input::KeyCode::KEY_LEFTALT && + key != Input::KeyCode::KEY_RIGHTALT && key != Input::KeyCode::KEY_LEFTSUPER && + key != Input::KeyCode::KEY_RIGHTSUPER, + "Cannot use explicit modifier keys as part of keybind, pass them as modifiers " + "instead as a second argument bitmask") + } + } KeyBind KeyBind::FromString(const std::string &bind_str) { KeyBind result; From 9b327f894d1883c1d6c1d824721cca5cf4478fdc Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Mon, 4 Nov 2024 15:10:45 -0800 Subject: [PATCH 127/129] More format stuff --- src/core/keybind/keybind.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/keybind/keybind.cpp b/src/core/keybind/keybind.cpp index b8f1653c..8323c9cb 100644 --- a/src/core/keybind/keybind.cpp +++ b/src/core/keybind/keybind.cpp @@ -72,7 +72,7 @@ namespace Toolbox { bool KeyBind::isInputMatching() const { return std::all_of(m_key_combo.begin(), m_key_combo.end(), [](Input::KeyCode keybind) { return Input::GetKey(keybind); }) && - (Input::GetPressedKeyModifiers() & m_key_mods) == m_key_mods; + (Input::GetPressedKeyModifiers() & m_key_mods) == m_key_mods; } std::string KeyBind::toString() const { @@ -102,7 +102,8 @@ namespace Toolbox { bool KeyBind::scanNextInputKey() { // Check if any of the keys are still being held bool any_keys_held = std::any_of(m_key_combo.begin(), m_key_combo.end(), - [](Input::KeyCode key) { return Input::GetKey(key); }) || !!(Input::GetPressedKeyModifiers() & m_key_mods); + [](Input::KeyCode key) { return Input::GetKey(key); }) || + !!(Input::GetPressedKeyModifiers() & m_key_mods); if (m_key_combo.size() > 0 && !any_keys_held) { return true; } From d767a4820452b1ee16a0e7218df73cbc43da2814 Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Mon, 11 Nov 2024 18:55:28 -0800 Subject: [PATCH 128/129] Update scene window bindings to new system --- src/gui/scene/window.cpp | 108 ++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 53 deletions(-) diff --git a/src/gui/scene/window.cpp b/src/gui/scene/window.cpp index bcc9b71b..66c4a83a 100644 --- a/src/gui/scene/window.cpp +++ b/src/gui/scene/window.cpp @@ -1460,7 +1460,7 @@ void SceneWindow::buildContextMenuVirtualObj() { m_hierarchy_virtual_node_menu = ContextMenu>(); m_hierarchy_virtual_node_menu.addOption( - "Insert Object Before...", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_N}, + "Insert Object Before...", KeyBind({KeyCode::KEY_N}, KeyModifier::KEY_CTRL), [this](SelectionNodeInfo info) { m_create_obj_dialog.setInsertPolicy(CreateObjDialog::InsertPolicy::INSERT_BEFORE); m_create_obj_dialog.open(); @@ -1468,7 +1468,7 @@ void SceneWindow::buildContextMenuVirtualObj() { }); m_hierarchy_virtual_node_menu.addOption( - "Insert Object After...", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_N}, + "Insert Object After...", KeyBind({KeyCode::KEY_N}, KeyModifier::KEY_CTRL), [this](SelectionNodeInfo info) { m_create_obj_dialog.setInsertPolicy(CreateObjDialog::InsertPolicy::INSERT_AFTER); m_create_obj_dialog.open(); @@ -1477,18 +1477,18 @@ void SceneWindow::buildContextMenuVirtualObj() { m_hierarchy_virtual_node_menu.addDivider(); - m_hierarchy_virtual_node_menu.addOption("Rename...", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_R}, - [this](SelectionNodeInfo info) { - m_rename_obj_dialog.open(); - m_rename_obj_dialog.setOriginalName( - info.m_selected->getNameRef().name()); - return; - }); + m_hierarchy_virtual_node_menu.addOption( + "Rename...", KeyBind({KeyCode::KEY_R}, KeyModifier::KEY_CTRL), + [this](SelectionNodeInfo info) { + m_rename_obj_dialog.open(); + m_rename_obj_dialog.setOriginalName(info.m_selected->getNameRef().name()); + return; + }); m_hierarchy_virtual_node_menu.addDivider(); m_hierarchy_virtual_node_menu.addOption( - "Copy", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_C}, + "Copy", KeyBind({KeyCode::KEY_C}, KeyModifier::KEY_CTRL), [this](SelectionNodeInfo info) { info.m_selected = make_deep_clone(info.m_selected); GUIApplication::instance().getSceneObjectClipboard().setData(info); @@ -1496,7 +1496,7 @@ void SceneWindow::buildContextMenuVirtualObj() { }); m_hierarchy_virtual_node_menu.addOption( - "Paste", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_V}, + "Paste", KeyBind({KeyCode::KEY_V}, KeyModifier::KEY_CTRL), [this](SelectionNodeInfo info) { auto nodes = GUIApplication::instance().getSceneObjectClipboard().getData(); auto this_parent = info.m_selected->getParent(); @@ -1552,7 +1552,7 @@ void SceneWindow::buildContextMenuGroupObj() { m_hierarchy_group_node_menu = ContextMenu>(); m_hierarchy_group_node_menu.addOption( - "Add Child Object...", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_N}, + "Add Child Object...", KeyBind({KeyCode::KEY_N}, KeyModifier::KEY_CTRL), [this](SelectionNodeInfo info) { m_create_obj_dialog.setInsertPolicy(CreateObjDialog::InsertPolicy::INSERT_CHILD); m_create_obj_dialog.open(); @@ -1560,7 +1560,7 @@ void SceneWindow::buildContextMenuGroupObj() { }); m_hierarchy_group_node_menu.addOption( - "Insert Object Before...", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_N}, + "Insert Object Before...", KeyBind({KeyCode::KEY_N}, KeyModifier::KEY_CTRL), [this](SelectionNodeInfo info) { m_create_obj_dialog.setInsertPolicy(CreateObjDialog::InsertPolicy::INSERT_BEFORE); m_create_obj_dialog.open(); @@ -1568,7 +1568,7 @@ void SceneWindow::buildContextMenuGroupObj() { }); m_hierarchy_group_node_menu.addOption( - "Insert Object After...", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_N}, + "Insert Object After...", KeyBind({KeyCode::KEY_N}, KeyModifier::KEY_CTRL), [this](SelectionNodeInfo info) { m_create_obj_dialog.setInsertPolicy(CreateObjDialog::InsertPolicy::INSERT_AFTER); m_create_obj_dialog.open(); @@ -1577,18 +1577,18 @@ void SceneWindow::buildContextMenuGroupObj() { m_hierarchy_group_node_menu.addDivider(); - m_hierarchy_group_node_menu.addOption("Rename...", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_R}, - [this](SelectionNodeInfo info) { - m_rename_obj_dialog.open(); - m_rename_obj_dialog.setOriginalName( - info.m_selected->getNameRef().name()); - return; - }); + m_hierarchy_group_node_menu.addOption( + "Rename...", KeyBind({KeyCode::KEY_R}, KeyModifier::KEY_CTRL), + [this](SelectionNodeInfo info) { + m_rename_obj_dialog.open(); + m_rename_obj_dialog.setOriginalName(info.m_selected->getNameRef().name()); + return; + }); m_hierarchy_group_node_menu.addDivider(); m_hierarchy_group_node_menu.addOption( - "Copy", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_C}, + "Copy", KeyBind({KeyCode::KEY_C}, KeyModifier::KEY_CTRL), [this](SelectionNodeInfo info) { info.m_selected = make_deep_clone(info.m_selected); GUIApplication::instance().getSceneObjectClipboard().setData(info); @@ -1596,7 +1596,7 @@ void SceneWindow::buildContextMenuGroupObj() { }); m_hierarchy_group_node_menu.addOption( - "Paste", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_V}, + "Paste", KeyBind({KeyCode::KEY_V}, KeyModifier::KEY_CTRL), [this](SelectionNodeInfo info) { auto nodes = GUIApplication::instance().getSceneObjectClipboard().getData(); auto this_parent = std::reinterpret_pointer_cast(info.m_selected); @@ -1652,7 +1652,7 @@ void SceneWindow::buildContextMenuPhysicalObj() { m_hierarchy_physical_node_menu = ContextMenu>(); m_hierarchy_physical_node_menu.addOption( - "Insert Object Before...", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_N}, + "Insert Object Before...", KeyBind({KeyCode::KEY_N}, KeyModifier::KEY_CTRL), [this](SelectionNodeInfo info) { m_create_obj_dialog.setInsertPolicy(CreateObjDialog::InsertPolicy::INSERT_BEFORE); m_create_obj_dialog.open(); @@ -1660,7 +1660,7 @@ void SceneWindow::buildContextMenuPhysicalObj() { }); m_hierarchy_physical_node_menu.addOption( - "Insert Object After...", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_N}, + "Insert Object After...", KeyBind({KeyCode::KEY_N}, KeyModifier::KEY_CTRL), [this](SelectionNodeInfo info) { m_create_obj_dialog.setInsertPolicy(CreateObjDialog::InsertPolicy::INSERT_AFTER); m_create_obj_dialog.open(); @@ -1670,7 +1670,7 @@ void SceneWindow::buildContextMenuPhysicalObj() { m_hierarchy_physical_node_menu.addDivider(); m_hierarchy_physical_node_menu.addOption( - "Rename...", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_R}, + "Rename...", KeyBind({KeyCode::KEY_R}, KeyModifier::KEY_CTRL), [this](SelectionNodeInfo info) { m_rename_obj_dialog.open(); m_rename_obj_dialog.setOriginalName(info.m_selected->getNameRef().name()); @@ -1680,7 +1680,7 @@ void SceneWindow::buildContextMenuPhysicalObj() { m_hierarchy_physical_node_menu.addDivider(); m_hierarchy_physical_node_menu.addOption( - "View in Scene", {KeyCode::KEY_LEFTALT, KeyCode::KEY_V}, + "View in Scene", KeyBind({KeyCode::KEY_V}, KeyModifier::KEY_ALT), [this](SelectionNodeInfo info) { auto member_result = info.m_selected->getMember("Transform"); if (!member_result) { @@ -1708,7 +1708,7 @@ void SceneWindow::buildContextMenuPhysicalObj() { }); m_hierarchy_physical_node_menu.addOption( - "Move to Camera", {KeyCode::KEY_LEFTALT, KeyCode::KEY_C}, + "Move to Camera", KeyBind({KeyCode::KEY_C}, KeyModifier::KEY_ALT), [this](SelectionNodeInfo info) { auto member_result = info.m_selected->getMember("Transform"); if (!member_result) { @@ -1742,7 +1742,7 @@ void SceneWindow::buildContextMenuPhysicalObj() { m_hierarchy_physical_node_menu.addDivider(); m_hierarchy_physical_node_menu.addOption( - "Copy", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_C}, + "Copy", KeyBind({KeyCode::KEY_C}, KeyModifier::KEY_CTRL), [this](SelectionNodeInfo info) { info.m_selected = make_deep_clone(info.m_selected); GUIApplication::instance().getSceneObjectClipboard().setData(info); @@ -1750,7 +1750,7 @@ void SceneWindow::buildContextMenuPhysicalObj() { }); m_hierarchy_physical_node_menu.addOption( - "Paste", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_V}, + "Paste", KeyBind({KeyCode::KEY_V}, KeyModifier::KEY_CTRL), [this](SelectionNodeInfo info) { auto nodes = GUIApplication::instance().getSceneObjectClipboard().getData(); auto this_parent = reinterpret_cast(info.m_selected->getParent()); @@ -1804,7 +1804,8 @@ void SceneWindow::buildContextMenuPhysicalObj() { m_hierarchy_physical_node_menu.addDivider(); m_hierarchy_physical_node_menu.addOption( - "Copy Player Transform", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_LEFTALT, KeyCode::KEY_P}, + "Copy Player Transform", + KeyBind({KeyCode::KEY_P}, KeyModifier::KEY_CTRL | KeyModifier::KEY_ALT), [this]() { Game::TaskCommunicator &task_communicator = GUIApplication::instance().getTaskCommunicator(); @@ -1820,7 +1821,8 @@ void SceneWindow::buildContextMenuPhysicalObj() { }); m_hierarchy_physical_node_menu.addOption( - "Copy Player Position", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_LEFTALT, KeyCode::KEY_P}, + "Copy Player Position", + KeyBind({KeyCode::KEY_P}, KeyModifier::KEY_CTRL | KeyModifier::KEY_ALT), [this]() { Game::TaskCommunicator &task_communicator = GUIApplication::instance().getTaskCommunicator(); @@ -1841,7 +1843,7 @@ void SceneWindow::buildContextMenuMultiObj() { ContextMenu>>(); m_hierarchy_multi_node_menu.addOption( - "Copy", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_C}, + "Copy", KeyBind({KeyCode::KEY_C}, KeyModifier::KEY_CTRL), [this](std::vector> infos) { for (auto &info : infos) { info.m_selected = make_deep_clone(info.m_selected); @@ -1851,7 +1853,7 @@ void SceneWindow::buildContextMenuMultiObj() { }); m_hierarchy_multi_node_menu.addOption( - "Paste", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_V}, + "Paste", KeyBind({KeyCode::KEY_V}, KeyModifier::KEY_CTRL), [this](std::vector> infos) { auto nodes = GUIApplication::instance().getSceneObjectClipboard().getData(); for (auto &info : infos) { @@ -1915,7 +1917,7 @@ void SceneWindow::buildContextMenuRail() { m_rail_list_single_node_menu = ContextMenu>(); m_rail_list_single_node_menu.addOption("Insert Rail Here...", - {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_N}, + KeyBind({KeyCode::KEY_N}, KeyModifier::KEY_CTRL), [this](SelectionNodeInfo info) { m_create_rail_dialog.open(); return; @@ -1923,13 +1925,13 @@ void SceneWindow::buildContextMenuRail() { m_rail_list_single_node_menu.addDivider(); - m_rail_list_single_node_menu.addOption("Rename...", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_R}, - [this](SelectionNodeInfo info) { - m_rename_rail_dialog.open(); - m_rename_rail_dialog.setOriginalName( - info.m_selected->name()); - return; - }); + m_rail_list_single_node_menu.addOption( + "Rename...", KeyBind({KeyCode::KEY_R}, KeyModifier::KEY_CTRL), + [this](SelectionNodeInfo info) { + m_rename_rail_dialog.open(); + m_rename_rail_dialog.setOriginalName(info.m_selected->name()); + return; + }); // m_rail_list_single_node_menu.addDivider(); // @@ -1938,7 +1940,7 @@ void SceneWindow::buildContextMenuRail() { m_rail_list_single_node_menu.addDivider(); m_rail_list_single_node_menu.addOption( - "Copy", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_C}, + "Copy", KeyBind({KeyCode::KEY_C}, KeyModifier::KEY_CTRL), [this](SelectionNodeInfo info) { info.m_selected = make_deep_clone(info.m_selected); GUIApplication::instance().getSceneRailClipboard().setData(info); @@ -1946,7 +1948,7 @@ void SceneWindow::buildContextMenuRail() { }); m_rail_list_single_node_menu.addOption( - "Paste", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_V}, + "Paste", KeyBind({KeyCode::KEY_V}, KeyModifier::KEY_CTRL), [this](SelectionNodeInfo info) { auto nodes = GUIApplication::instance().getSceneRailClipboard().getData(); if (nodes.size() > 0) { @@ -1984,7 +1986,7 @@ void SceneWindow::buildContextMenuMultiRail() { m_rail_list_multi_node_menu = ContextMenu>>(); m_rail_list_multi_node_menu.addOption( - "Copy", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_C}, + "Copy", KeyBind({KeyCode::KEY_C}, KeyModifier::KEY_CTRL), [this](std::vector> info) { for (auto &select : info) { select.m_selected = make_deep_clone(select.m_selected); @@ -1994,7 +1996,7 @@ void SceneWindow::buildContextMenuMultiRail() { }); m_rail_list_multi_node_menu.addOption( - "Paste", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_V}, + "Paste", KeyBind({KeyCode::KEY_V}, KeyModifier::KEY_CTRL), [this](std::vector> info) { auto nodes = GUIApplication::instance().getSceneRailClipboard().getData(); if (nodes.size() > 0) { @@ -2035,7 +2037,7 @@ void SceneWindow::buildContextMenuRailNode() { m_rail_node_list_single_node_menu = ContextMenu>(); m_rail_node_list_single_node_menu.addOption("Insert Node Here...", - {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_N}, + KeyBind({KeyCode::KEY_N}, KeyModifier::KEY_CTRL), [this](SelectionNodeInfo info) { m_create_rail_dialog.open(); return Result(); @@ -2044,7 +2046,7 @@ void SceneWindow::buildContextMenuRailNode() { m_rail_node_list_single_node_menu.addDivider(); m_rail_node_list_single_node_menu.addOption( - "View in Scene", {KeyCode::KEY_LEFTALT, KeyCode::KEY_V}, + "View in Scene", KeyBind({KeyCode::KEY_V}, KeyModifier::KEY_ALT), [this](SelectionNodeInfo info) { glm::vec3 translation = info.m_selected->getPosition(); @@ -2055,7 +2057,7 @@ void SceneWindow::buildContextMenuRailNode() { }); m_rail_node_list_single_node_menu.addOption( - "Move to Camera", {KeyCode::KEY_LEFTALT, KeyCode::KEY_C}, + "Move to Camera", KeyBind({KeyCode::KEY_C}, KeyModifier::KEY_ALT), [this](SelectionNodeInfo info) { RefPtr rail = m_current_scene->getRailData().getRail(info.m_selected->getRailUUID()); @@ -2076,7 +2078,7 @@ void SceneWindow::buildContextMenuRailNode() { m_rail_node_list_single_node_menu.addDivider(); m_rail_node_list_single_node_menu.addOption( - "Copy", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_C}, + "Copy", KeyBind({KeyCode::KEY_C}, KeyModifier::KEY_CTRL), [this](SelectionNodeInfo info) { info.m_selected = make_deep_clone(info.m_selected); GUIApplication::instance().getSceneRailNodeClipboard().setData(info); @@ -2084,7 +2086,7 @@ void SceneWindow::buildContextMenuRailNode() { }); m_rail_node_list_single_node_menu.addOption( - "Paste", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_V}, + "Paste", KeyBind({KeyCode::KEY_V}, KeyModifier::KEY_CTRL), [this](SelectionNodeInfo info) { RefPtr rail = m_current_scene->getRailData().getRail(info.m_selected->getRailUUID()); @@ -2117,7 +2119,7 @@ void SceneWindow::buildContextMenuMultiRailNode() { ContextMenu>>(); m_rail_node_list_multi_node_menu.addOption( - "Copy", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_C}, + "Copy", KeyBind({KeyCode::KEY_C}, KeyModifier::KEY_CTRL), [this](std::vector> info) { for (auto &select : info) { select.m_selected = make_deep_clone(select.m_selected); @@ -2127,7 +2129,7 @@ void SceneWindow::buildContextMenuMultiRailNode() { }); m_rail_node_list_multi_node_menu.addOption( - "Paste", {KeyCode::KEY_LEFTCONTROL, KeyCode::KEY_V}, + "Paste", KeyBind({KeyCode::KEY_V}, KeyModifier::KEY_CTRL), [this](std::vector> info) { RefPtr rail = m_current_scene->getRailData().getRail(info[0].m_selected->getRailUUID()); From e5e5d1b5b31f88ea1bea782cbd87da0bafa077ea Mon Sep 17 00:00:00 2001 From: Alex Sanchez-Stern Date: Mon, 11 Nov 2024 18:56:39 -0800 Subject: [PATCH 129/129] Fix both file handling paths triggering on dialog close --- include/gui/application.hpp | 3 +-- src/gui/application.cpp | 30 ++++++++++++------------------ 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/include/gui/application.hpp b/include/gui/application.hpp index b9d882e5..e7cc51be 100644 --- a/include/gui/application.hpp +++ b/include/gui/application.hpp @@ -204,8 +204,7 @@ namespace Toolbox { bool m_dockspace_built; bool m_opening_options_window = false; - bool m_is_file_dialog_open = false; - bool m_is_dir_dialog_open = false; + bool m_browsing_dir = false; std::thread m_thread_templates_init; DolphinCommunicator m_dolphin_communicator; diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 7638a37e..504add27 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -521,10 +521,18 @@ namespace Toolbox { if (ImGui::BeginMenu("File")) { if (ImGui::MenuItem(ICON_FK_FOLDER_OPEN " Open...")) { - m_is_file_dialog_open = true; + if (!FileDialog::instance()->isAlreadyOpen()) { + FileDialogFilter filter; + filter.addFilter("Nintendo Scene Archive", "szs,arc"); + FileDialog::instance()->openDialog(m_load_path, m_render_window, false, filter); + } + m_browsing_dir = false; } if (ImGui::MenuItem(ICON_FK_FOLDER_OPEN " Open Folder...")) { - m_is_dir_dialog_open = true; + m_browsing_dir = true; + if (!FileDialog::instance()->isAlreadyOpen()) { + FileDialog::instance()->openDialog(m_load_path, m_render_window, true); + } } ImGui::Separator(); @@ -569,13 +577,7 @@ namespace Toolbox { ImGui::EndMainMenuBar(); - if (m_is_dir_dialog_open) { - if (!FileDialog::instance()->isAlreadyOpen()) { - FileDialog::instance()->openDialog(m_load_path, m_render_window, true); - } - m_is_dir_dialog_open = false; - } - if (FileDialog::instance()->isDone()) { + if (FileDialog::instance()->isDone() && m_browsing_dir) { FileDialog::instance()->close(); if (FileDialog::instance()->isOk()) { std::filesystem::path selected_path = FileDialog::instance()->getFilenameResult(); @@ -591,15 +593,7 @@ namespace Toolbox { } } - if (m_is_file_dialog_open) { - if (!FileDialog::instance()->isAlreadyOpen()) { - FileDialogFilter filter; - filter.addFilter("Nintendo Scene Archive", "szs,arc"); - FileDialog::instance()->openDialog(m_load_path, m_render_window, false, filter); - } - m_is_file_dialog_open = false; - } - if (FileDialog::instance()->isDone()) { + if (FileDialog::instance()->isDone() && !m_browsing_dir) { FileDialog::instance()->close(); if (FileDialog::instance()->isOk()) { std::filesystem::path selected_path = FileDialog::instance()->getFilenameResult();