1 /* 2 * Copyright 2006, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 */ 8 9 #ifndef ICON_RENDERER_H 10 #define ICON_RENDERER_H 11 12 #include <agg_gamma_lut.h> 13 #include <agg_pixfmt_rgba.h> 14 #include <agg_rasterizer_compound_aa.h> 15 #include <agg_rendering_buffer.h> 16 #include <agg_renderer_scanline.h> 17 #include <agg_scanline_bin.h> 18 #include <agg_scanline_u.h> 19 #include <agg_span_allocator.h> 20 #include <agg_trans_affine.h> 21 22 class BBitmap; 23 class BRect; 24 class Icon; 25 26 typedef agg::gamma_lut 27 <agg::int8u, agg::int8u> GammaTable; 28 29 typedef agg::rendering_buffer RenderingBuffer; 30 typedef agg::pixfmt_bgra32 PixelFormat; 31 typedef agg::pixfmt_bgra32_pre PixelFormatPre; 32 typedef agg::renderer_base<PixelFormat> BaseRenderer; 33 typedef agg::renderer_base<PixelFormatPre> BaseRendererPre; 34 35 typedef agg::scanline_u8 Scanline; 36 typedef agg::scanline_bin BinaryScanline; 37 typedef agg::span_allocator<agg::rgba8> SpanAllocator; 38 typedef agg::rasterizer_compound_aa 39 <agg::rasterizer_sl_clip_dbl> CompoundRasterizer; 40 41 typedef agg::trans_affine Transformation; 42 43 class IconRenderer { 44 public: 45 IconRenderer(BBitmap* bitmap); 46 virtual ~IconRenderer(); 47 48 void SetIcon(const Icon* icon); 49 50 void Render(); 51 void Render(const BRect& area); 52 53 void SetScale(double scale); 54 void SetBackground(const BBitmap* background); 55 // background is not copied, 56 // ownership stays with the caller 57 // colorspace and size need to 58 // be the same as bitmap passed 59 // to constructor 60 void SetBackground(const agg::rgba8& color); 61 // used when no background bitmap 62 // is set 63 64 const ::GammaTable& GammaTable() const 65 { return fGammaTable; } 66 67 void Demultiply(); 68 69 private: 70 void _Render(const BRect& area); 71 72 BBitmap* fBitmap; 73 const BBitmap* fBackground; 74 agg::rgba8 fBackgroundColor; 75 const Icon* fIcon; 76 77 ::GammaTable fGammaTable; 78 79 RenderingBuffer fRenderingBuffer; 80 PixelFormat fPixelFormat; 81 PixelFormatPre fPixelFormatPre; 82 BaseRenderer fBaseRenderer; 83 BaseRendererPre fBaseRendererPre; 84 85 Scanline fScanline; 86 BinaryScanline fBinaryScanline; 87 SpanAllocator fSpanAllocator; 88 89 CompoundRasterizer fRasterizer; 90 91 Transformation fGlobalTransform; 92 }; 93 94 #endif // ICON_RENDERER_H 95