diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-29 20:54:10 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-29 20:54:10 +0000 |
commit | 9d161d2d6f5976f1e6f8df8e23054c25572ee1a9 (patch) | |
tree | be40743a1512e22b6eed346185b9ce7ca8a3b862 /cc | |
parent | ad0a4b06a57dc156fe3d4738d040719aaffd33d3 (diff) | |
download | chromium_src-9d161d2d6f5976f1e6f8df8e23054c25572ee1a9.zip chromium_src-9d161d2d6f5976f1e6f8df8e23054c25572ee1a9.tar.gz chromium_src-9d161d2d6f5976f1e6f8df8e23054c25572ee1a9.tar.bz2 |
cc: Include wheel/touch event handling in the JSON output for the layer tree.
This also adds a test with a small touch-handling region (TouchRegionLight), and
another test with a large number of touch-handling regions (TouchRegionHeavy)
for CalcDrawProps perf-test.
BUG=none
R=enne@chromium.org
Review URL: https://codereview.chromium.org/49913004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231634 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/cc_tests.gyp | 1 | ||||
-rw-r--r-- | cc/layers/layer_impl.cc | 7 | ||||
-rw-r--r-- | cc/test/data/touch_region_heavy.json | 515 | ||||
-rw-r--r-- | cc/test/data/touch_region_light.json | 67 | ||||
-rw-r--r-- | cc/test/layer_tree_json_parser.cc | 18 | ||||
-rw-r--r-- | cc/test/layer_tree_json_parser_unittest.cc | 116 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_common_perftest.cc | 24 |
7 files changed, 748 insertions, 0 deletions
diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp index f44edf0..54fd81c 100644 --- a/cc/cc_tests.gyp +++ b/cc/cc_tests.gyp @@ -77,6 +77,7 @@ 'scheduler/scheduler_unittest.cc', 'scheduler/texture_uploader_unittest.cc', 'test/fake_web_graphics_context_3d_unittest.cc', + 'test/layer_tree_json_parser_unittest.cc', 'trees/damage_tracker_unittest.cc', 'trees/layer_sorter_unittest.cc', 'trees/layer_tree_host_common_unittest.cc', diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc index ede4719..894daf1 100644 --- a/cc/layers/layer_impl.cc +++ b/cc/layers/layer_impl.cc @@ -614,6 +614,13 @@ base::DictionaryValue* LayerImpl::LayerTreeAsJson() const { if (scrollable_) result->SetBoolean("Scrollable", scrollable_); + if (have_wheel_event_handlers_) + result->SetBoolean("WheelHandler", have_wheel_event_handlers_); + if (!touch_event_handler_region_.IsEmpty()) { + scoped_ptr<base::Value> region = touch_event_handler_region_.AsValue(); + result->Set("TouchRegion", region.release()); + } + list = new base::ListValue; for (size_t i = 0; i < children_.size(); ++i) list->Append(children_[i]->LayerTreeAsJson()); diff --git a/cc/test/data/touch_region_heavy.json b/cc/test/data/touch_region_heavy.json new file mode 100644 index 0000000..26d618e --- /dev/null +++ b/cc/test/data/touch_region_heavy.json @@ -0,0 +1,515 @@ +{ + "Bounds": [ 0, 0 ], + "Children": [ { + "Bounds": [ 384, 640 ], + "Children": [ { + "Bounds": [ 384, 1681 ], + "Children": [ { + "Bounds": [ 384, 1681 ], + "Children": [ { + "Bounds": [ 384, 1681 ], + "Children": [ { + "Bounds": [ 298, 114 ], + "Children": [ { + "Bounds": [ 12979, 130 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, -10288.0, 118.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ -9999.0, -1.0 ], + "TouchRegion": [ -9999, -1, 11499, 1, -9999, 0, 12979, 126, -9999, 126, 11499, 3 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 11.0, 119.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 11.0, 120.0 ] + }, { + "Bounds": [ 320, 320 ], + "Children": [ { + "Bounds": [ 152, 152 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 0.0, + "Position": [ 4.0, 5.0 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 287.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 288.0 ] + }, { + "Bounds": [ 320, 320 ], + "Children": [ { + "Bounds": [ 152, 152 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 0.0, + "Position": [ 4.0, 5.0 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 287.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 288.0 ] + }, { + "Bounds": [ 320, 320 ], + "Children": [ { + "Bounds": [ 152, 152 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 0.0, + "Position": [ 4.0, 5.0 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 287.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 288.0 ] + }, { + "Bounds": [ 320, 320 ], + "Children": [ { + "Bounds": [ 152, 152 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 0.0, + "Position": [ 4.0, 5.0 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 287.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 288.0 ] + }, { + "Bounds": [ 300, 114 ], + "Children": [ { + "Bounds": [ 300, 114 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 10.0, 119.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 0.0 ], + "TouchRegion": [ 0, -1, 300, 115, 1, 114, 298, 1 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 10.0, 119.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 10.0, 120.0 ] + }, { + "Bounds": [ 300, 114 ], + "Children": [ { + "Bounds": [ 18, 36 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 10.0, 154.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 35.0 ], + "TouchRegion": [ -9999, -1, 10017, 36 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 10.0, 119.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 10.0, 120.0 ] + }, { + "Bounds": [ 300, 114 ], + "Children": [ { + "Bounds": [ 300, 36 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 10.0, 154.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 35.0 ], + "TouchRegion": [ -9999, -1, 10017, 36 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 10.0, 119.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 10.0, 120.0 ] + }, { + "Bounds": [ 320, 320 ], + "Children": [ { + "Bounds": [ 152, 152 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 4.0, 292.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 4.0, 5.0 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 287.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 288.0 ] + }, { + "Bounds": [ 320, 320 ], + "Children": [ { + "Bounds": [ 152, 152 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 164.0, 292.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 4.0, 5.0 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 287.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 288.0 ] + }, { + "Bounds": [ 320, 320 ], + "Children": [ { + "Bounds": [ 152, 152 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 4.0, 452.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 4.0, 5.0 ], + "TouchRegion": [ -1, 0, 152, 117, -9895, 117, 10046, 5, -9994, 122, 10145, 24, -9895, 146, 10046, 1, -1, 147, 152, 5, 5, 152, 140, 1 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 287.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 288.0 ] + }, { + "Bounds": [ 320, 320 ], + "Children": [ { + "Bounds": [ 152, 152 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 164.0, 452.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 4.0, 5.0 ], + "TouchRegion": [ -1, 0, 152, 117, -9895, 117, 10046, 5, -9994, 122, 10145, 24, -9895, 146, 10046, 1, -1, 147, 152, 5, 5, 152, 140, 1 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 287.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 288.0 ] + }, { + "Bounds": [ 320, 800 ], + "Children": [ { + "Bounds": [ 152, 152 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 4.0, 658.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 4.0, 5.0 ], + "TouchRegion": [ -1, 0, 152, 117, -9895, 117, 10046, 5, -9994, 122, 10145, 24, -9895, 146, 10046, 1, -1, 147, 152, 5, 5, 152, 140, 1 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 653.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 654.0 ] + }, { + "Bounds": [ 320, 800 ], + "Children": [ { + "Bounds": [ 152, 152 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 164.0, 658.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 4.0, 5.0 ], + "TouchRegion": [ -1, 0, 152, 117, -9895, 117, 10046, 5, -9994, 122, 10145, 24, -9895, 146, 10046, 1, -1, 147, 152, 5, 5, 152, 140, 1 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 653.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 654.0 ] + }, { + "Bounds": [ 320, 800 ], + "Children": [ { + "Bounds": [ 152, 152 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 4.0, 818.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 4.0, 5.0 ], + "TouchRegion": [ -1, 0, 152, 117, -9895, 117, 10046, 5, -9994, 122, 10145, 24, -9895, 146, 10046, 1, -1, 147, 152, 5, 5, 152, 140, 1 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 653.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 654.0 ] + }, { + "Bounds": [ 320, 800 ], + "Children": [ { + "Bounds": [ 152, 152 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 164.0, 818.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 4.0, 5.0 ], + "TouchRegion": [ -1, 0, 152, 117, -9895, 117, 10046, 5, -9994, 122, 10145, 24, -9895, 146, 10046, 1, -1, 147, 152, 5, 5, 152, 140, 1 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 653.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 654.0 ] + }, { + "Bounds": [ 320, 800 ], + "Children": [ { + "Bounds": [ 152, 152 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 4.0, 978.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 4.0, 5.0 ], + "TouchRegion": [ -1, 0, 152, 117, -9895, 117, 10046, 5, -9994, 122, 10145, 24, -9895, 146, 10046, 1, -1, 147, 152, 5, 5, 152, 140, 1 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 653.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 654.0 ] + }, { + "Bounds": [ 320, 800 ], + "Children": [ { + "Bounds": [ 152, 152 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 164.0, 978.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 4.0, 5.0 ], + "TouchRegion": [ -1, 0, 152, 117, -9895, 117, 10046, 5, -9994, 122, 10145, 24, -9895, 146, 10046, 1, -1, 147, 152, 5, 5, 152, 140, 1 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 653.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 654.0 ] + }, { + "Bounds": [ 320, 800 ], + "Children": [ { + "Bounds": [ 152, 152 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 4.0, 1138.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 4.0, 5.0 ], + "TouchRegion": [ -1, 0, 152, 117, -9895, 117, 10046, 5, -9994, 122, 10145, 24, -9895, 146, 10046, 1, -1, 147, 152, 5, 5, 152, 140, 1 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 653.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 654.0 ] + }, { + "Bounds": [ 320, 800 ], + "Children": [ { + "Bounds": [ 152, 152 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 164.0, 1138.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 4.0, 5.0 ], + "TouchRegion": [ -1, 0, 152, 117, -9895, 117, 10046, 5, -9994, 122, 10145, 24, -9895, 146, 10046, 1, -1, 147, 152, 5, 5, 152, 140, 1 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 653.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 654.0 ] + }, { + "Bounds": [ 320, 800 ], + "Children": [ { + "Bounds": [ 152, 152 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 4.0, 1298.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 4.0, 5.0 ], + "TouchRegion": [ -1, 0, 152, 117, -9895, 117, 10046, 5, -9994, 122, 10145, 24, -9895, 146, 10046, 1, -1, 147, 152, 5, 5, 152, 140, 1 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 653.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 654.0 ] + }, { + "Bounds": [ 320, 800 ], + "Children": [ { + "Bounds": [ 152, 152 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 164.0, 1298.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 4.0, 5.0 ], + "TouchRegion": [ -1, 0, 152, 117, -9895, 117, 10046, 5, -9994, 122, 10145, 24, -9895, 146, 10046, 1, -1, 147, 152, 5, 5, 152, 140, 1 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 653.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 654.0 ] + }, { + "Bounds": [ 320, 1498 ], + "Children": [ { + "Bounds": [ 104, 37 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 5.0, 256.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 5.0, 147.0 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 109.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 110.0 ] + }, { + "Bounds": [ 320, 1498 ], + "Children": [ { + "Bounds": [ 1, 13 ], + "Children": [ ], + "ContentsOpaque": true, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 108.0, 266.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 108.0, 157.0 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 109.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 110.0 ] + } ], + "ContentsOpaque": true, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, -0.0, -1.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 0.0 ], + "TouchRegion": [ -9993, 0, 326, 50, 0, 0, 320, 50, -9993, 50, 326, 6, -9990, 56, 320, 3, -9990, 59, 320, 1, 8, 59, 44, 1, -9990, 60, 320, 32, 8, 60, 44, 32, 247, 60, 65, 32, -9990, 92, 320, 1, 8, 92, 44, 1, -9990, 93, 320, 27, -9990, 120, 320, 48, 10, 120, 300, 48, -9990, 168, 320, 42, -262, 168, 262, 42, 10, 168, 300, 42, -9990, 210, 320, 2, 10, 210, 300, 2, -9990, 212, 320, 22, -262, 212, 262, 22, 10, 212, 300, 22, -9990, 234, 320, 20, -262, 234, 262, 20, -9990, 254, 320, 2, -9990, 256, 320, 42, -262, 256, 262, 42, -9990, 298, 320, 2, -9990, 300, 320, 42, -262, 300, 262, 42, -9990, 342, 320, 180 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, -0.0, -1.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 0.0 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, -0.0, -1.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 0.0 ], + "Scrollable": true + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 0.0 ] + }, { + "Bounds": [ 10, 640 ], + "Children": [ { + "Bounds": [ 10, 640 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 374.0, 0.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::PaintedScrollbarLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 0.0 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 374.0, 0.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 374.0, 0.0 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 0.0 ] +} + diff --git a/cc/test/data/touch_region_light.json b/cc/test/data/touch_region_light.json new file mode 100644 index 0000000..8b737b5 --- /dev/null +++ b/cc/test/data/touch_region_light.json @@ -0,0 +1,67 @@ +{ + "Bounds": [ 0, 0 ], + "Children": [ { + "Bounds": [ 384, 640 ], + "Children": [ { + "Bounds": [ 384, 732 ], + "Children": [ { + "Bounds": [ 384, 732 ], + "Children": [ { + "Bounds": [ 384, 732 ], + "Children": [ ], + "ContentsOpaque": true, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, -0.0, -1.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 0.0 ], + "TouchRegion": [ 0, 0, 384, 732 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, -0.0, -1.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 0.0 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, -0.0, -1.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 0.0 ], + "Scrollable": true + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 0.0 ] + }, { + "Bounds": [ 10, 640 ], + "Children": [ { + "Bounds": [ 10, 640 ], + "Children": [ ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 374.0, 0.0, 0.0, 1.0 ], + "DrawsContent": true, + "LayerType": "cc::PaintedScrollbarLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 0.0 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 374.0, 0.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 374.0, 0.0 ] + } ], + "ContentsOpaque": false, + "DrawTransform": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ], + "DrawsContent": false, + "LayerType": "cc::TiledLayerImpl", + "Opacity": 1.0, + "Position": [ 0.0, 0.0 ] +} + diff --git a/cc/test/layer_tree_json_parser.cc b/cc/test/layer_tree_json_parser.cc index e389b93..9a1b198 100644 --- a/cc/test/layer_tree_json_parser.cc +++ b/cc/test/layer_tree_json_parser.cc @@ -104,6 +104,24 @@ scoped_refptr<Layer> ParseTreeFromValue(base::Value* val, if (dict->GetBoolean("Scrollable", &scrollable)) new_layer->SetScrollable(scrollable); + bool wheel_handler; + if (dict->GetBoolean("WheelHandler", &wheel_handler)) + new_layer->SetHaveWheelEventHandlers(wheel_handler); + + if (dict->HasKey("TouchRegion")) { + success &= dict->GetList("TouchRegion", &list); + cc::Region touch_region; + for (size_t i = 0; i < list->GetSize(); ) { + int rect_x, rect_y, rect_width, rect_height; + success &= list->GetInteger(i++, &rect_x); + success &= list->GetInteger(i++, &rect_y); + success &= list->GetInteger(i++, &rect_width); + success &= list->GetInteger(i++, &rect_height); + touch_region.Union(gfx::Rect(rect_x, rect_y, rect_width, rect_height)); + } + new_layer->SetTouchEventHandlerRegion(touch_region); + } + success &= dict->GetList("DrawTransform", &list); double transform[16]; for (int i = 0; i < 16; ++i) diff --git a/cc/test/layer_tree_json_parser_unittest.cc b/cc/test/layer_tree_json_parser_unittest.cc new file mode 100644 index 0000000..4261a71 --- /dev/null +++ b/cc/test/layer_tree_json_parser_unittest.cc @@ -0,0 +1,116 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "cc/test/layer_tree_json_parser.h" + +#include "cc/layers/layer.h" +#include "cc/test/fake_impl_proxy.h" +#include "cc/test/fake_layer_tree_host.h" +#include "cc/test/fake_layer_tree_host_impl.h" +#include "cc/test/geometry_test_utils.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace cc { + +namespace { + +bool LayerTreesMatch(LayerImpl* const layer_impl, + Layer* const layer) { +#define RETURN_IF_EXPECTATION_FAILS(exp) \ + do { \ + exp; \ + if (testing::UnitTest::GetInstance()->current_test_info()-> \ + result()->Failed()) \ + return false; \ + } while (0) + + RETURN_IF_EXPECTATION_FAILS(EXPECT_EQ(layer_impl->children().size(), + layer->children().size())); + RETURN_IF_EXPECTATION_FAILS(EXPECT_SIZE_EQ(layer_impl->bounds(), + layer->bounds())); + RETURN_IF_EXPECTATION_FAILS(EXPECT_POINT_EQ(layer_impl->position(), + layer->position())); + RETURN_IF_EXPECTATION_FAILS( + EXPECT_TRANSFORMATION_MATRIX_EQ(layer_impl->draw_transform(), + layer->draw_transform())); + RETURN_IF_EXPECTATION_FAILS(EXPECT_EQ(layer_impl->contents_opaque(), + layer->contents_opaque())); + RETURN_IF_EXPECTATION_FAILS(EXPECT_EQ(layer_impl->scrollable(), + layer->scrollable())); + RETURN_IF_EXPECTATION_FAILS(EXPECT_FLOAT_EQ(layer_impl->opacity(), + layer->opacity())); + RETURN_IF_EXPECTATION_FAILS(EXPECT_EQ(layer_impl->have_wheel_event_handlers(), + layer->have_wheel_event_handlers())); + RETURN_IF_EXPECTATION_FAILS( + EXPECT_EQ(layer_impl->touch_event_handler_region(), + layer->touch_event_handler_region())); + + for (size_t i = 0; i < layer_impl->children().size(); ++i) { + RETURN_IF_EXPECTATION_FAILS( + EXPECT_TRUE(LayerTreesMatch(layer_impl->children()[i], + layer->children()[i]))); + } + + return true; +#undef RETURN_IF_EXPECTATION_FAILS +} + +} // namespace + +class LayerTreeJsonParserSanityCheck : public testing::Test { +}; + +TEST_F(LayerTreeJsonParserSanityCheck, Basic) { + FakeImplProxy proxy; + FakeLayerTreeHostImpl host_impl(&proxy); + LayerTreeImpl* tree = host_impl.active_tree(); + + scoped_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1)); + scoped_ptr<LayerImpl> parent(LayerImpl::Create(tree, 2)); + scoped_ptr<LayerImpl> child(LayerImpl::Create(tree, 3)); + + root_impl->SetBounds(gfx::Size(100, 100)); + parent->SetBounds(gfx::Size(50, 50)); + child->SetBounds(gfx::Size(40, 40)); + + parent->SetPosition(gfx::Point(25, 25)); + + child->SetHaveWheelEventHandlers(true); + + parent->AddChild(child.Pass()); + root_impl->AddChild(parent.Pass()); + tree->SetRootLayer(root_impl.Pass()); + + std::string json = host_impl.LayerTreeAsJson(); + scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); + ASSERT_TRUE(root); + EXPECT_TRUE(LayerTreesMatch(host_impl.RootLayer(), root.get())); +} + +TEST_F(LayerTreeJsonParserSanityCheck, EventHandlerRegions) { + FakeImplProxy proxy; + FakeLayerTreeHostImpl host_impl(&proxy); + LayerTreeImpl* tree = host_impl.active_tree(); + + scoped_ptr<LayerImpl> root_impl(LayerImpl::Create(tree, 1)); + scoped_ptr<LayerImpl> touch_layer(LayerImpl::Create(tree, 2)); + + root_impl->SetBounds(gfx::Size(100, 100)); + touch_layer->SetBounds(gfx::Size(50, 50)); + + cc::Region touch_region; + touch_region.Union(gfx::Rect(10, 10, 20, 30)); + touch_region.Union(gfx::Rect(40, 10, 20, 20)); + touch_layer->SetTouchEventHandlerRegion(touch_region); + + root_impl->AddChild(touch_layer.Pass()); + tree->SetRootLayer(root_impl.Pass()); + + std::string json = host_impl.LayerTreeAsJson(); + scoped_refptr<Layer> root = ParseTreeFromJson(json, NULL); + ASSERT_TRUE(root); + EXPECT_TRUE(LayerTreesMatch(host_impl.RootLayer(), root.get())); +} + +} // namespace cc diff --git a/cc/trees/layer_tree_host_common_perftest.cc b/cc/trees/layer_tree_host_common_perftest.cc index 2152533..d940709 100644 --- a/cc/trees/layer_tree_host_common_perftest.cc +++ b/cc/trees/layer_tree_host_common_perftest.cc @@ -164,6 +164,18 @@ TEST_F(CalcDrawPropsMainTest, HeavyPage) { RunCalcDrawProps(); } +TEST_F(CalcDrawPropsMainTest, TouchRegionLight) { + SetTestName("touch_region_light"); + ReadTestFile("touch_region_light"); + RunCalcDrawProps(); +} + +TEST_F(CalcDrawPropsMainTest, TouchRegionHeavy) { + SetTestName("touch_region_heavy"); + ReadTestFile("touch_region_heavy"); + RunCalcDrawProps(); +} + TEST_F(CalcDrawPropsImplTest, TenTen) { SetTestName("10_10"); ReadTestFile("10_10_layer_tree"); @@ -176,5 +188,17 @@ TEST_F(CalcDrawPropsImplTest, HeavyPage) { RunCalcDrawProps(); } +TEST_F(CalcDrawPropsImplTest, TouchRegionLight) { + SetTestName("touch_region_light"); + ReadTestFile("touch_region_light"); + RunCalcDrawProps(); +} + +TEST_F(CalcDrawPropsImplTest, TouchRegionHeavy) { + SetTestName("touch_region_heavy"); + ReadTestFile("touch_region_heavy"); + RunCalcDrawProps(); +} + } // namespace } // namespace cc |