D9848: Updated the blur method to use the more efficient dual kawase blur algorithm.

Anthony Fieroni noreply at phabricator.kde.org
Sat Jan 13 09:36:19 UTC 2018


anthonyfieroni added inline comments.
Restricted Application edited projects, added KWin; removed Plasma.

INLINE COMMENTS

> blur.cpp:94
>      delete shader;
> -    delete target;
> +    shader = NULL;
> +    

m_simpleTarget should be deleted too

> blur.cpp:96-104
> +    for (int i = 0; i < renderTargets.size(); i++) {
> +        delete renderTargets[i];
> +        renderTargets[i] = NULL;
> +        
> +        renderTextures[i].discard();
> +    }
> +    

Make a function that clears them.

> blur.cpp:117
>  
> -void BlurEffect::updateTexture() {
> -    delete target;
> -    // Offscreen texture that's used as the target for the horizontal blur pass
> -    // and the source for the vertical pass.
> -    tex = GLTexture(GL_RGBA8, effects->virtualScreenSize());
> -    tex.setFilter(GL_LINEAR);
> -    tex.setWrapMode(GL_CLAMP_TO_EDGE);
> +bool BlurEffect::renderTargetsValid()
> +{

Make it const.

> blur.cpp:119-129
> +    if (renderTargets.isEmpty()) {
> +        return false;
> +    }
> +    
> +    for (int i = 0; i < renderTargets.size(); i++) {
> +        if (!renderTargets[i]->valid()) {
> +            return false;

You can minimize it

  return !renderTargets.isEmpty() 
        && std::find_if(renderTargets.cbegin(), renderTargets.cend(), [](const GLRenderTarget *target) {
                                 return !target->valid(); }) == renderTarget.cend();

> blur.cpp:180-188
> +    for (int i = 0; i < renderTargets.size(); i++) {
> +        delete renderTargets[i];
> +        renderTargets[i] = NULL;
> +        
> +        renderTextures[i].discard();
> +    }
> +    

Use same function from above.

> blur.cpp:670-724
> +    shader->bind(BlurShader::copySampleType);
> +    
> +    shader->setModelViewProjectionMatrix(screenProjection);
> +    shader->setTextureSize(screen.size());
> +    shader->setBlurRect(shape.boundingRect().adjusted(BORDER_SIZE, BORDER_SIZE, -BORDER_SIZE, -BORDER_SIZE), screen.size());
> +    
> +    GLRenderTarget::pushRenderTarget(renderTargets[0]);

Make a 3 function copySampleType, downSampleType, upSampleType with needed parameters. Call them here and in doCachedBlur

> blur.h:83
>      QRegion blurRegion(const EffectWindow *w) const;
> -    bool shouldBlur(const EffectWindow *w, int mask, const WindowPaintData &data) const;
> +    bool shouldBlur(const EffectWindow *w, int mask, const WindowPaintData &data);
>      void updateBlurRegion(EffectWindow *w) const;

Still can be const.

> blurshader.cpp:232-239
>      if (gles) {
>          if (core) {
> -            stream << "#version 300 es\n\n";
> +            streamVert << "#version 300 es\n\n";
>          }
> -        stream << "precision highp float;\n";
> +        
> +        streamVert << "precision highp float;\n";
>      } else if (glsl_140) {

QString glHeaderString;
  if (gles) {
      if (core) {
          glHeaderString += "#version 300 es\n\n";
      }
      glHeaderString += "precision highp float;\n";
  } else if (glsl_140) {
      glHeaderString += "#version 140\n\n";
  }
  streamVert << glHeaderString;

> blurshader.cpp:256-264
> +    if (gles) {
> +        if (core) {
> +            streamFragDown << "#version 300 es\n\n";
> +        }
> +        
> +        streamFragDown << "precision highp float;\n";
> +    } else if (glsl_140) {

streamFragDown << glHeaderString;

> blurshader.cpp:266-271
> +    streamFragDown << "uniform sampler2D texUnit;\n";
> +    streamFragDown << "uniform float offset;\n";
> +    streamFragDown << "uniform vec2 textureSize;\n";
> +
> +    if (core)
> +        streamFragDown << "out vec4 fragColor;\n\n";

QString glUniformString = "uniform sampler2D texUnit;\n"
                            "uniform float offset;\n"
                            "uniform vec2 textureSize;\n";
  if (core) {
      glUniformString += "out vec4 fragColor;\n\n";
  }
  streamFragDown << glUniformString;

> blurshader.cpp:293-308
>      if (gles) {
>          if (core) {
> -            stream2 << "#version 300 es\n\n";
> +            streamFragUp << "#version 300 es\n\n";
>          }
> -        stream2 << "precision highp float;\n";
> +        
> +        streamFragUp << "precision highp float;\n";
>      } else if (glsl_140) {

streamFragUp << glHeaderString << glUniformString;

> blurshader.cpp:333-348
> +    if (gles) {
> +        if (core) {
> +            streamFragCopy << "#version 300 es\n\n";
> +        }
> +        
> +        streamFragCopy << "precision highp float;\n";
> +    } else if (glsl_140) {

streamFragCopy << glHeaderString << glUniformString;

REPOSITORY
  R108 KWin

REVISION DETAIL
  https://phabricator.kde.org/D9848

To: anemeth, #plasma, #kwin
Cc: anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin, iodelay, bwowk, ZrenBot, progwolff, lesliezhai, ali-mohamed, hardening, jensreuterberg, abetts, sebas, apol
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20180113/dbc9cb3e/attachment-0001.html>


More information about the Plasma-devel mailing list