The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
4.0KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef __JUCE_LOWLEVELGRAPHICSSOFTWARERENDERER_JUCEHEADER__
  18. #define __JUCE_LOWLEVELGRAPHICSSOFTWARERENDERER_JUCEHEADER__
  19. #include "juce_LowLevelGraphicsContext.h"
  20. #include "../native/juce_RenderingHelpers.h"
  21. //==============================================================================
  22. /**
  23. A lowest-common-denominator implementation of LowLevelGraphicsContext that does all
  24. its rendering in memory.
  25. User code is not supposed to create instances of this class directly - do all your
  26. rendering via the Graphics class instead.
  27. */
  28. class JUCE_API LowLevelGraphicsSoftwareRenderer : public LowLevelGraphicsContext
  29. {
  30. public:
  31. //==============================================================================
  32. LowLevelGraphicsSoftwareRenderer (const Image& imageToRenderOnto);
  33. LowLevelGraphicsSoftwareRenderer (const Image& imageToRenderOnto, Point<int> origin,
  34. const RectangleList& initialClip);
  35. ~LowLevelGraphicsSoftwareRenderer();
  36. bool isVectorDevice() const override;
  37. void setOrigin (int x, int y) override;
  38. void addTransform (const AffineTransform&) override;
  39. float getScaleFactor() override;
  40. bool clipToRectangle (const Rectangle<int>&) override;
  41. bool clipToRectangleList (const RectangleList&) override;
  42. void excludeClipRectangle (const Rectangle<int>&) override;
  43. void clipToPath (const Path&, const AffineTransform&) override;
  44. void clipToImageAlpha (const Image&, const AffineTransform&) override;
  45. bool clipRegionIntersects (const Rectangle<int>&) override;
  46. Rectangle<int> getClipBounds() const override;
  47. bool isClipEmpty() const override;
  48. void saveState() override;
  49. void restoreState() override;
  50. void beginTransparencyLayer (float opacity) override;
  51. void endTransparencyLayer() override;
  52. void setFill (const FillType&) override;
  53. void setOpacity (float opacity) override;
  54. void setInterpolationQuality (Graphics::ResamplingQuality) override;
  55. void fillRect (const Rectangle<int>&, bool replaceExistingContents) override;
  56. void fillPath (const Path&, const AffineTransform&) override;
  57. void drawImage (const Image&, const AffineTransform&) override;
  58. void drawLine (const Line <float>&) override;
  59. void drawVerticalLine (int x, float top, float bottom) override;
  60. void drawHorizontalLine (int x, float top, float bottom) override;
  61. void setFont (const Font&) override;
  62. const Font& getFont() override;
  63. void drawGlyph (int glyphNumber, const AffineTransform&) override;
  64. const Image& getImage() const noexcept { return savedState->image; }
  65. const RenderingHelpers::TranslationOrTransform& getTransform() const noexcept { return savedState->transform; }
  66. protected:
  67. RenderingHelpers::SavedStateStack <RenderingHelpers::SoftwareRendererSavedState> savedState;
  68. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LowLevelGraphicsSoftwareRenderer)
  69. };
  70. #endif // __JUCE_LOWLEVELGRAPHICSSOFTWARERENDERER_JUCEHEADER__