[PATCH weston] internal-screenshot-test: Fix endian problem

Derek Foreman derekf at osg.samsung.com
Fri May 29 07:39:29 PDT 2015


On 29/05/15 03:53 AM, Pekka Paalanen wrote:
> On Tue, 26 May 2015 12:00:49 -0500
> Derek Foreman <derekf at osg.samsung.com> wrote:
> 
>> Use bit-shifts to properly generate pixel data.
>>
>> Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
>> ---
>>
>>  tests/internal-screenshot-test.c | 13 ++++++++-----
>>  1 file changed, 8 insertions(+), 5 deletions(-)
>>
>> diff --git a/tests/internal-screenshot-test.c b/tests/internal-screenshot-test.c
>> index 991761f..7294a37 100644
>> --- a/tests/internal-screenshot-test.c
>> +++ b/tests/internal-screenshot-test.c
>> @@ -185,16 +185,19 @@ capture_screenshot_of_output(struct client *client) {
>>  }
>>  
>>  static void
>> -draw_stuff(char *pixels, int w, int h)
>> +draw_stuff(void *pixels, int w, int h)
>>  {
>>  	int x, y;
>> +	uint8_t r, g, b;
>> +	uint32_t *pixel;
>>  
>>  	for (x = 0; x < w; x++)
>>  		for (y = 0; y < h; y++) {
>> -			pixels[y * w * 4 + x * 4] = x;
>> -			pixels[y * w * 4 + x * 4 + 1] = x + y;
>> -			pixels[y * w * 4 + x * 4 + 2] = y;
>> -			pixels[y * w * 4 + x * 4 + 3] = 255;
>> +			b = x;
>> +			g = x + y;
>> +			r = y;
>> +			pixel = (uint32_t *)pixels + y * w + x;
>> +			*pixel = (255 << 24) | (r << 16) | (g << 8) | b;
>>  		}
>>  }
>>  
> 
> Assumes stride == width * 4.

Stride is always width * 4 here because we're using create_shm_buffer()
which hard codes format to ARGB8888 and stride to width * 4.

Would you like me to document this in a comment?

> For 1.9
> Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> 
> 
> Thanks,
> pq
> 



More information about the wayland-devel mailing list