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

Side by Side Diff: Source/core/layout/HitTestCache.cpp

Issue 1177123003: Revert "Implement a Hit Test Cache for same point hits." (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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
« no previous file with comments | « Source/core/layout/HitTestCache.h ('k') | Source/core/layout/HitTestRequest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015 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 "config.h"
6 #include "core/layout/HitTestCache.h"
7
8 #include "public/platform/Platform.h"
9
10 namespace blink {
11
12 bool HitTestCache::lookupCachedResult(HitTestResult& hitResult, uint64_t domTree Version)
13 {
14 bool result = false;
15 HitHistogramMetric metric = HitHistogramMetric::MISS;
16 if (hitResult.hitTestRequest().avoidCache()) {
17 metric = HitHistogramMetric::MISS_EXPLICIT_AVOID;
18 // For now we don't support rect based hit results.
19 } else if (domTreeVersion == m_domTreeVersion && !hitResult.hitTestLocation( ).isRectBasedTest()) {
20 for (const auto& cachedItem : m_items) {
21 if (cachedItem.validityRect().contains(hitResult.hitTestLocation().p oint())) {
22 if (hitResult.hitTestRequest().equalForCacheability(cachedItem.h itTestRequest())) {
23 metric = hitResult.hitTestLocation().point() == cachedItem.h itTestLocation().point() ? HitHistogramMetric::HIT_EXACT_MATCH : HitHistogramMet ric::HIT_REGION_MATCH;
24 result = true;
25 hitResult = cachedItem;
26 break;
27 }
28 metric = HitHistogramMetric::MISS_VALIDITY_RECT_MATCHES;
29 }
30 }
31 }
32 Platform::current()->histogramEnumeration("Event.HitTest", static_cast<int>( metric), static_cast<int>(HitHistogramMetric::MAX_HIT_METRIC));
33 return result;
34 }
35
36 void HitTestCache::verifyCachedResult(const HitTestResult& expected, const HitTe stResult& actual)
37 {
38 bool pointMatch = actual.hitTestLocation().point() == expected.hitTestLocati on().point();
39
40 ValidityHistogramMetric metric;
41 if (!actual.equalForCacheability(expected)) {
42 if (pointMatch) {
43 metric = expected.hitTestLocation().isRectBasedTest() ? ValidityHist ogramMetric::INCORRECT_RECT_BASED_EXACT_MATCH : ValidityHistogramMetric::INCORRE CT_POINT_EXACT_MATCH;
44 } else {
45 metric = expected.hitTestLocation().isRectBasedTest() ? ValidityHist ogramMetric::INCORRECT_RECT_BASED_REGION : ValidityHistogramMetric::INCORRECT_PO INT_REGION;
46 }
47
48 // ASSERT that the cache hit is the same as the actual result.
49 ASSERT_NOT_REACHED();
50 } else {
51 metric = pointMatch ? ValidityHistogramMetric::VALID_EXACT_MATCH : Valid ityHistogramMetric::VALID_REGION;
52 }
53 Platform::current()->histogramEnumeration("Event.HitTestValidity", static_ca st<int>(metric), static_cast<int>(ValidityHistogramMetric::MAX_VALIDITY_METRIC)) ;
54 }
55
56 void HitTestCache::addCachedResult(const HitTestResult& result, uint64_t domTree Version)
57 {
58 // For now we don't support rect based hit results.
59 if (result.hitTestLocation().isRectBasedTest())
60 return;
61 if (domTreeVersion != m_domTreeVersion)
62 clear();
63 if (m_items.size() < HIT_TEST_CACHE_SIZE)
64 m_items.resize(m_updateIndex + 1);
65
66 m_items.at(m_updateIndex).cacheValues(result);
67 m_domTreeVersion = domTreeVersion;
68
69 m_updateIndex++;
70 if (m_updateIndex >= HIT_TEST_CACHE_SIZE)
71 m_updateIndex = 0;
72 }
73
74 void HitTestCache::clear()
75 {
76 m_updateIndex = 0;
77 m_items.clear();
78 }
79
80 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/HitTestCache.h ('k') | Source/core/layout/HitTestRequest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698