diff options
author | Neil Hodgson <nyamatongwe@gmail.com> | 2018-05-21 15:20:08 +1000 |
---|---|---|
committer | Neil Hodgson <nyamatongwe@gmail.com> | 2018-05-21 15:20:08 +1000 |
commit | 9f00df4e57e917035d2f939ce70ccf2ee83a9725 (patch) | |
tree | d2c867d424dcb2ca9d545f23218d5bc95fb214cd /cocoa/QuartzTextLayout.h | |
parent | 8bda8cce4b5daf0bc785401a887331182e4f2b74 (diff) | |
download | scintilla-mirror-9f00df4e57e917035d2f939ce70ccf2ee83a9725.tar.gz |
Backport: Remove CGContextRef field in QuartzTextLayout as it is only used in draw method
where it can easily be provided. Retaining a CGContextRef in QuartzTextLayout
could lead to it being used after being invalidated.
Backport of changeset 6963:a8774d6100a6.
Diffstat (limited to 'cocoa/QuartzTextLayout.h')
-rw-r--r-- | cocoa/QuartzTextLayout.h | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/cocoa/QuartzTextLayout.h b/cocoa/QuartzTextLayout.h index 0f813f301..f2387dd9b 100644 --- a/cocoa/QuartzTextLayout.h +++ b/cocoa/QuartzTextLayout.h @@ -19,13 +19,9 @@ class QuartzTextLayout { public: - /** Create a text layout for drawing on the specified context. */ - explicit QuartzTextLayout( CGContextRef context ) + /** Create a text layout for drawing. */ + QuartzTextLayout() : mString(NULL), mLine(NULL), stringLength(0) { - mString = NULL; - mLine = NULL; - stringLength = 0; - setContext(context); } ~QuartzTextLayout() @@ -63,12 +59,13 @@ public: CFRelease( str ); } - /** Draw the text layout into the current CGContext at the specified position. + /** Draw the text layout into a CGContext at the specified position. + * @param gc The CGContext in which to draw the text. * @param x The x axis position to draw the baseline in the current CGContext. * @param y The y axis position to draw the baseline in the current CGContext. */ - void draw( float x, float y ) + void draw( CGContextRef gc, float x, float y ) { - if (mLine == NULL) + if (!mLine) return; ::CGContextSetTextMatrix(gc, CGAffineTransformMakeScale(1.0, -1.0)); @@ -96,13 +93,7 @@ public: return stringLength; } - inline void setContext (CGContextRef context) - { - gc = context; - } - private: - CGContextRef gc; CFAttributedStringRef mString; CTLineRef mLine; CFIndex stringLength; |