aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cocoa/PlatCocoa.mm7
-rw-r--r--cocoa/QuartzTextLayout.h20
2 files changed, 8 insertions, 19 deletions
diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm
index 75c386f76..1141cca44 100644
--- a/cocoa/PlatCocoa.mm
+++ b/cocoa/PlatCocoa.mm
@@ -127,7 +127,7 @@ SurfaceImpl::SurfaceImpl() {
y = 0;
gc = NULL;
- textLayout.reset(new QuartzTextLayout(nullptr));
+ textLayout.reset(new QuartzTextLayout());
codePage = 0;
verticalDeviceResolution = 0;
@@ -147,7 +147,6 @@ SurfaceImpl::~SurfaceImpl() {
//--------------------------------------------------------------------------------------------------
void SurfaceImpl::Clear() {
- textLayout->setContext(nullptr);
if (bitmapData) {
bitmapData.reset();
// We only "own" the graphics context if we are a bitmap context
@@ -193,7 +192,6 @@ void SurfaceImpl::Init(SurfaceID sid, WindowID) {
Release();
gc = static_cast<CGContextRef>(sid);
CGContextSetLineWidth(gc, 1.0);
- textLayout->setContext(gc);
}
//--------------------------------------------------------------------------------------------------
@@ -229,7 +227,6 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID
// and we have no use for the bitmap without the context
bitmapData.reset();
}
- textLayout->setContext(gc);
// the context retains the color space, so we can release it
CGColorSpaceRelease(colorSpace);
@@ -863,7 +860,7 @@ void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION yba
CGColorRelease(color);
textLayout->setText(text, encoding, *style);
- textLayout->draw(rc.left, ybase);
+ textLayout->draw(gc, rc.left, ybase);
}
//--------------------------------------------------------------------------------------------------
diff --git a/cocoa/QuartzTextLayout.h b/cocoa/QuartzTextLayout.h
index c33231176..a3ed910de 100644
--- a/cocoa/QuartzTextLayout.h
+++ b/cocoa/QuartzTextLayout.h
@@ -18,12 +18,8 @@
class QuartzTextLayout {
public:
- /** Create a text layout for drawing on the specified context. */
- explicit QuartzTextLayout(CGContextRef context) {
- mString = NULL;
- mLine = NULL;
- stringLength = 0;
- setContext(context);
+ /** Create a text layout for drawing. */
+ QuartzTextLayout() : mString(NULL), mLine(NULL), stringLength(0) {
}
~QuartzTextLayout() {
@@ -58,11 +54,12 @@ 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) {
- if (mLine == NULL)
+ void draw(CGContextRef gc, float x, float y) {
+ if (!mLine)
return;
::CGContextSetTextMatrix(gc, CGAffineTransformMakeScale(1.0, -1.0));
@@ -89,12 +86,7 @@ public:
return stringLength;
}
- inline void setContext(CGContextRef context) {
- gc = context;
- }
-
private:
- CGContextRef gc;
CFAttributedStringRef mString;
CTLineRef mLine;
CFIndex stringLength;