Replace doc::LayerImage::getCel() with doc::Layer::cel()

This commit is contained in:
David Capello 2014-12-28 21:04:08 -03:00
parent 06d18f1e8a
commit 603dde343f
24 changed files with 87 additions and 108 deletions

View File

@ -46,8 +46,6 @@
* Convert doc::PixelFormat to a enum class
* Add doc::Spec with width/height/channels/ColorMode/ncolors
* Convert doc::LayerIndex -> typedef int doc::layer_t;
* Replace doc::LayerImage::getCel() with doc::Layer::cel()
* Replace doc::Sprite::getPalette() with doc::Sprite::palette()
* Replace doc::Palette::getEntry() with doc::Palette::entry()
* Remove LayerFolder, replace it with an array of layers
* Add new "level" into Layer class

View File

@ -91,8 +91,8 @@ void MergeDownLayerCommand::onExecute(Context* context)
for (frame_t frpos = 0; frpos<sprite->totalFrames(); ++frpos) {
// Get frames
Cel* src_cel = static_cast<LayerImage*>(src_layer)->getCel(frpos);
Cel* dst_cel = static_cast<LayerImage*>(dst_layer)->getCel(frpos);
Cel* src_cel = src_layer->cel(frpos);
Cel* dst_cel = dst_layer->cel(frpos);
// Get images
Image* src_image;

View File

@ -178,7 +178,7 @@ void NewFileCommand::onExecute(Context* context)
LayerImage* layerImage = static_cast<LayerImage*>(layer);
layerImage->configureAsBackground();
Image* image = layerImage->getCel(frame_t(0))->image();
Image* image = layerImage->cel(frame_t(0))->image();
doc::clear_image(image,
color_utils::color_for_target(color,
ColorTarget(

View File

@ -76,7 +76,7 @@ void ContextFlags::update(Context* context)
if (layer->isImage()) {
m_flags |= ActiveLayerIsImage;
Cel* cel = static_cast<LayerImage*>(layer)->getCel(location.frame());
Cel* cel = layer->cel(location.frame());
if (cel) {
m_flags |= HasActiveCel;

View File

@ -304,8 +304,7 @@ void DocumentApi::displaceFrames(Layer* layer, frame_t frame)
// Displace all cels in '>=frame' to the next frame.
for (frame_t c=sprite->lastFrame(); c>=frame; --c) {
Cel* cel = imglayer->getCel(c);
if (cel)
if (Cel* cel = imglayer->cel(c))
setCelFramePosition(imglayer, cel, cel->frame()+1);
}
@ -392,11 +391,11 @@ void DocumentApi::removeFrameOfLayer(Layer* layer, frame_t frame)
case ObjectType::LayerImage: {
LayerImage* imglayer = static_cast<LayerImage*>(layer);
if (Cel* cel = imglayer->getCel(frame))
if (Cel* cel = imglayer->cel(frame))
removeCel(cel);
for (++frame; frame<sprite->totalFrames(); ++frame)
if (Cel* cel = imglayer->getCel(frame))
if (Cel* cel = imglayer->cel(frame))
setCelFramePosition(imglayer, cel, cel->frame()-1);
break;
}
@ -671,8 +670,7 @@ void DocumentApi::cropCel(Sprite* sprite, Cel* cel, int x, int y, int w, int h)
void DocumentApi::clearCel(LayerImage* layer, frame_t frame)
{
Cel* cel = layer->getCel(frame);
if (cel)
if (Cel* cel = layer->cel(frame))
clearCel(cel);
}
@ -713,8 +711,8 @@ void DocumentApi::moveCel(
clearCel(dstLayer, dstFrame);
addEmptyFramesTo(dstSprite, dstFrame);
Cel* srcCel = srcLayer->getCel(srcFrame);
Cel* dstCel = dstLayer->getCel(dstFrame);
Cel* srcCel = srcLayer->cel(srcFrame);
Cel* dstCel = dstLayer->cel(dstFrame);
Image* srcImage = (srcCel ? srcCel->image(): NULL);
Image* dstImage = (dstCel ? dstCel->image(): NULL);
@ -780,8 +778,8 @@ void DocumentApi::copyCel(
clearCel(dstLayer, dstFrame);
addEmptyFramesTo(dstSprite, dstFrame);
Cel* srcCel = srcLayer->getCel(srcFrame);
Cel* dstCel = dstLayer->getCel(dstFrame);
Cel* srcCel = srcLayer->cel(srcFrame);
Cel* dstCel = dstLayer->cel(dstFrame);
Image* srcImage = (srcCel ? srcCel->image(): NULL);
Image* dstImage = (dstCel ? dstCel->image(): NULL);
@ -826,8 +824,8 @@ void DocumentApi::swapCel(
ASSERT(frame2 >= 0 && frame2 < sprite->totalFrames());
(void)sprite; // To avoid unused variable warning on Release mode
Cel* cel1 = layer->getCel(frame1);
Cel* cel2 = layer->getCel(frame2);
Cel* cel1 = layer->cel(frame1);
Cel* cel2 = layer->cel(frame2);
if (cel1) setCelFramePosition(layer, cel1, frame2);
if (cel2) setCelFramePosition(layer, cel2, frame1);
@ -1020,7 +1018,7 @@ void DocumentApi::backgroundFromLayer(LayerImage* layer)
// Fill all empty cels with a flat-image filled with bgcolor
for (frame_t frame(0); frame<sprite->totalFrames(); ++frame) {
Cel* cel = layer->getCel(frame);
Cel* cel = layer->cel(frame);
if (!cel) {
Image* cel_image = Image::create(sprite->pixelFormat(), sprite->width(), sprite->height());
clear_image(cel_image, bgcolor);
@ -1088,7 +1086,7 @@ void DocumentApi::flattenLayers(Sprite* sprite)
clear_image(image, bgcolor);
render.renderSprite(image, sprite, frame);
cel = background->getCel(frame);
cel = background->cel(frame);
if (cel) {
cel_image = cel->image();
ASSERT(cel_image != NULL);
@ -1170,7 +1168,7 @@ Cel* DocumentApi::addImage(LayerImage* layer, frame_t frameNumber, Image* image)
{
int imageIndex = addImageInStock(layer->sprite(), image);
ASSERT(layer->getCel(frameNumber) == NULL);
ASSERT(layer->cel(frameNumber) == NULL);
base::UniquePtr<Cel> cel(new Cel(frameNumber, imageIndex));

View File

@ -37,7 +37,7 @@ TEST(DocumentApi, MoveCel) {
LayerImage* layer1 = dynamic_cast<LayerImage*>(sprite->folder()->getFirstLayer());
LayerImage* layer2 = new LayerImage(sprite);
Cel* cel1 = layer1->getCel(frame_t(0));
Cel* cel1 = layer1->cel(frame_t(0));
cel1->setPosition(2, -2);
cel1->setOpacity(128);
@ -55,9 +55,9 @@ TEST(DocumentApi, MoveCel) {
layer1, frame_t(0),
layer2, frame_t(1));
EXPECT_EQ(NULL, layer1->getCel(frame_t(0)));
EXPECT_EQ(NULL, layer1->cel(frame_t(0)));
Cel* cel2 = layer2->getCel(frame_t(1));
Cel* cel2 = layer2->cel(frame_t(1));
ASSERT_TRUE(cel2 != NULL);
Image* image2 = cel2->image();

View File

@ -249,9 +249,8 @@ void DocumentExporter::exportSheet()
createEmptyTexture(samples));
Sprite* texture = textureDocument->sprite();
Image* textureImage = static_cast<LayerImage*>(
texture->folder()->getFirstLayer())
->getCel(frame_t(0))->image();
Image* textureImage = texture->folder()->getFirstLayer()
->cel(frame_t(0))->image();
renderTexture(samples, textureImage);
@ -296,8 +295,7 @@ void DocumentExporter::captureSamples(Samples& samples)
Sample sample(doc, sprite, layer, frame, filename);
if (m_ignoreEmptyCels) {
if (layer && layer->isImage() &&
!static_cast<LayerImage*>(layer)->getCel(frame)) {
if (layer && layer->isImage() && !layer->cel(frame)) {
// Empty cel this sample completely
continue;
}

View File

@ -50,16 +50,16 @@ Palette* DocumentLocation::palette()
const Cel* DocumentLocation::cel() const
{
if (m_layer && m_layer->isImage())
return static_cast<const LayerImage*>(m_layer)->getCel(m_frame);
if (m_layer)
return m_layer->cel(m_frame);
else
return NULL;
}
Cel* DocumentLocation::cel()
{
if (m_layer && m_layer->isImage())
return static_cast<LayerImage*>(m_layer)->getCel(m_frame);
if (m_layer)
return m_layer->cel(m_frame);
else
return NULL;
}

View File

@ -117,7 +117,7 @@ public:
LayerImage* layer = static_cast<LayerImage*>(sprite->indexToLayer(LayerIndex(i)));
for (int j=0; j<4; j++) {
Cel* cel = layer->getCel(frame_t(j));
Cel* cel = layer->cel(frame_t(j));
Image* image;
if (cel)
image = cel->image();
@ -143,7 +143,7 @@ protected:
return expect_layer_frame(sprite->layerToIndex(expected_layer), -1, layer, -1);
}
bool expect_frame(int expected_frame, int frame) {
bool expect_frame(int expected_frame, frame_t frame) {
for (int i=0; i<(int)sprite->countLayers(); ++i) {
if (!expect_layer_frame(i, expected_frame, i, frame))
return false;
@ -151,13 +151,13 @@ protected:
return true;
}
bool expect_layer_frame(int expected_layer, int expected_frame, int layer, int frame) {
bool expect_layer_frame(int expected_layer, int expected_frame, int layer, frame_t frame) {
if (frame >= 0) {
if (!expect_cel(expected_layer, expected_frame, layer, frame))
return false;
EXPECT_EQ((expected_frame+1), sprite->frameDuration(frame_t(frame)));
return ((expected_frame+1) == sprite->frameDuration(frame_t(frame)));
EXPECT_EQ((expected_frame+1), sprite->frameDuration(frame));
return ((expected_frame+1) == sprite->frameDuration(frame));
}
if (layer >= 0) {
@ -171,12 +171,12 @@ protected:
return true;
}
bool expect_cel(int expected_layer, int expected_frame, int layer, int frame) {
bool expect_cel(int expected_layer, int expected_frame, int layer, frame_t frame) {
color_t expected_color = white;
color_t color = get_pixel(
static_cast<LayerImage*>(sprite->indexToLayer(LayerIndex(layer)))
->getCel(frame_t(frame))->image(),
sprite->indexToLayer(LayerIndex(layer))
->cel(frame)->image(),
expected_layer, expected_frame);
EXPECT_EQ(expected_color, color);
@ -184,9 +184,8 @@ protected:
return (expected_color == color);
}
bool expect_empty_cel(int layer, int frame) {
Cel* cel = static_cast<LayerImage*>(sprite->indexToLayer(LayerIndex(layer)))
->getCel(frame_t(frame));
bool expect_empty_cel(int layer, frame_t frame) {
Cel* cel = sprite->indexToLayer(LayerIndex(layer))->cel(frame);
EXPECT_EQ(NULL, cel);
return (cel == NULL);
@ -203,17 +202,17 @@ protected:
color_t white;
};
inline DocumentRange range(Layer* fromLayer, int fromFrNum, Layer* toLayer, int toFrNum, DocumentRange::Type type) {
inline DocumentRange range(Layer* fromLayer, frame_t fromFrNum, Layer* toLayer, frame_t toFrNum, DocumentRange::Type type) {
DocumentRange r;
r.startRange(fromLayer->sprite()->layerToIndex(fromLayer), frame_t(fromFrNum), type);
r.endRange(toLayer->sprite()->layerToIndex(toLayer), frame_t(toFrNum));
r.startRange(fromLayer->sprite()->layerToIndex(fromLayer), fromFrNum, type);
r.endRange(toLayer->sprite()->layerToIndex(toLayer), toFrNum);
return r;
}
inline DocumentRange range(int fromLayer, int fromFrNum, int toLayer, int toFrNum, DocumentRange::Type type) {
inline DocumentRange range(int fromLayer, frame_t fromFrNum, int toLayer, frame_t toFrNum, DocumentRange::Type type) {
DocumentRange r;
r.startRange(LayerIndex(fromLayer), frame_t(fromFrNum), type);
r.endRange(LayerIndex(toLayer), frame_t(toFrNum));
r.startRange(LayerIndex(fromLayer), fromFrNum, type);
r.endRange(LayerIndex(toLayer), toFrNum);
return r;
}
@ -233,15 +232,15 @@ inline DocumentRange layers_range(int layer) {
return range(layer, -1, layer, -1, DocumentRange::kLayers);
}
inline DocumentRange frames_range(int fromFrame, int toFrame) {
inline DocumentRange frames_range(frame_t fromFrame, frame_t toFrame) {
return range(0, fromFrame, 0, toFrame, DocumentRange::kFrames);
}
inline DocumentRange frames_range(int frame) {
inline DocumentRange frames_range(frame_t frame) {
return range(0, frame, 0, frame, DocumentRange::kFrames);
}
inline DocumentRange cels_range(int fromLayer, int fromFrNum, int toLayer, int toFrNum) {
inline DocumentRange cels_range(int fromLayer, frame_t fromFrNum, int toLayer, frame_t toFrNum) {
return range(fromLayer, fromFrNum, toLayer, toFrNum, DocumentRange::kCels);
}

View File

@ -498,7 +498,7 @@ static void ase_file_write_layers(FILE* f, ASE_FrameHeader* frame_header, Layer*
static void ase_file_write_cels(FILE* f, ASE_FrameHeader* frame_header, Sprite* sprite, Layer* layer, frame_t frame)
{
if (layer->isImage()) {
Cel* cel = static_cast<LayerImage*>(layer)->getCel(frame);
Cel* cel = layer->cel(frame);
if (cel) {
/* fop_error(fop, "New cel in frame %d, in layer %d\n", */
/* frame, sprite_layer2index(sprite, layer)); */
@ -1058,7 +1058,7 @@ static Cel* ase_file_read_cel_chunk(FILE* f, Sprite* sprite, frame_t frame,
case ASE_FILE_LINK_CEL: {
// Read link position
frame_t link_frame = frame_t(fgetw(f));
Cel* link = static_cast<LayerImage*>(layer)->getCel(link_frame);
Cel* link = layer->cel(link_frame);
if (link) {
// Create a copy of the linked cel (avoid using links cel)

View File

@ -50,9 +50,9 @@ TEST(File, SeveralSizes)
doc->setFilename(&fn[0]);
// Random pixels
LayerImage* layer = dynamic_cast<LayerImage*>(doc->sprite()->folder()->getFirstLayer());
Layer* layer = doc->sprite()->folder()->getFirstLayer();
ASSERT_TRUE(layer != NULL);
Image* image = layer->getCel(frame_t(0))->image();
Image* image = layer->cel(frame_t(0))->image();
std::srand(w*h);
int c = std::rand()%256;
for (int y=0; y<h; y++) {
@ -74,9 +74,9 @@ TEST(File, SeveralSizes)
ASSERT_EQ(h, doc->sprite()->height());
// Same random pixels (see the seed)
LayerImage* layer = dynamic_cast<LayerImage*>(doc->sprite()->folder()->getFirstLayer());
Layer* layer = doc->sprite()->folder()->getFirstLayer();
ASSERT_TRUE(layer != NULL);
Image* image = layer->getCel(frame_t(0))->image();
Image* image = layer->cel(frame_t(0))->image();
std::srand(w*h);
int c = std::rand()%256;
for (int y=0; y<h; y++) {

View File

@ -54,7 +54,7 @@ TEST_F(GifFormat, Dimensions)
LayerImage* layer = dynamic_cast<LayerImage*>(sprite->folder()->getFirstLayer());
ASSERT_NE((LayerImage*)NULL, layer);
Image* image = layer->getCel(frame_t(0))->image();
Image* image = layer->cel(frame_t(0))->image();
clear_image(image, doc->sprite()->transparentColor());
save_document(&m_ctx, doc);
@ -98,7 +98,7 @@ TEST_F(GifFormat, OpaqueIndexed)
layer->setBackground(true);
ASSERT_NE((LayerImage*)NULL, layer);
Image* image = layer->getCel(frame_t(0))->image();
Image* image = layer->cel(frame_t(0))->image();
image->putPixel(0, 0, 0);
image->putPixel(0, 1, 1);
image->putPixel(1, 0, 2);
@ -124,7 +124,7 @@ TEST_F(GifFormat, OpaqueIndexed)
EXPECT_EQ(rgb(129, 255, 32), pal->getEntry(2));
EXPECT_EQ(rgb(0, 0, 255), pal->getEntry(3));
Image* image = layer->getCel(frame_t(0))->image();
Image* image = layer->cel(frame_t(0))->image();
EXPECT_EQ(0, sprite->transparentColor());
EXPECT_EQ(0, image->getPixel(0, 0));
EXPECT_EQ(1, image->getPixel(0, 1));
@ -154,7 +154,7 @@ TEST_F(GifFormat, TransparentIndexed)
LayerImage* layer = dynamic_cast<LayerImage*>(sprite->folder()->getFirstLayer());
ASSERT_NE((LayerImage*)NULL, layer);
Image* image = layer->getCel(frame_t(0))->image();
Image* image = layer->cel(frame_t(0))->image();
image->putPixel(0, 0, 0);
image->putPixel(0, 1, 1);
image->putPixel(1, 0, 2);
@ -180,7 +180,7 @@ TEST_F(GifFormat, TransparentIndexed)
EXPECT_EQ(rgb(129, 255, 32), pal->getEntry(2));
EXPECT_EQ(rgb(0, 0, 255), pal->getEntry(3));
Image* image = layer->getCel(frame_t(0))->image();
Image* image = layer->cel(frame_t(0))->image();
EXPECT_EQ(0, sprite->transparentColor());
EXPECT_EQ(0, image->getPixel(0, 0));
EXPECT_EQ(1, image->getPixel(0, 1));
@ -204,7 +204,7 @@ TEST_F(GifFormat, TransparentRgbQuantization)
LayerImage* layer = dynamic_cast<LayerImage*>(sprite->folder()->getFirstLayer());
ASSERT_NE((LayerImage*)NULL, layer);
Image* image = layer->getCel(frame_t(0))->image();
Image* image = layer->cel(frame_t(0))->image();
image->putPixel(0, 0, rgba(0, 0, 0, 0));
image->putPixel(0, 1, rgb(255, 0, 0));
image->putPixel(1, 0, rgb(0, 255, 0));
@ -224,7 +224,7 @@ TEST_F(GifFormat, TransparentRgbQuantization)
ASSERT_NE((LayerImage*)NULL, layer);
Palette* pal = sprite->palette(frame_t(0));
Image* image = layer->getCel(frame_t(0))->image();
Image* image = layer->cel(frame_t(0))->image();
EXPECT_EQ(0, sprite->transparentColor());
EXPECT_EQ(0, image->getPixel(0, 0));
EXPECT_EQ(rgb(255, 0, 0), pal->getEntry(image->getPixel(0, 1)));
@ -250,7 +250,7 @@ TEST_F(GifFormat, OpaqueRgbQuantization)
ASSERT_NE((LayerImage*)NULL, layer);
EXPECT_NE((LayerImage*)NULL, sprite->backgroundLayer());
Image* image = layer->getCel(frame_t(0))->image();
Image* image = layer->cel(frame_t(0))->image();
image->putPixel(0, 0, rgb(0, 0, 0));
image->putPixel(0, 1, rgb(255, 0, 0));
image->putPixel(1, 0, rgb(0, 255, 0));
@ -272,7 +272,7 @@ TEST_F(GifFormat, OpaqueRgbQuantization)
EXPECT_EQ(layer, sprite->backgroundLayer());
Palette* pal = sprite->palette(frame_t(0));
Image* image = layer->getCel(frame_t(0))->image();
Image* image = layer->cel(frame_t(0))->image();
EXPECT_EQ(0, sprite->transparentColor());
EXPECT_EQ(rgb(0, 0, 0), pal->getEntry(image->getPixel(0, 0)));
EXPECT_EQ(rgb(255, 0, 0), pal->getEntry(image->getPixel(0, 1)));
@ -299,7 +299,7 @@ TEST_F(GifFormat, OpaqueRgbQuantizationTwoLayers)
LayerImage* layer2 = new LayerImage(sprite);
sprite->folder()->addLayer(layer2);
Image* image1 = layer1->getCel(frame_t(0))->image();
Image* image1 = layer1->cel(frame_t(0))->image();
Image* image2 = Image::create(IMAGE_RGB, 2, 2);
int image2Idx = sprite->stock()->addImage(image2);
Cel* cel2 = new Cel(frame_t(0), image2Idx);
@ -330,7 +330,7 @@ TEST_F(GifFormat, OpaqueRgbQuantizationTwoLayers)
ASSERT_TRUE(layer->isBackground());
Palette* pal = sprite->palette(frame_t(0));
Image* image = layer->getCel(frame_t(0))->image();
Image* image = layer->cel(frame_t(0))->image();
EXPECT_EQ(0, sprite->transparentColor());
EXPECT_EQ(1, image->getPixel(0, 0));

View File

@ -117,8 +117,8 @@ bool save_palette(const char *filename, Palette* pal)
Sprite* sprite = doc->sprite();
doc->sprite()->setPalette(pal, false);
LayerImage* layer = dynamic_cast<LayerImage*>(sprite->folder()->getFirstLayer());
Image* image = layer->getCel(frame_t(0))->image();
Layer* layer = sprite->folder()->getFirstLayer();
Image* image = layer->cel(frame_t(0))->image();
int x, y, c;
for (y=c=0; y<16; y++)

View File

@ -80,7 +80,7 @@ static bool has_cels(const Layer* layer, frame_t frame)
switch (layer->type()) {
case ObjectType::LayerImage:
return static_cast<const LayerImage*>(layer)->getCel(frame) ? true: false;
return (layer->cel(frame) ? true: false);
case ObjectType::LayerFolder: {
LayerConstIterator it = static_cast<const LayerFolder*>(layer)->getLayerBegin();

View File

@ -50,7 +50,7 @@ MovingCelState::MovingCelState(Editor* editor, MouseMessage* msg)
LayerImage* layer = static_cast<LayerImage*>(editor->layer());
ASSERT(layer->isImage());
m_cel = layer->getCel(editor->frame());
m_cel = layer->cel(editor->frame());
if (m_cel) {
m_celStart = m_cel->position();
}

View File

@ -1787,7 +1787,7 @@ void Timeline::updateStatusBar(ui::Message* msg)
case A_PART_CEL:
if (layer) {
Cel* cel = (layer->isImage() ? static_cast<LayerImage*>(layer)->getCel(m_hot_frame): NULL);
Cel* cel = (layer->isImage() ? layer->cel(m_hot_frame): NULL);
StatusBar::instance()->setStatusText(0,
"%s at frame %d",
cel ? "Cel": "Empty cel",

View File

@ -320,7 +320,7 @@ void clipboard::paste()
i >= srcRange.layerBegin() &&
i >= LayerIndex(0) &&
j >= LayerIndex(0); --i, --j) {
Cel* cel = static_cast<LayerImage*>(srcLayers[i])->getCel(frame);
Cel* cel = srcLayers[i]->cel(frame);
if (cel && cel->image()) {
api.copyCel(
@ -328,7 +328,7 @@ void clipboard::paste()
static_cast<LayerImage*>(dstLayers[j]), dstFrame);
}
else {
Cel* dstCel = static_cast<LayerImage*>(dstLayers[j])->getCel(dstFrame);
Cel* dstCel = dstLayers[j]->cel(dstFrame);
if (dstCel)
api.clearCel(dstCel);
}
@ -354,7 +354,7 @@ void clipboard::paste()
j = LayerIndex(dstLayers.size()-1);
i >= LayerIndex(0) &&
j >= LayerIndex(0); --i, --j) {
Cel* cel = static_cast<LayerImage*>(srcLayers[i])->getCel(frame);
Cel* cel = static_cast<LayerImage*>(srcLayers[i])->cel(frame);
if (cel && cel->image()) {
api.copyCel(
static_cast<LayerImage*>(srcLayers[i]), frame,

View File

@ -86,7 +86,7 @@ ExpandCelCanvas::ExpandCelCanvas(Context* context, TiledMode tiledMode, UndoTran
m_layer = location.layer();
if (m_layer->isImage()) {
m_cel = static_cast<LayerImage*>(m_layer)->getCel(location.frame());
m_cel = m_layer->cel(location.frame());
if (m_cel)
m_celImage = m_cel->image();
}

View File

@ -46,7 +46,7 @@ CelList get_cels_in_range(Sprite* sprite, const DocumentRange& range)
begin = range.frameBegin()-1;
frame != begin;
--frame) {
Cel* cel = layerImage->getCel(frame);
Cel* cel = layerImage->cel(frame);
if (cel)
cels.push_back(cel);
}

View File

@ -43,14 +43,12 @@ void ImagesCollector::collectFromLayer(Layer* layer, frame_t frame)
case ObjectType::LayerImage: {
if (m_allFrames) {
for (frame_t frame(0); frame<sprite->totalFrames(); ++frame) {
Cel* cel = static_cast<LayerImage*>(layer)->getCel(frame);
if (cel != NULL)
if (Cel* cel = layer->cel(frame))
collectImage(layer, cel);
}
}
else {
Cel* cel = static_cast<LayerImage*>(layer)->getCel(frame);
if (cel != NULL)
if (Cel* cel = layer->cel(frame))
collectImage(layer, cel);
}
break;

View File

@ -131,7 +131,16 @@ void LayerImage::destroyAllCels()
Cel* LayerImage::cel(frame_t frame) const
{
return const_cast<Cel*>(getCel(frame_t(frame)));
CelConstIterator it = getCelBegin();
CelConstIterator end = getCelEnd();
for (; it != end; ++it) {
Cel* cel = *it;
if (cel->frame() == frame)
return cel;
}
return NULL;
}
void LayerImage::getCels(CelList& cels) const
@ -188,25 +197,6 @@ void LayerImage::moveCel(Cel* cel, frame_t frame)
addCel(cel);
}
const Cel* LayerImage::getCel(frame_t frame) const
{
CelConstIterator it = getCelBegin();
CelConstIterator end = getCelEnd();
for (; it != end; ++it) {
const Cel* cel = *it;
if (cel->frame() == frame)
return cel;
}
return NULL;
}
Cel* LayerImage::getCel(frame_t frame)
{
return const_cast<Cel*>(static_cast<const LayerImage*>(this)->getCel(frame));
}
/**
* Configures some properties of the specified layer to make it as the
* "Background" of the sprite.

View File

@ -115,8 +115,6 @@ namespace doc {
void addCel(Cel *cel);
void removeCel(Cel *cel);
void moveCel(Cel *cel, frame_t frame);
const Cel* getCel(frame_t frame) const;
Cel* getCel(frame_t frame);
Cel* cel(frame_t frame) const override;
void getCels(CelList& cels) const override;
Cel* getLastCel() const;

View File

@ -472,7 +472,7 @@ void Sprite::pickCels(int x, int y, frame_t frame, int opacityThreshold, CelList
if (!layer->isImage() || !layer->isVisible())
continue;
Cel* cel = static_cast<LayerImage*>(layer)->getCel(frame);
Cel* cel = layer->cel(frame);
if (!cel)
continue;

View File

@ -590,7 +590,7 @@ void Render::renderLayer(
(!render_transparent && !layer->isBackground()))
break;
const Cel* cel = static_cast<const LayerImage*>(layer)->getCel(frame);
const Cel* cel = layer->cel(frame);
if (cel != NULL) {
Image* src_image;