[Alephmodular-devel] Drawing Contexts - CDContext
Status: Pre-Alpha
Brought to you by:
brefin
From: Br'fin <br...@ma...> - 2003-07-28 22:24:19
|
Yes, I know it's old and crusty in here. But I never know quite what to do aside from occasionally making some headway on the Display Abstraction. The general business I see CDContext dealing with will mainly be drawing lines, text, and filling areas. As such it will provide the support/features needed and provided by screen_drawing.cpp. As well as other areas where direct drawing commands are done upon a buffer. (For instance, asking a buffer to be erased/filled to a color) CDContext A CDContext, aka a Drawing Context, would own all of the high-level operations for operating on a buffer. For instance, using line primitives and displaying text. Some systems, such as Macintosh, use a method of drawing commands that works as follows. Store the current drawing context Use the desired graphics port as the context perform drawing operations Swap the ports back to where they were before. Modern systems are much more object orientated which helps also when dealing with threads and multiple processors. So we will have a CDContext for each buffer we wish to draw to. (However, each buffer will only have one context, but may have multiple copies of that context floating around (via reference counting)) In practice, using a CDContext would be like: std::auto_ptr<CDContext> context= CBuffer.get_drawing_context() context.draw_line... context.draw_text (context automatically freed) Since the Macintosh scheme currently uses Quickdraw, the existing Macintosh method predates multithreading and other modern issues. We should accept that the Carbon based drawing methods may have problems with performing drawing operations between sets of drawing contexts all at once. ( for instance: dc1.draw_line dc2.draw_line dc1.draw_line ) But that is probably fairly rare to begin with. And in the future may allow us to shift to a Quartz based drawing scheme. (Heh, anti-aliased text and map lines?) If a CBuffer already has an existing CDContext, then it should return the same drawing context. Hence, CDContext should be reference counted. Refer to the C++ faq for the basics: http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.21 -Jeremy Parsons |