[PATCH 1/1] d3drm/tests: Add texture loading tests.

Henri Verbeet hverbeet at gmail.com
Fri Jan 15 16:37:12 CST 2016


On 15 January 2016 at 21:38, Aaryaman Vasishta
<jem456.vasishta at gmail.com> wrote:
> On Fri, Jan 15, 2016 at 5:25 PM, Henri Verbeet <hverbeet at codeweavers.com>
> wrote:
>>
>> +        for (i = 0; i < img->palette_size; ++i)
>> +        {
>> +            unsigned int idx = upside_down ? (h - 1) * w - i + (i % w) *
>> 2 :
>
> How did you come up with that equation? Would be nice to know :)

Mostly just maths. In the normal case palette index "i" corresponds to
the pixel (i % w, i / w), and the pixel at location (x, y) has palette
index "y * w + x". I.e., "idx = (i / w) * w + i % w", which simplifies
to "idx = i". Flipping the image means the new "y" becomes "h - 1 -
y", so you get:
    idx = (h - 1 - (i / w)) * w + i % w;
         = (h - 1) * w - (i - i % w) + i % w;
         = (h - 1) * w - i + (i % w) * 2;

>> +        hr = IDirect3DRM_LoadTexture(d3drm1, filename, &texture1);
>> +        ok(SUCCEEDED(hr), "Test %u: Failed to load texture, hr %#x.\n",
>> i, hr);
>> +        d3drm_img = IDirect3DRMTexture_GetImage(texture1);
>> +        todo_wine ok(!!d3drm_img, "Test %u: Failed to get image.\n", i);
>
>  Why the '!!' ? How's that better than using a single negation?
Mostly just personal preference. I think "!p" and "!!p" are easier to
read and reason about than "p == NULL" and "p != NULL", but I'm sure
there are people that disagree. Perhaps I just like prefix operators
better.



More information about the wine-devel mailing list