Skip to content

Commit c961bf5

Browse files
[[ RefactorGraphics ]] Fixed crash with windows text rendering outside layer.
[[ RefactorGraphics ]] Ajdusted clipped text offset calculations on iOS and Mac. [[ RefactorGraphics ]] Fixed crash when typing text quickly in message box in Linux. [[ RefactorGraphics ]] Fix to prevent the color white being ignored by objects. [[ RefactorGraphics ]] Added stipple paint mode to libgraphics - used by object handle drawing currently, may need more thought. [[ RefactorGraphics ]] Tweaks to get things to compile using 10.4 SDK.
1 parent d51635f commit c961bf5

16 files changed

Lines changed: 176 additions & 131 deletions

engine/src/graphics_util.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,12 @@ inline MCRectangle MCGRectangleGetIntegerInterior(MCGRectangle p_rect)
6161
return t_rect;
6262
}
6363

64+
inline MCGPoint MCPointToMCGPoint(MCPoint p_point)
65+
{
66+
MCGPoint t_point;
67+
t_point . x = (MCGFloat) p_point . x;
68+
t_point . y = (MCGFloat) p_point . y;
69+
return t_point;
70+
}
71+
6472
#endif // __GRAPHICS_UTIL_H_

engine/src/graphicscontext.cpp

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,38 +65,32 @@ static inline MCGFont MCFontStructToMCGFont(MCFontStruct *p_font)
6565
return t_font;
6666
}
6767

68-
#else
68+
#elif defined(_SERVER)
6969

7070
static inline MCGFont MCFontStructToMCGFont(MCFontStruct *p_font)
7171
{
7272
MCGFont t_font;
7373
t_font . size = p_font -> size;
7474
t_font . ascent = p_font -> ascent;
7575
t_font . descent = p_font -> descent;
76-
t_font . fid = p_font -> fid;
76+
t_font . fid = nil;
7777
return t_font;
7878
}
7979

80-
#endif
81-
82-
/*static inline MCGRectangle MCRectangleToMCGRectangle(MCRectangle p_rect)
83-
{
84-
MCGRectangle t_rect;
85-
t_rect . origin . x = (MCGFloat) p_rect . x;
86-
t_rect . origin . y = (MCGFloat) p_rect . y;
87-
t_rect . size . width = (MCGFloat) p_rect . width;
88-
t_rect . size . height = (MCGFloat) p_rect . height;
89-
return t_rect;
90-
}*/
80+
#else
9181

92-
static inline MCGPoint MCPointToMCGPoint(MCPoint p_point)
82+
static inline MCGFont MCFontStructToMCGFont(MCFontStruct *p_font)
9383
{
94-
MCGPoint t_point;
95-
t_point . x = (MCGFloat) p_point . x;
96-
t_point . y = (MCGFloat) p_point . y;
97-
return t_point;
84+
MCGFont t_font;
85+
t_font . size = p_font -> size;
86+
t_font . ascent = p_font -> ascent;
87+
t_font . descent = p_font -> descent;
88+
t_font . fid = p_font -> fid;
89+
return t_font;
9890
}
9991

92+
#endif
93+
10094
static inline MCGBlendMode MCBitmapEffectBlendModeToMCGBlendMode(MCBitmapEffectBlendMode p_blend_mode)
10195
{
10296
switch(p_blend_mode)
@@ -331,6 +325,7 @@ void MCGraphicsContext::setfunction(uint1 p_function)
331325
t_blend_mode = kMCGBlendModeSourceOver;
332326
break;
333327
case GXblendDstOver:
328+
case GXor:
334329
t_blend_mode = kMCGBlendModeDestinationOver;
335330
break;
336331
case GXblendSrcIn:
@@ -352,6 +347,7 @@ void MCGraphicsContext::setfunction(uint1 p_function)
352347
t_blend_mode = kMCGBlendModeDestinationAtop;
353348
break;
354349
case GXblendXor:
350+
case GXxor:
355351
t_blend_mode = kMCGBlendModeXor;
356352
break;
357353
case GXblendPlus:
@@ -456,11 +452,12 @@ void MCGraphicsContext::setfillstyle(uint2 style, MCPatternRef p, int2 x, int2 y
456452
m_pattern_x = x;
457453
m_pattern_y = y;
458454
}
455+
else if (style == FillStippled)
456+
MCGContextSetFillPaintStyle(m_gcontext, kMCGPaintStyleStippled);
457+
else if (style == FillOpaqueStippled)
458+
MCGContextSetFillPaintStyle(m_gcontext, kMCGPaintStyleStippled);
459459
else
460-
{
461-
MCGAffineTransform t_transform = MCGAffineTransformMakeIdentity();
462-
MCGContextSetFillPattern(m_gcontext, NULL, t_transform, kMCGImageFilterNearest);
463-
}
460+
MCGContextSetFillPaintStyle(m_gcontext, kMCGPaintStyleOpaque);
464461
}
465462

466463
void MCGraphicsContext::getfillstyle(uint2& style, MCPatternRef& p, int2& x, int2& y)

engine/src/mbliphonestack.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ static bool MCGImageToUIImage(MCGImageRef p_image, bool p_copy, MCGFloat p_scale
280280
t_success = MCGImageToCGImage(p_image, MCGRectangleMake(0, 0, MCGImageGetWidth(p_image), MCGImageGetHeight(p_image)), p_copy, false, t_cg_image);
281281

282282
if (t_success)
283-
t_success = nil != (t_image = [UIImage imageWithCGImage:t_cg_image scale:p_scale orientation:0.0]);
283+
t_success = nil != (t_image = [UIImage imageWithCGImage:t_cg_image scale:p_scale orientation:/*0.0*/UIImageOrientationUp]);
284284

285285
if (t_cg_image != nil)
286286
CGImageRelease(t_cg_image);

engine/src/object.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,8 @@ Boolean MCObject::getforecolor(uint2 di, Boolean rev, Boolean hilite,
12261226
if (dc->getdepth() > 1)
12271227
{
12281228
Boolean hasindex = getcindex(di, i);
1229-
if (hasindex && colors[i].pixel != MAXUINT4)
1229+
// MM-2013-08-28: [[ RefactorGraphics ]] We now pack alpha values into pixels meaning checking against MAXUNIT4 means white will always be ignored. Not sure why this check was here previously.
1230+
if (hasindex) // && colors[i].pixel != MAXUINT4)
12301231
{
12311232
c = colors[i];
12321233
return True;

engine/src/osxcisupport.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ rei_boolean_t coreimage_visualeffect_lookup(const char *p_name, rei_visualeffect
241241
static CIFilter *sg_current_filter = nil;
242242
static rei_rectangle_t sg_current_area;
243243
// IM-2013-08-29: [[ RefactorGraphics ]] Record surface height so we can transform image location to flipped context
244-
static CGFloat sg_current_height;
244+
static float sg_current_height;
245245

246246
bool MCGImageToCIImage(MCGImageRef p_image, CIImage *&r_image)
247247
{
@@ -262,7 +262,7 @@ bool MCGImageToCIImage(MCGImageRef p_image, CIImage *&r_image)
262262
return t_success;
263263
}
264264

265-
rei_boolean_t coreimage_visualeffect_begin(rei_handle_t p_handle, MCGImageRef p_image_a, MCGImageRef p_image_b, rei_rectangle_ref_t p_area, CGFloat p_surface_height, rei_visualeffect_parameter_list_ref_t p_parameters)
265+
rei_boolean_t coreimage_visualeffect_begin(rei_handle_t p_handle, MCGImageRef p_image_a, MCGImageRef p_image_b, rei_rectangle_ref_t p_area, float p_surface_height, rei_visualeffect_parameter_list_ref_t p_parameters)
266266
{
267267
bool t_success = true;
268268

engine/src/osxcoreimage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static bool s_coreimage_initialized = false;
4848
extern rei_boolean_t coreimage_visualeffect_initialise(void);
4949
extern void coreimage_visualeffect_finalise(void);
5050
extern rei_boolean_t coreimage_visualeffect_lookup(const char *p_name, rei_visualeffect_info_ref_t *r_info);
51-
extern rei_boolean_t coreimage_visualeffect_begin(rei_handle_t p_handle, MCGImageRef p_image_a, MCGImageRef p_image_b, rei_rectangle_ref_t p_area, CGFloat p_surface_height, rei_visualeffect_parameter_list_ref_t p_parameters);
51+
extern rei_boolean_t coreimage_visualeffect_begin(rei_handle_t p_handle, MCGImageRef p_image_a, MCGImageRef p_image_b, rei_rectangle_ref_t p_area, float p_surface_height, rei_visualeffect_parameter_list_ref_t p_parameters);
5252
extern rei_boolean_t coreimage_visualeffect_step(MCStackSurface *p_target, float p_time);
5353
extern rei_boolean_t coreimage_visualeffect_end(void);
5454

engine/src/osxstack.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -966,34 +966,35 @@ static inline CGRect MCGRectangleToCGRect(MCGRectangle p_rect)
966966

967967
static inline CGBlendMode MCGBlendModeToCGBlendMode(MCGBlendMode p_blend)
968968
{
969+
// MM-2013-08-28: [[ RefactorGraphics ]] Tweak for 10.4 SDK support.
969970
switch (p_blend)
970971
{
971972
case kMCGBlendModeClear:
972-
return kCGBlendModeClear;
973+
return (CGBlendMode) 16; //kCGBlendModeClear;
973974
case kMCGBlendModeCopy:
974-
return kCGBlendModeCopy;
975-
case kMCGBlendModeSourceOver:
976-
return kCGBlendModeNormal;
975+
return (CGBlendMode) 17; //kCGBlendModeCopy;
977976
case kMCGBlendModeSourceIn:
978-
return kCGBlendModeSourceIn;
977+
return (CGBlendMode) 18; //kCGBlendModeSourceIn;
979978
case kMCGBlendModeSourceOut:
980-
return kCGBlendModeSourceOut;
979+
return (CGBlendMode) 19; //kCGBlendModeSourceOut;
981980
case kMCGBlendModeSourceAtop:
982-
return kCGBlendModeSourceAtop;
981+
return (CGBlendMode) 20; //kCGBlendModeSourceAtop;
983982
case kMCGBlendModeDestinationOver:
984-
return kCGBlendModeDestinationOver;
983+
return (CGBlendMode) 21; //kCGBlendModeDestinationOver;
985984
case kMCGBlendModeDestinationIn:
986-
return kCGBlendModeDestinationIn;
985+
return (CGBlendMode) 22; //kCGBlendModeDestinationIn;
987986
case kMCGBlendModeDestinationOut:
988-
return kCGBlendModeDestinationOut;
987+
return (CGBlendMode) 23; //kCGBlendModeDestinationOut;
989988
case kMCGBlendModeDestinationAtop:
990-
return kCGBlendModeDestinationAtop;
989+
return (CGBlendMode) 24; //kCGBlendModeDestinationAtop;
991990
case kMCGBlendModeXor:
992-
return kCGBlendModeXOR;
991+
return (CGBlendMode) 25; //kCGBlendModeXOR;
993992
case kMCGBlendModePlusDarker:
994-
return kCGBlendModePlusDarker;
993+
return (CGBlendMode) 26; //kCGBlendModePlusDarker;
995994
case kMCGBlendModePlusLighter:
996-
return kCGBlendModePlusLighter;
995+
return (CGBlendMode) 27; //kCGBlendModePlusLighter;
996+
case kMCGBlendModeSourceOver:
997+
return kCGBlendModeNormal;
997998
case kMCGBlendModeMultiply:
998999
return kCGBlendModeMultiply;
9991000
case kMCGBlendModeScreen:

libgraphics/include/graphics.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,13 @@ struct MCGAffineTransform
131131
enum MCGFillRule
132132
{
133133
kMCGFillRuleNonZero,
134-
kMCGFillRuleEvenOdd
134+
kMCGFillRuleEvenOdd,
135+
};
136+
137+
enum MCGPaintStyle
138+
{
139+
kMCGPaintStyleOpaque,
140+
kMCGPaintStyleStippled,
135141
};
136142

137143
enum MCGBlendMode
@@ -464,6 +470,7 @@ void MCGContextSetFillOpacity(MCGContextRef context, MCGFloat opacity);
464470
void MCGContextSetFillRGBAColor(MCGContextRef context, MCGFloat red, MCGFloat green, MCGFloat blue, MCGFloat alpha);
465471
void MCGContextSetFillPattern(MCGContextRef context, MCGImageRef image, MCGAffineTransform transform, MCGImageFilter filter);
466472
void MCGContextSetFillGradient(MCGContextRef context, MCGGradientFunction function, const MCGFloat* stops, const MCGColor* colors, uindex_t ramp_length, bool mirror, bool wrap, uint32_t repeats, MCGAffineTransform transform, MCGImageFilter filter);
473+
void MCGContextSetFillPaintStyle(MCGContextRef context, MCGPaintStyle style);
467474

468475
// Stroke attributes
469476
void MCGContextSetStrokeOpacity(MCGContextRef context, MCGFloat opacity);
@@ -475,6 +482,7 @@ void MCGContextSetStrokeMiterLimit(MCGContextRef context, MCGFloat limit);
475482
void MCGContextSetStrokeJoinStyle(MCGContextRef context, MCGJoinStyle style);
476483
void MCGContextSetStrokeCapStyle(MCGContextRef context, MCGCapStyle style);
477484
void MCGContextSetStrokeDashes(MCGContextRef context, MCGFloat phase, const MCGFloat *lengths, uindex_t arity);
485+
void MCGContextSetStrokePaintStyle(MCGContextRef context, MCGPaintStyle style);
478486

479487
// Transforms - concatenated with the current CTM.
480488
void MCGContextConcatCTM(MCGContextRef context, MCGAffineTransform transform);

0 commit comments

Comments
 (0)