mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-12 12:05:08 +08:00
fix RenderNode::getMatrix
This commit is contained in:
parent
80c323be8c
commit
6c56ea2a77
@ -26,18 +26,32 @@ bool RenderNode::hasIdentityMatrix()const{
|
||||
return rc;
|
||||
}
|
||||
|
||||
static inline float sdot(float a,float b,float c,float d){
|
||||
return a * b + c * d;
|
||||
}
|
||||
|
||||
void RenderNode::getMatrix(Matrix&outMatrix)const{
|
||||
outMatrix = identity_matrix();
|
||||
#if 1
|
||||
const float px = (mPivotX==FLT_MIN)?(mRight - mLeft)/2:mPivotX;
|
||||
const float py = (mPivotY==FLT_MIN)?(mBottom- mTop)/2:mPivotY;
|
||||
outMatrix.translate(px,py);
|
||||
outMatrix.scale(mScaleX,mScaleY);
|
||||
outMatrix.rotate(mRotation*M_PI/180.f);
|
||||
outMatrix.translate(mTranslationX - px,mTranslationY - py);
|
||||
outMatrix.scale(mScaleX,mScaleY);
|
||||
outMatrix.translate(-px,-py);
|
||||
Matrix rt = identity_matrix();
|
||||
rt.translate(mTranslationX,mTranslationY);
|
||||
outMatrix.multiply(outMatrix,rt);
|
||||
#else
|
||||
auto sdot=[](float a,float b,float c,float d)->float{
|
||||
return a * b + c * d;
|
||||
};
|
||||
outMatrix.translate(mTranslationX,mTranslationY);
|
||||
outMatrix.scale(mScaleX,mScaleY);
|
||||
|
||||
const float radians = mRotation*M_PI/180.f;
|
||||
const float fsin = sin(radians);
|
||||
const float fcos = cos(radians);
|
||||
Matrix rt(fcos,-fsin, fsin,fcos, sdot(-fsin,mPivotY,1.f-fcos,mPivotX),sdot(fsin,mPivotX,1.f-fcos,mPivotY));
|
||||
outMatrix.multiply(outMatrix,rt);
|
||||
#endif
|
||||
}
|
||||
|
||||
void RenderNode::getInverseMatrix(Matrix&outMatrix)const{
|
||||
|
@ -121,7 +121,7 @@ View::View(Context*ctx,const AttributeSet&attrs){
|
||||
if(attrs.hasAttribute("transformPivotX"))
|
||||
setPivotX(attrs.getDimensionPixelSize("transformPivotX",0));
|
||||
if(attrs.hasAttribute("transformPivotY"))
|
||||
setPivotY(attrs.getDimensionPixelSize("transformPivotY",0));
|
||||
setPivotY(attrs.getDimensionPixelSize("transformPivotY",0));
|
||||
|
||||
setKeyboardNavigationCluster( attrs.getBoolean("keyboardNavigationCluster",false) );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user