time | Calls | line |
---|
| | 1 | function [autoSwitch, userSpecifiedRenderer] = autoSwitchToPaintersForPrint(pj)
|
| | 2 | % This undocumented helper function is for internal use.
|
| | 3 |
|
| | 4 | % AUTOSWITCHTOPAINTERSFORPRINT
|
| | 5 | % Checks to see if we should use painters for output generation when
|
| | 6 | % producing vector output, based on heuristic implemented here
|
| | 7 | % Copyright 2014-2019 The MathWorks, Inc.
|
| | 8 |
|
< 0.001 | 12 | 9 | autoSwitch = false;
|
| | 10 | % becomes false if we don't exit early. Early exit triggered by:
|
| | 11 | % not vector format
|
| | 12 | % renderer was manually set (mode is manual)
|
| | 13 | % renderer was specified in print command
|
| | 14 | % renderer is already painters
|
< 0.001 | 12 | 15 | userSpecifiedRenderer = true;
|
| | 16 |
|
< 0.001 | 12 | 17 | exportHndl = pj.Handles{1};
|
0.003 | 12 | 18 | isVectorFormat = length(pj.Driver) > 1 && ...
|
| 12 | 19 | (strncmp(pj.Driver(1:2), 'ps', 2) || ...
|
| 12 | 20 | any(strncmp(pj.Driver(1:3), {'eps', 'met', 'pdf', 'svg'}, 3)));
|
| | 21 |
|
| | 22 | % We won't "auto switch" if
|
| | 23 | % ** not doing a vector format or
|
| | 24 | % ** renderer was specified in call to print, or
|
| | 25 | % ** user set figure's renderer (renderermode is 'manual'), or
|
| | 26 | % ** renderer is already set to 'painters'
|
< 0.001 | 12 | 27 | rendererProp = 'Renderer';
|
0.002 | 12 | 28 | if isa(exportHndl, 'matlab.graphics.primitive.Canvas') || ...
|
| 12 | 29 | isa(exportHndl, 'matlab.graphics.primitive.canvas.JavaCanvas') || ...
|
| 12 | 30 | isa(exportHndl, 'matlab.graphics.primitive.canvas.HTMLCanvas')
|
| | 31 | rendererProp = 'OpenGL';
|
< 0.001 | 12 | 32 | end
|
< 0.001 | 12 | 33 | if ~isVectorFormat || pj.rendererOption || ...
|
| | 34 | strcmp(exportHndl.([rendererProp 'Mode']), 'manual') || ...
|
| | 35 | any(strcmp(exportHndl.(rendererProp), {'painters', 'off'}))
|
< 0.001 | 12 | 36 | return;
|
| | 37 | end
|
| | 38 |
|
| | 39 | % not returning early, checking contents w/in heuristic
|
| | 40 | userSpecifiedRenderer = false;
|
| | 41 |
|
| | 42 | % use the heuristic to decide whether or not switch
|
| | 43 | % auto switch only if the scene isn't too complex
|
| | 44 |
|
| | 45 | % when exporting, and not printing, we might have a specified set of
|
| | 46 | % objects to export (print does entire figure). We only want to
|
| | 47 | % consider that specified set when deciding whether to autoswitch
|
| | 48 | if (isfield(pj, 'temp') || isprop(pj, 'temp')) && isfield(pj.temp, 'exportInclude') && ...
|
| | 49 | ~isempty(pj.temp.exportInclude)
|
| | 50 | exportHndl = setdiff(pj.temp.exportInclude, exportHndl);
|
| | 51 | end
|
| | 52 |
|
| | 53 | % first check if any axes use depth sorting (only care if the axes
|
| | 54 | % contents are visible since that would impact rendering)
|
| | 55 | ax = findobjinternal(exportHndl, 'type', 'axes', 'SortMethod', 'depth', 'ContentsVisible', 'on');
|
| | 56 | if ~isempty(ax)
|
| | 57 | % depth sorting in use, don't autoswitch g1736840
|
| | 58 | autoSwitch = false;
|
| | 59 | else
|
| | 60 | % none of the axes were using depth sorting, but still need to
|
| | 61 | % check for more complex figures. For example, figs w/large surfaces
|
| | 62 | % or large number of markers could result in time-consuming
|
| | 63 | % output generation and large output files.
|
| | 64 | checker = matlab.graphics.internal.PrintPaintersChecker.getInstance();
|
| | 65 | autoSwitch = ~checker.exceedsVertexLimits(exportHndl);
|
| | 66 | end
|
| | 67 | % if we still think we can/should auto switch, check to see if the
|
| | 68 | % figure uses transparency and, if so, whether the output format
|
| | 69 | % supports it (right now, PS/EPS don't support transparency
|
| | 70 | if autoSwitch && ~isempty(strfind(pj.Driver, 'ps'))
|
| | 71 | % if transparency, don't autoswitch
|
| | 72 | autoSwitch = ~hasTransparency(exportHndl, checker.DebugMode);
|
| | 73 | end
|
| | 74 |
|
| | 75 | % if we still think we can/should auto switch, check to see if there is
|
| | 76 | % any lighting involved, and don't autoSwitch if there is
|
| | 77 | if autoSwitch
|
| | 78 | autoSwitch = ~checker.exceedsLightingLimits(exportHndl);
|
| | 79 | end
|
| | 80 |
|
| | 81 | % if we still think we can/should auto switch, check to see if there is
|
| | 82 | % any surface with texturemap facecolor exist, and don't autoSwitch if
|
| | 83 | % it is going to be large output size (except PDF format) [g1651960]
|
| | 84 | if autoSwitch && ~contains(pj.Driver, 'pdf')
|
| | 85 | autoSwitch = ~checker.exceedsTextureLimits(exportHndl);
|
| | 86 | end
|
| | 87 |
|
| | 88 | % if we still think we can/should auto switch, check to see if there is
|
| | 89 | % trianglestrip/quadrilateral with texturemap/interp facecolor
|
| | 90 | % exceeds beyond certain limit[g1769901].
|
| | 91 | if autoSwitch
|
| | 92 | autoSwitch = ~checker.exceedsIntepolatedLimits(exportHndl);
|
| | 93 | end
|
| | 94 | end
|
Other subfunctions in this file are not included in this listing.