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