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.

117 lines
4.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI 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. #pragma once
  18. //==============================================================================
  19. /**
  20. An implementation of LowLevelGraphicsContext that turns the drawing operations
  21. into a PostScript document.
  22. */
  23. class JUCE_API LowLevelGraphicsPostScriptRenderer : public LowLevelGraphicsContext
  24. {
  25. public:
  26. //==============================================================================
  27. LowLevelGraphicsPostScriptRenderer (OutputStream& resultingPostScript,
  28. const String& documentTitle,
  29. int totalWidth,
  30. int totalHeight);
  31. ~LowLevelGraphicsPostScriptRenderer();
  32. //==============================================================================
  33. bool isVectorDevice() const override;
  34. void setOrigin (Point<int>) override;
  35. void addTransform (const AffineTransform&) override;
  36. float getPhysicalPixelScaleFactor() override;
  37. bool clipToRectangle (const Rectangle<int>&) override;
  38. bool clipToRectangleList (const RectangleList<int>&) override;
  39. void excludeClipRectangle (const Rectangle<int>&) override;
  40. void clipToPath (const Path&, const AffineTransform&) override;
  41. void clipToImageAlpha (const Image&, const AffineTransform&) override;
  42. void saveState() override;
  43. void restoreState() override;
  44. void beginTransparencyLayer (float) override;
  45. void endTransparencyLayer() override;
  46. bool clipRegionIntersects (const Rectangle<int>&) override;
  47. Rectangle<int> getClipBounds() const override;
  48. bool isClipEmpty() const override;
  49. //==============================================================================
  50. void setFill (const FillType&) override;
  51. void setOpacity (float) override;
  52. void setInterpolationQuality (Graphics::ResamplingQuality) override;
  53. //==============================================================================
  54. void fillRect (const Rectangle<int>&, bool replaceExistingContents) override;
  55. void fillRect (const Rectangle<float>&) override;
  56. void fillRectList (const RectangleList<float>&) 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. //==============================================================================
  61. const Font& getFont() override;
  62. void setFont (const Font&) override;
  63. void drawGlyph (int glyphNumber, const AffineTransform&) override;
  64. protected:
  65. //==============================================================================
  66. OutputStream& out;
  67. int totalWidth, totalHeight;
  68. bool needToClip;
  69. Colour lastColour;
  70. struct SavedState
  71. {
  72. SavedState();
  73. ~SavedState();
  74. RectangleList<int> clip;
  75. int xOffset, yOffset;
  76. FillType fillType;
  77. Font font;
  78. private:
  79. SavedState& operator= (const SavedState&);
  80. };
  81. OwnedArray <SavedState> stateStack;
  82. void writeClip();
  83. void writeColour (Colour colour);
  84. void writePath (const Path&) const;
  85. void writeXY (float x, float y) const;
  86. void writeTransform (const AffineTransform&) const;
  87. void writeImage (const Image&, int sx, int sy, int maxW, int maxH) const;
  88. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LowLevelGraphicsPostScriptRenderer)
  89. };