[egl] fix incorrect mouse size and position scaling

This commit is contained in:
Geoffrey McRae 2018-09-24 20:11:42 +10:00
parent 375b97ca6f
commit 2db26ae37e

View file

@ -83,7 +83,6 @@ struct Inst
size_t frameSize; size_t frameSize;
const uint8_t * data; const uint8_t * data;
bool update; bool update;
int screenW, screenH;
bool mouseVisible; bool mouseVisible;
float mouseX, mouseY, mouseW, mouseH; float mouseX, mouseY, mouseW, mouseH;
@ -165,15 +164,12 @@ void egl_on_resize(void * opaque, const int width, const int height, const LG_Re
{ {
struct Inst * this = (struct Inst *)opaque; struct Inst * this = (struct Inst *)opaque;
this->screenW = width;
this->screenH = height;
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
this->mouseScaleX = 2.0f / width ;
this->mouseScaleY = 2.0f / height;
this->mouseW = this->mouseWidth * (1.0f / this->screenW); this->mouseScaleX = 2.0f / this->format.width;
this->mouseH = this->mouseHeight * (1.0f / this->screenH); this->mouseScaleY = 2.0f / this->format.height;
this->mouseW = this->mouseWidth * (1.0f / this->format.width );
this->mouseH = this->mouseHeight * (1.0f / this->format.height);
} }
bool egl_on_mouse_shape(void * opaque, const LG_RendererCursor cursor, const int width, const int height, const int pitch, const uint8_t * data) bool egl_on_mouse_shape(void * opaque, const LG_RendererCursor cursor, const int width, const int height, const int pitch, const uint8_t * data)
@ -186,8 +182,8 @@ bool egl_on_mouse_shape(void * opaque, const LG_RendererCursor cursor, const int
this->mouseHeight = height; this->mouseHeight = height;
this->mousePitch = pitch; this->mousePitch = pitch;
this->mouseW = this->mouseWidth * (1.0f / this->screenW); this->mouseW = this->mouseWidth * (1.0f / this->format.width );
this->mouseH = this->mouseHeight * (1.0f / this->screenH); this->mouseH = this->mouseHeight * (1.0f / this->format.height);
const size_t size = height * pitch; const size_t size = height * pitch;
if (size > this->mouseDataSize) if (size > this->mouseDataSize)