2008-08-02 18:31:32 +04:00
|
|
|
/*
|
2009-03-08 20:41:24 +03:00
|
|
|
* Copyright 2008,2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
2008-08-02 18:31:32 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf 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; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2011-01-07 02:34:56 +03:00
|
|
|
#include "amiga/os3support.h"
|
2008-08-02 18:31:32 +04:00
|
|
|
#include "desktop/browser.h"
|
2011-02-20 21:06:56 +03:00
|
|
|
#include "amiga/gui.h"
|
|
|
|
#include "amiga/bitmap.h"
|
2012-03-22 13:34:34 +04:00
|
|
|
#include "desktop/options.h"
|
2011-02-20 21:06:56 +03:00
|
|
|
#include "content/urldb.h"
|
|
|
|
#include "desktop/plotters.h"
|
|
|
|
#include "desktop/thumbnail.h"
|
|
|
|
|
2009-03-08 20:41:24 +03:00
|
|
|
#include <proto/graphics.h>
|
|
|
|
#include <proto/Picasso96API.h>
|
|
|
|
#include <intuition/intuition.h>
|
2011-01-07 02:17:17 +03:00
|
|
|
#ifdef __amigaos4__
|
2009-03-08 20:41:24 +03:00
|
|
|
#include <graphics/blitattr.h>
|
|
|
|
#include <graphics/composite.h>
|
2011-01-07 02:17:17 +03:00
|
|
|
#endif
|
2011-01-07 02:34:56 +03:00
|
|
|
#include <graphics/gfxbase.h>
|
2011-02-20 21:06:56 +03:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
2008-08-02 18:31:32 +04:00
|
|
|
|
2010-03-28 19:51:05 +04:00
|
|
|
bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap,
|
2008-08-02 18:31:32 +04:00
|
|
|
const char *url)
|
|
|
|
{
|
2009-03-08 20:41:24 +03:00
|
|
|
struct BitScaleArgs bsa;
|
2011-02-20 20:11:07 +03:00
|
|
|
int plot_width;
|
|
|
|
int plot_height;
|
2012-03-22 13:34:34 +04:00
|
|
|
int redraw_tile_size = nsoption_int(redraw_tile_size_x);
|
2011-06-30 19:48:07 +04:00
|
|
|
struct redraw_context ctx = {
|
|
|
|
.interactive = false,
|
2011-12-24 02:39:25 +04:00
|
|
|
.background_images = true,
|
2011-06-30 19:48:07 +04:00
|
|
|
.plot = &amiplot
|
|
|
|
};
|
2011-02-14 01:25:11 +03:00
|
|
|
|
2012-03-22 13:34:34 +04:00
|
|
|
if(nsoption_int(redraw_tile_size_y) < nsoption_int(redraw_tile_size_x))
|
|
|
|
redraw_tile_size = nsoption_int(redraw_tile_size_y);
|
2012-02-29 23:09:55 +04:00
|
|
|
|
|
|
|
plot_width = MIN(content_get_width(content), redraw_tile_size);
|
2011-02-20 20:11:07 +03:00
|
|
|
plot_height = ((plot_width * bitmap->height) + (bitmap->width / 2)) /
|
|
|
|
bitmap->width;
|
2009-03-08 20:41:24 +03:00
|
|
|
|
2009-07-07 23:28:34 +04:00
|
|
|
bitmap->nativebm = p96AllocBitMap(bitmap->width, bitmap->height, 32,
|
|
|
|
BMF_CLEAR | BMF_DISPLAYABLE | BMF_INTERLEAVED,
|
|
|
|
browserglob.bm, RGBFB_A8R8G8B8);
|
2009-03-08 20:41:24 +03:00
|
|
|
|
|
|
|
bitmap->nativebmwidth = bitmap->width;
|
|
|
|
bitmap->nativebmheight = bitmap->height;
|
2009-08-23 19:59:41 +04:00
|
|
|
ami_clearclipreg(&browserglob);
|
2011-02-20 20:11:07 +03:00
|
|
|
|
2011-06-30 19:48:07 +04:00
|
|
|
thumbnail_redraw(content, plot_width, plot_height, &ctx);
|
2011-02-20 20:11:07 +03:00
|
|
|
|
2011-01-07 02:34:56 +03:00
|
|
|
if(GfxBase->LibNode.lib_Version >= 53) // AutoDoc says v52, but this function isn't in OS4.0, so checking for v53 (OS4.1)
|
2009-03-08 20:41:24 +03:00
|
|
|
{
|
2011-02-20 20:11:07 +03:00
|
|
|
float resample_scale = bitmap->width / (float)plot_width;
|
2009-07-04 23:10:33 +04:00
|
|
|
uint32 flags = COMPFLAG_IgnoreDestAlpha | COMPFLAG_SrcAlphaOverride;
|
2012-03-22 13:34:34 +04:00
|
|
|
if(nsoption_bool(scale_quality)) flags |= COMPFLAG_SrcFilter;
|
2009-07-04 23:10:33 +04:00
|
|
|
|
2009-07-07 23:28:34 +04:00
|
|
|
CompositeTags(COMPOSITE_Src,browserglob.bm,bitmap->nativebm,
|
2011-02-20 20:11:07 +03:00
|
|
|
COMPTAG_ScaleX,
|
|
|
|
COMP_FLOAT_TO_FIX(resample_scale),
|
|
|
|
COMPTAG_ScaleY,
|
|
|
|
COMP_FLOAT_TO_FIX(resample_scale),
|
2009-07-04 23:10:33 +04:00
|
|
|
COMPTAG_Flags,flags,
|
2009-03-08 20:41:24 +03:00
|
|
|
COMPTAG_DestX,0,
|
|
|
|
COMPTAG_DestY,0,
|
|
|
|
COMPTAG_DestWidth,bitmap->width,
|
|
|
|
COMPTAG_DestHeight,bitmap->height,
|
|
|
|
COMPTAG_OffsetX,0,
|
|
|
|
COMPTAG_OffsetY,0,
|
|
|
|
TAG_DONE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bsa.bsa_SrcX = 0;
|
|
|
|
bsa.bsa_SrcY = 0;
|
2011-02-20 20:11:07 +03:00
|
|
|
bsa.bsa_SrcWidth = plot_width;
|
|
|
|
bsa.bsa_SrcHeight = plot_height;
|
2009-03-08 20:41:24 +03:00
|
|
|
bsa.bsa_DestX = 0;
|
|
|
|
bsa.bsa_DestY = 0;
|
|
|
|
// bsa.bsa_DestWidth = width;
|
|
|
|
// bsa.bsa_DestHeight = height;
|
2011-02-20 20:11:07 +03:00
|
|
|
bsa.bsa_XSrcFactor = plot_width;
|
2009-03-08 20:41:24 +03:00
|
|
|
bsa.bsa_XDestFactor = bitmap->width;
|
2011-02-20 20:11:07 +03:00
|
|
|
bsa.bsa_YSrcFactor = plot_height;
|
2009-03-08 20:41:24 +03:00
|
|
|
bsa.bsa_YDestFactor = bitmap->height;
|
2009-07-07 23:28:34 +04:00
|
|
|
bsa.bsa_SrcBitMap = browserglob.bm;
|
2009-03-08 20:41:24 +03:00
|
|
|
bsa.bsa_DestBitMap = bitmap->nativebm;
|
|
|
|
bsa.bsa_Flags = 0;
|
|
|
|
|
|
|
|
BitMapScale(&bsa);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (url) urldb_set_thumbnail(url, bitmap);
|
|
|
|
|
|
|
|
return true;
|
2008-08-02 18:31:32 +04:00
|
|
|
}
|