diff options
author | Michal Klocek <michal.klocek@theqtcompany.com> | 2015-11-16 20:18:03 +0100 |
---|---|---|
committer | Michal Klocek <michal.klocek@theqtcompany.com> | 2015-11-27 11:30:25 +0000 |
commit | eea315187d1add70aaf69745c031b8d6342b2303 (patch) | |
tree | 403a0fe2548dfb57466a84ff91beb94a2aafcf63 /tests | |
parent | 3fadff6e01232f70492a05b1fb779968d9662462 (diff) | |
download | qtlocation-eea315187d1add70aaf69745c031b8d6342b2303.tar.gz |
Improve map item rendering performance
A flood of input events, such as when pinch, triggers
multiple map item geometry updates to occur per frame. These
geometry updates are potentially expensive and only the
last generated geometry is used. Mark items to be polished to
make geometry updates once per frame when updatePolish() is called.
Done-with: Aaron McCarthy <aaron.mccarthy@jollamobile.com>
Change-Id: I0af40e2d0b09c8364382d4b4c018988f3986f7f0
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative_ui/tst_map_error.qml | 2 | ||||
-rw-r--r-- | tests/auto/declarative_ui/tst_map_flick.qml | 1 | ||||
-rw-r--r-- | tests/auto/declarative_ui/tst_map_item.qml | 43 | ||||
-rw-r--r-- | tests/auto/declarative_ui/tst_map_item_details.qml | 17 | ||||
-rw-r--r-- | tests/auto/declarative_ui/tst_map_item_fit_viewport.qml | 2 | ||||
-rw-r--r-- | tests/auto/declarative_ui/tst_map_mouse.qml | 54 |
6 files changed, 74 insertions, 45 deletions
diff --git a/tests/auto/declarative_ui/tst_map_error.qml b/tests/auto/declarative_ui/tst_map_error.qml index aaa58e6c..c102db6e 100644 --- a/tests/auto/declarative_ui/tst_map_error.qml +++ b/tests/auto/declarative_ui/tst_map_error.qml @@ -100,7 +100,7 @@ Item { mouseClick(map, 50, 50) mouseClick(map, 50, 50) mouseClick(map, 50, 50) - compare(map.mouseClickedSpy.count, 3) + tryCompare(map.mouseClickedSpy, "count", 3) } function test_map_clicked_wiht_no_plugin() diff --git a/tests/auto/declarative_ui/tst_map_flick.qml b/tests/auto/declarative_ui/tst_map_flick.qml index 4094a7c7..e225480d 100644 --- a/tests/auto/declarative_ui/tst_map_flick.qml +++ b/tests/auto/declarative_ui/tst_map_flick.qml @@ -288,6 +288,7 @@ Item { { map.center.latitude = 50 map.center.longitude = 50 + waitForRendering(map) mousePress(page, 0, 0) for (var i = 0; i < 50; i += 5) { wait(20) diff --git a/tests/auto/declarative_ui/tst_map_item.qml b/tests/auto/declarative_ui/tst_map_item.qml index 32de8efd..5be8896f 100644 --- a/tests/auto/declarative_ui/tst_map_item.qml +++ b/tests/auto/declarative_ui/tst_map_item.qml @@ -257,37 +257,40 @@ Item { map.center = preMapRect.topLeft var point = map.fromCoordinate(preMapRect.topLeft) mouseClick(map, point.x + 5, point.y + 5) - compare(preMapRectClicked.count, 1) + tryCompare(preMapRectClicked, "count", 1) mouseClick(map, 1, 1) // no item hit - compare(preMapRectClicked.count, 1) + tryCompare(preMapRectClicked, "count", 1) compare(preMapCircleClicked.count, 0) // click circle, overlaps and is above rect map.center = preMapCircle.center + verify(waitForRendering(map)) point = map.fromCoordinate(preMapCircle.center) mouseClick(map, point.x - 5, point.y - 5) - compare(preMapRectClicked.count, 1) + tryCompare(preMapRectClicked, "count", 1) compare(preMapCircleClicked.count, 1) // click within circle bounding rect but not inside the circle geometry map.center = preMapCircle.center.atDistanceAndAzimuth(preMapCircle.radius, -45) mouseClick(map, preMapCircle.x + 4, preMapCircle.y + 4) - compare(preMapRectClicked.count, 2) + tryCompare(preMapRectClicked, "count", 2) compare(preMapCircleClicked.count, 1) // click quick item compare(preMapQuickItemClicked.count, 0) map.center = preMapQuickItem.coordinate + verify(waitForRendering(map)) point = map.fromCoordinate(preMapQuickItem.coordinate) mouseClick(map, point.x + 5, point.y + 5) - compare(preMapQuickItemClicked.count, 1) + tryCompare(preMapQuickItemClicked, "count", 1) // click polygon compare (preMapPolygonClicked.count, 0) map.center = preMapPolygon.path[1] + verify(waitForRendering(map)) point = map.fromCoordinate(preMapPolygon.path[1]) mouseClick(map, point.x - 5, point.y) - compare(preMapPolygonClicked.count, 1) + tryCompare(preMapPolygonClicked, "count", 1) // remove items and repeat clicks to verify they are gone map.clearMapItems() @@ -328,48 +331,54 @@ Item { compare (map.mapItems.length, 6) visualInspectionPoint() map.center = preMapRect.topLeft + verify(waitForRendering(map)) point = map.fromCoordinate(preMapRect.topLeft) mouseClick(map, point.x + 5, point.y + 5) - compare(preMapRectClicked.count, 1) + tryCompare(preMapRectClicked, "count", 1) map.center = preMapCircle.center + verify(waitForRendering(map)) point = map.fromCoordinate(preMapCircle.center) mouseClick(map, point.x - 5, point.y - 5) - compare(preMapRectClicked.count, 1) + tryCompare(preMapRectClicked, "count", 1) compare(preMapCircleClicked.count, 1) map.center = preMapCircle.center.atDistanceAndAzimuth(preMapCircle.radius, -45) mouseClick(map, preMapCircle.x + 4, preMapCircle.y + 4) - compare(preMapRectClicked.count, 2) + tryCompare(preMapRectClicked, "count", 2) compare(preMapCircleClicked.count, 1) compare(preMapQuickItemClicked.count, 0) map.center = preMapQuickItem.coordinate + verify(waitForRendering(map)) point = map.fromCoordinate(preMapQuickItem.coordinate) mouseClick(map, point.x + 5, point.y + 5) - compare(preMapQuickItemClicked.count, 1) + tryCompare(preMapQuickItemClicked, "count", 1) map.center = preMapPolygon.path[1] + verify(waitForRendering(map)) point = map.fromCoordinate(preMapPolygon.path[1]) mouseClick(map, point.x - 5, point.y) - compare(preMapPolygonClicked.count, 1) + tryCompare(preMapPolygonClicked, "count", 1) // item clips to map. not sure if this is sensible test map.addMapItem(extMapCircle) map.center = extMapCircle.center + verify(waitForRendering(map)) visualInspectionPoint(); point = map.fromCoordinate(extMapCircle.center) mouseClick(map, point.x, point.y) - compare(extMapCircleClicked.count, 1) + tryCompare(extMapCircleClicked, "count", 1) mouseClick(map, point.x, -5) - compare(extMapCircleClicked.count, 1) + tryCompare(extMapCircleClicked, "count", 1) map.removeMapItem(extMapCircle) map.addMapItem(extMapQuickItem) map.center = extMapQuickItem.coordinate + verify(waitForRendering(map)) visualInspectionPoint(); point = map.fromCoordinate(extMapQuickItem.coordinate) mouseClick(map, point.x + 5, point.y + 5) - compare(extMapQuickItemClicked.count, 1) + tryCompare(extMapQuickItemClicked, "count", 1) mouseClick(map, map.width + 5, point.y + 5) - compare(extMapQuickItemClicked.count, 1) + tryCompare(extMapQuickItemClicked, "count", 1) map.removeMapItem(extMapQuickItem) } @@ -378,6 +387,8 @@ Item { // basic drags, drag rectangle compare (preMapRectActiveChanged.count, 0) map.center = preMapRect.topLeft + verify(waitForRendering(map)) + var i var point = map.fromCoordinate(preMapRect.topLeft) var targetCoordinate = map.toCoordinate(51, 51) @@ -400,6 +411,7 @@ Item { // drag circle compare (preMapCircleActiveChanged.count, 0) map.center = preMapCircle.center + verify(waitForRendering(map)) point = map.fromCoordinate(preMapCircle.center) targetCoordinate = map.toCoordinate(51, 51) mousePress(map, point.x, point.y) @@ -418,6 +430,7 @@ Item { // drag quick item compare (preMapQuickItemActiveChanged.count, 0) map.center = preMapQuickItem.coordinate + verify(waitForRendering(map)) point = map.fromCoordinate(preMapQuickItem.coordinate) targetCoordinate = map.toCoordinate(51, 51) mousePress(map, point.x + 5, point.y + 5) diff --git a/tests/auto/declarative_ui/tst_map_item_details.qml b/tests/auto/declarative_ui/tst_map_item_details.qml index b4468301..20849079 100644 --- a/tests/auto/declarative_ui/tst_map_item_details.qml +++ b/tests/auto/declarative_ui/tst_map_item_details.qml @@ -41,7 +41,11 @@ Item { x: 0; y: 0; width: 240 height: 240 - Plugin { id: testPlugin; name : "qmlgeo.test.plugin"; allowExperimental: true } + Plugin { id: testPlugin + name : "qmlgeo.test.plugin" + allowExperimental: true + parameters: [ PluginParameter { name: "finishRequestImmediately"; value: true}] + } property variant mapDefaultCenter: QtPositioning.coordinate(20, 20) @@ -327,8 +331,9 @@ Item { verify(extMapPolygon0.path.length == 0) extMapPolygon.addCoordinate(polyCoordinate) verify(extMapPolygon.path.length == 3) + verify(waitForRendering(map)) mouseClick(map, point.x - 5, point.y) - compare(extMapPolygonClicked.count, 1) + tryCompare(extMapPolygonClicked, "count", 1) extMapPolygon.path[0].latitude = 10 verify(extMapPolygon.path[0].latitude, 10) @@ -427,6 +432,7 @@ Item { verify(point.x > map.width / 2.0) // move item edge onto dateline extMapRectDateline.topLeft.longitude = datelineCoordinate.longitude + verify(waitForRendering(map)) point = map.fromCoordinate(extMapRectDateline.topLeft) verify(point.x == map.width / 2.0) // drag item back onto dateline @@ -450,6 +456,7 @@ Item { point = map.fromCoordinate(extMapCircleDateline.center) verify(point.x == map.width / 2.0) extMapCircleDateline.center.longitude = datelineCoordinateRight.longitude + verify(waitForRendering(map)) point = map.fromCoordinate(extMapCircleDateline.center) verify(point.x > map.width / 2.0) mousePress(map, point.x, point.y) @@ -469,6 +476,7 @@ Item { point = map.fromCoordinate(extMapQuickItemDateline.coordinate) verify(point.x < map.width / 2.0) extMapQuickItemDateline.coordinate.longitude = datelineCoordinateRight.longitude + verify(waitForRendering(map)) point = map.fromCoordinate(extMapQuickItemDateline.coordinate) verify(point.x > map.width / 2.0) mousePress(map, point.x + 5, point.y + 5) @@ -510,6 +518,7 @@ Item { path = extMapPolygonDateline.path; path[3].longitude = datelineCoordinate.longitude; extMapPolygonDateline.path = path; + verify(waitForRendering(map)) point = map.fromCoordinate(extMapPolygonDateline.path[3]) verify(point.x == map.width / 2.0) mousePress(map, point.x + 5, point.y - 5) @@ -518,6 +527,7 @@ Item { mouseMove(map, point.x + 5 - i, point.y - 5 ) } mouseRelease(map, point.x + 5 - i, point.y - 5) + verify(waitForRendering(map,10000)) point = map.fromCoordinate(extMapPolygonDateline.path[0]) verify(point.x < map.width / 2.0) point = map.fromCoordinate(extMapPolygonDateline.path[1]) @@ -596,6 +606,7 @@ Item { // rectangle map.addMapItem(extMapRectEdge) + verify(waitForRendering(map)) verify(extMapRectEdge.topLeft.longitude == -15) verify(extMapRectEdge.bottomRight.longitude == -5) var point = map.fromCoordinate(extMapRectEdge.topLeft) @@ -650,6 +661,7 @@ Item { // quickitem map.addMapItem(extMapQuickItemEdge) map.center = datelineCoordinate + verify(waitForRendering(map)) verify(extMapQuickItemEdge.coordinate.longitude == -15) point = map.fromCoordinate(extMapQuickItemEdge.coordinate) verify(point.x < map.width) @@ -671,6 +683,7 @@ Item { // polygon map.center = datelineCoordinate map.addMapItem(extMapPolygonEdge) + verify(waitForRendering(map)) verify(extMapPolygonEdge.path[0].longitude == -15) verify(extMapPolygonEdge.path[1].longitude == -5) verify(extMapPolygonEdge.path[2].longitude == -5) diff --git a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml index 8671d05d..b3ac1d8f 100644 --- a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml +++ b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml @@ -240,6 +240,7 @@ Item { // normal case - fit viewport to items which are all already visible verify_visibility_all_items() map.fitViewportToMapItems() + verify(waitForRendering(map)) visualInspectionPoint() verify_visibility_all_items() } @@ -577,6 +578,7 @@ Item { map.addMapItem(preMapPolygon) map.addMapItem(preMapPolyline) map.addMapItem(preMapRoute) + verify(waitForRendering(map)) compare (map.mapItems.length, 6) calculate_bounds() } diff --git a/tests/auto/declarative_ui/tst_map_mouse.qml b/tests/auto/declarative_ui/tst_map_mouse.qml index fe02f81d..57cde142 100644 --- a/tests/auto/declarative_ui/tst_map_mouse.qml +++ b/tests/auto/declarative_ui/tst_map_mouse.qml @@ -267,25 +267,25 @@ Item { compare(mouseUpperClickedSpy.count, 0) mouseUpper.enabled = true mouseClick(map, 5, 25) - compare(mouseUpperClickedSpy.count, 1) + tryCompare(mouseUpperClickedSpy, "count", 1) compare(mouseUpperEnabledChangedSpy.count, 2) // when overlapping are is disabled, the event should flow through compare(mouseOverlapperClickedSpy.count, 0) mouseClick(map, 55, 25) - compare(mouseUpperClickedSpy.count, 1) + tryCompare(mouseUpperClickedSpy, "count", 1) compare(mouseOverlapperClickedSpy.count, 1) mouseOverlapper.enabled = false compare(mouseOverlapperEnabledChangedSpy.count, 1) compare(mouseOverlapper.enabled, false) mouseClick(map, 55, 25) - compare(mouseOverlapperClickedSpy.count, 1) + tryCompare(mouseOverlapperClickedSpy, "count", 1) compare(mouseUpperClickedSpy.count, 2) // re-enable and verify that still works mouseOverlapper.enabled = true compare(mouseOverlapperEnabledChangedSpy.count, 2) compare(mouseOverlapper.enabled, true) mouseClick(map, 55, 25) - compare(mouseOverlapperClickedSpy.count, 2) // should consume again + tryCompare(mouseOverlapperClickedSpy, "count", 2) // should consume again compare(mouseUpperClickedSpy.count, 2) } @@ -338,7 +338,7 @@ Item { mouseUpper.acceptedButtons = Qt.LeftButton compare(mouseUpperAcceptedButtonsChangedSpy.count, 2) mouseClick(map, 5, 25) - compare(mouseUpperClickedSpy.count, 1) + tryCompare(mouseUpperClickedSpy, "count", 1) } function test_basic_position_changed() { @@ -574,40 +574,40 @@ Item { // mouse click with unaccepted buttons should not cause click mouseUpper.acceptedButtons = Qt.LeftButton mouseClick(map, 5, 25, Qt.RightButton, Qt.AltModifier) - compare(mouseUpperClickedSpy.count, 1) + tryCompare(mouseUpperClickedSpy, "count", 1) compare(mouseLowerClickedSpy.count, 0) compare(mouseOverlapperClickedSpy.count, 0) mouseClick(map, 5, 25) - compare(mouseUpperClickedSpy.count, 2) + tryCompare(mouseUpperClickedSpy, "count", 2) compare(mouseLowerClickedSpy.count, 0) compare(mouseOverlapperClickedSpy.count, 0) compare(mouseUpper.lastModifiers, Qt.NoModifier) compare(mouseUpper.lastButton, Qt.LeftButton) mouseClick(map, 5, 55) - compare(mouseUpperClickedSpy.count, 2) + tryCompare(mouseUpperClickedSpy, "count", 2) compare(mouseLowerClickedSpy.count, 1) compare(mouseOverlapperClickedSpy.count, 0) mouseClick(map, 5, 55) - compare(mouseUpperClickedSpy.count, 2) + tryCompare(mouseUpperClickedSpy,"count", 2) compare(mouseLowerClickedSpy.count, 2) compare(mouseOverlapperClickedSpy.count, 0) // declaration order counts on overlap case; overlapping area // declared later will get the events mouseClick(map, 55, 25) - compare(mouseUpperClickedSpy.count, 2) + tryCompare(mouseUpperClickedSpy, "count", 2) compare(mouseLowerClickedSpy.count, 2) compare(mouseOverlapperClickedSpy.count, 1) mouseClick(map, 55, 75) - compare(mouseUpperClickedSpy.count, 2) + tryCompare(mouseUpperClickedSpy, "count", 2) compare(mouseLowerClickedSpy.count, 2) compare(mouseOverlapperClickedSpy.count, 2) real_click(map, 55, 25) - compare(mouseUpperClickedSpy.count, 2) + tryCompare(mouseUpperClickedSpy, "count", 2) compare(mouseLowerClickedSpy.count, 2) compare(mouseOverlapperClickedSpy.count, 3) real_click(map, 55, 75) - compare(mouseUpperClickedSpy.count, 2) + tryCompare(mouseUpperClickedSpy, "count", 2) compare(mouseLowerClickedSpy.count, 2) compare(mouseOverlapperClickedSpy.count, 4) } @@ -621,7 +621,7 @@ Item { compare(mouseLowerDoubleClickedSpy.count, 0) compare(mouseOverlapperDoubleClickedSpy.count, 0) real_double_click(map, 5, 25) - compare(mouseUpper.lastAccepted, true) + tryCompare(mouseUpper, "lastAccepted", true) compare(mouseUpper.lastButton, Qt.LeftButton) compare(mouseUpper.lastModifiers, Qt.NoModifier) compare(mouseUpper.lastWasHeld, false) @@ -632,26 +632,26 @@ Item { compare(mouseLowerDoubleClickedSpy.count, 0) compare(mouseOverlapperDoubleClickedSpy.count, 0) real_double_click(map, 5, 25) - compare(mouseUpperDoubleClickedSpy.count, 2) + tryCompare(mouseUpperDoubleClickedSpy, "count", 2) compare(mouseLowerDoubleClickedSpy.count, 0) compare(mouseOverlapperDoubleClickedSpy.count, 0) real_double_click(map, 5, 55) - compare(mouseUpperDoubleClickedSpy.count, 2) + tryCompare(mouseUpperDoubleClickedSpy, "count", 2) compare(mouseLowerDoubleClickedSpy.count, 1) compare(mouseOverlapperDoubleClickedSpy.count, 0) real_double_click(map, 5, 55) - compare(mouseUpperDoubleClickedSpy.count, 2) + tryCompare(mouseUpperDoubleClickedSpy, "count", 2) compare(mouseLowerDoubleClickedSpy.count, 2) compare(mouseOverlapperDoubleClickedSpy.count, 0) // declaration order counts on overlap case; overlapping area declared later will get the events real_double_click(map, 55, 25) - compare(mouseUpperDoubleClickedSpy.count, 2) + tryCompare(mouseUpperDoubleClickedSpy, "count", 2) compare(mouseLowerDoubleClickedSpy.count, 2) compare(mouseOverlapperDoubleClickedSpy.count, 1) compare(mouseOverlapperPressedSpy.count, 2) compare(mouseOverlapperReleasedSpy.count, 2) real_double_click(map, 55, 75) - compare(mouseUpperDoubleClickedSpy.count, 2) + tryCompare(mouseUpperDoubleClickedSpy, "count", 2) compare(mouseLowerDoubleClickedSpy.count, 2) compare(mouseOverlapperDoubleClickedSpy.count, 2) compare(mouseOverlapperPressedSpy.count, 4) @@ -659,20 +659,20 @@ Item { // disable overlapping area and check event is delivered to the ones beneath mouseOverlapper.enabled = false real_double_click(map, 55, 25) - compare(mouseUpperDoubleClickedSpy.count, 3) + tryCompare(mouseUpperDoubleClickedSpy, "count", 3) compare(mouseLowerDoubleClickedSpy.count, 2) compare(mouseOverlapperDoubleClickedSpy.count, 2) real_double_click(map, 55, 75) - compare(mouseUpperDoubleClickedSpy.count, 3) + tryCompare(mouseUpperDoubleClickedSpy, "count", 3) compare(mouseLowerDoubleClickedSpy.count, 3) compare(mouseOverlapperDoubleClickedSpy.count, 2) mouseOverlapper.enabled = true real_double_click(map, 55, 25) - compare(mouseUpperDoubleClickedSpy.count, 3) + tryCompare(mouseUpperDoubleClickedSpy, "count", 3) compare(mouseLowerDoubleClickedSpy.count, 3) compare(mouseOverlapperDoubleClickedSpy.count, 3) real_double_click(map, 55, 75) - compare(mouseUpperDoubleClickedSpy.count, 3) + tryCompare(mouseUpperDoubleClickedSpy, "count", 3) compare(mouseLowerDoubleClickedSpy.count, 3) compare(mouseOverlapperDoubleClickedSpy.count, 4) } @@ -698,11 +698,11 @@ Item { compare(mouseUpper.lastY, 5) // remember 20 offset of the mouse area mouseRelease(map,5,25) real_press_and_hold(map, 5, 55) - compare(mouseUpperPressAndHoldSpy.count, 1) + tryCompare(mouseUpperPressAndHoldSpy, "count", 1) compare(mouseLowerPressAndHoldSpy.count, 1) compare(mouseOverlapperPressAndHoldSpy.count, 0) real_press_and_hold(map, 55, 75) - compare(mouseUpperPressAndHoldSpy.count, 1) + tryCompare(mouseUpperPressAndHoldSpy, "count", 1) compare(mouseLowerPressAndHoldSpy.count, 1) compare(mouseOverlapperPressAndHoldSpy.count, 1) compare(mouseOverlapper.lastAccepted, true) @@ -713,14 +713,14 @@ Item { compare(mouseOverlapper.lastY, 75) // make sure that the wasHeld is cleared mouseClick(map, 55, 75) - compare(mouseOverlapper.lastAccepted, true) + tryCompare(mouseOverlapper, "lastAccepted", true) compare(mouseOverlapper.lastButton, Qt.LeftButton) compare(mouseOverlapper.lastModifiers, Qt.NoModifier) compare(mouseOverlapper.lastWasHeld, false) compare(mouseOverlapper.lastX, 5) compare(mouseOverlapper.lastY, 75) real_press_and_hold(map, 55, 25) - compare(mouseUpperPressAndHoldSpy.count, 1) + tryCompare(mouseUpperPressAndHoldSpy, "count", 1) compare(mouseLowerPressAndHoldSpy.count, 1) compare(mouseOverlapperPressAndHoldSpy.count, 2) } |