wined3d: Introduce a helper function to assign wined3d_box values.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2017-04-06 23:44:30 +02:00 committed by Alexandre Julliard
parent cefd06380c
commit df6120274d
9 changed files with 36 additions and 121 deletions

View file

@ -976,14 +976,8 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CopySubresourceRegion(ID3D
src_resource, src_subresource_idx, src_box);
if (src_box)
{
wined3d_src_box.left = src_box->left;
wined3d_src_box.top = src_box->top;
wined3d_src_box.front = src_box->front;
wined3d_src_box.right = src_box->right;
wined3d_src_box.bottom = src_box->bottom;
wined3d_src_box.back = src_box->back;
}
wined3d_box_set(&wined3d_src_box, src_box->left, src_box->top,
src_box->right, src_box->bottom, src_box->front, src_box->back);
wined3d_dst_resource = wined3d_resource_from_d3d11_resource(dst_resource);
wined3d_src_resource = wined3d_resource_from_d3d11_resource(src_resource);
@ -1020,14 +1014,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_UpdateSubresource(ID3D11De
iface, resource, subresource_idx, box, data, row_pitch, depth_pitch);
if (box)
{
wined3d_box.left = box->left;
wined3d_box.top = box->top;
wined3d_box.front = box->front;
wined3d_box.right = box->right;
wined3d_box.bottom = box->bottom;
wined3d_box.back = box->back;
}
wined3d_box_set(&wined3d_box, box->left, box->top, box->right, box->bottom, box->front, box->back);
wined3d_resource = wined3d_resource_from_d3d11_resource(resource);
wined3d_mutex_lock();
@ -3820,14 +3807,8 @@ static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device1 *
src_resource, src_subresource_idx, src_box);
if (src_box)
{
wined3d_src_box.left = src_box->left;
wined3d_src_box.top = src_box->top;
wined3d_src_box.front = src_box->front;
wined3d_src_box.right = src_box->right;
wined3d_src_box.bottom = src_box->bottom;
wined3d_src_box.back = src_box->back;
}
wined3d_box_set(&wined3d_src_box, src_box->left, src_box->top,
src_box->right, src_box->bottom, src_box->front, src_box->back);
wined3d_dst_resource = wined3d_resource_from_d3d10_resource(dst_resource);
wined3d_src_resource = wined3d_resource_from_d3d10_resource(src_resource);

View file

@ -240,12 +240,7 @@ static HRESULT WINAPI d3d8_surface_LockRect(IDirect3DSurface8 *iface,
locked_rect->pBits = NULL;
return D3DERR_INVALIDCALL;
}
box.left = rect->left;
box.top = rect->top;
box.right = rect->right;
box.bottom = rect->bottom;
box.front = 0;
box.back = 1;
wined3d_box_set(&box, rect->left, rect->top, rect->right, rect->bottom, 0, 1);
}
hr = wined3d_resource_map(wined3d_texture_get_resource(surface->wined3d_texture), surface->sub_resource_idx,

View file

@ -340,12 +340,7 @@ static HRESULT WINAPI d3d8_texture_2d_AddDirtyRect(IDirect3DTexture8 *iface, con
{
struct wined3d_box dirty_region;
dirty_region.left = dirty_rect->left;
dirty_region.top = dirty_rect->top;
dirty_region.right = dirty_rect->right;
dirty_region.bottom = dirty_rect->bottom;
dirty_region.front = 0;
dirty_region.back = 1;
wined3d_box_set(&dirty_region, dirty_rect->left, dirty_rect->top, dirty_rect->right, dirty_rect->bottom, 0, 1);
hr = wined3d_texture_add_dirty_region(texture->wined3d_texture, 0, &dirty_region);
}
wined3d_mutex_unlock();
@ -709,12 +704,7 @@ static HRESULT WINAPI d3d8_texture_cube_AddDirtyRect(IDirect3DCubeTexture8 *ifac
{
struct wined3d_box dirty_region;
dirty_region.left = dirty_rect->left;
dirty_region.top = dirty_rect->top;
dirty_region.right = dirty_rect->right;
dirty_region.bottom = dirty_rect->bottom;
dirty_region.front = 0;
dirty_region.back = 1;
wined3d_box_set(&dirty_region, dirty_rect->left, dirty_rect->top, dirty_rect->right, dirty_rect->bottom, 0, 1);
hr = wined3d_texture_add_dirty_region(texture->wined3d_texture, face, &dirty_region);
}
wined3d_mutex_unlock();

View file

@ -1402,14 +1402,7 @@ static HRESULT WINAPI d3d9_device_UpdateSurface(IDirect3DDevice9Ex *iface,
iface, src_surface, src_rect, dst_surface, dst_point);
if (src_rect)
{
src_box.left = src_rect->left;
src_box.top = src_rect->top;
src_box.right = src_rect->right;
src_box.bottom = src_rect->bottom;
src_box.front = 0;
src_box.back = 1;
}
wined3d_box_set(&src_box, src_rect->left, src_rect->top, src_rect->right, src_rect->bottom, 0, 1);
wined3d_mutex_lock();
hr = wined3d_device_copy_sub_resource_region(device->wined3d_device,

View file

@ -245,14 +245,7 @@ static HRESULT WINAPI d3d9_surface_LockRect(IDirect3DSurface9 *iface,
iface, locked_rect, wine_dbgstr_rect(rect), flags);
if (rect)
{
box.left = rect->left;
box.top = rect->top;
box.right = rect->right;
box.bottom = rect->bottom;
box.front = 0;
box.back = 1;
}
wined3d_box_set(&box, rect->left, rect->top, rect->right, rect->bottom, 0, 1);
wined3d_mutex_lock();
hr = wined3d_resource_map(wined3d_texture_get_resource(surface->wined3d_texture), surface->sub_resource_idx,

View file

@ -382,12 +382,7 @@ static HRESULT WINAPI d3d9_texture_2d_AddDirtyRect(IDirect3DTexture9 *iface, con
{
struct wined3d_box dirty_region;
dirty_region.left = dirty_rect->left;
dirty_region.top = dirty_rect->top;
dirty_region.right = dirty_rect->right;
dirty_region.bottom = dirty_rect->bottom;
dirty_region.front = 0;
dirty_region.back = 1;
wined3d_box_set(&dirty_region, dirty_rect->left, dirty_rect->top, dirty_rect->right, dirty_rect->bottom, 0, 1);
hr = wined3d_texture_add_dirty_region(texture->wined3d_texture, 0, &dirty_region);
}
wined3d_mutex_unlock();
@ -797,12 +792,7 @@ static HRESULT WINAPI d3d9_texture_cube_AddDirtyRect(IDirect3DCubeTexture9 *ifa
{
struct wined3d_box dirty_region;
dirty_region.left = dirty_rect->left;
dirty_region.top = dirty_rect->top;
dirty_region.right = dirty_rect->right;
dirty_region.bottom = dirty_rect->bottom;
dirty_region.front = 0;
dirty_region.back = 1;
wined3d_box_set(&dirty_region, dirty_rect->left, dirty_rect->top, dirty_rect->right, dirty_rect->bottom, 0, 1);
hr = wined3d_texture_add_dirty_region(texture->wined3d_texture, face, &dirty_region);
}
wined3d_mutex_unlock();

View file

@ -985,12 +985,7 @@ static HRESULT surface_lock(struct ddraw_surface *surface,
wined3d_mutex_unlock();
return DDERR_INVALIDPARAMS;
}
box.left = rect->left;
box.top = rect->top;
box.right = rect->right;
box.bottom = rect->bottom;
box.front = 0;
box.back = 1;
wined3d_box_set(&box, rect->left, rect->top, rect->right, rect->bottom, 0, 1);
}
if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)

View file

@ -3876,13 +3876,7 @@ void CDECL wined3d_device_copy_resource(struct wined3d_device *device,
if (dst_resource->type == WINED3D_RTYPE_BUFFER)
{
box.left = 0;
box.top = 0;
box.right = src_resource->size;
box.bottom = 1;
box.front = 0;
box.back = 1;
wined3d_box_set(&box, 0, 0, src_resource->size, 1, 0, 1);
wined3d_cs_emit_blt_sub_resource(device->cs, dst_resource, 0, &box,
src_resource, 0, &box, 0, NULL, WINED3D_TEXF_POINT);
return;
@ -3908,13 +3902,10 @@ void CDECL wined3d_device_copy_resource(struct wined3d_device *device,
for (i = 0; i < dst_texture->level_count; ++i)
{
box.left = 0;
box.top = 0;
box.right = wined3d_texture_get_level_width(dst_texture, i);
box.bottom = wined3d_texture_get_level_height(dst_texture, i);
box.front = 0;
box.back = wined3d_texture_get_level_depth(dst_texture, i);
wined3d_box_set(&box, 0, 0,
wined3d_texture_get_level_width(dst_texture, i),
wined3d_texture_get_level_height(dst_texture, i),
0, wined3d_texture_get_level_depth(dst_texture, i));
for (j = 0; j < dst_texture->layer_count; ++j)
{
unsigned int idx = j * dst_texture->level_count + i;
@ -3975,12 +3966,7 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
if (!src_box)
{
b.left = 0;
b.top = 0;
b.right = src_resource->size;
b.bottom = 1;
b.front = 0;
b.back = 1;
wined3d_box_set(&b, 0, 0, src_resource->size, 1, 0, 1);
src_box = &b;
}
else if ((src_box->left >= src_box->right
@ -3999,12 +3985,7 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
return WINED3DERR_INVALIDCALL;
}
dst_box.left = dst_x;
dst_box.top = 0;
dst_box.right = dst_x + (src_box->right - src_box->left);
dst_box.bottom = 1;
dst_box.front = 0;
dst_box.back = 1;
wined3d_box_set(&dst_box, dst_x, 0, dst_x + (src_box->right - src_box->left), 1, 0, 1);
}
else if (dst_resource->type == WINED3D_RTYPE_TEXTURE_2D)
{
@ -4038,13 +4019,8 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
if (!src_box)
{
b.left = 0;
b.top = 0;
b.right = wined3d_texture_get_level_width(src_texture, src_level);
b.bottom = wined3d_texture_get_level_height(src_texture, src_level);
b.front = 0;
b.back = 1;
wined3d_box_set(&b, 0, 0, wined3d_texture_get_level_width(src_texture, src_level),
wined3d_texture_get_level_height(src_texture, src_level), 0, 1);
src_box = &b;
}
else if (FAILED(wined3d_texture_check_box_dimensions(src_texture, src_level, src_box)))
@ -4053,12 +4029,8 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
return WINED3DERR_INVALIDCALL;
}
dst_box.left = dst_x;
dst_box.top = dst_y;
dst_box.right = dst_x + (src_box->right - src_box->left);
dst_box.bottom = dst_y + (src_box->bottom - src_box->top);
dst_box.front = 0;
dst_box.back = 1;
wined3d_box_set(&dst_box, dst_x, dst_y, dst_x + (src_box->right - src_box->left),
dst_y + (src_box->bottom - src_box->top), 0, 1);
if (FAILED(wined3d_texture_check_box_dimensions(dst_texture,
dst_sub_resource_idx % dst_texture->level_count, &dst_box)))
{
@ -4124,12 +4096,7 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str
if (!box)
{
b.left = 0;
b.top = 0;
b.right = width;
b.bottom = height;
b.front = 0;
b.back = depth;
wined3d_box_set(&b, 0, 0, width, height, 0, depth);
box = &b;
}
else if (box->left >= box->right || box->right > width

View file

@ -2659,4 +2659,15 @@ static inline unsigned int wined3d_log2i(unsigned int x)
#endif
}
static inline void wined3d_box_set(struct wined3d_box *box, unsigned int left, unsigned int top,
unsigned int right, unsigned int bottom, unsigned int front, unsigned int back)
{
box->left = left;
box->top = top;
box->right = right;
box->bottom = bottom;
box->front = front;
box->back = back;
}
#endif /* __WINE_WINED3D_H */