office-gobmx/drawinglayer
Bartosz Kosiorek 33d2cf7008 WMF Change the sign of read fields in BITBLT and DIB records
Additionally the names of variables were improved,
and additional checks were added for unsupported cases
Change-Id: Id84ef1218c5c2a40c8d01f2d40857d892badbb9f

Change-Id: I1b8571d0a627827bc1e67c2bfc6c1932d58c5233
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116744
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
2021-06-05 20:20:24 +02:00
..
inc no need to allocate this separately 2021-05-30 20:18:52 +02:00
qa/unit properly draw only parts of FillGradientPrimitive2D (tdf#139000) 2021-05-21 16:53:21 +02:00
source WMF Change the sign of read fields in BITBLT and DIB records 2021-06-05 20:20:24 +02:00
CppunitTest_drawinglayer_border.mk
CppunitTest_drawinglayer_processors.mk properly draw only parts of FillGradientPrimitive2D (tdf#139000) 2021-05-21 16:53:21 +02:00
drawinglayer.component
IwyuFilter_drawinglayer.yaml
Library_drawinglayer.mk
Makefile
Module_drawinglayer.mk add a unittest for impress drawing a dotted line in tdf#136957 2021-05-06 11:23:11 +02:00
README.md createPixelProcessor2DFromOutputDevice won't return null 2021-04-28 21:37:43 +02:00

Drawing API

Drawing API that can specify what to draw via a kind of display list.

Example of the DrawingLayer use is eg. in svx/source/xoutdev/xtabhtch.cxx:121. A stripped down version with extended comments:

 // Create a hatch primitive (here a rectangle that will be filled with
 // the appropriate hatching, but has no border).
 // This will not draw it yet; it's so far only constructed to add it to a
 // display list later.
 const drawinglayer::primitive2d::Primitive2DReference aHatchPrimitive(
     new drawinglayer::primitive2d::PolyPolygonHatchPrimitive2D(...));

 // Create a rectangle around the hatch, to give it a border.
 const drawinglayer::primitive2d::Primitive2DReference aBlackRectanglePrimitive(
     new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(...));

 // Here we want to render to a virtual device (to later obtain the bitmap
 // out of that), so prepare it.
 VirtualDevice aVirtualDevice;

 // Create processor and draw primitives, to get it ready for rendering.
 std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(
     drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(...));

 // Fill-in the display list.
 drawinglayer::primitive2d::Primitive2DSequence aSequence(2);

 aSequence[0] = aHatchPrimitive;
 aSequence[1] = aBlackRectanglePrimitive;

 // Render it to the virtual device.
 pProcessor2D->process(aSequence);
 pProcessor2D.reset();

 // Obtain the bitmap that was rendered from the virtual device, to re-use
 // it in the widget.
 aRetval = aVirtualDevice.GetBitmap(Point(0, 0), aVirtualDevice.GetOutputSizePixel());

DrawingLayer Glossary

Primitives - classes that represent what should be drawn. It holds the data what to draw, but does not contain any kind of the rendering. Some of the primitives are 'Basic primitives', that are primitives that cannot be decomposed. The rest of the primitives can be decomposed to the basic primitives.

Decomposition - a way how to break down the more complicated primitives into the basic primitives, and represent them via them; this logically makes the plain Primitive2DSequence display list a hierarchy. Eg. PolygonMarkerPrimitive2D can be decomposed to 2 hairlines PolyPolygonHairlinePrimitive2D's, each with different color.

Processor - a class that goes through the hierarchy of the Primitives, and renders it some way. Various processors, like VclPixelProcessor2D (renders to the screen), VclMetafileProcessor2D (renders to the VCL metafile, eg. for printing), etc.

How to Implement a New Primitive ("Something New to Draw")

  • Create an ancestor of BasePrimitive2D (or of its ancestor if it fits the purpose better)

    • Assign it an ID [in drawinglayer_primitivetypes2d.hxx]

    • Implement its decomposition [virtual Primitive2DSequence create2DDecomposition(...)]

  • Extend the (various) processor(s) If you need more than relying on just the decomposition

Where is DrawingLayer Used

  • SdrObject(s) (rectangles, Circles, predefined shapes etc.)

  • Selections

  • Various smaller cases to 'just draw something'

    • Draw to a virtual device, and use the resulting bitmap (like the example above)
  • Custom widgets (like the Header / Footer indicator button)