mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-10 12:44:53 +00:00
Merge duplicate cels in SimpleLayoutSamples (not only linked cels)
This commit is contained in:
parent
926accf7c7
commit
ea5e67b0ea
@ -354,12 +354,14 @@ class DocExporter::SimpleLayoutSamples : public DocExporter::LayoutSamples {
|
|||||||
public:
|
public:
|
||||||
SimpleLayoutSamples(SpriteSheetType type,
|
SimpleLayoutSamples(SpriteSheetType type,
|
||||||
int maxCols, int maxRows,
|
int maxCols, int maxRows,
|
||||||
bool splitLayers, bool splitTags)
|
bool splitLayers, bool splitTags,
|
||||||
|
bool mergeDups)
|
||||||
: m_type(type)
|
: m_type(type)
|
||||||
, m_maxCols(maxCols)
|
, m_maxCols(maxCols)
|
||||||
, m_maxRows(maxRows)
|
, m_maxRows(maxRows)
|
||||||
, m_splitLayers(splitLayers)
|
, m_splitLayers(splitLayers)
|
||||||
, m_splitTags(splitTags) {
|
, m_splitTags(splitTags)
|
||||||
|
, m_mergeDups(mergeDups) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void layoutSamples(Samples& samples,
|
void layoutSamples(Samples& samples,
|
||||||
@ -377,6 +379,7 @@ public:
|
|||||||
const Layer* oldLayer = nullptr;
|
const Layer* oldLayer = nullptr;
|
||||||
const Tag* oldTag = nullptr;
|
const Tag* oldTag = nullptr;
|
||||||
|
|
||||||
|
doc::ImagesMap duplicates;
|
||||||
gfx::Point framePt(borderPadding, borderPadding);
|
gfx::Point framePt(borderPadding, borderPadding);
|
||||||
gfx::Size rowSize(0, 0);
|
gfx::Size rowSize(0, 0);
|
||||||
|
|
||||||
@ -406,6 +409,23 @@ public:
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_mergeDups) {
|
||||||
|
doc::ImageBufferPtr sampleBuf = std::make_shared<doc::ImageBuffer>();
|
||||||
|
doc::ImageRef sampleRender(sample.createRender(sampleBuf));
|
||||||
|
auto it = duplicates.find(sampleRender);
|
||||||
|
if (it != duplicates.end()) {
|
||||||
|
const uint32_t j = it->second;
|
||||||
|
|
||||||
|
sample.setDuplicated();
|
||||||
|
sample.setSharedBounds(samples[j].sharedBounds());
|
||||||
|
++i;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
duplicates[sampleRender] = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const Sprite* sprite = sample.sprite();
|
const Sprite* sprite = sample.sprite();
|
||||||
const Layer* layer = sample.layer();
|
const Layer* layer = sample.layer();
|
||||||
const Tag* tag = sample.tag();
|
const Tag* tag = sample.tag();
|
||||||
@ -495,6 +515,7 @@ private:
|
|||||||
int m_maxRows;
|
int m_maxRows;
|
||||||
bool m_splitLayers;
|
bool m_splitLayers;
|
||||||
bool m_splitTags;
|
bool m_splitTags;
|
||||||
|
bool m_mergeDups;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DocExporter::BestFitLayoutSamples : public DocExporter::LayoutSamples {
|
class DocExporter::BestFitLayoutSamples : public DocExporter::LayoutSamples {
|
||||||
@ -894,7 +915,7 @@ void DocExporter::captureSamples(Samples& samples,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Re-use linked samples
|
// Re-use linked samples
|
||||||
if (link && mergeDuplicates()) {
|
if (link && m_mergeDuplicates) {
|
||||||
for (const Sample& other : samples) {
|
for (const Sample& other : samples) {
|
||||||
if (token.canceled())
|
if (token.canceled())
|
||||||
return;
|
return;
|
||||||
@ -1014,7 +1035,8 @@ void DocExporter::layoutSamples(Samples& samples,
|
|||||||
SimpleLayoutSamples layout(
|
SimpleLayoutSamples layout(
|
||||||
m_sheetType,
|
m_sheetType,
|
||||||
m_textureColumns, m_textureRows,
|
m_textureColumns, m_textureRows,
|
||||||
m_splitLayers, m_splitTags);
|
m_splitLayers, m_splitTags,
|
||||||
|
m_mergeDuplicates);
|
||||||
layout.layoutSamples(
|
layout.layoutSamples(
|
||||||
samples, m_borderPadding, m_shapePadding,
|
samples, m_borderPadding, m_shapePadding,
|
||||||
width, height, token);
|
width, height, token);
|
||||||
|
@ -100,7 +100,6 @@ namespace app {
|
|||||||
class SimpleLayoutSamples;
|
class SimpleLayoutSamples;
|
||||||
class BestFitLayoutSamples;
|
class BestFitLayoutSamples;
|
||||||
|
|
||||||
bool mergeDuplicates() const { return m_mergeDuplicates; }
|
|
||||||
void captureSamples(Samples& samples,
|
void captureSamples(Samples& samples,
|
||||||
base::task_token& token);
|
base::task_token& token);
|
||||||
void layoutSamples(Samples& samples,
|
void layoutSamples(Samples& samples,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user