On 14 September 2018 at 20:13, Nikolay Sivov nsivov@codeweavers.com wrote:
On 09/14/2018 06:15 PM, Henri Verbeet wrote:
This seems a little more complicated than it really needs to be. In d2d_bitmap_GetSurface(), can't you just do something like the following?
ID3D10ShaderResourceView_GetResource(bitmap->view, &resource); ID3D10Resource_QueryInterface(resource, &IID_IDXGISurface, &surface);
Yes, that would be an alternative to separate surface pointer in bitmap structure. The problem is that this method is not supposed to always work. According to tests it only works for bitmaps created from DXGI target/device context. I can use some flag instead to indicate that if you think it's better.
Sure, you can just flag it on bitmap creation. It's perhaps unfortunate that D2D1_BITMAP_OPTIONS doesn't have a flag for that.
I'm not necessarily opposed to storing the surface in struct d2d_bitmap though, but in that case I think you should retrieve it from the SRV in d2d_bitmap_init() as well, instead of doing that in its callers.