DrawingPrimitives

From Apache OpenOffice Wiki
Revision as of 14:22, 1 September 2006 by Thorsten (Talk | contribs)

Jump to: navigation, search

The DrawingLayer, i.e. the engine providing the Draw/Impress content, which is reused in both Calc and Writer, currently undergoes substantial refactoring. This rework takes place in CWS aw033 (and partially in CWS aw024). Although the DrawingLayer was already usable as an engine, it had several shortcomings, among them no clear distinction between model and view (all model objects handled the viewing of their content themselves), lacking separation of concerns (lots of generally useful functionality was buried in the DrawingLayer code, instead of separated out into tooling libraries), and a hard-to-remove dependency on VCL's OutputDevice for rendering.

All three items will be addressed in CWS aw033, and the means for that are DrawingPrimitives. The mental model for these primitives are metafiles or display lists, i.e. resolution-independent representation of renderable geometry. DrawingPrimitives define a hierarchy of increasingly simpler geometric primitives, starting with fairly high-level ones like customShapePrimitive or captionPrimitive, down to simple ones like polyPolygonColorPrimitive. The high-level primitives have built-in support for breaking them up into simpler ones, which makes implementing a renderer for DrawingPrimitives quite easy (in a first step, one has to provide only support for a small set of very basic primitives, like bitmap and polygon).

Giving it a try

You can have a (preliminary) glance at how this works by building CWS aw033 (follow the link for informations on which milestone this is currently based, and which modules are branched). You'll further need to checkout the new module drawinglayer from CVS.

After the build is done, open up a Draw or Impress, insert some shapes, and toggle between old and new drawing layer via <Ctrl><Shift>-T (this already repaints the view, just like <Ctrl><Shift>-R).

Some code pointers:

  • drawinglayer/source/primitive for the basic primitives
  • svx/source/sdr/primitive for the high-level (shape-equivalent) primitives
  • svx/source/sdr/contact/objectcontactofpageview.cxx: DoProcessDisplay() for the main paint entry (and some funny flags)

Using XCanvas as the backend renderer

Having said all this, it's now fairly easy to have XCanvas used instead of OutputDevice. I've implemented a preliminary canvas renderer in drawinglayer/source/processor/canvasprocessor.cxx, which, when used, can finally display the Draw/Impress edit view anti-aliased:

Screenshot

Personal tools