Last Comment Bug 750006 - render active layers at full scale and transform them on the GPU
: render active layers at full scale and transform them on the GPU
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Graphics: Layers (show other bugs)
: Trunk
: x86 Mac OS X
: -- normal (vote)
: mozilla15
Assigned To: Andreas Gal :gal
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-28 19:56 PDT by Andreas Gal :gal
Modified: 2012-05-01 16:36 PDT (History)
7 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
patch (3.30 KB, patch)
2012-04-28 19:56 PDT, Andreas Gal :gal
no flags Details | Diff | Splinter Review
patch (1.59 KB, patch)
2012-04-29 13:44 PDT, Andreas Gal :gal
roc: review+
Details | Diff | Splinter Review

Description Andreas Gal :gal 2012-04-28 19:56:03 PDT
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.
Comment 1 Andreas Gal :gal 2012-04-28 19:56:25 PDT
Created attachment 619355 [details] [diff] [review]
patch
Comment 2 Robert O'Callahan (:roc) (Exited; email my personal email if necessary) 2012-04-28 22:05:21 PDT
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.
Comment 3 Andreas Gal :gal 2012-04-29 13:44:55 PDT
Created attachment 619443 [details] [diff] [review]
patch

Below 1.0 scale render at full resolution and scale by transforming the layer.
Comment 4 Andreas Gal :gal 2012-04-29 13:47:22 PDT
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.
Comment 5 Robert O'Callahan (:roc) (Exited; email my personal email if necessary) 2012-04-29 14:16:41 PDT
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
Comment 8 Chris Jones [:cjones] inactive; ni?/f?/r? if you need me 2012-04-30 15:45:15 PDT
Is this the same thing as bug 711997?

Note You need to log in before you can comment on or make changes to this bug.