mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-24 15:29:45 +03:00
Port cocoa front end to use thumbnail_redraw(). Note: untested.
svn path=/trunk/netsurf/; revision=11720
This commit is contained in:
parent
8813181cea
commit
a06b4b4302
@ -28,41 +28,36 @@
|
||||
bool thumbnail_create(struct hlcache_handle *content, struct bitmap *bitmap,
|
||||
const char *url)
|
||||
{
|
||||
int bwidth = bitmap_get_width( bitmap );
|
||||
int bheight = bitmap_get_height( bitmap );
|
||||
CGColorSpaceRef cspace = CGColorSpaceCreateWithName( kCGColorSpaceGenericRGB );
|
||||
CGContextRef bitmapContext = CGBitmapContextCreate( bitmap_get_buffer( bitmap ),
|
||||
bitmap_get_width( bitmap ), bitmap_get_height( bitmap ),
|
||||
bwidth, bheight,
|
||||
bitmap_get_bpp( bitmap ) * 8 / 4,
|
||||
bitmap_get_rowstride( bitmap ),
|
||||
cspace, kCGImageAlphaNoneSkipLast );
|
||||
CGColorSpaceRelease( cspace );
|
||||
|
||||
|
||||
size_t width = MIN( content_get_width( content ), 1024 );
|
||||
size_t height = MIN( content_get_height( content ), 768 );
|
||||
size_t height = ((width * bheight) + bwidth / 2)) / bwidth;
|
||||
|
||||
CGContextTranslateCTM( bitmapContext, 0, bheight );
|
||||
CGContextScaleCTM( bitmapContext, (CGFloat)bwidth / width, -(CGFloat)bheight / height );
|
||||
|
||||
struct rect clip;
|
||||
clip.x0 = 0;
|
||||
clip.y0 = 0;
|
||||
clip.x1 = content_get_width( content );
|
||||
clip.y1 = content_get_height( content );
|
||||
|
||||
CGContextTranslateCTM( bitmapContext, 0, bitmap_get_height( bitmap ) );
|
||||
CGContextScaleCTM( bitmapContext, (CGFloat)bitmap_get_width( bitmap ) / width, -(CGFloat)bitmap_get_height( bitmap ) / height );
|
||||
|
||||
[NSGraphicsContext setCurrentContext: [NSGraphicsContext graphicsContextWithGraphicsPort: bitmapContext flipped: YES]];
|
||||
|
||||
content_redraw( content, 0, 0, content_get_width( content ), content_get_height( content ),
|
||||
&clip,
|
||||
1.0, 0xFFFFFFFF );
|
||||
|
||||
|
||||
/* todo: ??? set plot scale according to the scale the thumbnail will be
|
||||
* rendered at, by calling thumbnail_get_redraw_scale(). ??? */
|
||||
|
||||
thumbnail_redraw( content, width, height );
|
||||
|
||||
[NSGraphicsContext setCurrentContext: nil];
|
||||
CGContextRelease( bitmapContext );
|
||||
|
||||
bitmap_modified( bitmap );
|
||||
|
||||
if (NULL != url) urldb_set_thumbnail( url, bitmap );
|
||||
|
||||
return true;
|
||||
|
||||
bitmap_modified( bitmap );
|
||||
|
||||
if (NULL != url) urldb_set_thumbnail( url, bitmap );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user