Audio plugin host https://kx.studio/carla
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.

118 lines
4.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. //==============================================================================
  21. /**
  22. An implementation of LowLevelGraphicsContext that turns the drawing operations
  23. into a PostScript document.
  24. @tags{Graphics}
  25. */
  26. class JUCE_API LowLevelGraphicsPostScriptRenderer : public LowLevelGraphicsContext
  27. {
  28. public:
  29. //==============================================================================
  30. LowLevelGraphicsPostScriptRenderer (OutputStream& resultingPostScript,
  31. const String& documentTitle,
  32. int totalWidth,
  33. int totalHeight);
  34. //==============================================================================
  35. bool isVectorDevice() const override;
  36. void setOrigin (Point<int>) override;
  37. void addTransform (const AffineTransform&) override;
  38. float getPhysicalPixelScaleFactor() 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 fillRect (const Rectangle<float>&) override;
  58. void fillRectList (const RectangleList<float>&) override;
  59. void fillPath (const Path&, const AffineTransform&) override;
  60. void drawImage (const Image&, const AffineTransform&) override;
  61. void drawLine (const Line <float>&) 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. /** Describes a saved state */
  73. struct SavedState
  74. {
  75. SavedState();
  76. SavedState (const SavedState&) = default;
  77. SavedState& operator= (const SavedState&) = delete;
  78. RectangleList<int> clip;
  79. int xOffset, yOffset;
  80. FillType fillType;
  81. Font font;
  82. };
  83. OwnedArray<SavedState> stateStack;
  84. void writeClip();
  85. void writeColour (Colour colour);
  86. void writePath (const Path&) const;
  87. void writeXY (float x, float y) const;
  88. void writeTransform (const AffineTransform&) const;
  89. void writeImage (const Image&, int sx, int sy, int maxW, int maxH) const;
  90. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LowLevelGraphicsPostScriptRenderer)
  91. };
  92. } // namespace juce