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.

juce_LowLevelGraphicsPostScriptRenderer.h 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - 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 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-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. ~LowLevelGraphicsPostScriptRenderer() override;
  35. //==============================================================================
  36. bool isVectorDevice() const override;
  37. void setOrigin (Point<int>) override;
  38. void addTransform (const AffineTransform&) override;
  39. float getPhysicalPixelScaleFactor() override;
  40. bool clipToRectangle (const Rectangle<int>&) override;
  41. bool clipToRectangleList (const RectangleList<int>&) 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. void saveState() override;
  46. void restoreState() override;
  47. void beginTransparencyLayer (float) override;
  48. void endTransparencyLayer() override;
  49. bool clipRegionIntersects (const Rectangle<int>&) override;
  50. Rectangle<int> getClipBounds() const override;
  51. bool isClipEmpty() const override;
  52. //==============================================================================
  53. void setFill (const FillType&) override;
  54. void setOpacity (float) override;
  55. void setInterpolationQuality (Graphics::ResamplingQuality) override;
  56. //==============================================================================
  57. void fillRect (const Rectangle<int>&, bool replaceExistingContents) override;
  58. void fillRect (const Rectangle<float>&) override;
  59. void fillRectList (const RectangleList<float>&) override;
  60. void fillPath (const Path&, const AffineTransform&) override;
  61. void drawImage (const Image&, const AffineTransform&) override;
  62. void drawLine (const Line <float>&) override;
  63. //==============================================================================
  64. const Font& getFont() override;
  65. void setFont (const Font&) override;
  66. void drawGlyph (int glyphNumber, const AffineTransform&) override;
  67. protected:
  68. //==============================================================================
  69. OutputStream& out;
  70. int totalWidth, totalHeight;
  71. bool needToClip;
  72. Colour lastColour;
  73. /** Describes a saved state */
  74. struct SavedState
  75. {
  76. SavedState();
  77. SavedState& operator= (const SavedState&) = delete;
  78. ~SavedState();
  79. RectangleList<int> clip;
  80. int xOffset, yOffset;
  81. FillType fillType;
  82. Font font;
  83. };
  84. OwnedArray<SavedState> stateStack;
  85. void writeClip();
  86. void writeColour (Colour colour);
  87. void writePath (const Path&) const;
  88. void writeXY (float x, float y) const;
  89. void writeTransform (const AffineTransform&) const;
  90. void writeImage (const Image&, int sx, int sy, int maxW, int maxH) const;
  91. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LowLevelGraphicsPostScriptRenderer)
  92. };
  93. } // namespace juce