title: Graphics.Draw*, AutoScroll & Culling
body: <p>I've implemented a custom control in C#/Winforms which does things like syntax highlighting &amp; autocomplete.  I'm using AutoScroll to manage scrolling and it works nicely.</p>
  
  <p>Currently I have not optimized at all (sure optimization is important, but I'm doing that last; functionality is what I'm after first), I am rendering huge documents, and each keypress will re-parse the affected line to make sure syntax highlighting is consistent.</p>
  
  <p>Right now in my big meaty paint method, I am painting every string, keyword, etc, even if it is outside of the clip region.  But regardless of how big the document is &amp; how many combinations of keywords/highlighted bits &amp; pieces I have, it still runs bloody fast with not much memory &amp; CPU overhead.</p>
  
  <p>So my question - do the Graphics.Draw* methods do any kind of culling?  Eg: If the AutoScrollPosition is way down the document &amp; I Graphics.DrawString(<em>insert some coordinates outside the draw region</em>), is any actual work being done?  Also note I'm running VS on Win 7 inside a VM, and it is still running fast.  Not that it's an issue now, but it would be nice to keep in mind for later when it comes to the optimization phase. :D</p>
  
  <p>Cheers,
  Aaron</p>