<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="http://git.reviewboard.kde.org/r/102780/">http://git.reviewboard.kde.org/r/102780/</a>
     </td>
    </tr>
   </table>
   <br />









<div>




<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="http://git.reviewboard.kde.org/r/102780/diff/1/?file=37886#file37886line50" style="color: black; font-weight: bold; text-decoration: underline;">libs/flake/KoColorBackground.h</a>
    <span style="font-weight: normal;">

     (Diff revision 1)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">public:</pre></td>

  </tr>
 </tbody>



 
 




 <tbody>

  <tr>
    <th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">50</font></th>
    <td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">    <span class="k">virtual</span> <span class="kt">void</span> <span class="n">paint</span><span class="p">(</span><span class="n">QPainter</span><span class="hl"> </span><span class="o"><span class="hl">&</span></span><span class="n">painter</span><span class="p">,</span> <span class="k">const</span> <span class="n">QPainterPath</span><span class="hl"> </span><span class="o"><span class="hl">&</span></span><span class="n">fillPath</span><span class="p">)</span> <span class="k">const</span><span class="p">;</span></pre></td>
    <th bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">50</font></th>
    <td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">    <span class="k">virtual</span> <span class="kt">void</span> <span class="n">paint</span><span class="p">(</span><span class="n">QPainter</span><span class="o"><span class="hl">&</span></span><span class="hl"> </span><span class="n">painter</span><span class="p">,</span> <span class="k">const</span> <span class="n">QPainterPath</span><span class="o"><span class="hl">&</span></span><span class="hl"> </span><span class="n">fillPath</span><span class="p"><span class="hl">,</span></span><span class="hl"> </span><span class="k"><span class="hl">const</span></span><span class="hl"> </span><span class="n"><span class="hl">KoViewConverter</span></span><span class="o"><span class="hl">*</span></span><span class="hl"> </span><span class="n"><span class="hl">convert</span></span><span class="hl"> </span><span class="o"><span class="hl">=</span></span><span class="hl"> </span><span class="mi"><span class="hl">0</span></span><span class="p">)</span> <span class="k">const</span><span class="p">;</span></pre></td>
  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Please drop this parameter.</pre>
</div>
<br />

<div>




<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="http://git.reviewboard.kde.org/r/102780/diff/1/?file=37891#file37891line126" style="color: black; font-weight: bold; text-decoration: underline;">libs/flake/KoOdfGradientBackground.cpp</a>
    <span style="font-weight: normal;">

     (Diff revision 1)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
   <td colspan="2"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">void KoOdfGradientBackground::paint(QPainter& painter, const QPainterPath& fillPath, const KoViewConverter* convert) const</pre></td>

  </tr>
 </tbody>




 
 



 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">126</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">    <span class="n">d</span><span class="o">-></span><span class="n">buffer</span> <span class="o">=</span> <span class="n">QImage</span><span class="p">(</span><span class="n">qCeil</span><span class="p">(</span><span class="n">pixels</span><span class="p">.</span><span class="n">size</span><span class="p">().</span><span class="n">width</span><span class="p">()),</span> <span class="n">qCeil</span><span class="p">(</span><span class="n">pixels</span><span class="p">.</span><span class="n">size</span><span class="p">().</span><span class="n">height</span><span class="p">()),</span> <span class="n">QImage</span><span class="o">::</span><span class="n">Format_ARGB32_Premultiplied</span><span class="p">);</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">127</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">    <span class="k">if</span> <span class="p">(</span><span class="n">d</span><span class="o">-></span><span class="n">style</span> <span class="o">==</span> <span class="s">"square"</span><span class="p">)</span> <span class="p">{</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">128</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="n">renderSquareGradient</span><span class="p">(</span><span class="n">d</span><span class="o">-></span><span class="n">buffer</span><span class="p">);</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">129</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">    <span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">130</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="n">renderRectangleGradient</span><span class="p">(</span><span class="n">d</span><span class="o">-></span><span class="n">buffer</span><span class="p">);</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">131</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">    <span class="p">}</span></pre></td>
  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">The buffer seems to be cached. However its content is recreated all the time. Maybe this can be optimized.</pre>
</div>
<br />

<div>




<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="http://git.reviewboard.kde.org/r/102780/diff/1/?file=37895#file37895line1458" style="color: black; font-weight: bold; text-decoration: underline;">libs/flake/KoShape.cpp</a>
    <span style="font-weight: normal;">

     (Diff revision 1)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">KoShapeBackground *KoShape::loadOdfFill(KoShapeLoadingContext &context) const</pre></td>

  </tr>
 </tbody>




 
 



 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1458</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="c1">// one more try if gradient</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1459</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="k">if</span> <span class="p">(</span><span class="n">fill</span> <span class="o">==</span> <span class="s">"gradient"</span><span class="p">)</span> <span class="p">{</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1460</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">            <span class="n">bg</span> <span class="o">=</span> <span class="k">new</span> <span class="n">KoOdfGradientBackground</span><span class="p">();</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1461</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">            <span class="k">return</span> <span class="p">(</span><span class="n">bg</span><span class="o">-></span><span class="n">loadStyle</span><span class="p">(</span><span class="n">context</span><span class="p">.</span><span class="n">odfLoadingContext</span><span class="p">(),</span> <span class="n">size</span><span class="p">())</span> <span class="o">?</span> <span class="n">bg</span> <span class="o">:</span> <span class="mi">0</span><span class="p">);</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1462</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="p">}</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1463</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
  </tr>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">1464</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This leaks the old bg. Would it be possible to already create the corrext background in case it is supported by KoOdfGradientBackground. That will get rid of an additional new/delete which is quite expensive.</pre>
</div>
<br />



<p>- Thorsten</p>


<br />
<p>On October 5th, 2011, 1:33 p.m., Lukáš Tvrdý wrote:</p>






<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('http://git.reviewboard.kde.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for Calligra, Jan Hambrecht and Thorsten Zachmann.</div>
<div>By Lukáš Tvrdý.</div>


<p style="color: grey;"><i>Updated Oct. 5, 2011, 1:33 p.m.</i></p>






<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Bugs: displays gradient of shapes from bug https://bugs.kde.org/show_bug.cgi?id=274909
Ellipsoid gradient is missing so far.

This patch adds support for ODF gradient style rectangular and square.

First I was trying to integrate gradients into KoGradientBackground, but shortly I noticed
that it is crashing as the editing tools require QGradient and are tied to it. So some abstraction
and re-factoring will be needed to support of creation and editing of the constructed ODF gradients.

Then I decided to introduce new class KoOdfGradientBackground which is not editable and integrate nicely.

Saving and loading of gradients work.

The gradients have many options like position, rotation, border. So far square gradients support 
all of them, though rotation of gradient is showing some artifacts, small pixels, I was not able to fix them. 
Rectangular type does not support rotation. 

Rotation would probably require to compute the gradient per pixel, which might be slow. I was trying to use QPainter and combination of QGradient and 
clipping to create the gradients effectively. I found inspiration here http://ariya.ofilabs.com/2011/06/rectangular-gradient.html
for square gradient.Rectangular gradient was done in similar way.

There was some problem with alias when rendering the gradients. First I was trying to solve it by supersampling,
then I wanted to use the exact size of the shape in pixels (without zooming). Then I ended up to compute
the pixel size of the shape on the canvas. 

There are two possibilities: to add new parameter KoViewConverter to paint method of the KoShapeBackground,
in the patch you can see it is not that much effort. Zagge was in a favor to not to add that parameter and 
he was suggesting to use QPainter's matrix as that one already includes the zooming information.

The patch includes the changes needed to include KoViewConverter, I will drop them if the preferred 
way is to use paint's QPainter matrix, which so far works as needed.

Square gradients in words
http://wstaw.org/m/2011/10/05/plasma-desktopoo2237.jpg

Rectangular gradients in words
http://wstaw.org/m/2011/10/05/plasma-desktopLg2237.jpg
</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I'm going to test it with cstester, I don't expect any regressions as the code handles previously non-handled ODF gradients.</pre>
  </td>
 </tr>
</table>




<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>libs/flake/CMakeLists.txt <span style="color: grey">(dad0c9a)</span></li>

 <li>libs/flake/KoColorBackground.h <span style="color: grey">(6cf70d3)</span></li>

 <li>libs/flake/KoColorBackground.cpp <span style="color: grey">(08692ee)</span></li>

 <li>libs/flake/KoGradientBackground.h <span style="color: grey">(be21eec)</span></li>

 <li>libs/flake/KoGradientBackground.cpp <span style="color: grey">(a56b7c3)</span></li>

 <li>libs/flake/KoOdfGradientBackground.h <span style="color: grey">(PRE-CREATION)</span></li>

 <li>libs/flake/KoOdfGradientBackground.cpp <span style="color: grey">(PRE-CREATION)</span></li>

 <li>libs/flake/KoPathShape.cpp <span style="color: grey">(4c5ffb6)</span></li>

 <li>libs/flake/KoPatternBackground.h <span style="color: grey">(d372677)</span></li>

 <li>libs/flake/KoPatternBackground.cpp <span style="color: grey">(577bf3d)</span></li>

 <li>libs/flake/KoShape.cpp <span style="color: grey">(6b07e7c)</span></li>

 <li>libs/flake/KoShapeBackground.h <span style="color: grey">(7822c50)</span></li>

</ul>

<p><a href="http://git.reviewboard.kde.org/r/102780/diff/" style="margin-left: 3em;">View Diff</a></p>




  </td>
 </tr>
</table>








  </div>
 </body>
</html>