mirror of
https://github.com/aseprite/aseprite.git
synced 2024-10-03 05:22:23 +00:00
Avoid loading current dithering matrix on each mouse move (related to #4174)
With this change we are reusing the cached/loaded matrix on each DitheringMatrixInfo struct, calling the load_dithering_matrix_from_sprite() function just one time (not on each brush preview/mouse movement).
This commit is contained in:
parent
29479cb231
commit
e87f6df72b
@ -936,15 +936,15 @@ const render::DitheringMatrix* Extensions::ditheringMatrix(const std::string& ma
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Extension::DitheringMatrixInfo> Extensions::ditheringMatrices()
|
std::vector<Extension::DitheringMatrixInfo*> Extensions::ditheringMatrices()
|
||||||
{
|
{
|
||||||
std::vector<Extension::DitheringMatrixInfo> result;
|
std::vector<Extension::DitheringMatrixInfo*> result;
|
||||||
for (auto ext : m_extensions) {
|
for (auto ext : m_extensions) {
|
||||||
if (!ext->isEnabled()) // Ignore disabled themes
|
if (!ext->isEnabled()) // Ignore disabled themes
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (auto it : ext->m_ditheringMatrices)
|
for (auto& it : ext->m_ditheringMatrices)
|
||||||
result.push_back(it.second);
|
result.push_back(&it.second);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,13 @@ namespace app {
|
|||||||
std::string palettePath(const std::string& palId);
|
std::string palettePath(const std::string& palId);
|
||||||
ExtensionItems palettes() const;
|
ExtensionItems palettes() const;
|
||||||
const render::DitheringMatrix* ditheringMatrix(const std::string& matrixId);
|
const render::DitheringMatrix* ditheringMatrix(const std::string& matrixId);
|
||||||
std::vector<Extension::DitheringMatrixInfo> ditheringMatrices();
|
|
||||||
|
// The returned collection can be used temporarily while
|
||||||
|
// extensions are not installed/uninstalled. Each element is
|
||||||
|
// pointing to the real matrix info owned by extensions, this is
|
||||||
|
// needed to cache the matrix because it is lazy loaded from an
|
||||||
|
// image file. These pointers cannot be deleted.
|
||||||
|
std::vector<Extension::DitheringMatrixInfo*> ditheringMatrices();
|
||||||
|
|
||||||
obs::signal<void(Extension*)> NewExtension;
|
obs::signal<void(Extension*)> NewExtension;
|
||||||
obs::signal<void(Extension*)> KeysChange;
|
obs::signal<void(Extension*)> KeysChange;
|
||||||
|
@ -1260,9 +1260,9 @@ public:
|
|||||||
bool found = false;
|
bool found = false;
|
||||||
auto ditheringMatrices = App::instance()
|
auto ditheringMatrices = App::instance()
|
||||||
->extensions().ditheringMatrices();
|
->extensions().ditheringMatrices();
|
||||||
for (const auto& it : ditheringMatrices) {
|
for (const auto* it : ditheringMatrices) {
|
||||||
if (it.name() == dynaPref.matrixName()) {
|
if (it->name() == dynaPref.matrixName()) {
|
||||||
m_dynamics.ditheringMatrix = it.matrix();
|
m_dynamics.ditheringMatrix = it->matrix();
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2019-2023 Igara Studio S.A.
|
// Copyright (C) 2019-2024 Igara Studio S.A.
|
||||||
// Copyright (C) 2017 David Capello
|
// Copyright (C) 2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -217,25 +217,25 @@ void DitheringSelector::regenerate(int selectedItemIndex)
|
|||||||
addItem(new DitherItem(render::DitheringAlgorithm::None,
|
addItem(new DitherItem(render::DitheringAlgorithm::None,
|
||||||
render::DitheringMatrix(),
|
render::DitheringMatrix(),
|
||||||
Strings::dithering_selector_no_dithering()));
|
Strings::dithering_selector_no_dithering()));
|
||||||
for (const auto& it : ditheringMatrices) {
|
for (const auto* it : ditheringMatrices) {
|
||||||
try {
|
try {
|
||||||
addItem(new DitherItem(
|
addItem(new DitherItem(
|
||||||
render::DitheringAlgorithm::Ordered,
|
render::DitheringAlgorithm::Ordered,
|
||||||
it.matrix(),
|
it->matrix(),
|
||||||
Strings::dithering_selector_ordered_dithering() + it.name()));
|
Strings::dithering_selector_ordered_dithering() + it->name()));
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
LOG(ERROR, "%s\n", e.what());
|
LOG(ERROR, "%s\n", e.what());
|
||||||
Console::showException(e);
|
Console::showException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const auto& it : ditheringMatrices) {
|
for (const auto* it : ditheringMatrices) {
|
||||||
try {
|
try {
|
||||||
addItem(
|
addItem(
|
||||||
new DitherItem(
|
new DitherItem(
|
||||||
render::DitheringAlgorithm::Old,
|
render::DitheringAlgorithm::Old,
|
||||||
it.matrix(),
|
it->matrix(),
|
||||||
Strings::dithering_selector_old_dithering() + it.name()));
|
Strings::dithering_selector_old_dithering() + it->name()));
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
LOG(ERROR, "%s\n", e.what());
|
LOG(ERROR, "%s\n", e.what());
|
||||||
@ -251,9 +251,9 @@ void DitheringSelector::regenerate(int selectedItemIndex)
|
|||||||
case SelectMatrix:
|
case SelectMatrix:
|
||||||
addItem(new DitherItem(render::DitheringMatrix(),
|
addItem(new DitherItem(render::DitheringMatrix(),
|
||||||
Strings::dithering_selector_no_dithering()));
|
Strings::dithering_selector_no_dithering()));
|
||||||
for (auto& it : ditheringMatrices) {
|
for (const auto* it : ditheringMatrices) {
|
||||||
try {
|
try {
|
||||||
addItem(new DitherItem(it.matrix(), it.name()));
|
addItem(new DitherItem(it->matrix(), it->name()));
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
LOG(ERROR, "%s\n", e.what());
|
LOG(ERROR, "%s\n", e.what());
|
||||||
|
Loading…
Reference in New Issue
Block a user