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
This commit is contained in:
parent
4e92d140ef
commit
41b6aabf35
@ -54,8 +54,8 @@ struct layer_state_t {
|
|||||||
};
|
};
|
||||||
SurfaceID surface;
|
SurfaceID surface;
|
||||||
uint32_t what;
|
uint32_t what;
|
||||||
int32_t x;
|
float x;
|
||||||
int32_t y;
|
float y;
|
||||||
uint32_t z;
|
uint32_t z;
|
||||||
uint32_t w;
|
uint32_t w;
|
||||||
uint32_t h;
|
uint32_t h;
|
||||||
|
@ -145,7 +145,7 @@ public:
|
|||||||
status_t setAlpha(SurfaceID id, float alpha=1.0f);
|
status_t setAlpha(SurfaceID id, float alpha=1.0f);
|
||||||
status_t setFreezeTint(SurfaceID id, uint32_t tint);
|
status_t setFreezeTint(SurfaceID id, uint32_t tint);
|
||||||
status_t setMatrix(SurfaceID id, float dsdx, float dtdx, float dsdy, float dtdy);
|
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 setSize(SurfaceID id, uint32_t w, uint32_t h);
|
||||||
status_t destroySurface(SurfaceID sid);
|
status_t destroySurface(SurfaceID sid);
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ class Composer : public Singleton<Composer>
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
status_t setPosition(const sp<SurfaceComposerClient>& client, SurfaceID id,
|
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,
|
status_t setSize(const sp<SurfaceComposerClient>& client, SurfaceID id,
|
||||||
uint32_t w, uint32_t h);
|
uint32_t w, uint32_t h);
|
||||||
status_t setLayer(const sp<SurfaceComposerClient>& client, SurfaceID id,
|
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,
|
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);
|
Mutex::Autolock _l(mLock);
|
||||||
layer_state_t* s = getLayerStateLocked(client, id);
|
layer_state_t* s = getLayerStateLocked(client, id);
|
||||||
if (!s)
|
if (!s)
|
||||||
@ -372,7 +372,7 @@ status_t SurfaceComposerClient::setFreezeTint(SurfaceID id, uint32_t tint) {
|
|||||||
return getComposer().setFreezeTint(this, id, 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);
|
return getComposer().setPosition(this, id, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,6 @@ LayerBase::LayerBase(SurfaceFlinger* flinger, DisplayID display)
|
|||||||
mFlinger(flinger), mFiltering(false),
|
mFlinger(flinger), mFiltering(false),
|
||||||
mNeedsFiltering(false),
|
mNeedsFiltering(false),
|
||||||
mOrientation(0),
|
mOrientation(0),
|
||||||
mLeft(0), mTop(0),
|
|
||||||
mTransactionFlags(0),
|
mTransactionFlags(0),
|
||||||
mPremultipliedAlpha(true), mName("unnamed"), mDebug(false),
|
mPremultipliedAlpha(true), mName("unnamed"), mDebug(false),
|
||||||
mInvalidate(0)
|
mInvalidate(0)
|
||||||
@ -119,7 +118,7 @@ uint32_t LayerBase::setTransactionFlags(uint32_t flags) {
|
|||||||
return android_atomic_or(flags, &mTransactionFlags);
|
return android_atomic_or(flags, &mTransactionFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LayerBase::setPosition(int32_t x, int32_t y) {
|
bool LayerBase::setPosition(float x, float y) {
|
||||||
if (mCurrentState.transform.tx() == x && mCurrentState.transform.ty() == y)
|
if (mCurrentState.transform.tx() == x && mCurrentState.transform.ty() == y)
|
||||||
return false;
|
return false;
|
||||||
mCurrentState.sequence++;
|
mCurrentState.sequence++;
|
||||||
@ -259,8 +258,6 @@ void LayerBase::validateVisibility(const Transform& planeTransform)
|
|||||||
mOrientation = tr.getOrientation();
|
mOrientation = tr.getOrientation();
|
||||||
mTransform = tr;
|
mTransform = tr;
|
||||||
mTransformedBounds = tr.makeBounds(w, h);
|
mTransformedBounds = tr.makeBounds(w, h);
|
||||||
mLeft = tr.tx();
|
|
||||||
mTop = tr.ty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerBase::lockPageFlip(bool& recomputeVisibleRegions)
|
void LayerBase::lockPageFlip(bool& recomputeVisibleRegions)
|
||||||
@ -476,10 +473,10 @@ void LayerBase::dump(String8& result, char* buffer, size_t SIZE) const
|
|||||||
snprintf(buffer, SIZE,
|
snprintf(buffer, SIZE,
|
||||||
"+ %s %p\n"
|
"+ %s %p\n"
|
||||||
" "
|
" "
|
||||||
"z=%9d, pos=(%4d,%4d), size=(%4d,%4d), "
|
"z=%9d, pos=(%g,%g), size=(%4d,%4d), "
|
||||||
"isOpaque=%1d, needsDithering=%1d, invalidate=%1d, "
|
"isOpaque=%1d, needsDithering=%1d, invalidate=%1d, "
|
||||||
"alpha=0x%02x, flags=0x%08x, tr=[%.2f, %.2f][%.2f, %.2f]\n",
|
"alpha=0x%02x, flags=0x%08x, tr=[%.2f, %.2f][%.2f, %.2f]\n",
|
||||||
getTypeId(), this, s.z, tx(), ty(), s.w, s.h,
|
getTypeId(), this, s.z, s.transform.tx(), s.transform.ty(), s.w, s.h,
|
||||||
isOpaque(), needsDithering(), contentDirty,
|
isOpaque(), needsDithering(), contentDirty,
|
||||||
s.alpha, s.flags,
|
s.alpha, s.flags,
|
||||||
s.transform[0][0], s.transform[0][1],
|
s.transform[0][0], s.transform[0][1],
|
||||||
|
@ -84,7 +84,7 @@ public:
|
|||||||
String8 getName() const;
|
String8 getName() const;
|
||||||
|
|
||||||
// modify current state
|
// modify current state
|
||||||
bool setPosition(int32_t x, int32_t y);
|
bool setPosition(float x, float y);
|
||||||
bool setLayer(uint32_t z);
|
bool setLayer(uint32_t z);
|
||||||
bool setSize(uint32_t w, uint32_t h);
|
bool setSize(uint32_t w, uint32_t h);
|
||||||
bool setAlpha(uint8_t alpha);
|
bool setAlpha(uint8_t alpha);
|
||||||
@ -217,8 +217,6 @@ public:
|
|||||||
inline State& currentState() { return mCurrentState; }
|
inline State& currentState() { return mCurrentState; }
|
||||||
|
|
||||||
int32_t getOrientation() const { return mOrientation; }
|
int32_t getOrientation() const { return mOrientation; }
|
||||||
int tx() const { return mLeft; }
|
|
||||||
int ty() const { return mTop; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const GraphicPlane& graphicPlane(int dpy) const;
|
const GraphicPlane& graphicPlane(int dpy) const;
|
||||||
@ -250,8 +248,6 @@ protected:
|
|||||||
Transform mTransform;
|
Transform mTransform;
|
||||||
GLfloat mVertices[4][2];
|
GLfloat mVertices[4][2];
|
||||||
Rect mTransformedBounds;
|
Rect mTransformedBounds;
|
||||||
int mLeft;
|
|
||||||
int mTop;
|
|
||||||
|
|
||||||
// these are protected by an external lock
|
// these are protected by an external lock
|
||||||
State mCurrentState;
|
State mCurrentState;
|
||||||
|
@ -91,12 +91,12 @@ bool Transform::transformed() const {
|
|||||||
return type() > TRANSLATE;
|
return type() > TRANSLATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Transform::tx() const {
|
float Transform::tx() const {
|
||||||
return floorf(mMatrix[2][0] + 0.5f);
|
return mMatrix[2][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
int Transform::ty() const {
|
float Transform::ty() const {
|
||||||
return floorf(mMatrix[2][1] + 0.5f);
|
return mMatrix[2][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transform::reset() {
|
void Transform::reset() {
|
||||||
@ -239,7 +239,9 @@ Region Transform::transform(const Region& reg) const
|
|||||||
out.set(transform(reg.bounds()));
|
out.set(transform(reg.bounds()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
out = reg.translate(tx(), ty());
|
int xpos = floorf(tx() + 0.5f);
|
||||||
|
int ypos = floorf(ty() + 0.5f);
|
||||||
|
out = reg.translate(xpos, ypos);
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -64,8 +64,8 @@ public:
|
|||||||
uint32_t getOrientation() const;
|
uint32_t getOrientation() const;
|
||||||
|
|
||||||
float const* operator [] (int i) const; // returns column i
|
float const* operator [] (int i) const; // returns column i
|
||||||
int tx() const;
|
float tx() const;
|
||||||
int ty() const;
|
float ty() const;
|
||||||
|
|
||||||
// modify the transform
|
// modify the transform
|
||||||
void reset();
|
void reset();
|
||||||
|
Loading…
Reference in New Issue
Block a user