Closed Bug 750006 Opened 12 years ago Closed 12 years ago

render active layers at full scale and transform them on the GPU

Categories

(Core :: Graphics: Layers, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla15

People

(Reporter: gal, Assigned: gal)

Details

Attachments

(1 file, 1 obsolete file)

If an animation scales content up or down, we currently redraw it at powers of 2 and scale up from there to the actual transform on the GPU. This balances memory use and avoids redrawing every time, which is too slow.

I would like to change this to render active layers at 1.0 scale at all times and do the entire transformation on the GPU. This avoids redrawing completely, but uses more texture memory and initial upload bandwidth. On the other hand, this is applied to active layers only, so we use more memory and bandwidth during the actual animation only. Once the animation stops, the active layer times out and is deleted and we redraw. Also it should be noted that in most cases we use much less total upload bandwidth, since we draw only once. The current patch doesn't try to exclude boundary conditions (e.g. very large textures animated to very small scales 0.1 .. 0.2 etc). The old code wasn't particularly good about that either. When going from 0 to 100% scale we would redraw a bunch of time at small scale which really doesn't make any sense what so ever since it doesn't save memory but it causes redraw churn.

This change provides much smoother scaling animations on desktop and in particular mobile. I discussed this with cjones. He thinks this approach is wrong, so I have my work cut out for me trying to convince him of the opposite.
Attached patch patch (obsolete) — Splinter Review
Assignee: nobody → gal
Attachment #619355 - Flags: review?(roc)
Attachment #619355 - Flags: feedback?(jones.chris.g)
When zooming out, I think this makes sense --- crappy downscaling in some cases, but OK. (Maybe it should be mobile-only for that case?) When zooming in, this could lead to arbitrarily bad rendering for vector graphics. So I'm not quite convinced. Maybe if you make the scale a minimum of 1.0 in each direction?

(In reply to Andreas Gal :gal from comment #0)
> The current patch doesn't try to exclude boundary conditions
> (e.g. very large textures animated to very small scales 0.1 .. 0.2 etc). The
> old code wasn't particularly good about that either. When going from 0 to
> 100% scale we would redraw a bunch of time at small scale which really
> doesn't make any sense what so ever since it doesn't save memory but it
> causes redraw churn.

We can tweak our existing heuristics to avoid that, e.g. avoid reducing the scaled texture size to below some minimum threshold.
Attached patch patchSplinter Review
Below 1.0 scale render at full resolution and scale by transforming the layer.
Attachment #619355 - Attachment is obsolete: true
Attachment #619355 - Flags: review?(roc)
Attachment #619355 - Flags: feedback?(jones.chris.g)
Comment on attachment 619443 [details] [diff] [review]
patch

roc, this does what you suggested (don't go below 1.0 scale). I tried this with vector content and it doesn't look too bad. This only kicks in while the content is animated. The moment the animation stops we redraw. Above 1.0 scale we stick to the old approach, which should work better for large scale corner cases.
Attachment #619443 - Flags: review?(roc)
Comment on attachment 619443 [details] [diff] [review]
patch

Review of attachment 619443 [details] [diff] [review]:
-----------------------------------------------------------------

OK, let's try this

::: gfx/thebes/gfxUtils.cpp
@@ +549,5 @@
>  
> +  gfxFloat scale = pow(kScaleResolution, power);
> +
> +  if (scale < 1.0)
> +      scale = 1.0;

use NS_MAX
Attachment #619443 - Flags: review?(roc) → review+
https://hg.mozilla.org/mozilla-central/rev/2e84edabd25b
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla15
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: