Commit 28674759 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

viz: removes VizHitTestQuery::hit_test_data_size_

And replaces with hit_test_data_.size().

BUG=none
TEST=none

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Change-Id: I0bd21c5cfe5ced5df871dc9ed419a291b4633018
Reviewed-on: https://chromium-review.googlesource.com/1239168Reviewed-by: default avatarRia Jiang <riajiang@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593352}
parent e2516381
...@@ -24,9 +24,9 @@ bool RegionMatchEventSource(EventSource event_source, uint32_t flags) { ...@@ -24,9 +24,9 @@ bool RegionMatchEventSource(EventSource event_source, uint32_t flags) {
HitTestRegionFlags::kHitTestTouch)) != 0u; HitTestRegionFlags::kHitTestTouch)) != 0u;
} }
bool CheckChildCount(int32_t child_count, uint32_t child_count_max) { bool CheckChildCount(int32_t child_count, size_t child_count_max) {
return (child_count >= 0) && return (child_count >= 0) &&
(static_cast<uint32_t>(child_count) < child_count_max); (static_cast<size_t>(child_count) < child_count_max);
} }
} // namespace } // namespace
...@@ -40,18 +40,16 @@ void HitTestQuery::OnAggregatedHitTestRegionListUpdated( ...@@ -40,18 +40,16 @@ void HitTestQuery::OnAggregatedHitTestRegionListUpdated(
const std::vector<AggregatedHitTestRegion>& hit_test_data) { const std::vector<AggregatedHitTestRegion>& hit_test_data) {
hit_test_data_.clear(); hit_test_data_.clear();
hit_test_data_ = hit_test_data; hit_test_data_ = hit_test_data;
hit_test_data_size_ = hit_test_data.size();
} }
Target HitTestQuery::FindTargetForLocation( Target HitTestQuery::FindTargetForLocation(
EventSource event_source, EventSource event_source,
const gfx::PointF& location_in_root) const { const gfx::PointF& location_in_root) const {
base::ElapsedTimer target_timer; if (hit_test_data_.empty())
return Target();
base::ElapsedTimer target_timer;
Target target; Target target;
if (!hit_test_data_size_)
return target;
FindTargetInRegionForLocation(event_source, location_in_root, 0, &target); FindTargetInRegionForLocation(event_source, location_in_root, 0, &target);
UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES("Event.VizHitTest.TargetTimeUs", UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES("Event.VizHitTest.TargetTimeUs",
target_timer.Elapsed(), target_timer.Elapsed(),
...@@ -67,7 +65,7 @@ bool HitTestQuery::TransformLocationForTarget( ...@@ -67,7 +65,7 @@ bool HitTestQuery::TransformLocationForTarget(
gfx::PointF* transformed_location) const { gfx::PointF* transformed_location) const {
base::ElapsedTimer transform_timer; base::ElapsedTimer transform_timer;
if (!hit_test_data_size_) if (hit_test_data_.empty())
return false; return false;
if (target_ancestors.size() == 0u || if (target_ancestors.size() == 0u ||
...@@ -90,7 +88,7 @@ bool HitTestQuery::TransformLocationForTarget( ...@@ -90,7 +88,7 @@ bool HitTestQuery::TransformLocationForTarget(
bool HitTestQuery::GetTransformToTarget(const FrameSinkId& target, bool HitTestQuery::GetTransformToTarget(const FrameSinkId& target,
gfx::Transform* transform) const { gfx::Transform* transform) const {
if (!hit_test_data_size_) if (hit_test_data_.empty())
return false; return false;
return GetTransformToTargetRecursively(target, 0, transform); return GetTransformToTargetRecursively(target, 0, transform);
...@@ -110,7 +108,7 @@ bool HitTestQuery::ContainsActiveFrameSinkId( ...@@ -110,7 +108,7 @@ bool HitTestQuery::ContainsActiveFrameSinkId(
bool HitTestQuery::FindTargetInRegionForLocation( bool HitTestQuery::FindTargetInRegionForLocation(
EventSource event_source, EventSource event_source,
const gfx::PointF& location_in_parent, const gfx::PointF& location_in_parent,
uint32_t region_index, size_t region_index,
Target* target) const { Target* target) const {
gfx::PointF location_transformed(location_in_parent); gfx::PointF location_transformed(location_in_parent);
...@@ -132,11 +130,12 @@ bool HitTestQuery::FindTargetInRegionForLocation( ...@@ -132,11 +130,12 @@ bool HitTestQuery::FindTargetInRegionForLocation(
} }
const int32_t region_child_count = hit_test_data_[region_index].child_count; const int32_t region_child_count = hit_test_data_[region_index].child_count;
if (!CheckChildCount(region_child_count, hit_test_data_size_ - region_index)) if (!CheckChildCount(region_child_count,
hit_test_data_.size() - region_index))
return false; return false;
uint32_t child_region = region_index + 1; size_t child_region = region_index + 1;
uint32_t child_region_end = child_region + region_child_count; size_t child_region_end = child_region + region_child_count;
gfx::PointF location_in_target = gfx::PointF location_in_target =
location_transformed - location_transformed -
hit_test_data_[region_index].rect.OffsetFromOrigin(); hit_test_data_[region_index].rect.OffsetFromOrigin();
...@@ -171,7 +170,7 @@ bool HitTestQuery::TransformLocationForTargetRecursively( ...@@ -171,7 +170,7 @@ bool HitTestQuery::TransformLocationForTargetRecursively(
EventSource event_source, EventSource event_source,
const std::vector<FrameSinkId>& target_ancestors, const std::vector<FrameSinkId>& target_ancestors,
size_t target_ancestor, size_t target_ancestor,
uint32_t region_index, size_t region_index,
gfx::PointF* location_in_target) const { gfx::PointF* location_in_target) const {
const uint32_t flags = hit_test_data_[region_index].flags; const uint32_t flags = hit_test_data_[region_index].flags;
if ((flags & HitTestRegionFlags::kHitTestChildSurface) == 0u && if ((flags & HitTestRegionFlags::kHitTestChildSurface) == 0u &&
...@@ -186,11 +185,13 @@ bool HitTestQuery::TransformLocationForTargetRecursively( ...@@ -186,11 +185,13 @@ bool HitTestQuery::TransformLocationForTargetRecursively(
return true; return true;
const int32_t region_child_count = hit_test_data_[region_index].child_count; const int32_t region_child_count = hit_test_data_[region_index].child_count;
if (!CheckChildCount(region_child_count, hit_test_data_size_ - region_index)) if (!CheckChildCount(region_child_count,
hit_test_data_.size() - region_index)) {
return false; return false;
}
uint32_t child_region = region_index + 1; size_t child_region = region_index + 1;
uint32_t child_region_end = child_region + region_child_count; size_t child_region_end = child_region + region_child_count;
while (child_region < child_region_end) { while (child_region < child_region_end) {
if (hit_test_data_[child_region].frame_sink_id == if (hit_test_data_[child_region].frame_sink_id ==
target_ancestors[target_ancestor - 1]) { target_ancestors[target_ancestor - 1]) {
...@@ -212,7 +213,7 @@ bool HitTestQuery::TransformLocationForTargetRecursively( ...@@ -212,7 +213,7 @@ bool HitTestQuery::TransformLocationForTargetRecursively(
bool HitTestQuery::GetTransformToTargetRecursively( bool HitTestQuery::GetTransformToTargetRecursively(
const FrameSinkId& target, const FrameSinkId& target,
uint32_t region_index, size_t region_index,
gfx::Transform* transform) const { gfx::Transform* transform) const {
// TODO(riajiang): Cache the matrix product such that the transform can be // TODO(riajiang): Cache the matrix product such that the transform can be
// found immediately. // found immediately.
...@@ -224,11 +225,13 @@ bool HitTestQuery::GetTransformToTargetRecursively( ...@@ -224,11 +225,13 @@ bool HitTestQuery::GetTransformToTargetRecursively(
} }
const int32_t region_child_count = hit_test_data_[region_index].child_count; const int32_t region_child_count = hit_test_data_[region_index].child_count;
if (!CheckChildCount(region_child_count, hit_test_data_size_ - region_index)) if (!CheckChildCount(region_child_count,
hit_test_data_.size() - region_index)) {
return false; return false;
}
uint32_t child_region = region_index + 1; size_t child_region = region_index + 1;
uint32_t child_region_end = child_region + region_child_count; size_t child_region_end = child_region + region_child_count;
while (child_region < child_region_end) { while (child_region < child_region_end) {
gfx::Transform transform_to_child; gfx::Transform transform_to_child;
if (GetTransformToTargetRecursively(target, child_region, if (GetTransformToTargetRecursively(target, child_region,
......
...@@ -108,7 +108,7 @@ class VIZ_HOST_EXPORT HitTestQuery { ...@@ -108,7 +108,7 @@ class VIZ_HOST_EXPORT HitTestQuery {
// |location_in_parent| is in the coordinate space of |region_index|'s parent. // |location_in_parent| is in the coordinate space of |region_index|'s parent.
bool FindTargetInRegionForLocation(EventSource event_source, bool FindTargetInRegionForLocation(EventSource event_source,
const gfx::PointF& location_in_parent, const gfx::PointF& location_in_parent,
uint32_t region_index, size_t region_index,
Target* target) const; Target* target) const;
// Transform |location_in_target| to be in |region_index|'s coordinate space. // Transform |location_in_target| to be in |region_index|'s coordinate space.
...@@ -118,17 +118,16 @@ class VIZ_HOST_EXPORT HitTestQuery { ...@@ -118,17 +118,16 @@ class VIZ_HOST_EXPORT HitTestQuery {
EventSource event_source, EventSource event_source,
const std::vector<FrameSinkId>& target_ancestors, const std::vector<FrameSinkId>& target_ancestors,
size_t target_ancestor, size_t target_ancestor,
uint32_t region_index, size_t region_index,
gfx::PointF* location_in_target) const; gfx::PointF* location_in_target) const;
bool GetTransformToTargetRecursively(const FrameSinkId& target, bool GetTransformToTargetRecursively(const FrameSinkId& target,
uint32_t region_index, size_t region_index,
gfx::Transform* transform) const; gfx::Transform* transform) const;
void ReceivedBadMessageFromGpuProcess() const; void ReceivedBadMessageFromGpuProcess() const;
std::vector<AggregatedHitTestRegion> hit_test_data_; std::vector<AggregatedHitTestRegion> hit_test_data_;
uint32_t hit_test_data_size_ = 0;
// Log bad message and shut down Viz process when it is compromised. // Log bad message and shut down Viz process when it is compromised.
base::RepeatingClosure bad_message_gpu_callback_; base::RepeatingClosure bad_message_gpu_callback_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment