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.

121 lines
4.4KB

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