This is a static copy of a profile report

Home

printing/private/modifyColorsForPrint (Calls: 22, Time: 1.407 s)
Generated 16-Jul-2020 17:09:31 using performance time.
function in file /Applications/MATLAB_R2020a.app/toolbox/matlab/graphics/printing/private/modifyColorsForPrint.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
...tChanges>localUpdateColorsIfNeededsubfunction22
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
70
adjustbackground('save', h);
121.151 s81.8%
85
adjustbackground('restore', h)...
100.250 s17.8%
68
if strcmp('on', get(h,'InvertH...
120.002 s0.2%
20
if strcmp(invertRevertFlag, 'i...
220.000 s0.0%
75
varargout = {modified, inverte...
120.000 s0.0%
All other lines  0.003 s0.2%
Totals  1.407 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
printing/private/adjustbackgroundfunction221.400 s99.5%
Self time (built-ins, overhead, etc.)  0.006 s0.5%
Totals  1.407 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function91
Non-code lines (comments, blank lines)45
Code lines (lines that can run)46
Code lines that did run28
Code lines that did not run18
Coverage (did run/can run)60.87 %
Function listing
time 
Calls 
 line
   1 
function varargout = modifyColorsForPrint(invertRevertFlag, varargin)
   2 
% MODIFYCOLORSFORPRINT Modify a figure's colors for printing based on
   3 
% preference settings for figure copy options.  This undocumented helper
   4 
% function is for internal use.
   5 

   6 
% This function is called during the print path.  See usage in
   7 
% alternatePrintPath.m
   8 
    
   9 
% MODIFYCOLORSFORPRINT('invert', h, honorColorPrefs,
  10 
% outputRendererIsPainters, outputBitmap, figbkcolorpref) can be used to
  11 
% invert the colors based on the arguments.  The return will be:
  12 
% [modified, invertedFlag, originalColor].  The invertedFlag and
  13 
% originalColor can be used when calling this function to 'revert'.
  14 

  15 
% MODIFYCOLORSFORPRINT('revert', h, invertedFlag, origColor) reverts the
  16 
% colors to their original values, before 'invert' was called.
  17 
    
  18 
%   Copyright 2013 The MathWorks, Inc.
  19 

< 0.001 
     22 
  20
    if strcmp(invertRevertFlag, 'invert') && length(varargin) == 5 
< 0.001 
     12 
  21
        h = varargin{1}; 
< 0.001 
     12 
  22
        honorColorPrefs = varargin{2}; 
< 0.001 
     12 
  23
        outputRendererIsPainters = varargin{3}; 
< 0.001 
     12 
  24
        outputBitmap = varargin{4}; 
< 0.001 
     12 
  25
        figbkcolorpref = varargin{5}; 
  26 
        
< 0.001 
     12 
  27
        modified = false; 
< 0.001 
     12 
  28
        inverted = 0; 
< 0.001 
     12 
  29
        origColor = []; 
  30 
        
< 0.001 
     12 
  31
        if honorColorPrefs 
  32 
            % if called from Edit->Copy Figure, check what figure
  33 
            % background setting is in place from Edit->Copy Options.  The
  34 
            % result of the copy is also dependent on the renderer and the
  35 
            % format selected.
  36 
            
  37 
            % figbkcolor will be one of the following:
  38 
            %    0 == 'none' (transparent)
  39 
            %    1 == white
  40 
            %    2 == use figure background
  41 
            
  42 
            switch figbkcolorpref
  43 
                case 0  % none/transparent background
  44 
                    if outputRendererIsPainters && ~outputBitmap
  45 
                        % Can produce transparent background
  46 
                        inverted = 2;
  47 
                        origColor = LocalColorNone(h);
  48 
                    else
  49 
                        % The user has selected transparent background, but
  50 
                        % we can't produce it either because of the
  51 
                        % renderer or the output format.  Either way,
  52 
                        % instead of creating output with black background,
  53 
                        % set it to white
  54 
                        inverted = 1;
  55 
                        adjustbackground('save', h);
  56 
                    end
  57 
                    modified = true;
  58 
                    
  59 
                case 1  % white background
  60 
                    inverted = 1;
  61 
                    adjustbackground('save', h);
  62 
                    modified = true;
  63 
                    
  64 
                case 2  % figure background
  65 
                    % Nothing to do in this case
  66 
            end
< 0.001 
     12 
  67
        else 
  0.002 
     12 
  68
            if strcmp('on', get(h,'InvertHardcopy')) 
< 0.001 
     12 
  69
                inverted = 1; 
  1.151 
     12 
  70
                adjustbackground('save', h); 
< 0.001 
     12 
  71
                modified = true; 
< 0.001 
     12 
  72
            end 
< 0.001 
     12 
  73
        end 
  74 
        
< 0.001 
     12 
  75
        varargout = {modified, inverted, origColor}; 
< 0.001 
     10 
  76
    elseif strcmp(invertRevertFlag, 'revert') 
< 0.001 
     10 
  77
        h = varargin{1}; 
< 0.001 
     10 
  78
        inverted = varargin{2}; 
< 0.001 
     10 
  79
        origColor = varargin{3}; 
  80 
        
  81 
        % Invert back the toner saving/colornone color changes
< 0.001 
     10 
  82
        switch inverted 
< 0.001 
     10 
  83
            case 1 
  84 
                % inverthardcopy == true
  0.250 
     10 
  85
                adjustbackground('restore', h); 
  86 
            case 2
  87 
                % print w/transparent background == true (edit->CopyOptions)
  88 
                LocalColorNone(h, origColor);
< 0.001 
     10 
  89
        end 
< 0.001 
     22 
  90
    end 
< 0.001 
     22 
  91
end 

Other subfunctions in this file are not included in this listing.