Direct2D Implementation Progress

Alexandru Pana edited this page Aug 10, 2014 · 8 revisions
Clone this wiki locally

Week 1

  • Implemented solid color pens
  • Implemented solid color brushes
  • Implemented DrawRectangle and DrawRoundedRectangle methods.

Week 2

Graphics data objects:

  • Implementation of wxD2DPathData almost finished (some use cases require special handling).
  • Implemented wxD2DMatrixData
  • Added support for gradient (radial and linear) brushes in wxD2DBrushData

Context methods:

  • Implemented wxD2DContext::DrawEllipse
  • Implemented wxD2DContext::StrokePath
  • Implemented matrix methods: SetTransform, GetTransform, ConcatTransform, Translate, Scale and Rotate
  • Implemented Push and Pop state (which saves the quality settings and the transformation)
  • Implemented wxD2DContext::SetAntialiasMode
  • Implemented wxD2DContext::ShouldOffset
  • Added handling for handling pens with odd width (offset by 0.5)

Helper functions / classes:

  • Implemented CompositionMode conversion function (to be used later for image drawing)
  • Implemented InterpolationQuality conversion function (to be used later for image drawing)

Week 3

This week I mostly worked on fixing path-related problems and making the graphics context compatible with the draw sample. You can find some screenshots here: https://www.dropbox.com/sh/jyorwbvuphl7dxt/AAAqXsFlxpLY4NYRK8quFLnYa

Notice the main differences between GDI and D2D implementations are:

  • lack of hatch brushes / pens in Direct2D
  • Path problems due to API incompatibilities (current point resets at 0, 0)
  • Lack of text (not yet implemented)
  • Some missing shapes due to the fact that the shapes are rendered to an intermediate memory DC which is not yet implemented.

Week 4

Fixed various path related bugs and managed to get the sample looking right. Both the "circles" and the "splines" pages of the drawing sample have been affected.

Outlines appear stretched, because the current algorithm scales the canvas in order to draw an ellipse as a stretched circle.

Weeks 5, 6 and 7

University break

Week 8

  • Added support for bitmap brushes and pens (no support for masked bitmaps)
  • Researched the blending mechanism used by Direct2D for drawing bitmaps
  • Implemented rectangular clipping (no support for wxRegion)

Week 9

  • Added support for masked bitmaps
  • Added support for text rendering

Graphics data objects:

  • Implemented wxD2DFontData

Renderer methods:

  • Implemented wxD2DRenderer::CreateBitmapFromNativeBitmap
  • Implemented wxD2DRenderer::CreateBitmapFromImage
  • Implemented wxD2DRenderer::CreateImageFromBitmap
  • Implemented wxD2DRenderer::CreateFont which creates a font from a fontface name, size, flags and color
  • Implemented wxD2DRenderer::CreateFont which creates a graphics font from a wxFont and a wxColour

Context methods:

  • Implemented wxD2DContext::DrawIcon
  • Implemented wxD2DContext::DoDrawText
  • Initial implementation of wxD2DContext::GetTextExtent
  • Implemented hatch brushes

Bug fixes:

  • Fixed a series of transformation bugs caused by an improper matrix multiplication operation (the source and destination matrices were the same corrupting the result)

Week 10

  • Rewrote all the code that deals with direct2d resource acquisition and release so it's better organized, easier to reason about, more reliable and safe.
  • Added support for composition mode wxCOMPOSITION_DEST
  • Replaced all raw Direct2D pointers with CComPtr smart pointers and most other pointers to wxSharedPtr pointers
  • Fixed all warnings
  • Renamed classes and functions to conform with the "wx" prefix standard
  • Implemented lightweight measuring context
  • Implemented wxD2DPathData::Clone
  • Added support for the "descend" and "external leading" font metrics inside the GetTextExtent method

Context methods:

  • Implemented Clip(wxRegion)
  • Implemented CreateSubBitmap
  • Implemented BeginLayer and EndLayer methods
  • Implemented GetPartialTextExtents
  • Implemented CreateMeasuringContext
  • Implemented CreateContextFromNativeContext

Bug fixes:

  • Fixed a bug causing the wxD2DBitmapData destructor to fail by dereferencing an invalid pointer
  • Fixed a bug where wxD2DContext::GetTextExtent would not include trailing whitespace in the calculation of the width

Week 11 & Week 12

  • Implemented memory DC graphics context
  • Added more checks for direct2d HRESULTs
  • Implemented hatch style pens
  • Rebased with master