Remove implicit SharedPtr conversion to T*

This commit is contained in:
David Capello 2015-04-02 20:42:43 -03:00
parent d362f85e98
commit 22c3c4f20e
70 changed files with 220 additions and 199 deletions

View File

@ -65,7 +65,7 @@ AppMenus::AppMenus()
void AppMenus::reload() void AppMenus::reload()
{ {
XmlDocumentRef doc(GuiXml::instance()->doc()); XmlDocumentRef doc(GuiXml::instance()->doc());
TiXmlHandle handle(doc); TiXmlHandle handle(doc.get());
const char* path = GuiXml::instance()->filename(); const char* path = GuiXml::instance()->filename();
//////////////////////////////////////// ////////////////////////////////////////

View File

@ -45,7 +45,7 @@ void AddFrame::onExecute()
LayerImage* bglayer = sprite->backgroundLayer(); LayerImage* bglayer = sprite->backgroundLayer();
if (bglayer) { if (bglayer) {
ImageRef bgimage(Image::create(sprite->pixelFormat(), sprite->width(), sprite->height())); ImageRef bgimage(Image::create(sprite->pixelFormat(), sprite->width(), sprite->height()));
clear_image(bgimage, doc->bgColor(bglayer)); clear_image(bgimage.get(), doc->bgColor(bglayer));
Cel* cel = new Cel(m_newFrame, bgimage); Cel* cel = new Cel(m_newFrame, bgimage);
m_addCel.reset(new cmd::AddCel(bglayer, cel)); m_addCel.reset(new cmd::AddCel(bglayer, cel));
m_addCel->execute(context()); m_addCel->execute(context());

View File

@ -57,8 +57,8 @@ void BackgroundFromLayer::onExecute()
Image* cel_image = cel->image(); Image* cel_image = cel->image();
ASSERT(cel_image); ASSERT(cel_image);
clear_image(bg_image, bgcolor); clear_image(bg_image.get(), bgcolor);
render::composite_image(bg_image, cel_image, render::composite_image(bg_image.get(), cel_image,
cel->x(), cel->y(), cel->x(), cel->y(),
MID(0, cel->opacity(), 255), MID(0, cel->opacity(), 255),
static_cast<LayerImage*>(layer)->getBlendMode()); static_cast<LayerImage*>(layer)->getBlendMode());
@ -69,11 +69,11 @@ void BackgroundFromLayer::onExecute()
// same size of cel-image and bg-image // same size of cel-image and bg-image
if (bg_image->width() == cel_image->width() && if (bg_image->width() == cel_image->width() &&
bg_image->height() == cel_image->height()) { bg_image->height() == cel_image->height()) {
executeAndAdd(new CopyRect(cel_image, bg_image, executeAndAdd(new CopyRect(cel_image, bg_image.get(),
gfx::Clip(0, 0, cel_image->bounds()))); gfx::Clip(0, 0, cel_image->bounds())));
} }
else { else {
ImageRef bg_image2(Image::createCopy(bg_image)); ImageRef bg_image2(Image::createCopy(bg_image.get()));
executeAndAdd(new cmd::ReplaceImage(sprite, cel->imageRef(), bg_image2)); executeAndAdd(new cmd::ReplaceImage(sprite, cel->imageRef(), bg_image2));
} }
} }
@ -84,7 +84,7 @@ void BackgroundFromLayer::onExecute()
if (!cel) { if (!cel) {
ImageRef cel_image(Image::create(sprite->pixelFormat(), ImageRef cel_image(Image::create(sprite->pixelFormat(),
sprite->width(), sprite->height())); sprite->width(), sprite->height()));
clear_image(cel_image, bgcolor); clear_image(cel_image.get(), bgcolor);
// Create the new cel and add it to the new background layer // Create the new cel and add it to the new background layer
cel = new Cel(frame, cel_image); cel = new Cel(frame, cel_image);

View File

@ -35,8 +35,8 @@ void ClearImage::onExecute()
void ClearImage::onUndo() void ClearImage::onUndo()
{ {
copy_image(image(), m_copy); copy_image(image(), m_copy.get());
m_copy.reset(nullptr); m_copy.reset();
} }
} // namespace cmd } // namespace cmd

View File

@ -113,7 +113,7 @@ void ClearMask::clear()
void ClearMask::restore() void ClearMask::restore()
{ {
copy_image(m_dstImage->image(), m_copy, m_offsetX, m_offsetY); copy_image(m_dstImage->image(), m_copy.get(), m_offsetX, m_offsetY);
} }
} // namespace cmd } // namespace cmd

View File

@ -95,10 +95,10 @@ void CopyCel::onExecute()
int blend = (srcLayer->isBackground() ? int blend = (srcLayer->isBackground() ?
BLEND_MODE_COPY: BLEND_MODE_NORMAL); BLEND_MODE_COPY: BLEND_MODE_NORMAL);
ImageRef tmp(Image::createCopy(dstImage)); ImageRef tmp(Image::createCopy(dstImage.get()));
render::composite_image(tmp, srcImage, render::composite_image(tmp.get(), srcImage,
srcCel->x(), srcCel->y(), 255, blend); srcCel->x(), srcCel->y(), 255, blend);
executeAndAdd(new cmd::CopyRect(dstImage, tmp, gfx::Clip(tmp->bounds()))); executeAndAdd(new cmd::CopyRect(dstImage.get(), tmp.get(), gfx::Clip(tmp->bounds())));
} }
} }
// For transparent layers // For transparent layers

View File

@ -37,7 +37,7 @@ void DeselectMask::onUndo()
doc->setMask(m_oldMask); doc->setMask(m_oldMask);
doc->setMaskVisible(true); doc->setMaskVisible(true);
m_oldMask.reset(nullptr); m_oldMask.reset();
} }
size_t DeselectMask::onMemSize() const size_t DeselectMask::onMemSize() const

View File

@ -57,8 +57,8 @@ void FlattenLayers::onExecute()
// Copy all frames to the background. // Copy all frames to the background.
for (frame_t frame(0); frame<sprite->totalFrames(); ++frame) { for (frame_t frame(0); frame<sprite->totalFrames(); ++frame) {
// Clear the image and render this frame. // Clear the image and render this frame.
clear_image(image, bgcolor); clear_image(image.get(), bgcolor);
render.renderSprite(image, sprite, frame); render.renderSprite(image.get(), sprite, frame);
// TODO Keep cel links when possible // TODO Keep cel links when possible
@ -71,11 +71,11 @@ void FlattenLayers::onExecute()
cel_image = cel->imageRef(); cel_image = cel->imageRef();
ASSERT(cel_image); ASSERT(cel_image);
executeAndAdd(new cmd::CopyRect(cel_image, image, executeAndAdd(new cmd::CopyRect(cel_image.get(), image.get(),
gfx::Clip(0, 0, image->bounds()))); gfx::Clip(0, 0, image->bounds())));
} }
else { else {
cel_image.reset(Image::createCopy(image)); cel_image.reset(Image::createCopy(image.get()));
cel = new Cel(frame, cel_image); cel = new Cel(frame, cel_image);
background->addCel(cel); background->addCel(cel);
} }

View File

@ -98,10 +98,10 @@ void MoveCel::onExecute()
int blend = (srcLayer->isBackground() ? int blend = (srcLayer->isBackground() ?
BLEND_MODE_COPY: BLEND_MODE_NORMAL); BLEND_MODE_COPY: BLEND_MODE_NORMAL);
ImageRef tmp(Image::createCopy(dstImage)); ImageRef tmp(Image::createCopy(dstImage.get()));
render::composite_image(tmp, srcImage, render::composite_image(tmp.get(), srcImage,
srcCel->x(), srcCel->y(), 255, blend); srcCel->x(), srcCel->y(), 255, blend);
executeAndAdd(new cmd::CopyRect(dstImage, tmp, gfx::Clip(tmp->bounds()))); executeAndAdd(new cmd::CopyRect(dstImage.get(), tmp.get(), gfx::Clip(tmp->bounds())));
} }
executeAndAdd(new cmd::ClearCel(srcCel)); executeAndAdd(new cmd::ClearCel(srcCel));
} }

View File

@ -37,10 +37,10 @@ void ReplaceImage::onExecute()
// modify/re-add this same image ID // modify/re-add this same image ID
ImageRef oldImage = sprite()->getImageRef(m_oldImageId); ImageRef oldImage = sprite()->getImageRef(m_oldImageId);
ASSERT(oldImage); ASSERT(oldImage);
m_copy.reset(Image::createCopy(oldImage)); m_copy.reset(Image::createCopy(oldImage.get()));
sprite()->replaceImage(m_oldImageId, m_newImage); sprite()->replaceImage(m_oldImageId, m_newImage);
m_newImage.reset(nullptr); m_newImage.reset();
} }
void ReplaceImage::onUndo() void ReplaceImage::onUndo()
@ -51,7 +51,7 @@ void ReplaceImage::onUndo()
m_copy->setId(m_oldImageId); m_copy->setId(m_oldImageId);
sprite()->replaceImage(m_newImageId, m_copy); sprite()->replaceImage(m_newImageId, m_copy);
m_copy.reset(Image::createCopy(newImage)); m_copy.reset(Image::createCopy(newImage.get()));
} }
void ReplaceImage::onRedo() void ReplaceImage::onRedo()
@ -62,7 +62,7 @@ void ReplaceImage::onRedo()
m_copy->setId(m_newImageId); m_copy->setId(m_newImageId);
sprite()->replaceImage(m_oldImageId, m_copy); sprite()->replaceImage(m_oldImageId, m_copy);
m_copy.reset(Image::createCopy(oldImage)); m_copy.reset(Image::createCopy(oldImage.get()));
} }
} // namespace cmd } // namespace cmd

View File

@ -29,7 +29,7 @@ void ReselectMask::onExecute()
if (m_oldMask) { if (m_oldMask) {
doc->setMask(m_oldMask); doc->setMask(m_oldMask);
m_oldMask.reset(nullptr); m_oldMask.reset();
} }
doc->setMaskVisible(true); doc->setMaskVisible(true);

View File

@ -39,7 +39,7 @@ void SetCelData::onExecute()
createCopy(); createCopy();
cel->setDataRef(m_newData); cel->setDataRef(m_newData);
m_newData.reset(nullptr); m_newData.reset();
} }
void SetCelData::onUndo() void SetCelData::onUndo()
@ -52,7 +52,7 @@ void SetCelData::onUndo()
m_dataCopy->image()->setId(m_oldImageId); m_dataCopy->image()->setId(m_oldImageId);
cel->setDataRef(m_dataCopy); cel->setDataRef(m_dataCopy);
m_dataCopy.reset(nullptr); m_dataCopy.reset();
} }
else { else {
CelDataRef oldData = cel->sprite()->getCelDataRef(m_oldDataId); CelDataRef oldData = cel->sprite()->getCelDataRef(m_oldDataId);

View File

@ -267,7 +267,7 @@ retry:;
Image::create(sprite->pixelFormat(), frameBounds.w, frameBounds.h)); Image::create(sprite->pixelFormat(), frameBounds.w, frameBounds.h));
// Render the portion of sheet. // Render the portion of sheet.
render.renderSprite(resultImage, sprite, currentFrame, render.renderSprite(resultImage.get(), sprite, currentFrame,
gfx::Clip(0, 0, x, y, frameBounds.w, frameBounds.h)); gfx::Clip(0, 0, x, y, frameBounds.w, frameBounds.h));
animation.push_back(resultImage); animation.push_back(resultImage);

View File

@ -94,7 +94,7 @@ void MergeDownLayerCommand::onExecute(Context* context)
// With source image? // With source image?
if (src_image) { if (src_image) {
// No destination image // No destination image
if (dst_image == NULL) { // Only a transparent layer can have a null cel if (!dst_image) { // Only a transparent layer can have a null cel
// Copy this cel to the destination layer... // Copy this cel to the destination layer...
// Creating a copy of the image // Creating a copy of the image
@ -122,13 +122,14 @@ void MergeDownLayerCommand::onExecute(Context* context)
doc::color_t bgcolor = app_get_color_to_clear_layer(dst_layer); doc::color_t bgcolor = app_get_color_to_clear_layer(dst_layer);
ImageRef new_image(doc::crop_image(dst_image, ImageRef new_image(doc::crop_image(
dst_image.get(),
bounds.x-dst_cel->x(), bounds.x-dst_cel->x(),
bounds.y-dst_cel->y(), bounds.y-dst_cel->y(),
bounds.w, bounds.h, bgcolor)); bounds.w, bounds.h, bgcolor));
// Merge src_image in new_image // Merge src_image in new_image
render::composite_image(new_image, src_image, render::composite_image(new_image.get(), src_image,
src_cel->x()-bounds.x, src_cel->x()-bounds.x,
src_cel->y()-bounds.y, src_cel->y()-bounds.y,
src_cel->opacity(), src_cel->opacity(),

View File

@ -111,7 +111,7 @@ protected:
ImageRef new_image(Image::create(image->pixelFormat(), ImageRef new_image(Image::create(image->pixelFormat(),
m_angle == 180 ? image->width(): image->height(), m_angle == 180 ? image->width(): image->height(),
m_angle == 180 ? image->height(): image->width())); m_angle == 180 ? image->height(): image->width()));
doc::rotate_image(image, new_image, m_angle); doc::rotate_image(image, new_image.get(), m_angle);
api.replaceImage(m_sprite, cel->imageRef(), new_image); api.replaceImage(m_sprite, cel->imageRef(), new_image);
} }

View File

@ -95,7 +95,7 @@ protected:
ImageRef new_image(Image::create(image->pixelFormat(), MAX(1, w), MAX(1, h))); ImageRef new_image(Image::create(image->pixelFormat(), MAX(1, w), MAX(1, h)));
doc::algorithm::fixup_image_transparent_colors(image); doc::algorithm::fixup_image_transparent_colors(image);
doc::algorithm::resize_image(image, new_image, doc::algorithm::resize_image(image, new_image.get(),
m_resize_method, m_resize_method,
m_sprite->palette(cel->frame()), m_sprite->palette(cel->frame()),
m_sprite->rgbMap(cel->frame())); m_sprite->rgbMap(cel->frame()));
@ -125,7 +125,7 @@ protected:
gfx::Rect( gfx::Rect(
scale_x(m_document->mask()->bounds().x-1), scale_x(m_document->mask()->bounds().x-1),
scale_y(m_document->mask()->bounds().y-1), MAX(1, w), MAX(1, h))); scale_y(m_document->mask()->bounds().y-1), MAX(1, w), MAX(1, h)));
algorithm::resize_image(old_bitmap, new_mask->bitmap(), algorithm::resize_image(old_bitmap.get(), new_mask->bitmap(),
m_resize_method, m_resize_method,
m_sprite->palette(0), // Ignored m_sprite->palette(0), // Ignored
m_sprite->rgbMap(0)); // Ignored m_sprite->rgbMap(0)); // Ignored

View File

@ -181,14 +181,14 @@ void ConvolutionMatrixCommand::onExecute(Context* context)
ConvolutionMatrixFilter filter; ConvolutionMatrixFilter filter;
filter.setTiledMode(docPref.tiled.mode()); filter.setTiledMode(docPref.tiled.mode());
if (matrix != 0) if (matrix)
filter.setMatrix(matrix); filter.setMatrix(matrix);
FilterManagerImpl filterMgr(context, &filter); FilterManagerImpl filterMgr(context, &filter);
ConvolutionMatrixWindow window(filter, filterMgr, m_stock); ConvolutionMatrixWindow window(filter, filterMgr, m_stock);
if (window.doModal()) { if (window.doModal()) {
if (filter.getMatrix() != NULL) if (filter.getMatrix())
set_config_string(ConfigSection, "Selected", filter.getMatrix()->getName()); set_config_string(ConfigSection, "Selected", filter.getMatrix()->getName());
} }
} }

View File

@ -68,7 +68,8 @@ void ConvolutionMatrixStock::reloadStock()
while (rf.next()) { while (rf.next()) {
// Open matrices stock file // Open matrices stock file
base::FileHandle f = base::open_file(rf.filename(), "r"); base::FileHandle handle(base::open_file(rf.filename(), "r"));
FILE* f = handle.get();
if (!f) if (!f)
continue; continue;

View File

@ -91,7 +91,7 @@ FilterWorker::FilterWorker(FilterManagerImpl* filterMgr)
FilterWorker::~FilterWorker() FilterWorker::~FilterWorker()
{ {
if (m_alertWindow != NULL) if (m_alertWindow)
m_alertWindow->closeWindow(NULL); m_alertWindow->closeWindow(NULL);
delete m_progressBar; delete m_progressBar;

View File

@ -115,8 +115,8 @@ public:
layer->addCel(cel); layer->addCel(cel);
} }
clear_image(image, black); clear_image(image.get(), black);
put_pixel(image, i, j, white); put_pixel(image.get(), i, j, white);
} }
} }
} }

View File

@ -150,7 +150,8 @@ FileFormat* CreateAseFormat()
bool AseFormat::onLoad(FileOp* fop) bool AseFormat::onLoad(FileOp* fop)
{ {
FileHandle f(open_file_with_exception(fop->filename, "rb")); FileHandle handle(open_file_with_exception(fop->filename, "rb"));
FILE* f = handle.get();
ASE_Header header; ASE_Header header;
if (!ase_file_read_header(f, &header)) { if (!ase_file_read_header(f, &header)) {
@ -295,7 +296,8 @@ bool AseFormat::onLoad(FileOp* fop)
bool AseFormat::onSave(FileOp* fop) bool AseFormat::onSave(FileOp* fop)
{ {
Sprite* sprite = fop->document->sprite(); Sprite* sprite = fop->document->sprite();
FileHandle f(open_file_with_exception(fop->filename, "wb")); FileHandle handle(open_file_with_exception(fop->filename, "wb"));
FILE* f = handle.get();
// Write the header // Write the header
ASE_Header header; ASE_Header header;
@ -1037,15 +1039,15 @@ static Cel* ase_file_read_cel_chunk(FILE* f, Sprite* sprite, frame_t frame,
switch (image->pixelFormat()) { switch (image->pixelFormat()) {
case IMAGE_RGB: case IMAGE_RGB:
read_raw_image<RgbTraits>(f, image, fop, header); read_raw_image<RgbTraits>(f, image.get(), fop, header);
break; break;
case IMAGE_GRAYSCALE: case IMAGE_GRAYSCALE:
read_raw_image<GrayscaleTraits>(f, image, fop, header); read_raw_image<GrayscaleTraits>(f, image.get(), fop, header);
break; break;
case IMAGE_INDEXED: case IMAGE_INDEXED:
read_raw_image<IndexedTraits>(f, image, fop, header); read_raw_image<IndexedTraits>(f, image.get(), fop, header);
break; break;
} }
@ -1096,15 +1098,15 @@ static Cel* ase_file_read_cel_chunk(FILE* f, Sprite* sprite, frame_t frame,
switch (image->pixelFormat()) { switch (image->pixelFormat()) {
case IMAGE_RGB: case IMAGE_RGB:
read_compressed_image<RgbTraits>(f, image, chunk_end, fop, header); read_compressed_image<RgbTraits>(f, image.get(), chunk_end, fop, header);
break; break;
case IMAGE_GRAYSCALE: case IMAGE_GRAYSCALE:
read_compressed_image<GrayscaleTraits>(f, image, chunk_end, fop, header); read_compressed_image<GrayscaleTraits>(f, image.get(), chunk_end, fop, header);
break; break;
case IMAGE_INDEXED: case IMAGE_INDEXED:
read_compressed_image<IndexedTraits>(f, image, chunk_end, fop, header); read_compressed_image<IndexedTraits>(f, image.get(), chunk_end, fop, header);
break; break;
} }
} }

View File

@ -602,7 +602,8 @@ bool BmpFormat::onLoad(FileOp *fop)
PixelFormat pixelFormat; PixelFormat pixelFormat;
int format; int format;
FileHandle f(open_file_with_exception(fop->filename, "rb")); FileHandle handle(open_file_with_exception(fop->filename, "rb"));
FILE* f = handle.get();
if (read_bmfileheader(f, &fileheader) != 0) if (read_bmfileheader(f, &fileheader) != 0)
return false; return false;
@ -692,7 +693,7 @@ bool BmpFormat::onLoad(FileOp *fop)
} }
// Setup the file-data. // Setup the file-data.
if (fop->seq.format_options == NULL) { if (!fop->seq.format_options) {
base::SharedPtr<BmpOptions> bmp_options(new BmpOptions()); base::SharedPtr<BmpOptions> bmp_options(new BmpOptions());
bmp_options->format = format; bmp_options->format = format;
@ -711,7 +712,7 @@ bool BmpFormat::onLoad(FileOp *fop)
#ifdef ENABLE_SAVE #ifdef ENABLE_SAVE
bool BmpFormat::onSave(FileOp *fop) bool BmpFormat::onSave(FileOp *fop)
{ {
Image *image = fop->seq.image; Image* image = fop->seq.image.get();
int bfSize; int bfSize;
int biSizeImage; int biSizeImage;
int bpp = (image->pixelFormat() == IMAGE_RGB) ? 24 : 8; int bpp = (image->pixelFormat() == IMAGE_RGB) ? 24 : 8;
@ -729,7 +730,8 @@ bool BmpFormat::onSave(FileOp *fop)
bfSize = 54 + biSizeImage; /* header + image data */ bfSize = 54 + biSizeImage; /* header + image data */
} }
FileHandle f(open_file_with_exception(fop->filename, "wb")); FileHandle handle(open_file_with_exception(fop->filename, "wb"));
FILE* f = handle.get();
/* file_header */ /* file_header */
fputw(0x4D42, f); /* bfType ("BM") */ fputw(0x4D42, f); /* bfType ("BM") */

View File

@ -422,7 +422,7 @@ FileOp* fop_to_save_document(Context* context, Document* document, const char* f
base::SharedPtr<FormatOptions> format_options = fop->format->getFormatOptions(fop); base::SharedPtr<FormatOptions> format_options = fop->format->getFormatOptions(fop);
// Does the user cancelled the operation? // Does the user cancelled the operation?
if (format_options == NULL) { if (!format_options) {
fop_free(fop); fop_free(fop);
return NULL; return NULL;
} }
@ -472,7 +472,7 @@ void fop_operate(FileOp *fop, IFileOpProgress* progress)
fop->document->sprite()->setPalette(fop->seq.palette, true); \ fop->document->sprite()->setPalette(fop->seq.palette, true); \
} \ } \
\ \
old_image = fop->seq.image; \ old_image = fop->seq.image.get(); \
fop->seq.image.reset(NULL); \ fop->seq.image.reset(NULL); \
fop->seq.last_cel = NULL; \ fop->seq.last_cel = NULL; \
} while (0) } while (0)
@ -480,7 +480,7 @@ void fop_operate(FileOp *fop, IFileOpProgress* progress)
// Load the sequence // Load the sequence
frame_t frames(fop->seq.filename_list.size()); frame_t frames(fop->seq.filename_list.size());
frame_t frame(0); frame_t frame(0);
old_image = NULL; old_image = nullptr;
fop->seq.has_alpha = false; fop->seq.has_alpha = false;
fop->seq.progress_offset = 0.0f; fop->seq.progress_offset = 0.0f;
@ -502,10 +502,10 @@ void fop_operate(FileOp *fop, IFileOpProgress* progress)
if (!old_image) { if (!old_image) {
// Error reading the first frame // Error reading the first frame
if (!loadres || !fop->document || !fop->seq.last_cel) { if (!loadres || !fop->document || !fop->seq.last_cel) {
delete fop->seq.image; fop->seq.image.reset();
delete fop->seq.last_cel; delete fop->seq.last_cel;
delete fop->document; delete fop->document;
fop->document = NULL; fop->document = nullptr;
break; break;
} }
// Read ok // Read ok
@ -518,7 +518,7 @@ void fop_operate(FileOp *fop, IFileOpProgress* progress)
else { else {
// All done (or maybe not enough memory) // All done (or maybe not enough memory)
if (!loadres || !fop->seq.last_cel) { if (!loadres || !fop->seq.last_cel) {
delete fop->seq.image; fop->seq.image.reset();
delete fop->seq.last_cel; delete fop->seq.last_cel;
break; break;
} }
@ -594,7 +594,7 @@ void fop_operate(FileOp *fop, IFileOpProgress* progress)
render::Render render; render::Render render;
for (frame_t frame(0); frame < sprite->totalFrames(); ++frame) { for (frame_t frame(0); frame < sprite->totalFrames(); ++frame) {
// Draw the "frame" in "fop->seq.image" // Draw the "frame" in "fop->seq.image"
render.renderSprite(fop->seq.image, sprite, frame); render.renderSprite(fop->seq.image.get(), sprite, frame);
// Setup the palette. // Setup the palette.
sprite->palette(frame)->copyColorsTo(fop->seq.palette); sprite->palette(frame)->copyColorsTo(fop->seq.palette);
@ -702,7 +702,7 @@ void fop_post_load(FileOp* fop)
frame_t(0), NULL)); frame_t(0), NULL));
fop->document->sprite()->resetPalettes(); fop->document->sprite()->resetPalettes();
fop->document->sprite()->setPalette(palette, false); fop->document->sprite()->setPalette(palette.get(), false);
} }
} }
@ -711,7 +711,7 @@ void fop_post_load(FileOp* fop)
void fop_sequence_set_format_options(FileOp* fop, const base::SharedPtr<FormatOptions>& format_options) void fop_sequence_set_format_options(FileOp* fop, const base::SharedPtr<FormatOptions>& format_options)
{ {
ASSERT(fop->seq.format_options == NULL); ASSERT(!fop->seq.format_options);
fop->seq.format_options = format_options; fop->seq.format_options = format_options;
} }

View File

@ -74,7 +74,8 @@ bool FliFormat::onLoad(FileOp* fop)
#endif #endif
// Open the file to read in binary mode // Open the file to read in binary mode
FileHandle f(open_file_with_exception(fop->filename, "rb")); FileHandle handle(open_file_with_exception(fop->filename, "rb"));
FILE* f = handle.get();
fli_read_header(f, &fli_header); fli_read_header(f, &fli_header);
fseek(f, 128, SEEK_SET); fseek(f, 128, SEEK_SET);
@ -201,7 +202,8 @@ bool FliFormat::onSave(FileOp* fop)
fli_header.oframe1 = fli_header.oframe2 = 0; fli_header.oframe1 = fli_header.oframe2 = 0;
/* open the file to write in binary mode */ /* open the file to write in binary mode */
FileHandle f(open_file_with_exception(fop->filename, "wb")); FileHandle handle(open_file_with_exception(fop->filename, "wb"));
FILE* f = handle.get();
fseek(f, 128, SEEK_SET); fseek(f, 128, SEEK_SET);

View File

@ -776,7 +776,7 @@ bool GifFormat::onSave(FileOp* fop)
base::SharedPtr<FormatOptions> GifFormat::onGetFormatOptions(FileOp* fop) base::SharedPtr<FormatOptions> GifFormat::onGetFormatOptions(FileOp* fop)
{ {
base::SharedPtr<GifOptions> gif_options; base::SharedPtr<GifOptions> gif_options;
if (fop->document->getFormatOptions() != NULL) if (fop->document->getFormatOptions())
gif_options = base::SharedPtr<GifOptions>(fop->document->getFormatOptions()); gif_options = base::SharedPtr<GifOptions>(fop->document->getFormatOptions());
if (!gif_options) if (!gif_options)

View File

@ -80,7 +80,8 @@ struct BITMAPINFOHEADER {
bool IcoFormat::onLoad(FileOp* fop) bool IcoFormat::onLoad(FileOp* fop)
{ {
FileHandle f(open_file_with_exception(fop->filename, "rb")); FileHandle handle(open_file_with_exception(fop->filename, "rb"));
FILE* f = handle.get();
// Read the icon header // Read the icon header
ICONDIR header; ICONDIR header;
@ -132,7 +133,7 @@ bool IcoFormat::onLoad(FileOp* fop)
ImageRef image(Image::create(pixelFormat, width, height)); ImageRef image(Image::create(pixelFormat, width, height));
Cel* cel = new Cel(frame_t(0), image); Cel* cel = new Cel(frame_t(0), image);
layer->addCel(cel); layer->addCel(cel);
clear_image(image, 0); clear_image(image.get(), 0);
// Go to the entry start in the file // Go to the entry start in the file
fseek(f, entry.image_offset, SEEK_SET); fseek(f, entry.image_offset, SEEK_SET);
@ -178,16 +179,16 @@ bool IcoFormat::onLoad(FileOp* fop)
c = fgetc(f); c = fgetc(f);
ASSERT(c >= 0 && c < numcolors); ASSERT(c >= 0 && c < numcolors);
if (c >= 0 && c < numcolors) if (c >= 0 && c < numcolors)
put_pixel(image, x, y, c); put_pixel(image.get(), x, y, c);
else else
put_pixel(image, x, y, 0); put_pixel(image.get(), x, y, 0);
break; break;
case 24: case 24:
b = fgetc(f); b = fgetc(f);
g = fgetc(f); g = fgetc(f);
r = fgetc(f); r = fgetc(f);
put_pixel(image, x, y, rgba(r, g, b, 255)); put_pixel(image.get(), x, y, rgba(r, g, b, 255));
break; break;
} }
} }
@ -207,7 +208,7 @@ bool IcoFormat::onLoad(FileOp* fop)
v = 128; v = 128;
for (b=0; b<8; b++) { for (b=0; b<8; b++) {
if ((m & v) == v) if ((m & v) == v)
put_pixel(image, x*8+b, y, 0); // TODO mask color put_pixel(image.get(), x*8+b, y, 0); // TODO mask color
v >>= 1; v >>= 1;
} }
} }
@ -232,7 +233,8 @@ bool IcoFormat::onSave(FileOp* fop)
int c, x, y, b, m, v; int c, x, y, b, m, v;
frame_t n, num = sprite->totalFrames(); frame_t n, num = sprite->totalFrames();
FileHandle f(open_file_with_exception(fop->filename, "wb")); FileHandle handle(open_file_with_exception(fop->filename, "wb"));
FILE* f = handle.get();
offset = 6 + num*16; // ICONDIR + ICONDIRENTRYs offset = 6 + num*16; // ICONDIR + ICONDIRENTRYs

View File

@ -105,7 +105,8 @@ bool JpegFormat::onLoad(FileOp* fop)
JDIMENSION buffer_height; JDIMENSION buffer_height;
int c; int c;
FileHandle file(open_file_with_exception(fop->filename, "rb")); FileHandle handle(open_file_with_exception(fop->filename, "rb"));
FILE* file = handle.get();
// Initialize the JPEG decompression object with error handling. // Initialize the JPEG decompression object with error handling.
jerr.fop = fop; jerr.fop = fop;
@ -234,14 +235,15 @@ bool JpegFormat::onSave(FileOp* fop)
{ {
struct jpeg_compress_struct cinfo; struct jpeg_compress_struct cinfo;
struct error_mgr jerr; struct error_mgr jerr;
Image *image = fop->seq.image; Image* image = fop->seq.image.get();
JSAMPARRAY buffer; JSAMPARRAY buffer;
JDIMENSION buffer_height; JDIMENSION buffer_height;
base::SharedPtr<JpegOptions> jpeg_options = fop->seq.format_options; base::SharedPtr<JpegOptions> jpeg_options = fop->seq.format_options;
int c; int c;
// Open the file for write in it. // Open the file for write in it.
FileHandle file(open_file_with_exception(fop->filename, "wb")); FileHandle handle(open_file_with_exception(fop->filename, "wb"));
FILE* file = handle.get();
// Allocate and initialize JPEG compression object. // Allocate and initialize JPEG compression object.
jerr.fop = fop; jerr.fop = fop;
@ -350,7 +352,7 @@ bool JpegFormat::onSave(FileOp* fop)
base::SharedPtr<FormatOptions> JpegFormat::onGetFormatOptions(FileOp* fop) base::SharedPtr<FormatOptions> JpegFormat::onGetFormatOptions(FileOp* fop)
{ {
base::SharedPtr<JpegOptions> jpeg_options; base::SharedPtr<JpegOptions> jpeg_options;
if (fop->document->getFormatOptions() != NULL) if (fop->document->getFormatOptions())
jpeg_options = base::SharedPtr<JpegOptions>(fop->document->getFormatOptions()); jpeg_options = base::SharedPtr<JpegOptions>(fop->document->getFormatOptions());
if (!jpeg_options) if (!jpeg_options)

View File

@ -55,7 +55,8 @@ bool PcxFormat::onLoad(FileOp* fop)
int x, y; int x, y;
char ch = 0; char ch = 0;
FileHandle f(open_file_with_exception(fop->filename, "rb")); FileHandle handle(open_file_with_exception(fop->filename, "rb"));
FILE* f = handle.get();
fgetc(f); /* skip manufacturer ID */ fgetc(f); /* skip manufacturer ID */
fgetc(f); /* skip version flag */ fgetc(f); /* skip version flag */
@ -178,7 +179,7 @@ bool PcxFormat::onLoad(FileOp* fop)
#ifdef ENABLE_SAVE #ifdef ENABLE_SAVE
bool PcxFormat::onSave(FileOp* fop) bool PcxFormat::onSave(FileOp* fop)
{ {
Image *image = fop->seq.image; Image* image = fop->seq.image.get();
int c, r, g, b; int c, r, g, b;
int x, y; int x, y;
int runcount; int runcount;
@ -186,7 +187,8 @@ bool PcxFormat::onSave(FileOp* fop)
char runchar; char runchar;
char ch = 0; char ch = 0;
FileHandle f(open_file_with_exception(fop->filename, "wb")); FileHandle handle(open_file_with_exception(fop->filename, "wb"));
FILE* f = handle.get();
if (image->pixelFormat() == IMAGE_RGB) { if (image->pixelFormat() == IMAGE_RGB) {
depth = 24; depth = 24;

View File

@ -71,7 +71,8 @@ bool PngFormat::onLoad(FileOp* fop)
png_bytep row_pointer; png_bytep row_pointer;
PixelFormat pixelFormat; PixelFormat pixelFormat;
FileHandle fp(open_file_with_exception(fop->filename, "rb")); FileHandle handle(open_file_with_exception(fop->filename, "rb"));
FILE* fp = handle.get();
/* Create and initialize the png_struct with the desired error handler /* Create and initialize the png_struct with the desired error handler
* functions. If you want to use the default stderr and longjump method, * functions. If you want to use the default stderr and longjump method,
@ -321,7 +322,7 @@ bool PngFormat::onLoad(FileOp* fop)
#ifdef ENABLE_SAVE #ifdef ENABLE_SAVE
bool PngFormat::onSave(FileOp* fop) bool PngFormat::onSave(FileOp* fop)
{ {
Image *image = fop->seq.image; Image* image = fop->seq.image.get();
png_uint_32 width, height, y; png_uint_32 width, height, y;
png_structp png_ptr; png_structp png_ptr;
png_infop info_ptr; png_infop info_ptr;
@ -331,7 +332,8 @@ bool PngFormat::onSave(FileOp* fop)
int pass, number_passes; int pass, number_passes;
/* open the file */ /* open the file */
FileHandle fp(open_file_with_exception(fop->filename, "wb")); FileHandle handle(open_file_with_exception(fop->filename, "wb"));
FILE* fp = handle.get();
/* Create and initialize the png_struct with the desired error handler /* Create and initialize the png_struct with the desired error handler
* functions. If you want to use the default stderr and longjump method, * functions. If you want to use the default stderr and longjump method,

View File

@ -197,7 +197,8 @@ bool TgaFormat::onLoad(FileOp* fop)
unsigned int c, i, x, y, yc; unsigned int c, i, x, y, yc;
int compressed; int compressed;
FileHandle f(open_file_with_exception(fop->filename, "rb")); FileHandle handle(open_file_with_exception(fop->filename, "rb"));
FILE* f = handle.get();
id_length = fgetc(f); id_length = fgetc(f);
palette_type = fgetc(f); palette_type = fgetc(f);
@ -381,13 +382,14 @@ bool TgaFormat::onLoad(FileOp* fop)
// should be an array of at least 256 RGB structures). // should be an array of at least 256 RGB structures).
bool TgaFormat::onSave(FileOp* fop) bool TgaFormat::onSave(FileOp* fop)
{ {
Image *image = fop->seq.image; Image* image = fop->seq.image.get();
unsigned char image_palette[256][3]; unsigned char image_palette[256][3];
int x, y, c, r, g, b; int x, y, c, r, g, b;
int depth = (image->pixelFormat() == IMAGE_RGB) ? 32 : 8; int depth = (image->pixelFormat() == IMAGE_RGB) ? 32 : 8;
bool need_pal = (image->pixelFormat() == IMAGE_INDEXED)? true: false; bool need_pal = (image->pixelFormat() == IMAGE_INDEXED)? true: false;
FileHandle f(open_file_with_exception(fop->filename, "wb")); FileHandle handle(open_file_with_exception(fop->filename, "wb"));
FILE* f = handle.get();
fputc(0, f); /* id length (no id saved) */ fputc(0, f); /* id length (no id saved) */
fputc((need_pal) ? 1 : 0, f); /* palette type */ fputc((need_pal) ? 1 : 0, f); /* palette type */

View File

@ -42,7 +42,7 @@ LayerImage* create_flatten_layer_copy(Sprite* dstSprite, const Layer* srcLayer,
cel->setPosition(bounds.x, bounds.y); cel->setPosition(bounds.x, bounds.y);
// Render this frame. // Render this frame.
render.renderLayer(image, srcLayer, frame, render.renderLayer(image.get(), srcLayer, frame,
gfx::Clip(0, 0, bounds)); gfx::Clip(0, 0, bounds));
// Add the cel (and release the base::UniquePtr). // Add the cel (and release the base::UniquePtr).

View File

@ -43,7 +43,7 @@ GuiXml::GuiXml()
std::string GuiXml::version() std::string GuiXml::version()
{ {
TiXmlHandle handle(m_doc); TiXmlHandle handle(m_doc.get());
TiXmlElement* xmlKey = handle.FirstChild("gui").ToElement(); TiXmlElement* xmlKey = handle.FirstChild("gui").ToElement();
if (xmlKey && xmlKey->Attribute("version")) { if (xmlKey && xmlKey->Attribute("version")) {

View File

@ -39,7 +39,7 @@ Job::Job(const char* jobName)
m_progress = StatusBar::instance()->addProgress(); m_progress = StatusBar::instance()->addProgress();
m_alert_window = ui::Alert::create("%s<<Working...||&Cancel", jobName); m_alert_window = ui::Alert::create("%s<<Working...||&Cancel", jobName);
m_timer.reset(new ui::Timer(kMonitoringPeriod, m_alert_window)); m_timer.reset(new ui::Timer(kMonitoringPeriod, m_alert_window.get()));
m_timer->Tick.connect(&Job::onMonitoringTick, this); m_timer->Tick.connect(&Job::onMonitoringTick, this);
m_timer->start(); m_timer->start();
} }
@ -51,7 +51,7 @@ Job::~Job()
ASSERT(!m_timer->isRunning()); ASSERT(!m_timer->isRunning());
ASSERT(m_thread == NULL); ASSERT(m_thread == NULL);
if (m_alert_window != NULL) if (m_alert_window)
m_alert_window->closeWindow(NULL); m_alert_window->closeWindow(NULL);
if (m_progress) if (m_progress)

View File

@ -167,7 +167,7 @@ void ToolBox::loadTools()
PRINTF("Loading Aseprite tools\n"); PRINTF("Loading Aseprite tools\n");
XmlDocumentRef doc(GuiXml::instance()->doc()); XmlDocumentRef doc(GuiXml::instance()->doc());
TiXmlHandle handle(doc); TiXmlHandle handle(doc.get());
// For each group // For each group
TiXmlElement* xmlGroup = handle.FirstChild("gui").FirstChild("tools").FirstChild("group").ToElement(); TiXmlElement* xmlGroup = handle.FirstChild("gui").FirstChild("tools").FirstChild("group").ToElement();

View File

@ -205,7 +205,7 @@ void Editor::setStateInternal(const EditorStatePtr& newState)
// Fire before change state event, set the state, and fire after // Fire before change state event, set the state, and fire after
// change state event. // change state event.
EditorState::BeforeChangeAction beforeChangeAction = EditorState::BeforeChangeAction beforeChangeAction =
m_state->onBeforeChangeState(this, newState); m_state->onBeforeChangeState(this, newState.get());
// Push a new state // Push a new state
if (newState) { if (newState) {
@ -223,7 +223,7 @@ void Editor::setStateInternal(const EditorStatePtr& newState)
m_state = m_statesHistory.top(); m_state = m_statesHistory.top();
} }
ASSERT(m_state != NULL); ASSERT(m_state);
// Change to the new state. // Change to the new state.
m_state->onAfterChangeState(this); m_state->onAfterChangeState(this);
@ -584,7 +584,7 @@ void Editor::drawSpriteClipped(const gfx::Region& updateRegion)
for (const Rect& screenRect : screenRegion) { for (const Rect& screenRect : screenRegion) {
IntersectClip clip(&screenGraphics, screenRect); IntersectClip clip(&screenGraphics, screenRect);
if (clip) if (clip)
drawSpriteUnclippedRect(editorGraphics, updateRect); drawSpriteUnclippedRect(editorGraphics.get(), updateRect);
} }
} }
} }
@ -670,9 +670,9 @@ void Editor::drawMaskSafe()
GraphicsPtr g = getGraphics(getClientBounds()); GraphicsPtr g = getGraphics(getClientBounds());
for (const gfx::Rect& rc : region) { for (const gfx::Rect& rc : region) {
IntersectClip clip(g, rc); IntersectClip clip(g.get(), rc);
if (clip) if (clip)
drawMask(g); drawMask(g.get());
} }
// Draw the cursor // Draw the cursor

View File

@ -29,7 +29,7 @@ EditorStatePtr EditorStatesHistory::top()
void EditorStatesHistory::push(const EditorStatePtr& state) void EditorStatesHistory::push(const EditorStatePtr& state)
{ {
ASSERT(state != NULL); ASSERT(state);
m_states.push_back(state); m_states.push_back(state);
} }

View File

@ -121,7 +121,7 @@ void MovingPixelsState::translate(const gfx::Point& delta)
EditorState::BeforeChangeAction MovingPixelsState::onBeforeChangeState(Editor* editor, EditorState* newState) EditorState::BeforeChangeAction MovingPixelsState::onBeforeChangeState(Editor* editor, EditorState* newState)
{ {
ASSERT(m_pixelsMovement != NULL); ASSERT(m_pixelsMovement);
ASSERT(editor == m_editor); ASSERT(editor == m_editor);
// If we are changing to another state, we've to drop the image. // If we are changing to another state, we've to drop the image.
@ -153,7 +153,7 @@ EditorState::BeforeChangeAction MovingPixelsState::onBeforeChangeState(Editor* e
void MovingPixelsState::onCurrentToolChange(Editor* editor) void MovingPixelsState::onCurrentToolChange(Editor* editor)
{ {
ASSERT(m_pixelsMovement != NULL); ASSERT(m_pixelsMovement);
ASSERT(editor == m_editor); ASSERT(editor == m_editor);
tools::Tool* current_tool = editor->getCurrentEditorTool(); tools::Tool* current_tool = editor->getCurrentEditorTool();
@ -170,7 +170,7 @@ void MovingPixelsState::onCurrentToolChange(Editor* editor)
bool MovingPixelsState::onMouseDown(Editor* editor, MouseMessage* msg) bool MovingPixelsState::onMouseDown(Editor* editor, MouseMessage* msg)
{ {
ASSERT(m_pixelsMovement != NULL); ASSERT(m_pixelsMovement);
ASSERT(editor == m_editor); ASSERT(editor == m_editor);
// Set this editor as the active one and setup the ContextBar for // Set this editor as the active one and setup the ContextBar for
@ -246,7 +246,7 @@ bool MovingPixelsState::onMouseDown(Editor* editor, MouseMessage* msg)
bool MovingPixelsState::onMouseUp(Editor* editor, MouseMessage* msg) bool MovingPixelsState::onMouseUp(Editor* editor, MouseMessage* msg)
{ {
ASSERT(m_pixelsMovement != NULL); ASSERT(m_pixelsMovement);
ASSERT(editor == m_editor); ASSERT(editor == m_editor);
// Drop the image temporarily in this location (where the user releases the mouse) // Drop the image temporarily in this location (where the user releases the mouse)
@ -261,7 +261,7 @@ bool MovingPixelsState::onMouseUp(Editor* editor, MouseMessage* msg)
bool MovingPixelsState::onMouseMove(Editor* editor, MouseMessage* msg) bool MovingPixelsState::onMouseMove(Editor* editor, MouseMessage* msg)
{ {
ASSERT(m_pixelsMovement != NULL); ASSERT(m_pixelsMovement);
ASSERT(editor == m_editor); ASSERT(editor == m_editor);
// If there is a button pressed // If there is a button pressed
@ -305,7 +305,7 @@ bool MovingPixelsState::onMouseMove(Editor* editor, MouseMessage* msg)
bool MovingPixelsState::onSetCursor(Editor* editor) bool MovingPixelsState::onSetCursor(Editor* editor)
{ {
ASSERT(m_pixelsMovement != NULL); ASSERT(m_pixelsMovement);
ASSERT(editor == m_editor); ASSERT(editor == m_editor);
// Move selection // Move selection
@ -321,7 +321,7 @@ bool MovingPixelsState::onSetCursor(Editor* editor)
bool MovingPixelsState::onKeyDown(Editor* editor, KeyMessage* msg) bool MovingPixelsState::onKeyDown(Editor* editor, KeyMessage* msg)
{ {
ASSERT(m_pixelsMovement != NULL); ASSERT(m_pixelsMovement);
if (!isActiveEditor()) if (!isActiveEditor())
return false; return false;
ASSERT(editor == m_editor); ASSERT(editor == m_editor);
@ -394,7 +394,7 @@ bool MovingPixelsState::onKeyDown(Editor* editor, KeyMessage* msg)
bool MovingPixelsState::onKeyUp(Editor* editor, KeyMessage* msg) bool MovingPixelsState::onKeyUp(Editor* editor, KeyMessage* msg)
{ {
ASSERT(m_pixelsMovement != NULL); ASSERT(m_pixelsMovement);
if (!isActiveEditor()) if (!isActiveEditor())
return false; return false;
ASSERT(editor == m_editor); ASSERT(editor == m_editor);
@ -405,7 +405,7 @@ bool MovingPixelsState::onKeyUp(Editor* editor, KeyMessage* msg)
bool MovingPixelsState::onUpdateStatusBar(Editor* editor) bool MovingPixelsState::onUpdateStatusBar(Editor* editor)
{ {
ASSERT(m_pixelsMovement != NULL); ASSERT(m_pixelsMovement);
ASSERT(editor == m_editor); ASSERT(editor == m_editor);
const gfx::Transformation& transform(getTransformation(editor)); const gfx::Transformation& transform(getTransformation(editor));
@ -501,10 +501,10 @@ void MovingPixelsState::onDropPixels(ContextBarObserver::DropAction action)
void MovingPixelsState::setTransparentColor(const app::Color& color) void MovingPixelsState::setTransparentColor(const app::Color& color)
{ {
ASSERT(m_pixelsMovement != NULL); ASSERT(m_pixelsMovement);
Layer* layer = m_editor->layer(); Layer* layer = m_editor->layer();
ASSERT(layer != NULL); ASSERT(layer);
m_pixelsMovement->setMaskColor( m_pixelsMovement->setMaskColor(
color_utils::color_for_target_mask(color, ColorTarget(layer))); color_utils::color_for_target_mask(color, ColorTarget(layer)));

View File

@ -454,7 +454,7 @@ void KeyboardShortcuts::importFile(TiXmlElement* rootElement, KeySource source)
void KeyboardShortcuts::importFile(const std::string& filename, KeySource source) void KeyboardShortcuts::importFile(const std::string& filename, KeySource source)
{ {
XmlDocumentRef doc = app::open_xml(filename); XmlDocumentRef doc = app::open_xml(filename);
TiXmlHandle handle(doc); TiXmlHandle handle(doc.get());
TiXmlElement* xmlKey = handle.FirstChild("keyboard").ToElement(); TiXmlElement* xmlKey = handle.FirstChild("keyboard").ToElement();
importFile(xmlKey, source); importFile(xmlKey, source);

View File

@ -254,7 +254,7 @@ void NewsListBox::parseFile(const std::string& filename)
return; return;
} }
TiXmlHandle handle(doc); TiXmlHandle handle(doc.get());
TiXmlElement* itemXml = handle TiXmlElement* itemXml = handle
.FirstChild("rss") .FirstChild("rss")
.FirstChild("channel") .FirstChild("channel")

View File

@ -37,7 +37,7 @@ SkinPropertyPtr get_skin_property(ui::Widget* widget)
SkinPropertyPtr skinProp; SkinPropertyPtr skinProp;
skinProp = widget->getProperty(SkinProperty::Name); skinProp = widget->getProperty(SkinProperty::Name);
if (skinProp == NULL) { if (!skinProp) {
skinProp.reset(new SkinProperty); skinProp.reset(new SkinProperty);
widget->setProperty(skinProp); widget->setProperty(skinProp);
} }

View File

@ -369,7 +369,7 @@ void SkinTheme::onRegenerate()
return; return;
XmlDocumentRef doc = open_xml(rf.filename()); XmlDocumentRef doc = open_xml(rf.filename());
TiXmlHandle handle(doc); TiXmlHandle handle(doc.get());
// Load dimension // Load dimension
{ {
@ -491,7 +491,7 @@ void SkinTheme::onRegenerate()
PRINTF("Loading part '%s'...\n", part_id); PRINTF("Loading part '%s'...\n", part_id);
SkinPartPtr part = m_parts_by_id[part_id]; SkinPartPtr part = m_parts_by_id[part_id];
if (part == NULL) if (!part)
part = m_parts_by_id[part_id] = SkinPartPtr(new SkinPart); part = m_parts_by_id[part_id] = SkinPartPtr(new SkinPart);
if (w > 0 && h > 0) { if (w > 0 && h > 0) {
@ -911,7 +911,7 @@ void SkinTheme::paintButton(PaintEvent& ev)
// Tool buttons are smaller // Tool buttons are smaller
LookType look = NormalLook; LookType look = NormalLook;
SkinPropertyPtr skinPropery = widget->getProperty(SkinProperty::Name); SkinPropertyPtr skinPropery = widget->getProperty(SkinProperty::Name);
if (skinPropery != NULL) if (skinPropery)
look = skinPropery->getLook(); look = skinPropery->getLook();
// Selected // Selected
@ -986,7 +986,7 @@ void SkinTheme::paintCheckBox(PaintEvent& ev)
// Check box look // Check box look
LookType look = NormalLook; LookType look = NormalLook;
SkinPropertyPtr skinPropery = widget->getProperty(SkinProperty::Name); SkinPropertyPtr skinPropery = widget->getProperty(SkinProperty::Name);
if (skinPropery != NULL) if (skinPropery)
look = skinPropery->getLook(); look = skinPropery->getLook();
// Background // Background
@ -1040,7 +1040,7 @@ void SkinTheme::paintEntry(PaintEvent& ev)
bool isMiniLook = false; bool isMiniLook = false;
SkinPropertyPtr skinPropery = widget->getProperty(SkinProperty::Name); SkinPropertyPtr skinPropery = widget->getProperty(SkinProperty::Name);
if (skinPropery != NULL) if (skinPropery)
isMiniLook = (skinPropery->getLook() == MiniLook); isMiniLook = (skinPropery->getLook() == MiniLook);
gfx::Color bg = colors.background(); gfx::Color bg = colors.background();
@ -1403,11 +1403,11 @@ void SkinTheme::paintSlider(PaintEvent& ev)
ISliderBgPainter* bgPainter = NULL; ISliderBgPainter* bgPainter = NULL;
SkinPropertyPtr skinPropery = widget->getProperty(SkinProperty::Name); SkinPropertyPtr skinPropery = widget->getProperty(SkinProperty::Name);
if (skinPropery != NULL) if (skinPropery)
isMiniLook = (skinPropery->getLook() == MiniLook); isMiniLook = (skinPropery->getLook() == MiniLook);
SkinSliderPropertyPtr skinSliderPropery = widget->getProperty(SkinSliderProperty::Name); SkinSliderPropertyPtr skinSliderPropery = widget->getProperty(SkinSliderProperty::Name);
if (skinSliderPropery != NULL) if (skinSliderPropery)
bgPainter = skinSliderPropery->getBgPainter(); bgPainter = skinSliderPropery->getBgPainter();
// Draw customized background // Draw customized background
@ -1649,7 +1649,7 @@ void SkinTheme::paintViewScrollbar(PaintEvent& ev)
bool isMiniLook = false; bool isMiniLook = false;
SkinPropertyPtr skinPropery = widget->getProperty(SkinProperty::Name); SkinPropertyPtr skinPropery = widget->getProperty(SkinProperty::Name);
if (skinPropery != NULL) if (skinPropery)
isMiniLook = (skinPropery->getLook() == MiniLook); isMiniLook = (skinPropery->getLook() == MiniLook);
skin::Style* bgStyle = (isMiniLook ? skin::Style* bgStyle = (isMiniLook ?

View File

@ -39,7 +39,7 @@ void BackgroundRule::onPaint(ui::Graphics* g, const gfx::Rect& bounds, const cha
{ {
SkinTheme* theme = static_cast<SkinTheme*>(ui::CurrentTheme::get()); SkinTheme* theme = static_cast<SkinTheme*>(ui::CurrentTheme::get());
if (m_part != NULL && m_part->size() > 0) { if (m_part && m_part->size() > 0) {
if (m_part->size() == 1) { if (m_part->size() == 1) {
if (!gfx::is_transparent(m_color)) if (!gfx::is_transparent(m_color))
g->fillRect(m_color, bounds); g->fillRect(m_color, bounds);

View File

@ -101,7 +101,7 @@ SkinPartPtr StyleSheet::convertPart(const css::Value& value)
if (value.type() == css::Value::String) { if (value.type() == css::Value::String) {
const std::string& part_id = value.string(); const std::string& part_id = value.string();
part = get_part_by_id(part_id); part = get_part_by_id(part_id);
if (part == NULL) if (!part)
throw base::Exception("Unknown part '%s'\n", part_id.c_str()); throw base::Exception("Unknown part '%s'\n", part_id.c_str());
} }
return part; return part;

View File

@ -71,7 +71,7 @@ Tabs::Tabs(TabsDelegate* delegate)
Tabs::~Tabs() Tabs::~Tabs()
{ {
m_removedTab.reset(nullptr); m_removedTab.reset();
// Stop animation // Stop animation
stopAnimation(); stopAnimation();
@ -104,7 +104,7 @@ void Tabs::removeTab(TabView* tabView, bool with_animation)
return; return;
if (m_hot == tab) if (m_hot == tab)
m_hot.reset(nullptr); m_hot.reset();
if (m_selected == tab) { if (m_selected == tab) {
if (tab == m_list.back()) if (tab == m_list.back())
@ -113,7 +113,7 @@ void Tabs::removeTab(TabView* tabView, bool with_animation)
selectNextTab(); selectNextTab();
if (m_selected == tab) if (m_selected == tab)
m_selected.reset(nullptr); m_selected.reset();
} }
TabsListIterator it = TabsListIterator it =
@ -335,7 +335,7 @@ bool Tabs::onProcessMessage(Message* msg)
case kMouseLeaveMessage: case kMouseLeaveMessage:
if (m_hot) { if (m_hot) {
m_hot.reset(nullptr); m_hot.reset();
invalidate(); invalidate();
} }
return true; return true;
@ -756,8 +756,8 @@ void Tabs::stopDrag(DropTabResult result)
case DropTabResult::DOCKED_IN_OTHER_PLACE: { case DropTabResult::DOCKED_IN_OTHER_PLACE: {
TabPtr tab = m_floatingTab; TabPtr tab = m_floatingTab;
m_floatingTab.reset(nullptr); m_floatingTab.reset();
m_removedTab.reset(nullptr); m_removedTab.reset();
destroyFloatingTab(); destroyFloatingTab();
//ASSERT(tab); // TODO check this state //ASSERT(tab); // TODO check this state
@ -823,7 +823,7 @@ void Tabs::createFloatingTab(TabPtr& tab)
resetOldPositions(); resetOldPositions();
m_floatingTab = tab; m_floatingTab = tab;
m_removedTab.reset(nullptr); m_removedTab.reset();
startAnimation(ANI_REMOVING_TAB, ANI_REMOVING_TAB_TICKS); startAnimation(ANI_REMOVING_TAB, ANI_REMOVING_TAB_TICKS);
updateTabs(); updateTabs();
} }
@ -832,12 +832,12 @@ void Tabs::destroyFloatingTab()
{ {
if (m_floatingOverlay) { if (m_floatingOverlay) {
OverlayManager::instance()->removeOverlay(m_floatingOverlay.get()); OverlayManager::instance()->removeOverlay(m_floatingOverlay.get());
m_floatingOverlay.reset(nullptr); m_floatingOverlay.reset();
} }
if (m_floatingTab) { if (m_floatingTab) {
TabPtr tab(m_floatingTab); TabPtr tab(m_floatingTab);
m_floatingTab.reset(nullptr); m_floatingTab.reset();
resetOldPositions(); resetOldPositions();
startAnimation(ANI_ADDING_TAB, ANI_ADDING_TAB_TICKS); startAnimation(ANI_ADDING_TAB, ANI_ADDING_TAB_TICKS);

View File

@ -164,7 +164,7 @@ void ExpandCelCanvas::commit()
// Copy the destination to the cel image. // Copy the destination to the cel image.
m_transaction.execute(new cmd::CopyRegion( m_transaction.execute(new cmd::CopyRegion(
m_celImage, m_dstImage, m_validDstRegion, dx, dy)); m_celImage.get(), m_dstImage, m_validDstRegion, dx, dy));
} }
// If the size of both images are different, we have to // If the size of both images are different, we have to
// replace the entire image. // replace the entire image.
@ -252,7 +252,7 @@ void ExpandCelCanvas::validateSourceCanvas(const gfx::Region& rgn)
fill_rect(m_srcImage, rc, m_srcImage->maskColor()); fill_rect(m_srcImage, rc, m_srcImage->maskColor());
for (const auto& rc : rgnToValidate) for (const auto& rc : rgnToValidate)
m_srcImage->copy(m_celImage, m_srcImage->copy(m_celImage.get(),
gfx::Clip(rc.x, rc.y, gfx::Clip(rc.x, rc.y,
rc.x+m_bounds.x-m_origCelPos.x, rc.x+m_bounds.x-m_origCelPos.x,
rc.y+m_bounds.y-m_origCelPos.y, rc.w, rc.h)); rc.y+m_bounds.y-m_origCelPos.y, rc.w, rc.h));
@ -276,7 +276,7 @@ void ExpandCelCanvas::validateDestCanvas(const gfx::Region& rgn)
src_y = m_bounds.y; src_y = m_bounds.y;
} }
else { else {
src = m_celImage; src = m_celImage.get();
src_x = m_origCelPos.x; src_x = m_origCelPos.x;
src_y = m_origCelPos.y; src_y = m_origCelPos.y;
} }

View File

@ -38,7 +38,8 @@ Image* load_pic_file(const char* filename, int* x, int* y, Palette** palette)
int byte; int byte;
int bpp; int bpp;
base::FileHandle f(base::open_file_with_exception(filename, "rb")); base::FileHandle handle(base::open_file_with_exception(filename, "rb"));
FILE* f = handle.get();
// Animator format? // Animator format?
magic = base::fgetw(f); magic = base::fgetw(f);
@ -83,8 +84,9 @@ Image* load_pic_file(const char* filename, int* x, int* y, Palette** palette)
} }
// rewind // rewind
f.reset(NULL); handle.reset();
f = base::open_file_with_exception(filename, "rb"); handle = base::open_file_with_exception(filename, "rb");
f = handle.get();
// read a PIC/MSK Animator Pro file // read a PIC/MSK Animator Pro file
size = base::fgetl(f); // file size size = base::fgetl(f); // file size
@ -172,7 +174,8 @@ int save_pic_file(const char *filename, int x, int y, const Palette* palette, co
if ((bpp == 8) && (!palette)) if ((bpp == 8) && (!palette))
return -1; return -1;
base::FileHandle f(base::open_file_with_exception(filename, "wb")); base::FileHandle handle(base::open_file_with_exception(filename, "wb"));
FILE* f = handle.get();
size = 64; size = 64;
// Bit-per-pixel image data block // Bit-per-pixel image data block

View File

@ -89,7 +89,7 @@ Widget* WidgetLoader::loadWidgetFromXmlFile(
m_tooltipManager = NULL; m_tooltipManager = NULL;
XmlDocumentRef doc(open_xml(xmlFilename)); XmlDocumentRef doc(open_xml(xmlFilename));
TiXmlHandle handle(doc); TiXmlHandle handle(doc.get());
// Search the requested widget. // Search the requested widget.
TiXmlElement* xmlElement = handle TiXmlElement* xmlElement = handle

View File

@ -29,8 +29,8 @@ XmlDocumentRef open_xml(const std::string& filename)
// Try to load the XML file // Try to load the XML file
XmlDocumentRef doc(new TiXmlDocument()); XmlDocumentRef doc(new TiXmlDocument());
doc->SetValue(filename.c_str()); doc->SetValue(filename.c_str());
if (!doc->LoadFile(file)) if (!doc->LoadFile(file.get()))
throw XmlException(doc); throw XmlException(doc.get());
return doc; return doc;
} }
@ -41,8 +41,8 @@ void save_xml(XmlDocumentRef doc, const std::string& filename)
if (!file) if (!file)
throw Exception("Error loading file: " + filename); throw Exception("Error loading file: " + filename);
if (!doc->SaveFile(file)) if (!doc->SaveFile(file.get()))
throw XmlException(doc); throw XmlException(doc.get());
} }
bool bool_attr_is_true(const TiXmlElement* elem, const char* attrName) bool bool_attr_is_true(const TiXmlElement* elem, const char* attrName)

View File

@ -1,5 +1,5 @@
// Aseprite Base Library // Aseprite Base Library
// Copyright (c) 2001-2013 David Capello // Copyright (c) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -211,7 +211,7 @@ public:
T* get() const { return m_ptr; } T* get() const { return m_ptr; }
T& operator*() const { return *m_ptr; } T& operator*() const { return *m_ptr; }
T* operator->() const { return m_ptr; } T* operator->() const { return m_ptr; }
operator T*() const { return m_ptr; } explicit operator bool() const { return (m_ptr != nullptr); }
long use_count() const { return (m_refCount ? m_refCount->use_count(): 0); } long use_count() const { return (m_refCount ? m_refCount->use_count(): 0); }
bool unique() const { return use_count() == 1; } bool unique() const { return use_count() == 1; }

View File

@ -22,7 +22,7 @@ namespace doc {
using namespace base::serialization; using namespace base::serialization;
using namespace base::serialization::little_endian; using namespace base::serialization::little_endian;
void write_celdata(std::ostream& os, CelData* celdata) void write_celdata(std::ostream& os, const CelData* celdata)
{ {
write32(os, celdata->id()); write32(os, celdata->id());
write16(os, (int16_t)celdata->position().x); write16(os, (int16_t)celdata->position().x);

View File

@ -15,7 +15,7 @@ namespace doc {
class CelData; class CelData;
class SubObjectsIO; class SubObjectsIO;
void write_celdata(std::ostream& os, CelData* cel); void write_celdata(std::ostream& os, const CelData* cel);
CelData* read_celdata(std::istream& is, SubObjectsIO* subObjects); CelData* read_celdata(std::istream& is, SubObjectsIO* subObjects);
} // namespace doc } // namespace doc

View File

@ -1,5 +1,5 @@
// Aseprite Document Library // Aseprite Document Library
// Copyright (c) 2001-2014 David Capello // Copyright (c) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -22,7 +22,7 @@ namespace doc {
using namespace base::serialization; using namespace base::serialization;
using namespace base::serialization::little_endian; using namespace base::serialization::little_endian;
void write_cel(std::ostream& os, Cel* cel) void write_cel(std::ostream& os, const Cel* cel)
{ {
write32(os, cel->id()); write32(os, cel->id());
write16(os, cel->frame()); write16(os, cel->frame());

View File

@ -1,5 +1,5 @@
// Aseprite Document Library // Aseprite Document Library
// Copyright (c) 2001-2014 David Capello // Copyright (c) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -15,7 +15,7 @@ namespace doc {
class Cel; class Cel;
class SubObjectsIO; class SubObjectsIO;
void write_cel(std::ostream& os, Cel* cel); void write_cel(std::ostream& os, const Cel* cel);
Cel* read_cel(std::istream& is, SubObjectsIO* subObjects); Cel* read_cel(std::istream& is, SubObjectsIO* subObjects);
} // namespace doc } // namespace doc

View File

@ -22,7 +22,7 @@ namespace doc {
using namespace base::serialization; using namespace base::serialization;
using namespace base::serialization::little_endian; using namespace base::serialization::little_endian;
void write_frame_tag(std::ostream& os, FrameTag* tag) void write_frame_tag(std::ostream& os, const FrameTag* tag)
{ {
std::string name = tag->name(); std::string name = tag->name();

View File

@ -14,7 +14,7 @@ namespace doc {
class FrameTag; class FrameTag;
void write_frame_tag(std::ostream& os, FrameTag* tag); void write_frame_tag(std::ostream& os, const FrameTag* tag);
FrameTag* read_frame_tag(std::istream& is); FrameTag* read_frame_tag(std::istream& is);
} // namespace doc } // namespace doc

View File

@ -1,5 +1,5 @@
// Aseprite Document Library // Aseprite Document Library
// Copyright (c) 2001-2014 David Capello // Copyright (c) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -33,7 +33,7 @@ using namespace base::serialization::little_endian;
// BYTE[2] for Grayscale images, or // BYTE[2] for Grayscale images, or
// BYTE for Indexed images // BYTE for Indexed images
void write_image(std::ostream& os, Image* image) void write_image(std::ostream& os, const Image* image)
{ {
write32(os, image->id()); write32(os, image->id());
write8(os, image->pixelFormat()); // Pixel format write8(os, image->pixelFormat()); // Pixel format

View File

@ -1,5 +1,5 @@
// Aseprite Document Library // Aseprite Document Library
// Copyright (c) 2001-2014 David Capello // Copyright (c) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -14,7 +14,7 @@ namespace doc {
class Image; class Image;
void write_image(std::ostream& os, Image* image); void write_image(std::ostream& os, const Image* image);
Image* read_image(std::istream& is); Image* read_image(std::istream& is);
} // namespace doc } // namespace doc

View File

@ -33,7 +33,7 @@ using namespace base::serialization::little_endian;
// Serialized Layer data: // Serialized Layer data:
void write_layer(std::ostream& os, Layer* layer) void write_layer(std::ostream& os, const Layer* layer)
{ {
std::string name = layer->name(); std::string name = layer->name();
@ -46,8 +46,8 @@ void write_layer(std::ostream& os, Layer* layer)
switch (layer->type()) { switch (layer->type()) {
case ObjectType::LayerImage: { case ObjectType::LayerImage: {
CelIterator it, begin = static_cast<LayerImage*>(layer)->getCelBegin(); CelConstIterator it, begin = static_cast<const LayerImage*>(layer)->getCelBegin();
CelIterator end = static_cast<LayerImage*>(layer)->getCelEnd(); CelConstIterator end = static_cast<const LayerImage*>(layer)->getCelEnd();
// Images // Images
int images = 0; int images = 0;
@ -71,24 +71,24 @@ void write_layer(std::ostream& os, Layer* layer)
for (it=begin; it != end; ++it) { for (it=begin; it != end; ++it) {
Cel* cel = *it; Cel* cel = *it;
if (!cel->link()) if (!cel->link())
write_celdata(os, cel->dataRef()); write_celdata(os, cel->dataRef().get());
} }
// Cels // Cels
write16(os, static_cast<LayerImage*>(layer)->getCelsCount()); write16(os, static_cast<const LayerImage*>(layer)->getCelsCount());
for (it=begin; it != end; ++it) { for (it=begin; it != end; ++it) {
Cel* cel = *it; const Cel* cel = *it;
write_cel(os, cel); write_cel(os, cel);
} }
break; break;
} }
case ObjectType::LayerFolder: { case ObjectType::LayerFolder: {
LayerIterator it = static_cast<LayerFolder*>(layer)->getLayerBegin(); LayerConstIterator it = static_cast<const LayerFolder*>(layer)->getLayerBegin();
LayerIterator end = static_cast<LayerFolder*>(layer)->getLayerEnd(); LayerConstIterator end = static_cast<const LayerFolder*>(layer)->getLayerEnd();
// Number of sub-layers // Number of sub-layers
write16(os, static_cast<LayerFolder*>(layer)->getLayersCount()); write16(os, static_cast<const LayerFolder*>(layer)->getLayersCount());
for (; it != end; ++it) for (; it != end; ++it)
write_layer(os, *it); write_layer(os, *it);

View File

@ -1,5 +1,5 @@
// Aseprite Document Library // Aseprite Document Library
// Copyright (c) 2001-2014 David Capello // Copyright (c) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -22,7 +22,7 @@ namespace doc {
InvalidLayerType(const char* msg) throw() : base::Exception(msg) { } InvalidLayerType(const char* msg) throw() : base::Exception(msg) { }
}; };
void write_layer(std::ostream& os, Layer* layer); void write_layer(std::ostream& os, const Layer* layer);
Layer* read_layer(std::istream& is, SubObjectsIO* subObjects); Layer* read_layer(std::istream& is, SubObjectsIO* subObjects);
} // namespace doc } // namespace doc

View File

@ -74,7 +74,7 @@ bool Mask::isRectangular() const
if (!m_bitmap) if (!m_bitmap)
return false; return false;
LockImageBits<BitmapTraits> bits(m_bitmap); LockImageBits<BitmapTraits> bits(m_bitmap.get());
LockImageBits<BitmapTraits>::iterator it = bits.begin(), end = bits.end(); LockImageBits<BitmapTraits>::iterator it = bits.begin(), end = bits.end();
for (; it != end; ++it) { for (; it != end; ++it) {
@ -95,7 +95,7 @@ void Mask::copyFrom(const Mask* sourceMask)
add(sourceMask->bounds()); add(sourceMask->bounds());
// And copy the "mask" bitmap // And copy the "mask" bitmap
copy_image(m_bitmap, sourceMask->m_bitmap); copy_image(m_bitmap.get(), sourceMask->m_bitmap.get());
} }
} }
@ -106,7 +106,7 @@ void Mask::offsetOrigin(int dx, int dy)
void Mask::clear() void Mask::clear()
{ {
m_bitmap.reset(nullptr); m_bitmap.reset();
m_bounds = gfx::Rect(0, 0, 0, 0); m_bounds = gfx::Rect(0, 0, 0, 0);
} }
@ -115,7 +115,7 @@ void Mask::invert()
if (!m_bitmap) if (!m_bitmap)
return; return;
LockImageBits<BitmapTraits> bits(m_bitmap); LockImageBits<BitmapTraits> bits(m_bitmap.get());
LockImageBits<BitmapTraits>::iterator it = bits.begin(), end = bits.end(); LockImageBits<BitmapTraits>::iterator it = bits.begin(), end = bits.end();
for (; it != end; ++it) for (; it != end; ++it)
@ -129,7 +129,7 @@ void Mask::replace(const gfx::Rect& bounds)
m_bounds = bounds; m_bounds = bounds;
m_bitmap.reset(Image::create(IMAGE_BITMAP, bounds.w, bounds.h, m_buffer)); m_bitmap.reset(Image::create(IMAGE_BITMAP, bounds.w, bounds.h, m_buffer));
clear_image(m_bitmap, 1); clear_image(m_bitmap.get(), 1);
} }
void Mask::add(const gfx::Rect& bounds) void Mask::add(const gfx::Rect& bounds)
@ -137,7 +137,7 @@ void Mask::add(const gfx::Rect& bounds)
if (m_freeze_count == 0) if (m_freeze_count == 0)
reserve(bounds); reserve(bounds);
fill_rect(m_bitmap, fill_rect(m_bitmap.get(),
bounds.x-m_bounds.x, bounds.x-m_bounds.x,
bounds.y-m_bounds.y, bounds.y-m_bounds.y,
bounds.x-m_bounds.x+bounds.w-1, bounds.x-m_bounds.x+bounds.w-1,
@ -149,7 +149,7 @@ void Mask::subtract(const gfx::Rect& bounds)
if (!m_bitmap) if (!m_bitmap)
return; return;
fill_rect(m_bitmap, fill_rect(m_bitmap.get(),
bounds.x-m_bounds.x, bounds.x-m_bounds.x,
bounds.y-m_bounds.y, bounds.y-m_bounds.y,
bounds.x-m_bounds.x+bounds.w-1, bounds.x-m_bounds.x+bounds.w-1,
@ -168,7 +168,7 @@ void Mask::intersect(const gfx::Rect& bounds)
Image* image = NULL; Image* image = NULL;
if (!newBounds.isEmpty()) { if (!newBounds.isEmpty()) {
image = crop_image(m_bitmap, image = crop_image(m_bitmap.get(),
newBounds.x-m_bounds.x, newBounds.x-m_bounds.x,
newBounds.y-m_bounds.y, newBounds.y-m_bounds.y,
newBounds.w, newBounds.w,
@ -185,7 +185,7 @@ void Mask::byColor(const Image *src, int color, int fuzziness)
{ {
replace(src->bounds()); replace(src->bounds());
Image* dst = m_bitmap; Image* dst = m_bitmap.get();
switch (src->pixelFormat()) { switch (src->pixelFormat()) {
@ -358,13 +358,13 @@ void Mask::reserve(const gfx::Rect& bounds)
if (!m_bitmap) { if (!m_bitmap) {
m_bounds = bounds; m_bounds = bounds;
m_bitmap.reset(Image::create(IMAGE_BITMAP, bounds.w, bounds.h, m_buffer)); m_bitmap.reset(Image::create(IMAGE_BITMAP, bounds.w, bounds.h, m_buffer));
clear_image(m_bitmap, 0); clear_image(m_bitmap.get(), 0);
} }
else { else {
gfx::Rect newBounds = m_bounds.createUnion(bounds); gfx::Rect newBounds = m_bounds.createUnion(bounds);
if (m_bounds != newBounds) { if (m_bounds != newBounds) {
Image* image = crop_image(m_bitmap, Image* image = crop_image(m_bitmap.get(),
newBounds.x-m_bounds.x, newBounds.x-m_bounds.x,
newBounds.y-m_bounds.y, newBounds.y-m_bounds.y,
newBounds.w, newBounds.w,
@ -428,7 +428,7 @@ void Mask::shrink()
m_bounds.w = x2 - x1 + 1; m_bounds.w = x2 - x1 + 1;
m_bounds.h = y2 - y1 + 1; m_bounds.h = y2 - y1 + 1;
Image* image = crop_image(m_bitmap, m_bounds.x-u, m_bounds.y-v, m_bounds.w, m_bounds.h, 0); Image* image = crop_image(m_bitmap.get(), m_bounds.x-u, m_bounds.y-v, m_bounds.w, m_bounds.h, 0);
m_bitmap.reset(image); m_bitmap.reset(image);
} }

View File

@ -31,8 +31,8 @@ namespace doc {
void setName(const char *name); void setName(const char *name);
const std::string& name() const { return m_name; } const std::string& name() const { return m_name; }
const Image* bitmap() const { return m_bitmap; } const Image* bitmap() const { return m_bitmap.get(); }
Image* bitmap() { return m_bitmap; } Image* bitmap() { return m_bitmap.get(); }
// Returns true if the mask is completely empty (i.e. nothing // Returns true if the mask is completely empty (i.e. nothing
// selected) // selected)
@ -42,10 +42,10 @@ namespace doc {
// Returns true if the point is inside the mask // Returns true if the point is inside the mask
bool containsPoint(int u, int v) const { bool containsPoint(int u, int v) const {
return (m_bitmap && return (m_bitmap.get() &&
u >= m_bounds.x && u < m_bounds.x+m_bounds.w && u >= m_bounds.x && u < m_bounds.x+m_bounds.w &&
v >= m_bounds.y && v < m_bounds.y+m_bounds.h && v >= m_bounds.y && v < m_bounds.y+m_bounds.h &&
get_pixel(m_bitmap, u-m_bounds.x, v-m_bounds.y)); get_pixel(m_bitmap.get(), u-m_bounds.x, v-m_bounds.y));
} }
const gfx::Rect& bounds() const { return m_bounds; } const gfx::Rect& bounds() const { return m_bounds; }

View File

@ -1,5 +1,5 @@
// Aseprite Document Library // Aseprite Document Library
// Copyright (c) 2001-2014 David Capello // Copyright (c) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -29,7 +29,7 @@ using namespace base::serialization::little_endian;
// BYTE 8 pixels of the mask // BYTE 8 pixels of the mask
// BYTE for Indexed images // BYTE for Indexed images
void write_mask(std::ostream& os, Mask* mask) void write_mask(std::ostream& os, const Mask* mask)
{ {
const gfx::Rect& bounds = mask->bounds(); const gfx::Rect& bounds = mask->bounds();

View File

@ -1,5 +1,5 @@
// Aseprite Document Library // Aseprite Document Library
// Copyright (c) 2001-2014 David Capello // Copyright (c) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -14,7 +14,7 @@ namespace doc {
class Mask; class Mask;
void write_mask(std::ostream& os, Mask* mask); void write_mask(std::ostream& os, const Mask* mask);
Mask* read_mask(std::istream& is); Mask* read_mask(std::istream& is);
} // namespace doc } // namespace doc

View File

@ -1,5 +1,5 @@
// Aseprite Document Library // Aseprite Document Library
// Copyright (c) 2001-2014 David Capello // Copyright (c) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -28,7 +28,7 @@ using namespace base::serialization::little_endian;
// for each color ("ncolors" times) // for each color ("ncolors" times)
// DWORD _rgba color // DWORD _rgba color
void write_palette(std::ostream& os, Palette* palette) void write_palette(std::ostream& os, const Palette* palette)
{ {
write16(os, palette->frame()); // Frame write16(os, palette->frame()); // Frame
write16(os, palette->size()); // Number of colors write16(os, palette->size()); // Number of colors

View File

@ -1,5 +1,5 @@
// Aseprite Document Library // Aseprite Document Library
// Copyright (c) 2001-2014 David Capello // Copyright (c) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -14,7 +14,7 @@ namespace doc {
class Palette; class Palette;
void write_palette(std::ostream& os, Palette* palette); void write_palette(std::ostream& os, const Palette* palette);
Palette* read_palette(std::istream& is); Palette* read_palette(std::istream& is);
} // namespace doc } // namespace doc

View File

@ -105,7 +105,7 @@ Sprite* Sprite::createBasicSprite(doc::PixelFormat format, int width, int height
// Create the main image. // Create the main image.
doc::ImageRef image(doc::Image::create(format, width, height)); doc::ImageRef image(doc::Image::create(format, width, height));
doc::clear_image(image, 0); doc::clear_image(image.get(), 0);
// Create the first transparent layer. // Create the first transparent layer.
{ {

View File

@ -155,7 +155,7 @@ void ConvolutionMatrixFilter::applyToRgba(FilterManager* filterMgr)
continue; continue;
} }
delegate.reset(m_matrix); delegate.reset(m_matrix.get());
get_neighboring_pixels<RgbTraits>(src, x, y, get_neighboring_pixels<RgbTraits>(src, x, y,
m_matrix->getWidth(), m_matrix->getWidth(),
m_matrix->getHeight(), m_matrix->getHeight(),
@ -222,7 +222,7 @@ void ConvolutionMatrixFilter::applyToGrayscale(FilterManager* filterMgr)
continue; continue;
} }
delegate.reset(m_matrix); delegate.reset(m_matrix.get());
get_neighboring_pixels<GrayscaleTraits>(src, x, y, get_neighboring_pixels<GrayscaleTraits>(src, x, y,
m_matrix->getWidth(), m_matrix->getWidth(),
m_matrix->getHeight(), m_matrix->getHeight(),
@ -277,7 +277,7 @@ void ConvolutionMatrixFilter::applyToIndexed(FilterManager* filterMgr)
continue; continue;
} }
delegate.reset(m_matrix); delegate.reset(m_matrix.get());
get_neighboring_pixels<IndexedTraits>(src, x, y, get_neighboring_pixels<IndexedTraits>(src, x, y,
m_matrix->getWidth(), m_matrix->getWidth(),
m_matrix->getHeight(), m_matrix->getHeight(),

View File

@ -35,7 +35,7 @@ static void run(int argc, const char* argv[])
base::FileHandle inputFile(base::open_file(inputFilename, "rb")); base::FileHandle inputFile(base::open_file(inputFilename, "rb"));
doc = new TiXmlDocument(); doc = new TiXmlDocument();
doc->SetValue(inputFilename.c_str()); doc->SetValue(inputFilename.c_str());
if (!doc->LoadFile(inputFile)) if (!doc->LoadFile(inputFile.get()))
throw std::runtime_error("invalid input file"); throw std::runtime_error("invalid input file");
} }

View File

@ -1,5 +1,5 @@
// Aseprite Render Library // Aseprite Render Library
// Copyright (c) 2001-2014 David Capello // Copyright (c) 2001-2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -61,7 +61,7 @@ Palette* create_palette_from_rgb(
ImageRef flat_image(Image::create(sprite->pixelFormat(), ImageRef flat_image(Image::create(sprite->pixelFormat(),
sprite->width(), sprite->height())); sprite->width(), sprite->height()));
render::Render().renderSprite(flat_image, sprite, frameNumber); render::Render().renderSprite(flat_image.get(), sprite, frameNumber);
// Create an array of images // Create an array of images
std::vector<Image*> image_array; std::vector<Image*> image_array;
@ -76,7 +76,7 @@ Palette* create_palette_from_rgb(
image_array.push_back(image); image_array.push_back(image);
} }
} }
image_array.push_back(flat_image); image_array.push_back(flat_image.get());
// Generate an optimized palette for all images // Generate an optimized palette for all images
create_palette_from_images(image_array, palette, has_background_layer); create_palette_from_images(image_array, palette, has_background_layer);

View File

@ -1326,7 +1326,7 @@ bool Widget::onProcessMessage(Message* msg)
ASSERT(ptmsg->rect().h > 0); ASSERT(ptmsg->rect().h > 0);
GraphicsPtr graphics = getGraphics(toClient(ptmsg->rect())); GraphicsPtr graphics = getGraphics(toClient(ptmsg->rect()));
return paintEvent(graphics); return paintEvent(graphics.get());
} }
case kKeyDownMessage: case kKeyDownMessage: