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

7 ビュー (過去 30 日間)
Michael Mancinelli
Michael Mancinelli 2015 年 11 月 19 日
コメント済み: Mike Garrity 2015 年 11 月 23 日
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!

回答 (1 件)

Mike Garrity
Mike Garrity 2015 年 11 月 19 日
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 件のコメント
Walter Roberson
Walter Roberson 2015 年 11 月 19 日
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 2015 年 11 月 23 日
Yes, it looks like I lost track of a negation there. Sorry about that.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by