提交 d1dc3aee 编写于 作者: L liqiang

Add 3d transformation

Change-Id: I615b7ae868c1952b65a37cf913ed43a54a458209
Signed-off-by: Nliqiang <liqiang121@huawei.com>
上级 41769a95
......@@ -505,7 +505,6 @@ void RootView::BlitMapBuffer(Rect& curViewRect, TransformMap& transMap, const Re
Rect invalidRect = curViewRect;
transMap.SetTransMapRect(curViewRect);
invalidRect.Join(invalidRect, transMap.GetBoxRect());
if (invalidRect.Intersect(invalidRect, invalidatedArea)) {
uint8_t pxSize = DrawUtils::GetPxSizeByColorMode(dc_.mapBufferInfo->mode);
ImageInfo imageInfo;
......@@ -706,6 +705,14 @@ UIView* RootView::GetTopUIView(const Rect& rect)
currentView = (g_viewStack[stackCount])->GetNextSibling();
}
}
UIView* parentView = topView;
while (parentView->GetParent() != nullptr) {
UIView* tempView = parentView;
parentView = parentView->GetParent();
if (!tempView->IsTransInvalid()) {
topView = parentView;
}
}
return topView;
}
......
......@@ -266,7 +266,7 @@ void UIImageView::SetResizeMode(ImageResizeMode mode)
}
}
void UIImageView::AdjustScaleAndTranslate(Vector2<float>& scale, Vector2<int16_t>& translate,
void UIImageView::AdjustScaleAndTranslate(Vector3<float>& scale, Vector3<int16_t>& translate,
int16_t widgetWidth, int16_t widgetHeight) const
{
// adjust scale
......@@ -314,7 +314,7 @@ void UIImageView::UpdateContentMatrix()
return;
}
if (contentMatrix_ == nullptr) {
contentMatrix_ = new Matrix3<float>();
contentMatrix_ = new Matrix4<float>();
if (contentMatrix_ == nullptr) {
GRAPHIC_LOGE("can not new contentMatrix");
return;
......@@ -327,13 +327,13 @@ void UIImageView::UpdateContentMatrix()
float scaleX = static_cast<float>(widgetWidth) / static_cast<float>(imageWidth_);
float scaleY = static_cast<float>(widgetHeight) / static_cast<float>(imageHeight_);
Vector2<float> scale(scaleX, scaleY);
Vector2<int16_t> translate(style_->paddingLeft_ + style_->borderWidth_,
style_->paddingTop_ + style_->borderWidth_);
Vector3<float> scale(scaleX, scaleY, 1.0f);
Vector3<int16_t> translate(style_->paddingLeft_ + style_->borderWidth_,
style_->paddingTop_ + style_->borderWidth_, 0);
AdjustScaleAndTranslate(scale, translate, widgetWidth, widgetHeight);
auto scaleMatrix = Matrix3<float>::Scale(scale, Vector2<float>(viewRect.GetX(), viewRect.GetY()));
auto translateMatrix = Matrix3<float>::Translate(Vector2<float>(translate.x_, translate.y_));
auto scaleMatrix = Matrix4<float>::Scale(scale, Vector3<float>(viewRect.GetX(), viewRect.GetY(), 0));
auto translateMatrix = Matrix4<float>::Translate(Vector3<float>(translate.x_, translate.y_, 0));
*contentMatrix_ = translateMatrix * scaleMatrix;
}
......@@ -382,7 +382,7 @@ void UIImageView::UpdateDrawTransMap(bool updateContentMatrix)
}
// merge the transMap and content matrix
auto rect = transMap_->GetTransMapRect();
auto translate = Matrix3<float>::Translate(Vector2<float>(-rect.GetX(), -rect.GetY()));
auto translate = Matrix4<float>::Translate(Vector3<float>(-rect.GetX(), -rect.GetY(), 0));
auto matrix = transMap_->GetTransformMatrix() * translate;
matrix = matrix * (*contentMatrix_);
drawTransMap_->SetMatrix(matrix);
......
......@@ -245,32 +245,43 @@ void UIView::UpdateRectInfo(uint8_t key, const Rect& rect)
}
void UIView::Rotate(int16_t angle, const Vector2<float>& pivot)
{
Vector3<float> pivotStart3D = Vector3<float>(pivot.x_, pivot.y_, 0);
Vector3<float> pivotEnd3D = Vector3<float>(pivot.x_, pivot.y_, 1.0f);
Rotate(angle, pivotStart3D, pivotEnd3D);
}
void UIView::Rotate(int16_t angle, const Vector3<float>& pivotStart, const Vector3<float>& pivotEnd)
{
if (transMap_ == nullptr) {
ReMeasure();
transMap_ = new TransformMap();
if (transMap_ == nullptr) {
GRAPHIC_LOGE("new TransformMap fail");
return;
}
}
bool firstTrans = transMap_->IsInvalid();
Rect joinRect = transMap_->GetBoxRect();
transMap_->SetTransMapRect(GetOrigRect());
transMap_->Rotate(angle, pivot);
joinRect.Join(joinRect, transMap_->GetBoxRect());
transMap_->Rotate(angle, pivotStart, pivotEnd);
if (firstTrans) {
joinRect = transMap_->GetBoxRect();
} else {
joinRect.Join(joinRect, transMap_->GetBoxRect());
}
joinRect.Join(joinRect, GetOrigRect());
InvalidateRect(joinRect);
}
void UIView::Scale(const Vector2<float>& scale, const Vector2<float>& pivot)
{
Vector3<float> scale3D = Vector3<float>(scale.x_, scale.y_, 1.0f);
Vector3<float> pivot3D = Vector3<float>(scale.x_, scale.y_, 0);
Scale(scale3D, pivot3D);
}
void UIView::Scale(const Vector3<float>& scale, const Vector3<float>& pivot)
{
if (transMap_ == nullptr) {
ReMeasure();
transMap_ = new TransformMap();
if (transMap_ == nullptr) {
GRAPHIC_LOGE("new TransformMap fail");
return;
}
}
bool firstTrans = transMap_->IsInvalid();
Rect joinRect = transMap_->GetBoxRect();
......@@ -285,23 +296,47 @@ void UIView::Scale(const Vector2<float>& scale, const Vector2<float>& pivot)
InvalidateRect(joinRect);
}
void UIView::Translate(const Vector2<int16_t>& trans)
void UIView::Shear(const Vector2<float>& shearX, const Vector2<float>& shearY, const Vector2<float>& shearZ)
{
if (transMap_ == nullptr) {
ReMeasure();
transMap_ = new TransformMap(GetOrigRect());
if (transMap_ == nullptr) {
GRAPHIC_LOGE("new TransformMap fail");
return;
}
transMap_ = new TransformMap();
}
transMap_->Translate(trans);
bool firstTrans = transMap_->IsInvalid();
Rect joinRect = transMap_->GetBoxRect();
transMap_->SetTransMapRect(GetOrigRect());
transMap_->Shear(shearX, shearY, shearZ);
if (firstTrans) {
joinRect = transMap_->GetBoxRect();
} else {
joinRect.Join(joinRect, transMap_->GetBoxRect());
}
joinRect.Join(joinRect, GetOrigRect());
InvalidateRect(joinRect);
}
Rect prevRect = GetRect();
Rect mapRect = transMap_->GetBoxRect();
void UIView::Translate(const Vector2<int16_t>& trans)
{
Vector3<int16_t> trans3D = Vector3<int16_t>(trans.x_, trans.y_, 0);
Translate(trans3D);
}
Rect joinRect;
joinRect.Join(prevRect, mapRect);
void UIView::Translate(const Vector3<int16_t>& trans)
{
if (transMap_ == nullptr) {
ReMeasure();
transMap_ = new TransformMap();
}
bool firstTrans = transMap_->IsInvalid();
Rect joinRect = transMap_->GetBoxRect();
transMap_->SetTransMapRect(GetOrigRect());
transMap_->Translate(trans);
if (firstTrans) {
joinRect = transMap_->GetBoxRect();
} else {
joinRect.Join(joinRect, transMap_->GetBoxRect());
}
joinRect.Join(joinRect, GetOrigRect());
InvalidateRect(joinRect);
}
......@@ -313,6 +348,34 @@ bool UIView::IsTransInvalid()
return transMap_->IsInvalid();
}
void UIView::SetCameraDistance(int16_t distance)
{
if (transMap_ == nullptr) {
ReMeasure();
transMap_ = new TransformMap();
}
Rect joinRect = transMap_->GetBoxRect();
transMap_->SetTransMapRect(GetOrigRect());
transMap_->SetCameraDistance(distance);
joinRect.Join(joinRect, transMap_->GetBoxRect());
joinRect.Join(joinRect, GetOrigRect());
InvalidateRect(joinRect);
}
void UIView::SetCameraPosition(const Vector2<float>& position)
{
if (transMap_ == nullptr) {
ReMeasure();
transMap_ = new TransformMap();
}
Rect joinRect = transMap_->GetBoxRect();
transMap_->SetTransMapRect(GetOrigRect());
transMap_->SetCameraPosition(position);
joinRect.Join(joinRect, transMap_->GetBoxRect());
joinRect.Join(joinRect, GetOrigRect());
InvalidateRect(joinRect);
}
void UIView::ResetTransParameter()
{
if (transMap_ != nullptr) {
......@@ -614,19 +677,16 @@ void UIView::SetTransformMap(const TransformMap& transMap)
return;
}
Rect prevRect = GetRect();
Rect mapRect = transMap.GetBoxRect();
Rect joinRect;
joinRect.Join(prevRect, mapRect);
InvalidateRect(joinRect);
if (transMap_ == nullptr) {
transMap_ = new TransformMap();
}
*transMap_ = transMap;
transMap_->SetTransMapRect(GetOrigRect());
Rect joinRect;
joinRect.Join(GetRect(), transMap_->GetBoxRect());
InvalidateRect(joinRect);
}
void UIView::SetWidthPercent(float widthPercent)
......@@ -731,6 +791,7 @@ void UIView::LayoutCenterOfParent(int16_t xOffset, int16_t yOffset)
int16_t bottomMargin = style_->marginBottom_;
// 2: half
int16_t posX = parent_->GetWidth() / 2 - (rect_.GetWidth() - leftMargin + rightMargin) / 2 + xOffset;
// 2: half
int16_t posY = parent_->GetHeight() / 2 - (rect_.GetHeight() - topMargin + bottomMargin) / 2 + yOffset;
SetPosition(posX, posY);
}
......
......@@ -1132,10 +1132,10 @@ static void DrawFixedTriangleTrueColorBilinear8888Inner(const TriangleScanInfo&
#endif
Color32 result;
result.red = static_cast<uint8_t>(outR >> 15); // 15: shift 15 bit right to convert fixed to int
result.green = static_cast<uint8_t>(outG >> 15); // 15: shift 15 bit right to convert fixed to int
result.blue = static_cast<uint8_t>(outB >> 15); // 15: shift 15 bit right to convert fixed to int
result.alpha = static_cast<uint8_t>(outA >> 15); // 15: shift 15 bit right to convert fixed to int
result.red = static_cast<uint8_t>(outR >> FIXED_Q_NUM);
result.green = static_cast<uint8_t>(outG >> FIXED_Q_NUM);
result.blue = static_cast<uint8_t>(outB >> FIXED_Q_NUM);
result.alpha = static_cast<uint8_t>(outA >> FIXED_Q_NUM);
if ((in.opaScale == OPA_OPAQUE) && (result.alpha == OPA_OPAQUE)) {
COLOR_FILL_COVER(screenBuffer, bufferMode, result.red, result.green, result.blue, ARGB8888);
} else {
......@@ -1282,6 +1282,144 @@ static void DrawTriangleTrueColorBilinear8888InnerNeon(const TriangleScanInfo& i
}
#endif
void DrawUtils::Draw3DTriangleTrueColorBilinear8888(const TriangleScanInfo& in, const ColorMode bufferMode)
{
int16_t maskLeft = in.mask.GetLeft();
int16_t maskRight = in.mask.GetRight();
int16_t xMinErr = 0;
int16_t xMaxErr = 0;
GetXAxisErrForJunctionLine(in.ignoreJunctionPoint, in.isRightPart, xMinErr, xMaxErr);
#if ENABLE_FIXED_POINT
int64_t invMatrix00 = FO_TRANS_FLOAT_TO_FIXED(in.matrix.GetData()[0]);
int64_t invMatrix01 = FO_TRANS_FLOAT_TO_FIXED(in.matrix.GetData()[1]);
int64_t invMatrix02 = FO_TRANS_FLOAT_TO_FIXED(in.matrix.GetData()[2]);
int64_t invMatrix20 = FO_TRANS_FLOAT_TO_FIXED(in.matrix.GetData()[3]);
int64_t invMatrix21 = FO_TRANS_FLOAT_TO_FIXED(in.matrix.GetData()[4]);
int64_t invMatrix22 = FO_TRANS_FLOAT_TO_FIXED(in.matrix.GetData()[5]);
int64_t invMatrix30 = FO_TRANS_FLOAT_TO_FIXED(in.matrix.GetData()[6]);
int64_t invMatrix31 = FO_TRANS_FLOAT_TO_FIXED(in.matrix.GetData()[7]);
int64_t invMatrix32 = FO_TRANS_FLOAT_TO_FIXED(in.matrix.GetData()[8]);
#else // ENABLE_FIXED_POINT
float invMatrix00 = in.matrix.GetData()[0];
float invMatrix01 = in.matrix.GetData()[1];
float invMatrix02 = in.matrix.GetData()[2];
float invMatrix20 = in.matrix.GetData()[3];
float invMatrix21 = in.matrix.GetData()[4];
float invMatrix22 = in.matrix.GetData()[5];
float invMatrix30 = in.matrix.GetData()[6];
float invMatrix31 = in.matrix.GetData()[7];
float invMatrix32 = in.matrix.GetData()[8];
#endif // ENABLE_FIXED_POINT
for (int16_t y = in.yMin; y <= in.yMax; ++y) {
#if ENABLE_FIXED_POINT
int16_t tempV = FO_TO_INTEGER(in.edge1.curX) + xMinErr;
int16_t xMin = MATH_MAX(tempV, maskLeft);
tempV = FO_TO_INTEGER(in.edge2.curX) + xMaxErr;
int16_t xMax = MATH_MIN(tempV, maskRight);
#else // ENABLE_FIXED_POINT
int16_t xMin = MATH_MAX(static_cast<int16_t>(in.edge1.curX + xMinErr), maskLeft);
int16_t xMax = MATH_MIN(static_cast<int16_t>(in.edge2.curX + xMaxErr), maskRight);
#endif // ENABLE_FIXED_POINT
// move to current position
uint8_t* screenBuffer = in.screenBuffer + (y * in.screenBufferWidth + xMin) * in.bufferPxSize;
for (int16_t x = xMin; x <= xMax; x++) {
#if ENABLE_FIXED_POINT
int64_t w = invMatrix02 * x + invMatrix22 * y + invMatrix32;
int64_t u = FO_DIV((invMatrix00 * x + invMatrix20 * y + invMatrix30), w);
int64_t v = FO_DIV((invMatrix01 * x + invMatrix21 * y + invMatrix31), w);
int16_t intU = FO_TO_INTEGER(u);
int16_t intV = FO_TO_INTEGER(v);
#else // ENABLE_FIXED_POINT
float w = invMatrix02 * x + invMatrix22 * y + invMatrix32;
float u = (invMatrix00 * x + invMatrix20 * y + invMatrix30) / w;
float v = (invMatrix01 * x + invMatrix21 * y + invMatrix31) / w;
int16_t intU = static_cast<int16_t>(u);
int16_t intV = static_cast<int16_t>(v);
#endif // ENABLE_FIXED_POINT
if ((u >= 0) && (intU < in.info.header.width - 1) && (v >= 0) && (intV < in.info.header.height - 1)) {
#if ENABLE_ARM_MATH
uint32_t val1 = __SMUAD(intV, in.srcLineWidth);
uint32_t val2 = __SMUAD(intU, in.pixelSize);
uint32_t px1 = val1 + val2;
#else // ENABLE_ARM_MATH
uint32_t px1 = intV * in.srcLineWidth + intU * in.pixelSize;
#endif // ENABLE_ARM_MATH
uint8_t* imgHead = const_cast<uint8_t*>(in.info.data);
const ColorType p1 = *(reinterpret_cast<ColorType*>(&imgHead[px1]));
const ColorType p2 = *(reinterpret_cast<ColorType*>(&imgHead[px1 + in.pixelSize]));
const ColorType p3 = *(reinterpret_cast<ColorType*>(&imgHead[px1 + in.srcLineWidth]));
const ColorType p4 = *(reinterpret_cast<ColorType*>(&imgHead[px1 + in.srcLineWidth + in.pixelSize]));
#if ENABLE_FIXED_POINT
int64_t decU = FO_DECIMAL(u);
int64_t decV = FO_DECIMAL(v);
int64_t decUMinus1 = FIXED_NUM_1 - decU;
int64_t decVMinus1 = FIXED_NUM_1 - decV;
int64_t w1 = FO_MUL(decUMinus1, decVMinus1);
int64_t w2 = FO_MUL(decU, decVMinus1);
int64_t w3 = FO_MUL(decUMinus1, decV);
int64_t w4 = FO_MUL(decU, decV);
#if ENABLE_ARM_MATH
const int64_t outR =
__SMUAD(p1.red, w1) + __SMUAD(p2.red, w2) + __SMUAD(p3.red, w3) + __SMUAD(p4.red, w4);
const int64_t outG =
__SMUAD(p1.green, w1) + __SMUAD(p2.green, w2) + __SMUAD(p3.green, w3) + __SMUAD(p4.green, w4);
const int64_t outB =
__SMUAD(p1.blue, w1) + __SMUAD(p2.blue, w2) + __SMUAD(p3.blue, w3) + __SMUAD(p4.blue, w4);
const int64_t outA =
__SMUAD(p1.alpha, w1) + __SMUAD(p2.alpha, w2) + __SMUAD(p3.alpha, w3) + __SMUAD(p4.alpha, w4);
#else
const int64_t outR = p1.red * w1 + p2.red * w2 + p3.red * w3 + p4.red * w4;
const int64_t outG = p1.green * w1 + p2.green * w2 + p3.green * w3 + p4.green * w4;
const int64_t outB = p1.blue * w1 + p2.blue * w2 + p3.blue * w3 + p4.blue * w4;
const int64_t outA = p1.alpha * w1 + p2.alpha * w2 + p3.alpha * w3 + p4.alpha * w4;
#endif
Color32 result;
result.red = static_cast<uint8_t>(outR >> FIXED_Q_NUM);
result.green = static_cast<uint8_t>(outG >> FIXED_Q_NUM);
result.blue = static_cast<uint8_t>(outB >> FIXED_Q_NUM);
result.alpha = static_cast<uint8_t>(outA >> FIXED_Q_NUM);
#else // ENABLE_FIXED_POINT
const float decU = u - intU;
const float decV = v - intV;
const float decUMinus1 = 1 - decU;
const float decVMinus1 = 1 - decV;
const int32_t w1 = static_cast<int32_t>(decUMinus1 * decVMinus1 * 256.0f); // 256:shift 8 bit left
const int32_t w2 = static_cast<int32_t>(decU * decVMinus1 * 256.0f); // 256:shift 8 bit left
const int32_t w3 = static_cast<int32_t>(decUMinus1 * decV * 256.0f); // 256:shift 8 bit left
const int32_t w4 = static_cast<int32_t>(decU * decV * 256.0f);
#if ENABLE_ARM_MATH
const int32_t outR =
__SMUAD(p1.red, w1) + __SMUAD(p2.red, w2) + __SMUAD(p3.red, w3) + __SMUAD(p4.red, w4);
const int32_t outG =
__SMUAD(p1.green, w1) + __SMUAD(p2.green, w2) + __SMUAD(p3.green, w3) + __SMUAD(p4.green, w4);
const int32_t outB =
__SMUAD(p1.blue, w1) + __SMUAD(p2.blue, w2) + __SMUAD(p3.blue, w3) + __SMUAD(p4.blue, w4);
const int32_t outA =
__SMUAD(p1.alpha, w1) + __SMUAD(p2.alpha, w2) + __SMUAD(p3.alpha, w3) + __SMUAD(p4.alpha, w4);
#else // ENABLE_ARM_MATH
const int32_t outR = p1.red * w1 + p2.red * w2 + p3.red * w3 + p4.red * w4;
const int32_t outG = p1.green * w1 + p2.green * w2 + p3.green * w3 + p4.green * w4;
const int32_t outB = p1.blue * w1 + p2.blue * w2 + p3.blue * w3 + p4.blue * w4;
const int32_t outA = p1.alpha * w1 + p2.alpha * w2 + p3.alpha * w3 + p4.alpha * w4;
#endif // ENABLE_ARM_MATH
Color32 result;
result.red = static_cast<uint8_t>(outR >> 8); // 8:shift 8 bit right
result.green = static_cast<uint8_t>(outG >> 8); // 8:shift 8 bit right
result.blue = static_cast<uint8_t>(outB >> 8); // 8:shift 8 bit right
result.alpha = static_cast<uint8_t>(outA >> 8); // 8:shift 8 bit right
#endif // ENABLE_FIXED_POINT
if ((in.opaScale == OPA_OPAQUE) && (result.alpha == OPA_OPAQUE)) {
COLOR_FILL_COVER(screenBuffer, bufferMode, result.red, result.green, result.blue, ARGB8888);
} else {
COLOR_FILL_BLEND(screenBuffer, bufferMode, &result, ARGB8888, in.opaScale);
}
}
screenBuffer += in.bufferPxSize;
}
StepToNextLine(in.edge1, in.edge2);
}
}
void DrawUtils::DrawTriangleTrueColorBilinear8888(const TriangleScanInfo& in, const ColorMode bufferMode)
{
int16_t maskLeft = in.mask.GetLeft();
......@@ -1490,7 +1628,11 @@ void DrawUtils::DrawTriangleTransformPart(BufferInfo& gfxDstBuffer, const Triang
if (part.info.algorithm == TransformAlgorithm::NEAREST_NEIGHBOR) {
fuc = DrawTriangleTrueColorNearest;
} else if (part.info.header.colorMode == ARGB8888) {
fuc = DrawTriangleTrueColorBilinear8888;
if (part.transMap.Is3DTransform()) {
fuc = Draw3DTriangleTrueColorBilinear8888;
} else {
fuc = DrawTriangleTrueColorBilinear8888;
}
} else if (part.info.header.colorMode == RGB888) {
fuc = DrawTriangleTrueColorBilinear888;
} else {
......@@ -1516,7 +1658,8 @@ void DrawUtils::DrawTriangleTransformPart(BufferInfo& gfxDstBuffer, const Triang
part.info,
part.mask,
part.isRightPart,
part.ignoreJunctionPoint};
part.ignoreJunctionPoint,
part.transMap.invMatrix_};
fuc(input, gfxDstBuffer.mode);
}
......@@ -1644,36 +1787,39 @@ void DrawUtils::AddBorderToImageData(TransformDataInfo& newDataInfo)
void DrawUtils::UpdateTransMap(int16_t width, int16_t height, TransformMap& transMap)
{
Rect rect = transMap.GetTransMapRect();
Matrix3<float> matrix = transMap.GetTransformMatrix();
matrix = matrix * (Matrix3<float>::Translate(Vector2<float>(-rect.GetX(), -rect.GetY())));
Matrix4<float> matrix = transMap.GetTransformMatrix();
matrix = matrix * (Matrix4<float>::Translate(Vector3<float>(-rect.GetX(), -rect.GetY(), 0)));
int16_t offsetX = (width - rect.GetWidth()) / 2; // 2 : half;
int16_t offsetY = (height - rect.GetHeight()) / 2; // 2 : half;
rect.SetPosition(rect.GetX() - offsetX, rect.GetY() - offsetY);
rect.Resize(width, height);
Polygon polygon = Polygon(rect);
uint8_t vertexNum = transMap.GetPolygon().GetVertexNum();
Vector3<float> imgPoint3;
Vector4<float> imgPoint4;
for (uint8_t i = 0; i < vertexNum; i++) {
Vector3<float> point(polygon[i].x_, polygon[i].y_, 1);
imgPoint3 = matrix * point;
if (imgPoint3.x_ < COORD_MIN) {
Vector4<float> point(polygon[i].x_, polygon[i].y_, 0, 1);
imgPoint4 = matrix * point;
if (imgPoint4.x_ < COORD_MIN) {
polygon[i].x_ = COORD_MIN;
} else if (imgPoint3.x_ > COORD_MAX) {
} else if (imgPoint4.x_ > COORD_MAX) {
polygon[i].x_ = COORD_MAX;
} else {
polygon[i].x_ = MATH_ROUND(imgPoint3.x_);
polygon[i].x_ = MATH_ROUND(imgPoint4.x_);
}
if (imgPoint3.y_ < COORD_MIN) {
if (imgPoint4.y_ < COORD_MIN) {
polygon[i].y_ = COORD_MIN;
} else if (imgPoint3.y_ > COORD_MAX) {
} else if (imgPoint4.y_ > COORD_MAX) {
polygon[i].y_ = COORD_MAX;
} else {
polygon[i].y_ = MATH_ROUND(imgPoint3.y_);
polygon[i].y_ = MATH_ROUND(imgPoint4.y_);
}
}
transMap.SetPolygon(polygon);
transMap.invMatrix_ = (matrix * (Matrix3<float>::Translate(Vector2<float>(rect.GetX(), rect.GetY())))).Inverse();
Matrix3<float> matrix3(matrix[0][0], matrix[0][1], matrix[0][3],
matrix[1][0], matrix[1][1], matrix[1][3],
matrix[3][0], matrix[3][1], matrix[3][3]);
transMap.invMatrix_ = (matrix3 * (Matrix3<float>::Translate(Vector2<float>(rect.GetX(), rect.GetY())))).Inverse();
}
void DrawUtils::DrawTransform(BufferInfo& gfxDstBuffer,
......
......@@ -37,13 +37,14 @@ namespace OHOS {
SWAP_INT16(y1, y2);
// FixedPointed Related definition.
#define FIXED_NUM_1 32768
#define FIXED_NUM_1 1048576
#define FIXED_Q_NUM 20
#define FO_TRANS_FLOAT_TO_FIXED(f) (static_cast<int64_t>((f) * FIXED_NUM_1))
#define FO_TRANS_INTEGER_TO_FIXED(f) ((static_cast<int64_t>(f)) << 15)
#define FO_DIV(n1, n2) ((static_cast<int64_t>(n1) << 15) / (n2))
#define FO_TO_INTEGER(n) ((n) >= 0 ? ((n) >> 15) : (((n) >> 15) + 1))
#define FO_DECIMAL(n) ((n) >= 0 ? ((n) & 32767) : ((n) | (-32768)))
#define FO_MUL(n1, n2) ((static_cast<int64_t>(n1) * (n2)) >> 15)
#define FO_TRANS_INTEGER_TO_FIXED(f) ((static_cast<int64_t>(f)) << FIXED_Q_NUM)
#define FO_DIV(n1, n2) ((static_cast<int64_t>(n1) << FIXED_Q_NUM) / (n2))
#define FO_TO_INTEGER(n) ((n) >= 0 ? ((n) >> FIXED_Q_NUM) : (((n) >> FIXED_Q_NUM) + 1))
#define FO_DECIMAL(n) ((n) >= 0 ? ((n) & (FIXED_NUM_1 - 1)) : ((n) | (-FIXED_NUM_1)))
#define FO_MUL(n1, n2) ((static_cast<int64_t>(n1) * (n2)) >> FIXED_Q_NUM)
struct EdgeSides {
int16_t left;
......@@ -154,6 +155,7 @@ struct TriangleScanInfo {
const Rect& mask;
bool isRightPart;
bool ignoreJunctionPoint;
Matrix3<float> matrix;
};
struct TrianglePartInfo {
......@@ -301,6 +303,8 @@ private:
static void DrawTriangleTrueColorBilinear888(const TriangleScanInfo& triangle, const ColorMode bufferMode);
static void Draw3DTriangleTrueColorBilinear8888(const TriangleScanInfo& triangle, const ColorMode bufferMode);
static void DrawTriangleTrueColorBilinear8888(const TriangleScanInfo& triangle, const ColorMode bufferMode);
inline static void StepToNextLine(TriangleEdge& edg1, TriangleEdge& edg2);
......
......@@ -268,8 +268,6 @@ public:
CENTER,
SCALE_DOWN,
};
void AdjustScaleAndTranslate(Vector2<float>& scale, Vector2<int16_t>& translate,
int16_t widgetWidth, int16_t widgetHeight) const;
void SetResizeMode(ImageResizeMode mode);
void SetWidth(int16_t width) override;
void SetHeight(int16_t height) override;
......@@ -307,7 +305,7 @@ protected:
Image image_;
ImageResizeMode imageResizeMode_ = ImageResizeMode::NONE;
TransformMap* drawTransMap_ = nullptr;
Matrix3<float>* contentMatrix_ = nullptr;
Matrix4<float>* contentMatrix_ = nullptr;
bool transMapInvalid_ = true;
private:
void ReMeasure() override;
......@@ -320,6 +318,8 @@ private:
#endif
void UpdateContentMatrix();
void UpdateDrawTransMap(bool updateContentMatrix = false);
void AdjustScaleAndTranslate(Vector3<float>& scale, Vector3<int16_t>& translate,
int16_t widgetWidth, int16_t widgetHeight) const;
};
} // namespace OHOS
#endif // GRAPHIC_LITE_UI_IMAGE_VIEW_H
\ No newline at end of file
......@@ -1516,7 +1516,7 @@ public:
}
/**
* @brief Rotates the view.
* @brief Rotates the view in 2d.
* @param angle Indicates the rotation angle.
* @param pivot Indicates the coordinates of the rotation pivot.
* @since 5.0
......@@ -1525,7 +1525,17 @@ public:
void Rotate(int16_t angle, const Vector2<float>& pivot);
/**
* @brief Scales the view.
* @brief Rotates the view in 3d.
* @param angle Indicates the rotation angle.
* @param pivotStart Indicates the coordinates of the rotation start pivot.
* @param pivotEnd Indicates the coordinates of the rotation end pivot.
* @since 5.0
* @version 3.0
*/
void Rotate(int16_t angle, const Vector3<float>& pivotStart, const Vector3<float>& pivotEnd);
/**
* @brief Scales the view in 2d.
*
* @param scale Indicates the scale factor on x- and y- axes.
* @param pivot Indicates the scaling pivot.
......@@ -1534,10 +1544,40 @@ public:
*/
void Scale(const Vector2<float>& scale, const Vector2<float>& pivot);
/**
* @brief Scales the view in 3d.
*
* @param scale Indicates the scale factor on x- and y- axes.
* @param pivot Indicates the scaling pivot.
* @since 5.0
* @version 3.0
*/
void Scale(const Vector3<float>& scale, const Vector3<float>& pivot);
/**
* @brief Shears the view in 3d.
*
* @param shearX Indicates the shear parameters around x- axes,
* which means many it shears in y and z direction(current invalid).
* @param shearY Indicates the shear parameters around y- axes,
* which means many it shears in x and z direction(current invalid).
* @param shaerZ Indicates the shear parameters around z- axes,
* which means many it shears in x and y.
* @since 5.0
* @version 3.0
*/
void Shear(const Vector2<float>& shearX, const Vector2<float>& shearY, const Vector2<float>& shearZ);
void Translate(const Vector2<int16_t>& trans);
void Translate(const Vector3<int16_t>& trans);
bool IsTransInvalid();
void SetCameraDistance(int16_t distance);
void SetCameraPosition(const Vector2<float>& position);
void ResetTransParameter();
#if ENABLE_ROTATE_INPUT
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册