Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: components/viz/hittest/display_hittest_data.cc

Issue 2908783002: WIP Hittest Component.
Patch Set: improvements from reviewer comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "display_hittest_data.h"
rjkroege 2017/06/07 17:16:45 wrong order
gklassen 2017/06/07 20:04:43 Done.
6 #include "base/logging.h"
7 #include "components/viz/hittest/hittest_aggregator.h"
8
9 namespace viz {
10
11 namespace {
12 constexpr int kInitialSize = 1024;
13 constexpr int kEndOfList = -1;
14 }
15
16 DisplayHittestData::DisplayHittestData() {}
17 DisplayHittestData::~DisplayHittestData() {}
18
19 DisplayHittestData* DisplayHittestData::Create() {
20 return Create(kInitialSize);
21 }
22 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.
23 int cb = sizeof(DisplayHittestData) + size * sizeof(Element);
24 DisplayHittestData* instance = (DisplayHittestData*)::operator new(cb);
25 instance->size_ = size;
26 return instance;
27 }
28
29 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.
30 cc::SurfaceId root_surface_id) {
31 Append(map, root_surface_id);
32 regions_[count_].child_count_ = kEndOfList;
33 }
34
35 void DisplayHittestData::Append(const HittestDataMap& map,
36 cc::SurfaceId surface_id) {
37 auto search = map.find(surface_id);
38 if (search == map.end()) {
39 // referenced surface not found!
40 return;
41 }
42 hittest::mojom::HittestData* hittest_data = search->second.get();
43
44 int index = count_++;
45
46 regions_[index].surface_id_ = hittest_data->surface_id_;
47 regions_[index].flags_ = hittest_data->flags_;
48 regions_[index].rect_ = hittest_data->rect_;
49 regions_[index].transform_ = hittest_data->transform_;
50
51 for (auto& region : hittest_data->regions_) {
52 Append(map, region);
53 if (region->flags_ == hittest::mojom::HittestRegionFlags::HITTEST_SURFACE) {
54 Append(map, region->surface_id_);
55 }
56 }
57
58 regions_[index].child_count_ = count_ - index;
59 }
60
61 void DisplayHittestData::Append(
62 const HittestDataMap& map,
63 const hittest::mojom::HittestRegionPtr& region) {
64 int index = count_++;
65
66 regions_[index].surface_id_ = region->surface_id_;
67 regions_[index].flags_ = region->flags_;
68 regions_[index].rect_ = region->rect_;
69 regions_[index].transform_ = region->transform_;
70
71 if (region->flags_ == hittest::mojom::HittestRegionFlags::HITTEST_SURFACE) {
72 Append(map, region->surface_id_);
73 }
74
75 regions_[index].child_count_ = count_ - index;
76 }
77
78 void DisplayHittestData::Swap() {
79 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.
80 count_ = 0;
81 }
82
83 } // namespace viz
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698