Changeset 148201 in webkit


Ignore:
Timestamp:
Apr 11, 2013 7:36:22 AM (11 years ago)
Author:
anilsson@rim.com
Message:

[BlackBerry][CSS Filters] Blur filter fails to recompute blur size when layer size changes
https://bugs.webkit.org/show_bug.cgi?id=114272

Reviewed by Rob Buis.

Blur appeared blocky or pixelated when surface changed size after
creating the filter actions. The initial image size was used to
determine the blur size (expressed in texture coordinate system).
Fixed by recomputing the blur size when the surface size changes, using
a new Uniform1f subclass that can use a functor to compute the uniform
value per-frame.

This fixes css3/filters/effect-blur-hw.html. This can only be verified
by manual inspection because the BlackBerry port is not currently using
pixel tests.

PR 323730

  • platform/graphics/blackberry/LayerFilterRenderer.cpp:

(WebCore):
(SurfaceFunctor):
(WebCore::SurfaceFunctor::SurfaceFunctor):
(InverseSurfaceWidth):
(WebCore::InverseSurfaceWidth::InverseSurfaceWidth):
(WebCore::InverseSurfaceWidth::operator()):
(InverseSurfaceHeight):
(WebCore::InverseSurfaceHeight::InverseSurfaceHeight):
(WebCore::LayerFilterRenderer::actionsForOperations):

  • platform/graphics/blackberry/LayerFilterRenderer.h:

(Uniform1f):
(WebCore):
(Uniform1fWithFunctor):
(WebCore::Uniform1fWithFunctor::create):
(WebCore::Uniform1fWithFunctor::Uniform1fWithFunctor):
(WebCore::Uniform1fWithFunctor::apply):
(WebCore::Uniform1f::createWithFunctor):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r148200 r148201  
     12013-04-11  Arvid Nilsson  <anilsson@rim.com>
     2
     3        [BlackBerry][CSS Filters] Blur filter fails to recompute blur size when layer size changes
     4        https://bugs.webkit.org/show_bug.cgi?id=114272
     5
     6        Reviewed by Rob Buis.
     7
     8        Blur appeared blocky or pixelated when surface changed size after
     9        creating the filter actions. The initial image size was used to
     10        determine the blur size (expressed in texture coordinate system).
     11        Fixed by recomputing the blur size when the surface size changes, using
     12        a new Uniform1f subclass that can use a functor to compute the uniform
     13        value per-frame.
     14
     15        This fixes css3/filters/effect-blur-hw.html. This can only be verified
     16        by manual inspection because the BlackBerry port is not currently using
     17        pixel tests.
     18
     19        PR 323730
     20
     21        * platform/graphics/blackberry/LayerFilterRenderer.cpp:
     22        (WebCore):
     23        (SurfaceFunctor):
     24        (WebCore::SurfaceFunctor::SurfaceFunctor):
     25        (InverseSurfaceWidth):
     26        (WebCore::InverseSurfaceWidth::InverseSurfaceWidth):
     27        (WebCore::InverseSurfaceWidth::operator()):
     28        (InverseSurfaceHeight):
     29        (WebCore::InverseSurfaceHeight::InverseSurfaceHeight):
     30        (WebCore::LayerFilterRenderer::actionsForOperations):
     31        * platform/graphics/blackberry/LayerFilterRenderer.h:
     32        (Uniform1f):
     33        (WebCore):
     34        (Uniform1fWithFunctor):
     35        (WebCore::Uniform1fWithFunctor::create):
     36        (WebCore::Uniform1fWithFunctor::Uniform1fWithFunctor):
     37        (WebCore::Uniform1fWithFunctor::apply):
     38        (WebCore::Uniform1f::createWithFunctor):
     39
    1402013-04-11  Arvid Nilsson  <anilsson@rim.com>
    241
  • trunk/Source/WebCore/platform/graphics/blackberry/LayerFilterRenderer.cpp

    r148192 r148201  
    3838
    3939namespace WebCore {
     40
     41class SurfaceFunctor {
     42public:
     43    SurfaceFunctor(LayerRendererSurface* surface)
     44        : m_surface(surface)
     45    {
     46    }
     47
     48protected:
     49    LayerRendererSurface* m_surface;
     50};
     51
     52class InverseSurfaceWidth : public SurfaceFunctor {
     53public:
     54    InverseSurfaceWidth(LayerRendererSurface* surface) : SurfaceFunctor(surface) { }
     55
     56    float operator() () { return 1.0f / m_surface->size().width(); }
     57};
     58
     59class InverseSurfaceHeight : public SurfaceFunctor {
     60public:
     61    InverseSurfaceHeight(LayerRendererSurface* surface) : SurfaceFunctor(surface) { }
     62
     63    float operator() () { return 1.0f / m_surface->size().height(); }
     64};
    4065
    4166static int operationTypeToProgramID(const FilterOperation::OperationType& t)
     
    602627            // BLUR Y:
    603628            ret.last()->appendParameter(Uniform1f::create(m_amountLocation[LayerData::CSSFilterShaderBlurY], amount));
    604             ret.last()->appendParameter(Uniform1f::create(m_blurAmountLocation[0]
    605                 , 1.0f / float(surface->size().height())));
     629            ret.last()->appendParameter(Uniform1f::createWithFunctor(m_blurAmountLocation[0], InverseSurfaceHeight(surface)));
    606630
    607631            // BLUR X:
    608632            ret.append(LayerFilterRendererAction::create(LayerData::CSSFilterShaderBlurX));
    609633            ret.last()->appendParameter(Uniform1f::create(m_amountLocation[LayerData::CSSFilterShaderBlurX], amount));
    610             ret.last()->appendParameter(Uniform1f::create(m_blurAmountLocation[1]
    611                 , 1.0f / float(surface->size().width())));
     634            ret.last()->appendParameter(Uniform1f::createWithFunctor(m_blurAmountLocation[1], InverseSurfaceWidth(surface)));
    612635
    613636            }
     
    635658            ret.last()->appendParameter(Uniform1f::create(m_amountLocation[LayerData::CSSFilterShaderBlurY]
    636659                , dsfo.stdDeviation()));
    637             ret.last()->appendParameter(Uniform1f::create(m_blurAmountLocation[0]
    638                 , 1.0f / float(surface->size().height())));
     660            ret.last()->appendParameter(Uniform1f::createWithFunctor(m_blurAmountLocation[0], InverseSurfaceHeight(surface)));
    639661
    640662            // BLUR X
     
    642664            ret.last()->appendParameter(Uniform1f::create(m_amountLocation[LayerData::CSSFilterShaderBlurX]
    643665                , dsfo.stdDeviation()));
    644             ret.last()->appendParameter(Uniform1f::create(m_blurAmountLocation[1]
    645                 , 1.0f / float(surface->size().width())));
     666            ret.last()->appendParameter(Uniform1f::createWithFunctor(m_blurAmountLocation[1], InverseSurfaceWidth(surface)));
    646667
    647668            // Repaint original image
  • trunk/Source/WebCore/platform/graphics/blackberry/LayerFilterRenderer.h

    r148129 r148201  
    7070    static PassRefPtr<Uniform> create(int location, float val);
    7171
     72    template<typename Functor>
     73    static PassRefPtr<Uniform> createWithFunctor(int location, Functor);
     74
    7275protected:
    7376    Uniform1f(int location, float val);
    7477
    75 private:
    76     virtual void apply();
     78    virtual void apply();
     79
    7780    float m_val;
    7881};
     82
     83template<typename Functor>
     84class Uniform1fWithFunctor : public Uniform1f {
     85public:
     86    static PassRefPtr<Uniform> create(int location, Functor functor)
     87    {
     88        return adoptRef(new Uniform1fWithFunctor(location, functor));
     89    }
     90
     91protected:
     92    Uniform1fWithFunctor(int location, Functor functor)
     93        : Uniform1f(location, 0)
     94        , m_functor(functor)
     95    {
     96    }
     97
     98    virtual void apply()
     99    {
     100        m_val = m_functor();
     101        Uniform1f::apply();
     102    }
     103
     104    Functor m_functor;
     105};
     106
     107template<typename Functor>
     108inline PassRefPtr<Uniform> Uniform1f::createWithFunctor(int location, Functor functor)
     109{
     110    return Uniform1fWithFunctor<Functor>::create(location, functor);
     111}
    79112
    80113class Uniform1i : public Uniform {
Note: See TracChangeset for help on using the changeset viewer.