steamcompmgr: Handle cursor image width being different to surface width for rotation offset
The surface width for the cursor is 256, but the image width is 64 which means we have a bunch of blank space, so we need to account for this in DRM code for the CRTC offsets.
This commit is contained in:
parent
8313853802
commit
a1d560e836
4 changed files with 35 additions and 13 deletions
|
@ -1074,8 +1074,10 @@ drm_prepare_basic( struct drm_t *drm, const struct Composite_t *pComposite, cons
|
||||||
|
|
||||||
if ( g_bRotated )
|
if ( g_bRotated )
|
||||||
{
|
{
|
||||||
|
int64_t imageH = pPipeline->layerBindings[ 0 ].imageHeight / pComposite->data.vScale[ 0 ].y;
|
||||||
|
|
||||||
int64_t tmp = crtcX;
|
int64_t tmp = crtcX;
|
||||||
crtcX = g_nOutputHeight - crtcH - crtcY;
|
crtcX = g_nOutputHeight - imageH - crtcY;
|
||||||
crtcY = tmp;
|
crtcY = tmp;
|
||||||
|
|
||||||
tmp = crtcW;
|
tmp = crtcW;
|
||||||
|
@ -1135,9 +1137,11 @@ drm_prepare_liftoff( struct drm_t *drm, const struct Composite_t *pComposite, co
|
||||||
uint64_t crtcH = srcHeight / pComposite->data.vScale[ i ].y;
|
uint64_t crtcH = srcHeight / pComposite->data.vScale[ i ].y;
|
||||||
|
|
||||||
if (g_bRotated) {
|
if (g_bRotated) {
|
||||||
|
int64_t imageH = pPipeline->layerBindings[ i ].imageHeight / pComposite->data.vScale[ i ].y;
|
||||||
|
|
||||||
const int32_t x = crtcX;
|
const int32_t x = crtcX;
|
||||||
const uint64_t w = crtcW;
|
const uint64_t w = crtcW;
|
||||||
crtcX = g_nOutputHeight - crtcH - crtcY;
|
crtcX = g_nOutputHeight - imageH - crtcY;
|
||||||
crtcY = x;
|
crtcY = x;
|
||||||
crtcW = crtcH;
|
crtcW = crtcH;
|
||||||
crtcH = w;
|
crtcH = w;
|
||||||
|
|
|
@ -33,6 +33,9 @@ struct VulkanPipeline_t
|
||||||
{
|
{
|
||||||
int surfaceWidth;
|
int surfaceWidth;
|
||||||
int surfaceHeight;
|
int surfaceHeight;
|
||||||
|
|
||||||
|
int imageWidth;
|
||||||
|
int imageHeight;
|
||||||
|
|
||||||
std::shared_ptr<CVulkanTexture> tex;
|
std::shared_ptr<CVulkanTexture> tex;
|
||||||
uint32_t fbid;
|
uint32_t fbid;
|
||||||
|
|
|
@ -1067,12 +1067,17 @@ bool MouseCursor::getTexture()
|
||||||
m_hotspotX = image->xhot;
|
m_hotspotX = image->xhot;
|
||||||
m_hotspotY = image->yhot;
|
m_hotspotY = image->yhot;
|
||||||
|
|
||||||
m_width = image->width;
|
m_imageWidth = image->width;
|
||||||
m_height = image->height;
|
m_imageHeight = image->height;
|
||||||
if ( BIsNested() == false && alwaysComposite == false )
|
if ( BIsNested() == false && alwaysComposite == false )
|
||||||
{
|
{
|
||||||
m_width = g_DRM.cursor_width;
|
m_surfaceWidth = g_DRM.cursor_width;
|
||||||
m_height = g_DRM.cursor_height;
|
m_surfaceHeight = g_DRM.cursor_height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_surfaceWidth = m_imageWidth;
|
||||||
|
m_surfaceHeight = m_imageHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_texture = nullptr;
|
m_texture = nullptr;
|
||||||
|
@ -1080,12 +1085,12 @@ bool MouseCursor::getTexture()
|
||||||
// Assume the cursor is fully translucent unless proven otherwise.
|
// Assume the cursor is fully translucent unless proven otherwise.
|
||||||
bool bNoCursor = true;
|
bool bNoCursor = true;
|
||||||
|
|
||||||
auto cursorBuffer = std::vector<uint32_t>(m_width * m_height);
|
auto cursorBuffer = std::vector<uint32_t>(m_surfaceWidth * m_surfaceHeight);
|
||||||
for (int i = 0; i < image->height; i++) {
|
for (int i = 0; i < image->height; i++) {
|
||||||
for (int j = 0; j < image->width; j++) {
|
for (int j = 0; j < image->width; j++) {
|
||||||
cursorBuffer[i * m_width + j] = image->pixels[i * image->width + j];
|
cursorBuffer[i * m_surfaceWidth + j] = image->pixels[i * image->width + j];
|
||||||
|
|
||||||
if ( cursorBuffer[i * m_width + j] & 0xff000000 ) {
|
if ( cursorBuffer[i * m_surfaceWidth + j] & 0xff000000 ) {
|
||||||
bNoCursor = false;
|
bNoCursor = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1111,7 +1116,7 @@ bool MouseCursor::getTexture()
|
||||||
// TODO: choose format & modifiers from cursor plane
|
// TODO: choose format & modifiers from cursor plane
|
||||||
}
|
}
|
||||||
|
|
||||||
m_texture = vulkan_create_texture_from_bits(m_width, m_height, DRM_FORMAT_ARGB8888, texCreateFlags, cursorBuffer.data());
|
m_texture = vulkan_create_texture_from_bits(m_surfaceWidth, m_surfaceHeight, DRM_FORMAT_ARGB8888, texCreateFlags, cursorBuffer.data());
|
||||||
assert(m_texture);
|
assert(m_texture);
|
||||||
XFree(image);
|
XFree(image);
|
||||||
m_dirty = false;
|
m_dirty = false;
|
||||||
|
@ -1183,8 +1188,11 @@ void MouseCursor::paint(win *window, win *fit, struct Composite_t *pComposite,
|
||||||
pComposite->data.vOffset[ curLayer ].x = -scaledX;
|
pComposite->data.vOffset[ curLayer ].x = -scaledX;
|
||||||
pComposite->data.vOffset[ curLayer ].y = -scaledY;
|
pComposite->data.vOffset[ curLayer ].y = -scaledY;
|
||||||
|
|
||||||
pPipeline->layerBindings[ curLayer ].surfaceWidth = m_width;
|
pPipeline->layerBindings[ curLayer ].surfaceWidth = m_surfaceWidth;
|
||||||
pPipeline->layerBindings[ curLayer ].surfaceHeight = m_height;
|
pPipeline->layerBindings[ curLayer ].surfaceHeight = m_surfaceHeight;
|
||||||
|
|
||||||
|
pPipeline->layerBindings[ curLayer ].imageWidth = m_imageWidth;
|
||||||
|
pPipeline->layerBindings[ curLayer ].imageHeight = m_imageHeight;
|
||||||
|
|
||||||
pPipeline->layerBindings[ curLayer ].zpos = g_zposCursor; // cursor, on top of both bottom layers
|
pPipeline->layerBindings[ curLayer ].zpos = g_zposCursor; // cursor, on top of both bottom layers
|
||||||
|
|
||||||
|
@ -1380,6 +1388,9 @@ paint_window(win *w, win *scaleW, struct Composite_t *pComposite,
|
||||||
pPipeline->layerBindings[ curLayer ].surfaceWidth = w->a.width;
|
pPipeline->layerBindings[ curLayer ].surfaceWidth = w->a.width;
|
||||||
pPipeline->layerBindings[ curLayer ].surfaceHeight = w->a.height;
|
pPipeline->layerBindings[ curLayer ].surfaceHeight = w->a.height;
|
||||||
|
|
||||||
|
pPipeline->layerBindings[ curLayer ].imageWidth = w->a.width;
|
||||||
|
pPipeline->layerBindings[ curLayer ].imageHeight = w->a.height;
|
||||||
|
|
||||||
pPipeline->layerBindings[ curLayer ].zpos = g_zposBase;
|
pPipeline->layerBindings[ curLayer ].zpos = g_zposBase;
|
||||||
|
|
||||||
if ( w != scaleW )
|
if ( w != scaleW )
|
||||||
|
@ -1687,6 +1698,9 @@ paint_all()
|
||||||
pipeline.layerBindings[ 0 ].surfaceWidth = g_nOutputWidth;
|
pipeline.layerBindings[ 0 ].surfaceWidth = g_nOutputWidth;
|
||||||
pipeline.layerBindings[ 0 ].surfaceHeight = g_nOutputHeight;
|
pipeline.layerBindings[ 0 ].surfaceHeight = g_nOutputHeight;
|
||||||
|
|
||||||
|
pipeline.layerBindings[ 0 ].imageWidth = g_nOutputWidth;
|
||||||
|
pipeline.layerBindings[ 0 ].imageHeight = g_nOutputHeight;
|
||||||
|
|
||||||
pipeline.layerBindings[ 0 ].fbid = vulkan_get_last_composite_fbid();
|
pipeline.layerBindings[ 0 ].fbid = vulkan_get_last_composite_fbid();
|
||||||
pipeline.layerBindings[ 0 ].bFilter = false;
|
pipeline.layerBindings[ 0 ].bFilter = false;
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,8 @@ private:
|
||||||
|
|
||||||
int m_x = 0, m_y = 0;
|
int m_x = 0, m_y = 0;
|
||||||
int m_hotspotX = 0, m_hotspotY = 0;
|
int m_hotspotX = 0, m_hotspotY = 0;
|
||||||
int m_width = 0, m_height = 0;
|
int m_surfaceWidth = 0, m_surfaceHeight = 0;
|
||||||
|
int m_imageWidth = 0, m_imageHeight = 0;
|
||||||
|
|
||||||
std::shared_ptr<CVulkanTexture> m_texture;
|
std::shared_ptr<CVulkanTexture> m_texture;
|
||||||
bool m_dirty;
|
bool m_dirty;
|
||||||
|
|
Loading…
Reference in a new issue