From b42918e0271e66829cd630dedfe12a81e0281aec Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 8 Sep 2013 03:17:01 +0200 Subject: doc/Implementation/AWTPrinting: Update to match latest code --- doc/Implementation/AWTPrinting.txt | 67 ++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 21 deletions(-) diff --git a/doc/Implementation/AWTPrinting.txt b/doc/Implementation/AWTPrinting.txt index 0be3848ed..85cf8bb90 100644 --- a/doc/Implementation/AWTPrinting.txt +++ b/doc/Implementation/AWTPrinting.txt @@ -1,28 +1,57 @@ Screenshots of unit tests: - + Unit test producing the results: - - -GLCanvas Print code: - + Base Test Class: + + AWT: + + Swing: + + +Print code: + AWTTilePainter (common code): + + GLCanvas: + + ... +++ Enhance lifecycle for AWT printing via AWTPrintLifecycle: -Low-res print at 72dpi leaves the frame untouched, -where high-res print at 300dpi increases the frame size -to the reverse scale-factor. +We fit the frame into the imageable area with for 72 dpi, +assuming that is the default AWT painting density. +The frame borders are considered. + +The frame's scale factor 'scaleComp72' is used for the graphics print matrix +of the overall print-job, hence no frame resize is required. + +The GL scale factor 'scaleGLMatXY', 72dpi/glDPI, is passed to the GL object +which locally scales the print matrix and renders the scene with 1/scaleGLMatXY pixels. -Before printing and optional resize, we setup the GLCanvas: +Before printing, we setup the GLCanvas, ..: - move GLContext and GLEventListener -> offscreen - - destroy onscreen component w/ size equals of tile-size - This steps allows us to ensure we use limited GPU resources. -this is done w/ setupPrint(). + - offscreen is of tile-size + +this is performed w/ AWTPrintLifecycle.setupPrint(..). Impl. in GLCanvas, etc. -After printing, releasePrint() shall be called. Impl. in GLCanvas .. etc. +After printing, AWTPrintLifecycle.releasePrint() shall be called. Impl. in GLCanvas .. etc. + +To perform AWTPrintLifecycle on all component in one container, +one may use: + + final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(frame, g2d, scaleGLMatXY, scaleGLMatXY); + try { + AWTEDTExecutor.singleton.invoke(true, new Runnable() { + public void run() { + frame.printAll(g2d); + } }); + } finally { + ctx.releasePrint(); + } + +++ @@ -41,13 +70,9 @@ TileRendererBase.TileRendererNotify interface! +++ -Screenshots/Bugs: - -You see the black raster, which shows each rendered tile. - -As you can see, we have different results w/ onscreen and offscreen -AWT printing. Both expose bugs regarding layout/scale of the AWT components. +Bugs: + - None in results -It would be interesting to learn what I am doing wrong w/ the printing setup -or GLCanvas rendering at print. + - GLCanvas: Workaround bug where onscreen MSAA cannot switch to offscreen FBO, + i.e. stay 'onscreen' -- cgit v1.2.3