Bug 140603 - SVG lighting filter calculation is optimized to be executed in a loop
Summary: SVG lighting filter calculation is optimized to be executed in a loop
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-01-18 20:20 PST by Said Abou-Hallawa
Modified: 2018-01-03 16:08 PST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Said Abou-Hallawa 2015-01-18 20:20:19 PST
The function FELighting::inlineSetPixel() is called to apply the lighting on a single pixel one at a time. Things to be noticed here about this function

-- The same calculation is carried out for the same values when calling this function from a loop. As an example consider these lines from FELighting::inlineSetPixel():

        normalVector.setX(factorX * static_cast<float>(normal2DVector.x()) * data.surfaceScale);
        normalVector.setY(factorY * static_cast<float>(normal2DVector.y()) * data.surfaceScale);

and consider the case when it is called from any loop in FELighting::drawLighting(). All loops call FELighting::inlineSetPixel() with the same values for factorX, factorY, normal2DVector and data.surfaceScale. So the above multiplications should be carried out only once for every loop and reused for all pixels processed in this loop.

-- The calculation of FELighting::inlineSetPixel() is not reused for adjacent pixels if they should be the same. Caching the resulting color or the light strength of the last pixel should accelerate the lighting calculation for adjacent pixels.
Comment 1 Radar WebKit Bug Importer 2015-01-19 12:03:15 PST
<rdar://problem/19521229>
Comment 2 Simon Fraser (smfr) 2018-01-03 16:08:06 PST
(In reply to Said Abou-Hallawa from comment #0)
> The function FELighting::inlineSetPixel() is called to apply the lighting on
> a single pixel one at a time. Things to be noticed here about this function
> 
> -- The same calculation is carried out for the same values when calling this
> function from a loop. As an example consider these lines from
> FELighting::inlineSetPixel():
> 
>         normalVector.setX(factorX * static_cast<float>(normal2DVector.x()) *
> data.surfaceScale);
>         normalVector.setY(factorY * static_cast<float>(normal2DVector.y()) *
> data.surfaceScale);
> 
> and consider the case when it is called from any loop in
> FELighting::drawLighting(). All loops call FELighting::inlineSetPixel() with
> the same values for factorX, factorY, normal2DVector and data.surfaceScale.
> So the above multiplications should be carried out only once for every loop
> and reused for all pixels processed in this loop.

The normal vector is not constant here; it's the surface normal, computed by the Sobel filter that compares the alpha values of neighboring pixels.

> -- The calculation of FELighting::inlineSetPixel() is not reused for
> adjacent pixels if they should be the same. Caching the resulting color or
> the light strength of the last pixel should accelerate the lighting
> calculation for adjacent pixels.

That's possibly true.