openshot-audio  0.1.4
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) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_MAC_COREGRAPHICSCONTEXT_H_INCLUDED
26 #define JUCE_MAC_COREGRAPHICSCONTEXT_H_INCLUDED
27 
28 //==============================================================================
30 {
31 public:
32  CoreGraphicsContext (CGContextRef context, const float flipHeight, const float targetScale);
34 
35  //==============================================================================
36  bool isVectorDevice() const override { return false; }
37 
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  bool clipRegionIntersects (const Rectangle<int>&) override;
47  Rectangle<int> getClipBounds() const override;
48  bool isClipEmpty() const override;
49 
50  //==============================================================================
51  void saveState() override;
52  void restoreState() override;
53  void beginTransparencyLayer (float opacity) override;
54  void endTransparencyLayer() override;
55 
56  //==============================================================================
57  void setFill (const FillType&) override;
58  void setOpacity (float) override;
60 
61  //==============================================================================
62  void fillRect (const Rectangle<int>&, bool replaceExistingContents) override;
63  void fillRect (const Rectangle<float>&) override;
64  void fillRectList (const RectangleList<float>&) override;
65  void fillPath (const Path&, const AffineTransform&) override;
66  void drawImage (const Image& sourceImage, const AffineTransform&) override;
67 
68  //==============================================================================
69  void drawLine (const Line<float>&) override;
70  void setFont (const Font&) override;
71  const Font& getFont() override;
72  void drawGlyph (int glyphNumber, const AffineTransform&) override;
73  bool drawTextLayout (const AttributedString&, const Rectangle<float>&) override;
74 
75 private:
76  CGContextRef context;
77  const CGFloat flipHeight;
78  float targetScale;
79  CGColorSpaceRef rgbColourSpace, greyColourSpace;
80  mutable Rectangle<int> lastClipRect;
81  mutable bool lastClipRectIsValid;
82 
83  struct SavedState
84  {
85  SavedState();
86  SavedState (const SavedState&);
87  ~SavedState();
88 
89  void setFill (const FillType&);
90 
91  FillType fillType;
92  Font font;
93  CGFontRef fontRef;
94  CGAffineTransform fontTransform;
95  CGGradientRef gradient;
96  };
97 
99  OwnedArray<SavedState> stateStack;
100 
101  void drawGradient();
102  void createPath (const Path&) const;
103  void createPath (const Path&, const AffineTransform&) const;
104  void flip() const;
105  void applyTransform (const AffineTransform&) const;
106  void drawImage (const Image&, const AffineTransform&, bool fillEntireClipAsTiles);
107  bool clipToRectangleListWithoutTest (const RectangleList<int>&);
108  void fillCGRect (const CGRect&, bool replaceExistingContents);
109 
111 };
112 
113 #endif // JUCE_MAC_COREGRAPHICSCONTEXT_H_INCLUDED
void setOpacity(float) override
Definition: juce_mac_CoreGraphicsContext.mm:380
ResamplingQuality
Definition: juce_GraphicsContext.h:465
Definition: juce_Font.h:39
void setFill(const FillType &) override
Definition: juce_mac_CoreGraphicsContext.mm:368
void restoreState() override
Definition: juce_mac_CoreGraphicsContext.mm:338
Definition: juce_Line.h:44
void setOrigin(Point< int >) override
Definition: juce_mac_CoreGraphicsContext.mm:194
void fillRect(const Rectangle< int > &, bool replaceExistingContents) override
Definition: juce_mac_CoreGraphicsContext.mm:394
void excludeClipRectangle(const Rectangle< int > &) override
Definition: juce_mac_CoreGraphicsContext.mm:265
float getPhysicalPixelScaleFactor() override
Definition: juce_mac_CoreGraphicsContext.mm:214
bool isVectorDevice() const override
Definition: juce_mac_CoreGraphicsContext.h:36
Rectangle< int > getClipBounds() const override
Definition: juce_mac_CoreGraphicsContext.mm:310
void saveState() override
Definition: juce_mac_CoreGraphicsContext.mm:332
bool isClipEmpty() const override
Definition: juce_mac_CoreGraphicsContext.mm:326
void beginTransparencyLayer(float opacity) override
Definition: juce_mac_CoreGraphicsContext.mm:354
void setFont(const Font &) override
Definition: juce_mac_CoreGraphicsContext.mm:592
bool clipRegionIntersects(const Rectangle< int > &) override
Definition: juce_mac_CoreGraphicsContext.mm:305
void clipToImageAlpha(const Image &, const AffineTransform &) override
Definition: juce_mac_CoreGraphicsContext.mm:279
void drawGlyph(int glyphNumber, const AffineTransform &) override
Definition: juce_mac_CoreGraphicsContext.mm:617
Definition: juce_Rectangle.h:36
~CoreGraphicsContext()
Definition: juce_mac_CoreGraphicsContext.mm:185
bool clipToRectangleList(const RectangleList< int > &) override
Definition: juce_mac_CoreGraphicsContext.mm:260
void drawImage(const Image &sourceImage, const AffineTransform &) override
Definition: juce_mac_CoreGraphicsContext.mm:480
Definition: juce_Path.h:62
void fillRectList(const RectangleList< float > &) override
Definition: juce_mac_CoreGraphicsContext.mm:564
bool drawTextLayout(const AttributedString &, const Rectangle< float > &) override
Definition: juce_mac_CoreGraphicsContext.mm:665
void fillPath(const Path &, const AffineTransform &) override
Definition: juce_mac_CoreGraphicsContext.mm:447
bool clipToRectangle(const Rectangle< int > &) override
Definition: juce_mac_CoreGraphicsContext.mm:221
Definition: juce_AttributedString.h:39
Definition: juce_FillType.h:38
void drawLine(const Line< float > &) override
Definition: juce_mac_CoreGraphicsContext.mm:541
const Font & getFont() override
Definition: juce_mac_CoreGraphicsContext.mm:612
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
CoreGraphicsContext(CGContextRef context, const float flipHeight, const float targetScale)
Definition: juce_mac_CoreGraphicsContext.mm:167
Definition: juce_Image.h:54
Definition: juce_LowLevelGraphicsContext.h:43
Definition: juce_AffineTransform.h:40
void addTransform(const AffineTransform &) override
Definition: juce_mac_CoreGraphicsContext.mm:202
Definition: juce_mac_CoreGraphicsContext.h:29
void setInterpolationQuality(Graphics::ResamplingQuality) override
Definition: juce_mac_CoreGraphicsContext.mm:386
void endTransparencyLayer() override
Definition: juce_mac_CoreGraphicsContext.mm:361
void clipToPath(const Path &, const AffineTransform &) override
Definition: juce_mac_CoreGraphicsContext.mm:272