Remove DocumentApi::setPixelFormat() member function

This commit is contained in:
David Capello 2017-05-17 13:57:36 -03:00
parent 16aeae0833
commit 5c07f86a66
3 changed files with 7 additions and 19 deletions

View File

@ -9,10 +9,10 @@
#endif
#include "app/app.h"
#include "app/cmd/set_pixel_format.h"
#include "app/commands/command.h"
#include "app/commands/params.h"
#include "app/context_access.h"
#include "app/document_api.h"
#include "app/modules/editors.h"
#include "app/modules/gui.h"
#include "app/modules/palettes.h"
@ -367,13 +367,17 @@ void ChangePixelFormatCommand::onExecute(Context* context)
m_dithering = window.ditheringAlgorithm();
}
// No conversion needed
if (context->activeDocument()->sprite()->pixelFormat() == m_format)
return;
{
ContextWriter writer(context);
Transaction transaction(writer.context(), "Color Mode Change");
Document* document(writer.document());
Sprite* sprite(writer.sprite());
document->getApi(transaction).setPixelFormat(sprite, m_format, m_dithering);
transaction.execute(new cmd::SetPixelFormat(sprite, m_format, m_dithering));
transaction.commit();
}

View File

@ -37,7 +37,6 @@
#include "app/cmd/set_mask.h"
#include "app/cmd/set_mask_position.h"
#include "app/cmd/set_palette.h"
#include "app/cmd/set_pixel_format.h"
#include "app/cmd/set_slice_key.h"
#include "app/cmd/set_sprite_size.h"
#include "app/cmd/set_total_frames.h"
@ -55,8 +54,8 @@
#include "doc/frame_tag.h"
#include "doc/frame_tags.h"
#include "doc/mask.h"
#include "doc/palette.h"
#include "doc/slice.h"
#include "render/quantization.h"
#include "render/render.h"
#include <set>
@ -181,16 +180,6 @@ void DocumentApi::trimSprite(Sprite* sprite)
cropSprite(sprite, bounds);
}
void DocumentApi::setPixelFormat(Sprite* sprite,
const PixelFormat newFormat,
const render::DitheringAlgorithm dithering)
{
if (sprite->pixelFormat() == newFormat)
return;
m_transaction.execute(new cmd::SetPixelFormat(sprite, newFormat, dithering));
}
void DocumentApi::addFrame(Sprite* sprite, frame_t newFrame)
{
copyFrame(sprite, newFrame-1, newFrame);

View File

@ -12,9 +12,7 @@
#include "doc/color.h"
#include "doc/frame.h"
#include "doc/image_ref.h"
#include "doc/pixel_format.h"
#include "gfx/rect.h"
#include "render/dithering_algorithm.h"
namespace doc {
class Cel;
@ -46,9 +44,6 @@ namespace app {
void setSpriteTransparentColor(Sprite* sprite, color_t maskColor);
void cropSprite(Sprite* sprite, const gfx::Rect& bounds);
void trimSprite(Sprite* sprite);
void setPixelFormat(Sprite* sprite,
const PixelFormat newFormat,
const render::DitheringAlgorithm dithering);
// Frames API
void addFrame(Sprite* sprite, frame_t newFrame);