openshot-audio  0.1.7
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
CoreGraphicsContext::fillRect
void fillRect(const Rectangle< int > &, bool replaceExistingContents) override
Definition: juce_mac_CoreGraphicsContext.mm:394
Path
Definition: juce_Path.h:62
CoreGraphicsContext::addTransform
void addTransform(const AffineTransform &) override
Definition: juce_mac_CoreGraphicsContext.mm:202
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
CoreGraphicsContext::getPhysicalPixelScaleFactor
float getPhysicalPixelScaleFactor() override
Definition: juce_mac_CoreGraphicsContext.mm:214
CoreGraphicsContext::setFill
void setFill(const FillType &) override
Definition: juce_mac_CoreGraphicsContext.mm:368
CoreGraphicsContext::clipToPath
void clipToPath(const Path &, const AffineTransform &) override
Definition: juce_mac_CoreGraphicsContext.mm:272
CoreGraphicsContext::isClipEmpty
bool isClipEmpty() const override
Definition: juce_mac_CoreGraphicsContext.mm:326
CoreGraphicsContext::setOrigin
void setOrigin(Point< int >) override
Definition: juce_mac_CoreGraphicsContext.mm:194
CoreGraphicsContext::setFont
void setFont(const Font &) override
Definition: juce_mac_CoreGraphicsContext.mm:592
CoreGraphicsContext::setOpacity
void setOpacity(float) override
Definition: juce_mac_CoreGraphicsContext.mm:380
FillType
Definition: juce_FillType.h:38
Rectangle< int >
ScopedPointer< SavedState >
LowLevelGraphicsContext
Definition: juce_LowLevelGraphicsContext.h:43
Image
Definition: juce_Image.h:54
CoreGraphicsContext::isVectorDevice
bool isVectorDevice() const override
Definition: juce_mac_CoreGraphicsContext.h:36
CoreGraphicsContext::saveState
void saveState() override
Definition: juce_mac_CoreGraphicsContext.mm:332
CoreGraphicsContext::getClipBounds
Rectangle< int > getClipBounds() const override
Definition: juce_mac_CoreGraphicsContext.mm:310
CoreGraphicsContext::clipToImageAlpha
void clipToImageAlpha(const Image &, const AffineTransform &) override
Definition: juce_mac_CoreGraphicsContext.mm:279
CoreGraphicsContext::drawGlyph
void drawGlyph(int glyphNumber, const AffineTransform &) override
Definition: juce_mac_CoreGraphicsContext.mm:617
CoreGraphicsContext::beginTransparencyLayer
void beginTransparencyLayer(float opacity) override
Definition: juce_mac_CoreGraphicsContext.mm:354
CoreGraphicsContext::clipRegionIntersects
bool clipRegionIntersects(const Rectangle< int > &) override
Definition: juce_mac_CoreGraphicsContext.mm:305
CoreGraphicsContext::~CoreGraphicsContext
~CoreGraphicsContext()
Definition: juce_mac_CoreGraphicsContext.mm:185
CoreGraphicsContext::clipToRectangleList
bool clipToRectangleList(const RectangleList< int > &) override
Definition: juce_mac_CoreGraphicsContext.mm:260
AttributedString
Definition: juce_AttributedString.h:39
CoreGraphicsContext::fillRectList
void fillRectList(const RectangleList< float > &) override
Definition: juce_mac_CoreGraphicsContext.mm:564
CoreGraphicsContext::excludeClipRectangle
void excludeClipRectangle(const Rectangle< int > &) override
Definition: juce_mac_CoreGraphicsContext.mm:265
CoreGraphicsContext::drawTextLayout
bool drawTextLayout(const AttributedString &, const Rectangle< float > &) override
Definition: juce_mac_CoreGraphicsContext.mm:665
RectangleList< int >
CoreGraphicsContext::CoreGraphicsContext
CoreGraphicsContext(CGContextRef context, const float flipHeight, const float targetScale)
Definition: juce_mac_CoreGraphicsContext.mm:167
Font
Definition: juce_Font.h:39
Line
Definition: juce_Line.h:44
OwnedArray< SavedState >
AffineTransform
Definition: juce_AffineTransform.h:40
CoreGraphicsContext::drawImage
void drawImage(const Image &sourceImage, const AffineTransform &) override
Definition: juce_mac_CoreGraphicsContext.mm:480
CoreGraphicsContext::setInterpolationQuality
void setInterpolationQuality(Graphics::ResamplingQuality) override
Definition: juce_mac_CoreGraphicsContext.mm:386
CoreGraphicsContext::getFont
const Font & getFont() override
Definition: juce_mac_CoreGraphicsContext.mm:612
CoreGraphicsContext::drawLine
void drawLine(const Line< float > &) override
Definition: juce_mac_CoreGraphicsContext.mm:541
CoreGraphicsContext
Definition: juce_mac_CoreGraphicsContext.h:29
CoreGraphicsContext::fillPath
void fillPath(const Path &, const AffineTransform &) override
Definition: juce_mac_CoreGraphicsContext.mm:447
CoreGraphicsContext::endTransparencyLayer
void endTransparencyLayer() override
Definition: juce_mac_CoreGraphicsContext.mm:361
Graphics::ResamplingQuality
ResamplingQuality
Definition: juce_GraphicsContext.h:465
CoreGraphicsContext::clipToRectangle
bool clipToRectangle(const Rectangle< int > &) override
Definition: juce_mac_CoreGraphicsContext.mm:221
Point< int >
CoreGraphicsContext::restoreState
void restoreState() override
Definition: juce_mac_CoreGraphicsContext.mm:338