Tech Off Thread

5 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

gdi+ hardware acceleration

Back to Forum: Tech Off
  • User profile image

    Is there a future for hardware acceleration and gdi+ ? anything planned ?


  • User profile image

    Other than optimalizations with GDI compatibility mode in Avalon, I don't think there will be any effort in it. The same as Avalon will use GDI compatibility mode in XP.

    GDI is all about in-memory manipulation of bitmaps... Those manipulations reside in the 2D parts of a video card, and some card manufacturers provide better hardware acceleration than others (Matrox is regarded as the fastest in 2D manipulations). So in that sense GDI is allready hardware accelerated.

    But the future is all about scalability (different screen sizes, DPI's) so bitmap based interfaces will face shortcomings with scaling. Vectorization addresses this. So get prepared to forget everything about GDI in the next 5 years.


  • User profile image

       GDI is hardware accelerated. GDI+ however, is not. I don't know the exact answer, but I'm reasonably sure I read somewhere that the hardware-driver changes required would be present in Longhorn but not before.

    Don't quote me on that though Wink


  • User profile image
    Frank Hileman

    GDI+ apparently uses GDI internally sometimes, so  there may be some acceleration.

    There is one library that optimizes GDI+ graphics, using all kinds of tricks to make it fast:

  • User profile image
    Mike Dimmick

    Frank Hileman wrote:
    GDI+ apparently uses GDI internally sometimes, so there may be some acceleration.

    Make that 'a heck of a lot'. First, you can barely draw on Windows without going through GDI - the alternative is to go through DirectX, and you can't mix-and-match (IIRC). GDI+ is designed to interop with GDI. GDI+ is a wrapper on top of GDI - with a nicer API, and a boatload of helper functions.

    >dumpbin /imports gdiplus.dll

    [...bunch of kernel32.dll, user32.dll imports...]

                  4EC51050 Import Address Table
                  4EDC2F5C Import Name Table
                  FFFFFFFF time date stamp
                  FFFFFFFF Index of first forwarder reference

          77F1A147    169 GetDIBColorTable
          77F1A719     E8 FillRgn
          77F1EDD8    22F SetMiterLimit
          77F15FD5     50 CreateSolidBrush
          77F447F7    24C StrokePath
          77F2E858    183 GetGraphicsMode
          77F1ED14    234 SetPolyFillMode
          77F44884     E7 FillPath
          77F266C9    24B StrokeAndFillPath
          77F44C75    1EA PolyPolyline
          77F43213    194 GetNearestPaletteIndex
          77F19012     DD ExtTextOutA
          77F180F0    1AE GetTextCharsetInfo
          77F19F44    250 TranslateCharsetInfo
          77F265AD    1EF PolylineTo
          77F1A781    1EE Polyline
          77F19D07    1CD LineTo
          77F2FB94    165 GetCurrentPositionEx
          77F43947      C ArcTo
          77F1EEF6    211 SetArcDirection
          77F25307    20B SelectClipPath
          77F449DC    19B GetPath
          77F26649     1D CloseFigure
          77F44749      1 AbortPath
          77F447A0     EA FlattenPath
          77F44911    256 WidenPath
          77F24C4B     11 BeginPath
          77F1C83B     94 Ellipse
          77F437A9      8 AngleArc
          77F26500    1E6 PolyBezierTo
          77F44D09    1E5 PolyBezier
          77F3B486    201 RoundRect
          77F44DBB    1E7 PolyDraw
          77F3BEA4    1DF Pie
          77F43A07     19 Chord
          77F4385B      B Arc
          77F24CCB     99 EndPath
          77F25449    1D3 OffsetClipRgn
          77F1A5E9    1A4 GetRgnBox
          77F1A208     21 CombineRgn
          77F3BFDA    230 SetPaletteEntries
          77F43223    1FF ResizePalette
          77F18665     D7 ExcludeClipRect
          77F19C60    1D1 MoveToEx
          77F2453F    1E0 PlayEnhMetaFile
          77F49513    1C1 GetWinMetaFileBits
          77F43AF3    1E4 PlgBlt
          77F16DC0     12 BitBlt
          77F2F27C    1D5 OffsetViewportOrgEx
          77F1C6FC    249 StretchBlt
          77F3C352    208 ScaleViewportExtEx
          77F3C433    209 ScaleWindowExtEx
          77F1DF84     22 CombineTransform
          77F3C6B0    22C SetMapperFlags
          77F19B6C     47 CreatePen
          77F1B52C     33 CreateDIBitmap
          77F1B4D2     46 CreatePatternBrush
          77F176B1     DC ExtSelectClipRgn
          77F2BDD5    14D GetBkMode
          77F18120    1AB GetTextAlign
          77F1BC60    1D0 ModifyWorldTransform
          77F1AC3B     D9 ExtCreateRegion
          77F16E51     2C CreateCompatibleBitmap
          77F18E07    193 GetNearestColor
          77F19D5F    238 SetStretchBltMode
          77F1B8B7    24A StretchDIBits
          77F19921    23A SetTextAlign
          77F1E190    23D SetTextJustification
          77F44BD0    1E9 PolyPolygon
          77F2C860    1E3 PlayMetaFileRecord
          77F1F77C     D8 ExtCreatePen
          77F1D2E9    1C4 GetWorldTransform
          77F1C6A8    19F GetROP2
          77F1A990    235 SetROP2
          77F1BACF    1F6 Rectangle
          77F1D1EE    1ED Polygon
          77F16899    1C7 IntersectClipRect
          77F18834    219 SetBrushOrgEx
          77F16917    161 GetClipRgn
          77F178DC    20C SelectClipRgn
          77F184D4    14C GetBkColor
          77F18528    1AF GetTextColor
          77F2E923     48 CreatePenIndirect
          77F18323    197 GetObjectW
          77F1BFE7     51 DPtoLP
          77F3AFC5     31 CreateDIBPatternBrushPt
          77F17EC6     DE ExtTextOutW
          77F19B4D    213 SetBitmapBits
          77F1D6AC    21E SetDIBColorTable
          77F2AFC7     38 CreateEnhMetaFileW
          77F2BA1D     F4 GdiComment
          77F1E3AC    190 GetMetaFileW
          77F42956    18E GetMetaFileA
          77F19884    207 SaveDC
          77F194AD    243 SetWindowOrgEx
          77F17988    23F SetViewportOrgEx
          77F1C484    224 SetGraphicsMode
          77F1C54F    244 SetWorldTransform
          77F1E403    177 GetEnhMetaFileW
          77F494A4    170 GetEnhMetaFileA
          77F2EAD0    171 GetEnhMetaFileBits
          77F27E70     23 CopyEnhMetaFileA
          77F2433D     25 CopyMetaFileA
          77F2E745     8E DeleteMetaFile
          77F1DFA3    174 GetEnhMetaFileHeader
          77F2E9EE    22D SetMetaFileBitsEx
          77F27C0C    222 SetEnhMetaFileBits
          77F2C556     37 CreateEnhMetaFileA
          77F1A8F7    22B SetMapMode
          77F2E45F    23E SetViewportExtEx
          77F2E3B6    242 SetWindowExtEx
          77F2DFF1    1E2 PlayMetaFile
          77F2B662     1C CloseEnhMetaFile
          77F1DCC0     8D DeleteEnhMetaFile
          77F1E21F    22E SetMetaRgn
          77F2E8BB    18F GetMetaFileBitsEx
          77F2DD1A     D1 EnumMetaFile
          77F1E3E9     C8 EnumEnhMetaFile
          77F1EF66    1E1 PlayEnhMetaFileRecord
          77F197BE    200 RestoreDC
          77F15FF1    1A5 GetStockObject
          77F1601F     27 CreateBitmap
          77F15BA7    23C SetTextColor
          77F15C59    215 SetBkColor
          77F15D0B    216 SetBkMode
          77F18DD7     45 CreatePalette
          77F1D55B    1A9 GetSystemPaletteEntries
          77F2FE5B    1AA GetSystemPaletteUse
          77F158A2    16B GetDeviceCaps
          77F20979     DA ExtEscape
          77F17FA3    196 GetObjectType
          77F1D35B    19C GetPixel
          77F16A3B     8F DeleteObject
          77F182DE    20F SelectPalette
          77F1CA0C    1B9 GetTextFaceA
          77F1A821    1BC GetTextMetricsA
          77F1B079    1BB GetTextFaceW
          77F17BF5    1BD GetTextMetricsW
          77F3EAA1     CA EnumFontFamiliesExA
          77F2F690     CB EnumFontFamiliesExW
          77F159A0    20E SelectObject
          77F18BBA     3D CreateFontIndirectW
          77F1D10C     3A CreateFontIndirectA
          77F19B24    1A2 GetRegionData
          77F16CA6     8C DeleteDC
          77F1CE55     2E CreateDCA
          77F1CF18     41 CreateICA
          77F175C3     4B CreateRectRgn
          77F19B03    1A0 GetRandomRgn
          77F18195    1CB LPtoDP
          77F17AB5    1C2 GetWindowExtEx
          77F17B2D    1BF GetViewportExtEx
          77F1ABC8    1C3 GetWindowOrgEx
          77F17A3D    1C0 GetViewportOrgEx
          77F1AB59    18D GetMapMode
          77F1BB9E    225 SetICMMode
          77F27FBB     D4 Escape
          77F19C31    167 GetDCOrgEx
          77F19A82    195 GetObjectA
          77F182A1    164 GetCurrentObject
          77F19FC5    16A GetDIBits
          77F15E10     2D CreateCompatibleDC
          77F19610     32 CreateDIBSection
          77F1BD89    1F3 RealizePalette
          77F1CDEF    19A GetPaletteEntries
          77F157BE    11B GdiFlush
          77F186B0    1DD PatBlt
          77F1AA29     29 CreateBrushIndirect
          77F1B3A1    21F SetDIBits

    Most of the drawing calls should be accelerated, although some GDI+ operations have to be broken down into the primitives that can be accelerated (for example, gradient brushes are not offered by GDI, so I presume GDI+ either works out a big area of gradient and calls CreatePatternBrush, or works out the area to be painted in each discrete colour and makes a call to Polygon). The choice of what's accelerated is down to the video card driver anyway - it declares to GDI what it supports, but has the option of telling GDI that a call is too complex for it, which causes GDI to break the operation down into smaller steps.

    Interesting to see that some piece of code calls GetRandomRgn. I remember noticing this oddly named function some time in early 2000 and guessing, from the then rather unclear documentation, that it was previously undocumented. Sure enough, looking back through earlier MSDN Library CDs, I saw that it had recently been added to the documentation set. It appears that the window's reported update region isn't actually clipped to what's currently visible - using this API can further minimize how much drawing you need to do. Reducing your drawing just to what's visible and needs to be updated can seriously speed up your drawing code - what's the point in drawing something if it's currently off the screen? The cost is usually greater complexity in working out what needs to be drawn, and is a tradeoff - is it more expensive to compute the exact set of objects to draw, or just to draw them regardless?

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.