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.

113 lines
4.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. //==============================================================================
  16. /**
  17. An implementation of LowLevelGraphicsContext that turns the drawing operations
  18. into a PostScript document.
  19. @tags{Graphics}
  20. */
  21. class JUCE_API LowLevelGraphicsPostScriptRenderer : public LowLevelGraphicsContext
  22. {
  23. public:
  24. //==============================================================================
  25. LowLevelGraphicsPostScriptRenderer (OutputStream& resultingPostScript,
  26. const String& documentTitle,
  27. int totalWidth,
  28. int totalHeight);
  29. ~LowLevelGraphicsPostScriptRenderer() override;
  30. //==============================================================================
  31. bool isVectorDevice() const override;
  32. void setOrigin (Point<int>) override;
  33. void addTransform (const AffineTransform&) override;
  34. float getPhysicalPixelScaleFactor() override;
  35. bool clipToRectangle (const Rectangle<int>&) override;
  36. bool clipToRectangleList (const RectangleList<int>&) override;
  37. void excludeClipRectangle (const Rectangle<int>&) override;
  38. void clipToPath (const Path&, const AffineTransform&) override;
  39. void clipToImageAlpha (const Image&, const AffineTransform&) override;
  40. void saveState() override;
  41. void restoreState() override;
  42. void beginTransparencyLayer (float) override;
  43. void endTransparencyLayer() override;
  44. bool clipRegionIntersects (const Rectangle<int>&) override;
  45. Rectangle<int> getClipBounds() const override;
  46. bool isClipEmpty() const override;
  47. //==============================================================================
  48. void setFill (const FillType&) override;
  49. void setOpacity (float) override;
  50. void setInterpolationQuality (Graphics::ResamplingQuality) override;
  51. //==============================================================================
  52. void fillRect (const Rectangle<int>&, bool replaceExistingContents) override;
  53. void fillRect (const Rectangle<float>&) override;
  54. void fillRectList (const RectangleList<float>&) override;
  55. void fillPath (const Path&, const AffineTransform&) override;
  56. void drawImage (const Image&, const AffineTransform&) override;
  57. void drawLine (const Line <float>&) override;
  58. //==============================================================================
  59. const Font& getFont() override;
  60. void setFont (const Font&) override;
  61. void drawGlyph (int glyphNumber, const AffineTransform&) override;
  62. protected:
  63. //==============================================================================
  64. OutputStream& out;
  65. int totalWidth, totalHeight;
  66. bool needToClip;
  67. Colour lastColour;
  68. /** Describes a saved state */
  69. struct SavedState
  70. {
  71. SavedState();
  72. SavedState& operator= (const SavedState&) = delete;
  73. ~SavedState();
  74. RectangleList<int> clip;
  75. int xOffset, yOffset;
  76. FillType fillType;
  77. Font font;
  78. };
  79. OwnedArray<SavedState> stateStack;
  80. void writeClip();
  81. void writeColour (Colour colour);
  82. void writePath (const Path&) const;
  83. void writeXY (float x, float y) const;
  84. void writeTransform (const AffineTransform&) const;
  85. void writeImage (const Image&, int sx, int sy, int maxW, int maxH) const;
  86. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LowLevelGraphicsPostScriptRenderer)
  87. };
  88. } // namespace juce