Remove thumbnails generation code

At the moment we'll keep the timeline simple (without thumbnails).
This commit is contained in:
David Capello 2013-11-10 23:11:59 -03:00
parent d39feb063c
commit 055907d008
4 changed files with 4 additions and 275 deletions

View File

@ -226,7 +226,6 @@ add_library(app-library
util/msk_file.cpp
util/pic_file.cpp
util/render.cpp
util/thmbnail.cpp
webserver.cpp
widget_loader.cpp
xml_document.cpp

View File

@ -41,7 +41,6 @@
#include "app/ui_context.h"
#include "app/undo_transaction.h"
#include "app/util/celmove.h"
#include "app/util/thmbnail.h"
#include "base/compiler_specific.h"
#include "base/memory.h"
#include "gfx/point.h"
@ -510,7 +509,6 @@ bool Timeline::onProcessMessage(Message* msg)
gfx::Point mousePos = mouseMsg->position();
popup_menu->showPopup(mousePos.x, mousePos.y);
destroy_thumbnails();
invalidate();
}
}
@ -552,7 +550,6 @@ bool Timeline::onProcessMessage(Message* msg)
gfx::Point mousePos = mouseMsg->position();
popup_menu->showPopup(mousePos.x, mousePos.y);
destroy_thumbnails();
invalidate();
regenerateLayers();
}
@ -636,7 +633,6 @@ bool Timeline::onProcessMessage(Message* msg)
gfx::Point mousePos = mouseMsg->position();
popup_menu->showPopup(mousePos.x, mousePos.y);
destroy_thumbnails();
regenerateLayers();
invalidate();
}
@ -650,7 +646,6 @@ bool Timeline::onProcessMessage(Message* msg)
move_cel(writer);
}
destroy_thumbnails();
regenerateLayers();
invalidate();
}
@ -1133,7 +1128,6 @@ void Timeline::drawCel(const gfx::Rect& clip, int layer_index, FrameNumber frame
ui::Color bg = theme->getColor(is_hot ? ThemeColor::HotFace: ThemeColor::Face);
int x1, y1, x2, y2;
int cx1, cy1, cx2, cy2;
BITMAP *thumbnail;
get_clip_rect(ji_screen, &cx1, &cy1, &cx2, &cy2);
@ -1150,7 +1144,7 @@ void Timeline::drawCel(const gfx::Rect& clip, int layer_index, FrameNumber frame
getBounds().x2()-1,
getBounds().y2()-1);
Rect thumbnail_rect(Point(x1+3, y1+3), Point(x2-2, y2-2));
Rect cel_rect(Point(x1+3, y1+3), Point(x2-2, y2-2));
// Draw the box for the cel.
if (selected_layer && frame == m_frame) {
@ -1168,17 +1162,11 @@ void Timeline::drawCel(const gfx::Rect& clip, int layer_index, FrameNumber frame
// TODO why a cel can't have an associated image?
m_sprite->getStock()->getImage(cel->getImage()) == NULL) {
jdraw_rectfill(thumbnail_rect, bg);
draw_emptyset_symbol(ji_screen, thumbnail_rect, theme->getColor(ThemeColor::Disabled));
jdraw_rectfill(cel_rect, bg);
draw_emptyset_symbol(ji_screen, cel_rect, theme->getColor(ThemeColor::Disabled));
}
else {
thumbnail = generate_thumbnail(layer, cel, m_sprite);
if (thumbnail != NULL) {
stretch_blit(thumbnail, ji_screen,
0, 0, thumbnail->w, thumbnail->h,
thumbnail_rect.x, thumbnail_rect.y,
thumbnail_rect.w, thumbnail_rect.h);
}
jdraw_rectfill(cel_rect, theme->getColor(ThemeColor::Text));
}
// If this cel is hot and other cel was clicked, we have to draw

View File

@ -1,220 +0,0 @@
/* Aseprite
* Copyright (C) 2001-2013 David Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <allegro/color.h>
#include <allegro/draw.h>
#include <allegro/gfx.h>
#include "app/modules/gfx.h"
#include "app/util/thmbnail.h"
#include "raster/blend.h"
#include "raster/cel.h"
#include "raster/image.h"
#include "raster/layer.h"
#include "raster/palette.h"
#include "raster/primitives.h"
#include "raster/sprite.h"
#include "raster/stock.h"
#define THUMBNAIL_W 32
#define THUMBNAIL_H 32
namespace app {
struct Thumbnail {
const Cel *cel;
BITMAP* bmp;
Thumbnail(const Cel *cel, BITMAP* bmp)
: cel(cel), bmp(bmp) {
}
~Thumbnail() {
destroy_bitmap(bmp);
}
};
typedef std::vector<Thumbnail*> ThumbnailsList;
static ThumbnailsList* thumbnails = NULL;
static void thumbnail_render(BITMAP* bmp, const Image* image, bool has_alpha, const Palette* palette);
void destroy_thumbnails()
{
if (thumbnails) {
for (ThumbnailsList::iterator it = thumbnails->begin(); it != thumbnails->end(); ++it)
delete *it;
thumbnails->clear();
delete thumbnails;
thumbnails = NULL;
}
}
BITMAP* generate_thumbnail(const Layer* layer, const Cel* cel, const Sprite *sprite)
{
Thumbnail* thumbnail;
BITMAP* bmp;
if (!thumbnails)
thumbnails = new ThumbnailsList();
// Find the thumbnail
for (ThumbnailsList::iterator it = thumbnails->begin(); it != thumbnails->end(); ++it) {
thumbnail = *it;
if (thumbnail->cel == cel)
return thumbnail->bmp;
}
bmp = create_bitmap(THUMBNAIL_W, THUMBNAIL_H);
if (!bmp)
return NULL;
thumbnail_render(bmp,
sprite->getStock()->getImage(cel->getImage()),
!layer->isBackground(),
sprite->getPalette(cel->getFrame()));
thumbnail = new Thumbnail(cel, bmp);
if (!thumbnail) {
destroy_bitmap(bmp);
return NULL;
}
thumbnails->push_back(thumbnail);
return thumbnail->bmp;
}
static void thumbnail_render(BITMAP* bmp, const Image* image, bool has_alpha, const Palette* palette)
{
register int c, x, y;
int w, h, x1, y1;
double sx, sy, scale;
ASSERT(image != NULL);
sx = (double)image->getWidth() / (double)bmp->w;
sy = (double)image->getHeight() / (double)bmp->h;
scale = MAX(sx, sy);
w = image->getWidth() / scale;
h = image->getHeight() / scale;
w = MIN(bmp->w, w);
h = MIN(bmp->h, h);
x1 = bmp->w/2 - w/2;
y1 = bmp->h/2 - h/2;
x1 = MAX(0, x1);
y1 = MAX(0, y1);
/* with alpha blending */
if (has_alpha) {
register int c2;
rectgrid(bmp, 0, 0, bmp->w-1, bmp->h-1,
bmp->w/4, bmp->h/4);
switch (image->getPixelFormat()) {
case IMAGE_RGB:
for (y=0; y<h; y++)
for (x=0; x<w; x++) {
c = get_pixel(image, x*scale, y*scale);
c2 = getpixel(bmp, x1+x, y1+y);
c = rgba_blend_normal(rgba(getr(c2), getg(c2), getb(c2), 255), c, 255);
putpixel(bmp, x1+x, y1+y, makecol(rgba_getr(c),
rgba_getg(c),
rgba_getb(c)));
}
break;
case IMAGE_GRAYSCALE:
for (y=0; y<h; y++)
for (x=0; x<w; x++) {
c = get_pixel(image, x*scale, y*scale);
c2 = getpixel(bmp, x1+x, y1+y);
c = graya_blend_normal(graya(getr(c2), 255), c, 255);
putpixel(bmp, x1+x, y1+y, makecol(graya_getv(c),
graya_getv(c),
graya_getv(c)));
}
break;
case IMAGE_INDEXED: {
for (y=0; y<h; y++)
for (x=0; x<w; x++) {
c = get_pixel(image, x*scale, y*scale);
if (c != 0) {
ASSERT(c >= 0 && c < palette->size());
c = palette->getEntry(MID(0, c, palette->size()-1));
putpixel(bmp, x1+x, y1+y, makecol(rgba_getr(c),
rgba_getg(c),
rgba_getb(c)));
}
}
break;
}
}
}
/* without alpha blending */
else {
clear_to_color(bmp, makecol(128, 128, 128));
switch (image->getPixelFormat()) {
case IMAGE_RGB:
for (y=0; y<h; y++)
for (x=0; x<w; x++) {
c = get_pixel(image, x*scale, y*scale);
putpixel(bmp, x1+x, y1+y, makecol(rgba_getr(c),
rgba_getg(c),
rgba_getb(c)));
}
break;
case IMAGE_GRAYSCALE:
for (y=0; y<h; y++)
for (x=0; x<w; x++) {
c = get_pixel(image, x*scale, y*scale);
putpixel(bmp, x1+x, y1+y, makecol(graya_getv(c),
graya_getv(c),
graya_getv(c)));
}
break;
case IMAGE_INDEXED: {
for (y=0; y<h; y++)
for (x=0; x<w; x++) {
c = get_pixel(image, x*scale, y*scale);
ASSERT(c >= 0 && c < palette->size());
c = palette->getEntry(MID(0, c, palette->size()-1));
putpixel(bmp, x1+x, y1+y, makecol(rgba_getr(c),
rgba_getg(c),
rgba_getb(c)));
}
break;
}
}
}
}
} // namespace app

View File

@ -1,38 +0,0 @@
/* Aseprite
* Copyright (C) 2001-2013 David Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef APP_UTIL_THMBNAIL_H_INCLUDED
#define APP_UTIL_THMBNAIL_H_INCLUDED
struct BITMAP;
namespace raster {
class Cel;
class Layer;
class Sprite;
}
namespace app {
using namespace raster;
void destroy_thumbnails();
BITMAP* generate_thumbnail(const Layer* layer, const Cel* cel, const Sprite* sprite);
} // namespace app
#endif