diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2011-02-20 12:39:23 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2011-02-20 12:39:23 +0000 |
commit | a06b4b4302acdb1406fa9a5f88f5439675598cd4 (patch) | |
tree | aa4a9386e040c5362dac32df21c9563683dba40a /cocoa | |
parent | 8813181cea3228d4f48aef70e4063ab7d2e9abf4 (diff) | |
download | netsurf-a06b4b4302acdb1406fa9a5f88f5439675598cd4.tar.gz netsurf-a06b4b4302acdb1406fa9a5f88f5439675598cd4.tar.bz2 |
Port cocoa front end to use thumbnail_redraw(). Note: untested.
svn path=/trunk/netsurf/; revision=11720
Diffstat (limited to 'cocoa')
-rw-r--r-- | cocoa/thumbnail.m | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/cocoa/thumbnail.m b/cocoa/thumbnail.m index 26f1a7a65..0ec66b52a 100644 --- a/cocoa/thumbnail.m +++ b/cocoa/thumbnail.m @@ -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 ); - - 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 ); + size_t height = ((width * bheight) + bwidth / 2)) / bwidth; + CGContextTranslateCTM( bitmapContext, 0, bheight ); + CGContextScaleCTM( bitmapContext, (CGFloat)bwidth / width, -(CGFloat)bheight / 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; + return true; } |