w3c / imsc-hrm

IMSC Hypothetical Render Model
https://w3c.github.io/imsc-hrm/spec/imsc-hrm.html
Other
1 stars 6 forks source link

NBG(R_i) counts transparent backgrounds #4

Closed palemieux closed 2 years ago

palemieux commented 3 years ago

The quantity NBG(Ri) counts tts:backgroundColor attributes even when the color is transparent, which should result in no drawing.

tts:backgroundColor with transparent colors should be ignored.

nigelmegitt commented 3 years ago

I'm not sure how useful this is, given that it adds complexity, and the HRM is primarily a high-water-mark guide? My concerns are that not all implementations will optimise the drawing in ways that we can see could be possible, but the document contents should be processable even by such non-optimised implementations.

The background being transparent is not the only optimisation we might guess that implementations would make. Another is the case that a background color is specified on an element but does not need to be drawn, because it would never be visible, because there's another element on which a different background color is specified, that occupies an entirely overlapping portion of the rendering area.

For example if a region sets tts:backgroundColor and body also sets tts:backgroundColor (see also w3c/imsc-hrm#2 ), then the region's background will never be seen - I haven't checked but there might need to be additional checks here for padding on the region, in case there are "edge cases" where edges are visible.

I suggest making no change here.

palemieux commented 3 years ago

In what circumstances would a background ever be drawn if the alpha channel is 0 or the color is transparent?

nigelmegitt commented 3 years ago

In what circumstances would a background ever be drawn if the alpha channel is 0 or the color is transparent?

If the implementer hadn't tested for that and optimised it out, but simply saw "there's a background, better go draw it".

palemieux commented 3 years ago

If the implementer hadn't tested for that and optimised it out, but simply saw "there's a background, better go draw it".

They should optimize it... just like the model assumes that identical glyphs are copied rather than rendered twice.

nigelmegitt commented 3 years ago

They should optimize it

That's extra work, when the content author should omit the tts:backgroundColor style, if it has no opacity.

Working out which optimisations to factor into the HRM and which to leave out is a line-drawing exercise. It doesn't much matter as long as everyone gets the same answer. Computing the HRM values is hard enough work already without having to factor this kind of thing in, and my guess is that it's a tiny edge case in terms of the amount of content that would trigger the optimisation. My feeling here is that it is not a particularly important change to make.

palemieux commented 3 years ago

nd my guess is that it's a tiny edge case in terms of the amount of content that would trigger the optimisation. My feeling here is that it is not a particularly important change to make.

I agree. Which is why I think the change is easy to make :)

nigelmegitt commented 3 years ago

I agree. Which is why I think the change is easy to make :)

But also the change has little benefit, right?

palemieux commented 3 years ago

But also the change has little benefit, right?

I am concerned with needlessly penalizing tools that write tts:backgroundColor="transparent" (which is the initial value) expecting nothing to happen. I have seen these examples in the wild.

A related questions is: does specifying a background color with transparent alpha the same as specifying tts:backgroundColor="transparent"?

nigelmegitt commented 3 years ago

See https://github.com/w3c/csswg-drafts/issues/2722 for additional entertainment regarding "transparent" - we possibly do need to take into account blending across animations of colour values towards transparency.

css-meeting-bot commented 3 years ago

The Timed Text Working Group just discussed NBG(R_i) counts transparent backgrounds w3c/imsc#570, and agreed to the following:

The full IRC log of that discussion <nigel> Topic: NBG(R_i) counts transparent backgrounds w3c/imsc#570
<nigel> github: https://github.com/w3c/imsc/issues/570
<nigel> Pierre: The issue here is the algorithm makes a difference if the background is not specified or is transparent,
<nigel> .. but those two are really equivalent.
<nigel> .. It doesn't make sense for two documents to result in different complexity just based on initial value or specified value, where they're the same.
<nigel> Nigel: This is about the computed value rather than the specified value, because initial can change the default?
<nigel> Pierre: Right, but right now the HRM is defined in terms of specified values if I'm not mistaken.
<nigel> Nigel: That's weird!
<nigel> Pierre: That was before initial, where for things that are not inherited it makes a difference.
<nigel> .. That may be a separate issue that we need to fix.
<nigel> Nigel: The two things go together.
<nigel> Pierre: Sure, but even if initial is transparent, there should be no difference in complexity if one document specifies backgroundColor="transparent"
<nigel> .. and the other one doesn't.
<nigel> Nigel: If you change this to be based on computed values and change the algorithm to ignore transparent background values, that
<nigel> .. would solve both issues?
<nigel> Pierre: I agree, we could solve both at once that way.
<nigel> Nigel: I think that makes the case for a change here more concrete.
<nigel> .. My discussion comments before were based on reluctance to change HRM because it will create
<nigel> .. new values, with new thresholds etc. so it could be costly for implementations.
<nigel> Pierre: These three issues I filed were as a result of trying to implement the spec.
<nigel> .. I'm not aware of any other implementation of the HRM.
<nigel> .. Of course I was running my HRM code against sample documents.
<nigel> Nigel: Any other questions or comments?
<nigel> Pierre: I'll generate a pull request based on this.
<nigel> SUMMARY: Pierre @palemieux to open a pull request as per the above discussion.
palemieux commented 3 years ago

@nigelmegitt I have create w3c/imsc#572.