Why does turning the visibility of a figure to "off" slow things down?

7 vues (au cours des 30 derniers jours)
Michael Mancinelli
Michael Mancinelli le 19 Nov 2015
Commenté : Mike Garrity le 23 Nov 2015
I have an application where turning the visibility of the figure off actually quadruples the run time of my program. I do a lot of axis and lighting manipulations between grabbing the screen.
Here is brief example that leads to a roughly 10% increase in time:
%%->> Visible ON<<-
tic
h = figure('Visible', 'On');
surf(peaks);
light;
axis([10 40 10 40 -5 5]);
h.Color = 'r';
view(45,45);
data = getframe();
toc
%%->>Visible OFF<<-
tic
h = figure('Visible', 'Off');
surf(peaks);
light;
axis([10 40 10 40 -5 5]);
h.Color = 'r';
view(45,45);
data = getframe();
toc
Basically, I would love an explanation as to why MATLAB acts any differently when the figure is not displayed!

Réponses (1)

Mike Garrity
Mike Garrity le 19 Nov 2015
They actually don't do the same thing at all.
In the Visible='on' case, the pixels are already sitting in the framebuffer on the graphics card. The getframe function just fetches them.
In the Visible='off' case, there is no framebuffer and the graphics haven't already been drawn. So the getframe command basically starts a print job. Printing is nearly as tightly optimized as on screen rendering because it supports lots of additional features that you're not using here. For one thing, it needs to allocate a number of resources which are basically free when you're drawing into the framebuffer.
  2 commentaires
Walter Roberson
Walter Roberson le 19 Nov 2015
Mike, is that "is nearly" or "is not nearly" ? The "is nearly" would imply that the timing should be very close, which the rest of your discussion seems to argue otherwise.
Mike Garrity
Mike Garrity le 23 Nov 2015
Yes, it looks like I lost track of a negation there. Sorry about that.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by