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.

127 lines
4.6KB

  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_LOWLEVELGRAPHICSPOSTSCRIPTRENDERER_H_INCLUDED
  18. #define JUCE_LOWLEVELGRAPHICSPOSTSCRIPTRENDERER_H_INCLUDED
  19. #include "juce_LowLevelGraphicsContext.h"
  20. //==============================================================================
  21. /**
  22. An implementation of LowLevelGraphicsContext that turns the drawing operations
  23. into a PostScript document.
  24. */
  25. class JUCE_API LowLevelGraphicsPostScriptRenderer : public LowLevelGraphicsContext
  26. {
  27. public:
  28. //==============================================================================
  29. LowLevelGraphicsPostScriptRenderer (OutputStream& resultingPostScript,
  30. const String& documentTitle,
  31. int totalWidth,
  32. int totalHeight);
  33. ~LowLevelGraphicsPostScriptRenderer();
  34. //==============================================================================
  35. bool isVectorDevice() const override;
  36. void setOrigin (int x, int y) override;
  37. void addTransform (const AffineTransform&) override;
  38. float getScaleFactor() override;
  39. bool clipToRectangle (const Rectangle<int>&) override;
  40. bool clipToRectangleList (const RectangleList<int>&) override;
  41. void excludeClipRectangle (const Rectangle<int>&) override;
  42. void clipToPath (const Path&, const AffineTransform&) override;
  43. void clipToImageAlpha (const Image&, const AffineTransform&) override;
  44. void saveState() override;
  45. void restoreState() override;
  46. void beginTransparencyLayer (float) override;
  47. void endTransparencyLayer() override;
  48. bool clipRegionIntersects (const Rectangle<int>&) override;
  49. Rectangle<int> getClipBounds() const override;
  50. bool isClipEmpty() const override;
  51. //==============================================================================
  52. void setFill (const FillType&) override;
  53. void setOpacity (float) override;
  54. void setInterpolationQuality (Graphics::ResamplingQuality) override;
  55. //==============================================================================
  56. void fillRect (const Rectangle<int>&, bool replaceExistingContents) override;
  57. void fillPath (const Path&, const AffineTransform&) override;
  58. void drawImage (const Image&, const AffineTransform&) override;
  59. void drawLine (const Line <float>&) override;
  60. void drawVerticalLine (int x, float top, float bottom) override;
  61. void drawHorizontalLine (int x, float top, float bottom) override;
  62. //==============================================================================
  63. const Font& getFont() override;
  64. void setFont (const Font&) override;
  65. void drawGlyph (int glyphNumber, const AffineTransform&) override;
  66. protected:
  67. //==============================================================================
  68. OutputStream& out;
  69. int totalWidth, totalHeight;
  70. bool needToClip;
  71. Colour lastColour;
  72. struct SavedState
  73. {
  74. SavedState();
  75. ~SavedState();
  76. RectangleList<int> clip;
  77. int xOffset, yOffset;
  78. FillType fillType;
  79. Font font;
  80. private:
  81. SavedState& operator= (const SavedState&);
  82. };
  83. OwnedArray <SavedState> stateStack;
  84. void writeClip();
  85. void writeColour (const Colour& colour);
  86. void writePath (const Path& path) const;
  87. void writeXY (float x, float y) const;
  88. void writeTransform (const AffineTransform& trans) const;
  89. void writeImage (const Image& im, int sx, int sy, int maxW, int maxH) const;
  90. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LowLevelGraphicsPostScriptRenderer)
  91. };
  92. #endif // JUCE_LOWLEVELGRAPHICSPOSTSCRIPTRENDERER_H_INCLUDED