LMMS
Loading...
Searching...
No Matches
juce_mac_CoreGraphicsContext.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29namespace detail
30{
32 {
33 void operator() (CGColorSpaceRef ptr) const noexcept { CGColorSpaceRelease (ptr); }
34 };
35
37 {
38 void operator() (CGContextRef ptr) const noexcept { CGContextRelease (ptr); }
39 };
40
42 {
43 void operator() (CGDataProviderRef ptr) const noexcept { CGDataProviderRelease (ptr); }
44 };
45
47 {
48 void operator() (CGImageRef ptr) const noexcept { CGImageRelease (ptr); }
49 };
50
52 {
53 void operator() (CGGradientRef ptr) const noexcept { CGGradientRelease (ptr); }
54 };
55
56 //==============================================================================
57 using ColorSpacePtr = std::unique_ptr<CGColorSpace, ColorSpaceDelete>;
58 using ContextPtr = std::unique_ptr<CGContext, ContextDelete>;
59 using DataProviderPtr = std::unique_ptr<CGDataProvider, DataProviderDelete>;
60 using ImagePtr = std::unique_ptr<CGImage, ImageDelete>;
61 using GradientPtr = std::unique_ptr<CGGradient, GradientDelete>;
62}
63
64//==============================================================================
66{
67public:
68 CoreGraphicsContext (CGContextRef context, float flipHeight);
70
71 //==============================================================================
72 bool isVectorDevice() const override { return false; }
73
74 void setOrigin (Point<int>) override;
75 void addTransform (const AffineTransform&) override;
77 bool clipToRectangle (const Rectangle<int>&) override;
79 void excludeClipRectangle (const Rectangle<int>&) override;
80 void clipToPath (const Path&, const AffineTransform&) override;
81 void clipToImageAlpha (const Image&, const AffineTransform&) override;
82 bool clipRegionIntersects (const Rectangle<int>&) override;
83 Rectangle<int> getClipBounds() const override;
84 bool isClipEmpty() const override;
85
86 //==============================================================================
87 void saveState() override;
88 void restoreState() override;
89 void beginTransparencyLayer (float opacity) override;
90 void endTransparencyLayer() override;
91
92 //==============================================================================
93 void setFill (const FillType&) override;
94 void setOpacity (float) override;
96
97 //==============================================================================
98 void fillRect (const Rectangle<int>&, bool replaceExistingContents) override;
99 void fillRect (const Rectangle<float>&) override;
100 void fillRectList (const RectangleList<float>&) override;
101 void fillPath (const Path&, const AffineTransform&) override;
102 void drawImage (const Image& sourceImage, const AffineTransform&) override;
103
104 //==============================================================================
105 void drawLine (const Line<float>&) override;
106 void setFont (const Font&) override;
107 const Font& getFont() override;
108 void drawGlyph (int glyphNumber, const AffineTransform&) override;
109 bool drawTextLayout (const AttributedString&, const Rectangle<float>&) override;
110
111private:
112 //==============================================================================
114 const CGFloat flipHeight;
117 mutable bool lastClipRectIsValid = false;
118
120 {
124
125 void setFill (const FillType&);
126
129 CGFontRef fontRef = {};
130 CGAffineTransform textMatrix = CGAffineTransformIdentity,
131 inverseTextMatrix = CGAffineTransformIdentity;
133 };
134
135 std::unique_ptr<SavedState> state;
137
139 void createPath (const Path&) const;
140 void createPath (const Path&, const AffineTransform&) const;
141 void flip() const;
142 void applyTransform (const AffineTransform&) const;
143 void drawImage (const Image&, const AffineTransform&, bool fillEntireClipAsTiles);
145 void fillCGRect (const CGRect&, bool replaceExistingContents);
146
148};
149
150} // namespace juce
Definition juce_AffineTransform.h:43
Definition juce_AttributedString.h:47
bool clipRegionIntersects(const Rectangle< int > &) override
void addTransform(const AffineTransform &) override
bool lastClipRectIsValid
Definition juce_mac_CoreGraphicsContext.h:117
void applyTransform(const AffineTransform &) const
float getPhysicalPixelScaleFactor() override
void drawImage(const Image &sourceImage, const AffineTransform &) override
void restoreState() override
detail::ColorSpacePtr greyColourSpace
Definition juce_mac_CoreGraphicsContext.h:115
bool isVectorDevice() const override
Definition juce_mac_CoreGraphicsContext.h:72
const CGFloat flipHeight
Definition juce_mac_CoreGraphicsContext.h:114
void setFont(const Font &) override
detail::ColorSpacePtr rgbColourSpace
Definition juce_mac_CoreGraphicsContext.h:115
void endTransparencyLayer() override
const Font & getFont() override
void saveState() override
void clipToPath(const Path &, const AffineTransform &) override
void setInterpolationQuality(Graphics::ResamplingQuality) override
detail::ContextPtr context
Definition juce_mac_CoreGraphicsContext.h:113
bool clipToRectangleListWithoutTest(const RectangleList< int > &)
OwnedArray< SavedState > stateStack
Definition juce_mac_CoreGraphicsContext.h:136
void beginTransparencyLayer(float opacity) override
bool isClipEmpty() const override
bool clipToRectangle(const Rectangle< int > &) override
void drawGlyph(int glyphNumber, const AffineTransform &) override
CoreGraphicsContext(CGContextRef context, float flipHeight)
bool drawTextLayout(const AttributedString &, const Rectangle< float > &) override
void drawLine(const Line< float > &) override
bool clipToRectangleList(const RectangleList< int > &) override
void drawImage(const Image &, const AffineTransform &, bool fillEntireClipAsTiles)
void createPath(const Path &) const
void clipToImageAlpha(const Image &, const AffineTransform &) override
void createPath(const Path &, const AffineTransform &) const
void setOrigin(Point< int >) override
void excludeClipRectangle(const Rectangle< int > &) override
Rectangle< int > lastClipRect
Definition juce_mac_CoreGraphicsContext.h:116
void fillRect(const Rectangle< int > &, bool replaceExistingContents) override
void fillRect(const Rectangle< float > &) override
void setOpacity(float) override
Rectangle< int > getClipBounds() const override
void fillRectList(const RectangleList< float > &) override
std::unique_ptr< SavedState > state
Definition juce_mac_CoreGraphicsContext.h:135
void setFill(const FillType &) override
void fillCGRect(const CGRect &, bool replaceExistingContents)
void fillPath(const Path &, const AffineTransform &) override
Definition juce_FillType.h:41
Definition juce_Font.h:42
ResamplingQuality
Definition juce_GraphicsContext.h:462
Definition juce_Image.h:58
Definition juce_Line.h:47
Definition juce_OwnedArray.h:51
Definition juce_Path.h:65
Definition juce_Point.h:42
Definition juce_Rectangle.h:67
Definition juce_RectangleList.h:43
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition juce_FloatVectorOperations.h:143
std::unique_ptr< CGImage, ImageDelete > ImagePtr
Definition juce_mac_CoreGraphicsContext.h:60
std::unique_ptr< CGDataProvider, DataProviderDelete > DataProviderPtr
Definition juce_mac_CoreGraphicsContext.h:59
std::unique_ptr< CGContext, ContextDelete > ContextPtr
Definition juce_mac_CoreGraphicsContext.h:58
std::unique_ptr< CGColorSpace, ColorSpaceDelete > ColorSpacePtr
Definition juce_mac_CoreGraphicsContext.h:57
std::unique_ptr< CGGradient, GradientDelete > GradientPtr
Definition juce_mac_CoreGraphicsContext.h:61
Definition carla_juce.cpp:31
jack_client_t client jack_client_t client jack_client_t client jack_client_t JackInfoShutdownCallback void arg jack_client_t jack_port_t port void func jack_client_t const char const char unsigned long flags const jack_port_t port jack_client_t jack_port_id_t port_id const jack_port_t const char port_name const jack_port_t port void * ptr
Definition juce_linux_JackAudio.cpp:79
detail::GradientPtr gradient
Definition juce_mac_CoreGraphicsContext.h:132
CGAffineTransform textMatrix
Definition juce_mac_CoreGraphicsContext.h:130
FillType fillType
Definition juce_mac_CoreGraphicsContext.h:127
CGFontRef fontRef
Definition juce_mac_CoreGraphicsContext.h:129
CGAffineTransform inverseTextMatrix
Definition juce_mac_CoreGraphicsContext.h:131
Font font
Definition juce_mac_CoreGraphicsContext.h:128
Definition juce_mac_CoreGraphicsContext.h:32
Definition juce_mac_CoreGraphicsContext.h:37
Definition juce_mac_CoreGraphicsContext.h:42
Definition juce_mac_CoreGraphicsContext.h:52
Definition juce_mac_CoreGraphicsContext.h:47