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.

119 lines
4.3KB

  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. #pragma once
  20. //==============================================================================
  21. /**
  22. An implementation of LowLevelGraphicsContext that turns the drawing operations
  23. into a PostScript document.
  24. */
  25. class JUCE_API LowLevelGraphicsPostScriptRenderer : public LowLevelGraphicsContext
  26. {
  27. public:
  28. //==============================================================================
  29. LowLevelGraphicsPostScriptRenderer (OutputStream& resultingPostScript,
  30. const String& documentTitle,
  31. int totalWidth,
  32. int totalHeight);
  33. ~LowLevelGraphicsPostScriptRenderer();
  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. struct SavedState
  73. {
  74. SavedState();
  75. ~SavedState();
  76. RectangleList<int> clip;
  77. int xOffset, yOffset;
  78. FillType fillType;
  79. Font font;
  80. private:
  81. SavedState& operator= (const SavedState&);
  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. };