fix gravity and scaledrawable

This commit is contained in:
houzh 2023-09-13 13:48:41 +08:00
parent fb391ef2e2
commit 43dfd5ef03
4 changed files with 13 additions and 13 deletions

View File

@ -30,7 +30,7 @@ ScaleDrawable::ScaleDrawable(std::shared_ptr<ScaleState> state):DrawableWrapper(
mState = state;
}
ScaleDrawable::ScaleDrawable(Drawable* drawable, int gravity,int scaleWidth,int scaleHeight)
ScaleDrawable::ScaleDrawable(Drawable* drawable, int gravity,float scaleWidth,float scaleHeight)
:ScaleDrawable(std::make_shared<ScaleState>()){
mState->mGravity = gravity;
mState->mScaleWidth = scaleWidth;
@ -62,13 +62,13 @@ void ScaleDrawable::onBoundsChange(const Rect& bounds){
const int level = getLevel();
int w = bounds.width;
if (mState->mScaleWidth > 0) {
if (mState->mScaleWidth > 0.f) {
const int iw = min ? d->getIntrinsicWidth() : 0;
w -= (int) ((w - iw) * (MAX_LEVEL - level) * mState->mScaleWidth / MAX_LEVEL);
}
int h = bounds.height;
if (mState->mScaleHeight > 0) {
if (mState->mScaleHeight > 0.f) {
const int ih = min ? d->getIntrinsicHeight() : 0;
h -= (int) ((h - ih) * (MAX_LEVEL - level) * mState->mScaleHeight / MAX_LEVEL);
}

View File

@ -7,8 +7,8 @@ class ScaleDrawable:public DrawableWrapper{
private:
class ScaleState:public DrawableWrapperState{
public:
int mScaleWidth;
int mScaleHeight;
float mScaleWidth;
float mScaleHeight;
int mGravity;
int mInitialLevel;
bool mUseIntrinsicSizeAsMin;
@ -23,7 +23,7 @@ protected:
bool onLevelChange(int level)override;
std::shared_ptr<DrawableWrapperState> mutateConstantState()override;
public:
ScaleDrawable(Drawable* drawable, int gravity,int scaleWidth,int scaleHeight);
ScaleDrawable(Drawable* drawable, int gravity,float scaleWidth,float scaleHeight);
std::shared_ptr<ConstantState>getConstantState()override;
void draw(Canvas& canvas);
int getOpacity()override;

View File

@ -11,7 +11,7 @@ void Gravity::apply(int gravity, int w, int h,const RECT& container,RECT& outRec
}
void Gravity::apply(int gravity, int w, int h,const RECT& container,RECT& outRect, int layoutDirection){
int absGravity = getAbsoluteGravity(gravity, layoutDirection);
const int absGravity = getAbsoluteGravity(gravity, layoutDirection);
apply(absGravity, w, h, container, 0, 0, outRect);
}
@ -63,7 +63,7 @@ void Gravity::apply(int gravity, int w, int h,const RECT& container,int xAdj, in
outRect.top = container.top;
}
if (outRect.bottom() > container.bottom()) {
outRect.height=container.bottom()-outRect.top;
outRect.height = container.bottom() - outRect.top;
}
}
break;
@ -72,7 +72,7 @@ void Gravity::apply(int gravity, int w, int h,const RECT& container,int xAdj, in
outRect.height = h;
if ((gravity&(AXIS_CLIP<<AXIS_Y_SHIFT)) == (AXIS_CLIP<<AXIS_Y_SHIFT)) {
if (outRect.bottom() > container.bottom()) {
outRect.width=container.bottom()-outRect.top;
outRect.height = container.bottom() - outRect.top;
}
}
break;

View File

@ -310,7 +310,7 @@ void VelocityTrackerImpl::addMovement(const MotionEvent& event) {
}
nsecs_t eventTime;
VelocityTracker::Position positions[128];//pointerCount];
VelocityTracker::Position positions[pointerCount];
size_t historySize = event.getHistorySize();
memset(positions,0,sizeof(positions));
@ -632,7 +632,7 @@ static bool solveLeastSquares(const float* x, const float* y,
#endif
// Expand the X vector to a matrix A, pre-multiplied by the weights.
float a[128][128];//[n][m]; // column-major order
float a[n][m]; // column-major order
for (uint32_t h = 0; h < m; h++) {
a[0][h] = w[h];
for (uint32_t i = 1; i < n; i++) {
@ -644,8 +644,8 @@ static bool solveLeastSquares(const float* x, const float* y,
#endif
// Apply the Gram-Schmidt process to A to obtain its QR decomposition.
float q[128][128];//[n][m]; // orthonormal basis, column-major order
float r[128][128];//[n][n]; // upper triangular matrix, row-major order
float q[n][m]; // orthonormal basis, column-major order
float r[n][n]; // upper triangular matrix, row-major order
for (uint32_t j = 0; j < n; j++) {
for (uint32_t h = 0; h < m; h++) {
q[j][h] = a[j][h];