W3C home > Mailing lists > Public > public-svg-wg@w3.org > July to September 2012

RE: SVG 2 rendering model

From: Rik Cabanier <cabanier@adobe.com>
Date: Fri, 3 Aug 2012 00:07:45 -0700
To: "'Nikos Andronikos'" <nikos.andronikos@cisra.canon.com.au>, Leonard Rosenthol <lrosenth@adobe.com>
CC: "public-svg-wg@w3.org" <public-svg-wg@w3.org>
Message-ID: <83F37C1A4497B54589EAEDC750D03A9473B7E697@nambx09.corp.adobe.com>
Hi Nikos,

Thanks for the reply. I agree that a buffer is needed; the need for group alpha is implies it.

Reading the compositing spec, it has the following wording:
A compositing group is rendered by first compositing the elements of the group onto the inital backdrop.

This is incorrect. The elements composite with each other and during the composite they will look at the backdrop.
For the first element this is equal to the group backdrop. The second element = group backdrop + first element, etc.
The first element composites into an empty buffer; the second composites on top of the first, etc.

This is what is causing your concern with filters since the backdrop is pulled in and becomes filtered.
Another side effect is that the non-standard compositing modes are no longer group invariant with this approach (per the SVG Open document).

With my proposal, you get group invariance and filters will do as you expect.

I don't think we need to change much. Just some of the wording in the intro to compositing groups.

What do you think?

From: Nikos Andronikos [mailto:nikos.andronikos@cisra.canon.com.au]
Sent: Thursday, August 02, 2012 9:54 PM
To: Leonard Rosenthol
Cc: Rik Cabanier; public-svg-wg@w3.org
Subject: Re: SVG 2 rendering model

On 3/08/2012 6:08 AM, Leonard Rosenthol wrote:

On 8/2/12 3:34 PM, "Rik Cabanier" <cabanier@adobe.com><mailto:cabanier@adobe.com> wrote:



Hi Leonard,



The problem with making isolated the default is that it will impact

performance for all of the normal cases.

Isolated is faster since you don't have to composite all the group to get

the background.



But you DO have to create an "offscreen buffer", composite the entire

group into that, and then blit the entire "offscreen" back.   So you're

clearly using more memory and time than simply putting bits into the

existing buffer.





The compositing spec specifies the order in which filters and compositing

happens.

The filters spec should say if the stacking group it creates is isolated

or not. I believe people don't want it to be isolated (and can post some

examples if needed)



But how would you apply a filter to a group that has already been blended

into the background?  The result is certainly going to be different -

which may be good or bad.



I would think that given a group with a filter applied to it, you have to

make that specific group isolated, apply the filter, and only then blend

it to the background.
Exactly, and in the default case the output would be different between SVG 1.1 and SVG 2, which I consider bad.

Filter effects currently relies on the SVG 1.1 compositing model

>From http://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html:
"The compositing model follows the SVG compositing model<http://www.w3.org/TR/SVG11/render.html#Introduction> [SVG11]<http://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#SVG11>: first any filter effect is applied, then any clipping, masking and opacity. These effects all apply after any other CSS effects such as 'border'. As per SVG, the application of 'filter<http://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#filter>' has no effect on hit-testing."
Note: for groups, that means first composite the contents of the group together, then apply any filter effect, then clipping, masking and group opacity.

That was fine when you could composite the elements within the group in isolation, as was the case with SVG 1.1
But the default in the new model is isolated=false.

With isolated = false, you cannot composite the group contents together, apply the filter effects and then composite the result with the document. If you do and you are using a combination of operator and blend mode that is not group invariant you will get the wrong output.

I've attached an SVG file which demonstrates the output under each rendering model.

-----------------------------------------------------
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"<http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd>>
<svg viewBox="0 0 1350 540" xmlns="http://www.w3.org/2000/svg"<http://www.w3.org/2000/svg> version="1.1">

  <defs>
    <filter id="ShiftBGAndBlur" filterUnits="userSpaceOnUse" x="0" y="0" width="1200" height="400">
      <feOffset in="SourceGraphic" dx="0" dy="125" />
      <feGaussianBlur stdDeviation="8" />
    </filter>
  </defs>

  <text>SVG 1.1</text>
  <text x="280">SVG 2</text>
  <g transform="translate(0, 20)">

  <g transform="translate(0,0)" enable-background="new">
    <text>Firstly the contents of the group are composited together</text>
    <desc>Firstly the contents of the group are rendered into a transparent black buffer B</desc>
    <g>
      <circle cx="125" cy="75" r="45" fill="green" opacity=".5" />
      <polygon points="160,25 160,125 240,75" fill="blue" opacity=".5" />
    </g>
    <rect x="5" y="5" width="260" height="260" fill="none" stroke="blue"/>
  </g>

  <g transform="translate(0,280)" enable-background="new">
    <text>Then the filter effect is applied to the composite</text>
    <desc>Then the filter effect is applied to the buffer B</desc>
    <g>
        <g filter="url(#ShiftBGAndBlur)">
          <circle cx="125" cy="75" r="45" fill="green" opacity=".5"/>
          <polygon points="160,25 160,125 240,75" fill="blue" opacity=".5"/>
        </g>
    </g>
    <rect x="5" y="5" width="260" height="260" fill="none" stroke="blue"/>
  </g>

  <g transform="translate(0,560)" enable-background="new">
    <text>then the result of the filter effect is composited onto the page</text>
    <desc>then the buffer B is composited onto the output</desc>
    <g>
        <rect x="25" y="25" width="100" height="100" fill="red"/>
        <g filter="url(#ShiftBGAndBlur)">
          <circle cx="125" cy="75" r="45" fill="green" opacity=".5" />
          <polygon points="160,25 160,125 240,75" fill="blue" opacity=".5" />
        </g>
    </g>
    <rect x="5" y="5" width="260" height="260" fill="none" stroke="blue"/>
  </g>

  <clipPath id="cliptoself_clip">
    <circle cx="125" cy="75" r="45"/>
  </clipPath>

  <g transform="translate(270,0)" enable-background="new">
    <desc>In SVG 2, the contents of the group are rendered into a buffer B2 initialised with the group backdrop. Note clip to self behaviour.</desc>
    <g>
        <rect x="25" y="25" width="100" height="100" fill="red" clip-path="url(#cliptoself_clip)"/>
        <g>
          <circle cx="125" cy="75" r="45" fill="green" opacity=".5"/>
          <polygon points="160,25 160,125 240,75" fill="blue" opacity=".5"/>
        </g>
    </g>
    <rect x="5" y="5" width="260" height="260" fill="none" stroke="blue"/>
  </g>

  <g transform="translate(270,280)" enable-background="new">
    <desc>Then the filter effect is applied to the buffer B2</desc>
    <g filter="url(#ShiftBGAndBlur)">
        <rect x="25" y="25" width="100" height="100" fill="red" clip-path="url(#cliptoself_clip)"/>
        <g>
          <circle cx="125" cy="75" r="45" fill="green" opacity=".5"/>
          <polygon points="160,25 160,125 240,75" fill="blue" opacity=".5"/>
        </g>
    </g>
    <rect x="5" y="5" width="260" height="260" fill="none" stroke="blue"/>
  </g>

  <g transform="translate(270,560)" enable-background="new">
    <desc>then the buffer B2 is composited onto the output - what's wrong with this picture?</desc>
    <rect x="25" y="25" width="100" height="100" fill="red"/>
    <g filter="url(#ShiftBGAndBlur)">
        <rect x="25" y="25" width="100" height="100" fill="red" clip-path="url(#cliptoself_clip)"/>
        <g>
          <circle cx="125" cy="75" r="45" fill="green" opacity=".5"/>
          <polygon points="160,25 160,125 240,75" fill="blue" opacity=".5"/>
        </g>
    </g>
    <rect x="5" y="5" width="260" height="260" fill="none" stroke="blue"/>
  </g>
  </g>

</svg>
The information contained in this email message and any attachments may be confidential and may also be the subject to legal professional privilege. If you are not the intended recipient, any use, interference with, disclosure or copying of this material is unauthorised and prohibited. If you have received this email in error, please immediately advise the sender by return email and delete the information from your system.
Received on Friday, 3 August 2012 07:08:16 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 3 August 2012 07:08:16 GMT