Приветствую!
ГИС Конструктор для Qt Designer x64 (версия 12.6.1), ОС Astra Linux
В процессе изучения вопросов производительности, обнаружил особенность: линии толще 1,5 мм рисуются почти на порядок медленнее. С чем это может быть связано?
Пример:
Результат:
С уважением,
Матвеев П.В.
ГИС Конструктор для Qt Designer x64 (версия 12.6.1), ОС Astra Linux
В процессе изучения вопросов производительности, обнаружил особенность: линии толще 1,5 мм рисуются почти на порядок медленнее. С чем это может быть связано?
Пример:
Код |
---|
#include <QString> #include <QDebug> #include <QImage> #include "mapapi.h" #include "sitapi.h" #include "rscapi.h" #include "mapcreat.h" #include "maptype.h" #include "sys/time.h" void paintMapObj(HMAP hmap, HOBJ hobj,RECT* rect, XIMAGEDESC* desc) { mapPaintMapObjectToDib(hmap, desc->Point, desc->Width, desc->Height, rect, 0, hobj); // QImage im((const uchar*) desc->Point, desc->Width, desc->Height, desc->RowSize, // QImage::Format_RGB32); // QString fileName("/tmp/obj"); // fileName += QString::number(mapGetObjectNumber(hobj)); // fileName += ".png"; // if (!im.save(fileName, "PNG")) { // qDebug() << "image save error"; // } } long testPaintPerformance(HMAP hmap, HOBJ hobj, RECT* aRect, int aTryCnt) { XIMAGEDESC desc; memset((void*) &desc, 0, sizeof(desc)); desc.Width = aRect->right - aRect->left; desc.Height = aRect->bottom - aRect->top; desc.Depth = 32; desc.CellSize = desc.Depth / 8; desc.RowSize = desc.Width * desc.CellSize; desc.Point = (char*) malloc(desc.Height * desc.RowSize); memset((void*) desc.Point, 0, desc.Height * desc.RowSize); timespec ts1; clock_gettime(CLOCK_MONOTONIC, &ts1); for (int i = 0; i < aTryCnt; i++) { paintMapObj(hmap, hobj, aRect, &desc); } timespec ts2; clock_gettime(CLOCK_MONOTONIC, &ts2); free((void*)desc.Point); return (((ts2.tv_sec - ts1.tv_sec) * 1E9) + (ts2.tv_nsec - ts1.tv_nsec)) / aTryCnt / 1000; } HOBJ createLineObject(HMAP hmap, int aColor, int width, POINT* pt1, POINT*pt2) { HOBJ hobj = mapCreateObject(hmap, IDDOUBLE2, 0); if (hobj != 0) { if (mapRegisterDrawObject(hobj, 0, LOCAL_LINE) != 0) { IMGLINE line; memset((void*) &line, 0, sizeof(line)); line.Color = aColor; line.Thick = width; mapAppendDraw(hobj, IMG_LINE, (const char*) &line); double x1 = pt1->x; double y1 = pt1->y; mapPictureToPlane(hmap, &x1, &y1); double x2 = pt2->x; double y2 = pt2->y; mapPictureToPlane(hmap, &x2, &y2); for (int i =0 ; i< 50; i++) { mapAppendPointPlane(hobj, x1, y1, 0); mapAppendPointPlane(hobj, x2, y2, 0); mapAppendPointPlane(hobj, x1, y2, 0); mapAppendPointPlane(hobj, x2, y1, 0); mapAppendPointPlane(hobj, x1, y1, 0); mapAppendPointPlane(hobj, x2, y1, 0); mapAppendPointPlane(hobj, x2, y2, 0); mapAppendPointPlane(hobj, x1, y2, 0); mapAppendPointPlane(hobj, x1, y1, 0); } mapSetObjectPress(hobj, 1); mapSetObjectScale(hobj, 0); mapCommitObject(hobj); } else { qDebug() << "mapRegisterDrawObject error"; } } else { qDebug() << "mapCreateObject error"; } return hobj; } // Тест скорости рисоваиня линий. int main(int argc, char ** argv) { QString* siteName = new QString("/home/user/temp/testLineDrawPerformance.sitx"); QString* rscName = new QString("/home/user/temp/operator.rsc"); CREATESITEUN cs; memset((void*) &cs, 0, sizeof(cs)); cs.Length = sizeof(CREATESITEUN); cs.EllipsoideKind = 9; cs.MapType = 16; HMAP hmap = mapCreateSiteUn((const WCHAR*) siteName->constData(), (const WCHAR*) rscName->constData(), &cs); if (hmap != 0) { mapSetRealShowScale(hmap, 25000); POINT pt1; pt1.x = 0; pt1.y = 0; POINT pt2; pt2.x = 400; pt2.y = 400; DFRAME frame; mapGetTotalBorder(hmap, &frame, PP_PICTURE); RECT rect; rect.left = frame.X1; rect.right = frame.X2; rect.top = frame.Y1; rect.bottom = frame.Y2; for (int w = 500; w<=5000; w+=100){ HOBJ line = createLineObject(hmap, 0xff0000, w, &pt1, &pt2); qDebug() << "line width: " <<w <<" paint time: " <<testPaintPerformance(hmap, line, &rect, 100); mapFreeObject(line); } mapCloseMap(hmap); } } |
Код |
---|
... line width: 1200 paint time: 2335 line width: 1300 paint time: 2845 line width: 1400 paint time: 2839 line width: 1500 paint time: 24494 line width: 1600 paint time: 24418 line width: 1700 paint time: 24395 ... |
Матвеев П.В.
Изменено: Павел Матвеев - 10.01.2020 17:08:04