[webkit-dev] image downscaling during decoding

Ilyes Gouta ilyes.gouta at gmail.com
Mon Aug 13 07:36:31 PDT 2012


Hi,

> At the moment such images are full decoded to a full size buffer and get downscaled during rendering.

WebKit has already a hard coded
ImageSource::s_maxPixelsPerDecodedImage value, in
WebCode/platform/graphics/ImageSource.cpp which defaults to 1024 *
1024 when WebKit's option ENABLE(IMAGE_DECODER_DOWN_SAMPLING) gets
turned on. s_maxPixelsPerDecodedImage is used to compute a scaling
factor for both the horizontal and vertical directions and serves as a
cap to the maximum picture size that a decoder would produce (so
already a way to control the total memory allocated for pictures). Now
if those new width and height are smaller than the original picture's
dimensions, then the decoder if clever enough would then produce a
downscaled picture (preferably while decoding and not in a second
pass) that fit s_maxPixelsPerDecodedImage.

For example, it's is already possible for libjpeg to downscale JPEGs
(via a modified IDCT, so we get the resize for free), by specifying a
resize ratio via cinfo's scale_num and scale_denom fields.

Finally, it would make sense to allocate all those graphics buffers
from video memory instead of system memory (malloc()) (and yes that's
rather platform specific) and let the h/w to perform the final resize
and layout/rendering.

-Ilyes

On Mon, Aug 13, 2012 at 2:39 PM, Anton Obzhirov <a.obzhirov at samsung.com> wrote:
> Hi,
>
>
>
> We are looking for ways to improve page loading speed and reduce memory
> usage for WebKit in general and for GTK port of WebKit in particular.
>
> One of the ideas is to implement downscaling of the images during decoding
> for image elements with rectangle less then original image size.
>
> At the moment such images are full decoded to a full size buffer and get
> downscaled during rendering.
>
> It can be quite beneficial in term of memory usage and should speed up
> rendering of the pages like image galleries for example.
>
> So what are your thoughts about it?
>
>
>
> Regards,
>
> Anton
>
>
>
>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo/webkit-dev
>


More information about the webkit-dev mailing list