diff options
author | Axel Davy <[email protected]> | 2019-04-10 22:48:51 +0200 |
---|---|---|
committer | Axel Davy <[email protected]> | 2019-04-30 19:18:50 +0200 |
commit | 85c9d92067d28ce07c3a0c41f4ea225b3768db9c (patch) | |
tree | d4370980323f1bcd77faad98e422516aed956d77 /src/gallium | |
parent | 8ba4f73911a80f1dd377e5041d90e8da72d61478 (diff) |
st/nine: Refactor surface GetSystemMemPointer
It will make it easier to reuse in another place.
Signed-off-by: Axel Davy <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/state_trackers/nine/surface9.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/gallium/state_trackers/nine/surface9.c b/src/gallium/state_trackers/nine/surface9.c index 3266588e478..853e5a66f4c 100644 --- a/src/gallium/state_trackers/nine/surface9.c +++ b/src/gallium/state_trackers/nine/surface9.c @@ -394,15 +394,15 @@ NineSurface9_AddDirtyRect( struct NineSurface9 *This, } } -static inline uint8_t * -NineSurface9_GetSystemMemPointer(struct NineSurface9 *This, int x, int y) +static inline unsigned +NineSurface9_GetSystemMemOffset(enum pipe_format format, unsigned stride, + int x, int y) { - unsigned x_offset = util_format_get_stride(This->base.info.format, x); + unsigned x_offset = util_format_get_stride(format, x); - y = util_format_get_nblocksy(This->base.info.format, y); + y = util_format_get_nblocksy(format, y); - assert(This->data); - return This->data + (y * This->stride + x_offset); + return y * stride + x_offset; } HRESULT NINE_WINAPI @@ -497,9 +497,11 @@ NineSurface9_LockRect( struct NineSurface9 *This, pLockedRect->pBits = This->data + box.y * This->desc.Width + box.x; } else { pLockedRect->Pitch = This->stride; - pLockedRect->pBits = NineSurface9_GetSystemMemPointer(This, - box.x, - box.y); + pLockedRect->pBits = This->data + + NineSurface9_GetSystemMemOffset(This->base.info.format, + This->stride, + box.x, + box.y); } } else { bool no_refs = !p_atomic_read(&This->base.base.bind) && @@ -721,7 +723,7 @@ NineSurface9_CopyDefaultToMem( struct NineSurface9 *This, p_src = pipe->transfer_map(pipe, r_src, From->level, PIPE_TRANSFER_READ, &src_box, &transfer); - p_dst = NineSurface9_GetSystemMemPointer(This, 0, 0); + p_dst = This->data; assert (p_src && p_dst); |