Chromium Code Reviews| Index: components/viz/hittest/display_hittest_data.cc |
| diff --git a/components/viz/hittest/display_hittest_data.cc b/components/viz/hittest/display_hittest_data.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8020fce8876765654a54bff2f1def4002e43b3d7 |
| --- /dev/null |
| +++ b/components/viz/hittest/display_hittest_data.cc |
| @@ -0,0 +1,83 @@ |
| +// Copyright 2017 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 "display_hittest_data.h" |
|
rjkroege
2017/06/07 17:16:45
wrong order
gklassen
2017/06/07 20:04:43
Done.
|
| +#include "base/logging.h" |
| +#include "components/viz/hittest/hittest_aggregator.h" |
| + |
| +namespace viz { |
| + |
| +namespace { |
| +constexpr int kInitialSize = 1024; |
| +constexpr int kEndOfList = -1; |
| +} |
| + |
| +DisplayHittestData::DisplayHittestData() {} |
| +DisplayHittestData::~DisplayHittestData() {} |
| + |
| +DisplayHittestData* DisplayHittestData::Create() { |
| + return Create(kInitialSize); |
| +} |
| +DisplayHittestData* DisplayHittestData::Create(int size) { |
|
rjkroege
2017/06/07 17:16:45
I think that you need to organize this a bit diffe
gklassen
2017/06/07 20:04:43
Acknowledged.
|
| + int cb = sizeof(DisplayHittestData) + size * sizeof(Element); |
| + DisplayHittestData* instance = (DisplayHittestData*)::operator new(cb); |
| + instance->size_ = size; |
| + return instance; |
| +} |
| + |
| +void DisplayHittestData::Build(const HittestDataMap& map, |
|
rjkroege
2017/06/07 17:16:45
this looks like it's missing some functionality?
gklassen
2017/06/07 20:04:43
Done.
|
| + cc::SurfaceId root_surface_id) { |
| + Append(map, root_surface_id); |
| + regions_[count_].child_count_ = kEndOfList; |
| +} |
| + |
| +void DisplayHittestData::Append(const HittestDataMap& map, |
| + cc::SurfaceId surface_id) { |
| + auto search = map.find(surface_id); |
| + if (search == map.end()) { |
| + // referenced surface not found! |
| + return; |
| + } |
| + hittest::mojom::HittestData* hittest_data = search->second.get(); |
| + |
| + int index = count_++; |
| + |
| + regions_[index].surface_id_ = hittest_data->surface_id_; |
| + regions_[index].flags_ = hittest_data->flags_; |
| + regions_[index].rect_ = hittest_data->rect_; |
| + regions_[index].transform_ = hittest_data->transform_; |
| + |
| + for (auto& region : hittest_data->regions_) { |
| + Append(map, region); |
| + if (region->flags_ == hittest::mojom::HittestRegionFlags::HITTEST_SURFACE) { |
| + Append(map, region->surface_id_); |
| + } |
| + } |
| + |
| + regions_[index].child_count_ = count_ - index; |
| +} |
| + |
| +void DisplayHittestData::Append( |
| + const HittestDataMap& map, |
| + const hittest::mojom::HittestRegionPtr& region) { |
| + int index = count_++; |
| + |
| + regions_[index].surface_id_ = region->surface_id_; |
| + regions_[index].flags_ = region->flags_; |
| + regions_[index].rect_ = region->rect_; |
| + regions_[index].transform_ = region->transform_; |
| + |
| + if (region->flags_ == hittest::mojom::HittestRegionFlags::HITTEST_SURFACE) { |
| + Append(map, region->surface_id_); |
| + } |
| + |
| + regions_[index].child_count_ = count_ - index; |
| +} |
| + |
| +void DisplayHittestData::Swap() { |
| + front_offset_ = front_offset_ == 0 ? size_ << 2 : 0; |
|
rjkroege
2017/06/07 17:16:45
you could probably use division. compiler should b
gklassen
2017/06/07 20:04:43
Done.
|
| + count_ = 0; |
| +} |
| + |
| +} // namespace viz |