juce_LowLevelGraphicsContext.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. Interface class for graphics context objects, used internally by the Graphics class.
  24. Users are not supposed to create instances of this class directly - do your drawing
  25. via the Graphics object instead.
  26. It's a base class for different types of graphics context, that may perform software-based
  27. or OS-accelerated rendering.
  28. E.g. the LowLevelGraphicsSoftwareRenderer renders onto an image in memory, but other
  29. subclasses could render directly to a windows HDC, a Quartz context, or an OpenGL
  30. context.
  31. @tags{Graphics}
  32. */
  33. class JUCE_API LowLevelGraphicsContext
  34. {
  35. protected:
  36. //==============================================================================
  37. LowLevelGraphicsContext();
  38. public:
  39. virtual ~LowLevelGraphicsContext();
  40. /** Returns true if this device is vector-based, e.g. a printer. */
  41. virtual bool isVectorDevice() const = 0;
  42. //==============================================================================
  43. /** Moves the origin to a new position.
  44. The coordinates are relative to the current origin, and indicate the new position
  45. of (0, 0).
  46. */
  47. virtual void setOrigin (Point<int>) = 0;
  48. virtual void addTransform (const AffineTransform&) = 0;
  49. virtual float getPhysicalPixelScaleFactor() = 0;
  50. virtual bool clipToRectangle (const Rectangle<int>&) = 0;
  51. virtual bool clipToRectangleList (const RectangleList<int>&) = 0;
  52. virtual void excludeClipRectangle (const Rectangle<int>&) = 0;
  53. virtual void clipToPath (const Path&, const AffineTransform&) = 0;
  54. virtual void clipToImageAlpha (const Image&, const AffineTransform&) = 0;
  55. virtual bool clipRegionIntersects (const Rectangle<int>&) = 0;
  56. virtual Rectangle<int> getClipBounds() const = 0;
  57. virtual bool isClipEmpty() const = 0;
  58. virtual void saveState() = 0;
  59. virtual void restoreState() = 0;
  60. virtual void beginTransparencyLayer (float opacity) = 0;
  61. virtual void endTransparencyLayer() = 0;
  62. //==============================================================================
  63. virtual void setFill (const FillType&) = 0;
  64. virtual void setOpacity (float) = 0;
  65. virtual void setInterpolationQuality (Graphics::ResamplingQuality) = 0;
  66. //==============================================================================
  67. virtual void fillRect (const Rectangle<int>&, bool replaceExistingContents) = 0;
  68. virtual void fillRect (const Rectangle<float>&) = 0;
  69. virtual void fillRectList (const RectangleList<float>&) = 0;
  70. virtual void fillPath (const Path&, const AffineTransform&) = 0;
  71. virtual void drawImage (const Image&, const AffineTransform&) = 0;
  72. virtual void drawLine (const Line<float>&) = 0;
  73. virtual void setFont (const Font&) = 0;
  74. virtual const Font& getFont() = 0;
  75. virtual void drawGlyph (int glyphNumber, const AffineTransform&) = 0;
  76. virtual bool drawTextLayout (const AttributedString&, const Rectangle<float>&) { return false; }
  77. };
  78. } // namespace juce