Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 7fe8040

Browse files
committed
[[ CleanupMCColor ]] replace MCUIDC::querycolor, MCUIDC::alloccolor with new -> MCColorSetPixel and MCColorGetPixel functions respectively
[[ CleanupMCColor ]] remove references to MCColor.pixel field
1 parent 8d95a77 commit 7fe8040

40 files changed

+70
-261
lines changed

engine/src/bitmapeffect.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,23 +209,13 @@ static void MCBitmapEffectColorFromMCColor(MCColor &, uint32_t &) ATTRIBUTE_UNUS
209209
// MM-2013-12-10: [[ Bug 11568 ]] Store colors as BGRA instead of native since never directly rasterized.
210210
static void MCBitmapEffectColorToMCColor(uint32_t p_color, MCColor &r_color)
211211
{
212-
uint8_t r, g, b, a;
213-
MCGPixelUnpack(kMCGPixelFormatBGRA, p_color, r, g, b, a);
214-
r_color . pixel = MCGPixelPackNative(r, g, b, a);
215-
r_color . red = r;
216-
r_color . green = g;
217-
r_color . blue = b;
218-
r_color . red |= r_color . red << 8;
219-
r_color . green |= r_color . green << 8;
220-
r_color . blue |= r_color . blue << 8;
212+
MCColorSetPixel(r_color, p_color, kMCGPixelFormatBGRA);
221213
}
222214

223215
// MM-2013-12-10: [[ Bug 11568 ]] Store colors as BGRA instead of native since never directly rasterized.
224216
static void MCBitmapEffectColorFromMCColor(MCColor &p_color, uint32_t &r_color)
225217
{
226-
uint8_t r, g, b, a;
227-
MCGPixelUnpackNative(p_color . pixel, r, g, b, a);
228-
r_color = MCGPixelPack(kMCGPixelFormatBGRA, r, g, b, a);
218+
r_color = MCColorGetPixel(p_color, kMCGPixelFormatBGRA);
229219
}
230220

231221
// Set the given effect to default values for its type.

engine/src/block.cpp

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,6 @@ void MCBlock::open(MCFontRef p_parent_font)
474474
// MW-2012-02-14: [[ FontRefs ]] Map the font for the block.
475475
mapfont(p_parent_font);
476476

477-
if (flags & F_HAS_COLOR)
478-
MCscreen->alloccolor(*atts->color);
479-
if (flags & F_HAS_BACK_COLOR)
480-
MCscreen->alloccolor(*atts->backcolor);
481477
openimage();
482478
width = 0;
483479
}
@@ -1340,7 +1336,7 @@ void MCBlock::draw(MCDC *dc, coord_t x, coord_t lx, coord_t cx, int2 y, findex_t
13401336
MCColor fc, hc;
13411337
f->getforecolor(DI_FORE, False, True, fc, t_pattern, x, y, dc -> gettype(), f);
13421338
f->getforecolor(DI_HILITE, False, True, hc, t_pattern, x, y, dc -> gettype(), f);
1343-
if (hc.pixel == fc.pixel)
1339+
if (MCColorGetPixel(hc) == MCColorGetPixel(fc))
13441340
f->setforeground(dc, DI_BACK, False, True);
13451341
else
13461342
setcolorforselectedtext(dc, nil);
@@ -2151,19 +2147,13 @@ void MCBlock::exportattrs(MCFieldCharacterStyle& x_style)
21512147
{
21522148
if (getflag(F_HAS_COLOR))
21532149
{
2154-
if (!opened)
2155-
MCscreen -> alloccolor(*atts -> color);
2156-
21572150
x_style . has_text_color = true;
2158-
x_style . text_color = atts -> color -> pixel;
2151+
x_style . text_color = MCColorGetPixel(*(atts -> color));
21592152
}
21602153
if (getflag(F_HAS_BACK_COLOR))
21612154
{
2162-
if (!opened)
2163-
MCscreen -> alloccolor(*atts -> backcolor);
2164-
21652155
x_style . has_background_color = true;
2166-
x_style . background_color = atts -> backcolor -> pixel;
2156+
x_style . background_color = MCColorGetPixel(*(atts -> backcolor));
21672157
}
21682158
if (getflag(F_HAS_LINK))
21692159
{
@@ -2210,15 +2200,13 @@ void MCBlock::importattrs(const MCFieldCharacterStyle& p_style)
22102200
if (p_style . has_text_color)
22112201
{
22122202
MCColor t_color;
2213-
t_color . pixel = p_style . text_color;
2214-
MCscreen -> querycolor(t_color);
2203+
MCColorSetPixel(t_color, p_style . text_color);
22152204
setcolor(&t_color);
22162205
}
22172206
if (p_style . has_background_color)
22182207
{
22192208
MCColor t_color;
2220-
t_color . pixel = p_style . background_color;
2221-
MCscreen -> querycolor(t_color);
2209+
MCColorSetPixel(t_color, p_style . background_color);
22222210
setbackcolor(&t_color);
22232211
}
22242212
if (p_style . has_link_text)

engine/src/cmds.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,11 +1772,9 @@ void MCReset::exec_ctxt(MCExecContext& ctxt)
17721772

17731773
MCpatternlist->freepat(MCpenpattern);
17741774
MCpencolor.red = MCpencolor.green = MCpencolor.blue = 0x0;
1775-
MCscreen->alloccolor(MCpencolor);
17761775

17771776
MCpatternlist->freepat(MCbrushpattern);
17781777
MCbrushcolor.red = MCbrushcolor.green = MCbrushcolor.blue = 0xFFFF;
1779-
MCscreen->alloccolor(MCbrushcolor);
17801778
break;
17811779
case RT_PRINTING:
17821780
MCprinter -> Reset();

engine/src/cpalette.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Boolean MCColors::mdown(uint2 which)
126126
getcells(xcells, ycells);
127127
MCscreen->getpaletteentry((my - rect.y) * ycells / rect.height * xcells
128128
+ (mx - rect.x) * xcells / rect.width, color);
129-
selectedcolor = color.pixel;
129+
selectedcolor = MCColorGetPixel(color);
130130
// MW-2011-08-18: [[ Layers ]] Invalidate the whole object.
131131
layer_redrawall();
132132
message_with_valueref_args(MCM_mouse_down, MCSTR("1"));
@@ -182,8 +182,7 @@ Exec_stat MCColors::getprop_legacy(uint4 parid, Properties which, MCExecPoint& e
182182
#ifdef /* MCColors::getprop */ LEGACY_EXEC
183183
case P_SELECTED_COLOR:
184184
MCColor color;
185-
color.pixel = selectedcolor;
186-
MCscreen->querycolor(color);
185+
MCColorSetPixel(color, selectedcolor);
187186
ep.setcolor(color);
188187
break;
189188
#endif /* MCColors::getprop */
@@ -213,7 +212,6 @@ Exec_stat MCColors::setprop_legacy(uint4 parid, Properties p, MCExecPoint &ep, B
213212
}
214213
if (colorname != NULL)
215214
delete colorname;
216-
MCscreen->alloccolor(color);
217215
selectedcolor = color.pixel;
218216
}
219217
break;
@@ -274,7 +272,7 @@ void MCColors::draw(MCDC *dc, const MCRectangle &dirty, bool p_isolated, bool p_
274272
MCscreen->getpaletteentry(i * xcells + j, c);
275273
dc->setforeground(c);
276274
dc->fillrect(trect);
277-
if (c.pixel == selectedcolor)
275+
if (MCColorGetPixel(c) == selectedcolor)
278276
draw3d(dc, trect, ETCH_SUNKEN, borderwidth);
279277
}
280278
if (flags & F_SHOW_BORDER)

engine/src/desktop-dc.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,24 +98,14 @@ Boolean MCScreenDC::open()
9898
{
9999
black_pixel.red = black_pixel.green = black_pixel.blue = 0; //black pixel
100100
white_pixel.red = white_pixel.green = white_pixel.blue = 0xFFFF; //white pixel
101-
black_pixel.pixel = 0;
102-
white_pixel.pixel = 0xFFFFFF;
103101

104102
MCzerocolor = MCbrushcolor = white_pixel;
105-
alloccolor(MCbrushcolor);
106103
MCselectioncolor = MCpencolor = black_pixel;
107-
alloccolor(MCselectioncolor);
108-
alloccolor(MCpencolor);
109104
gray_pixel.red = gray_pixel.green = gray_pixel.blue = 0x8888;
110-
alloccolor(gray_pixel);
111105
background_pixel.red = background_pixel.green = background_pixel.blue = 0xffff;
112-
alloccolor(background_pixel);
113106

114107
MCPlatformGetSystemProperty(kMCPlatformSystemPropertyHiliteColor, kMCPlatformPropertyTypeColor, &MChilitecolor);
115-
alloccolor(MChilitecolor);
116-
117108
MCPlatformGetSystemProperty(kMCPlatformSystemPropertyAccentColor, kMCPlatformPropertyTypeColor, &MCaccentcolor);
118-
alloccolor(MCaccentcolor);
119109

120110
MCPlatformGetSystemProperty(kMCPlatformSystemPropertyDoubleClickInterval, kMCPlatformPropertyTypeUInt16, &MCdoubletime);
121111

@@ -562,8 +552,6 @@ void MCScreenDC::configurebackdrop(const MCColor& p_colour, MCPatternRef p_patte
562552
backdrop_pattern = p_pattern;
563553
backdrop_colour = p_colour;
564554

565-
alloccolor(backdrop_colour);
566-
567555
MCPlatformInvalidateWindow(backdrop_window, nil);
568556
MCPlatformUpdateWindow(backdrop_window);
569557
}

engine/src/dispatch.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,17 +2633,17 @@ void MCDispatch::GetDefaultTextHeight(MCExecContext& ctxt, uinteger_t& r_height)
26332633

26342634
void MCDispatch::GetDefaultForePixel(MCExecContext& ctxt, uinteger_t& r_pixel)
26352635
{
2636-
r_pixel = MCscreen->black_pixel.pixel & 0xFFFFFF;
2636+
r_pixel = MCColorGetPixel(MCscreen->black_pixel) & 0xFFFFFF;
26372637
}
26382638

26392639
void MCDispatch::GetDefaultBackPixel(MCExecContext& ctxt, uinteger_t& r_pixel)
26402640
{
2641-
r_pixel = MCscreen->background_pixel.pixel & 0xFFFFFF;
2641+
r_pixel = MCColorGetPixel(MCscreen->background_pixel) & 0xFFFFFF;
26422642
}
26432643

26442644
void MCDispatch::GetDefaultTopPixel(MCExecContext& ctxt, uinteger_t& r_pixel)
26452645
{
2646-
r_pixel = MCscreen->white_pixel.pixel & 0xFFFFFF;
2646+
r_pixel = MCColorGetPixel(MCscreen->white_pixel) & 0xFFFFFF;
26472647
}
26482648

26492649
void MCDispatch::GetDefaultForeColor(MCExecContext& ctxt, MCInterfaceNamedColor& r_color)

engine/src/exec-graphics.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,9 @@ void MCGraphicsExecResetPaint(MCExecContext& ctxt)
232232
MCmagnification = 8;
233233
MCpatternlist->freepat(MCpenpattern);
234234
MCpencolor.red = MCpencolor.green = MCpencolor.blue = 0x0;
235-
MCscreen->alloccolor(MCpencolor);
236-
235+
237236
MCpatternlist->freepat(MCbrushpattern);
238237
MCbrushcolor.red = MCbrushcolor.green = MCbrushcolor.blue = 0xFFFF;
239-
MCscreen->alloccolor(MCbrushcolor);
240238
}
241239

242240
////////////////////////////////////////////////////////////////////////////////

engine/src/exec-interface-field-chunk.cpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,14 +1304,11 @@ static void setparagraphattr_color(MCParagraphAttrs*& attrs, uint32_t p_flag, si
13041304
else // name null: must interpret the MCColor
13051305
t_color = p_color . color;
13061306

1307-
// Make sure the pixel attribute has been generated
1308-
MCscreen -> alloccolor(t_color);
1309-
13101307
if (attrs == nil)
13111308
attrs = new MCParagraphAttrs;
13121309

13131310
attrs -> flags |= p_flag;
1314-
((uint32_t *)((char *)attrs + p_field_offset))[0] = t_color . pixel;
1311+
((uint32_t *)((char *)attrs + p_field_offset))[0] = MCColorGetPixel(t_color);
13151312
}
13161313

13171314
static void setparagraphattr_bool(MCParagraphAttrs*& attrs, uint32_t p_flag, bool *p_value, bool &r_new_value)
@@ -2875,8 +2872,7 @@ void MCParagraph::GetBackColor(MCExecContext& ctxt, MCInterfaceNamedColor &r_col
28752872
else
28762873
{
28772874
MCColor t_color;
2878-
t_color . pixel = attrs -> background_color;
2879-
MCscreen -> querycolor(t_color);
2875+
MCColorSetPixel(t_color, attrs -> background_color);
28802876
get_interface_color(t_color, nil, r_color);
28812877
}
28822878
}
@@ -2886,8 +2882,7 @@ void MCParagraph::GetEffectiveBackColor(MCExecContext& ctxt, MCInterfaceNamedCol
28862882
if (attrs != nil && (attrs -> flags & PA_HAS_BACKGROUND_COLOR) != 0)
28872883
{
28882884
MCColor t_color;
2889-
t_color . pixel = attrs -> background_color;
2890-
MCscreen -> querycolor(t_color);
2885+
MCColorSetPixel(t_color, attrs -> background_color);
28912886
get_interface_color(t_color, nil, r_color);
28922887
}
28932888
}
@@ -2904,8 +2899,7 @@ void MCParagraph::GetBorderColor(MCExecContext& ctxt, MCInterfaceNamedColor &r_c
29042899
else
29052900
{
29062901
MCColor t_color;
2907-
t_color . pixel = attrs -> background_color;
2908-
MCscreen -> querycolor(t_color);
2902+
MCColorSetPixel(t_color, attrs -> background_color);
29092903
get_interface_color(t_color, nil, r_color);
29102904
}
29112905
}
@@ -2915,8 +2909,7 @@ void MCParagraph::GetEffectiveBorderColor(MCExecContext& ctxt, MCInterfaceNamedC
29152909
if (attrs != nil && (attrs -> flags & PA_HAS_BORDER_COLOR) != 0)
29162910
{
29172911
MCColor t_color;
2918-
t_color . pixel = attrs -> background_color;
2919-
MCscreen -> querycolor(t_color);
2912+
MCColorSetPixel(t_color, attrs -> background_color);
29202913
get_interface_color(t_color, nil, r_color);
29212914
}
29222915
}

engine/src/exec-interface-object.cpp

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,7 +1859,7 @@ bool MCObject::GetPixel(MCExecContext& ctxt, Properties which, bool effective, u
18591859

18601860
if (GetColor(ctxt, t_which, effective, t_color))
18611861
{
1862-
r_pixel = t_color.color.pixel & 0x00FFFFFF;
1862+
r_pixel = MCColorGetPixel(t_color.color) & 0x00FFFFFF;
18631863

18641864
MCInterfaceNamedColorFree(ctxt, t_color);
18651865
return true;
@@ -1874,8 +1874,7 @@ void MCObject::SetPixel(MCExecContext& ctxt, Properties which, uinteger_t pixel)
18741874
if (!getcindex(which - P_FORE_PIXEL, i))
18751875
i = createcindex(which - P_FORE_PIXEL);
18761876

1877-
colors[i] . pixel = pixel;
1878-
MCscreen -> querycolor(colors[i]);
1877+
MCColorSetPixel(colors[i], pixel);
18791878
if (colornames[i] != nil)
18801879
{
18811880
MCValueRelease(colornames[i]);
@@ -2072,8 +2071,6 @@ void MCObject::SetColor(MCExecContext& ctxt, int index, const MCInterfaceNamedCo
20722071
{
20732072
i = createcindex(index);
20742073
colors[i].red = colors[i].green = colors[i].blue = 0;
2075-
if (opened)
2076-
MCscreen->alloccolor(colors[i]);
20772074
}
20782075
set_interface_color(colors[i], colornames[i], p_color);
20792076

@@ -2084,8 +2081,6 @@ void MCObject::SetColor(MCExecContext& ctxt, int index, const MCInterfaceNamedCo
20842081
MCpatternlist->freepat(patterns[j].pattern);
20852082
destroypindex(index, j);
20862083
}
2087-
if (opened)
2088-
MCscreen->alloccolor(colors[i]);
20892084
}
20902085
}
20912086

@@ -2096,12 +2091,7 @@ bool MCObject::GetColor(MCExecContext& ctxt, Properties which, bool effective, M
20962091
{
20972092
get_interface_color(colors[i], colornames[i], r_color);
20982093

2099-
// AL-2015-05-20: [[ Bug 15378 ]] Reinstate fix for bug 9419:
2100-
// If the object isn't already open, then alloc the color first.
2101-
if (!opened)
2102-
MCscreen -> alloccolor(r_color . color);
2103-
2104-
return true;
2094+
return true;
21052095
}
21062096
else if (effective)
21072097
{
@@ -2125,7 +2115,6 @@ bool MCObject::GetColor(MCExecContext& ctxt, Properties which, bool effective, M
21252115
if (MCPlatformGetControlThemePropColor(t_control_type, t_control_part, t_control_state, t_control_prop, t_color))
21262116
{
21272117
t_found = true;
2128-
MCscreen->alloccolor(t_color);
21292118
r_color.color = t_color;
21302119
r_color.name = nil;
21312120
}
@@ -2387,8 +2376,6 @@ void MCObject::SetColors(MCExecContext& ctxt, MCStringRef p_input)
23872376
{
23882377
i = createcindex(index);
23892378
colors[i] = t_color . color;
2390-
if (opened)
2391-
MCscreen->alloccolor(colors[i]);
23922379
colornames[i] = t_color . name == nil ? nil : MCValueRetain(t_color . name);
23932380
}
23942381
else
@@ -2401,7 +2388,6 @@ void MCObject::SetColors(MCExecContext& ctxt, MCStringRef p_input)
24012388
if (opened)
24022389
{
24032390
colors[i] = t_color . color;
2404-
MCscreen->alloccolor(colors[i]);
24052391
}
24062392
colornames[i] = t_color . name == nil ? nil : MCValueRetain(t_color . name);
24072393
}

engine/src/exec-interface-stack.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,9 +1602,6 @@ void MCStack::SetLinkAtt(MCExecContext& ctxt, Properties which, MCInterfaceNamed
16021602
linkatts->colorname = MClinkatts.colorname == nil ? nil : MCValueRetain(MClinkatts.colorname);
16031603
linkatts->hilitecolorname = MClinkatts.hilitecolorname == nil ? nil : MCValueRetain(MClinkatts.hilitecolorname);
16041604
linkatts->visitedcolorname = MClinkatts.visitedcolorname == nil ? nil : MCValueRetain(MClinkatts.visitedcolorname);
1605-
MCscreen->alloccolor(linkatts->color);
1606-
MCscreen->alloccolor(linkatts->hilitecolor);
1607-
MCscreen->alloccolor(linkatts->visitedcolor);
16081605
}
16091606
switch (which)
16101607
{
@@ -1731,9 +1728,6 @@ void MCStack::SetUnderlineLinks(MCExecContext& ctxt, bool* p_value)
17311728
linkatts->colorname = MClinkatts.colorname == nil ? nil : MCValueRetain(MClinkatts.colorname);
17321729
linkatts->hilitecolorname = MClinkatts.hilitecolorname == nil ? nil : MCValueRetain(MClinkatts.hilitecolorname);
17331730
linkatts->visitedcolorname = MClinkatts.visitedcolorname == nil ? nil : MCValueRetain(MClinkatts.visitedcolorname);
1734-
MCscreen->alloccolor(linkatts->color);
1735-
MCscreen->alloccolor(linkatts->hilitecolor);
1736-
MCscreen->alloccolor(linkatts->visitedcolor);
17371731
}
17381732

17391733
linkatts->underline = *p_value;

0 commit comments

Comments
 (0)