Merge lp:~robertcarr/mir/delete-some-test-code into lp:mir/0.1
- delete-some-test-code
- Merge into trusty
Proposed by
Robert Carr
Status: | Superseded |
---|---|
Proposed branch: | lp:~robertcarr/mir/delete-some-test-code |
Merge into: | lp:mir/0.1 |
Diff against target: |
17543 lines (+5306/-4436) 300 files modified
3rd_party/android-input/android/CMakeLists.txt (+1/-0) 3rd_party/android-input/android/frameworks/base/include/androidfw/Input.h (+5/-2) 3rd_party/android-input/android/frameworks/base/include/androidfw/InputTransport.h (+10/-7) 3rd_party/android-input/android/frameworks/base/include/androidfw/IntSet.h (+104/-0) 3rd_party/android-input/android/frameworks/base/include/androidfw/VelocityControl.h (+2/-0) 3rd_party/android-input/android/frameworks/base/include/androidfw/VelocityTracker.h (+24/-22) 3rd_party/android-input/android/frameworks/base/services/input/InputDevice.cpp (+6/-3) 3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.cpp (+40/-33) 3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.h (+6/-6) 3rd_party/android-input/android/frameworks/base/services/input/InputEventPrinter.h (+138/-0) 3rd_party/android-input/android/frameworks/base/services/input/InputReader.cpp (+409/-354) 3rd_party/android-input/android/frameworks/base/services/input/InputReader.h (+68/-40) 3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp (+8/-8) 3rd_party/android-input/android/frameworks/base/services/input/IntSet.cpp (+123/-0) 3rd_party/android-input/android/frameworks/base/services/input/PointerController.cpp (+5/-8) 3rd_party/android-input/android/frameworks/base/services/input/PointerController.h (+2/-5) 3rd_party/android-input/android/frameworks/base/services/input/VelocityControl.cpp (+2/-2) 3rd_party/android-input/android/frameworks/base/services/input/VelocityTracker.cpp (+80/-83) CMakeLists.txt (+1/-1) debian/changelog (+7/-4) debian/control (+2/-2) debian/libmirserver11.install (+1/-1) doc/building_source_for_android.md (+4/-4) doc/component_reports.md (+2/-0) doc/installing_prebuilt_on_pc.md (+2/-2) doc/using_mir_on_pc.md (+6/-4) examples/demo-inprocess-surface-client/demo_inprocess_surface_client.cpp (+2/-1) examples/demo-inprocess-surface-client/inprocess_egl_client.cpp (+12/-11) examples/demo-inprocess-surface-client/inprocess_egl_client.h (+9/-11) examples/demo-shell/demo_shell.cpp (+0/-5) examples/demo-shell/window_manager.cpp (+2/-9) examples/demo-shell/window_manager.h (+0/-3) examples/demo_input_filter.cpp (+25/-3) examples/image_renderer.cpp (+59/-5) examples/render_surfaces.cpp (+13/-12) examples/render_to_fb.cpp (+1/-4) include/client/mir_toolkit/mir_client_library_drm.h (+14/-0) include/platform/mir/graphics/nested_context.h (+3/-0) include/server/mir/compositor/buffer_stream.h (+6/-5) include/server/mir/compositor/scene.h (+3/-6) include/server/mir/default_configuration_options.h (+2/-0) include/server/mir/default_server_configuration.h (+8/-1) include/server/mir/frontend/surface.h (+2/-21) include/server/mir/shell/application_session.h (+3/-0) include/server/mir/shell/focus_controller.h (+6/-2) include/server/mir/shell/session.h (+1/-0) include/server/mir/shell/session_manager.h (+3/-0) include/server/mir/shell/surface.h (+5/-2) include/server/mir/surfaces/buffer_stream_factory.h (+3/-4) include/server/mir/surfaces/surface.h (+11/-6) include/server/mir/surfaces/surface_controller.h (+1/-1) include/server/mir/surfaces/surfaces_report.h (+60/-0) include/test/mir_test/draw/android_graphics.h (+1/-1) include/test/mir_test_doubles/mock_android_framebuffer_window.h (+0/-46) include/test/mir_test_doubles/mock_buffer_bundle.h (+1/-0) include/test/mir_test_doubles/mock_buffer_stream.h (+3/-2) include/test/mir_test_doubles/mock_display_device.h (+6/-6) include/test/mir_test_doubles/mock_egl.h (+17/-0) include/test/mir_test_doubles/mock_focus_setter.h (+1/-1) include/test/mir_test_doubles/mock_frontend_surface.h (+1/-1) include/test/mir_test_doubles/mock_shell_session.h (+2/-0) include/test/mir_test_doubles/mock_surface_renderer.h (+4/-3) include/test/mir_test_doubles/mock_surface_state.h (+1/-0) include/test/mir_test_doubles/null_session_event_sink.h (+1/-1) include/test/mir_test_doubles/null_snapshot_strategy.h (+1/-1) include/test/mir_test_doubles/stub_buffer_allocator.h (+1/-9) include/test/mir_test_doubles/stub_buffer_stream.h (+6/-2) include/test/mir_test_doubles/stub_display_buffer_factory.h (+75/-0) include/test/mir_test_doubles/stub_display_device.h (+12/-10) include/test/mir_test_doubles/stub_driver_interpreter.h (+75/-0) include/test/mir_test_doubles/stub_ipc_factory.h (+2/-2) include/test/mir_test_doubles/stub_shell_session.h (+4/-0) include/test/mir_test_doubles/stub_surface.h (+1/-1) include/test/mir_test_doubles/stub_surface_builder.h (+8/-2) src/client/lttng/CMakeLists.txt (+5/-4) src/client/mir_client_library.cpp (+29/-8) src/client/mir_connection.cpp (+16/-0) src/client/mir_connection.h (+4/-0) src/platform/graphics/CMakeLists.txt (+0/-1) src/server/CMakeLists.txt (+2/-1) src/server/compositor/CMakeLists.txt (+1/-0) src/server/compositor/buffer_bundle.h (+1/-0) src/server/compositor/buffer_stream_factory.cpp (+3/-3) src/server/compositor/buffer_stream_factory.h (+1/-1) src/server/compositor/buffer_stream_surfaces.cpp (+6/-1) src/server/compositor/buffer_stream_surfaces.h (+3/-2) src/server/compositor/bypass.cpp (+2/-2) src/server/compositor/bypass.h (+3/-3) src/server/compositor/default_configuration.cpp (+85/-0) src/server/compositor/default_display_buffer_compositor.cpp (+3/-3) src/server/compositor/default_display_buffer_compositor_factory.cpp (+3/-3) src/server/compositor/default_display_buffer_compositor_factory.h (+2/-0) src/server/compositor/gl_renderer.cpp (+2/-2) src/server/compositor/gl_renderer.h (+2/-2) src/server/compositor/gl_renderer_factory.cpp (+1/-1) src/server/compositor/gl_renderer_factory.h (+1/-1) src/server/compositor/multi_threaded_compositor.cpp (+1/-1) src/server/compositor/occlusion.cpp (+1/-1) src/server/compositor/occlusion.h (+1/-1) src/server/compositor/renderer.h (+2/-5) src/server/compositor/rendering_operator.cpp (+2/-3) src/server/compositor/rendering_operator.h (+2/-2) src/server/compositor/switching_bundle.cpp (+20/-3) src/server/compositor/switching_bundle.h (+12/-3) src/server/default_configuration_options.cpp (+6/-0) src/server/default_server_configuration.cpp (+0/-672) src/server/frontend/CMakeLists.txt (+1/-0) src/server/frontend/default_configuration.cpp (+97/-2) src/server/frontend/global_event_sender.cpp (+1/-1) src/server/frontend/global_event_sender.h (+1/-1) src/server/frontend/protobuf_message_processor.cpp (+1/-1) src/server/frontend/protobuf_session_creator.cpp (+1/-1) src/server/frontend/resource_cache.cpp (+1/-1) src/server/frontend/session_mediator.cpp (+53/-32) src/server/frontend/session_mediator.h (+4/-1) src/server/frontend/session_mediator_android.cpp (+1/-1) src/server/frontend/session_mediator_gbm.cpp (+1/-1) src/server/frontend/surface.cpp (+1/-16) src/server/frontend/unauthorized_display_changer.cpp (+5/-6) src/server/frontend/unauthorized_display_changer.h (+4/-4) src/server/graphics/CMakeLists.txt (+7/-0) src/server/graphics/android/CMakeLists.txt (+1/-2) src/server/graphics/android/android_display.cpp (+52/-12) src/server/graphics/android/android_display.h (+13/-10) src/server/graphics/android/android_display_buffer_factory.h (+6/-12) src/server/graphics/android/android_display_factory.cpp (+0/-96) src/server/graphics/android/android_display_factory.h (+0/-57) src/server/graphics/android/android_framebuffer_window.cpp (+0/-78) src/server/graphics/android/android_framebuffer_window.h (+0/-50) src/server/graphics/android/android_framebuffer_window_query.h (+0/-44) src/server/graphics/android/android_platform.cpp (+24/-12) src/server/graphics/android/android_platform.h (+8/-2) src/server/graphics/android/display_buffer.cpp (+80/-0) src/server/graphics/android/display_buffer.h (+60/-0) src/server/graphics/android/display_buffer_factory.cpp (+66/-90) src/server/graphics/android/display_buffer_factory.h (+23/-7) src/server/graphics/android/display_device.h (+7/-8) src/server/graphics/android/display_resource_factory.h (+16/-14) src/server/graphics/android/fb_device.cpp (+1/-3) src/server/graphics/android/fb_device.h (+2/-2) src/server/graphics/android/hwc10_device.cpp (+3/-4) src/server/graphics/android/hwc10_device.h (+6/-6) src/server/graphics/android/hwc11_device.cpp (+2/-2) src/server/graphics/android/hwc11_device.h (+3/-3) src/server/graphics/android/hwc_common_device.cpp (+0/-10) src/server/graphics/android/hwc_common_device.h (+4/-8) src/server/graphics/android/resource_factory.cpp (+58/-54) src/server/graphics/android/resource_factory.h (+24/-23) src/server/graphics/android/server_render_window.cpp (+2/-2) src/server/graphics/android/server_render_window.h (+3/-3) src/server/graphics/default_configuration.cpp (+146/-0) src/server/graphics/default_display_configuration_policy.cpp (+6/-6) src/server/graphics/default_display_configuration_policy.h (+3/-6) src/server/graphics/gbm/native_gbm_platform.cpp (+1/-0) src/server/graphics/nested/host_connection.cpp (+3/-3) src/server/graphics/nested/host_connection.h (+1/-1) src/server/graphics/nested/nested_display.cpp (+30/-20) src/server/graphics/nested/nested_display.h (+1/-1) src/server/graphics/nested/nested_platform.cpp (+11/-2) src/server/graphics/nested/nested_platform.h (+1/-1) src/server/input/CMakeLists.txt (+1/-0) src/server/input/android/dummy_android_pointer_controller.h (+2/-4) src/server/input/default_configuration.cpp (+128/-0) src/server/input/display_input_region.cpp (+1/-1) src/server/input/event_filter_chain.cpp (+1/-1) src/server/input/nested_input_configuration.cpp (+2/-2) src/server/input/nested_input_relay.cpp (+1/-1) src/server/input/null_input_configuration.cpp (+1/-1) src/server/logging/CMakeLists.txt (+2/-0) src/server/logging/connector_report.cpp (+1/-1) src/server/logging/default_configuration.cpp (+112/-0) src/server/logging/display_report.cpp (+1/-1) src/server/logging/session_mediator_report.cpp (+1/-1) src/server/logging/surfaces_report.cpp (+119/-0) src/server/logging/surfaces_report.h (+56/-0) src/server/lttng/CMakeLists.txt (+5/-4) src/server/shell/CMakeLists.txt (+1/-1) src/server/shell/application_session.cpp (+1/-1) src/server/shell/broadcasting_session_event_sink.cpp (+1/-1) src/server/shell/broadcasting_session_event_sink.h (+2/-2) src/server/shell/consuming_placement_strategy.cpp (+1/-1) src/server/shell/default_configuration.cpp (+205/-0) src/server/shell/default_focus_mechanism.cpp (+1/-1) src/server/shell/default_focus_mechanism.h (+1/-1) src/server/shell/default_session_container.cpp (+1/-1) src/server/shell/gl_pixel_buffer.cpp (+1/-1) src/server/shell/gl_pixel_buffer.h (+1/-1) src/server/shell/graphics_display_layout.cpp (+1/-1) src/server/shell/mediating_display_changer.cpp (+2/-2) src/server/shell/organising_surface_factory.cpp (+1/-1) src/server/shell/registration_order_focus_sequence.cpp (+1/-1) src/server/shell/registration_order_focus_sequence.h (+1/-1) src/server/shell/session_manager.cpp (+3/-3) src/server/shell/surface.cpp (+5/-0) src/server/shell/surface_source.cpp (+2/-2) src/server/shell/threaded_snapshot_strategy.cpp (+2/-2) src/server/shell/threaded_snapshot_strategy.h (+1/-1) src/server/surfaces/CMakeLists.txt (+2/-0) src/server/surfaces/default_configuration.cpp (+99/-0) src/server/surfaces/mutable_surface_state.h (+1/-0) src/server/surfaces/surface.cpp (+32/-8) src/server/surfaces/surface_allocator.cpp (+8/-6) src/server/surfaces/surface_allocator.h (+5/-2) src/server/surfaces/surface_controller.cpp (+1/-1) src/server/surfaces/surface_data.cpp (+10/-0) src/server/surfaces/surface_data.h (+1/-0) src/server/surfaces/surface_stack.cpp (+21/-11) src/server/surfaces/surface_stack.h (+6/-3) src/server/surfaces/surfaces_report.cpp (+27/-0) tests/acceptance-tests/CMakeLists.txt (+1/-0) tests/acceptance-tests/test_client_authorization.cpp (+9/-57) tests/acceptance-tests/test_client_focus_notification.cpp (+13/-46) tests/acceptance-tests/test_client_input.cpp (+27/-77) tests/acceptance-tests/test_client_library_drm.cpp (+59/-0) tests/acceptance-tests/test_display_configuration.cpp (+3/-17) tests/acceptance-tests/test_focus_selection.cpp (+10/-54) tests/acceptance-tests/test_server_shutdown.cpp (+15/-10) tests/acceptance-tests/test_surfaces_with_output_id.cpp (+1/-1) tests/integration-tests/compositor/test_buffer_stream.cpp (+77/-5) tests/integration-tests/compositor/test_swapping_swappers.cpp (+1/-1) tests/integration-tests/graphics/android/test_display_integration.cpp (+36/-105) tests/integration-tests/graphics/android/test_internal_client.cpp (+15/-8) tests/integration-tests/graphics/gbm/test_buffer_integration.cpp (+6/-10) tests/integration-tests/shell/test_session.cpp (+8/-19) tests/integration-tests/shell/test_session_manager.cpp (+4/-5) tests/integration-tests/test_display_info.cpp (+7/-13) tests/integration-tests/test_drm_auth_magic.cpp (+2/-17) tests/integration-tests/test_error_reporting.cpp (+2/-2) tests/integration-tests/test_surface_first_frame_sync.cpp (+3/-3) tests/integration-tests/test_surfaceloop.cpp (+9/-20) tests/integration-tests/test_swapinterval.cpp (+7/-6) tests/mir-stress/src/client.h (+1/-1) tests/mir_test_doubles/mock_egl.cpp (+1/-1) tests/mir_test_framework/testing_server_options.cpp (+9/-14) tests/unit-tests/android_input/CMakeLists.txt (+1/-0) tests/unit-tests/android_input/input_reader.cpp (+156/-98) tests/unit-tests/android_input/int_set.cpp (+133/-0) tests/unit-tests/client/test_client_mir_surface.cpp (+1/-1) tests/unit-tests/client/test_mir_connection.cpp (+48/-1) tests/unit-tests/compositor/test_buffer_stream.cpp (+14/-3) tests/unit-tests/compositor/test_default_display_buffer_compositor.cpp (+5/-5) tests/unit-tests/compositor/test_gl_renderer.cpp (+4/-4) tests/unit-tests/compositor/test_multi_threaded_compositor.cpp (+1/-1) tests/unit-tests/compositor/test_rendering_operator.cpp (+2/-3) tests/unit-tests/compositor/test_switching_bundle.cpp (+149/-22) tests/unit-tests/frontend/CMakeLists.txt (+1/-0) tests/unit-tests/frontend/stress_protobuf_communicator.cpp (+1/-1) tests/unit-tests/frontend/test_global_event_sender.cpp (+1/-1) tests/unit-tests/frontend/test_protobuf_reports_errors.cpp (+1/-1) tests/unit-tests/frontend/test_protobuf_sends_fds.cpp (+1/-1) tests/unit-tests/frontend/test_protobuf_surface_apis.cpp (+1/-1) tests/unit-tests/frontend/test_published_socket_connector.cpp (+1/-1) tests/unit-tests/frontend/test_resource_cache.cpp (+1/-1) tests/unit-tests/frontend/test_session_mediator.cpp (+5/-11) tests/unit-tests/frontend/test_session_mediator_android.cpp (+4/-18) tests/unit-tests/frontend/test_session_mediator_gbm.cpp (+5/-19) tests/unit-tests/frontend/test_unauthorized_display_changer.cpp (+3/-4) tests/unit-tests/graphics/android/CMakeLists.txt (+2/-3) tests/unit-tests/graphics/android/test_android_display_factory.cpp (+0/-210) tests/unit-tests/graphics/android/test_android_fb.cpp (+179/-499) tests/unit-tests/graphics/android/test_android_framebuffer_window.cpp (+0/-283) tests/unit-tests/graphics/android/test_android_platform.cpp (+7/-4) tests/unit-tests/graphics/android/test_display_buffer_factory.cpp (+214/-0) tests/unit-tests/graphics/android/test_fb_device.cpp (+35/-34) tests/unit-tests/graphics/android/test_hwc10_device.cpp (+22/-39) tests/unit-tests/graphics/android/test_hwc11_device.cpp (+32/-20) tests/unit-tests/graphics/android/test_hwc_device.cpp (+6/-24) tests/unit-tests/graphics/android/test_hwc_display.cpp (+115/-94) tests/unit-tests/graphics/android/test_resource_factory.cpp (+65/-73) tests/unit-tests/graphics/android/test_server_interpreter.cpp (+16/-18) tests/unit-tests/graphics/gbm/test_gbm_display.cpp (+2/-2) tests/unit-tests/graphics/gbm/test_gbm_display_configuration.cpp (+1/-1) tests/unit-tests/graphics/gbm/test_gbm_display_multi_monitor.cpp (+1/-1) tests/unit-tests/graphics/gbm/test_native_gbm_platform.cpp (+12/-0) tests/unit-tests/graphics/test_default_display_configuration_policy.cpp (+1/-1) tests/unit-tests/graphics/test_display.cpp (+12/-26) tests/unit-tests/input/android/test_android_input_lexicon.cpp (+14/-0) tests/unit-tests/input/test_display_input_region.cpp (+1/-1) tests/unit-tests/input/test_event_filter_chain.cpp (+1/-1) tests/unit-tests/logging/test_display_report.cpp (+1/-1) tests/unit-tests/options/test_program_option.cpp (+4/-4) tests/unit-tests/shell/CMakeLists.txt (+0/-2) tests/unit-tests/shell/test_broadcasting_session_event_sink.cpp (+1/-1) tests/unit-tests/shell/test_consuming_placement_strategy.cpp (+1/-1) tests/unit-tests/shell/test_default_focus_mechanism.cpp (+2/-2) tests/unit-tests/shell/test_gl_pixel_buffer.cpp (+1/-1) tests/unit-tests/shell/test_graphics_display_layout.cpp (+1/-1) tests/unit-tests/shell/test_mediating_display_changer.cpp (+2/-2) tests/unit-tests/shell/test_organising_surface_factory.cpp (+1/-1) tests/unit-tests/shell/test_registration_order_focus_sequence.cpp (+2/-2) tests/unit-tests/shell/test_session_manager.cpp (+4/-4) tests/unit-tests/shell/test_surface.cpp (+8/-2) tests/unit-tests/shell/test_the_session_container_implementation.cpp (+1/-1) tests/unit-tests/shell/test_threaded_snapshot_strategy.cpp (+2/-2) tests/unit-tests/surfaces/test_surface.cpp (+69/-18) tests/unit-tests/surfaces/test_surface_allocator.cpp (+1/-1) tests/unit-tests/surfaces/test_surface_controller.cpp (+1/-1) tests/unit-tests/surfaces/test_surface_data.cpp (+18/-0) tests/unit-tests/surfaces/test_surface_stack.cpp (+81/-34) tools/setup-partial-armhf-chroot.sh (+17/-17) |
To merge this branch: | bzr merge lp:~robertcarr/mir/delete-some-test-code |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir development team | Pending | ||
Review via email: mp+194392@code.launchpad.net |
This proposal has been superseded by a proposal from 2013-11-07.
Commit message
Avoid defining useless test structs in acceptance tests.
Description of the change
Factor out a bunch of "ClientConfigCo
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '3rd_party/android-input/android/CMakeLists.txt' |
2 | --- 3rd_party/android-input/android/CMakeLists.txt 2013-10-15 08:53:10 +0000 |
3 | +++ 3rd_party/android-input/android/CMakeLists.txt 2013-11-07 18:01:18 +0000 |
4 | @@ -33,6 +33,7 @@ |
5 | frameworks/base/services/input/InputReader.cpp |
6 | frameworks/base/services/input/InputTransport.cpp |
7 | frameworks/base/services/input/InputWindow.cpp |
8 | + frameworks/base/services/input/IntSet.cpp |
9 | frameworks/base/services/input/PointerController.cpp |
10 | # Keyboard/keymap handling |
11 | frameworks/base/services/input/GenericKeyMap.cpp |
12 | |
13 | === modified file '3rd_party/android-input/android/frameworks/base/include/androidfw/Input.h' |
14 | --- 3rd_party/android-input/android/frameworks/base/include/androidfw/Input.h 2013-05-03 16:38:07 +0000 |
15 | +++ 3rd_party/android-input/android/frameworks/base/include/androidfw/Input.h 2013-11-07 18:01:18 +0000 |
16 | @@ -77,9 +77,12 @@ |
17 | /* |
18 | * Maximum pointer id value supported in a motion event. |
19 | * Smallest pointer id is 0. |
20 | - * (This is limited by our use of BitSet32 to track pointer assignments.) |
21 | + * Any reasonably large value that fits in a int32_t is fine. |
22 | + * A "reasonably large" number is one that guarantees uniqueness of a touch id for some 30 seconds |
23 | + * after its corresponding touch point has physically ended, under very heavy usage (many |
24 | + * simultaneous taps ongoing). |
25 | */ |
26 | -#define MAX_POINTER_ID 31 |
27 | +#define MAX_POINTER_ID 100000000 |
28 | |
29 | /* |
30 | * Declare a concrete type for the NDK's input event forward declaration. |
31 | |
32 | === modified file '3rd_party/android-input/android/frameworks/base/include/androidfw/InputTransport.h' |
33 | --- 3rd_party/android-input/android/frameworks/base/include/androidfw/InputTransport.h 2013-05-31 16:06:07 +0000 |
34 | +++ 3rd_party/android-input/android/frameworks/base/include/androidfw/InputTransport.h 2013-11-07 18:01:18 +0000 |
35 | @@ -29,12 +29,15 @@ |
36 | */ |
37 | |
38 | #include <androidfw/Input.h> |
39 | +#include <androidfw/IntSet.h> |
40 | #include <std/Errors.h> |
41 | #include <std/Timers.h> |
42 | #include <std/RefBase.h> |
43 | #include <std/String8.h> |
44 | #include <std/Vector.h> |
45 | -#include <std/BitSet.h> |
46 | + |
47 | +// C++ std lib |
48 | +#include <unordered_map> |
49 | |
50 | namespace android { |
51 | |
52 | @@ -352,23 +355,23 @@ |
53 | // Touch state per device and source, only for sources of class pointer. |
54 | struct History { |
55 | nsecs_t eventTime; |
56 | - BitSet32 idBits; |
57 | - int32_t idToIndex[MAX_POINTER_ID + 1]; |
58 | + IntSet ids; |
59 | + std::unordered_map<int32_t, size_t> idToIndex; |
60 | PointerCoords pointers[MAX_POINTERS]; |
61 | |
62 | void initializeFrom(const InputMessage* msg) { |
63 | eventTime = msg->body.motion.eventTime; |
64 | - idBits.clear(); |
65 | + ids.clear(); |
66 | for (size_t i = 0; i < msg->body.motion.pointerCount; i++) { |
67 | uint32_t id = msg->body.motion.pointers[i].properties.id; |
68 | - idBits.markBit(id); |
69 | + ids.insert(id); |
70 | idToIndex[id] = i; |
71 | pointers[i].copyFrom(msg->body.motion.pointers[i].coords); |
72 | } |
73 | } |
74 | |
75 | const PointerCoords& getPointerById(uint32_t id) const { |
76 | - return pointers[idToIndex[id]]; |
77 | + return pointers[idToIndex.at(id)]; |
78 | } |
79 | }; |
80 | struct TouchState { |
81 | @@ -385,7 +388,7 @@ |
82 | historyCurrent = 0; |
83 | historySize = 0; |
84 | lastResample.eventTime = 0; |
85 | - lastResample.idBits.clear(); |
86 | + lastResample.ids.clear(); |
87 | } |
88 | |
89 | void addHistory(const InputMessage* msg) { |
90 | |
91 | === added file '3rd_party/android-input/android/frameworks/base/include/androidfw/IntSet.h' |
92 | --- 3rd_party/android-input/android/frameworks/base/include/androidfw/IntSet.h 1970-01-01 00:00:00 +0000 |
93 | +++ 3rd_party/android-input/android/frameworks/base/include/androidfw/IntSet.h 2013-11-07 18:01:18 +0000 |
94 | @@ -0,0 +1,104 @@ |
95 | +/* |
96 | + * Copyright © 2013 Canonical Ltd. |
97 | + * |
98 | + * This program is free software: you can redistribute it and/or modify it |
99 | + * under the terms of the GNU Lesser General Public License version 3, |
100 | + * as published by the Free Software Foundation. |
101 | + * |
102 | + * This program is distributed in the hope that it will be useful, |
103 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
104 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
105 | + * GNU Lesser General Public License for more details. |
106 | + * |
107 | + * You should have received a copy of the GNU Lesser General Public License |
108 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
109 | + * |
110 | + * Author: Daniel d'Andrada <daniel.dandrada@canonical.com> |
111 | + */ |
112 | + |
113 | +#ifndef ANDROID_INTSET_H |
114 | +#define ANDROID_INTSET_H |
115 | + |
116 | +#include <assert.h> |
117 | + |
118 | +// C++ std lib |
119 | +#include <algorithm> |
120 | +#include <sstream> |
121 | +#include <set> |
122 | + |
123 | +#ifdef ANDROID_INPUT_INTSET_TEST |
124 | +namespace test { |
125 | +#endif |
126 | + |
127 | +namespace android { |
128 | + |
129 | +/* |
130 | + A set of integers |
131 | + |
132 | + It serves two purposes: |
133 | + - Provide a convenience wrapper for std::set<int32_t>. Because the std API is cumbersome. |
134 | + - Provide an API similar to the BitSet32 class that it's replacing. |
135 | + */ |
136 | +class IntSet { |
137 | +public: |
138 | + |
139 | +#ifdef ANDROID_INPUT_INTSET_TEST |
140 | + static int constructionCount; |
141 | + static int destructionCount; |
142 | +#endif |
143 | + |
144 | + IntSet(); |
145 | + IntSet(std::initializer_list<int32_t> list); |
146 | + virtual ~IntSet(); |
147 | + |
148 | + IntSet operator -(const IntSet &other) const; |
149 | + IntSet operator &(const IntSet &other) const; |
150 | + bool operator ==(const IntSet &other) const; |
151 | + |
152 | + std::set<int32_t>::iterator begin() { return stdSet.begin(); } |
153 | + std::set<int32_t>::const_iterator begin() const { return stdSet.begin(); } |
154 | + std::set<int32_t>::iterator end() { return stdSet.end(); } |
155 | + std::set<int32_t>::const_iterator end() const { return stdSet.end(); } |
156 | + std::set<int32_t>::const_iterator cbegin() const { return stdSet.cbegin(); } |
157 | + std::set<int32_t>::const_iterator cend() const { return stdSet.cend(); } |
158 | + |
159 | + void clear() { stdSet.clear(); } |
160 | + void insert(int32_t value) { stdSet.insert(value); } |
161 | + |
162 | + template<typename Func> |
163 | + void forEach(Func func) { std::for_each(stdSet.begin(), stdSet.end(), func); } |
164 | + |
165 | + template<typename Func> |
166 | + void forEach(Func func) const { std::for_each(stdSet.begin(), stdSet.end(), func); } |
167 | + |
168 | + void remove(int32_t value) { stdSet.erase(value); } |
169 | + void remove(const IntSet &values); |
170 | + |
171 | + size_t size() const { return stdSet.size(); } |
172 | + size_t count() const { return stdSet.size(); } |
173 | + |
174 | + bool isEmpty() const { return stdSet.empty(); } |
175 | + |
176 | + bool contains(int32_t value) const; |
177 | + |
178 | + int32_t first() const { return *stdSet.cbegin(); } |
179 | + |
180 | + // It's assumed that the given value does exist in the set |
181 | + size_t indexOf(int32_t value) const; |
182 | + |
183 | + std::string toString() const; |
184 | + |
185 | +private: |
186 | + void remove(std::set<int32_t>::iterator selfIterator, |
187 | + std::set<int32_t>::const_iterator otherIterator, |
188 | + std::set<int32_t>::const_iterator otherEnd); |
189 | + std::set<int32_t> stdSet; |
190 | +}; |
191 | + |
192 | +} // namespace android |
193 | + |
194 | +#ifdef ANDROID_INPUT_INTSET_TEST |
195 | +} // namespace test |
196 | +#endif |
197 | + |
198 | +#endif |
199 | |
200 | === modified file '3rd_party/android-input/android/frameworks/base/include/androidfw/VelocityControl.h' |
201 | --- 3rd_party/android-input/android/frameworks/base/include/androidfw/VelocityControl.h 2013-05-03 16:38:07 +0000 |
202 | +++ 3rd_party/android-input/android/frameworks/base/include/androidfw/VelocityControl.h 2013-11-07 18:01:18 +0000 |
203 | @@ -19,6 +19,7 @@ |
204 | |
205 | |
206 | #include <androidfw/Input.h> |
207 | +#include <androidfw/IntSet.h> |
208 | #include <androidfw/VelocityTracker.h> |
209 | #include <std/Timers.h> |
210 | |
211 | @@ -101,6 +102,7 @@ |
212 | nsecs_t mLastMovementTime; |
213 | VelocityTracker::Position mRawPosition; |
214 | VelocityTracker mVelocityTracker; |
215 | + IntSet mIds; |
216 | }; |
217 | |
218 | } // namespace android |
219 | |
220 | === modified file '3rd_party/android-input/android/frameworks/base/include/androidfw/VelocityTracker.h' |
221 | --- 3rd_party/android-input/android/frameworks/base/include/androidfw/VelocityTracker.h 2013-05-03 16:38:07 +0000 |
222 | +++ 3rd_party/android-input/android/frameworks/base/include/androidfw/VelocityTracker.h 2013-11-07 18:01:18 +0000 |
223 | @@ -17,10 +17,12 @@ |
224 | #ifndef _ANDROIDFW_VELOCITY_TRACKER_H |
225 | #define _ANDROIDFW_VELOCITY_TRACKER_H |
226 | |
227 | - |
228 | #include <androidfw/Input.h> |
229 | +#include <androidfw/IntSet.h> |
230 | #include <std/Timers.h> |
231 | -#include <std/BitSet.h> |
232 | + |
233 | +// C++ std lib |
234 | +#include <unordered_map> |
235 | |
236 | namespace android { |
237 | |
238 | @@ -74,14 +76,14 @@ |
239 | // Resets the velocity tracker state for specific pointers. |
240 | // Call this method when some pointers have changed and may be reusing |
241 | // an id that was assigned to a different pointer earlier. |
242 | - void clearPointers(BitSet32 idBits); |
243 | + void clearPointers(const IntSet &ids); |
244 | |
245 | // Adds movement information for a set of pointers. |
246 | - // The idBits bitfield specifies the pointer ids of the pointers whose positions |
247 | + // The ids set specifies the pointer ids of the pointers whose positions |
248 | // are included in the movement. |
249 | // The positions array contains position information for each pointer in order by |
250 | - // increasing id. Its size should be equal to the number of one bits in idBits. |
251 | - void addMovement(nsecs_t eventTime, BitSet32 idBits, const Position* positions); |
252 | + // increasing id. Its size should be equal to the size of ids. |
253 | + void addMovement(nsecs_t eventTime, const IntSet &ids, const Position* positions); |
254 | |
255 | // Adds movement information for all pointers in a MotionEvent, including historical samples. |
256 | void addMovement(const MotionEvent* event); |
257 | @@ -100,13 +102,13 @@ |
258 | inline int32_t getActivePointerId() const { return mActivePointerId; } |
259 | |
260 | // Gets a bitset containing all pointer ids from the most recent movement. |
261 | - inline BitSet32 getCurrentPointerIdBits() const { return mCurrentPointerIdBits; } |
262 | + inline const IntSet &getCurrentPointerIds() const { return mCurrentPointerIds; } |
263 | |
264 | private: |
265 | static const char* DEFAULT_STRATEGY; |
266 | |
267 | nsecs_t mLastEventTime; |
268 | - BitSet32 mCurrentPointerIdBits; |
269 | + IntSet mCurrentPointerIds; |
270 | int32_t mActivePointerId; |
271 | VelocityTrackerStrategy* mStrategy; |
272 | |
273 | @@ -127,8 +129,8 @@ |
274 | virtual ~VelocityTrackerStrategy() { } |
275 | |
276 | virtual void clear() = 0; |
277 | - virtual void clearPointers(BitSet32 idBits) = 0; |
278 | - virtual void addMovement(nsecs_t eventTime, BitSet32 idBits, |
279 | + virtual void clearPointers(const IntSet &ids) = 0; |
280 | + virtual void addMovement(nsecs_t eventTime, const IntSet &ids, |
281 | const VelocityTracker::Position* positions) = 0; |
282 | virtual bool getEstimator(uint32_t id, VelocityTracker::Estimator* outEstimator) const = 0; |
283 | }; |
284 | @@ -159,8 +161,8 @@ |
285 | virtual ~LeastSquaresVelocityTrackerStrategy(); |
286 | |
287 | virtual void clear(); |
288 | - virtual void clearPointers(BitSet32 idBits); |
289 | - virtual void addMovement(nsecs_t eventTime, BitSet32 idBits, |
290 | + virtual void clearPointers(const IntSet &ids); |
291 | + virtual void addMovement(nsecs_t eventTime, const IntSet &ids, |
292 | const VelocityTracker::Position* positions); |
293 | virtual bool getEstimator(uint32_t id, VelocityTracker::Estimator* outEstimator) const; |
294 | |
295 | @@ -175,11 +177,11 @@ |
296 | |
297 | struct Movement { |
298 | nsecs_t eventTime; |
299 | - BitSet32 idBits; |
300 | + IntSet ids; |
301 | VelocityTracker::Position positions[MAX_POINTERS]; |
302 | |
303 | inline const VelocityTracker::Position& getPosition(uint32_t id) const { |
304 | - return positions[idBits.getIndexOfBit(id)]; |
305 | + return positions[ids.indexOf(id)]; |
306 | } |
307 | }; |
308 | |
309 | @@ -202,8 +204,8 @@ |
310 | ~IntegratingVelocityTrackerStrategy(); |
311 | |
312 | virtual void clear(); |
313 | - virtual void clearPointers(BitSet32 idBits); |
314 | - virtual void addMovement(nsecs_t eventTime, BitSet32 idBits, |
315 | + virtual void clearPointers(const IntSet &ids); |
316 | + virtual void addMovement(nsecs_t eventTime, const IntSet &ids, |
317 | const VelocityTracker::Position* positions); |
318 | virtual bool getEstimator(uint32_t id, VelocityTracker::Estimator* outEstimator) const; |
319 | |
320 | @@ -218,8 +220,8 @@ |
321 | }; |
322 | |
323 | const uint32_t mDegree; |
324 | - BitSet32 mPointerIdBits; |
325 | - State mPointerState[MAX_POINTER_ID + 1]; |
326 | + IntSet mPointerIds; |
327 | + std::unordered_map<int32_t, State> mPointerState; // maps the id of a pointer to its state |
328 | |
329 | void initState(State& state, nsecs_t eventTime, float xpos, float ypos) const; |
330 | void updateState(State& state, nsecs_t eventTime, float xpos, float ypos) const; |
331 | @@ -236,8 +238,8 @@ |
332 | virtual ~LegacyVelocityTrackerStrategy(); |
333 | |
334 | virtual void clear(); |
335 | - virtual void clearPointers(BitSet32 idBits); |
336 | - virtual void addMovement(nsecs_t eventTime, BitSet32 idBits, |
337 | + virtual void clearPointers(const IntSet &ids); |
338 | + virtual void addMovement(nsecs_t eventTime, const IntSet &ids, |
339 | const VelocityTracker::Position* positions); |
340 | virtual bool getEstimator(uint32_t id, VelocityTracker::Estimator* outEstimator) const; |
341 | |
342 | @@ -253,11 +255,11 @@ |
343 | |
344 | struct Movement { |
345 | nsecs_t eventTime; |
346 | - BitSet32 idBits; |
347 | + IntSet ids; |
348 | VelocityTracker::Position positions[MAX_POINTERS]; |
349 | |
350 | inline const VelocityTracker::Position& getPosition(uint32_t id) const { |
351 | - return positions[idBits.getIndexOfBit(id)]; |
352 | + return positions[ids.indexOf(id)]; |
353 | } |
354 | }; |
355 | |
356 | |
357 | === modified file '3rd_party/android-input/android/frameworks/base/services/input/InputDevice.cpp' |
358 | --- 3rd_party/android-input/android/frameworks/base/services/input/InputDevice.cpp 2013-02-05 17:19:57 +0000 |
359 | +++ 3rd_party/android-input/android/frameworks/base/services/input/InputDevice.cpp 2013-11-07 18:01:18 +0000 |
360 | @@ -16,6 +16,9 @@ |
361 | |
362 | #define LOG_TAG "InputDevice" |
363 | |
364 | +#include <cutils/log.h> |
365 | +#define DEBUG_PROBE 0 |
366 | + |
367 | #include <stdlib.h> |
368 | #include <unistd.h> |
369 | #include <ctype.h> |
370 | @@ -97,7 +100,7 @@ |
371 | path.append("/usr/"); |
372 | appendInputDeviceConfigurationFileRelativePath(path, name, type); |
373 | #if DEBUG_PROBE |
374 | - ALOGD("Probing for system provided input device configuration file: path='%s'", path.string()); |
375 | + ALOGD("Probing for system provided input device configuration file: path='%s'", path.c_str()); |
376 | #endif |
377 | if (!access(c_str(path), R_OK)) { |
378 | #if DEBUG_PROBE |
379 | @@ -119,7 +122,7 @@ |
380 | path.append("/system/devices/"); |
381 | appendInputDeviceConfigurationFileRelativePath(path, name, type); |
382 | #if DEBUG_PROBE |
383 | - ALOGD("Probing for system user input device configuration file: path='%s'", path.string()); |
384 | + ALOGD("Probing for system user input device configuration file: path='%s'", path.c_str()); |
385 | #endif |
386 | if (!access(c_str(path), R_OK)) { |
387 | #if DEBUG_PROBE |
388 | @@ -131,7 +134,7 @@ |
389 | // Not found. |
390 | #if DEBUG_PROBE |
391 | ALOGD("Probe failed to find input device configuration file: name='%s', type=%d", |
392 | - name.string(), type); |
393 | + name.c_str(), type); |
394 | #endif |
395 | return String8(); |
396 | } |
397 | |
398 | === modified file '3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.cpp' |
399 | --- 3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.cpp 2013-08-28 03:41:48 +0000 |
400 | +++ 3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.cpp 2013-11-07 18:01:18 +0000 |
401 | @@ -152,7 +152,7 @@ |
402 | pointerCount, MAX_POINTERS); |
403 | return false; |
404 | } |
405 | - BitSet32 pointerIdBits; |
406 | + IntSet pointerIds; |
407 | for (size_t i = 0; i < pointerCount; i++) { |
408 | int32_t id = pointerProperties[i].id; |
409 | if (id < 0 || id > MAX_POINTER_ID) { |
410 | @@ -160,11 +160,11 @@ |
411 | id, MAX_POINTER_ID); |
412 | return false; |
413 | } |
414 | - if (pointerIdBits.hasBit(id)) { |
415 | + if (pointerIds.contains(id)) { |
416 | ALOGE("Motion event has duplicate pointer id %d", id); |
417 | return false; |
418 | } |
419 | - pointerIdBits.markBit(id); |
420 | + pointerIds.insert(id); |
421 | } |
422 | return true; |
423 | } |
424 | @@ -1043,7 +1043,7 @@ |
425 | // Success! Output targets. |
426 | injectionResult = INPUT_EVENT_INJECTION_SUCCEEDED; |
427 | addWindowTargetLocked(mFocusedWindowHandle, |
428 | - InputTarget::FLAG_FOREGROUND | InputTarget::FLAG_DISPATCH_AS_IS, BitSet32(0), |
429 | + InputTarget::FLAG_FOREGROUND | InputTarget::FLAG_DISPATCH_AS_IS, IntSet(), |
430 | inputTargets); |
431 | |
432 | // Done. |
433 | @@ -1181,7 +1181,7 @@ |
434 | } |
435 | |
436 | mTempTouchState.addOrUpdateWindow( |
437 | - windowHandle, outsideTargetFlags, BitSet32(0)); |
438 | + windowHandle, outsideTargetFlags, IntSet()); |
439 | } |
440 | } |
441 | }); |
442 | @@ -1250,10 +1250,10 @@ |
443 | } |
444 | |
445 | // Update the temporary touch state. |
446 | - BitSet32 pointerIds; |
447 | + IntSet pointerIds; |
448 | if (isSplit) { |
449 | - uint32_t pointerId = entry->pointerProperties[pointerIndex].id; |
450 | - pointerIds.markBit(pointerId); |
451 | + int32_t pointerId = entry->pointerProperties[pointerIndex].id; |
452 | + pointerIds.insert(pointerId); |
453 | } |
454 | mTempTouchState.addOrUpdateWindow(newTouchedWindowHandle, targetFlags, pointerIds); |
455 | } else { |
456 | @@ -1288,7 +1288,7 @@ |
457 | #endif |
458 | // Make a slippery exit from the old window. |
459 | mTempTouchState.addOrUpdateWindow(oldTouchedWindowHandle, |
460 | - InputTarget::FLAG_DISPATCH_AS_SLIPPERY_EXIT, BitSet32(0)); |
461 | + InputTarget::FLAG_DISPATCH_AS_SLIPPERY_EXIT, IntSet()); |
462 | |
463 | // Make a slippery entrance into the new window. |
464 | if (newTouchedWindowHandle->getInfo()->supportsSplitTouch()) { |
465 | @@ -1304,9 +1304,9 @@ |
466 | targetFlags |= InputTarget::FLAG_WINDOW_IS_OBSCURED; |
467 | } |
468 | |
469 | - BitSet32 pointerIds; |
470 | + IntSet pointerIds; |
471 | if (isSplit) { |
472 | - pointerIds.markBit(entry->pointerProperties[0].id); |
473 | + pointerIds.insert(entry->pointerProperties[0].id); |
474 | } |
475 | mTempTouchState.addOrUpdateWindow(newTouchedWindowHandle, targetFlags, pointerIds); |
476 | } |
477 | @@ -1321,7 +1321,7 @@ |
478 | c_str(mLastHoverWindowHandle->getName())); |
479 | #endif |
480 | mTempTouchState.addOrUpdateWindow(mLastHoverWindowHandle, |
481 | - InputTarget::FLAG_DISPATCH_AS_HOVER_EXIT, BitSet32(0)); |
482 | + InputTarget::FLAG_DISPATCH_AS_HOVER_EXIT, IntSet()); |
483 | } |
484 | |
485 | // Let the new window know that the hover sequence is starting. |
486 | @@ -1331,7 +1331,7 @@ |
487 | c_str(newHoverWindowHandle->getName())); |
488 | #endif |
489 | mTempTouchState.addOrUpdateWindow(newHoverWindowHandle, |
490 | - InputTarget::FLAG_DISPATCH_AS_HOVER_ENTER, BitSet32(0)); |
491 | + InputTarget::FLAG_DISPATCH_AS_HOVER_ENTER, IntSet()); |
492 | } |
493 | } |
494 | |
495 | @@ -1375,7 +1375,7 @@ |
496 | sp<InputWindowHandle> inputWindowHandle = touchedWindow.windowHandle; |
497 | if (inputWindowHandle->getInfo()->ownerUid != foregroundWindowUid) { |
498 | mTempTouchState.addOrUpdateWindow(inputWindowHandle, |
499 | - InputTarget::FLAG_ZERO_COORDS, BitSet32(0)); |
500 | + InputTarget::FLAG_ZERO_COORDS, IntSet()); |
501 | } |
502 | } |
503 | } |
504 | @@ -1421,7 +1421,7 @@ |
505 | mTempTouchState.addOrUpdateWindow(windowHandle, |
506 | InputTarget::FLAG_WINDOW_IS_OBSCURED |
507 | | InputTarget::FLAG_DISPATCH_AS_IS, |
508 | - BitSet32(0)); |
509 | + IntSet()); |
510 | } |
511 | }); |
512 | } |
513 | @@ -1491,12 +1491,12 @@ |
514 | // One pointer went up. |
515 | if (isSplit) { |
516 | int32_t pointerIndex = getMotionEventActionPointerIndex(action); |
517 | - uint32_t pointerId = entry->pointerProperties[pointerIndex].id; |
518 | + int32_t pointerId = entry->pointerProperties[pointerIndex].id; |
519 | |
520 | for (size_t i = 0; i < mTempTouchState.windows.size(); ) { |
521 | TouchedWindow& touchedWindow = mTempTouchState.windows.editItemAt(i); |
522 | if (touchedWindow.targetFlags & InputTarget::FLAG_SPLIT) { |
523 | - touchedWindow.pointerIds.clearBit(pointerId); |
524 | + touchedWindow.pointerIds.remove(pointerId); |
525 | if (touchedWindow.pointerIds.isEmpty()) { |
526 | mTempTouchState.windows.removeAt(i); |
527 | continue; |
528 | @@ -1538,7 +1538,7 @@ |
529 | } |
530 | |
531 | void InputDispatcher::addWindowTargetLocked(const sp<InputWindowHandle>& windowHandle, |
532 | - int32_t targetFlags, BitSet32 pointerIds, Vector<InputTarget>& inputTargets) { |
533 | + int32_t targetFlags, const IntSet &pointerIds, Vector<InputTarget>& inputTargets) { |
534 | inputTargets.push(); |
535 | |
536 | const InputWindowInfo* windowInfo = windowHandle->getInfo(); |
537 | @@ -1693,12 +1693,13 @@ |
538 | void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime, |
539 | const sp<Connection>& connection, EventEntry* eventEntry, const InputTarget* inputTarget) { |
540 | #if DEBUG_DISPATCH_CYCLE |
541 | + std::string pointerIdsString = inputTarget->pointerIds.toString(); |
542 | ALOGD("channel '%s' ~ prepareDispatchCycle - flags=0x%08x, " |
543 | "xOffset=%f, yOffset=%f, scaleFactor=%f, " |
544 | - "pointerIds=0x%x", |
545 | + "pointerIds=%s", |
546 | connection->getInputChannelName(), inputTarget->flags, |
547 | inputTarget->xOffset, inputTarget->yOffset, |
548 | - inputTarget->scaleFactor, inputTarget->pointerIds.value); |
549 | + inputTarget->scaleFactor, pointerIdsString.c_str()); |
550 | #endif |
551 | |
552 | // Skip this event if the connection status is not normal. |
553 | @@ -2163,8 +2164,8 @@ |
554 | } |
555 | |
556 | InputDispatcher::MotionEntry* |
557 | -InputDispatcher::splitMotionEvent(const MotionEntry* originalMotionEntry, BitSet32 pointerIds) { |
558 | - ALOG_ASSERT(pointerIds.value != 0); |
559 | +InputDispatcher::splitMotionEvent(const MotionEntry* originalMotionEntry, const IntSet &pointerIds) { |
560 | + ALOG_ASSERT(!pointerIds.isEmpty()); |
561 | |
562 | uint32_t splitPointerIndexMap[MAX_POINTERS]; |
563 | PointerProperties splitPointerProperties[MAX_POINTERS]; |
564 | @@ -2178,7 +2179,7 @@ |
565 | const PointerProperties& pointerProperties = |
566 | originalMotionEntry->pointerProperties[originalPointerIndex]; |
567 | uint32_t pointerId = uint32_t(pointerProperties.id); |
568 | - if (pointerIds.hasBit(pointerId)) { |
569 | + if (pointerIds.contains(pointerId)) { |
570 | splitPointerIndexMap[splitPointerCount] = originalPointerIndex; |
571 | splitPointerProperties[splitPointerCount].copyFrom(pointerProperties); |
572 | splitPointerCoords[splitPointerCount].copyFrom( |
573 | @@ -2207,8 +2208,8 @@ |
574 | int32_t originalPointerIndex = getMotionEventActionPointerIndex(action); |
575 | const PointerProperties& pointerProperties = |
576 | originalMotionEntry->pointerProperties[originalPointerIndex]; |
577 | - uint32_t pointerId = uint32_t(pointerProperties.id); |
578 | - if (pointerIds.hasBit(pointerId)) { |
579 | + int32_t pointerId = pointerProperties.id; |
580 | + if (pointerIds.contains(pointerId)) { |
581 | if (pointerIds.count() == 1) { |
582 | // The first/last pointer went down/up. |
583 | action = maskedAction == AMOTION_EVENT_ACTION_POINTER_DOWN |
584 | @@ -2216,7 +2217,7 @@ |
585 | } else { |
586 | // A secondary pointer went down/up. |
587 | uint32_t splitPointerIndex = 0; |
588 | - while (pointerId != uint32_t(splitPointerProperties[splitPointerIndex].id)) { |
589 | + while (pointerId != splitPointerProperties[splitPointerIndex].id) { |
590 | splitPointerIndex += 1; |
591 | } |
592 | action = maskedAction | (splitPointerIndex |
593 | @@ -2901,7 +2902,7 @@ |
594 | const TouchedWindow& touchedWindow = mTouchState.windows[i]; |
595 | if (touchedWindow.windowHandle == fromWindowHandle) { |
596 | int32_t oldTargetFlags = touchedWindow.targetFlags; |
597 | - BitSet32 pointerIds = touchedWindow.pointerIds; |
598 | + IntSet pointerIds = touchedWindow.pointerIds; |
599 | |
600 | mTouchState.windows.removeAt(i); |
601 | |
602 | @@ -3000,10 +3001,14 @@ |
603 | dump.append(INDENT "TouchedWindows:\n"); |
604 | for (size_t i = 0; i < mTouchState.windows.size(); i++) { |
605 | const TouchedWindow& touchedWindow = mTouchState.windows[i]; |
606 | - appendFormat(dump, INDENT2 "%d: name='%s', pointerIds=0x%0x, targetFlags=0x%x\n", |
607 | - i, c_str(touchedWindow.windowHandle->getName()), |
608 | - touchedWindow.pointerIds.value, |
609 | - touchedWindow.targetFlags); |
610 | + appendFormat(dump, INDENT2 "%d: name='%s'", |
611 | + i, c_str(touchedWindow.windowHandle->getName())); |
612 | + |
613 | + dump.append(", pointerIds=("); |
614 | + touchedWindow.pointerIds.forEach([&](int32_t id) {appendFormat(dump, ", %d", id);}); |
615 | + dump.append(")"); |
616 | + |
617 | + appendFormat(dump, ", targetFlags=0x%x\n", touchedWindow.targetFlags); |
618 | } |
619 | } else { |
620 | dump.append(INDENT "TouchedWindows: <none>\n"); |
621 | @@ -4191,7 +4196,7 @@ |
622 | } |
623 | |
624 | void InputDispatcher::TouchState::addOrUpdateWindow(const sp<InputWindowHandle>& windowHandle, |
625 | - int32_t targetFlags, BitSet32 pointerIds) { |
626 | + int32_t targetFlags, const IntSet &pointerIds) { |
627 | if (targetFlags & InputTarget::FLAG_SPLIT) { |
628 | split = true; |
629 | } |
630 | @@ -4203,7 +4208,9 @@ |
631 | if (targetFlags & InputTarget::FLAG_DISPATCH_AS_SLIPPERY_EXIT) { |
632 | touchedWindow.targetFlags &= ~InputTarget::FLAG_DISPATCH_AS_IS; |
633 | } |
634 | - touchedWindow.pointerIds.value |= pointerIds.value; |
635 | + pointerIds.forEach([&](int32_t id) { |
636 | + touchedWindow.pointerIds.insert(id); |
637 | + }); |
638 | return; |
639 | } |
640 | } |
641 | |
642 | === modified file '3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.h' |
643 | --- 3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.h 2013-05-30 19:24:29 +0000 |
644 | +++ 3rd_party/android-input/android/frameworks/base/services/input/InputDispatcher.h 2013-11-07 18:01:18 +0000 |
645 | @@ -19,13 +19,13 @@ |
646 | |
647 | #include <androidfw/Input.h> |
648 | #include <androidfw/InputTransport.h> |
649 | +#include <androidfw/IntSet.h> |
650 | #include <std/KeyedVector.h> |
651 | #include <std/Vector.h> |
652 | #include <std/Timers.h> |
653 | #include <std/RefBase.h> |
654 | #include <std/String8.h> |
655 | #include <std/Looper.h> |
656 | -#include <std/BitSet.h> |
657 | #include <std/atomic.h> |
658 | #include <std/Condition.h> |
659 | #include <std/Thread.h> |
660 | @@ -169,7 +169,7 @@ |
661 | |
662 | // The subset of pointer ids to include in motion events dispatched to this input target |
663 | // if FLAG_SPLIT is set. |
664 | - BitSet32 pointerIds; |
665 | + IntSet pointerIds; |
666 | }; |
667 | |
668 | |
669 | @@ -953,7 +953,7 @@ |
670 | struct TouchedWindow { |
671 | sp<InputWindowHandle> windowHandle; |
672 | int32_t targetFlags; |
673 | - BitSet32 pointerIds; // zero unless target flag FLAG_SPLIT is set |
674 | + IntSet pointerIds; // empty unless target flag FLAG_SPLIT is set |
675 | }; |
676 | struct TouchState { |
677 | bool down; |
678 | @@ -967,7 +967,7 @@ |
679 | void reset(); |
680 | void copyFrom(const TouchState& other); |
681 | void addOrUpdateWindow(const sp<InputWindowHandle>& windowHandle, |
682 | - int32_t targetFlags, BitSet32 pointerIds); |
683 | + int32_t targetFlags, const IntSet &pointerIds); |
684 | void removeWindow(const sp<InputWindowHandle>& windowHandle); |
685 | void filterNonAsIsTouchWindows(); |
686 | sp<InputWindowHandle> getFirstForegroundWindowHandle() const; |
687 | @@ -1033,7 +1033,7 @@ |
688 | bool* outConflictingPointerActions); |
689 | |
690 | void addWindowTargetLocked(const sp<InputWindowHandle>& windowHandle, |
691 | - int32_t targetFlags, BitSet32 pointerIds, Vector<InputTarget>& inputTargets); |
692 | + int32_t targetFlags, const IntSet &pointerIds, Vector<InputTarget>& inputTargets); |
693 | void addMonitoringTargetsLocked(Vector<InputTarget>& inputTargets); |
694 | |
695 | bool checkInjectionPermission(const sp<InputWindowHandle>& windowHandle, |
696 | @@ -1072,7 +1072,7 @@ |
697 | const CancelationOptions& options); |
698 | |
699 | // Splitting motion events across windows. |
700 | - MotionEntry* splitMotionEvent(const MotionEntry* originalMotionEntry, BitSet32 pointerIds); |
701 | + MotionEntry* splitMotionEvent(const MotionEntry* originalMotionEntry, const IntSet &pointerIds); |
702 | |
703 | // Reset and drop everything the dispatcher is doing. |
704 | void resetAndDropEverythingLocked(const char* reason); |
705 | |
706 | === added file '3rd_party/android-input/android/frameworks/base/services/input/InputEventPrinter.h' |
707 | --- 3rd_party/android-input/android/frameworks/base/services/input/InputEventPrinter.h 1970-01-01 00:00:00 +0000 |
708 | +++ 3rd_party/android-input/android/frameworks/base/services/input/InputEventPrinter.h 2013-11-07 18:01:18 +0000 |
709 | @@ -0,0 +1,138 @@ |
710 | +/* |
711 | + * Copyright © 2013 Canonical Ltd. |
712 | + * |
713 | + * This program is free software: you can redistribute it and/or modify it |
714 | + * under the terms of the GNU Lesser General Public License version 3, |
715 | + * as published by the Free Software Foundation. |
716 | + * |
717 | + * This program is distributed in the hope that it will be useful, |
718 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
719 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
720 | + * GNU Lesser General Public License for more details. |
721 | + * |
722 | + * You should have received a copy of the GNU Lesser General Public License |
723 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
724 | + * |
725 | + * Author: Daniel d'Andrada <daniel.dandrada@canonical.com> |
726 | + */ |
727 | + |
728 | +#ifndef INPUT_EVENT_PRINTER_H |
729 | +#define INPUT_EVENT_PRINTER_H |
730 | + |
731 | +#include <stdio.h> |
732 | + |
733 | +void synEvCodeToStr(char *codeStr, int code) { |
734 | + switch(code) { |
735 | + case SYN_REPORT: |
736 | + sprintf(codeStr, "SYN_REPORT"); |
737 | + break; |
738 | + case SYN_CONFIG: |
739 | + sprintf(codeStr, "SYN_CONFIG"); |
740 | + break; |
741 | + case SYN_MT_REPORT: |
742 | + sprintf(codeStr, "SYN_MT_REPORT"); |
743 | + break; |
744 | + case SYN_DROPPED: |
745 | + sprintf(codeStr, "SYN_DROPPED"); |
746 | + break; |
747 | + default: |
748 | + sprintf(codeStr, "0x%08x", code); |
749 | + break; |
750 | + } |
751 | +} |
752 | + |
753 | +void absEvCodeToStr(char *codeStr, int code) { |
754 | + switch(code) { |
755 | + case ABS_X: |
756 | + sprintf(codeStr, "ABS_X"); |
757 | + break; |
758 | + case ABS_Y: |
759 | + sprintf(codeStr, "ABS_Y"); |
760 | + break; |
761 | + case ABS_MT_TOUCH_MAJOR: |
762 | + sprintf(codeStr, "ABS_MT_TOUCH_MAJOR"); |
763 | + break; |
764 | + case ABS_MT_TOUCH_MINOR: |
765 | + sprintf(codeStr, "ABS_MT_TOUCH_MINOR"); |
766 | + break; |
767 | + case ABS_MT_ORIENTATION: |
768 | + sprintf(codeStr, "ABS_MT_ORIENTATION"); |
769 | + break; |
770 | + case ABS_MT_POSITION_X: |
771 | + sprintf(codeStr, "ABS_MT_POSITION_X"); |
772 | + break; |
773 | + case ABS_MT_POSITION_Y: |
774 | + sprintf(codeStr, "ABS_MT_POSITION_Y"); |
775 | + break; |
776 | + case ABS_MT_TOOL_TYPE: |
777 | + sprintf(codeStr, "ABS_MT_TOOL_TYPE"); |
778 | + break; |
779 | + default: |
780 | + sprintf(codeStr, "0x%08x", code); |
781 | + break; |
782 | + } |
783 | +} |
784 | + |
785 | +void keyEvCodeToStr(char *codeStr, int code) { |
786 | + switch(code) { |
787 | + case BTN_TOUCH: |
788 | + sprintf(codeStr, "BTN_TOUCH"); |
789 | + break; |
790 | + case BTN_STYLUS: |
791 | + sprintf(codeStr, "BTN_STYLUS"); |
792 | + break; |
793 | + default: |
794 | + sprintf(codeStr, "0x%08x", code); |
795 | + break; |
796 | + } |
797 | +} |
798 | + |
799 | +void inputEvToStr(char *buffer, int type, int code, int value) { |
800 | + char codeStr[100]; |
801 | + switch (type) { |
802 | + case EV_SYN: |
803 | + synEvCodeToStr(codeStr, code); |
804 | + sprintf(buffer, "EV_SYN, %s, 0x%08x", codeStr, value); |
805 | + break; |
806 | + case EV_KEY: |
807 | + keyEvCodeToStr(codeStr, code); |
808 | + sprintf(buffer, "EV_KEY, %s, 0x%08x", codeStr, value); |
809 | + break; |
810 | + case EV_REL: |
811 | + sprintf(buffer, "EV_REL, 0x%08x, 0x%08x", code, value); |
812 | + break; |
813 | + case EV_ABS: |
814 | + absEvCodeToStr(codeStr, code); |
815 | + sprintf(buffer, "EV_ABS, %s, 0x%08x", codeStr, value); |
816 | + break; |
817 | + case EV_MSC: |
818 | + sprintf(buffer, "EV_MSC, 0x%08x, 0x%08x", code, value); |
819 | + break; |
820 | + case EV_SW: |
821 | + sprintf(buffer, "EV_SW, 0x%08x, 0x%08x", code, value); |
822 | + break; |
823 | + case EV_LED: |
824 | + sprintf(buffer, "EV_LED, 0x%08x, 0x%08x", code, value); |
825 | + break; |
826 | + case EV_SND: |
827 | + sprintf(buffer, "EV_SND, 0x%08x, 0x%08x", code, value); |
828 | + break; |
829 | + case EV_REP: |
830 | + sprintf(buffer, "EV_REP, 0x%08x, 0x%08x", code, value); |
831 | + break; |
832 | + case EV_FF: |
833 | + sprintf(buffer, "EV_FF, 0x%08x, 0x%08x", code, value); |
834 | + break; |
835 | + case EV_PWR: |
836 | + sprintf(buffer, "EV_PWR, 0x%08x, 0x%08x", code, value); |
837 | + break; |
838 | + case EV_FF_STATUS: |
839 | + sprintf(buffer, "EV_FF_STATUS, 0x%08x, 0x%08x", code, value); |
840 | + break; |
841 | + default: |
842 | + sprintf(buffer, "0x%08x, 0x%08x, 0x%08x", type, code, value); |
843 | + break; |
844 | + } |
845 | +} |
846 | + |
847 | +#endif // INPUT_EVENT_PRINTER_H |
848 | |
849 | === modified file '3rd_party/android-input/android/frameworks/base/services/input/InputReader.cpp' |
850 | --- 3rd_party/android-input/android/frameworks/base/services/input/InputReader.cpp 2013-10-15 08:53:10 +0000 |
851 | +++ 3rd_party/android-input/android/frameworks/base/services/input/InputReader.cpp 2013-11-07 18:01:18 +0000 |
852 | @@ -47,6 +47,8 @@ |
853 | |
854 | #include <android/keycodes.h> |
855 | |
856 | +#include <std/BitSet.h> |
857 | + |
858 | #include <stddef.h> |
859 | #include <stdlib.h> |
860 | #include <unistd.h> |
861 | @@ -54,6 +56,10 @@ |
862 | #include <limits.h> |
863 | #include <math.h> |
864 | |
865 | +#if DEBUG_RAW_EVENTS |
866 | +#include "InputEventPrinter.h" |
867 | +#endif |
868 | + |
869 | #define INDENT " " |
870 | #define INDENT2 " " |
871 | #define INDENT3 " " |
872 | @@ -339,7 +345,7 @@ |
873 | batchSize += 1; |
874 | } |
875 | #if DEBUG_RAW_EVENTS |
876 | - ALOGD("BatchSize: %d Count: %d", batchSize, count); |
877 | + ALOGD("BatchSize: %zu Count: %zu", batchSize, count); |
878 | #endif |
879 | processEventsForDeviceLocked(deviceId, rawEvent, batchSize); |
880 | } else { |
881 | @@ -974,8 +980,9 @@ |
882 | size_t numMappers = mMappers.size(); |
883 | for (const RawEvent* rawEvent = rawEvents; count--; rawEvent++) { |
884 | #if DEBUG_RAW_EVENTS |
885 | - ALOGD("Input event: device=%d type=0x%04x code=0x%04x value=0x%08x", |
886 | - rawEvent->deviceId, rawEvent->type, rawEvent->code, rawEvent->value); |
887 | + char inputStr[200]; |
888 | + inputEvToStr(inputStr, rawEvent->type, rawEvent->code, rawEvent->value); |
889 | + ALOGD("Input event: device=%d %s", rawEvent->deviceId, inputStr); |
890 | #endif |
891 | |
892 | if (mDropUntilNextSync) { |
893 | @@ -1434,32 +1441,31 @@ |
894 | |
895 | void RawPointerData::clear() { |
896 | pointerCount = 0; |
897 | - clearIdBits(); |
898 | + clearIds(); |
899 | } |
900 | |
901 | void RawPointerData::copyFrom(const RawPointerData& other) { |
902 | pointerCount = other.pointerCount; |
903 | - hoveringIdBits = other.hoveringIdBits; |
904 | - touchingIdBits = other.touchingIdBits; |
905 | + hoveringIds = other.hoveringIds; |
906 | + touchingIds = other.touchingIds; |
907 | |
908 | for (uint32_t i = 0; i < pointerCount; i++) { |
909 | pointers[i] = other.pointers[i]; |
910 | |
911 | int id = pointers[i].id; |
912 | - idToIndex[id] = other.idToIndex[id]; |
913 | } |
914 | } |
915 | |
916 | void RawPointerData::getCentroidOfTouchingPointers(float* outX, float* outY) const { |
917 | float x = 0, y = 0; |
918 | - uint32_t count = touchingIdBits.count(); |
919 | + |
920 | + uint32_t count = touchingIds.count(); |
921 | if (count) { |
922 | - for (BitSet32 idBits(touchingIdBits); !idBits.isEmpty(); ) { |
923 | - uint32_t id = idBits.clearFirstMarkedBit(); |
924 | + touchingIds.forEach([&](int32_t id) { |
925 | const Pointer& pointer = pointerForId(id); |
926 | x += pointer.x; |
927 | y += pointer.y; |
928 | - } |
929 | + }); |
930 | x /= count; |
931 | y /= count; |
932 | } |
933 | @@ -1476,21 +1482,18 @@ |
934 | |
935 | void CookedPointerData::clear() { |
936 | pointerCount = 0; |
937 | - hoveringIdBits.clear(); |
938 | - touchingIdBits.clear(); |
939 | + hoveringIds.clear(); |
940 | + touchingIds.clear(); |
941 | } |
942 | |
943 | void CookedPointerData::copyFrom(const CookedPointerData& other) { |
944 | pointerCount = other.pointerCount; |
945 | - hoveringIdBits = other.hoveringIdBits; |
946 | - touchingIdBits = other.touchingIdBits; |
947 | + hoveringIds = other.hoveringIds; |
948 | + touchingIds = other.touchingIds; |
949 | |
950 | for (uint32_t i = 0; i < pointerCount; i++) { |
951 | pointerProperties[i].copyFrom(other.pointerProperties[i]); |
952 | pointerCoords[i].copyFrom(other.pointerCoords[i]); |
953 | - |
954 | - int id = pointerProperties[i].id; |
955 | - idToIndex[id] = other.idToIndex[id]; |
956 | } |
957 | } |
958 | |
959 | @@ -2554,7 +2557,8 @@ |
960 | InputMapper(device), |
961 | mSource(0), mDeviceMode(DEVICE_MODE_DISABLED), |
962 | mSurfaceOrientation(-1), mSurfaceWidth(-1), mSurfaceHeight(-1), |
963 | - mPointerUsage(POINTER_USAGE_NONE) { |
964 | + mPointerUsage(POINTER_USAGE_NONE), |
965 | + mNextNewPointerId(0) { |
966 | } |
967 | |
968 | TouchInputMapper::~TouchInputMapper() { |
969 | @@ -3499,12 +3503,12 @@ |
970 | mLastButtonState = 0; |
971 | mCurrentRawVScroll = 0; |
972 | mCurrentRawHScroll = 0; |
973 | - mCurrentFingerIdBits.clear(); |
974 | - mLastFingerIdBits.clear(); |
975 | - mCurrentStylusIdBits.clear(); |
976 | - mLastStylusIdBits.clear(); |
977 | - mCurrentMouseIdBits.clear(); |
978 | - mLastMouseIdBits.clear(); |
979 | + mCurrentFingerIds.clear(); |
980 | + mLastFingerIds.clear(); |
981 | + mCurrentStylusIds.clear(); |
982 | + mLastStylusIds.clear(); |
983 | + mCurrentMouseIds.clear(); |
984 | + mLastMouseIds.clear(); |
985 | mPointerUsage = POINTER_USAGE_NONE; |
986 | mSentHoverEnter = false; |
987 | mDownTime = 0; |
988 | @@ -3553,21 +3557,25 @@ |
989 | mLastRawPointerData.pointerCount, |
990 | mCurrentRawPointerData.pointerCount); |
991 | } else { |
992 | - ALOGD("syncTouch: pointerCount %d -> %d, touching ids 0x%08x -> 0x%08x, " |
993 | - "hovering ids 0x%08x -> 0x%08x", |
994 | + std::string lastTouchingIdsString = mLastRawPointerData.touchingIds.toString(); |
995 | + std::string currentTouchingIdsString = mCurrentRawPointerData.touchingIds.toString(); |
996 | + std::string lastHoveringIdsString = mLastRawPointerData.hoveringIds.toString(); |
997 | + std::string currentHoveringIdsString = mCurrentRawPointerData.hoveringIds.toString(); |
998 | + ALOGD("syncTouch: pointerCount %u -> %u, touching ids (%s) -> (%s), " |
999 | + "hovering ids (%s) -> (%s)", |
1000 | mLastRawPointerData.pointerCount, |
1001 | mCurrentRawPointerData.pointerCount, |
1002 | - mLastRawPointerData.touchingIdBits.value, |
1003 | - mCurrentRawPointerData.touchingIdBits.value, |
1004 | - mLastRawPointerData.hoveringIdBits.value, |
1005 | - mCurrentRawPointerData.hoveringIdBits.value); |
1006 | + lastTouchingIdsString.c_str(), |
1007 | + currentTouchingIdsString.c_str(), |
1008 | + lastHoveringIdsString.c_str(), |
1009 | + currentHoveringIdsString.c_str()); |
1010 | } |
1011 | #endif |
1012 | |
1013 | // Reset state that we will compute below. |
1014 | - mCurrentFingerIdBits.clear(); |
1015 | - mCurrentStylusIdBits.clear(); |
1016 | - mCurrentMouseIdBits.clear(); |
1017 | + mCurrentFingerIds.clear(); |
1018 | + mCurrentStylusIds.clear(); |
1019 | + mCurrentMouseIds.clear(); |
1020 | mCurrentCookedPointerData.clear(); |
1021 | |
1022 | if (mDeviceMode == DEVICE_MODE_DISABLED) { |
1023 | @@ -3617,38 +3625,36 @@ |
1024 | |
1025 | // Dispatch the touches either directly or by translation through a pointer on screen. |
1026 | if (mDeviceMode == DEVICE_MODE_POINTER) { |
1027 | - for (BitSet32 idBits(mCurrentRawPointerData.touchingIdBits); !idBits.isEmpty(); ) { |
1028 | - uint32_t id = idBits.clearFirstMarkedBit(); |
1029 | - const RawPointerData::Pointer& pointer = mCurrentRawPointerData.pointerForId(id); |
1030 | + for (uint32_t i = 0; i < mCurrentRawPointerData.pointerCount; ++i) { |
1031 | + const RawPointerData::Pointer& pointer = mCurrentRawPointerData.pointers[i]; |
1032 | if (pointer.toolType == AMOTION_EVENT_TOOL_TYPE_STYLUS |
1033 | || pointer.toolType == AMOTION_EVENT_TOOL_TYPE_ERASER) { |
1034 | - mCurrentStylusIdBits.markBit(id); |
1035 | + mCurrentStylusIds.insert(pointer.id); |
1036 | } else if (pointer.toolType == AMOTION_EVENT_TOOL_TYPE_FINGER |
1037 | || pointer.toolType == AMOTION_EVENT_TOOL_TYPE_UNKNOWN) { |
1038 | - mCurrentFingerIdBits.markBit(id); |
1039 | + mCurrentFingerIds.insert(pointer.id); |
1040 | } else if (pointer.toolType == AMOTION_EVENT_TOOL_TYPE_MOUSE) { |
1041 | - mCurrentMouseIdBits.markBit(id); |
1042 | + mCurrentMouseIds.insert(pointer.id); |
1043 | } |
1044 | } |
1045 | - for (BitSet32 idBits(mCurrentRawPointerData.hoveringIdBits); !idBits.isEmpty(); ) { |
1046 | - uint32_t id = idBits.clearFirstMarkedBit(); |
1047 | + mCurrentRawPointerData.hoveringIds.forEach([&](int32_t id) { |
1048 | const RawPointerData::Pointer& pointer = mCurrentRawPointerData.pointerForId(id); |
1049 | if (pointer.toolType == AMOTION_EVENT_TOOL_TYPE_STYLUS |
1050 | || pointer.toolType == AMOTION_EVENT_TOOL_TYPE_ERASER) { |
1051 | - mCurrentStylusIdBits.markBit(id); |
1052 | + mCurrentStylusIds.insert(id); |
1053 | } |
1054 | - } |
1055 | + }); |
1056 | |
1057 | // Stylus takes precedence over all tools, then mouse, then finger. |
1058 | PointerUsage pointerUsage = mPointerUsage; |
1059 | - if (!mCurrentStylusIdBits.isEmpty()) { |
1060 | - mCurrentMouseIdBits.clear(); |
1061 | - mCurrentFingerIdBits.clear(); |
1062 | + if (!mCurrentStylusIds.isEmpty()) { |
1063 | + mCurrentMouseIds.clear(); |
1064 | + mCurrentFingerIds.clear(); |
1065 | pointerUsage = POINTER_USAGE_STYLUS; |
1066 | - } else if (!mCurrentMouseIdBits.isEmpty()) { |
1067 | - mCurrentFingerIdBits.clear(); |
1068 | + } else if (!mCurrentMouseIds.isEmpty()) { |
1069 | + mCurrentFingerIds.clear(); |
1070 | pointerUsage = POINTER_USAGE_MOUSE; |
1071 | - } else if (!mCurrentFingerIdBits.isEmpty() || isPointerDown(mCurrentButtonState)) { |
1072 | + } else if (!mCurrentFingerIds.isEmpty() || isPointerDown(mCurrentButtonState)) { |
1073 | pointerUsage = POINTER_USAGE_GESTURES; |
1074 | } |
1075 | |
1076 | @@ -3661,8 +3667,7 @@ |
1077 | |
1078 | mPointerController->setButtonState(mCurrentButtonState); |
1079 | mPointerController->setSpots(mCurrentCookedPointerData.pointerCoords, |
1080 | - mCurrentCookedPointerData.idToIndex, |
1081 | - mCurrentCookedPointerData.touchingIdBits); |
1082 | + mCurrentCookedPointerData.pointerCount); |
1083 | } |
1084 | |
1085 | dispatchHoverExit(when, policyFlags); |
1086 | @@ -3679,9 +3684,9 @@ |
1087 | mLastRawPointerData.copyFrom(mCurrentRawPointerData); |
1088 | mLastCookedPointerData.copyFrom(mCurrentCookedPointerData); |
1089 | mLastButtonState = mCurrentButtonState; |
1090 | - mLastFingerIdBits = mCurrentFingerIdBits; |
1091 | - mLastStylusIdBits = mCurrentStylusIdBits; |
1092 | - mLastMouseIdBits = mCurrentMouseIdBits; |
1093 | + mLastFingerIds = mCurrentFingerIds; |
1094 | + mLastStylusIds = mCurrentStylusIds; |
1095 | + mLastMouseIds = mCurrentMouseIds; |
1096 | |
1097 | // Clear some transient state. |
1098 | mCurrentRawVScroll = 0; |
1099 | @@ -3699,7 +3704,7 @@ |
1100 | bool TouchInputMapper::consumeRawTouches(nsecs_t when, uint32_t policyFlags) { |
1101 | // Check for release of a virtual key. |
1102 | if (mCurrentVirtualKey.down) { |
1103 | - if (mCurrentRawPointerData.touchingIdBits.isEmpty()) { |
1104 | + if (mCurrentRawPointerData.touchingIds.isEmpty()) { |
1105 | // Pointer went up while virtual key was down. |
1106 | mCurrentVirtualKey.down = false; |
1107 | if (!mCurrentVirtualKey.ignored) { |
1108 | @@ -3714,8 +3719,8 @@ |
1109 | return true; |
1110 | } |
1111 | |
1112 | - if (mCurrentRawPointerData.touchingIdBits.count() == 1) { |
1113 | - uint32_t id = mCurrentRawPointerData.touchingIdBits.firstMarkedBit(); |
1114 | + if (mCurrentRawPointerData.touchingIds.count() == 1) { |
1115 | + int32_t id = mCurrentRawPointerData.touchingIds.first(); |
1116 | const RawPointerData::Pointer& pointer = mCurrentRawPointerData.pointerForId(id); |
1117 | const VirtualKey* virtualKey = findVirtualKeyHit(pointer.x, pointer.y); |
1118 | if (virtualKey && virtualKey->keyCode == mCurrentVirtualKey.keyCode) { |
1119 | @@ -3741,15 +3746,15 @@ |
1120 | } |
1121 | } |
1122 | |
1123 | - if (mLastRawPointerData.touchingIdBits.isEmpty() |
1124 | - && !mCurrentRawPointerData.touchingIdBits.isEmpty()) { |
1125 | + if (mLastRawPointerData.touchingIds.isEmpty() |
1126 | + && !mCurrentRawPointerData.touchingIds.isEmpty()) { |
1127 | // Pointer just went down. Check for virtual key press or off-screen touches. |
1128 | - uint32_t id = mCurrentRawPointerData.touchingIdBits.firstMarkedBit(); |
1129 | + int32_t id = mCurrentRawPointerData.touchingIds.first(); |
1130 | const RawPointerData::Pointer& pointer = mCurrentRawPointerData.pointerForId(id); |
1131 | if (!isPointInsideSurface(pointer.x, pointer.y)) { |
1132 | // If exactly one pointer went down, check for virtual key hit. |
1133 | // Otherwise we will drop the entire stroke. |
1134 | - if (mCurrentRawPointerData.touchingIdBits.count() == 1) { |
1135 | + if (mCurrentRawPointerData.touchingIds.count() == 1) { |
1136 | const VirtualKey* virtualKey = findVirtualKeyHit(pointer.x, pointer.y); |
1137 | if (virtualKey) { |
1138 | mCurrentVirtualKey.down = true; |
1139 | @@ -3789,7 +3794,7 @@ |
1140 | // area and accidentally triggers a virtual key. This often happens when virtual keys |
1141 | // are layed out below the screen near to where the on screen keyboard's space bar |
1142 | // is displayed. |
1143 | - if (mConfig.virtualKeyQuietTime > 0 && !mCurrentRawPointerData.touchingIdBits.isEmpty()) { |
1144 | + if (mConfig.virtualKeyQuietTime > 0 && !mCurrentRawPointerData.touchingIds.isEmpty()) { |
1145 | mContext->disableVirtualKeysUntil(when + mConfig.virtualKeyQuietTime); |
1146 | } |
1147 | return false; |
1148 | @@ -3809,13 +3814,13 @@ |
1149 | } |
1150 | |
1151 | void TouchInputMapper::dispatchTouches(nsecs_t when, uint32_t policyFlags) { |
1152 | - BitSet32 currentIdBits = mCurrentCookedPointerData.touchingIdBits; |
1153 | - BitSet32 lastIdBits = mLastCookedPointerData.touchingIdBits; |
1154 | + IntSet ¤tIds = mCurrentCookedPointerData.touchingIds; |
1155 | + IntSet &lastIds = mLastCookedPointerData.touchingIds; |
1156 | int32_t metaState = getContext()->getGlobalMetaState(); |
1157 | int32_t buttonState = mCurrentButtonState; |
1158 | |
1159 | - if (currentIdBits == lastIdBits) { |
1160 | - if (!currentIdBits.isEmpty()) { |
1161 | + if (currentIds == lastIds) { |
1162 | + if (!currentIds.isEmpty()) { |
1163 | // No pointer id changes so this is a move event. |
1164 | // The listener takes care of batching moves so we don't have to deal with that here. |
1165 | dispatchMotion(when, policyFlags, mSource, |
1166 | @@ -3823,66 +3828,63 @@ |
1167 | AMOTION_EVENT_EDGE_FLAG_NONE, |
1168 | mCurrentCookedPointerData.pointerProperties, |
1169 | mCurrentCookedPointerData.pointerCoords, |
1170 | - mCurrentCookedPointerData.idToIndex, |
1171 | - currentIdBits, -1, |
1172 | + mCurrentCookedPointerData.pointerCount, |
1173 | + currentIds, -1, |
1174 | mOrientedXPrecision, mOrientedYPrecision, mDownTime); |
1175 | } |
1176 | } else { |
1177 | // There may be pointers going up and pointers going down and pointers moving |
1178 | // all at the same time. |
1179 | - BitSet32 upIdBits(lastIdBits.value & ~currentIdBits.value); |
1180 | - BitSet32 downIdBits(currentIdBits.value & ~lastIdBits.value); |
1181 | - BitSet32 moveIdBits(lastIdBits.value & currentIdBits.value); |
1182 | - BitSet32 dispatchedIdBits(lastIdBits.value); |
1183 | + IntSet upIds = lastIds - currentIds; |
1184 | + IntSet downIds = currentIds - lastIds; |
1185 | + IntSet moveIds = lastIds & currentIds; |
1186 | + IntSet dispatchedIds = lastIds; |
1187 | |
1188 | // Update last coordinates of pointers that have moved so that we observe the new |
1189 | // pointer positions at the same time as other pointers that have just gone up. |
1190 | bool moveNeeded = updateMovedPointers( |
1191 | mCurrentCookedPointerData.pointerProperties, |
1192 | mCurrentCookedPointerData.pointerCoords, |
1193 | - mCurrentCookedPointerData.idToIndex, |
1194 | + mCurrentCookedPointerData.pointerCount, |
1195 | mLastCookedPointerData.pointerProperties, |
1196 | mLastCookedPointerData.pointerCoords, |
1197 | - mLastCookedPointerData.idToIndex, |
1198 | - moveIdBits); |
1199 | + mLastCookedPointerData.pointerCount, |
1200 | + moveIds); |
1201 | if (buttonState != mLastButtonState) { |
1202 | moveNeeded = true; |
1203 | } |
1204 | |
1205 | // Dispatch pointer up events. |
1206 | - while (!upIdBits.isEmpty()) { |
1207 | - uint32_t upId = upIdBits.clearFirstMarkedBit(); |
1208 | - |
1209 | + upIds.forEach([&](int32_t upId) { |
1210 | dispatchMotion(when, policyFlags, mSource, |
1211 | AMOTION_EVENT_ACTION_POINTER_UP, 0, metaState, buttonState, 0, |
1212 | mLastCookedPointerData.pointerProperties, |
1213 | mLastCookedPointerData.pointerCoords, |
1214 | - mLastCookedPointerData.idToIndex, |
1215 | - dispatchedIdBits, upId, |
1216 | + mLastCookedPointerData.pointerCount, |
1217 | + dispatchedIds, upId, |
1218 | mOrientedXPrecision, mOrientedYPrecision, mDownTime); |
1219 | - dispatchedIdBits.clearBit(upId); |
1220 | - } |
1221 | + dispatchedIds.remove(upId); |
1222 | + }); |
1223 | |
1224 | // Dispatch move events if any of the remaining pointers moved from their old locations. |
1225 | // Although applications receive new locations as part of individual pointer up |
1226 | // events, they do not generally handle them except when presented in a move event. |
1227 | if (moveNeeded) { |
1228 | - ALOG_ASSERT(moveIdBits.value == dispatchedIdBits.value); |
1229 | + ALOG_ASSERT(moveIds == dispatchedIds); |
1230 | dispatchMotion(when, policyFlags, mSource, |
1231 | AMOTION_EVENT_ACTION_MOVE, 0, metaState, buttonState, 0, |
1232 | mCurrentCookedPointerData.pointerProperties, |
1233 | mCurrentCookedPointerData.pointerCoords, |
1234 | - mCurrentCookedPointerData.idToIndex, |
1235 | - dispatchedIdBits, -1, |
1236 | + mCurrentCookedPointerData.pointerCount, |
1237 | + dispatchedIds, -1, |
1238 | mOrientedXPrecision, mOrientedYPrecision, mDownTime); |
1239 | } |
1240 | |
1241 | // Dispatch pointer down events using the new pointer locations. |
1242 | - while (!downIdBits.isEmpty()) { |
1243 | - uint32_t downId = downIdBits.clearFirstMarkedBit(); |
1244 | - dispatchedIdBits.markBit(downId); |
1245 | + downIds.forEach([&](int32_t downId) { |
1246 | + dispatchedIds.insert(downId); |
1247 | |
1248 | - if (dispatchedIdBits.count() == 1) { |
1249 | + if (dispatchedIds.count() == 1) { |
1250 | // First pointer is going down. Set down time. |
1251 | mDownTime = when; |
1252 | } |
1253 | @@ -3891,40 +3893,40 @@ |
1254 | AMOTION_EVENT_ACTION_POINTER_DOWN, 0, metaState, buttonState, 0, |
1255 | mCurrentCookedPointerData.pointerProperties, |
1256 | mCurrentCookedPointerData.pointerCoords, |
1257 | - mCurrentCookedPointerData.idToIndex, |
1258 | - dispatchedIdBits, downId, |
1259 | + mCurrentCookedPointerData.pointerCount, |
1260 | + dispatchedIds, downId, |
1261 | mOrientedXPrecision, mOrientedYPrecision, mDownTime); |
1262 | - } |
1263 | + }); |
1264 | } |
1265 | } |
1266 | |
1267 | void TouchInputMapper::dispatchHoverExit(nsecs_t when, uint32_t policyFlags) { |
1268 | if (mSentHoverEnter && |
1269 | - (mCurrentCookedPointerData.hoveringIdBits.isEmpty() |
1270 | - || !mCurrentCookedPointerData.touchingIdBits.isEmpty())) { |
1271 | + (mCurrentCookedPointerData.hoveringIds.isEmpty() |
1272 | + || !mCurrentCookedPointerData.touchingIds.isEmpty())) { |
1273 | int32_t metaState = getContext()->getGlobalMetaState(); |
1274 | dispatchMotion(when, policyFlags, mSource, |
1275 | AMOTION_EVENT_ACTION_HOVER_EXIT, 0, metaState, mLastButtonState, 0, |
1276 | mLastCookedPointerData.pointerProperties, |
1277 | mLastCookedPointerData.pointerCoords, |
1278 | - mLastCookedPointerData.idToIndex, |
1279 | - mLastCookedPointerData.hoveringIdBits, -1, |
1280 | + mLastCookedPointerData.pointerCount, |
1281 | + mLastCookedPointerData.hoveringIds, -1, |
1282 | mOrientedXPrecision, mOrientedYPrecision, mDownTime); |
1283 | mSentHoverEnter = false; |
1284 | } |
1285 | } |
1286 | |
1287 | void TouchInputMapper::dispatchHoverEnterAndMove(nsecs_t when, uint32_t policyFlags) { |
1288 | - if (mCurrentCookedPointerData.touchingIdBits.isEmpty() |
1289 | - && !mCurrentCookedPointerData.hoveringIdBits.isEmpty()) { |
1290 | + if (mCurrentCookedPointerData.touchingIds.isEmpty() |
1291 | + && !mCurrentCookedPointerData.hoveringIds.isEmpty()) { |
1292 | int32_t metaState = getContext()->getGlobalMetaState(); |
1293 | if (!mSentHoverEnter) { |
1294 | dispatchMotion(when, policyFlags, mSource, |
1295 | AMOTION_EVENT_ACTION_HOVER_ENTER, 0, metaState, mCurrentButtonState, 0, |
1296 | mCurrentCookedPointerData.pointerProperties, |
1297 | mCurrentCookedPointerData.pointerCoords, |
1298 | - mCurrentCookedPointerData.idToIndex, |
1299 | - mCurrentCookedPointerData.hoveringIdBits, -1, |
1300 | + mCurrentCookedPointerData.pointerCount, |
1301 | + mCurrentCookedPointerData.hoveringIds, -1, |
1302 | mOrientedXPrecision, mOrientedYPrecision, mDownTime); |
1303 | mSentHoverEnter = true; |
1304 | } |
1305 | @@ -3933,8 +3935,8 @@ |
1306 | AMOTION_EVENT_ACTION_HOVER_MOVE, 0, metaState, mCurrentButtonState, 0, |
1307 | mCurrentCookedPointerData.pointerProperties, |
1308 | mCurrentCookedPointerData.pointerCoords, |
1309 | - mCurrentCookedPointerData.idToIndex, |
1310 | - mCurrentCookedPointerData.hoveringIdBits, -1, |
1311 | + mCurrentCookedPointerData.pointerCount, |
1312 | + mCurrentCookedPointerData.hoveringIds, -1, |
1313 | mOrientedXPrecision, mOrientedYPrecision, mDownTime); |
1314 | } |
1315 | } |
1316 | @@ -3944,8 +3946,8 @@ |
1317 | |
1318 | mCurrentCookedPointerData.clear(); |
1319 | mCurrentCookedPointerData.pointerCount = currentPointerCount; |
1320 | - mCurrentCookedPointerData.hoveringIdBits = mCurrentRawPointerData.hoveringIdBits; |
1321 | - mCurrentCookedPointerData.touchingIdBits = mCurrentRawPointerData.touchingIdBits; |
1322 | + mCurrentCookedPointerData.hoveringIds = mCurrentRawPointerData.hoveringIds; |
1323 | + mCurrentCookedPointerData.touchingIds = mCurrentRawPointerData.touchingIds; |
1324 | |
1325 | // Walk through the the active pointers and map device coordinates onto |
1326 | // surface coordinates and adjust for display orientation. |
1327 | @@ -3988,7 +3990,7 @@ |
1328 | } |
1329 | |
1330 | if (mCalibration.haveSizeIsSummed && mCalibration.sizeIsSummed) { |
1331 | - uint32_t touchingCount = mCurrentRawPointerData.touchingIdBits.count(); |
1332 | + uint32_t touchingCount = mCurrentRawPointerData.touchingIds.count(); |
1333 | if (touchingCount > 1) { |
1334 | touchMajor /= touchingCount; |
1335 | touchMinor /= touchingCount; |
1336 | @@ -4137,9 +4139,6 @@ |
1337 | properties.clear(); |
1338 | properties.id = id; |
1339 | properties.toolType = in.toolType; |
1340 | - |
1341 | - // Write id index. |
1342 | - mCurrentCookedPointerData.idToIndex[id] = i; |
1343 | } |
1344 | } |
1345 | |
1346 | @@ -4203,8 +4202,7 @@ |
1347 | mPointerController->clearSpots(); |
1348 | } |
1349 | mPointerController->setSpots(mPointerGesture.currentGestureCoords, |
1350 | - mPointerGesture.currentGestureIdToIndex, |
1351 | - mPointerGesture.currentGestureIdBits); |
1352 | + mPointerGesture.currentGestureIds.count()); |
1353 | } else { |
1354 | mPointerController->setPresentation(PointerControllerInterface::PRESENTATION_POINTER); |
1355 | } |
1356 | @@ -4255,54 +4253,52 @@ |
1357 | || mPointerGesture.currentGestureMode == PointerGesture::FREEFORM; |
1358 | bool moveNeeded = false; |
1359 | if (down && !cancelPreviousGesture && !finishPreviousGesture |
1360 | - && !mPointerGesture.lastGestureIdBits.isEmpty() |
1361 | - && !mPointerGesture.currentGestureIdBits.isEmpty()) { |
1362 | - BitSet32 movedGestureIdBits(mPointerGesture.currentGestureIdBits.value |
1363 | - & mPointerGesture.lastGestureIdBits.value); |
1364 | + && !(mPointerGesture.lastGestureIds.isEmpty()) |
1365 | + && !(mPointerGesture.currentGestureIds.isEmpty())) { |
1366 | + IntSet movedGestureIds = mPointerGesture.currentGestureIds & mPointerGesture.lastGestureIds; |
1367 | moveNeeded = updateMovedPointers(mPointerGesture.currentGestureProperties, |
1368 | - mPointerGesture.currentGestureCoords, mPointerGesture.currentGestureIdToIndex, |
1369 | + mPointerGesture.currentGestureCoords, mPointerGesture.currentGestureIds.count(), |
1370 | mPointerGesture.lastGestureProperties, |
1371 | - mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIdToIndex, |
1372 | - movedGestureIdBits); |
1373 | + mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIds.count(), |
1374 | + movedGestureIds); |
1375 | if (buttonState != mLastButtonState) { |
1376 | moveNeeded = true; |
1377 | } |
1378 | } |
1379 | |
1380 | // Send motion events for all pointers that went up or were canceled. |
1381 | - BitSet32 dispatchedGestureIdBits(mPointerGesture.lastGestureIdBits); |
1382 | - if (!dispatchedGestureIdBits.isEmpty()) { |
1383 | + IntSet dispatchedGestureIds = mPointerGesture.lastGestureIds; |
1384 | + if (!dispatchedGestureIds.isEmpty()) { |
1385 | if (cancelPreviousGesture) { |
1386 | dispatchMotion(when, policyFlags, mSource, |
1387 | AMOTION_EVENT_ACTION_CANCEL, 0, metaState, buttonState, |
1388 | AMOTION_EVENT_EDGE_FLAG_NONE, |
1389 | mPointerGesture.lastGestureProperties, |
1390 | - mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIdToIndex, |
1391 | - dispatchedGestureIdBits, -1, |
1392 | + mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIds.count(), |
1393 | + dispatchedGestureIds, -1, |
1394 | 0, 0, mPointerGesture.downTime); |
1395 | |
1396 | - dispatchedGestureIdBits.clear(); |
1397 | + dispatchedGestureIds.clear(); |
1398 | } else { |
1399 | - BitSet32 upGestureIdBits; |
1400 | + IntSet upGestureIds; |
1401 | if (finishPreviousGesture) { |
1402 | - upGestureIdBits = dispatchedGestureIdBits; |
1403 | + upGestureIds = dispatchedGestureIds; |
1404 | } else { |
1405 | - upGestureIdBits.value = dispatchedGestureIdBits.value |
1406 | - & ~mPointerGesture.currentGestureIdBits.value; |
1407 | + upGestureIds = dispatchedGestureIds - mPointerGesture.currentGestureIds; |
1408 | } |
1409 | - while (!upGestureIdBits.isEmpty()) { |
1410 | - uint32_t id = upGestureIdBits.clearFirstMarkedBit(); |
1411 | + |
1412 | + upGestureIds.forEach([&](int32_t upId) { |
1413 | |
1414 | dispatchMotion(when, policyFlags, mSource, |
1415 | AMOTION_EVENT_ACTION_POINTER_UP, 0, |
1416 | metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE, |
1417 | mPointerGesture.lastGestureProperties, |
1418 | - mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIdToIndex, |
1419 | - dispatchedGestureIdBits, id, |
1420 | + mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIds.count(), |
1421 | + dispatchedGestureIds, upId, |
1422 | 0, 0, mPointerGesture.downTime); |
1423 | |
1424 | - dispatchedGestureIdBits.clearBit(id); |
1425 | - } |
1426 | + dispatchedGestureIds.remove(upId); |
1427 | + }); |
1428 | } |
1429 | } |
1430 | |
1431 | @@ -4311,30 +4307,29 @@ |
1432 | dispatchMotion(when, policyFlags, mSource, |
1433 | AMOTION_EVENT_ACTION_MOVE, 0, metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE, |
1434 | mPointerGesture.currentGestureProperties, |
1435 | - mPointerGesture.currentGestureCoords, mPointerGesture.currentGestureIdToIndex, |
1436 | - dispatchedGestureIdBits, -1, |
1437 | + mPointerGesture.currentGestureCoords, mPointerGesture.currentGestureIds.count(), |
1438 | + dispatchedGestureIds, -1, |
1439 | 0, 0, mPointerGesture.downTime); |
1440 | } |
1441 | |
1442 | // Send motion events for all pointers that went down. |
1443 | if (down) { |
1444 | - BitSet32 downGestureIdBits(mPointerGesture.currentGestureIdBits.value |
1445 | - & ~dispatchedGestureIdBits.value); |
1446 | - while (!downGestureIdBits.isEmpty()) { |
1447 | - uint32_t id = downGestureIdBits.clearFirstMarkedBit(); |
1448 | - dispatchedGestureIdBits.markBit(id); |
1449 | - |
1450 | - if (dispatchedGestureIdBits.count() == 1) { |
1451 | + IntSet downGestureIds = mPointerGesture.currentGestureIds - dispatchedGestureIds; |
1452 | + |
1453 | + downGestureIds.forEach([&](int32_t downId) { |
1454 | + dispatchedGestureIds.insert(downId); |
1455 | + |
1456 | + if (dispatchedGestureIds.size() == 1) { |
1457 | mPointerGesture.downTime = when; |
1458 | } |
1459 | |
1460 | dispatchMotion(when, policyFlags, mSource, |
1461 | AMOTION_EVENT_ACTION_POINTER_DOWN, 0, metaState, buttonState, 0, |
1462 | mPointerGesture.currentGestureProperties, |
1463 | - mPointerGesture.currentGestureCoords, mPointerGesture.currentGestureIdToIndex, |
1464 | - dispatchedGestureIdBits, id, |
1465 | + mPointerGesture.currentGestureCoords, mPointerGesture.currentGestureIds.count(), |
1466 | + dispatchedGestureIds, downId, |
1467 | 0, 0, mPointerGesture.downTime); |
1468 | - } |
1469 | + }); |
1470 | } |
1471 | |
1472 | // Send motion events for hover. |
1473 | @@ -4343,11 +4338,11 @@ |
1474 | AMOTION_EVENT_ACTION_HOVER_MOVE, 0, |
1475 | metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE, |
1476 | mPointerGesture.currentGestureProperties, |
1477 | - mPointerGesture.currentGestureCoords, mPointerGesture.currentGestureIdToIndex, |
1478 | - mPointerGesture.currentGestureIdBits, -1, |
1479 | + mPointerGesture.currentGestureCoords, |
1480 | + mPointerGesture.currentGestureIds.count(), -1, |
1481 | 0, 0, mPointerGesture.downTime); |
1482 | - } else if (dispatchedGestureIdBits.isEmpty() |
1483 | - && !mPointerGesture.lastGestureIdBits.isEmpty()) { |
1484 | + } else if (dispatchedGestureIds.isEmpty() |
1485 | + && !mPointerGesture.lastGestureIds.isEmpty()) { |
1486 | // Synthesize a hover move event after all pointers go up to indicate that |
1487 | // the pointer is hovering again even if the user is not currently touching |
1488 | // the touch pad. This ensures that a view will receive a fresh hover enter |
1489 | @@ -4375,32 +4370,29 @@ |
1490 | // Update state. |
1491 | mPointerGesture.lastGestureMode = mPointerGesture.currentGestureMode; |
1492 | if (!down) { |
1493 | - mPointerGesture.lastGestureIdBits.clear(); |
1494 | + mPointerGesture.lastGestureIds.clear(); |
1495 | } else { |
1496 | - mPointerGesture.lastGestureIdBits = mPointerGesture.currentGestureIdBits; |
1497 | - for (BitSet32 idBits(mPointerGesture.currentGestureIdBits); !idBits.isEmpty(); ) { |
1498 | - uint32_t id = idBits.clearFirstMarkedBit(); |
1499 | - uint32_t index = mPointerGesture.currentGestureIdToIndex[id]; |
1500 | + mPointerGesture.lastGestureIds = mPointerGesture.currentGestureIds; |
1501 | + mPointerGesture.lastGestureIdToIndex = mPointerGesture.currentGestureIdToIndex; |
1502 | + for (uint32_t index = 0; index < mPointerGesture.currentGestureIds.count(); ++index) { |
1503 | mPointerGesture.lastGestureProperties[index].copyFrom( |
1504 | mPointerGesture.currentGestureProperties[index]); |
1505 | mPointerGesture.lastGestureCoords[index].copyFrom( |
1506 | mPointerGesture.currentGestureCoords[index]); |
1507 | - mPointerGesture.lastGestureIdToIndex[id] = index; |
1508 | } |
1509 | } |
1510 | } |
1511 | |
1512 | void TouchInputMapper::abortPointerGestures(nsecs_t when, uint32_t policyFlags) { |
1513 | // Cancel previously dispatches pointers. |
1514 | - if (!mPointerGesture.lastGestureIdBits.isEmpty()) { |
1515 | + if (!mPointerGesture.lastGestureIds.isEmpty()) { |
1516 | int32_t metaState = getContext()->getGlobalMetaState(); |
1517 | int32_t buttonState = mCurrentButtonState; |
1518 | dispatchMotion(when, policyFlags, mSource, |
1519 | AMOTION_EVENT_ACTION_CANCEL, 0, metaState, buttonState, |
1520 | AMOTION_EVENT_EDGE_FLAG_NONE, |
1521 | mPointerGesture.lastGestureProperties, |
1522 | - mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIdToIndex, |
1523 | - mPointerGesture.lastGestureIdBits, -1, |
1524 | + mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIds.count(), -1, |
1525 | 0, 0, mPointerGesture.downTime); |
1526 | } |
1527 | |
1528 | @@ -4440,7 +4432,7 @@ |
1529 | |
1530 | mPointerGesture.activeGestureId = -1; |
1531 | mPointerGesture.currentGestureMode = PointerGesture::NEUTRAL; |
1532 | - mPointerGesture.currentGestureIdBits.clear(); |
1533 | + mPointerGesture.currentGestureIds.clear(); |
1534 | |
1535 | mPointerVelocityControl.reset(); |
1536 | return true; |
1537 | @@ -4451,21 +4443,20 @@ |
1538 | return false; |
1539 | } |
1540 | |
1541 | - const uint32_t currentFingerCount = mCurrentFingerIdBits.count(); |
1542 | - const uint32_t lastFingerCount = mLastFingerIdBits.count(); |
1543 | + const uint32_t currentFingerCount = mCurrentFingerIds.size(); |
1544 | + const uint32_t lastFingerCount = mLastFingerIds.size(); |
1545 | |
1546 | // Update the velocity tracker. |
1547 | { |
1548 | VelocityTracker::Position positions[MAX_POINTERS]; |
1549 | uint32_t count = 0; |
1550 | - for (BitSet32 idBits(mCurrentFingerIdBits); !idBits.isEmpty(); count++) { |
1551 | - uint32_t id = idBits.clearFirstMarkedBit(); |
1552 | + mCurrentFingerIds.forEach([&](int32_t id) { |
1553 | const RawPointerData::Pointer& pointer = mCurrentRawPointerData.pointerForId(id); |
1554 | positions[count].x = pointer.x * mPointerXMovementScale; |
1555 | positions[count].y = pointer.y * mPointerYMovementScale; |
1556 | - } |
1557 | - mPointerGesture.velocityTracker.addMovement(when, |
1558 | - mCurrentFingerIdBits, positions); |
1559 | + count++; |
1560 | + }); |
1561 | + mPointerGesture.velocityTracker.addMovement(when, mCurrentFingerIds, positions); |
1562 | } |
1563 | |
1564 | // Pick a new active touch id if needed. |
1565 | @@ -4477,17 +4468,17 @@ |
1566 | int32_t lastActiveTouchId = mPointerGesture.activeTouchId; |
1567 | int32_t activeTouchId = lastActiveTouchId; |
1568 | if (activeTouchId < 0) { |
1569 | - if (!mCurrentFingerIdBits.isEmpty()) { |
1570 | + if (!mCurrentFingerIds.isEmpty()) { |
1571 | activeTouchChanged = true; |
1572 | activeTouchId = mPointerGesture.activeTouchId = |
1573 | - mCurrentFingerIdBits.firstMarkedBit(); |
1574 | + mCurrentFingerIds.first(); |
1575 | mPointerGesture.firstTouchTime = when; |
1576 | } |
1577 | - } else if (!mCurrentFingerIdBits.hasBit(activeTouchId)) { |
1578 | + } else if (!mCurrentFingerIds.contains(activeTouchId)) { |
1579 | activeTouchChanged = true; |
1580 | - if (!mCurrentFingerIdBits.isEmpty()) { |
1581 | + if (!mCurrentFingerIds.isEmpty()) { |
1582 | activeTouchId = mPointerGesture.activeTouchId = |
1583 | - mCurrentFingerIdBits.firstMarkedBit(); |
1584 | + mCurrentFingerIds.first(); |
1585 | } else { |
1586 | activeTouchId = mPointerGesture.activeTouchId = -1; |
1587 | } |
1588 | @@ -4535,7 +4526,7 @@ |
1589 | |
1590 | mPointerGesture.activeGestureId = -1; |
1591 | mPointerGesture.currentGestureMode = PointerGesture::QUIET; |
1592 | - mPointerGesture.currentGestureIdBits.clear(); |
1593 | + mPointerGesture.currentGestureIds.clear(); |
1594 | |
1595 | mPointerVelocityControl.reset(); |
1596 | } else if (isPointerDown(mCurrentButtonState)) { |
1597 | @@ -4567,8 +4558,7 @@ |
1598 | if (activeTouchId >= 0 && currentFingerCount > 1) { |
1599 | int32_t bestId = -1; |
1600 | float bestSpeed = mConfig.pointerGestureDragMinSwitchSpeed; |
1601 | - for (BitSet32 idBits(mCurrentFingerIdBits); !idBits.isEmpty(); ) { |
1602 | - uint32_t id = idBits.clearFirstMarkedBit(); |
1603 | + mCurrentFingerIds.forEach([&](int32_t id) { |
1604 | float vx, vy; |
1605 | if (mPointerGesture.velocityTracker.getVelocity(id, &vx, &vy)) { |
1606 | float speed = hypotf(vx, vy); |
1607 | @@ -4577,7 +4567,7 @@ |
1608 | bestSpeed = speed; |
1609 | } |
1610 | } |
1611 | - } |
1612 | + }); |
1613 | if (bestId >= 0 && bestId != activeTouchId) { |
1614 | mPointerGesture.activeTouchId = activeTouchId = bestId; |
1615 | activeTouchChanged = true; |
1616 | @@ -4588,7 +4578,7 @@ |
1617 | } |
1618 | } |
1619 | |
1620 | - if (activeTouchId >= 0 && mLastFingerIdBits.hasBit(activeTouchId)) { |
1621 | + if (activeTouchId >= 0 && mLastFingerIds.contains(activeTouchId)) { |
1622 | const RawPointerData::Pointer& currentPointer = |
1623 | mCurrentRawPointerData.pointerForId(activeTouchId); |
1624 | const RawPointerData::Pointer& lastPointer = |
1625 | @@ -4611,9 +4601,8 @@ |
1626 | mPointerController->getPosition(&x, &y); |
1627 | |
1628 | mPointerGesture.currentGestureMode = PointerGesture::BUTTON_CLICK_OR_DRAG; |
1629 | - mPointerGesture.currentGestureIdBits.clear(); |
1630 | - mPointerGesture.currentGestureIdBits.markBit(mPointerGesture.activeGestureId); |
1631 | - mPointerGesture.currentGestureIdToIndex[mPointerGesture.activeGestureId] = 0; |
1632 | + mPointerGesture.currentGestureIds.clear(); |
1633 | + mPointerGesture.currentGestureIds.insert(mPointerGesture.activeGestureId); |
1634 | mPointerGesture.currentGestureProperties[0].clear(); |
1635 | mPointerGesture.currentGestureProperties[0].id = mPointerGesture.activeGestureId; |
1636 | mPointerGesture.currentGestureProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER; |
1637 | @@ -4648,11 +4637,9 @@ |
1638 | |
1639 | mPointerGesture.activeGestureId = 0; |
1640 | mPointerGesture.currentGestureMode = PointerGesture::TAP; |
1641 | - mPointerGesture.currentGestureIdBits.clear(); |
1642 | - mPointerGesture.currentGestureIdBits.markBit( |
1643 | + mPointerGesture.currentGestureIds.clear(); |
1644 | + mPointerGesture.currentGestureIds.insert( |
1645 | mPointerGesture.activeGestureId); |
1646 | - mPointerGesture.currentGestureIdToIndex[ |
1647 | - mPointerGesture.activeGestureId] = 0; |
1648 | mPointerGesture.currentGestureProperties[0].clear(); |
1649 | mPointerGesture.currentGestureProperties[0].id = |
1650 | mPointerGesture.activeGestureId; |
1651 | @@ -4690,7 +4677,7 @@ |
1652 | #endif |
1653 | mPointerGesture.activeGestureId = -1; |
1654 | mPointerGesture.currentGestureMode = PointerGesture::NEUTRAL; |
1655 | - mPointerGesture.currentGestureIdBits.clear(); |
1656 | + mPointerGesture.currentGestureIds.clear(); |
1657 | } |
1658 | } else if (currentFingerCount == 1) { |
1659 | // Case 4. Exactly one finger down, button is not pressed. (HOVER or TAP_DRAG) |
1660 | @@ -4724,7 +4711,7 @@ |
1661 | mPointerGesture.currentGestureMode = PointerGesture::TAP_DRAG; |
1662 | } |
1663 | |
1664 | - if (mLastFingerIdBits.hasBit(activeTouchId)) { |
1665 | + if (mLastFingerIds.contains(activeTouchId)) { |
1666 | const RawPointerData::Pointer& currentPointer = |
1667 | mCurrentRawPointerData.pointerForId(activeTouchId); |
1668 | const RawPointerData::Pointer& lastPointer = |
1669 | @@ -4764,9 +4751,8 @@ |
1670 | float x, y; |
1671 | mPointerController->getPosition(&x, &y); |
1672 | |
1673 | - mPointerGesture.currentGestureIdBits.clear(); |
1674 | - mPointerGesture.currentGestureIdBits.markBit(mPointerGesture.activeGestureId); |
1675 | - mPointerGesture.currentGestureIdToIndex[mPointerGesture.activeGestureId] = 0; |
1676 | + mPointerGesture.currentGestureIds.clear(); |
1677 | + mPointerGesture.currentGestureIds.insert(mPointerGesture.activeGestureId); |
1678 | mPointerGesture.currentGestureProperties[0].clear(); |
1679 | mPointerGesture.currentGestureProperties[0].id = mPointerGesture.activeGestureId; |
1680 | mPointerGesture.currentGestureProperties[0].toolType = |
1681 | @@ -4823,7 +4809,7 @@ |
1682 | if (*outFinishPreviousGesture || *outCancelPreviousGesture) { |
1683 | mPointerGesture.currentGestureMode = PointerGesture::PRESS; |
1684 | mPointerGesture.activeGestureId = 0; |
1685 | - mPointerGesture.referenceIdBits.clear(); |
1686 | + mPointerGesture.referenceIds.clear(); |
1687 | mPointerVelocityControl.reset(); |
1688 | |
1689 | // Use the centroid and pointer location as the reference points for the gesture. |
1690 | @@ -4841,21 +4827,18 @@ |
1691 | } |
1692 | |
1693 | // Clear the reference deltas for fingers not yet included in the reference calculation. |
1694 | - for (BitSet32 idBits(mCurrentFingerIdBits.value |
1695 | - & ~mPointerGesture.referenceIdBits.value); !idBits.isEmpty(); ) { |
1696 | - uint32_t id = idBits.clearFirstMarkedBit(); |
1697 | + (mCurrentFingerIds - mPointerGesture.referenceIds).forEach([&](int32_t id) { |
1698 | mPointerGesture.referenceDeltas[id].dx = 0; |
1699 | mPointerGesture.referenceDeltas[id].dy = 0; |
1700 | - } |
1701 | - mPointerGesture.referenceIdBits = mCurrentFingerIdBits; |
1702 | + }); |
1703 | + mPointerGesture.referenceIds = mCurrentFingerIds; |
1704 | |
1705 | // Add delta for all fingers and calculate a common movement delta. |
1706 | float commonDeltaX = 0, commonDeltaY = 0; |
1707 | - BitSet32 commonIdBits(mLastFingerIdBits.value |
1708 | - & mCurrentFingerIdBits.value); |
1709 | - for (BitSet32 idBits(commonIdBits); !idBits.isEmpty(); ) { |
1710 | - bool first = (idBits == commonIdBits); |
1711 | - uint32_t id = idBits.clearFirstMarkedBit(); |
1712 | + IntSet commonIds = mLastFingerIds & mCurrentFingerIds; |
1713 | + |
1714 | + bool first = true; |
1715 | + commonIds.forEach([&](int32_t id) { |
1716 | const RawPointerData::Pointer& cpd = mCurrentRawPointerData.pointerForId(id); |
1717 | const RawPointerData::Pointer& lpd = mLastRawPointerData.pointerForId(id); |
1718 | PointerGesture::Delta& delta = mPointerGesture.referenceDeltas[id]; |
1719 | @@ -4865,25 +4848,25 @@ |
1720 | if (first) { |
1721 | commonDeltaX = delta.dx; |
1722 | commonDeltaY = delta.dy; |
1723 | + first = false; |
1724 | } else { |
1725 | commonDeltaX = calculateCommonVector(commonDeltaX, delta.dx); |
1726 | commonDeltaY = calculateCommonVector(commonDeltaY, delta.dy); |
1727 | } |
1728 | - } |
1729 | + }); |
1730 | |
1731 | // Consider transitions from PRESS to SWIPE or MULTITOUCH. |
1732 | if (mPointerGesture.currentGestureMode == PointerGesture::PRESS) { |
1733 | - float dist[MAX_POINTER_ID + 1]; |
1734 | + std::unordered_map<int32_t, float> dist; |
1735 | int32_t distOverThreshold = 0; |
1736 | - for (BitSet32 idBits(mPointerGesture.referenceIdBits); !idBits.isEmpty(); ) { |
1737 | - uint32_t id = idBits.clearFirstMarkedBit(); |
1738 | + mPointerGesture.referenceIds.forEach([&](int32_t id) { |
1739 | PointerGesture::Delta& delta = mPointerGesture.referenceDeltas[id]; |
1740 | dist[id] = hypotf(delta.dx * mPointerXZoomScale, |
1741 | delta.dy * mPointerYZoomScale); |
1742 | if (dist[id] > mConfig.pointerGestureMultitouchMinDistance) { |
1743 | distOverThreshold += 1; |
1744 | } |
1745 | - } |
1746 | + }); |
1747 | |
1748 | // Only transition when at least two pointers have moved further than |
1749 | // the minimum distance threshold. |
1750 | @@ -4898,9 +4881,14 @@ |
1751 | mPointerGesture.currentGestureMode = PointerGesture::FREEFORM; |
1752 | } else { |
1753 | // There are exactly two pointers. |
1754 | - BitSet32 idBits(mCurrentFingerIdBits); |
1755 | - uint32_t id1 = idBits.clearFirstMarkedBit(); |
1756 | - uint32_t id2 = idBits.firstMarkedBit(); |
1757 | + int32_t id1; |
1758 | + int32_t id2; |
1759 | + { |
1760 | + auto currentFingerIdsIt = mCurrentFingerIds.cbegin(); |
1761 | + id1 = *currentFingerIdsIt; |
1762 | + ++currentFingerIdsIt; |
1763 | + id2 = *currentFingerIdsIt; |
1764 | + } |
1765 | const RawPointerData::Pointer& p1 = mCurrentRawPointerData.pointerForId(id1); |
1766 | const RawPointerData::Pointer& p2 = mCurrentRawPointerData.pointerForId(id2); |
1767 | float mutualDistance = distance(p1.x, p1.y, p2.x, p2.y); |
1768 | @@ -4977,12 +4965,11 @@ |
1769 | // except in PRESS mode while waiting for a transition to occur. |
1770 | if (mPointerGesture.currentGestureMode != PointerGesture::PRESS |
1771 | && (commonDeltaX || commonDeltaY)) { |
1772 | - for (BitSet32 idBits(mPointerGesture.referenceIdBits); !idBits.isEmpty(); ) { |
1773 | - uint32_t id = idBits.clearFirstMarkedBit(); |
1774 | + mPointerGesture.referenceIds.forEach([&](int32_t id) { |
1775 | PointerGesture::Delta& delta = mPointerGesture.referenceDeltas[id]; |
1776 | delta.dx = 0; |
1777 | delta.dy = 0; |
1778 | - } |
1779 | + }); |
1780 | |
1781 | mPointerGesture.referenceTouchX += commonDeltaX; |
1782 | mPointerGesture.referenceTouchY += commonDeltaY; |
1783 | @@ -5008,9 +4995,8 @@ |
1784 | #endif |
1785 | ALOG_ASSERT(mPointerGesture.activeGestureId >= 0); |
1786 | |
1787 | - mPointerGesture.currentGestureIdBits.clear(); |
1788 | - mPointerGesture.currentGestureIdBits.markBit(mPointerGesture.activeGestureId); |
1789 | - mPointerGesture.currentGestureIdToIndex[mPointerGesture.activeGestureId] = 0; |
1790 | + mPointerGesture.currentGestureIds.clear(); |
1791 | + mPointerGesture.currentGestureIds.insert(mPointerGesture.activeGestureId); |
1792 | mPointerGesture.currentGestureProperties[0].clear(); |
1793 | mPointerGesture.currentGestureProperties[0].id = mPointerGesture.activeGestureId; |
1794 | mPointerGesture.currentGestureProperties[0].toolType = |
1795 | @@ -5030,16 +5016,16 @@ |
1796 | #endif |
1797 | ALOG_ASSERT(mPointerGesture.activeGestureId >= 0); |
1798 | |
1799 | - mPointerGesture.currentGestureIdBits.clear(); |
1800 | + mPointerGesture.currentGestureIds.clear(); |
1801 | |
1802 | - BitSet32 mappedTouchIdBits; |
1803 | - BitSet32 usedGestureIdBits; |
1804 | + IntSet mappedTouchIds; |
1805 | + IntSet usedGestureIds; |
1806 | if (mPointerGesture.lastGestureMode != PointerGesture::FREEFORM) { |
1807 | // Initially, assign the active gesture id to the active touch point |
1808 | // if there is one. No other touch id bits are mapped yet. |
1809 | if (!*outCancelPreviousGesture) { |
1810 | - mappedTouchIdBits.markBit(activeTouchId); |
1811 | - usedGestureIdBits.markBit(mPointerGesture.activeGestureId); |
1812 | + mappedTouchIds.insert(activeTouchId); |
1813 | + usedGestureIds.insert(mPointerGesture.activeGestureId); |
1814 | mPointerGesture.freeformTouchToGestureIdMap[activeTouchId] = |
1815 | mPointerGesture.activeGestureId; |
1816 | } else { |
1817 | @@ -5048,38 +5034,41 @@ |
1818 | } else { |
1819 | // Otherwise, assume we mapped all touches from the previous frame. |
1820 | // Reuse all mappings that are still applicable. |
1821 | - mappedTouchIdBits.value = mLastFingerIdBits.value |
1822 | - & mCurrentFingerIdBits.value; |
1823 | - usedGestureIdBits = mPointerGesture.lastGestureIdBits; |
1824 | + mappedTouchIds = mLastFingerIds & mCurrentFingerIds; |
1825 | + usedGestureIds = mPointerGesture.lastGestureIds; |
1826 | |
1827 | // Check whether we need to choose a new active gesture id because the |
1828 | // current went went up. |
1829 | - for (BitSet32 upTouchIdBits(mLastFingerIdBits.value |
1830 | - & ~mCurrentFingerIdBits.value); |
1831 | - !upTouchIdBits.isEmpty(); ) { |
1832 | - uint32_t upTouchId = upTouchIdBits.clearFirstMarkedBit(); |
1833 | - uint32_t upGestureId = mPointerGesture.freeformTouchToGestureIdMap[upTouchId]; |
1834 | - if (upGestureId == uint32_t(mPointerGesture.activeGestureId)) { |
1835 | - mPointerGesture.activeGestureId = -1; |
1836 | - break; |
1837 | + auto it = mLastFingerIds.cbegin(); |
1838 | + while (it != mLastFingerIds.cend()) { |
1839 | + int32_t id = *it; |
1840 | + if (!mCurrentFingerIds.contains(id)) { |
1841 | + int32_t upGestureId = mPointerGesture.freeformTouchToGestureIdMap[id]; |
1842 | + if (upGestureId == mPointerGesture.activeGestureId) { |
1843 | + mPointerGesture.activeGestureId = -1; |
1844 | + break; |
1845 | + } |
1846 | } |
1847 | + it++; |
1848 | } |
1849 | } |
1850 | |
1851 | #if DEBUG_GESTURES |
1852 | - ALOGD("Gestures: FREEFORM follow up " |
1853 | - "mappedTouchIdBits=0x%08x, usedGestureIdBits=0x%08x, " |
1854 | - "activeGestureId=%d", |
1855 | - mappedTouchIdBits.value, usedGestureIdBits.value, |
1856 | - mPointerGesture.activeGestureId); |
1857 | + { |
1858 | + std::string mappedTouchIdsString = mappedTouchIdBits.toString(); |
1859 | + std::string usedGestureIdsString = usedGestureIdBits.toString(); |
1860 | + ALOGD("Gestures: FREEFORM follow up " |
1861 | + "mappedTouchIds=%s, usedGestureIds=%s, " |
1862 | + "activeGestureId=%d", |
1863 | + mappedTouchIdsString.c_str(), usedGestureIdsString.c_str(), |
1864 | + mPointerGesture.activeGestureId); |
1865 | + } |
1866 | #endif |
1867 | - |
1868 | - BitSet32 idBits(mCurrentFingerIdBits); |
1869 | - for (uint32_t i = 0; i < currentFingerCount; i++) { |
1870 | - uint32_t touchId = idBits.clearFirstMarkedBit(); |
1871 | - uint32_t gestureId; |
1872 | - if (!mappedTouchIdBits.hasBit(touchId)) { |
1873 | - gestureId = usedGestureIdBits.markFirstUnmarkedBit(); |
1874 | + uint32_t i = 0; |
1875 | + mCurrentFingerIds.forEach([&](int32_t touchId) { |
1876 | + int32_t gestureId; |
1877 | + if (mappedTouchIds.contains(touchId)) { |
1878 | + gestureId = usedGestureIds.first(); |
1879 | mPointerGesture.freeformTouchToGestureIdMap[touchId] = gestureId; |
1880 | #if DEBUG_GESTURES |
1881 | ALOGD("Gestures: FREEFORM " |
1882 | @@ -5094,8 +5083,7 @@ |
1883 | touchId, gestureId); |
1884 | #endif |
1885 | } |
1886 | - mPointerGesture.currentGestureIdBits.markBit(gestureId); |
1887 | - mPointerGesture.currentGestureIdToIndex[gestureId] = i; |
1888 | + mPointerGesture.currentGestureIds.insert(gestureId); |
1889 | |
1890 | const RawPointerData::Pointer& pointer = |
1891 | mCurrentRawPointerData.pointerForId(touchId); |
1892 | @@ -5116,11 +5104,12 @@ |
1893 | AMOTION_EVENT_AXIS_Y, mPointerGesture.referenceGestureY + deltaY); |
1894 | mPointerGesture.currentGestureCoords[i].setAxisValue( |
1895 | AMOTION_EVENT_AXIS_PRESSURE, 1.0f); |
1896 | - } |
1897 | + |
1898 | + ++i; |
1899 | + }); |
1900 | |
1901 | if (mPointerGesture.activeGestureId < 0) { |
1902 | - mPointerGesture.activeGestureId = |
1903 | - mPointerGesture.currentGestureIdBits.firstMarkedBit(); |
1904 | + mPointerGesture.activeGestureId = mPointerGesture.currentGestureIds.first(); |
1905 | #if DEBUG_GESTURES |
1906 | ALOGD("Gestures: FREEFORM new " |
1907 | "activeGestureId=%d", mPointerGesture.activeGestureId); |
1908 | @@ -5132,35 +5121,35 @@ |
1909 | mPointerController->setButtonState(mCurrentButtonState); |
1910 | |
1911 | #if DEBUG_GESTURES |
1912 | - ALOGD("Gestures: finishPreviousGesture=%s, cancelPreviousGesture=%s, " |
1913 | - "currentGestureMode=%d, currentGestureIdBits=0x%08x, " |
1914 | - "lastGestureMode=%d, lastGestureIdBits=0x%08x", |
1915 | - toString(*outFinishPreviousGesture), toString(*outCancelPreviousGesture), |
1916 | - mPointerGesture.currentGestureMode, mPointerGesture.currentGestureIdBits.value, |
1917 | - mPointerGesture.lastGestureMode, mPointerGesture.lastGestureIdBits.value); |
1918 | - for (BitSet32 idBits = mPointerGesture.currentGestureIdBits; !idBits.isEmpty(); ) { |
1919 | - uint32_t id = idBits.clearFirstMarkedBit(); |
1920 | - uint32_t index = mPointerGesture.currentGestureIdToIndex[id]; |
1921 | - const PointerProperties& properties = mPointerGesture.currentGestureProperties[index]; |
1922 | - const PointerCoords& coords = mPointerGesture.currentGestureCoords[index]; |
1923 | - ALOGD(" currentGesture[%d]: index=%d, toolType=%d, " |
1924 | - "x=%0.3f, y=%0.3f, pressure=%0.3f", |
1925 | - id, index, properties.toolType, |
1926 | - coords.getAxisValue(AMOTION_EVENT_AXIS_X), |
1927 | - coords.getAxisValue(AMOTION_EVENT_AXIS_Y), |
1928 | - coords.getAxisValue(AMOTION_EVENT_AXIS_PRESSURE)); |
1929 | - } |
1930 | - for (BitSet32 idBits = mPointerGesture.lastGestureIdBits; !idBits.isEmpty(); ) { |
1931 | - uint32_t id = idBits.clearFirstMarkedBit(); |
1932 | - uint32_t index = mPointerGesture.lastGestureIdToIndex[id]; |
1933 | - const PointerProperties& properties = mPointerGesture.lastGestureProperties[index]; |
1934 | - const PointerCoords& coords = mPointerGesture.lastGestureCoords[index]; |
1935 | - ALOGD(" lastGesture[%d]: index=%d, toolType=%d, " |
1936 | - "x=%0.3f, y=%0.3f, pressure=%0.3f", |
1937 | - id, index, properties.toolType, |
1938 | - coords.getAxisValue(AMOTION_EVENT_AXIS_X), |
1939 | - coords.getAxisValue(AMOTION_EVENT_AXIS_Y), |
1940 | - coords.getAxisValue(AMOTION_EVENT_AXIS_PRESSURE)); |
1941 | + { |
1942 | + std::string lastGestureIdsString = mPointerGesture.lastGestureIds.toString(); |
1943 | + |
1944 | + ALOGD("Gestures: finishPreviousGesture=%s, cancelPreviousGesture=%s, " |
1945 | + "currentGestureMode=%d, currentGestureIds.count()=%u, " |
1946 | + "lastGestureMode=%d, lastGestureIds=%s", |
1947 | + toString(*outFinishPreviousGesture), toString(*outCancelPreviousGesture), |
1948 | + mPointerGesture.currentGestureMode, mPointerGesture.currentGestureIds.count(), |
1949 | + mPointerGesture.lastGestureMode, lastGestureIdsString.c_str()); |
1950 | + for (uint32_t index = 0; index < mPointerGesture.currentGestureIds.count(); ++index) { |
1951 | + const PointerProperties& properties = mPointerGesture.currentGestureProperties[index]; |
1952 | + const PointerCoords& coords = mPointerGesture.currentGestureCoords[index]; |
1953 | + ALOGD(" currentGesture[%d]: index=%d, toolType=%d, " |
1954 | + "x=%0.3f, y=%0.3f, pressure=%0.3f", |
1955 | + id, index, properties.toolType, |
1956 | + coords.getAxisValue(AMOTION_EVENT_AXIS_X), |
1957 | + coords.getAxisValue(AMOTION_EVENT_AXIS_Y), |
1958 | + coords.getAxisValue(AMOTION_EVENT_AXIS_PRESSURE)); |
1959 | + } |
1960 | + for (uint32_t index = 0; index < mPointerGesture.lastGestureIds.count(); ++index) { |
1961 | + const PointerProperties& properties = mPointerGesture.lastGestureProperties[index]; |
1962 | + const PointerCoords& coords = mPointerGesture.lastGestureCoords[index]; |
1963 | + ALOGD(" lastGesture[%d]: index=%d, toolType=%d, " |
1964 | + "x=%0.3f, y=%0.3f, pressure=%0.3f", |
1965 | + id, index, properties.toolType, |
1966 | + coords.getAxisValue(AMOTION_EVENT_AXIS_X), |
1967 | + coords.getAxisValue(AMOTION_EVENT_AXIS_Y), |
1968 | + coords.getAxisValue(AMOTION_EVENT_AXIS_PRESSURE)); |
1969 | + } |
1970 | } |
1971 | #endif |
1972 | return true; |
1973 | @@ -5171,14 +5160,14 @@ |
1974 | mPointerSimple.currentProperties.clear(); |
1975 | |
1976 | bool down, hovering; |
1977 | - if (!mCurrentStylusIdBits.isEmpty()) { |
1978 | - uint32_t id = mCurrentStylusIdBits.firstMarkedBit(); |
1979 | - uint32_t index = mCurrentCookedPointerData.idToIndex[id]; |
1980 | + if (!mCurrentStylusIds.isEmpty()) { |
1981 | + int32_t id = mCurrentStylusIds.first(); |
1982 | + uint32_t index = mCurrentCookedPointerData.idToIndex(id); |
1983 | float x = mCurrentCookedPointerData.pointerCoords[index].getX(); |
1984 | float y = mCurrentCookedPointerData.pointerCoords[index].getY(); |
1985 | mPointerController->setPosition(x, y); |
1986 | |
1987 | - hovering = mCurrentCookedPointerData.hoveringIdBits.hasBit(id); |
1988 | + hovering = mCurrentCookedPointerData.hoveringIds.contains(id); |
1989 | down = !hovering; |
1990 | |
1991 | mPointerController->getPosition(&x, &y); |
1992 | @@ -5205,11 +5194,11 @@ |
1993 | mPointerSimple.currentProperties.clear(); |
1994 | |
1995 | bool down, hovering; |
1996 | - if (!mCurrentMouseIdBits.isEmpty()) { |
1997 | - uint32_t id = mCurrentMouseIdBits.firstMarkedBit(); |
1998 | - uint32_t currentIndex = mCurrentRawPointerData.idToIndex[id]; |
1999 | - if (mLastMouseIdBits.hasBit(id)) { |
2000 | - uint32_t lastIndex = mCurrentRawPointerData.idToIndex[id]; |
2001 | + if (!mCurrentMouseIds.isEmpty()) { |
2002 | + uint32_t id = mCurrentMouseIds.first(); |
2003 | + uint32_t currentIndex = mCurrentRawPointerData.idToIndex(id); |
2004 | + if (mLastMouseIds.contains(id)) { |
2005 | + uint32_t lastIndex = mCurrentRawPointerData.idToIndex(id); |
2006 | float deltaX = (mCurrentRawPointerData.pointers[currentIndex].x |
2007 | - mLastRawPointerData.pointers[lastIndex].x) |
2008 | * mPointerXMovementScale; |
2009 | @@ -5377,19 +5366,17 @@ |
2010 | |
2011 | void TouchInputMapper::dispatchMotion(nsecs_t when, uint32_t policyFlags, uint32_t source, |
2012 | int32_t action, int32_t flags, int32_t metaState, int32_t buttonState, int32_t edgeFlags, |
2013 | - const PointerProperties* properties, const PointerCoords* coords, |
2014 | - const uint32_t* idToIndex, BitSet32 idBits, |
2015 | + const PointerProperties* properties, const PointerCoords* coords, uint32_t inPointerCount, |
2016 | int32_t changedId, float xPrecision, float yPrecision, nsecs_t downTime) { |
2017 | PointerCoords pointerCoords[MAX_POINTERS]; |
2018 | PointerProperties pointerProperties[MAX_POINTERS]; |
2019 | uint32_t pointerCount = 0; |
2020 | - while (!idBits.isEmpty()) { |
2021 | - uint32_t id = idBits.clearFirstMarkedBit(); |
2022 | - uint32_t index = idToIndex[id]; |
2023 | - pointerProperties[pointerCount].copyFrom(properties[index]); |
2024 | - pointerCoords[pointerCount].copyFrom(coords[index]); |
2025 | - |
2026 | - if (changedId >= 0 && id == uint32_t(changedId)) { |
2027 | + |
2028 | + while (pointerCount < inPointerCount) { |
2029 | + pointerProperties[pointerCount].copyFrom(properties[pointerCount]); |
2030 | + pointerCoords[pointerCount].copyFrom(coords[pointerCount]); |
2031 | + |
2032 | + if (changedId >= 0 && properties[pointerCount].id == uint32_t(changedId)) { |
2033 | action |= pointerCount << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; |
2034 | } |
2035 | |
2036 | @@ -5418,31 +5405,94 @@ |
2037 | getListener()->notifyMotion(&args); |
2038 | } |
2039 | |
2040 | +void TouchInputMapper::dispatchMotion(nsecs_t when, uint32_t policyFlags, uint32_t source, |
2041 | + int32_t action, int32_t flags, int32_t metaState, int32_t buttonState, int32_t edgeFlags, |
2042 | + const PointerProperties* properties, const PointerCoords* coords, |
2043 | + uint32_t inPointerCount, const IntSet &idsToDispatch, |
2044 | + int32_t changedId, float xPrecision, float yPrecision, nsecs_t downTime) { |
2045 | + PointerCoords pointerCoords[MAX_POINTERS]; |
2046 | + PointerProperties pointerProperties[MAX_POINTERS]; |
2047 | + uint32_t pointerCount = 0; |
2048 | + |
2049 | + for (uint32_t i = 0; i < inPointerCount && pointerCount < idsToDispatch.size(); ++i) { |
2050 | + if (!idsToDispatch.contains(properties[i].id)) |
2051 | + continue; |
2052 | + |
2053 | + pointerProperties[pointerCount].copyFrom(properties[i]); |
2054 | + pointerCoords[pointerCount].copyFrom(coords[i]); |
2055 | + |
2056 | + if (changedId >= 0 && properties[i].id == uint32_t(changedId)) { |
2057 | + action |= i << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; |
2058 | + } |
2059 | + |
2060 | + pointerCount += 1; |
2061 | + } |
2062 | + |
2063 | + ALOG_ASSERT(pointerCount != 0); |
2064 | + |
2065 | + if (changedId >= 0 && pointerCount == 1) { |
2066 | + // Remove the poiter index part |
2067 | + int actionPart = action & AMOTION_EVENT_ACTION_MASK; |
2068 | + |
2069 | + // Replace initial down and final up action. |
2070 | + // We can compare the action without masking off the changed pointer index |
2071 | + // because we know the index is 0. |
2072 | + if (actionPart == AMOTION_EVENT_ACTION_POINTER_DOWN) { |
2073 | + actionPart = AMOTION_EVENT_ACTION_DOWN; |
2074 | + } else if (actionPart & AMOTION_EVENT_ACTION_POINTER_UP) { |
2075 | + actionPart = AMOTION_EVENT_ACTION_UP; |
2076 | + } else { |
2077 | + // Can't happen. |
2078 | + ALOG_ASSERT(false); |
2079 | + } |
2080 | + |
2081 | + // And put it back into the action integer |
2082 | + action = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) | actionPart; |
2083 | + } |
2084 | + |
2085 | + NotifyMotionArgs args(when, getDeviceId(), source, policyFlags, |
2086 | + action, flags, metaState, buttonState, edgeFlags, |
2087 | + pointerCount, pointerProperties, pointerCoords, xPrecision, yPrecision, downTime); |
2088 | + getListener()->notifyMotion(&args); |
2089 | +} |
2090 | + |
2091 | bool TouchInputMapper::updateMovedPointers(const PointerProperties* inProperties, |
2092 | - const PointerCoords* inCoords, const uint32_t* inIdToIndex, |
2093 | - PointerProperties* outProperties, PointerCoords* outCoords, const uint32_t* outIdToIndex, |
2094 | - BitSet32 idBits) const { |
2095 | + const PointerCoords* inCoords, uint32_t inPointerCount, |
2096 | + PointerProperties* outProperties, PointerCoords* outCoords, uint32_t outPointerCount, |
2097 | + const IntSet &commonTouchingIds) const { |
2098 | bool changed = false; |
2099 | - while (!idBits.isEmpty()) { |
2100 | - uint32_t id = idBits.clearFirstMarkedBit(); |
2101 | - uint32_t inIndex = inIdToIndex[id]; |
2102 | - uint32_t outIndex = outIdToIndex[id]; |
2103 | - |
2104 | - const PointerProperties& curInProperties = inProperties[inIndex]; |
2105 | - const PointerCoords& curInCoords = inCoords[inIndex]; |
2106 | - PointerProperties& curOutProperties = outProperties[outIndex]; |
2107 | - PointerCoords& curOutCoords = outCoords[outIndex]; |
2108 | - |
2109 | - if (curInProperties != curOutProperties) { |
2110 | - curOutProperties.copyFrom(curInProperties); |
2111 | - changed = true; |
2112 | - } |
2113 | - |
2114 | - if (curInCoords != curOutCoords) { |
2115 | - curOutCoords.copyFrom(curInCoords); |
2116 | - changed = true; |
2117 | - } |
2118 | - } |
2119 | + |
2120 | + if (commonTouchingIds.isEmpty()) { |
2121 | + return changed; |
2122 | + } |
2123 | + |
2124 | + for (uint32_t inIndex = 0; inIndex < inPointerCount; ++inIndex) { |
2125 | + int32_t inId = inProperties[inIndex].id; |
2126 | + if (!commonTouchingIds.contains(inId)) { |
2127 | + continue; |
2128 | + } |
2129 | + for (uint32_t outIndex = 0; outIndex < outPointerCount; ++outIndex) { |
2130 | + int32_t outId = outProperties[outIndex].id; |
2131 | + if (inId == outId) { |
2132 | + // The pointer is present in both sets. Let's see if it has moved. |
2133 | + const PointerProperties& curInProperties = inProperties[inIndex]; |
2134 | + const PointerCoords& curInCoords = inCoords[inIndex]; |
2135 | + PointerProperties& curOutProperties = outProperties[outIndex]; |
2136 | + PointerCoords& curOutCoords = outCoords[outIndex]; |
2137 | + |
2138 | + if (curInProperties != curOutProperties) { |
2139 | + curOutProperties.copyFrom(curInProperties); |
2140 | + changed = true; |
2141 | + } |
2142 | + |
2143 | + if (curInCoords != curOutCoords) { |
2144 | + curOutCoords.copyFrom(curInCoords); |
2145 | + changed = true; |
2146 | + } |
2147 | + } |
2148 | + } |
2149 | + } |
2150 | + |
2151 | return changed; |
2152 | } |
2153 | |
2154 | @@ -5484,7 +5534,7 @@ |
2155 | uint32_t currentPointerCount = mCurrentRawPointerData.pointerCount; |
2156 | uint32_t lastPointerCount = mLastRawPointerData.pointerCount; |
2157 | |
2158 | - mCurrentRawPointerData.clearIdBits(); |
2159 | + mCurrentRawPointerData.clearIds(); |
2160 | |
2161 | if (currentPointerCount == 0) { |
2162 | // No pointers to assign. |
2163 | @@ -5494,10 +5544,9 @@ |
2164 | if (lastPointerCount == 0) { |
2165 | // All pointers are new. |
2166 | for (uint32_t i = 0; i < currentPointerCount; i++) { |
2167 | - uint32_t id = i; |
2168 | + int32_t id = fetchNewPointerId(); |
2169 | mCurrentRawPointerData.pointers[i].id = id; |
2170 | - mCurrentRawPointerData.idToIndex[id] = i; |
2171 | - mCurrentRawPointerData.markIdBit(id, mCurrentRawPointerData.isHovering(i)); |
2172 | + mCurrentRawPointerData.insertId(id, mCurrentRawPointerData.isHovering(i)); |
2173 | } |
2174 | return; |
2175 | } |
2176 | @@ -5506,10 +5555,9 @@ |
2177 | && mCurrentRawPointerData.pointers[0].toolType |
2178 | == mLastRawPointerData.pointers[0].toolType) { |
2179 | // Only one pointer and no change in count so it must have the same id as before. |
2180 | - uint32_t id = mLastRawPointerData.pointers[0].id; |
2181 | + int32_t id = mLastRawPointerData.pointers[0].id; |
2182 | mCurrentRawPointerData.pointers[0].id = id; |
2183 | - mCurrentRawPointerData.idToIndex[id] = 0; |
2184 | - mCurrentRawPointerData.markIdBit(id, mCurrentRawPointerData.isHovering(0)); |
2185 | + mCurrentRawPointerData.insertId(id, mCurrentRawPointerData.isHovering(0)); |
2186 | return; |
2187 | } |
2188 | |
2189 | @@ -5569,9 +5617,9 @@ |
2190 | } |
2191 | |
2192 | #if DEBUG_POINTER_ASSIGNMENT |
2193 | - ALOGD("assignPointerIds - initial distance min-heap: size=%d", heapSize); |
2194 | + ALOGD("assignPointerIds - initial distance min-heap: size=%u", heapSize); |
2195 | for (size_t i = 0; i < heapSize; i++) { |
2196 | - ALOGD(" heap[%d]: cur=%d, last=%d, distance=%lld", |
2197 | + ALOGD(" heap[%d]: cur=%u, last=%u, distance=%llu", |
2198 | i, heap[i].currentPointerIndex, heap[i].lastPointerIndex, |
2199 | heap[i].distance); |
2200 | } |
2201 | @@ -5580,10 +5628,8 @@ |
2202 | // Pull matches out by increasing order of distance. |
2203 | // To avoid reassigning pointers that have already been matched, the loop keeps track |
2204 | // of which last and current pointers have been matched using the matchedXXXBits variables. |
2205 | - // It also tracks the used pointer id bits. |
2206 | BitSet32 matchedLastBits(0); |
2207 | BitSet32 matchedCurrentBits(0); |
2208 | - BitSet32 usedIdBits(0); |
2209 | bool first = true; |
2210 | for (uint32_t i = min(currentPointerCount, lastPointerCount); heapSize > 0 && i > 0; i--) { |
2211 | while (heapSize > 0) { |
2212 | @@ -5635,12 +5681,9 @@ |
2213 | matchedCurrentBits.markBit(currentPointerIndex); |
2214 | matchedLastBits.markBit(lastPointerIndex); |
2215 | |
2216 | - uint32_t id = mLastRawPointerData.pointers[lastPointerIndex].id; |
2217 | + int32_t id = mLastRawPointerData.pointers[lastPointerIndex].id; |
2218 | mCurrentRawPointerData.pointers[currentPointerIndex].id = id; |
2219 | - mCurrentRawPointerData.idToIndex[id] = currentPointerIndex; |
2220 | - mCurrentRawPointerData.markIdBit(id, |
2221 | - mCurrentRawPointerData.isHovering(currentPointerIndex)); |
2222 | - usedIdBits.markBit(id); |
2223 | + mCurrentRawPointerData.insertId(id, mCurrentRawPointerData.isHovering(currentPointerIndex)); |
2224 | |
2225 | #if DEBUG_POINTER_ASSIGNMENT |
2226 | ALOGD("assignPointerIds - matched: cur=%d, last=%d, id=%d, distance=%lld", |
2227 | @@ -5653,11 +5696,10 @@ |
2228 | // Assign fresh ids to pointers that were not matched in the process. |
2229 | for (uint32_t i = currentPointerCount - matchedCurrentBits.count(); i != 0; i--) { |
2230 | uint32_t currentPointerIndex = matchedCurrentBits.markFirstUnmarkedBit(); |
2231 | - uint32_t id = usedIdBits.markFirstUnmarkedBit(); |
2232 | + int32_t id = fetchNewPointerId(); |
2233 | |
2234 | mCurrentRawPointerData.pointers[currentPointerIndex].id = id; |
2235 | - mCurrentRawPointerData.idToIndex[id] = currentPointerIndex; |
2236 | - mCurrentRawPointerData.markIdBit(id, |
2237 | + mCurrentRawPointerData.insertId(id, |
2238 | mCurrentRawPointerData.isHovering(currentPointerIndex)); |
2239 | |
2240 | #if DEBUG_POINTER_ASSIGNMENT |
2241 | @@ -5667,6 +5709,14 @@ |
2242 | } |
2243 | } |
2244 | |
2245 | +int32_t TouchInputMapper::fetchNewPointerId() { |
2246 | + int32_t id = mNextNewPointerId++; |
2247 | + if (mNextNewPointerId > MAX_POINTER_ID) { |
2248 | + mNextNewPointerId = 0; |
2249 | + } |
2250 | + return id; |
2251 | +} |
2252 | + |
2253 | int32_t TouchInputMapper::getKeyCodeState(uint32_t sourceMask, int32_t keyCode) { |
2254 | if (mCurrentVirtualKey.down && mCurrentVirtualKey.keyCode == keyCode) { |
2255 | return AKEY_STATE_VIRTUAL; |
2256 | @@ -5740,16 +5790,21 @@ |
2257 | void SingleTouchInputMapper::syncTouch(nsecs_t when, bool* outHavePointerIds) { |
2258 | if (mTouchButtonAccumulator.isToolActive()) { |
2259 | mCurrentRawPointerData.pointerCount = 1; |
2260 | - mCurrentRawPointerData.idToIndex[0] = 0; |
2261 | |
2262 | bool isHovering = mTouchButtonAccumulator.getToolType() != AMOTION_EVENT_TOOL_TYPE_MOUSE |
2263 | && (mTouchButtonAccumulator.isHovering() |
2264 | || (mRawPointerAxes.pressure.valid |
2265 | && mSingleTouchMotionAccumulator.getAbsolutePressure() <= 0)); |
2266 | - mCurrentRawPointerData.markIdBit(0, isHovering); |
2267 | |
2268 | RawPointerData::Pointer& outPointer = mCurrentRawPointerData.pointers[0]; |
2269 | - outPointer.id = 0; |
2270 | + |
2271 | + if (mLastRawPointerData.pointerCount == 1) { |
2272 | + outPointer.id = mLastRawPointerData.pointers[0].id; |
2273 | + mCurrentRawPointerData.insertId(outPointer.id, isHovering); |
2274 | + } else { |
2275 | + outPointer.id = -1; |
2276 | + *outHavePointerIds = false; |
2277 | + } |
2278 | outPointer.x = mSingleTouchMotionAccumulator.getAbsoluteX(); |
2279 | outPointer.y = mSingleTouchMotionAccumulator.getAbsoluteY(); |
2280 | outPointer.pressure = mSingleTouchMotionAccumulator.getAbsolutePressure(); |
2281 | @@ -5766,6 +5821,7 @@ |
2282 | outPointer.toolType = AMOTION_EVENT_TOOL_TYPE_FINGER; |
2283 | } |
2284 | outPointer.isHovering = isHovering; |
2285 | + |
2286 | } |
2287 | } |
2288 | |
2289 | @@ -5798,7 +5854,7 @@ |
2290 | void MultiTouchInputMapper::reset(nsecs_t when) { |
2291 | mMultiTouchMotionAccumulator.reset(getDevice()); |
2292 | |
2293 | - mPointerIdBits.clear(); |
2294 | + mPointerIds.clear(); |
2295 | |
2296 | TouchInputMapper::reset(when); |
2297 | } |
2298 | @@ -5812,7 +5868,7 @@ |
2299 | void MultiTouchInputMapper::syncTouch(nsecs_t when, bool* outHavePointerIds) { |
2300 | size_t inCount = mMultiTouchMotionAccumulator.getSlotCount(); |
2301 | size_t outCount = 0; |
2302 | - BitSet32 newPointerIdBits; |
2303 | + IntSet newPointerIds; |
2304 | |
2305 | for (size_t inIndex = 0; inIndex < inCount; inIndex++) { |
2306 | const MultiTouchMotionAccumulator::Slot* inSlot = |
2307 | @@ -5861,27 +5917,26 @@ |
2308 | int32_t trackingId = inSlot->getTrackingId(); |
2309 | int32_t id = -1; |
2310 | if (trackingId >= 0) { |
2311 | - for (BitSet32 idBits(mPointerIdBits); !idBits.isEmpty(); ) { |
2312 | - uint32_t n = idBits.clearFirstMarkedBit(); |
2313 | + mPointerIds.forEach([&](int32_t n) { |
2314 | if (mPointerTrackingIdMap[n] == trackingId) { |
2315 | id = n; |
2316 | } |
2317 | - } |
2318 | + }); |
2319 | |
2320 | - if (id < 0 && !mPointerIdBits.isFull()) { |
2321 | - id = mPointerIdBits.markFirstUnmarkedBit(); |
2322 | + if (id < 0) { |
2323 | + id = fetchNewPointerId(); |
2324 | + mPointerIds.insert(id); |
2325 | mPointerTrackingIdMap[id] = trackingId; |
2326 | } |
2327 | } |
2328 | if (id < 0) { |
2329 | *outHavePointerIds = false; |
2330 | - mCurrentRawPointerData.clearIdBits(); |
2331 | - newPointerIdBits.clear(); |
2332 | + mCurrentRawPointerData.clearIds(); |
2333 | + newPointerIds.clear(); |
2334 | } else { |
2335 | outPointer.id = id; |
2336 | - mCurrentRawPointerData.idToIndex[id] = outCount; |
2337 | - mCurrentRawPointerData.markIdBit(id, isHovering); |
2338 | - newPointerIdBits.markBit(id); |
2339 | + mCurrentRawPointerData.insertId(id, isHovering); |
2340 | + newPointerIds.insert(id); |
2341 | } |
2342 | } |
2343 | |
2344 | @@ -5889,7 +5944,7 @@ |
2345 | } |
2346 | |
2347 | mCurrentRawPointerData.pointerCount = outCount; |
2348 | - mPointerIdBits = newPointerIdBits; |
2349 | + mPointerIds = newPointerIds; |
2350 | |
2351 | mMultiTouchMotionAccumulator.finishSync(); |
2352 | } |
2353 | @@ -5914,8 +5969,8 @@ |
2354 | && mRawPointerAxes.slot.minValue == 0 && mRawPointerAxes.slot.maxValue > 0) { |
2355 | size_t slotCount = mRawPointerAxes.slot.maxValue + 1; |
2356 | if (slotCount > MAX_SLOTS) { |
2357 | - ALOGW("MultiTouch Device %s reported %d slots but the framework " |
2358 | - "only supports a maximum of %d slots at this time.", |
2359 | + ALOGW("MultiTouch Device %s reported %lu slots but the framework " |
2360 | + "only supports a maximum of %lu slots at this time.", |
2361 | c_str(getDeviceName()), slotCount, MAX_SLOTS); |
2362 | slotCount = MAX_SLOTS; |
2363 | } |
2364 | @@ -6057,7 +6112,7 @@ |
2365 | // If there are too many axes, start dropping them. |
2366 | // Prefer to keep explicitly mapped axes. |
2367 | if (mAxes.size() > PointerCoords::MAX_AXES) { |
2368 | - ALOGI("Joystick '%s' has %d axes but the framework only supports a maximum of %d.", |
2369 | + ALOGI("Joystick '%s' has %lu axes but the framework only supports a maximum of %d.", |
2370 | c_str(getDeviceName()), mAxes.size(), PointerCoords::MAX_AXES); |
2371 | pruneAxes(true); |
2372 | pruneAxes(false); |
2373 | |
2374 | === modified file '3rd_party/android-input/android/frameworks/base/services/input/InputReader.h' |
2375 | --- 3rd_party/android-input/android/frameworks/base/services/input/InputReader.h 2013-09-20 12:18:12 +0000 |
2376 | +++ 3rd_party/android-input/android/frameworks/base/services/input/InputReader.h 2013-11-07 18:01:18 +0000 |
2377 | @@ -22,6 +22,7 @@ |
2378 | #include "InputListener.h" |
2379 | |
2380 | #include <androidfw/Input.h> |
2381 | +#include <androidfw/IntSet.h> |
2382 | #include <androidfw/VelocityControl.h> |
2383 | #include <androidfw/VelocityTracker.h> |
2384 | #include <std/KeyedVector.h> |
2385 | @@ -30,12 +31,14 @@ |
2386 | #include <std/Timers.h> |
2387 | #include <std/RefBase.h> |
2388 | #include <std/String8.h> |
2389 | -#include <std/BitSet.h> |
2390 | |
2391 | #include <limits.h> |
2392 | #include <stddef.h> |
2393 | #include <unistd.h> |
2394 | |
2395 | +// C++ std lib |
2396 | +#include <unordered_map> |
2397 | + |
2398 | // Maximum supported size of a vibration pattern. |
2399 | // Must be at least 2. |
2400 | #define MAX_VIBRATE_PATTERN_SIZE 100 |
2401 | @@ -678,7 +681,7 @@ |
2402 | /* Raw data for a collection of pointers including a pointer id mapping table. */ |
2403 | struct RawPointerData { |
2404 | struct Pointer { |
2405 | - uint32_t id; |
2406 | + int32_t id; |
2407 | int32_t x; |
2408 | int32_t y; |
2409 | int32_t pressure; |
2410 | @@ -696,29 +699,40 @@ |
2411 | |
2412 | uint32_t pointerCount; |
2413 | Pointer pointers[MAX_POINTERS]; |
2414 | - BitSet32 hoveringIdBits, touchingIdBits; |
2415 | - uint32_t idToIndex[MAX_POINTER_ID + 1]; |
2416 | + IntSet hoveringIds, touchingIds; |
2417 | + |
2418 | + uint32_t idToIndex(int32_t id) const { |
2419 | + uint32_t i = 0; |
2420 | + |
2421 | + while (pointers[i].id != id && i < pointerCount) { |
2422 | + ++i; |
2423 | + } |
2424 | + |
2425 | + assert(pointers[i].id == id); |
2426 | + return i; |
2427 | + } |
2428 | + |
2429 | |
2430 | RawPointerData(); |
2431 | void clear(); |
2432 | void copyFrom(const RawPointerData& other); |
2433 | void getCentroidOfTouchingPointers(float* outX, float* outY) const; |
2434 | |
2435 | - inline void markIdBit(uint32_t id, bool isHovering) { |
2436 | + inline void insertId(int32_t id, bool isHovering) { |
2437 | if (isHovering) { |
2438 | - hoveringIdBits.markBit(id); |
2439 | + hoveringIds.insert(id); |
2440 | } else { |
2441 | - touchingIdBits.markBit(id); |
2442 | + touchingIds.insert(id); |
2443 | } |
2444 | } |
2445 | |
2446 | - inline void clearIdBits() { |
2447 | - hoveringIdBits.clear(); |
2448 | - touchingIdBits.clear(); |
2449 | + inline void clearIds() { |
2450 | + hoveringIds.clear(); |
2451 | + touchingIds.clear(); |
2452 | } |
2453 | |
2454 | - inline const Pointer& pointerForId(uint32_t id) const { |
2455 | - return pointers[idToIndex[id]]; |
2456 | + inline const Pointer& pointerForId(int32_t id) const { |
2457 | + return pointers[idToIndex(id)]; |
2458 | } |
2459 | |
2460 | inline bool isHovering(uint32_t pointerIndex) { |
2461 | @@ -732,15 +746,22 @@ |
2462 | uint32_t pointerCount; |
2463 | PointerProperties pointerProperties[MAX_POINTERS]; |
2464 | PointerCoords pointerCoords[MAX_POINTERS]; |
2465 | - BitSet32 hoveringIdBits, touchingIdBits; |
2466 | - uint32_t idToIndex[MAX_POINTER_ID + 1]; |
2467 | + IntSet hoveringIds, touchingIds; |
2468 | + uint32_t idToIndex(int32_t id) const { |
2469 | + uint32_t i = 0; |
2470 | + |
2471 | + while (pointerProperties[i].id != id && i < pointerCount) { ++i; } |
2472 | + |
2473 | + assert(pointerProperties[i].id == id); |
2474 | + return i; |
2475 | + } |
2476 | |
2477 | CookedPointerData(); |
2478 | void clear(); |
2479 | void copyFrom(const CookedPointerData& other); |
2480 | |
2481 | inline bool isHovering(uint32_t pointerIndex) { |
2482 | - return hoveringIdBits.hasBit(pointerProperties[pointerIndex].id); |
2483 | + return hoveringIds.contains(pointerProperties[pointerIndex].id); |
2484 | } |
2485 | }; |
2486 | |
2487 | @@ -1233,13 +1254,13 @@ |
2488 | int32_t mCurrentRawVScroll; |
2489 | int32_t mCurrentRawHScroll; |
2490 | |
2491 | - // Id bits used to differentiate fingers, stylus and mouse tools. |
2492 | - BitSet32 mCurrentFingerIdBits; // finger or unknown |
2493 | - BitSet32 mLastFingerIdBits; |
2494 | - BitSet32 mCurrentStylusIdBits; // stylus or eraser |
2495 | - BitSet32 mLastStylusIdBits; |
2496 | - BitSet32 mCurrentMouseIdBits; // mouse or lens |
2497 | - BitSet32 mLastMouseIdBits; |
2498 | + // Id sets used to differentiate fingers, stylus and mouse tools. |
2499 | + IntSet mCurrentFingerIds; // finger or unknown |
2500 | + IntSet mLastFingerIds; |
2501 | + IntSet mCurrentStylusIds; // stylus or eraser |
2502 | + IntSet mLastStylusIds; |
2503 | + IntSet mCurrentMouseIds; // mouse or lens |
2504 | + IntSet mLastMouseIds; |
2505 | |
2506 | // True if we sent a HOVER_ENTER event. |
2507 | bool mSentHoverEnter; |
2508 | @@ -1266,6 +1287,7 @@ |
2509 | virtual bool hasStylus() const = 0; |
2510 | |
2511 | virtual void syncTouch(nsecs_t when, bool* outHavePointerIds) = 0; |
2512 | + int32_t fetchNewPointerId(); |
2513 | |
2514 | private: |
2515 | // The surface orientation and width and height set by configureSurface(). |
2516 | @@ -1445,14 +1467,14 @@ |
2517 | |
2518 | // Pointer coords and ids for the current and previous pointer gesture. |
2519 | Mode currentGestureMode; |
2520 | - BitSet32 currentGestureIdBits; |
2521 | - uint32_t currentGestureIdToIndex[MAX_POINTER_ID + 1]; |
2522 | + IntSet currentGestureIds; |
2523 | + std::unordered_map<int32_t, uint32_t> currentGestureIdToIndex; |
2524 | PointerProperties currentGestureProperties[MAX_POINTERS]; |
2525 | PointerCoords currentGestureCoords[MAX_POINTERS]; |
2526 | |
2527 | Mode lastGestureMode; |
2528 | - BitSet32 lastGestureIdBits; |
2529 | - uint32_t lastGestureIdToIndex[MAX_POINTER_ID + 1]; |
2530 | + IntSet lastGestureIds; |
2531 | + std::unordered_map<int32_t, uint32_t> lastGestureIdToIndex; |
2532 | PointerProperties lastGestureProperties[MAX_POINTERS]; |
2533 | PointerCoords lastGestureCoords[MAX_POINTERS]; |
2534 | |
2535 | @@ -1479,14 +1501,14 @@ |
2536 | |
2537 | // Distance that each pointer has traveled which has not yet been |
2538 | // subsumed into the reference gesture position. |
2539 | - BitSet32 referenceIdBits; |
2540 | + IntSet referenceIds; |
2541 | struct Delta { |
2542 | float dx, dy; |
2543 | }; |
2544 | - Delta referenceDeltas[MAX_POINTER_ID + 1]; |
2545 | + std::unordered_map<int32_t, Delta> referenceDeltas; |
2546 | |
2547 | // Describes how touch ids are mapped to gesture ids for freeform gestures. |
2548 | - uint32_t freeformTouchToGestureIdMap[MAX_POINTER_ID + 1]; |
2549 | + std::unordered_map<int32_t, int32_t> freeformTouchToGestureIdMap; |
2550 | |
2551 | // A velocity tracker for determining whether to switch active pointers during drags. |
2552 | VelocityTracker velocityTracker; |
2553 | @@ -1496,9 +1518,9 @@ |
2554 | activeTouchId = -1; |
2555 | activeGestureId = -1; |
2556 | currentGestureMode = NEUTRAL; |
2557 | - currentGestureIdBits.clear(); |
2558 | + currentGestureIds.clear(); |
2559 | lastGestureMode = NEUTRAL; |
2560 | - lastGestureIdBits.clear(); |
2561 | + lastGestureIds.clear(); |
2562 | downTime = 0; |
2563 | velocityTracker.clear(); |
2564 | resetTap(); |
2565 | @@ -1584,20 +1606,26 @@ |
2566 | int32_t action, int32_t flags, int32_t metaState, int32_t buttonState, |
2567 | int32_t edgeFlags, |
2568 | const PointerProperties* properties, const PointerCoords* coords, |
2569 | - const uint32_t* idToIndex, BitSet32 idBits, |
2570 | + uint32_t inPointerCount, |
2571 | + int32_t changedId, float xPrecision, float yPrecision, nsecs_t downTime); |
2572 | + void dispatchMotion(nsecs_t when, uint32_t policyFlags, uint32_t source, |
2573 | + int32_t action, int32_t flags, int32_t metaState, int32_t buttonState, |
2574 | + int32_t edgeFlags, |
2575 | + const PointerProperties* properties, const PointerCoords* coords, |
2576 | + uint32_t inPointerCount, const IntSet &idsToDispatch, |
2577 | int32_t changedId, float xPrecision, float yPrecision, nsecs_t downTime); |
2578 | |
2579 | - // Updates pointer coords and properties for pointers with specified ids that have moved. |
2580 | + // Updates pointer coords and properties for pointers that have moved. |
2581 | // Returns true if any of them changed. |
2582 | - bool updateMovedPointers(const PointerProperties* inProperties, |
2583 | - const PointerCoords* inCoords, const uint32_t* inIdToIndex, |
2584 | - PointerProperties* outProperties, PointerCoords* outCoords, |
2585 | - const uint32_t* outIdToIndex, BitSet32 idBits) const; |
2586 | + bool updateMovedPointers(const PointerProperties* inProperties, const PointerCoords* inCoords, |
2587 | + uint32_t inPointerCount, PointerProperties* outProperties, PointerCoords* outCoords, |
2588 | + uint32_t outPointerCount, const IntSet &commonTouchingIds) const; |
2589 | |
2590 | bool isPointInsideSurface(int32_t x, int32_t y); |
2591 | const VirtualKey* findVirtualKeyHit(int32_t x, int32_t y); |
2592 | |
2593 | void assignPointerIds(); |
2594 | + int32_t mNextNewPointerId; |
2595 | }; |
2596 | |
2597 | |
2598 | @@ -1635,9 +1663,9 @@ |
2599 | private: |
2600 | MultiTouchMotionAccumulator mMultiTouchMotionAccumulator; |
2601 | |
2602 | - // Specifies the pointer id bits that are in use, and their associated tracking id. |
2603 | - BitSet32 mPointerIdBits; |
2604 | - int32_t mPointerTrackingIdMap[MAX_POINTER_ID + 1]; |
2605 | + // Specifies the pointer ids that are in use, and their associated tracking id. |
2606 | + IntSet mPointerIds; |
2607 | + std::unordered_map<int32_t, int32_t> mPointerTrackingIdMap; |
2608 | }; |
2609 | |
2610 | |
2611 | |
2612 | === modified file '3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp' |
2613 | --- 3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp 2013-05-31 16:06:07 +0000 |
2614 | +++ 3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp 2013-11-07 18:01:18 +0000 |
2615 | @@ -593,7 +593,7 @@ |
2616 | if (eventTime < touchState.lastResample.eventTime) { |
2617 | rewriteMessage(touchState, msg); |
2618 | } else { |
2619 | - touchState.lastResample.idBits.clear(); |
2620 | + touchState.lastResample.ids.clear(); |
2621 | } |
2622 | } |
2623 | break; |
2624 | @@ -603,7 +603,7 @@ |
2625 | ssize_t index = findTouchState(deviceId, source); |
2626 | if (index >= 0) { |
2627 | TouchState& touchState = mTouchStates.editItemAt(index); |
2628 | - touchState.lastResample.idBits.clearBit(msg->body.motion.getActionId()); |
2629 | + touchState.lastResample.ids.remove(msg->body.motion.getActionId()); |
2630 | rewriteMessage(touchState, msg); |
2631 | } |
2632 | break; |
2633 | @@ -614,7 +614,7 @@ |
2634 | if (index >= 0) { |
2635 | TouchState& touchState = mTouchStates.editItemAt(index); |
2636 | rewriteMessage(touchState, msg); |
2637 | - touchState.lastResample.idBits.clearBit(msg->body.motion.getActionId()); |
2638 | + touchState.lastResample.ids.remove(msg->body.motion.getActionId()); |
2639 | } |
2640 | break; |
2641 | } |
2642 | @@ -644,7 +644,7 @@ |
2643 | void InputConsumer::rewriteMessage(const TouchState& state, InputMessage* msg) { |
2644 | for (size_t i = 0; i < msg->body.motion.pointerCount; i++) { |
2645 | uint32_t id = msg->body.motion.pointers[i].properties.id; |
2646 | - if (state.lastResample.idBits.hasBit(id)) { |
2647 | + if (state.lastResample.ids.contains(id)) { |
2648 | PointerCoords& msgCoords = msg->body.motion.pointers[i].coords; |
2649 | const PointerCoords& resampleCoords = state.lastResample.getPointerById(id); |
2650 | #if DEBUG_RESAMPLING |
2651 | @@ -689,7 +689,7 @@ |
2652 | size_t pointerCount = event->getPointerCount(); |
2653 | for (size_t i = 0; i < pointerCount; i++) { |
2654 | uint32_t id = event->getPointerId(i); |
2655 | - if (!current->idBits.hasBit(id)) { |
2656 | + if (!current->ids.contains(id)) { |
2657 | #if DEBUG_RESAMPLING |
2658 | ALOGD("Not resampled, missing id %d", id); |
2659 | #endif |
2660 | @@ -744,14 +744,14 @@ |
2661 | |
2662 | // Resample touch coordinates. |
2663 | touchState.lastResample.eventTime = sampleTime; |
2664 | - touchState.lastResample.idBits.clear(); |
2665 | + touchState.lastResample.ids.clear(); |
2666 | for (size_t i = 0; i < pointerCount; i++) { |
2667 | uint32_t id = event->getPointerId(i); |
2668 | touchState.lastResample.idToIndex[id] = i; |
2669 | - touchState.lastResample.idBits.markBit(id); |
2670 | + touchState.lastResample.ids.insert(id); |
2671 | PointerCoords& resampledCoords = touchState.lastResample.pointers[i]; |
2672 | const PointerCoords& currentCoords = current->getPointerById(id); |
2673 | - if (other->idBits.hasBit(id) |
2674 | + if (other->ids.contains(id) |
2675 | && shouldResampleTool(event->getToolType(i))) { |
2676 | const PointerCoords& otherCoords = other->getPointerById(id); |
2677 | resampledCoords.copyFrom(currentCoords); |
2678 | |
2679 | === added file '3rd_party/android-input/android/frameworks/base/services/input/IntSet.cpp' |
2680 | --- 3rd_party/android-input/android/frameworks/base/services/input/IntSet.cpp 1970-01-01 00:00:00 +0000 |
2681 | +++ 3rd_party/android-input/android/frameworks/base/services/input/IntSet.cpp 2013-11-07 18:01:18 +0000 |
2682 | @@ -0,0 +1,123 @@ |
2683 | +/* |
2684 | + * Copyright © 2013 Canonical Ltd. |
2685 | + * |
2686 | + * This program is free software: you can redistribute it and/or modify it |
2687 | + * under the terms of the GNU Lesser General Public License version 3, |
2688 | + * as published by the Free Software Foundation. |
2689 | + * |
2690 | + * This program is distributed in the hope that it will be useful, |
2691 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2692 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2693 | + * GNU Lesser General Public License for more details. |
2694 | + * |
2695 | + * You should have received a copy of the GNU Lesser General Public License |
2696 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2697 | + * |
2698 | + * Author: Daniel d'Andrada <daniel.dandrada@canonical.com> |
2699 | + */ |
2700 | + |
2701 | +#include <androidfw/IntSet.h> |
2702 | + |
2703 | +#ifdef ANDROID_INPUT_INTSET_TEST |
2704 | +using namespace test::android; |
2705 | +#else |
2706 | +using namespace android; |
2707 | +#endif |
2708 | + |
2709 | +IntSet::IntSet() { |
2710 | +#ifdef ANDROID_INPUT_INTSET_TEST |
2711 | + ++constructionCount; |
2712 | +#endif |
2713 | +} |
2714 | + |
2715 | +IntSet::IntSet(std::initializer_list<int32_t> list) |
2716 | + : stdSet(list) { |
2717 | +#ifdef ANDROID_INPUT_INTSET_TEST |
2718 | + ++constructionCount; |
2719 | +#endif |
2720 | +} |
2721 | + |
2722 | +IntSet::~IntSet() { |
2723 | +#ifdef ANDROID_INPUT_INTSET_TEST |
2724 | + ++destructionCount; |
2725 | +#endif |
2726 | +} |
2727 | + |
2728 | +IntSet IntSet::operator -(const IntSet &other) const { |
2729 | + IntSet result; |
2730 | + |
2731 | + std::set_difference(stdSet.cbegin(), stdSet.cend(), |
2732 | + other.stdSet.cbegin(), other.stdSet.cend(), |
2733 | + std::inserter(result.stdSet, result.stdSet.begin())); |
2734 | + |
2735 | + return result; |
2736 | +} |
2737 | + |
2738 | +IntSet IntSet::operator &(const IntSet &other) const { |
2739 | + IntSet result; |
2740 | + |
2741 | + std::set_intersection(stdSet.cbegin(), stdSet.cend(), |
2742 | + other.stdSet.cbegin(), other.stdSet.cend(), |
2743 | + std::inserter(result.stdSet, result.stdSet.begin())); |
2744 | + |
2745 | + return result; |
2746 | +} |
2747 | + |
2748 | +bool IntSet::operator ==(const IntSet &other) const { |
2749 | + return stdSet == other.stdSet; |
2750 | +} |
2751 | + |
2752 | +void IntSet::remove(const IntSet &values) { |
2753 | + remove(stdSet.begin(), values.stdSet.begin(), values.stdSet.end()); |
2754 | +} |
2755 | + |
2756 | +bool IntSet::contains(int32_t value) const { |
2757 | + return stdSet.find(value) != stdSet.end(); |
2758 | +} |
2759 | + |
2760 | +size_t IntSet::indexOf(int32_t value) const { |
2761 | + auto it = stdSet.begin(); |
2762 | + size_t index = 0; |
2763 | + while (it != stdSet.end() && *it != value) { |
2764 | + it++; |
2765 | + ++index; |
2766 | + } |
2767 | + assert(it != stdSet.end()); |
2768 | + return index; |
2769 | +} |
2770 | + |
2771 | +std::string IntSet::toString() const { |
2772 | + std::ostringstream stream; |
2773 | + |
2774 | + bool isFirst = true; |
2775 | + forEach([&](int32_t value) { |
2776 | + if (isFirst) { |
2777 | + isFirst = false; |
2778 | + } else { |
2779 | + stream << ", "; |
2780 | + } |
2781 | + stream << value; |
2782 | + }); |
2783 | + |
2784 | + return stream.str(); |
2785 | +} |
2786 | + |
2787 | +void IntSet::remove(std::set<int32_t>::iterator selfIterator, |
2788 | + std::set<int32_t>::const_iterator otherIterator, |
2789 | + std::set<int32_t>::const_iterator otherEnd) { |
2790 | + |
2791 | + if (selfIterator == stdSet.end() || otherIterator == otherEnd) |
2792 | + return; |
2793 | + |
2794 | + if (*selfIterator < *otherIterator) { |
2795 | + selfIterator++; |
2796 | + remove(selfIterator, otherIterator, otherEnd); |
2797 | + } else if (*selfIterator == *otherIterator) { |
2798 | + selfIterator = stdSet.erase(selfIterator); |
2799 | + otherIterator++; |
2800 | + remove(selfIterator, otherIterator, otherEnd); |
2801 | + } else /* *selfIterator > *otherIterator */ { |
2802 | + otherIterator++; |
2803 | + remove(selfIterator, otherIterator, otherEnd); |
2804 | + } |
2805 | +} |
2806 | |
2807 | === modified file '3rd_party/android-input/android/frameworks/base/services/input/PointerController.cpp' |
2808 | --- 3rd_party/android-input/android/frameworks/base/services/input/PointerController.cpp 2012-11-06 18:05:11 +0000 |
2809 | +++ 3rd_party/android-input/android/frameworks/base/services/input/PointerController.cpp 2013-11-07 18:01:18 +0000 |
2810 | @@ -167,15 +167,12 @@ |
2811 | } |
2812 | } |
2813 | |
2814 | -void PointerController::setSpots(const PointerCoords* spotCoords, |
2815 | - const uint32_t* spotIdToIndex, BitSet32 spotIdBits) { |
2816 | +void PointerController::setSpots(const PointerCoords* spotCoords, uint32_t spotCount) { |
2817 | #if DEBUG_POINTER_UPDATES |
2818 | - ALOGD("setSpots: idBits=%08x", spotIdBits.value); |
2819 | - for (BitSet32 idBits(spotIdBits); !idBits.isEmpty(); ) { |
2820 | - uint32_t id = idBits.firstMarkedBit(); |
2821 | - idBits.clearBit(id); |
2822 | - const PointerCoords& c = spotCoords[spotIdToIndex[id]]; |
2823 | - ALOGD(" spot %d: position=(%0.3f, %0.3f), pressure=%0.3f", id, |
2824 | + ALOGD("setSpots: spotCount=%d", spotCount); |
2825 | + for (size_t i = 0; i < spotCount; ++i) { |
2826 | + const PointerCoords& c = spotCoords[i]; |
2827 | + ALOGD(" spot %d: position=(%0.3f, %0.3f), pressure=%0.3f", i, |
2828 | c.getAxisValue(AMOTION_EVENT_AXIS_X), |
2829 | c.getAxisValue(AMOTION_EVENT_AXIS_Y), |
2830 | c.getAxisValue(AMOTION_EVENT_AXIS_PRESSURE)); |
2831 | |
2832 | === modified file '3rd_party/android-input/android/frameworks/base/services/input/PointerController.h' |
2833 | --- 3rd_party/android-input/android/frameworks/base/services/input/PointerController.h 2013-05-03 16:38:07 +0000 |
2834 | +++ 3rd_party/android-input/android/frameworks/base/services/input/PointerController.h 2013-11-07 18:01:18 +0000 |
2835 | @@ -18,7 +18,6 @@ |
2836 | #define _UI_POINTER_CONTROLLER_H |
2837 | |
2838 | #include <androidfw/Input.h> |
2839 | -#include <std/BitSet.h> |
2840 | #include <std/Mutex.h> |
2841 | #include <std/RefBase.h> |
2842 | #include <std/String8.h> |
2843 | @@ -104,8 +103,7 @@ |
2844 | * For spotCoords, pressure != 0 indicates that the spot's location is being |
2845 | * pressed (not hovering). |
2846 | */ |
2847 | - virtual void setSpots(const PointerCoords* spotCoords, const uint32_t* spotIdToIndex, |
2848 | - BitSet32 spotIdBits) = 0; |
2849 | + virtual void setSpots(const PointerCoords* spotCoords, uint32_t spotCount) = 0; |
2850 | |
2851 | /* Removes all spots. */ |
2852 | virtual void clearSpots() = 0; |
2853 | @@ -139,8 +137,7 @@ |
2854 | virtual void unfade(Transition transition); |
2855 | |
2856 | virtual void setPresentation(Presentation presentation); |
2857 | - virtual void setSpots(const PointerCoords* spotCoords, |
2858 | - const uint32_t* spotIdToIndex, BitSet32 spotIdBits); |
2859 | + virtual void setSpots(const PointerCoords* spotCoords, uint32_t spotCount); |
2860 | virtual void clearSpots(); |
2861 | |
2862 | void setDisplaySize(int32_t width, int32_t height); |
2863 | |
2864 | === modified file '3rd_party/android-input/android/frameworks/base/services/input/VelocityControl.cpp' |
2865 | --- 3rd_party/android-input/android/frameworks/base/services/input/VelocityControl.cpp 2013-05-03 16:38:07 +0000 |
2866 | +++ 3rd_party/android-input/android/frameworks/base/services/input/VelocityControl.cpp 2013-11-07 18:01:18 +0000 |
2867 | @@ -24,7 +24,6 @@ |
2868 | #include <limits.h> |
2869 | |
2870 | #include <androidfw/VelocityControl.h> |
2871 | -#include <std/BitSet.h> |
2872 | #include <std/Timers.h> |
2873 | |
2874 | namespace android { |
2875 | @@ -35,6 +34,7 @@ |
2876 | |
2877 | VelocityControl::VelocityControl() { |
2878 | reset(); |
2879 | + mIds.insert(1); |
2880 | } |
2881 | |
2882 | void VelocityControl::setParameters(const VelocityControlParameters& parameters) { |
2883 | @@ -66,7 +66,7 @@ |
2884 | if (deltaY) { |
2885 | mRawPosition.y += *deltaY; |
2886 | } |
2887 | - mVelocityTracker.addMovement(eventTime, BitSet32(BitSet32::valueForBit(0)), &mRawPosition); |
2888 | + mVelocityTracker.addMovement(eventTime, mIds, &mRawPosition); |
2889 | |
2890 | float vx, vy; |
2891 | float scale = mParameters.scale; |
2892 | |
2893 | === modified file '3rd_party/android-input/android/frameworks/base/services/input/VelocityTracker.cpp' |
2894 | --- 3rd_party/android-input/android/frameworks/base/services/input/VelocityTracker.cpp 2013-05-03 16:38:07 +0000 |
2895 | +++ 3rd_party/android-input/android/frameworks/base/services/input/VelocityTracker.cpp 2013-11-07 18:01:18 +0000 |
2896 | @@ -27,7 +27,7 @@ |
2897 | #include <limits.h> |
2898 | |
2899 | #include <androidfw/VelocityTracker.h> |
2900 | -#include <std/BitSet.h> |
2901 | +#include <androidfw/IntSet.h> |
2902 | #include <std/String8.h> |
2903 | #include <std/Timers.h> |
2904 | #include <std/Log.h> |
2905 | @@ -109,7 +109,7 @@ |
2906 | const char* VelocityTracker::DEFAULT_STRATEGY = "lsq2"; |
2907 | |
2908 | VelocityTracker::VelocityTracker(const char* strategy) : |
2909 | - mLastEventTime(0), mCurrentPointerIdBits(0), mActivePointerId(-1) { |
2910 | + mLastEventTime(0), mActivePointerId(-1) { |
2911 | char value[PROPERTY_VALUE_MAX]; |
2912 | |
2913 | // Allow the default strategy to be overridden using a system property for debugging. |
2914 | @@ -202,29 +202,24 @@ |
2915 | } |
2916 | |
2917 | void VelocityTracker::clear() { |
2918 | - mCurrentPointerIdBits.clear(); |
2919 | + mCurrentPointerIds.clear(); |
2920 | mActivePointerId = -1; |
2921 | |
2922 | mStrategy->clear(); |
2923 | } |
2924 | |
2925 | -void VelocityTracker::clearPointers(BitSet32 idBits) { |
2926 | - BitSet32 remainingIdBits(mCurrentPointerIdBits.value & ~idBits.value); |
2927 | - mCurrentPointerIdBits = remainingIdBits; |
2928 | +void VelocityTracker::clearPointers(const IntSet &ids) { |
2929 | + mCurrentPointerIds.remove(ids); |
2930 | |
2931 | - if (mActivePointerId >= 0 && idBits.hasBit(mActivePointerId)) { |
2932 | - mActivePointerId = !remainingIdBits.isEmpty() ? remainingIdBits.firstMarkedBit() : -1; |
2933 | + if (mActivePointerId >= 0 && ids.contains(mActivePointerId)) { |
2934 | + mActivePointerId = !mCurrentPointerIds.isEmpty() ? mCurrentPointerIds.first() : -1; |
2935 | } |
2936 | |
2937 | - mStrategy->clearPointers(idBits); |
2938 | + mStrategy->clearPointers(ids); |
2939 | } |
2940 | |
2941 | -void VelocityTracker::addMovement(nsecs_t eventTime, BitSet32 idBits, const Position* positions) { |
2942 | - while (idBits.count() > MAX_POINTERS) { |
2943 | - idBits.clearLastMarkedBit(); |
2944 | - } |
2945 | - |
2946 | - if ((mCurrentPointerIdBits.value & idBits.value) |
2947 | +void VelocityTracker::addMovement(nsecs_t eventTime, const IntSet &ids, const Position* positions) { |
2948 | + if (!(mCurrentPointerIds & ids).isEmpty() |
2949 | && eventTime >= mLastEventTime + ASSUME_POINTER_STOPPED_TIME) { |
2950 | #if DEBUG_VELOCITY |
2951 | ALOGD("VelocityTracker: stopped for %0.3f ms, clearing state.", |
2952 | @@ -236,20 +231,18 @@ |
2953 | } |
2954 | mLastEventTime = eventTime; |
2955 | |
2956 | - mCurrentPointerIdBits = idBits; |
2957 | - if (mActivePointerId < 0 || !idBits.hasBit(mActivePointerId)) { |
2958 | - mActivePointerId = idBits.isEmpty() ? -1 : idBits.firstMarkedBit(); |
2959 | + mCurrentPointerIds = ids; |
2960 | + if (mActivePointerId < 0 || !ids.contains(mActivePointerId)) { |
2961 | + mActivePointerId = ids.isEmpty() ? -1 : ids.first(); |
2962 | } |
2963 | |
2964 | - mStrategy->addMovement(eventTime, idBits, positions); |
2965 | + mStrategy->addMovement(eventTime, ids, positions); |
2966 | |
2967 | #if DEBUG_VELOCITY |
2968 | - ALOGD("VelocityTracker: addMovement eventTime=%lld, idBits=0x%08x, activePointerId=%d", |
2969 | - eventTime, idBits.value, mActivePointerId); |
2970 | - for (BitSet32 iterBits(idBits); !iterBits.isEmpty(); ) { |
2971 | - uint32_t id = iterBits.firstMarkedBit(); |
2972 | - uint32_t index = idBits.getIndexOfBit(id); |
2973 | - iterBits.clearBit(id); |
2974 | + ALOGD("VelocityTracker: addMovement eventTime=%lld, ids.cont()=%d, activePointerId=%d", |
2975 | + eventTime, ids.count(), mActivePointerId); |
2976 | + size_t index = 0; |
2977 | + ids.forEach([&](int32_t id) { |
2978 | Estimator estimator; |
2979 | getEstimator(id, &estimator); |
2980 | ALOGD(" %d: position (%0.3f, %0.3f), " |
2981 | @@ -259,6 +252,7 @@ |
2982 | vectorToString(estimator.xCoeff, estimator.degree + 1).string(), |
2983 | vectorToString(estimator.yCoeff, estimator.degree + 1).string(), |
2984 | estimator.confidence); |
2985 | + ++index; |
2986 | } |
2987 | #endif |
2988 | } |
2989 | @@ -276,9 +270,9 @@ |
2990 | // Start a new movement trace for a pointer that just went down. |
2991 | // We do this on down instead of on up because the client may want to query the |
2992 | // final velocity for a pointer that just went up. |
2993 | - BitSet32 downIdBits; |
2994 | - downIdBits.markBit(event->getPointerId(event->getActionIndex())); |
2995 | - clearPointers(downIdBits); |
2996 | + IntSet downIds; |
2997 | + downIds.insert(event->getPointerId(event->getActionIndex())); |
2998 | + clearPointers(downIds); |
2999 | break; |
3000 | } |
3001 | case AMOTION_EVENT_ACTION_MOVE: |
3002 | @@ -301,14 +295,14 @@ |
3003 | pointerCount = MAX_POINTERS; |
3004 | } |
3005 | |
3006 | - BitSet32 idBits; |
3007 | + IntSet ids; |
3008 | for (size_t i = 0; i < pointerCount; i++) { |
3009 | - idBits.markBit(event->getPointerId(i)); |
3010 | + ids.insert(event->getPointerId(i)); |
3011 | } |
3012 | |
3013 | uint32_t pointerIndex[MAX_POINTERS]; |
3014 | for (size_t i = 0; i < pointerCount; i++) { |
3015 | - pointerIndex[i] = idBits.getIndexOfBit(event->getPointerId(i)); |
3016 | + pointerIndex[i] = ids.indexOf(event->getPointerId(i)); |
3017 | } |
3018 | |
3019 | nsecs_t eventTime; |
3020 | @@ -322,7 +316,7 @@ |
3021 | positions[index].x = event->getHistoricalX(i, h); |
3022 | positions[index].y = event->getHistoricalY(i, h); |
3023 | } |
3024 | - addMovement(eventTime, idBits, positions); |
3025 | + addMovement(eventTime, ids, positions); |
3026 | } |
3027 | |
3028 | eventTime = event->getEventTime(); |
3029 | @@ -331,7 +325,7 @@ |
3030 | positions[index].x = event->getX(i); |
3031 | positions[index].y = event->getY(i); |
3032 | } |
3033 | - addMovement(eventTime, idBits, positions); |
3034 | + addMovement(eventTime, ids, positions); |
3035 | } |
3036 | |
3037 | bool VelocityTracker::getVelocity(uint32_t id, float* outVx, float* outVy) const { |
3038 | @@ -367,15 +361,14 @@ |
3039 | |
3040 | void LeastSquaresVelocityTrackerStrategy::clear() { |
3041 | mIndex = 0; |
3042 | - mMovements[0].idBits.clear(); |
3043 | -} |
3044 | - |
3045 | -void LeastSquaresVelocityTrackerStrategy::clearPointers(BitSet32 idBits) { |
3046 | - BitSet32 remainingIdBits(mMovements[mIndex].idBits.value & ~idBits.value); |
3047 | - mMovements[mIndex].idBits = remainingIdBits; |
3048 | -} |
3049 | - |
3050 | -void LeastSquaresVelocityTrackerStrategy::addMovement(nsecs_t eventTime, BitSet32 idBits, |
3051 | + mMovements[0].ids.clear(); |
3052 | +} |
3053 | + |
3054 | +void LeastSquaresVelocityTrackerStrategy::clearPointers(const IntSet &ids) { |
3055 | + mMovements[mIndex].ids.remove(ids); |
3056 | +} |
3057 | + |
3058 | +void LeastSquaresVelocityTrackerStrategy::addMovement(nsecs_t eventTime, const IntSet &ids, |
3059 | const VelocityTracker::Position* positions) { |
3060 | if (++mIndex == HISTORY_SIZE) { |
3061 | mIndex = 0; |
3062 | @@ -383,9 +376,9 @@ |
3063 | |
3064 | Movement& movement = mMovements[mIndex]; |
3065 | movement.eventTime = eventTime; |
3066 | - movement.idBits = idBits; |
3067 | - uint32_t count = idBits.count(); |
3068 | - for (uint32_t i = 0; i < count; i++) { |
3069 | + movement.ids = ids; |
3070 | + size_t count = ids.count(); |
3071 | + for (size_t i = 0; i < count; i++) { |
3072 | movement.positions[i] = positions[i]; |
3073 | } |
3074 | } |
3075 | @@ -570,7 +563,7 @@ |
3076 | const Movement& newestMovement = mMovements[mIndex]; |
3077 | do { |
3078 | const Movement& movement = mMovements[index]; |
3079 | - if (!movement.idBits.hasBit(id)) { |
3080 | + if (!movement.ids.contains(id)) { |
3081 | break; |
3082 | } |
3083 | |
3084 | @@ -702,36 +695,44 @@ |
3085 | } |
3086 | |
3087 | void IntegratingVelocityTrackerStrategy::clear() { |
3088 | - mPointerIdBits.clear(); |
3089 | -} |
3090 | - |
3091 | -void IntegratingVelocityTrackerStrategy::clearPointers(BitSet32 idBits) { |
3092 | - mPointerIdBits.value &= ~idBits.value; |
3093 | -} |
3094 | - |
3095 | -void IntegratingVelocityTrackerStrategy::addMovement(nsecs_t eventTime, BitSet32 idBits, |
3096 | + mPointerIds.clear(); |
3097 | +} |
3098 | + |
3099 | +void IntegratingVelocityTrackerStrategy::clearPointers(const IntSet &ids) { |
3100 | + mPointerIds.remove(ids); |
3101 | +} |
3102 | + |
3103 | +void IntegratingVelocityTrackerStrategy::addMovement(nsecs_t eventTime, const IntSet &ids, |
3104 | const VelocityTracker::Position* positions) { |
3105 | - uint32_t index = 0; |
3106 | - for (BitSet32 iterIdBits(idBits); !iterIdBits.isEmpty();) { |
3107 | - uint32_t id = iterIdBits.clearFirstMarkedBit(); |
3108 | - State& state = mPointerState[id]; |
3109 | - const VelocityTracker::Position& position = positions[index++]; |
3110 | - if (mPointerIdBits.hasBit(id)) { |
3111 | - updateState(state, eventTime, position.x, position.y); |
3112 | - } else { |
3113 | - initState(state, eventTime, position.x, position.y); |
3114 | - } |
3115 | + |
3116 | + { |
3117 | + auto pointerIdsIt = mPointerIds.begin(); |
3118 | + uint32_t index = 0; |
3119 | + |
3120 | + for_each(ids.begin(), ids.end(), [&](int32_t id) { |
3121 | + State& state = mPointerState[id]; |
3122 | + const VelocityTracker::Position& position = positions[index++]; |
3123 | + |
3124 | + while (*pointerIdsIt < id && pointerIdsIt != mPointerIds.end()) |
3125 | + pointerIdsIt++; |
3126 | + |
3127 | + if (pointerIdsIt != mPointerIds.end() && *pointerIdsIt == id) { |
3128 | + updateState(state, eventTime, position.x, position.y); |
3129 | + } else { |
3130 | + initState(state, eventTime, position.x, position.y); |
3131 | + } |
3132 | + }); |
3133 | } |
3134 | |
3135 | - mPointerIdBits = idBits; |
3136 | + mPointerIds = ids; |
3137 | } |
3138 | |
3139 | bool IntegratingVelocityTrackerStrategy::getEstimator(uint32_t id, |
3140 | VelocityTracker::Estimator* outEstimator) const { |
3141 | outEstimator->clear(); |
3142 | |
3143 | - if (mPointerIdBits.hasBit(id)) { |
3144 | - const State& state = mPointerState[id]; |
3145 | + if (mPointerIds.contains(id)) { |
3146 | + const State& state = mPointerState.at(id); |
3147 | populateEstimator(state, outEstimator); |
3148 | return true; |
3149 | } |
3150 | @@ -823,15 +824,14 @@ |
3151 | |
3152 | void LegacyVelocityTrackerStrategy::clear() { |
3153 | mIndex = 0; |
3154 | - mMovements[0].idBits.clear(); |
3155 | -} |
3156 | - |
3157 | -void LegacyVelocityTrackerStrategy::clearPointers(BitSet32 idBits) { |
3158 | - BitSet32 remainingIdBits(mMovements[mIndex].idBits.value & ~idBits.value); |
3159 | - mMovements[mIndex].idBits = remainingIdBits; |
3160 | -} |
3161 | - |
3162 | -void LegacyVelocityTrackerStrategy::addMovement(nsecs_t eventTime, BitSet32 idBits, |
3163 | + mMovements[0].ids.clear(); |
3164 | +} |
3165 | + |
3166 | +void LegacyVelocityTrackerStrategy::clearPointers(const IntSet &ids) { |
3167 | + mMovements[mIndex].ids.remove(ids); |
3168 | +} |
3169 | + |
3170 | +void LegacyVelocityTrackerStrategy::addMovement(nsecs_t eventTime, const IntSet &ids, |
3171 | const VelocityTracker::Position* positions) { |
3172 | if (++mIndex == HISTORY_SIZE) { |
3173 | mIndex = 0; |
3174 | @@ -839,11 +839,8 @@ |
3175 | |
3176 | Movement& movement = mMovements[mIndex]; |
3177 | movement.eventTime = eventTime; |
3178 | - movement.idBits = idBits; |
3179 | - uint32_t count = idBits.count(); |
3180 | - for (uint32_t i = 0; i < count; i++) { |
3181 | - movement.positions[i] = positions[i]; |
3182 | - } |
3183 | + movement.ids = ids; |
3184 | + memcpy(movement.positions, positions, sizeof(VelocityTracker::Position) * ids.count()); |
3185 | } |
3186 | |
3187 | bool LegacyVelocityTrackerStrategy::getEstimator(uint32_t id, |
3188 | @@ -851,7 +848,7 @@ |
3189 | outEstimator->clear(); |
3190 | |
3191 | const Movement& newestMovement = mMovements[mIndex]; |
3192 | - if (!newestMovement.idBits.hasBit(id)) { |
3193 | + if (!newestMovement.ids.contains(id)) { |
3194 | return false; // no data |
3195 | } |
3196 | |
3197 | @@ -862,7 +859,7 @@ |
3198 | do { |
3199 | uint32_t nextOldestIndex = (oldestIndex == 0 ? HISTORY_SIZE : oldestIndex) - 1; |
3200 | const Movement& nextOldestMovement = mMovements[nextOldestIndex]; |
3201 | - if (!nextOldestMovement.idBits.hasBit(id) |
3202 | + if (!nextOldestMovement.ids.contains(id) |
3203 | || nextOldestMovement.eventTime < minTime) { |
3204 | break; |
3205 | } |
3206 | |
3207 | === modified file 'CMakeLists.txt' |
3208 | --- CMakeLists.txt 2013-10-21 07:47:44 +0000 |
3209 | +++ CMakeLists.txt 2013-11-07 18:01:18 +0000 |
3210 | @@ -28,7 +28,7 @@ |
3211 | |
3212 | set(MIR_VERSION_MAJOR 0) |
3213 | set(MIR_VERSION_MINOR 1) |
3214 | -set(MIR_VERSION_PATCH 0) |
3215 | +set(MIR_VERSION_PATCH 1) |
3216 | |
3217 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) |
3218 | |
3219 | |
3220 | === modified file 'debian/changelog' |
3221 | --- debian/changelog 2013-11-05 09:36:37 +0000 |
3222 | +++ debian/changelog 2013-11-07 18:01:18 +0000 |
3223 | @@ -1,3 +1,9 @@ |
3224 | +mir (0.1.1-0ubuntu1) UNRELEASED; urgency=low |
3225 | + |
3226 | + * Bump version to 0.1.1 |
3227 | + |
3228 | + -- Daniel van Vugt <daniel.van.vugt@canonical.com> Wed, 30 Oct 2013 11:46:13 +0800 |
3229 | + |
3230 | mir (0.1.0+14.04.20131030-0ubuntu1) trusty; urgency=low |
3231 | |
3232 | [ Ubuntu daily release ] |
3233 | @@ -13,9 +19,6 @@ |
3234 | server crashes without the timeout, rendering it needless anyway. |
3235 | (LP: #1245958) |
3236 | |
3237 | - [ Ubuntu daily release ] |
3238 | - * Automatic snapshot from revision 1163 |
3239 | - |
3240 | -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 30 Oct 2013 18:37:21 +0000 |
3241 | |
3242 | mir (0.1.0+14.04.20131028-0ubuntu1) trusty; urgency=low |
3243 | @@ -117,7 +120,7 @@ |
3244 | #1244192) |
3245 | |
3246 | [ Ubuntu daily release ] |
3247 | - * Automatic snapshot from revision 1161 |
3248 | + * Automatic snapshot from revision 1160 |
3249 | |
3250 | -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Mon, 28 Oct 2013 02:04:31 +0000 |
3251 | |
3252 | |
3253 | === modified file 'debian/control' |
3254 | --- debian/control 2013-10-21 16:02:28 +0000 |
3255 | +++ debian/control 2013-11-07 18:01:18 +0000 |
3256 | @@ -69,7 +69,7 @@ |
3257 | . |
3258 | Contains the protocol's definition files. |
3259 | |
3260 | -Package: libmirserver9 |
3261 | +Package: libmirserver11 |
3262 | Section: libs |
3263 | Architecture: i386 amd64 armhf arm64 |
3264 | Multi-Arch: same |
3265 | @@ -115,7 +115,7 @@ |
3266 | Architecture: i386 amd64 armhf arm64 |
3267 | Multi-Arch: same |
3268 | Pre-Depends: ${misc:Pre-Depends} |
3269 | -Depends: libmirserver9 (= ${binary:Version}), |
3270 | +Depends: libmirserver11 (= ${binary:Version}), |
3271 | libmirprotobuf-dev (= ${binary:Version}), |
3272 | mircommon-dev (= ${binary:Version}), |
3273 | libglm-dev, |
3274 | |
3275 | === renamed file 'debian/libmirserver9.install' => 'debian/libmirserver11.install' |
3276 | --- debian/libmirserver9.install 2013-10-21 17:49:01 +0000 |
3277 | +++ debian/libmirserver11.install 2013-11-07 18:01:18 +0000 |
3278 | @@ -1,1 +1,1 @@ |
3279 | -usr/lib/*/libmirserver.so.9 |
3280 | +usr/lib/*/libmirserver.so.11 |
3281 | |
3282 | === modified file 'doc/building_source_for_android.md' |
3283 | --- doc/building_source_for_android.md 2013-06-14 19:08:45 +0000 |
3284 | +++ doc/building_source_for_android.md 2013-11-07 18:01:18 +0000 |
3285 | @@ -52,17 +52,17 @@ |
3286 | compile and run code, and is well suited for a development workflow. |
3287 | |
3288 | - Be sure that the cross compiler that you are using matches the target |
3289 | - environment. (eg, make sure you're using the saucy toolchain if you're |
3290 | - targeting a saucy phablet image) You can specify the toolchain version |
3291 | + environment. (eg, make sure you're using the trusty toolchain if you're |
3292 | + targeting a trusty phablet image) You can specify the toolchain version |
3293 | thusly: |
3294 | |
3295 | - $ apt-get install g++-arm-linux-gnueabihf/saucy |
3296 | + $ apt-get install g++-arm-linux-gnueabihf/trusty |
3297 | |
3298 | - Get access to armhf packages via apt-get. On an amd64/ia32 system, you can |
3299 | do this by adding a file like the one below to /etc/apt/sources.list.d/ |
3300 | |
3301 | #example sources.list with armhf dependencies |
3302 | - deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ saucy main restricted universe multiverse |
3303 | + deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted universe multiverse |
3304 | |
3305 | Then you should run: |
3306 | |
3307 | |
3308 | === modified file 'doc/component_reports.md' |
3309 | --- doc/component_reports.md 2013-08-29 03:48:16 +0000 |
3310 | +++ doc/component_reports.md 2013-11-07 18:01:18 +0000 |
3311 | @@ -18,11 +18,13 @@ |
3312 | |
3313 | Report | Handlers |
3314 | ----------------------- | -------- |
3315 | +connector-report | log |
3316 | display-report | log |
3317 | input-report | log,lttng |
3318 | legacy-input-report | log |
3319 | msg-processor-report | log,lttng |
3320 | session-mediator-report | log |
3321 | +surfaces-report | log |
3322 | |
3323 | For example, to enable the LTTng input report, one could either use the |
3324 | `--input-report=lttng` command-line option to the server, or set the |
3325 | |
3326 | === modified file 'doc/installing_prebuilt_on_pc.md' |
3327 | --- doc/installing_prebuilt_on_pc.md 2013-08-28 03:41:48 +0000 |
3328 | +++ doc/installing_prebuilt_on_pc.md 2013-11-07 18:01:18 +0000 |
3329 | @@ -1,8 +1,8 @@ |
3330 | Installing pre-built packages on a PC {#installing_prebuilt_on_pc} |
3331 | ===================================== |
3332 | |
3333 | -Install saucy if you haven't done so already. Uninstall any proprietary |
3334 | -drivers (-nvidia, -fglrx) and reboot on the FOSS drivers. |
3335 | +Install Ubuntu 13.10 or later if you haven't done so already. Uninstall any |
3336 | +proprietary drivers (-nvidia, -fglrx) and reboot on the FOSS drivers. |
3337 | |
3338 | Install Mir: |
3339 | |
3340 | |
3341 | === modified file 'doc/using_mir_on_pc.md' |
3342 | --- doc/using_mir_on_pc.md 2013-09-19 13:24:22 +0000 |
3343 | +++ doc/using_mir_on_pc.md 2013-11-07 18:01:18 +0000 |
3344 | @@ -15,19 +15,21 @@ |
3345 | lsmod | grep drm |
3346 | |
3347 | Before you can use Mir you need to ensure you have the proper custom Mesa |
3348 | -build installed. If you are running Ubuntu saucy |
3349 | +build installed. If you are running Ubuntu 13.10 or later |
3350 | (see \ref installing_prebuilt_on_pc), you should be good to go. |
3351 | |
3352 | If you built Mir from source code (see \ref building_source_for_pc), you |
3353 | need to ensure you are using the proper Mesa at runtime. You can do that by |
3354 | -installing the Mesa packages from saucy or by building the custom Mesa yourself |
3355 | -and ensuring it can be found by Mir, e.g., by using LD_LIBRARY_PATH. |
3356 | +installing the Mesa packages from Ubuntu 13.10 (or later) or by building the |
3357 | +custom Mesa yourself and ensuring it can be found by Mir, e.g., by using |
3358 | +LD_LIBRARY_PATH. |
3359 | |
3360 | Using Mir as system compositor with X |
3361 | ------------------------------------- |
3362 | |
3363 | Note: for this to work you need to have Mir and all its dependencies (which |
3364 | -include lightdm, Mesa and the Xorg drivers). The easiest way is to run saucy. |
3365 | +include lightdm, Mesa and the Xorg drivers). The easiest way is to run Ubuntu |
3366 | +13.10 or later. |
3367 | |
3368 | If you have installed unity-system-compositor it will have created a file in |
3369 | /etc/lightdm/lightdm.conf.d/10-unity-system-compositor.conf to run XMir. If you |
3370 | |
3371 | === modified file 'examples/demo-inprocess-surface-client/demo_inprocess_surface_client.cpp' |
3372 | --- examples/demo-inprocess-surface-client/demo_inprocess_surface_client.cpp 2013-08-28 03:41:48 +0000 |
3373 | +++ examples/demo-inprocess-surface-client/demo_inprocess_surface_client.cpp 2013-11-07 18:01:18 +0000 |
3374 | @@ -49,7 +49,8 @@ |
3375 | { |
3376 | client = std::make_shared<me::InprocessEGLClient>( |
3377 | config.the_graphics_platform(), |
3378 | - config.the_session_manager()); |
3379 | + config.the_frontend_shell(), |
3380 | + config.the_focus_controller()); |
3381 | }); |
3382 | ///\internal [main_tag] |
3383 | |
3384 | |
3385 | === modified file 'examples/demo-inprocess-surface-client/inprocess_egl_client.cpp' |
3386 | --- examples/demo-inprocess-surface-client/inprocess_egl_client.cpp 2013-09-19 13:24:22 +0000 |
3387 | +++ examples/demo-inprocess-surface-client/inprocess_egl_client.cpp 2013-11-07 18:01:18 +0000 |
3388 | @@ -20,11 +20,12 @@ |
3389 | #include "example_egl_helper.h" |
3390 | |
3391 | #include "mir/main_loop.h" |
3392 | -#include "mir/shell/session_manager.h" |
3393 | -#include "mir/shell/surface.h" |
3394 | +#include "mir/shell/focus_controller.h" |
3395 | +#include "mir/frontend/surface.h" |
3396 | #include "mir/shell/surface_creation_parameters.h" |
3397 | #include "mir/shell/session.h" |
3398 | #include "mir/frontend/session.h" |
3399 | +#include "mir/frontend/shell.h" |
3400 | #include "mir/geometry/size.h" |
3401 | #include "mir/graphics/buffer_properties.h" |
3402 | #include "mir/graphics/platform.h" |
3403 | @@ -46,18 +47,19 @@ |
3404 | #include <signal.h> |
3405 | |
3406 | namespace mf = mir::frontend; |
3407 | -namespace mc = mir::compositor; |
3408 | namespace msh = mir::shell; |
3409 | namespace mg = mir::graphics; |
3410 | namespace me = mir::examples; |
3411 | namespace mircv = mir::input::receiver; |
3412 | namespace geom = mir::geometry; |
3413 | |
3414 | -me::InprocessEGLClient::InprocessEGLClient(std::shared_ptr<mg::Platform> const& graphics_platform, |
3415 | - std::shared_ptr<msh::SessionManager> const& session_manager) |
3416 | +me::InprocessEGLClient::InprocessEGLClient( |
3417 | + std::shared_ptr<mg::Platform> const& graphics_platform, |
3418 | + std::shared_ptr<frontend::Shell> const& shell, |
3419 | + std::shared_ptr<shell::FocusController> const& focus_controller) |
3420 | : graphics_platform(graphics_platform), |
3421 | - |
3422 | - session_manager(session_manager), |
3423 | + shell(shell), |
3424 | + focus_controller(focus_controller), |
3425 | client_thread(std::mem_fn(&InprocessEGLClient::thread_loop), this), |
3426 | terminate(false) |
3427 | { |
3428 | @@ -66,7 +68,7 @@ |
3429 | me::InprocessEGLClient::~InprocessEGLClient() |
3430 | { |
3431 | terminate = true; |
3432 | - auto session = session_manager->focussed_application().lock(); |
3433 | + auto session = focus_controller->focussed_application().lock(); |
3434 | if (session) |
3435 | session->force_requests_to_complete(); |
3436 | client_thread.join(); |
3437 | @@ -91,10 +93,9 @@ |
3438 | .of_size(surface_size) |
3439 | .of_buffer_usage(mg::BufferUsage::hardware) |
3440 | .of_pixel_format(geom::PixelFormat::argb_8888); |
3441 | - auto session = session_manager->open_session("Inprocess client", |
3442 | - std::make_shared<NullEventSink>()); |
3443 | + auto session = shell->open_session("Inprocess client", std::make_shared<NullEventSink>()); |
3444 | // TODO: Why do we get an ID? ~racarr |
3445 | - auto surface = session->get_surface(session_manager->create_surface_for(session, params)); |
3446 | + auto surface = session->get_surface(shell->create_surface_for(session, params)); |
3447 | |
3448 | auto input_platform = mircv::InputPlatform::create(); |
3449 | input_thread = input_platform->create_input_thread( |
3450 | |
3451 | === modified file 'examples/demo-inprocess-surface-client/inprocess_egl_client.h' |
3452 | --- examples/demo-inprocess-surface-client/inprocess_egl_client.h 2013-08-28 03:41:48 +0000 |
3453 | +++ examples/demo-inprocess-surface-client/inprocess_egl_client.h 2013-11-07 18:01:18 +0000 |
3454 | @@ -35,14 +35,9 @@ |
3455 | class InputReceiverThread; |
3456 | } |
3457 | } |
3458 | -namespace graphics |
3459 | -{ |
3460 | -class Platform; |
3461 | -} |
3462 | -namespace shell |
3463 | -{ |
3464 | -class SessionManager; |
3465 | -} |
3466 | +namespace graphics { class Platform; } |
3467 | +namespace shell { class FocusController; } |
3468 | +namespace frontend { class Shell; } |
3469 | |
3470 | namespace examples |
3471 | { |
3472 | @@ -51,8 +46,10 @@ |
3473 | class InprocessEGLClient |
3474 | { |
3475 | public: |
3476 | - InprocessEGLClient(std::shared_ptr<graphics::Platform> const& graphics_platform, |
3477 | - std::shared_ptr<shell::SessionManager> const& session_manager); |
3478 | + InprocessEGLClient( |
3479 | + std::shared_ptr<graphics::Platform> const& graphics_platform, |
3480 | + std::shared_ptr<frontend::Shell> const& shell, |
3481 | + std::shared_ptr<shell::FocusController> const& focus_controller); |
3482 | |
3483 | ~InprocessEGLClient(); |
3484 | |
3485 | @@ -62,7 +59,8 @@ |
3486 | |
3487 | private: |
3488 | std::shared_ptr<graphics::Platform> const graphics_platform; |
3489 | - std::shared_ptr<shell::SessionManager> const session_manager; |
3490 | + std::shared_ptr<frontend::Shell> const shell; |
3491 | + std::shared_ptr<shell::FocusController> const focus_controller; |
3492 | |
3493 | std::thread client_thread; |
3494 | |
3495 | |
3496 | === modified file 'examples/demo-shell/demo_shell.cpp' |
3497 | --- examples/demo-shell/demo_shell.cpp 2013-09-17 18:40:01 +0000 |
3498 | +++ examples/demo-shell/demo_shell.cpp 2013-11-07 18:01:18 +0000 |
3499 | @@ -24,11 +24,7 @@ |
3500 | |
3501 | #include "mir/run_mir.h" |
3502 | #include "mir/report_exception.h" |
3503 | -#include "mir/shell/session_manager.h" |
3504 | -#include "mir/shell/registration_order_focus_sequence.h" |
3505 | -#include "mir/shell/default_focus_mechanism.h" |
3506 | #include "mir/shell/session_container.h" |
3507 | -#include "mir/shell/organising_surface_factory.h" |
3508 | #include "mir/graphics/display.h" |
3509 | #include "mir/input/composite_event_filter.h" |
3510 | |
3511 | @@ -97,7 +93,6 @@ |
3512 | // We use this strange two stage initialization to avoid a circular dependency between the EventFilters |
3513 | // and the SessionStore |
3514 | wm->set_focus_controller(config.the_focus_controller()); |
3515 | - wm->set_session_manager(config.the_session_manager()); |
3516 | wm->set_display(config.the_display()); |
3517 | wm->set_compositor(config.the_compositor()); |
3518 | }); |
3519 | |
3520 | === modified file 'examples/demo-shell/window_manager.cpp' |
3521 | --- examples/demo-shell/window_manager.cpp 2013-09-17 19:46:15 +0000 |
3522 | +++ examples/demo-shell/window_manager.cpp 2013-11-07 18:01:18 +0000 |
3523 | @@ -19,7 +19,6 @@ |
3524 | #include "window_manager.h" |
3525 | |
3526 | #include "mir/shell/focus_controller.h" |
3527 | -#include "mir/shell/session_manager.h" |
3528 | #include "mir/shell/session.h" |
3529 | #include "mir/shell/surface.h" |
3530 | #include "mir/graphics/display.h" |
3531 | @@ -51,12 +50,6 @@ |
3532 | focus_controller = controller; |
3533 | } |
3534 | |
3535 | -void me::WindowManager::set_session_manager( |
3536 | - std::shared_ptr<msh::SessionManager> const& sm) |
3537 | -{ |
3538 | - session_manager = sm; |
3539 | -} |
3540 | - |
3541 | void me::WindowManager::set_display(std::shared_ptr<mg::Display> const& dpy) |
3542 | { |
3543 | display = dpy; |
3544 | @@ -130,7 +123,7 @@ |
3545 | } |
3546 | } |
3547 | else if (event.type == mir_event_type_motion && |
3548 | - session_manager) |
3549 | + focus_controller) |
3550 | { |
3551 | geometry::Point cursor = average_pointer(event.motion); |
3552 | |
3553 | @@ -138,7 +131,7 @@ |
3554 | MirMotionAction action = static_cast<MirMotionAction>(event.motion.action & ~0xff00); |
3555 | |
3556 | std::shared_ptr<msh::Session> app = |
3557 | - session_manager->focussed_application().lock(); |
3558 | + focus_controller->focussed_application().lock(); |
3559 | |
3560 | int fingers = static_cast<int>(event.motion.pointer_count); |
3561 | |
3562 | |
3563 | === modified file 'examples/demo-shell/window_manager.h' |
3564 | --- examples/demo-shell/window_manager.h 2013-09-17 18:40:01 +0000 |
3565 | +++ examples/demo-shell/window_manager.h 2013-11-07 18:01:18 +0000 |
3566 | @@ -29,7 +29,6 @@ |
3567 | namespace shell |
3568 | { |
3569 | class FocusController; |
3570 | -class SessionManager; |
3571 | } |
3572 | namespace graphics |
3573 | { |
3574 | @@ -49,7 +48,6 @@ |
3575 | ~WindowManager() = default; |
3576 | |
3577 | void set_focus_controller(std::shared_ptr<shell::FocusController> const& focus_controller); |
3578 | - void set_session_manager(std::shared_ptr<shell::SessionManager> const& sm); |
3579 | void set_display(std::shared_ptr<graphics::Display> const& display); |
3580 | void set_compositor(std::shared_ptr<compositor::Compositor> const& compositor); |
3581 | |
3582 | @@ -61,7 +59,6 @@ |
3583 | |
3584 | private: |
3585 | std::shared_ptr<shell::FocusController> focus_controller; |
3586 | - std::shared_ptr<shell::SessionManager> session_manager; |
3587 | std::shared_ptr<graphics::Display> display; |
3588 | std::shared_ptr<compositor::Compositor> compositor; |
3589 | |
3590 | |
3591 | === modified file 'examples/demo_input_filter.cpp' |
3592 | --- examples/demo_input_filter.cpp 2013-08-28 03:41:48 +0000 |
3593 | +++ examples/demo_input_filter.cpp 2013-11-07 18:01:18 +0000 |
3594 | @@ -32,6 +32,21 @@ |
3595 | |
3596 | struct PrintingEventFilter : public mi::EventFilter |
3597 | { |
3598 | + void print_motion_event(MirMotionEvent const& ev) |
3599 | + { |
3600 | + std::cout << "Motion Event time=" << ev.event_time |
3601 | + << " pointer_count=" << ev.pointer_count << std::endl; |
3602 | + |
3603 | + for (size_t i = 0; i < ev.pointer_count; ++i) |
3604 | + { |
3605 | + std::cout << " " |
3606 | + << " id=" << ev.pointer_coordinates[i].id |
3607 | + << " pos=(" << ev.pointer_coordinates[i].x << ", " << ev.pointer_coordinates[i].y << ")" |
3608 | + << std::endl; |
3609 | + } |
3610 | + std::cout << "----------------" << std::endl << std::endl; |
3611 | + } |
3612 | + |
3613 | bool handle(MirEvent const& ev) override |
3614 | { |
3615 | // TODO: Enhance printing |
3616 | @@ -42,8 +57,7 @@ |
3617 | } |
3618 | else if (ev.type == mir_event_type_motion) |
3619 | { |
3620 | - std::cout << "Handling motion event (time, pointer0_x, pointer0_y): " << ev.motion.event_time << " " |
3621 | - << ev.motion.pointer_coordinates[0].x << " " << ev.motion.pointer_coordinates[0].y << std::endl; |
3622 | + print_motion_event(ev.motion); |
3623 | } |
3624 | return false; |
3625 | } |
3626 | @@ -56,7 +70,7 @@ |
3627 | event_filter(std::make_shared<PrintingEventFilter>()) |
3628 | { |
3629 | } |
3630 | - |
3631 | + |
3632 | std::shared_ptr<mi::CompositeEventFilter> the_composite_event_filter() override |
3633 | { |
3634 | auto composite_filter = ServerConfiguration::the_composite_event_filter(); |
3635 | @@ -69,10 +83,18 @@ |
3636 | |
3637 | } |
3638 | |
3639 | + |
3640 | +#include <std/MirLog.h> |
3641 | +void my_write_to_log(int /*prio*/, char const* buffer) |
3642 | +{ |
3643 | + printf("%s\n", buffer); |
3644 | +} |
3645 | + |
3646 | int main(int argc, char const* argv[]) |
3647 | try |
3648 | { |
3649 | DemoServerConfiguration config(argc, argv); |
3650 | + mir::write_to_log = my_write_to_log; |
3651 | |
3652 | mir::run_mir(config, [](mir::DisplayServer&) {/* empty init */}); |
3653 | return 0; |
3654 | |
3655 | === modified file 'examples/image_renderer.cpp' |
3656 | --- examples/image_renderer.cpp 2013-03-21 03:32:59 +0000 |
3657 | +++ examples/image_renderer.cpp 2013-11-07 18:01:18 +0000 |
3658 | @@ -87,11 +87,68 @@ |
3659 | BOOST_THROW_EXCEPTION(std::runtime_error(object_info_err)); |
3660 | } |
3661 | |
3662 | +class GLState |
3663 | +{ |
3664 | +public: |
3665 | + GLState(GLint attrib_loc) |
3666 | + : attrib_loc{attrib_loc} |
3667 | + { |
3668 | + glGetIntegerv(GL_CURRENT_PROGRAM, &program); |
3669 | + glGetIntegerv(GL_TEXTURE_BINDING_2D, &texture); |
3670 | + glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &buffer); |
3671 | + glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture_unit); |
3672 | + if (attrib_loc >= 0) |
3673 | + { |
3674 | + glGetVertexAttribiv(attrib_loc, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &attrib_enabled); |
3675 | + glGetVertexAttribiv(attrib_loc, GL_VERTEX_ATTRIB_ARRAY_SIZE, &attrib_size); |
3676 | + glGetVertexAttribiv(attrib_loc, GL_VERTEX_ATTRIB_ARRAY_TYPE, &attrib_type); |
3677 | + glGetVertexAttribiv(attrib_loc, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &attrib_normalized); |
3678 | + glGetVertexAttribiv(attrib_loc, GL_VERTEX_ATTRIB_ARRAY_STRIDE, &attrib_stride); |
3679 | + glGetVertexAttribPointerv(attrib_loc, GL_VERTEX_ATTRIB_ARRAY_POINTER, &attrib_pointer); |
3680 | + } |
3681 | + } |
3682 | + |
3683 | + GLState() : GLState{invalid_attrib_loc} {} |
3684 | + |
3685 | + ~GLState() |
3686 | + { |
3687 | + glUseProgram(program); |
3688 | + glBindTexture(GL_TEXTURE_2D, texture); |
3689 | + glBindBuffer(GL_ARRAY_BUFFER, buffer); |
3690 | + glActiveTexture(active_texture_unit); |
3691 | + if (attrib_loc >= 0) |
3692 | + { |
3693 | + glVertexAttribPointer(attrib_loc, attrib_size, attrib_type, |
3694 | + attrib_normalized, attrib_stride, attrib_pointer); |
3695 | + if (attrib_enabled) |
3696 | + glEnableVertexAttribArray(attrib_loc); |
3697 | + else |
3698 | + glDisableVertexAttribArray(attrib_loc); |
3699 | + } |
3700 | + } |
3701 | + |
3702 | +private: |
3703 | + static GLint const invalid_attrib_loc = -1; |
3704 | + GLint program = 0; |
3705 | + GLint texture = 0; |
3706 | + GLint buffer = 0; |
3707 | + GLint active_texture_unit = 0; |
3708 | + GLint attrib_loc = invalid_attrib_loc; |
3709 | + GLint attrib_enabled = 0; |
3710 | + GLint attrib_size = 0; |
3711 | + GLint attrib_type = 0; |
3712 | + GLint attrib_normalized = 0; |
3713 | + GLint attrib_stride = 0; |
3714 | + GLvoid* attrib_pointer = nullptr; |
3715 | +}; |
3716 | + |
3717 | } |
3718 | |
3719 | mt::ImageRenderer::ImageRenderer(const uint8_t* pixel_data, mir::geometry::Size size, |
3720 | uint32_t bytes_per_pixel) |
3721 | { |
3722 | + GLState gl_state; |
3723 | + |
3724 | resources.setup(); |
3725 | |
3726 | /* Upload the texture */ |
3727 | @@ -173,7 +230,6 @@ |
3728 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
3729 | |
3730 | glUniform1i(tex_loc, 0); |
3731 | - glBindTexture(GL_TEXTURE_2D, 0); |
3732 | |
3733 | /* Create VBO */ |
3734 | glGenBuffers(1, &vertex_attribs_vbo); |
3735 | @@ -181,14 +237,13 @@ |
3736 | glBindBuffer(GL_ARRAY_BUFFER, vertex_attribs_vbo); |
3737 | glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_attribs), |
3738 | glm::value_ptr(vertex_attribs[0]), GL_STATIC_DRAW); |
3739 | - |
3740 | - glBindBuffer(GL_ARRAY_BUFFER, 0); |
3741 | - glUseProgram(0); |
3742 | } |
3743 | |
3744 | |
3745 | void mt::ImageRenderer::render() |
3746 | { |
3747 | + GLState gl_state(resources.position_attr_loc); |
3748 | + |
3749 | glUseProgram(resources.program); |
3750 | |
3751 | glActiveTexture(GL_TEXTURE0); |
3752 | @@ -202,5 +257,4 @@ |
3753 | /* Draw */ |
3754 | glEnableVertexAttribArray(resources.position_attr_loc); |
3755 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); |
3756 | - glDisableVertexAttribArray(resources.position_attr_loc); |
3757 | } |
3758 | |
3759 | === modified file 'examples/render_surfaces.cpp' |
3760 | --- examples/render_surfaces.cpp 2013-10-15 08:53:10 +0000 |
3761 | +++ examples/render_surfaces.cpp 2013-11-07 18:01:18 +0000 |
3762 | @@ -16,7 +16,7 @@ |
3763 | * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com> |
3764 | */ |
3765 | |
3766 | -#include "mir/compositor/default_display_buffer_compositor_factory.h" |
3767 | +#include "mir/compositor/display_buffer_compositor_factory.h" |
3768 | #include "mir/compositor/display_buffer_compositor.h" |
3769 | #include "mir/graphics/graphic_buffer_allocator.h" |
3770 | #include "mir/frontend/connector.h" |
3771 | @@ -55,6 +55,7 @@ |
3772 | namespace mi = mir::input; |
3773 | namespace geom = mir::geometry; |
3774 | namespace mt = mir::tools; |
3775 | +namespace me = mir::examples; |
3776 | |
3777 | ///\page render_surfaces-example render_surfaces.cpp: A simple program using the mir library. |
3778 | ///\tableofcontents |
3779 | @@ -248,7 +249,7 @@ |
3780 | |
3781 | ///\internal [RenderSurfacesServerConfiguration_tag] |
3782 | // Extend the default configuration to manage moveables. |
3783 | -class RenderSurfacesServerConfiguration : public mir::examples::ServerConfiguration |
3784 | +class RenderSurfacesServerConfiguration : public me::ServerConfiguration |
3785 | { |
3786 | public: |
3787 | RenderSurfacesServerConfiguration(int argc, char const** argv) |
3788 | @@ -349,32 +350,32 @@ |
3789 | uint32_t frames; |
3790 | }; |
3791 | |
3792 | - class RenderSurfacesDisplayBufferCompositorFactory : public mc::DefaultDisplayBufferCompositorFactory |
3793 | + class RenderSurfacesDisplayBufferCompositorFactory : public mc::DisplayBufferCompositorFactory |
3794 | { |
3795 | public: |
3796 | RenderSurfacesDisplayBufferCompositorFactory( |
3797 | - std::shared_ptr<mc::Scene> const& scene, |
3798 | - std::shared_ptr<mc::RendererFactory> const& renderer_factory, |
3799 | - std::shared_ptr<mc::OverlayRenderer> const& overlay_renderer, |
3800 | + std::shared_ptr<mc::DisplayBufferCompositorFactory> const& factory, |
3801 | std::vector<Moveable>& moveables) |
3802 | - : DefaultDisplayBufferCompositorFactory{scene, renderer_factory, overlay_renderer}, |
3803 | + : factory{factory}, |
3804 | moveables(moveables) |
3805 | { |
3806 | } |
3807 | |
3808 | std::unique_ptr<mc::DisplayBufferCompositor> create_compositor_for(mg::DisplayBuffer& display_buffer) |
3809 | { |
3810 | - auto cs = DefaultDisplayBufferCompositorFactory::create_compositor_for(display_buffer); |
3811 | - auto raw = new RenderSurfacesDisplayBufferCompositor(std::move(cs), moveables); |
3812 | + auto compositor = factory->create_compositor_for(display_buffer); |
3813 | + auto raw = new RenderSurfacesDisplayBufferCompositor( |
3814 | + std::move(compositor), moveables); |
3815 | return std::unique_ptr<RenderSurfacesDisplayBufferCompositor>(raw); |
3816 | } |
3817 | + |
3818 | + private: |
3819 | + std::shared_ptr<mc::DisplayBufferCompositorFactory> const factory; |
3820 | std::vector<Moveable>& moveables; |
3821 | }; |
3822 | |
3823 | return std::make_shared<RenderSurfacesDisplayBufferCompositorFactory>( |
3824 | - the_scene(), |
3825 | - the_renderer_factory(), |
3826 | - the_overlay_renderer(), |
3827 | + me::ServerConfiguration::the_display_buffer_compositor_factory(), |
3828 | moveables); |
3829 | } |
3830 | ///\internal [RenderSurfacesDisplayBufferCompositor_tag] |
3831 | |
3832 | === modified file 'examples/render_to_fb.cpp' |
3833 | --- examples/render_to_fb.cpp 2013-09-19 13:24:22 +0000 |
3834 | +++ examples/render_to_fb.cpp 2013-11-07 18:01:18 +0000 |
3835 | @@ -21,8 +21,6 @@ |
3836 | #include "mir/default_server_configuration.h" |
3837 | #include "mir/graphics/display.h" |
3838 | #include "mir/graphics/display_buffer.h" |
3839 | -#include "mir/graphics/default_display_configuration_policy.h" |
3840 | -#include "mir/graphics/platform.h" |
3841 | #include "mir/report_exception.h" |
3842 | |
3843 | #include <csignal> |
3844 | @@ -56,8 +54,7 @@ |
3845 | |
3846 | mir::DefaultServerConfiguration conf{argc, argv}; |
3847 | |
3848 | - auto platform = conf.the_graphics_platform(); |
3849 | - auto display = platform->create_display(std::make_shared<mg::DefaultDisplayConfigurationPolicy>()); |
3850 | + auto display = conf.the_display(); |
3851 | |
3852 | mir::draw::glAnimationBasic gl_animation; |
3853 | |
3854 | |
3855 | === modified file 'include/client/mir_toolkit/mir_client_library_drm.h' |
3856 | --- include/client/mir_toolkit/mir_client_library_drm.h 2013-05-30 03:50:54 +0000 |
3857 | +++ include/client/mir_toolkit/mir_client_library_drm.h 2013-11-07 18:01:18 +0000 |
3858 | @@ -27,6 +27,8 @@ |
3859 | extern "C" { |
3860 | #endif |
3861 | |
3862 | +struct gbm_device; |
3863 | + |
3864 | typedef void (*mir_drm_auth_magic_callback)(int status, void *context); |
3865 | |
3866 | /* Authenticates a DRM magic cookie */ |
3867 | @@ -35,6 +37,18 @@ |
3868 | mir_drm_auth_magic_callback callback, |
3869 | void *context); |
3870 | |
3871 | +/** |
3872 | + * Set the gbm_device to be used by the EGL implementation. |
3873 | + * This is required if the application needs to create EGLImages from |
3874 | + * gbm buffers objects created on that gbm device. |
3875 | + * \param [in] connection The connection |
3876 | + * \param [in] dev The gbm_device to set |
3877 | + * \return A non-zero value if the operation was successful, |
3878 | + * 0 otherwise |
3879 | + */ |
3880 | +int mir_connection_drm_set_gbm_device(MirConnection* connection, |
3881 | + struct gbm_device* dev); |
3882 | + |
3883 | #ifdef __cplusplus |
3884 | } |
3885 | /**@}*/ |
3886 | |
3887 | === modified file 'include/platform/mir/graphics/nested_context.h' |
3888 | --- include/platform/mir/graphics/nested_context.h 2013-10-23 09:33:59 +0000 |
3889 | +++ include/platform/mir/graphics/nested_context.h 2013-11-07 18:01:18 +0000 |
3890 | @@ -21,6 +21,8 @@ |
3891 | |
3892 | #include <vector> |
3893 | |
3894 | +struct gbm_device; |
3895 | + |
3896 | namespace mir |
3897 | { |
3898 | namespace graphics |
3899 | @@ -33,6 +35,7 @@ |
3900 | |
3901 | virtual std::vector<int> platform_fd_items() = 0; |
3902 | virtual void drm_auth_magic(int magic) = 0; |
3903 | + virtual void drm_set_gbm_device(struct gbm_device* dev) = 0; |
3904 | |
3905 | protected: |
3906 | NestedContext() = default; |
3907 | |
3908 | === renamed file 'include/server/mir/surfaces/buffer_stream.h' => 'include/server/mir/compositor/buffer_stream.h' |
3909 | --- include/server/mir/surfaces/buffer_stream.h 2013-08-28 03:41:48 +0000 |
3910 | +++ include/server/mir/compositor/buffer_stream.h 2013-11-07 18:01:18 +0000 |
3911 | @@ -17,8 +17,8 @@ |
3912 | * Kevin DuBois <kevin.dubois@canonical.com> |
3913 | */ |
3914 | |
3915 | -#ifndef MIR_SURFACES_BUFFER_STREAM_H_ |
3916 | -#define MIR_SURFACES_BUFFER_STREAM_H_ |
3917 | +#ifndef MIR_COMPOSITOR_BUFFER_STREAM_H_ |
3918 | +#define MIR_COMPOSITOR_BUFFER_STREAM_H_ |
3919 | |
3920 | #include "mir/geometry/size.h" |
3921 | #include "mir/geometry/pixel_format.h" |
3922 | @@ -33,13 +33,13 @@ |
3923 | class Buffer; |
3924 | } |
3925 | |
3926 | -namespace surfaces |
3927 | +namespace compositor |
3928 | { |
3929 | |
3930 | class BufferStream |
3931 | { |
3932 | public: |
3933 | - virtual ~BufferStream() {/* TODO: make nothrow */} |
3934 | + virtual ~BufferStream() = default; |
3935 | |
3936 | virtual std::shared_ptr<graphics::Buffer> secure_client_buffer() = 0; |
3937 | virtual std::shared_ptr<graphics::Buffer> |
3938 | @@ -47,6 +47,7 @@ |
3939 | virtual std::shared_ptr<graphics::Buffer> lock_snapshot_buffer() = 0; |
3940 | virtual geometry::PixelFormat get_stream_pixel_format() = 0; |
3941 | virtual geometry::Size stream_size() = 0; |
3942 | + virtual void resize(geometry::Size const& size) = 0; |
3943 | virtual void allow_framedropping(bool) = 0; |
3944 | virtual void force_requests_to_complete() = 0; |
3945 | }; |
3946 | @@ -54,4 +55,4 @@ |
3947 | } |
3948 | } |
3949 | |
3950 | -#endif /* MIR_SURFACES_BUFFER_STREAM_H_ */ |
3951 | +#endif /* MIR_COMPOSITOR_BUFFER_STREAM_H_ */ |
3952 | |
3953 | === modified file 'include/server/mir/compositor/scene.h' |
3954 | --- include/server/mir/compositor/scene.h 2013-10-16 07:57:33 +0000 |
3955 | +++ include/server/mir/compositor/scene.h 2013-11-07 18:01:18 +0000 |
3956 | @@ -26,12 +26,9 @@ |
3957 | |
3958 | namespace mir |
3959 | { |
3960 | -namespace surfaces |
3961 | +namespace compositor |
3962 | { |
3963 | class BufferStream; |
3964 | -} |
3965 | -namespace compositor |
3966 | -{ |
3967 | class CompositingCriteria; |
3968 | |
3969 | class FilterForScene |
3970 | @@ -52,7 +49,7 @@ |
3971 | public: |
3972 | virtual ~OperatorForScene() {} |
3973 | |
3974 | - virtual void operator()(CompositingCriteria const&, surfaces::BufferStream&) = 0; |
3975 | + virtual void operator()(CompositingCriteria const&, BufferStream&) = 0; |
3976 | |
3977 | protected: |
3978 | OperatorForScene() = default; |
3979 | @@ -78,7 +75,7 @@ |
3980 | * Scene changes. |
3981 | * |
3982 | * The supplied callback should not directly or indirectly (e.g., |
3983 | - * by changing a property of a Renderable) change the state of |
3984 | + * by changing a property of a surface) change the state of |
3985 | * the Scene, otherwise a deadlock may occur. |
3986 | */ |
3987 | virtual void set_change_callback(std::function<void()> const& f) = 0; |
3988 | |
3989 | === modified file 'include/server/mir/default_configuration_options.h' |
3990 | --- include/server/mir/default_configuration_options.h 2013-10-23 09:02:02 +0000 |
3991 | +++ include/server/mir/default_configuration_options.h 2013-11-07 18:01:18 +0000 |
3992 | @@ -35,10 +35,12 @@ |
3993 | static char const* const display_report_opt; |
3994 | static char const* const legacy_input_report_opt; |
3995 | static char const* const connector_report_opt; |
3996 | + static char const* const surfaces_report_opt; |
3997 | static char const* const input_report_opt; |
3998 | static char const* const host_socket_opt; |
3999 | static char const* const standalone_opt; |
4000 | static char const* const frontend_threads; |
4001 | + static char const* const name_opt; |
4002 | |
4003 | static char const* const glog; |
4004 | static char const* const glog_stderrthreshold; |
4005 | |
4006 | === modified file 'include/server/mir/default_server_configuration.h' |
4007 | --- include/server/mir/default_server_configuration.h 2013-11-05 09:36:37 +0000 |
4008 | +++ include/server/mir/default_server_configuration.h 2013-11-07 18:01:18 +0000 |
4009 | @@ -85,6 +85,7 @@ |
4010 | class SurfaceStack; |
4011 | class SurfaceController; |
4012 | class InputRegistrar; |
4013 | +class SurfacesReport; |
4014 | } |
4015 | namespace graphics |
4016 | { |
4017 | @@ -105,6 +106,7 @@ |
4018 | class CursorListener; |
4019 | class InputRegion; |
4020 | class NestedInputRelay; |
4021 | +class EventHandler; |
4022 | } |
4023 | |
4024 | namespace logging |
4025 | @@ -138,7 +140,7 @@ |
4026 | virtual std::shared_ptr<compositor::RendererFactory> the_renderer_factory(); |
4027 | virtual std::shared_ptr<graphics::DisplayConfigurationPolicy> the_display_configuration_policy(); |
4028 | virtual std::shared_ptr<graphics::nested::HostConnection> the_host_connection(); |
4029 | - virtual std::shared_ptr<input::NestedInputRelay> the_nested_input_relay(); |
4030 | + virtual std::shared_ptr<input::EventFilter> the_nested_event_filter(); |
4031 | /** @} */ |
4032 | |
4033 | /** @name graphics configuration - dependencies |
4034 | @@ -195,6 +197,7 @@ |
4035 | virtual std::shared_ptr<shell::SurfaceConfigurator> the_shell_surface_configurator(); |
4036 | virtual std::shared_ptr<shell::SessionEventSink> the_shell_session_event_sink(); |
4037 | virtual std::shared_ptr<shell::SessionEventHandlerRegister> the_shell_session_event_handler_register(); |
4038 | + virtual std::shared_ptr<shell::SurfaceController> the_shell_surface_controller(); |
4039 | /** @} */ |
4040 | |
4041 | /** @name shell configuration - dependencies |
4042 | @@ -210,6 +213,7 @@ |
4043 | * configurable interfaces for modifying surfaces |
4044 | * @{ */ |
4045 | virtual std::shared_ptr<surfaces::SurfaceStackModel> the_surface_stack_model(); |
4046 | + virtual std::shared_ptr<surfaces::SurfacesReport> the_surfaces_report(); |
4047 | /** @} */ |
4048 | |
4049 | /** @name surfaces configuration - dependencies |
4050 | @@ -276,6 +280,8 @@ |
4051 | CachedPtr<compositor::RendererFactory> renderer_factory; |
4052 | CachedPtr<compositor::BufferStreamFactory> buffer_stream_factory; |
4053 | CachedPtr<surfaces::SurfaceStack> surface_stack; |
4054 | + CachedPtr<surfaces::SurfacesReport> surfaces_report; |
4055 | + |
4056 | CachedPtr<shell::SurfaceFactory> shell_surface_factory; |
4057 | CachedPtr<shell::SessionContainer> shell_session_container; |
4058 | CachedPtr<shell::FocusSetter> shell_focus_setter; |
4059 | @@ -310,6 +316,7 @@ |
4060 | std::shared_ptr<graphics::GraphicBufferAllocator> const& allocator); |
4061 | |
4062 | virtual std::string the_socket_file() const; |
4063 | + std::shared_ptr<input::NestedInputRelay> the_nested_input_relay(); |
4064 | }; |
4065 | } |
4066 | |
4067 | |
4068 | === modified file 'include/server/mir/frontend/surface.h' |
4069 | --- include/server/mir/frontend/surface.h 2013-10-15 08:53:10 +0000 |
4070 | +++ include/server/mir/frontend/surface.h 2013-11-07 18:01:18 +0000 |
4071 | @@ -55,12 +55,7 @@ |
4072 | virtual geometry::Size size() const = 0; |
4073 | virtual geometry::PixelFormat pixel_format() const = 0; |
4074 | |
4075 | - /// Submit the current client buffer, return the next client buffer |
4076 | - /// |
4077 | - /// \param [out] need_ipc: True if the buffer content must be sent via IPC |
4078 | - /// False if only the buffer's ID must be sent. |
4079 | - /// \returns The next client buffer |
4080 | - virtual std::shared_ptr<graphics::Buffer> advance_client_buffer(bool& need_full_ipc) = 0; |
4081 | + virtual std::shared_ptr<graphics::Buffer> advance_client_buffer() = 0; |
4082 | |
4083 | virtual bool supports_input() const = 0; |
4084 | virtual int client_input_fd() const = 0; |
4085 | @@ -75,21 +70,7 @@ |
4086 | |
4087 | auto as_internal_surface(std::shared_ptr<Surface> const& surface) |
4088 | -> std::shared_ptr<graphics::InternalSurface>; |
4089 | - |
4090 | -class ClientTrackingSurface : public Surface |
4091 | -{ |
4092 | -public: |
4093 | - ClientTrackingSurface(); |
4094 | - virtual ~ClientTrackingSurface() = default; |
4095 | - |
4096 | - virtual std::shared_ptr<graphics::Buffer> advance_client_buffer(bool& need_full_ipc) override; |
4097 | - |
4098 | - virtual std::shared_ptr<graphics::Buffer> advance_client_buffer() = 0; |
4099 | -private: |
4100 | - std::shared_ptr<ClientBufferTracker> client_tracker; |
4101 | -}; |
4102 | - |
4103 | -} |
4104 | +} |
4105 | } |
4106 | |
4107 | |
4108 | |
4109 | === removed directory 'include/server/mir/graphics/nested' |
4110 | === modified file 'include/server/mir/shell/application_session.h' |
4111 | --- include/server/mir/shell/application_session.h 2013-08-28 03:41:48 +0000 |
4112 | +++ include/server/mir/shell/application_session.h 2013-11-07 18:01:18 +0000 |
4113 | @@ -36,6 +36,9 @@ |
4114 | class SnapshotStrategy; |
4115 | class SessionListener; |
4116 | |
4117 | +// TODO make private to shell |
4118 | +// This first needs unity-mir and unit-system_compositor to be updated to use Session |
4119 | +// and that first needs -c 1167 of development-branch to land on lp:mir |
4120 | class ApplicationSession : public Session |
4121 | { |
4122 | public: |
4123 | |
4124 | === modified file 'include/server/mir/shell/focus_controller.h' |
4125 | --- include/server/mir/shell/focus_controller.h 2013-08-28 03:41:48 +0000 |
4126 | +++ include/server/mir/shell/focus_controller.h 2013-11-07 18:01:18 +0000 |
4127 | @@ -19,18 +19,22 @@ |
4128 | #ifndef MIR_SHELL_FOCUS_CONTROLLER_H_ |
4129 | #define MIR_SHELL_FOCUS_CONTROLLER_H_ |
4130 | |
4131 | +#include <memory> |
4132 | + |
4133 | namespace mir |
4134 | { |
4135 | - |
4136 | namespace shell |
4137 | { |
4138 | +class Session; |
4139 | |
4140 | class FocusController |
4141 | { |
4142 | public: |
4143 | - virtual ~FocusController() {} |
4144 | + virtual ~FocusController() = default; |
4145 | |
4146 | virtual void focus_next() = 0; |
4147 | + virtual std::weak_ptr<Session> focussed_application() const = 0; |
4148 | + virtual void set_focus_to(std::shared_ptr<Session> const& focus) = 0; |
4149 | |
4150 | protected: |
4151 | FocusController() = default; |
4152 | |
4153 | === modified file 'include/server/mir/shell/session.h' |
4154 | --- include/server/mir/shell/session.h 2013-08-28 03:41:48 +0000 |
4155 | +++ include/server/mir/shell/session.h 2013-11-07 18:01:18 +0000 |
4156 | @@ -37,6 +37,7 @@ |
4157 | |
4158 | virtual void take_snapshot(SnapshotCallback const& snapshot_taken) = 0; |
4159 | virtual std::shared_ptr<Surface> default_surface() const = 0; |
4160 | + virtual void set_lifecycle_state(MirLifecycleState state) = 0; |
4161 | }; |
4162 | |
4163 | } |
4164 | |
4165 | === modified file 'include/server/mir/shell/session_manager.h' |
4166 | --- include/server/mir/shell/session_manager.h 2013-08-28 03:41:48 +0000 |
4167 | +++ include/server/mir/shell/session_manager.h 2013-11-07 18:01:18 +0000 |
4168 | @@ -48,6 +48,9 @@ |
4169 | class SessionListener; |
4170 | struct SurfaceCreationParameters; |
4171 | |
4172 | +// TODO make private to shell |
4173 | +// This first needs unity-mir to be updated to use FocusController |
4174 | +// and that first needs -c 1175 of development-branch to land on lp:mir |
4175 | class SessionManager : public frontend::Shell, public shell::FocusController |
4176 | { |
4177 | public: |
4178 | |
4179 | === modified file 'include/server/mir/shell/surface.h' |
4180 | --- include/server/mir/shell/surface.h 2013-10-15 08:53:10 +0000 |
4181 | +++ include/server/mir/shell/surface.h 2013-11-07 18:01:18 +0000 |
4182 | @@ -44,7 +44,7 @@ |
4183 | class SurfaceController; |
4184 | struct SurfaceCreationParameters; |
4185 | |
4186 | -class Surface : public frontend::ClientTrackingSurface, public shell::SurfaceBufferAccess |
4187 | +class Surface : public frontend::Surface, public shell::SurfaceBufferAccess |
4188 | { |
4189 | public: |
4190 | Surface( |
4191 | @@ -86,8 +86,11 @@ |
4192 | virtual void set_input_region(std::vector<geometry::Rectangle> const& region); |
4193 | |
4194 | virtual void allow_framedropping(bool); |
4195 | - |
4196 | + |
4197 | virtual void raise(std::shared_ptr<SurfaceController> const& controller); |
4198 | + |
4199 | + virtual void resize(geometry::Size const& size); |
4200 | + |
4201 | private: |
4202 | bool set_type(MirSurfaceType t); // Use configure() to make public changes |
4203 | bool set_state(MirSurfaceState s); |
4204 | |
4205 | === modified file 'include/server/mir/surfaces/buffer_stream_factory.h' |
4206 | --- include/server/mir/surfaces/buffer_stream_factory.h 2013-08-28 03:41:48 +0000 |
4207 | +++ include/server/mir/surfaces/buffer_stream_factory.h 2013-11-07 18:01:18 +0000 |
4208 | @@ -25,18 +25,17 @@ |
4209 | |
4210 | namespace mir |
4211 | { |
4212 | +namespace compositor { class BufferStream; } |
4213 | namespace graphics { struct BufferProperties; } |
4214 | |
4215 | namespace surfaces |
4216 | { |
4217 | -class BufferStream; |
4218 | - |
4219 | class BufferStreamFactory |
4220 | { |
4221 | public: |
4222 | - virtual ~BufferStreamFactory() {} |
4223 | + virtual ~BufferStreamFactory() = default; |
4224 | |
4225 | - virtual std::shared_ptr<BufferStream> create_buffer_stream( |
4226 | + virtual std::shared_ptr<compositor::BufferStream> create_buffer_stream( |
4227 | graphics::BufferProperties const& buffer_properties) = 0; |
4228 | |
4229 | protected: |
4230 | |
4231 | === modified file 'include/server/mir/surfaces/surface.h' |
4232 | --- include/server/mir/surfaces/surface.h 2013-08-29 09:20:06 +0000 |
4233 | +++ include/server/mir/surfaces/surface.h 2013-11-07 18:01:18 +0000 |
4234 | @@ -34,6 +34,7 @@ |
4235 | { |
4236 | class CompositingCriteria; |
4237 | struct BufferIPCPackage; |
4238 | +class BufferStream; |
4239 | } |
4240 | namespace graphics |
4241 | { |
4242 | @@ -47,7 +48,7 @@ |
4243 | namespace surfaces |
4244 | { |
4245 | class SurfaceState; |
4246 | -class BufferStream; |
4247 | +class SurfacesReport; |
4248 | |
4249 | // TODO this is ideally an implementation class. It is only in a public header |
4250 | // TODO because it is used in some example code (which probably needs rethinking). |
4251 | @@ -55,8 +56,9 @@ |
4252 | { |
4253 | public: |
4254 | Surface(std::shared_ptr<surfaces::SurfaceState> const& surface_state, |
4255 | - std::shared_ptr<BufferStream> const& buffer_stream, |
4256 | - std::shared_ptr<input::InputChannel> const& input_channel); |
4257 | + std::shared_ptr<compositor::BufferStream> const& buffer_stream, |
4258 | + std::shared_ptr<input::InputChannel> const& input_channel, |
4259 | + std::shared_ptr<SurfacesReport> const& report); |
4260 | |
4261 | ~Surface(); |
4262 | |
4263 | @@ -66,7 +68,6 @@ |
4264 | void set_alpha(float alpha); |
4265 | void set_hidden(bool is_hidden); |
4266 | |
4267 | - /* From Renderable */ |
4268 | geometry::Point top_left() const; |
4269 | geometry::Size size() const; |
4270 | |
4271 | @@ -86,13 +87,17 @@ |
4272 | |
4273 | std::shared_ptr<compositor::CompositingCriteria> compositing_criteria(); |
4274 | |
4275 | - std::shared_ptr<BufferStream> buffer_stream() const; |
4276 | + std::shared_ptr<compositor::BufferStream> buffer_stream() const; |
4277 | |
4278 | std::shared_ptr<input::Surface> input_surface() const; |
4279 | + |
4280 | + void resize(geometry::Size const& size); |
4281 | + |
4282 | private: |
4283 | std::shared_ptr<surfaces::SurfaceState> surface_state; |
4284 | - std::shared_ptr<BufferStream> surface_buffer_stream; |
4285 | + std::shared_ptr<compositor::BufferStream> surface_buffer_stream; |
4286 | std::shared_ptr<input::InputChannel> const server_input_channel; |
4287 | + std::shared_ptr<SurfacesReport> const report; |
4288 | bool surface_in_startup; |
4289 | }; |
4290 | |
4291 | |
4292 | === modified file 'include/server/mir/surfaces/surface_controller.h' |
4293 | --- include/server/mir/surfaces/surface_controller.h 2013-08-28 03:41:48 +0000 |
4294 | +++ include/server/mir/surfaces/surface_controller.h 2013-11-07 18:01:18 +0000 |
4295 | @@ -45,7 +45,7 @@ |
4296 | |
4297 | virtual void raise(std::weak_ptr<Surface> const& surface); |
4298 | |
4299 | -protected: |
4300 | +private: |
4301 | std::shared_ptr<SurfaceStackModel> const surface_stack; |
4302 | }; |
4303 | |
4304 | |
4305 | === added file 'include/server/mir/surfaces/surfaces_report.h' |
4306 | --- include/server/mir/surfaces/surfaces_report.h 1970-01-01 00:00:00 +0000 |
4307 | +++ include/server/mir/surfaces/surfaces_report.h 2013-11-07 18:01:18 +0000 |
4308 | @@ -0,0 +1,60 @@ |
4309 | +/* |
4310 | + * Copyright © 2013 Canonical Ltd. |
4311 | + * |
4312 | + * This program is free software: you can redistribute it and/or modify it |
4313 | + * under the terms of the GNU General Public License version 3, |
4314 | + * as published by the Free Software Foundation. |
4315 | + * |
4316 | + * This program is distributed in the hope that it will be useful, |
4317 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4318 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4319 | + * GNU General Public License for more details. |
4320 | + * |
4321 | + * You should have received a copy of the GNU General Public License |
4322 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4323 | + * |
4324 | + * Authored by: Alan Griffiths <alan@octopull.co.uk> |
4325 | + */ |
4326 | + |
4327 | + |
4328 | +#ifndef MIR_SURFACES_SURFACES_REPORT_H_ |
4329 | +#define MIR_SURFACES_SURFACES_REPORT_H_ |
4330 | + |
4331 | +#include <memory> |
4332 | + |
4333 | +namespace mir |
4334 | +{ |
4335 | +namespace surfaces |
4336 | +{ |
4337 | +class Surface; |
4338 | + |
4339 | +class SurfacesReport |
4340 | +{ |
4341 | +public: |
4342 | + virtual void surface_created(Surface* const surface) = 0; |
4343 | + virtual void surface_added(Surface* const surface) = 0; |
4344 | + |
4345 | + virtual void surface_removed(Surface* const surface) = 0; |
4346 | + virtual void surface_deleted(Surface* const surface) = 0; |
4347 | + |
4348 | +protected: |
4349 | + SurfacesReport() = default; |
4350 | + virtual ~SurfacesReport() = default; |
4351 | + SurfacesReport(SurfacesReport const&) = delete; |
4352 | + SurfacesReport& operator=(SurfacesReport const&) = delete; |
4353 | +}; |
4354 | + |
4355 | +class NullSurfacesReport : public SurfacesReport |
4356 | +{ |
4357 | +public: |
4358 | + virtual void surface_created(Surface* const /*surface*/) override; |
4359 | + virtual void surface_added(Surface* const /*surface*/) override; |
4360 | + |
4361 | + virtual void surface_removed(Surface* const /*surface*/) override; |
4362 | + virtual void surface_deleted(Surface* const /*surface*/) override; |
4363 | +}; |
4364 | +} |
4365 | +} |
4366 | + |
4367 | + |
4368 | +#endif /* MIR_SURFACES_SURFACES_REPORT_H_ */ |
4369 | |
4370 | === modified file 'include/test/mir_test/draw/android_graphics.h' |
4371 | --- include/test/mir_test/draw/android_graphics.h 2013-10-17 05:51:24 +0000 |
4372 | +++ include/test/mir_test/draw/android_graphics.h 2013-11-07 18:01:18 +0000 |
4373 | @@ -19,7 +19,7 @@ |
4374 | #define MIR_TEST_DRAW_ANDROID_GRAPHICS |
4375 | |
4376 | #include "mir_toolkit/mir_client_library.h" |
4377 | -#include "mir/surfaces/buffer_stream.h" |
4378 | +#include "mir/compositor/buffer_stream.h" |
4379 | #include "mir/geometry/size.h" |
4380 | |
4381 | #include <hardware/gralloc.h> |
4382 | |
4383 | === removed file 'include/test/mir_test_doubles/mock_android_framebuffer_window.h' |
4384 | --- include/test/mir_test_doubles/mock_android_framebuffer_window.h 2013-03-21 19:15:14 +0000 |
4385 | +++ include/test/mir_test_doubles/mock_android_framebuffer_window.h 1970-01-01 00:00:00 +0000 |
4386 | @@ -1,46 +0,0 @@ |
4387 | -/* |
4388 | - * Copyright © 2013 Canonical Ltd. |
4389 | - * |
4390 | - * This program is free software: you can redistribute it and/or modify |
4391 | - * it under the terms of the GNU General Public License version 3 as |
4392 | - * published by the Free Software Foundation. |
4393 | - * |
4394 | - * This program is distributed in the hope that it will be useful, |
4395 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4396 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4397 | - * GNU General Public License for more details. |
4398 | - * |
4399 | - * You should have received a copy of the GNU General Public License |
4400 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4401 | - * |
4402 | - * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
4403 | - */ |
4404 | - |
4405 | -#ifndef MIR_TEST_DOUBLES_MOCK_ANDROID_FRAMEBUFFER_WINDOW_H_ |
4406 | -#define MIR_TEST_DOUBLES_MOCK_ANDROID_FRAMEBUFFER_WINDOW_H_ |
4407 | - |
4408 | -#include "src/server/graphics/android/android_framebuffer_window_query.h" |
4409 | -#include <gmock/gmock.h> |
4410 | - |
4411 | -namespace mir |
4412 | -{ |
4413 | -namespace test |
4414 | -{ |
4415 | -namespace doubles |
4416 | -{ |
4417 | - |
4418 | -class MockAndroidFramebufferWindow : public mir::graphics::android::AndroidFramebufferWindowQuery |
4419 | -{ |
4420 | -public: |
4421 | - MockAndroidFramebufferWindow() {} |
4422 | - ~MockAndroidFramebufferWindow() {} |
4423 | - |
4424 | - MOCK_CONST_METHOD0(android_native_window_type, EGLNativeWindowType()); |
4425 | - MOCK_CONST_METHOD1(android_display_egl_config, EGLConfig(EGLDisplay)); |
4426 | -}; |
4427 | - |
4428 | -} |
4429 | -} |
4430 | -} |
4431 | - |
4432 | -#endif /* MIR_TEST_DOUBLES_MOCK_ANDROID_FRAMEBUFFER_WINDOW_H_ */ |
4433 | |
4434 | === modified file 'include/test/mir_test_doubles/mock_buffer_bundle.h' |
4435 | --- include/test/mir_test_doubles/mock_buffer_bundle.h 2013-08-28 03:41:48 +0000 |
4436 | +++ include/test/mir_test_doubles/mock_buffer_bundle.h 2013-11-07 18:01:18 +0000 |
4437 | @@ -47,6 +47,7 @@ |
4438 | MOCK_CONST_METHOD0(properties, graphics::BufferProperties()); |
4439 | MOCK_METHOD0(force_client_abort, void()); |
4440 | MOCK_METHOD0(force_requests_to_complete, void()); |
4441 | + MOCK_METHOD1(resize, void(const geometry::Size &)); |
4442 | }; |
4443 | |
4444 | } |
4445 | |
4446 | === modified file 'include/test/mir_test_doubles/mock_buffer_stream.h' |
4447 | --- include/test/mir_test_doubles/mock_buffer_stream.h 2013-08-28 03:41:48 +0000 |
4448 | +++ include/test/mir_test_doubles/mock_buffer_stream.h 2013-11-07 18:01:18 +0000 |
4449 | @@ -19,7 +19,7 @@ |
4450 | #ifndef MIR_TEST_DOUBLES_MOCK_BUFFER_STREAM_H_ |
4451 | #define MIR_TEST_DOUBLES_MOCK_BUFFER_STREAM_H_ |
4452 | |
4453 | -#include "mir/surfaces/buffer_stream.h" |
4454 | +#include "mir/compositor/buffer_stream.h" |
4455 | |
4456 | #include <gmock/gmock.h> |
4457 | |
4458 | @@ -29,7 +29,7 @@ |
4459 | { |
4460 | namespace doubles |
4461 | { |
4462 | -struct MockBufferStream : public surfaces::BufferStream |
4463 | +struct MockBufferStream : public compositor::BufferStream |
4464 | { |
4465 | MOCK_METHOD0(secure_client_buffer, std::shared_ptr<graphics::Buffer>()); |
4466 | MOCK_METHOD1(lock_compositor_buffer, |
4467 | @@ -38,6 +38,7 @@ |
4468 | |
4469 | MOCK_METHOD0(get_stream_pixel_format, geometry::PixelFormat()); |
4470 | MOCK_METHOD0(stream_size, geometry::Size()); |
4471 | + MOCK_METHOD1(resize, void(geometry::Size const&)); |
4472 | MOCK_METHOD0(force_client_completion, void()); |
4473 | MOCK_METHOD1(allow_framedropping, void(bool)); |
4474 | MOCK_METHOD0(force_requests_to_complete, void()); |
4475 | |
4476 | === renamed file 'include/test/mir_test_doubles/mock_display_support_provider.h' => 'include/test/mir_test_doubles/mock_display_device.h' |
4477 | --- include/test/mir_test_doubles/mock_display_support_provider.h 2013-10-09 00:57:21 +0000 |
4478 | +++ include/test/mir_test_doubles/mock_display_device.h 2013-11-07 18:01:18 +0000 |
4479 | @@ -16,10 +16,10 @@ |
4480 | * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
4481 | */ |
4482 | |
4483 | -#ifndef MIR_TEST_DOUBLES_MOCK_DISPLAY_SUPPORT_PROVIDER_H_ |
4484 | -#define MIR_TEST_DOUBLES_MOCK_DISPLAY_SUPPORT_PROVIDER_H_ |
4485 | +#ifndef MIR_TEST_DOUBLES_MOCK_DISPLAY_DEVICE_H_ |
4486 | +#define MIR_TEST_DOUBLES_MOCK_DISPLAY_DEVICE_H_ |
4487 | |
4488 | -#include "src/server/graphics/android/display_support_provider.h" |
4489 | +#include "src/server/graphics/android/display_device.h" |
4490 | #include <gmock/gmock.h> |
4491 | |
4492 | namespace mir |
4493 | @@ -28,10 +28,10 @@ |
4494 | { |
4495 | namespace doubles |
4496 | { |
4497 | -class MockDisplaySupportProvider : public graphics::android::DisplaySupportProvider |
4498 | +class MockDisplayDevice : public graphics::android::DisplayDevice |
4499 | { |
4500 | public: |
4501 | - ~MockDisplaySupportProvider() noexcept {} |
4502 | + ~MockDisplayDevice() noexcept {} |
4503 | MOCK_CONST_METHOD0(display_size, geometry::Size()); |
4504 | MOCK_CONST_METHOD0(display_format, geometry::PixelFormat()); |
4505 | MOCK_CONST_METHOD0(number_of_framebuffers_available, unsigned int()); |
4506 | @@ -43,4 +43,4 @@ |
4507 | } |
4508 | } |
4509 | } |
4510 | -#endif /* MIR_TEST_DOUBLES_MOCK_DISPLAY_SUPPORT_PROVIDER_H_ */ |
4511 | +#endif /* MIR_TEST_DOUBLES_MOCK_DISPLAY_DEVICE_H_ */ |
4512 | |
4513 | === modified file 'include/test/mir_test_doubles/mock_egl.h' |
4514 | --- include/test/mir_test_doubles/mock_egl.h 2013-06-14 20:19:37 +0000 |
4515 | +++ include/test/mir_test_doubles/mock_egl.h 2013-11-07 18:01:18 +0000 |
4516 | @@ -36,6 +36,23 @@ |
4517 | namespace doubles |
4518 | { |
4519 | |
4520 | +MATCHER_P(AttrMatches, val, std::string("matches")) |
4521 | +{ |
4522 | + auto i = 0; |
4523 | + while ((val[i] != EGL_NONE) && (arg[i] != EGL_NONE)) |
4524 | + { |
4525 | + if (val[i] != arg[i]) |
4526 | + return false; |
4527 | + i++; |
4528 | + } |
4529 | + |
4530 | + if ((val[i] == EGL_NONE) && (arg[i] == EGL_NONE)) |
4531 | + { |
4532 | + return true; |
4533 | + } |
4534 | + return false; |
4535 | +} |
4536 | + |
4537 | class MockEGL |
4538 | { |
4539 | public: |
4540 | |
4541 | === modified file 'include/test/mir_test_doubles/mock_focus_setter.h' |
4542 | --- include/test/mir_test_doubles/mock_focus_setter.h 2013-08-28 03:41:48 +0000 |
4543 | +++ include/test/mir_test_doubles/mock_focus_setter.h 2013-11-07 18:01:18 +0000 |
4544 | @@ -19,7 +19,7 @@ |
4545 | #ifndef MIR_TEST_DOUBLES_MOCK_FOCUS_SETTER_H_ |
4546 | #define MIR_TEST_DOUBLES_MOCK_FOCUS_SETTER_H_ |
4547 | |
4548 | -#include "mir/shell/focus_setter.h" |
4549 | +#include "src/server/shell/focus_setter.h" |
4550 | |
4551 | #include <gmock/gmock.h> |
4552 | |
4553 | |
4554 | === modified file 'include/test/mir_test_doubles/mock_frontend_surface.h' |
4555 | --- include/test/mir_test_doubles/mock_frontend_surface.h 2013-08-28 03:41:48 +0000 |
4556 | +++ include/test/mir_test_doubles/mock_frontend_surface.h 2013-11-07 18:01:18 +0000 |
4557 | @@ -29,7 +29,7 @@ |
4558 | { |
4559 | namespace doubles |
4560 | { |
4561 | -struct MockFrontendSurface : public frontend::ClientTrackingSurface |
4562 | +struct MockFrontendSurface : public frontend::Surface |
4563 | { |
4564 | MockFrontendSurface() |
4565 | { |
4566 | |
4567 | === modified file 'include/test/mir_test_doubles/mock_shell_session.h' |
4568 | --- include/test/mir_test_doubles/mock_shell_session.h 2013-08-28 03:41:48 +0000 |
4569 | +++ include/test/mir_test_doubles/mock_shell_session.h 2013-11-07 18:01:18 +0000 |
4570 | @@ -49,6 +49,8 @@ |
4571 | |
4572 | MOCK_METHOD1(send_display_config, void(graphics::DisplayConfiguration const&)); |
4573 | MOCK_METHOD3(configure_surface, int(frontend::SurfaceId, MirSurfaceAttrib, int)); |
4574 | + |
4575 | + MOCK_METHOD1(set_lifecycle_state, void(MirLifecycleState state)); |
4576 | }; |
4577 | |
4578 | } |
4579 | |
4580 | === modified file 'include/test/mir_test_doubles/mock_surface_renderer.h' |
4581 | --- include/test/mir_test_doubles/mock_surface_renderer.h 2013-08-28 03:41:48 +0000 |
4582 | +++ include/test/mir_test_doubles/mock_surface_renderer.h 2013-11-07 18:01:18 +0000 |
4583 | @@ -18,8 +18,9 @@ |
4584 | #ifndef MIR_TEST_DOUBLES_MOCK_SURFACE_RENDERER_H_ |
4585 | #define MIR_TEST_DOUBLES_MOCK_SURFACE_RENDERER_H_ |
4586 | |
4587 | -#include "mir/surfaces/buffer_stream.h" |
4588 | -#include "mir/compositor/renderer.h" |
4589 | +#include "mir/compositor/buffer_stream.h" |
4590 | +#include "src/server/compositor/renderer.h" |
4591 | + |
4592 | #include <gmock/gmock.h> |
4593 | |
4594 | namespace mir |
4595 | @@ -32,7 +33,7 @@ |
4596 | struct MockSurfaceRenderer : public compositor::Renderer |
4597 | { |
4598 | MOCK_METHOD3(render, void( |
4599 | - std::function<void(std::shared_ptr<void> const&)>, compositor::CompositingCriteria const&, surfaces::BufferStream&)); |
4600 | + std::function<void(std::shared_ptr<void> const&)>, compositor::CompositingCriteria const&, compositor::BufferStream&)); |
4601 | MOCK_METHOD1(clear, void(unsigned long)); |
4602 | |
4603 | ~MockSurfaceRenderer() noexcept {} |
4604 | |
4605 | === modified file 'include/test/mir_test_doubles/mock_surface_state.h' |
4606 | --- include/test/mir_test_doubles/mock_surface_state.h 2013-10-07 07:56:05 +0000 |
4607 | +++ include/test/mir_test_doubles/mock_surface_state.h 2013-11-07 18:01:18 +0000 |
4608 | @@ -52,6 +52,7 @@ |
4609 | MOCK_CONST_METHOD0(name, std::string const&()); |
4610 | MOCK_METHOD2(apply_rotation, void(float, glm::vec3 const&)); |
4611 | MOCK_METHOD1(move_to, void(geometry::Point)); |
4612 | + MOCK_METHOD1(resize, void(geometry::Size const&)); |
4613 | MOCK_CONST_METHOD1(contains, bool(geometry::Point const&)); |
4614 | MOCK_METHOD1(set_input_region, void(std::vector<geometry::Rectangle> const&)); |
4615 | MOCK_CONST_METHOD0(alpha, float()); |
4616 | |
4617 | === modified file 'include/test/mir_test_doubles/null_session_event_sink.h' |
4618 | --- include/test/mir_test_doubles/null_session_event_sink.h 2013-08-15 09:15:39 +0000 |
4619 | +++ include/test/mir_test_doubles/null_session_event_sink.h 2013-11-07 18:01:18 +0000 |
4620 | @@ -19,7 +19,7 @@ |
4621 | #ifndef MIR_TEST_DOUBLES_NULL_SESSION_EVENT_SINK_H_ |
4622 | #define MIR_TEST_DOUBLES_NULL_SESSION_EVENT_SINK_H_ |
4623 | |
4624 | -#include "mir/shell/session_event_sink.h" |
4625 | +#include "src/server/shell/session_event_sink.h" |
4626 | |
4627 | namespace mir |
4628 | { |
4629 | |
4630 | === modified file 'include/test/mir_test_doubles/null_snapshot_strategy.h' |
4631 | --- include/test/mir_test_doubles/null_snapshot_strategy.h 2013-06-25 13:19:15 +0000 |
4632 | +++ include/test/mir_test_doubles/null_snapshot_strategy.h 2013-11-07 18:01:18 +0000 |
4633 | @@ -19,7 +19,7 @@ |
4634 | #ifndef MIR_TEST_DOUBLES_NULL_SNAPSHOT_STRATEGY_H_ |
4635 | #define MIR_TEST_DOUBLES_NULL_SNAPSHOT_STRATEGY_H_ |
4636 | |
4637 | -#include "mir/shell/snapshot_strategy.h" |
4638 | +#include "src/server/shell/snapshot_strategy.h" |
4639 | |
4640 | namespace mir |
4641 | { |
4642 | |
4643 | === modified file 'include/test/mir_test_doubles/stub_buffer_allocator.h' |
4644 | --- include/test/mir_test_doubles/stub_buffer_allocator.h 2013-08-28 03:41:48 +0000 |
4645 | +++ include/test/mir_test_doubles/stub_buffer_allocator.h 2013-11-07 18:01:18 +0000 |
4646 | @@ -37,15 +37,9 @@ |
4647 | |
4648 | struct StubBufferAllocator : public graphics::GraphicBufferAllocator |
4649 | { |
4650 | - StubBufferAllocator() : id{1} {} |
4651 | - |
4652 | std::shared_ptr<graphics::Buffer> alloc_buffer( |
4653 | - graphics::BufferProperties const&) |
4654 | + graphics::BufferProperties const& properties) |
4655 | { |
4656 | - graphics::BufferProperties properties{geometry::Size{id, id}, |
4657 | - geometry::PixelFormat::abgr_8888, |
4658 | - graphics::BufferUsage::hardware}; |
4659 | - ++id; |
4660 | return std::make_shared<StubBuffer>(properties); |
4661 | } |
4662 | |
4663 | @@ -53,8 +47,6 @@ |
4664 | { |
4665 | return {}; |
4666 | } |
4667 | - |
4668 | - unsigned int id; |
4669 | }; |
4670 | |
4671 | } |
4672 | |
4673 | === modified file 'include/test/mir_test_doubles/stub_buffer_stream.h' |
4674 | --- include/test/mir_test_doubles/stub_buffer_stream.h 2013-08-28 03:41:48 +0000 |
4675 | +++ include/test/mir_test_doubles/stub_buffer_stream.h 2013-11-07 18:01:18 +0000 |
4676 | @@ -19,7 +19,7 @@ |
4677 | #ifndef MIR_TEST_DOUBLES_NULL_BUFFER_STREAM_H_ |
4678 | #define MIR_TEST_DOUBLES_NULL_BUFFER_STREAM_H_ |
4679 | |
4680 | -#include <mir/surfaces/buffer_stream.h> |
4681 | +#include <mir/compositor/buffer_stream.h> |
4682 | #include <mir_test_doubles/stub_buffer.h> |
4683 | |
4684 | namespace mir |
4685 | @@ -29,7 +29,7 @@ |
4686 | namespace doubles |
4687 | { |
4688 | |
4689 | -class StubBufferStream : public surfaces::BufferStream |
4690 | +class StubBufferStream : public compositor::BufferStream |
4691 | { |
4692 | public: |
4693 | StubBufferStream() |
4694 | @@ -62,6 +62,10 @@ |
4695 | return geometry::Size(); |
4696 | } |
4697 | |
4698 | + void resize(geometry::Size const&) override |
4699 | + { |
4700 | + } |
4701 | + |
4702 | void force_requests_to_complete() |
4703 | { |
4704 | } |
4705 | |
4706 | === added file 'include/test/mir_test_doubles/stub_display_buffer_factory.h' |
4707 | --- include/test/mir_test_doubles/stub_display_buffer_factory.h 1970-01-01 00:00:00 +0000 |
4708 | +++ include/test/mir_test_doubles/stub_display_buffer_factory.h 2013-11-07 18:01:18 +0000 |
4709 | @@ -0,0 +1,75 @@ |
4710 | +/* |
4711 | + * Copyright © 2013 Canonical Ltd. |
4712 | + * |
4713 | + * This program is free software: you can redistribute it and/or modify it |
4714 | + * under the terms of the GNU General Public License version 3, |
4715 | + * as published by the Free Software Foundation. |
4716 | + * |
4717 | + * This program is distributed in the hope that it will be useful, |
4718 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4719 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4720 | + * GNU General Public License for more details. |
4721 | + * |
4722 | + * You should have received a copy of the GNU General Public License |
4723 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4724 | + * |
4725 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
4726 | + */ |
4727 | + |
4728 | +#ifndef MIR_TEST_DOUBLES_STUB_DISPLAY_BUFFER_FACTORY_H_ |
4729 | +#define MIR_TEST_DOUBLES_STUB_DISPLAY_BUFFER_FACTORY_H_ |
4730 | + |
4731 | +#include "src/server/graphics/android/android_display_buffer_factory.h" |
4732 | +#include "stub_display_buffer.h" |
4733 | +#include "stub_display_device.h" |
4734 | +#include <gmock/gmock.h> |
4735 | + |
4736 | +namespace mir |
4737 | +{ |
4738 | +namespace test |
4739 | +{ |
4740 | +namespace doubles |
4741 | +{ |
4742 | +struct StubDisplayBufferFactory : public graphics::android::AndroidDisplayBufferFactory |
4743 | +{ |
4744 | + StubDisplayBufferFactory(std::shared_ptr<graphics::android::DisplayDevice> const& stub_dev, geometry::Size sz) |
4745 | + : stub_dev(stub_dev), sz(sz) |
4746 | + { |
4747 | + } |
4748 | + |
4749 | + StubDisplayBufferFactory() |
4750 | + : StubDisplayBufferFactory(std::make_shared<StubDisplayDevice>(), geometry::Size{0,0}) |
4751 | + { |
4752 | + } |
4753 | + |
4754 | + StubDisplayBufferFactory(geometry::Size sz) |
4755 | + : StubDisplayBufferFactory(std::make_shared<StubDisplayDevice>(), sz) |
4756 | + { |
4757 | + } |
4758 | + |
4759 | + StubDisplayBufferFactory(std::shared_ptr<graphics::android::DisplayDevice> const& stub_dev) |
4760 | + : stub_dev(stub_dev), sz(geometry::Size{0,0}) |
4761 | + { |
4762 | + } |
4763 | + |
4764 | + std::unique_ptr<graphics::DisplayBuffer> create_display_buffer( |
4765 | + std::shared_ptr<graphics::android::DisplayDevice> const&, |
4766 | + EGLDisplay, EGLConfig, EGLContext) |
4767 | + { |
4768 | + return std::unique_ptr<graphics::DisplayBuffer>( |
4769 | + new StubDisplayBuffer(geometry::Rectangle{{0,0},sz})); |
4770 | + } |
4771 | + |
4772 | + std::shared_ptr<graphics::android::DisplayDevice> create_display_device() |
4773 | + { |
4774 | + return stub_dev; |
4775 | + } |
4776 | + |
4777 | + std::shared_ptr<graphics::android::DisplayDevice> const stub_dev; |
4778 | + geometry::Size sz; |
4779 | +}; |
4780 | +} |
4781 | +} |
4782 | +} // namespace mir |
4783 | + |
4784 | +#endif /* MIR_TEST_DOUBLES_STUB_DISPLAY_BUFFER_FACTORY_H_ */ |
4785 | |
4786 | === renamed file 'include/test/mir_test_doubles/stub_display_support_provider.h' => 'include/test/mir_test_doubles/stub_display_device.h' |
4787 | --- include/test/mir_test_doubles/stub_display_support_provider.h 2013-10-18 21:15:15 +0000 |
4788 | +++ include/test/mir_test_doubles/stub_display_device.h 2013-11-07 18:01:18 +0000 |
4789 | @@ -15,10 +15,10 @@ |
4790 | * |
4791 | */ |
4792 | |
4793 | -#ifndef MIR_TEST_DOUBLES_STUB_DISPLAY_SUPPORT_PROVIDER_H_ |
4794 | -#define MIR_TEST_DOUBLES_STUB_DISPLAY_SUPPORT_PROVIDER_H_ |
4795 | +#ifndef MIR_TEST_DOUBLES_STUB_DISPLAY_DEVICE_H_ |
4796 | +#define MIR_TEST_DOUBLES_STUB_DISPLAY_DEVICE_H_ |
4797 | |
4798 | -#include "src/server/graphics/android/display_support_provider.h" |
4799 | +#include "src/server/graphics/android/display_device.h" |
4800 | |
4801 | namespace mir |
4802 | { |
4803 | @@ -27,26 +27,28 @@ |
4804 | namespace doubles |
4805 | { |
4806 | |
4807 | -struct StubDisplaySupportProvider : public graphics::android::DisplaySupportProvider |
4808 | +struct StubDisplayDevice : public graphics::android::DisplayDevice |
4809 | { |
4810 | - StubDisplaySupportProvider(geometry::Size sz) |
4811 | + StubDisplayDevice(geometry::Size sz) |
4812 | : sz(sz) |
4813 | { |
4814 | } |
4815 | - StubDisplaySupportProvider() |
4816 | - : StubDisplaySupportProvider({0,0}) |
4817 | + |
4818 | + StubDisplayDevice() |
4819 | + : StubDisplayDevice({0,0}) |
4820 | { |
4821 | } |
4822 | |
4823 | - ~StubDisplaySupportProvider() noexcept {} |
4824 | + ~StubDisplayDevice() noexcept {} |
4825 | |
4826 | geometry::Size display_size() const { return sz; } |
4827 | - geometry::PixelFormat display_format() const { return geometry::PixelFormat(); } |
4828 | + geometry::PixelFormat display_format() const { return geometry::PixelFormat::abgr_8888; } |
4829 | unsigned int number_of_framebuffers_available() const { return 0; } |
4830 | void set_next_frontbuffer(std::shared_ptr<mir::graphics::Buffer> const&) {} |
4831 | void sync_to_display(bool) {} |
4832 | void mode(MirPowerMode) {} |
4833 | void commit_frame(EGLDisplay, EGLSurface) {} |
4834 | + |
4835 | private: |
4836 | geometry::Size sz; |
4837 | }; |
4838 | @@ -54,4 +56,4 @@ |
4839 | } |
4840 | } |
4841 | } |
4842 | -#endif /* MIR_TEST_DOUBLES_STUB_DISPLAY_SUPPORT_PROVIDER_H_ */ |
4843 | +#endif /* MIR_TEST_DOUBLES_STUB_DISPLAY_DEVICE_H_ */ |
4844 | |
4845 | === added file 'include/test/mir_test_doubles/stub_driver_interpreter.h' |
4846 | --- include/test/mir_test_doubles/stub_driver_interpreter.h 1970-01-01 00:00:00 +0000 |
4847 | +++ include/test/mir_test_doubles/stub_driver_interpreter.h 2013-11-07 18:01:18 +0000 |
4848 | @@ -0,0 +1,75 @@ |
4849 | +/* |
4850 | + * Copyright © 2012 Canonical Ltd. |
4851 | + * |
4852 | + * This program is free software: you can redistribute it and/or modify it |
4853 | + * under the terms of the GNU General Public License version 3, |
4854 | + * as published by the Free Software Foundation. |
4855 | + * |
4856 | + * This program is distributed in the hope that it will be useful, |
4857 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4858 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4859 | + * GNU General Public License for more details. |
4860 | + * |
4861 | + * You should have received a copy of the GNU General Public License |
4862 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4863 | + * |
4864 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
4865 | + */ |
4866 | + |
4867 | +#ifndef MIR_TEST_DOUBLES_STUB_DRIVER_INTERPRETER_H_ |
4868 | +#define MIR_TEST_DOUBLES_STUB_DRIVER_INTERPRETER_H_ |
4869 | + |
4870 | +#include "mir/graphics/android/android_driver_interpreter.h" |
4871 | + |
4872 | +namespace mir |
4873 | +{ |
4874 | +namespace test |
4875 | +{ |
4876 | +namespace doubles |
4877 | +{ |
4878 | + |
4879 | +class StubDriverInterpreter : public graphics::android::AndroidDriverInterpreter |
4880 | +{ |
4881 | +public: |
4882 | + StubDriverInterpreter(mir::geometry::Size sz, int visual_id) |
4883 | + : sz{sz}, |
4884 | + visual_id{visual_id} |
4885 | + { |
4886 | + } |
4887 | + |
4888 | + StubDriverInterpreter() |
4889 | + : StubDriverInterpreter(mir::geometry::Size{44,22}, 5) |
4890 | + { |
4891 | + } |
4892 | + |
4893 | + mir::graphics::NativeBuffer* driver_requests_buffer() |
4894 | + { |
4895 | + return nullptr; |
4896 | + } |
4897 | + void driver_returns_buffer(ANativeWindowBuffer*, int) |
4898 | + { |
4899 | + } |
4900 | + void dispatch_driver_request_format(int) |
4901 | + { |
4902 | + } |
4903 | + int driver_requests_info(int index) const |
4904 | + { |
4905 | + if (index == NATIVE_WINDOW_WIDTH) |
4906 | + return sz.width.as_uint32_t(); |
4907 | + if (index == NATIVE_WINDOW_HEIGHT) |
4908 | + return sz.height.as_uint32_t(); |
4909 | + if (index == NATIVE_WINDOW_FORMAT) |
4910 | + return visual_id; |
4911 | + return 0; |
4912 | + } |
4913 | + void sync_to_display(bool) |
4914 | + { |
4915 | + } |
4916 | +private: |
4917 | + mir::geometry::Size sz; |
4918 | + int visual_id; |
4919 | +}; |
4920 | +} |
4921 | +} |
4922 | +} |
4923 | +#endif /* MIR_TEST_DOUBLES_STUB_BUFFER_H_ */ |
4924 | |
4925 | === modified file 'include/test/mir_test_doubles/stub_ipc_factory.h' |
4926 | --- include/test/mir_test_doubles/stub_ipc_factory.h 2013-08-28 03:41:48 +0000 |
4927 | +++ include/test/mir_test_doubles/stub_ipc_factory.h 2013-11-07 18:01:18 +0000 |
4928 | @@ -21,8 +21,8 @@ |
4929 | #define MIR_TEST_DOUBLES_STUB_IPC_FACTORY_H_ |
4930 | |
4931 | #include "mir_test/fake_shared.h" |
4932 | -#include "mir/frontend/protobuf_ipc_factory.h" |
4933 | -#include "mir/frontend/resource_cache.h" |
4934 | +#include "src/server/frontend/protobuf_ipc_factory.h" |
4935 | +#include "src/server/frontend/resource_cache.h" |
4936 | #include "mir/frontend/null_message_processor_report.h" |
4937 | |
4938 | namespace mir |
4939 | |
4940 | === modified file 'include/test/mir_test_doubles/stub_shell_session.h' |
4941 | --- include/test/mir_test_doubles/stub_shell_session.h 2013-08-13 22:20:37 +0000 |
4942 | +++ include/test/mir_test_doubles/stub_shell_session.h 2013-11-07 18:01:18 +0000 |
4943 | @@ -71,6 +71,10 @@ |
4944 | { |
4945 | return std::shared_ptr<shell::Surface>(); |
4946 | } |
4947 | + |
4948 | + void set_lifecycle_state(MirLifecycleState /*state*/) |
4949 | + { |
4950 | + } |
4951 | }; |
4952 | |
4953 | } |
4954 | |
4955 | === modified file 'include/test/mir_test_doubles/stub_surface.h' |
4956 | --- include/test/mir_test_doubles/stub_surface.h 2013-10-15 08:53:10 +0000 |
4957 | +++ include/test/mir_test_doubles/stub_surface.h 2013-11-07 18:01:18 +0000 |
4958 | @@ -28,7 +28,7 @@ |
4959 | namespace doubles |
4960 | { |
4961 | |
4962 | -class StubSurface : public frontend::ClientTrackingSurface |
4963 | +class StubSurface : public frontend::Surface |
4964 | { |
4965 | public: |
4966 | virtual ~StubSurface() = default; |
4967 | |
4968 | === modified file 'include/test/mir_test_doubles/stub_surface_builder.h' |
4969 | --- include/test/mir_test_doubles/stub_surface_builder.h 2013-08-28 03:41:48 +0000 |
4970 | +++ include/test/mir_test_doubles/stub_surface_builder.h 2013-11-07 18:01:18 +0000 |
4971 | @@ -22,6 +22,7 @@ |
4972 | |
4973 | #include "mir/shell/surface_builder.h" |
4974 | #include "mir/surfaces/surface.h" |
4975 | +#include "mir/surfaces/surfaces_report.h" |
4976 | #include "mir/shell/surface_creation_parameters.h" |
4977 | |
4978 | #include "mir_test_doubles/stub_buffer_stream.h" |
4979 | @@ -47,7 +48,10 @@ |
4980 | { |
4981 | auto state = std::make_shared<MockSurfaceState>(); |
4982 | dummy_surface = std::make_shared<surfaces::Surface>( |
4983 | - state, buffer_stream, std::shared_ptr<input::InputChannel>()); |
4984 | + state, buffer_stream, |
4985 | + std::shared_ptr<input::InputChannel>(), |
4986 | + report); |
4987 | + |
4988 | return dummy_surface; |
4989 | } |
4990 | |
4991 | @@ -55,8 +59,10 @@ |
4992 | { |
4993 | } |
4994 | private: |
4995 | - std::shared_ptr<surfaces::BufferStream> const buffer_stream; |
4996 | + std::shared_ptr<compositor::BufferStream> const buffer_stream; |
4997 | std::shared_ptr<surfaces::Surface> dummy_surface; |
4998 | + std::shared_ptr<surfaces::SurfacesReport> report = std::make_shared<surfaces::NullSurfacesReport>(); |
4999 | + |
5000 | }; |
The diff has been truncated for viewing.