openblt

a hobby OS from the late 90s
git clone http://frotz.net/git/openblt.git
Log | Files | Refs | LICENSE

GraphicsContext.h (1400B)


      1 #ifndef _GRAPHICS_CONTEXT_H
      2 #define _GRAPHICS_CONTEXT_H
      3 
      4 #include "Renderer.h"
      5 #include "Region.h"
      6 
      7 class Window;
      8 
      9 class GraphicsContext {
     10 public:
     11 	
     12 	GraphicsContext();
     13 	Rect Bounds();
     14 
     15 	inline const Region& ClipRegion();
     16 	inline void SetClipRegion(const Region&);
     17 	inline void SetRenderer(Renderer*);
     18 	inline Renderer* GetRenderer();
     19 	inline void SetOrigin(int x, int y);
     20 	
     21 	void DrawLine(int, int, int, int);
     22 	void FillRect(int, int, int, int);
     23 	void Blit(int x, int y, char image[], int image_width,
     24 		int image_height, int img_bytes_per_row);    
     25 	void StretchBlit(Rect imageRect, Rect screenRect, char image[],
     26 		int img_bytes_per_row);
     27 	void CopyRect(Rect src, Rect dest, const Region &inCleanRegion,
     28 		Region &outNotCopied);	
     29 
     30 	void SetColor(char color);
     31 	void DrawString(int x, int y, const char *string);
     32 
     33 private:
     34 
     35 	Region fClipRegion;
     36 	Renderer *fRenderer;
     37 	char fCurrentColor;
     38 	int fXOrigin;
     39 	int fYOrigin;
     40 };
     41 
     42 	
     43 inline const Region& GraphicsContext::ClipRegion() 
     44 {
     45 	return fClipRegion;
     46 }
     47 
     48 inline void GraphicsContext::SetClipRegion(const Region &region)
     49 {
     50 	fClipRegion = region;
     51 	fClipRegion.ConstrainTo(fRenderer->Bounds());
     52 }
     53 
     54 inline void GraphicsContext::SetRenderer(Renderer *renderer)
     55 {
     56 	fRenderer = renderer;
     57 }
     58 
     59 inline Renderer* GraphicsContext::GetRenderer()
     60 {
     61 	return fRenderer;
     62 }
     63 
     64 inline void GraphicsContext::SetOrigin(int x, int y)
     65 {
     66 	fXOrigin = x;
     67 	fYOrigin = y;
     68 }
     69 
     70 
     71 #endif