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.5KB

9 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_LOWLEVELGRAPHICSPOSTSCRIPTRENDERER_H_INCLUDED
  18. #define JUCE_LOWLEVELGRAPHICSPOSTSCRIPTRENDERER_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. An implementation of LowLevelGraphicsContext that turns the drawing operations
  22. into a PostScript document.
  23. */
  24. class JUCE_API LowLevelGraphicsPostScriptRenderer : public LowLevelGraphicsContext
  25. {
  26. public:
  27. //==============================================================================
  28. LowLevelGraphicsPostScriptRenderer (OutputStream& resultingPostScript,
  29. const String& documentTitle,
  30. int totalWidth,
  31. int totalHeight);
  32. ~LowLevelGraphicsPostScriptRenderer();
  33. //==============================================================================
  34. bool isVectorDevice() const override;
  35. void setOrigin (Point<int>) override;
  36. void addTransform (const AffineTransform&) override;
  37. float getPhysicalPixelScaleFactor() override;
  38. bool clipToRectangle (const Rectangle<int>&) override;
  39. bool clipToRectangleList (const RectangleList<int>&) override;
  40. void excludeClipRectangle (const Rectangle<int>&) override;
  41. void clipToPath (const Path&, const AffineTransform&) override;
  42. void clipToImageAlpha (const Image&, const AffineTransform&) override;
  43. void saveState() override;
  44. void restoreState() override;
  45. void beginTransparencyLayer (float) override;
  46. void endTransparencyLayer() override;
  47. bool clipRegionIntersects (const Rectangle<int>&) override;
  48. Rectangle<int> getClipBounds() const override;
  49. bool isClipEmpty() const override;
  50. //==============================================================================
  51. void setFill (const FillType&) override;
  52. void setOpacity (float) override;
  53. void setInterpolationQuality (Graphics::ResamplingQuality) override;
  54. //==============================================================================
  55. void fillRect (const Rectangle<int>&, bool replaceExistingContents) override;
  56. void fillRect (const Rectangle<float>&) override;
  57. void fillRectList (const RectangleList<float>&) override;
  58. void fillPath (const Path&, const AffineTransform&) override;
  59. void drawImage (const Image&, const AffineTransform&) override;
  60. void drawLine (const Line <float>&) override;
  61. //==============================================================================
  62. const Font& getFont() override;
  63. void setFont (const Font&) override;
  64. void drawGlyph (int glyphNumber, const AffineTransform&) override;
  65. protected:
  66. //==============================================================================
  67. OutputStream& out;
  68. int totalWidth, totalHeight;
  69. bool needToClip;
  70. Colour lastColour;
  71. struct SavedState
  72. {
  73. SavedState();
  74. ~SavedState();
  75. RectangleList<int> clip;
  76. int xOffset, yOffset;
  77. FillType fillType;
  78. Font font;
  79. private:
  80. SavedState& operator= (const SavedState&);
  81. };
  82. OwnedArray <SavedState> stateStack;
  83. void writeClip();
  84. void writeColour (Colour colour);
  85. void writePath (const Path&) const;
  86. void writeXY (float x, float y) const;
  87. void writeTransform (const AffineTransform&) const;
  88. void writeImage (const Image&, int sx, int sy, int maxW, int maxH) const;
  89. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LowLevelGraphicsPostScriptRenderer)
  90. };
  91. #endif // JUCE_LOWLEVELGRAPHICSPOSTSCRIPTRENDERER_H_INCLUDED