I encountered a very depressing problem these two days. It was hard to debug the debug version of the common class, and there were many implementation classes and compile them into the release version. In fact, some files could not be opened, some images display incorrect colors. According to the normal idea, they are related to the pre-Debug macro definition, but rester. CPP has been checked several times and has not defined the debug Macro. I have compiled other files into the release version. This file is compiled into the debug version, so there is no problem. There is no way to do this, you can only find this part of the Drawing operation, modify the relevant color assignment, and view the image changes to determine the problematic part.
After a long time, I finally found the problem. The Code is as follows:
(Rgbil *) pix)-> C0 = (rgbil *) pix)-> C0> antishift) & 0x00ff00ffl;
(Rgbil *) pix)-> C1 = (rgbil *) pix)-> C1> antishift) & 0x00ff00ffl;
Rgbil is defined as follows:
Typedef struct _ xrgbil {
U32 C0;
U32 C1;
} Rgbil;
This method assigns a value for 32-bit data at a time. There is no problem in the debug version, but an error occurs in the release version.
Change
PIX-> Blue = (pix-> blue> antishift) & 0xff;
PIX-> Green = (pix-> green> antishift) & 0xff;
PIX-> Red = (pix-> Red> antishift) & 0xff;
PIX-> alpha = (pix-> alpha> antishift) & 0xff;
The pix type is as follows:
Typedef struct _ xrgbi {
2010blue;
2010green;
2010red;
B2alpha;
} Rgbi;
There is no problem with this operation.
The following is also a problem. Direct assignment is a problem. Only one byte and one byte can be assigned a value.
# If defined (_ Android __)
Char * T1 = (char *) (script + POS );
Char * t2 = (char *) & data;
For (INT I = 0; I <4; I ++)
{
* (T2 + I) = * (t1 + I + 4 );
}
For (INT I = 0; I <4; I ++)
{
* (T2 + I + 4) = * (t1 + I );
}
# Else
Xu32 * P = (xu32 *) & data;
Xu32 * PS = (xu32 *) (script + POS );
P [0] = Ps [1];
P [1] = Ps [0];
# Endif
I really don't know how GCC works. What optimizations have been made in the end?