[Mesa-dev] [PATCH 14/36] st/nine: Handle when cursor stride is not what is expected
Axel Davy
axel.davy at ens.fr
Wed Dec 7 22:30:37 UTC 2016
SetCursor assumes for now a 32x32 argb cursor with pitch 128.
32x32 argb doesn't have pitch 128 on all hw, thus use a
temporary surface with the correct pitch when needed.
Signed-off-by: Axel Davy <axel.davy at ens.fr>
---
src/gallium/state_trackers/nine/device9.c | 20 ++++++++++++++++++--
src/gallium/state_trackers/nine/device9.h | 1 +
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index ddac548..a78d18e 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -315,6 +315,11 @@ NineDevice9_ctor( struct NineDevice9 *This,
This->cursor.image = pScreen->resource_create(pScreen, &tmpl);
if (!This->cursor.image)
return D3DERR_OUTOFVIDEOMEMORY;
+
+ /* For uploading 32x32 (argb) cursor */
+ This->cursor.hw_upload_temp = MALLOC(32 * 4 * 32);
+ if (!This->cursor.hw_upload_temp)
+ return D3DERR_OUTOFVIDEOMEMORY;
}
/* Create constant buffers. */
@@ -506,6 +511,8 @@ NineDevice9_dtor( struct NineDevice9 *This )
FREE(This->state.vs_const_b);
FREE(This->state.vs_const_f_swvp);
+ FREE(This->cursor.hw_upload_temp);
+
if (This->swapchains) {
for (i = 0; i < This->nswapchains; ++i)
if (This->swapchains[i])
@@ -709,11 +716,20 @@ NineDevice9_SetCursorProperties( struct NineDevice9 *This,
lock.pBits, lock.Pitch,
This->cursor.w, This->cursor.h);
- if (hw_cursor)
+ if (hw_cursor) {
+ void *data = lock.pBits;
+ /* SetCursor assumes 32x32 argb with pitch 128 */
+ if (lock.Pitch != 128) {
+ sfmt->unpack_rgba_8unorm(This->cursor.hw_upload_temp, 128,
+ lock.pBits, lock.Pitch,
+ 32, 32);
+ data = This->cursor.hw_upload_temp;
+ }
hw_cursor = ID3DPresent_SetCursor(This->swapchains[0]->present,
- lock.pBits,
+ data,
&This->cursor.hotspot,
This->cursor.visible) == D3D_OK;
+ }
NineSurface9_UnlockRect(surf);
}
diff --git a/src/gallium/state_trackers/nine/device9.h b/src/gallium/state_trackers/nine/device9.h
index 12be643..d698cee 100644
--- a/src/gallium/state_trackers/nine/device9.h
+++ b/src/gallium/state_trackers/nine/device9.h
@@ -112,6 +112,7 @@ struct NineDevice9
POINT pos;
BOOL visible;
boolean software;
+ void *hw_upload_temp;
} cursor;
struct {
--
2.10.2
More information about the mesa-dev
mailing list