Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 34cb9f2a authored by Mathias Agopian's avatar Mathias Agopian
Browse files

fix Surface positions are not floats

Added Surface.setPosition(float, float) which allows to set a surface's
position in float.

Bug: 5239859
Change-Id: I903aef4ad5b5999142202fb8ea30fe216d805711
parent 32901b4f
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -442,7 +442,9 @@ public class Surface implements Parcelable {
    /** @hide */
    public native   void setLayer(int zorder);
    /** @hide */
    public native   void setPosition(int x, int y);
    public void setPosition(int x, int y) { setPosition((float)x, (float)y); }
    /** @hide */
    public native   void setPosition(float x, float y);
    /** @hide */
    public native   void setSize(int w, int h);
    /** @hide */
+2 −2
Original line number Diff line number Diff line
@@ -589,7 +589,7 @@ static void Surface_setLayer(
}

static void Surface_setPosition(
        JNIEnv* env, jobject clazz, jint x, jint y)
        JNIEnv* env, jobject clazz, jfloat x, jfloat y)
{
    const sp<SurfaceControl>& surface(getSurfaceControl(env, clazz));
    if (surface == 0) return;
@@ -832,7 +832,7 @@ static JNINativeMethod gSurfaceMethods[] = {
    {"screenshot",          "(II)Landroid/graphics/Bitmap;", (void*)Surface_screenshotAll },
    {"screenshot",          "(IIII)Landroid/graphics/Bitmap;", (void*)Surface_screenshot },
    {"setLayer",            "(I)V", (void*)Surface_setLayer },
    {"setPosition",         "(II)V",(void*)Surface_setPosition },
    {"setPosition",         "(FF)V",(void*)Surface_setPosition },
    {"setSize",             "(II)V",(void*)Surface_setSize },
    {"hide",                "()V",  (void*)Surface_hide },
    {"show",                "()V",  (void*)Surface_show },
+2 −2
Original line number Diff line number Diff line
@@ -54,8 +54,8 @@ struct layer_state_t {
            };
            SurfaceID       surface;
            uint32_t        what;
            int32_t         x;
            int32_t         y;
            float           x;
            float           y;
            uint32_t        z;
            uint32_t        w;
            uint32_t        h;
+1 −1
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ public:
    status_t    setAlpha(SurfaceID id, float alpha=1.0f);
    status_t    setFreezeTint(SurfaceID id, uint32_t tint);
    status_t    setMatrix(SurfaceID id, float dsdx, float dtdx, float dsdy, float dtdy);
    status_t    setPosition(SurfaceID id, int32_t x, int32_t y);
    status_t    setPosition(SurfaceID id, float x, float y);
    status_t    setSize(SurfaceID id, uint32_t w, uint32_t h);
    status_t    destroySurface(SurfaceID sid);

+3 −3
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ class Composer : public Singleton<Composer>
public:

    status_t setPosition(const sp<SurfaceComposerClient>& client, SurfaceID id,
            int32_t x, int32_t y);
            float x, float y);
    status_t setSize(const sp<SurfaceComposerClient>& client, SurfaceID id,
            uint32_t w, uint32_t h);
    status_t setLayer(const sp<SurfaceComposerClient>& client, SurfaceID id,
@@ -161,7 +161,7 @@ layer_state_t* Composer::getLayerStateLocked(
}

status_t Composer::setPosition(const sp<SurfaceComposerClient>& client,
        SurfaceID id, int32_t x, int32_t y) {
        SurfaceID id, float x, float y) {
    Mutex::Autolock _l(mLock);
    layer_state_t* s = getLayerStateLocked(client, id);
    if (!s)
@@ -372,7 +372,7 @@ status_t SurfaceComposerClient::setFreezeTint(SurfaceID id, uint32_t tint) {
    return getComposer().setFreezeTint(this, id, tint);
}

status_t SurfaceComposerClient::setPosition(SurfaceID id, int32_t x, int32_t y) {
status_t SurfaceComposerClient::setPosition(SurfaceID id, float x, float y) {
    return getComposer().setPosition(this, id, x, y);
}

Loading