summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlistair Strachan <alistair.strachan@imgtec.com>2017-06-07 16:34:44 -0700
committerFabien Sanglard <sanglardf@google.com>2017-06-15 00:44:01 +0000
commitc175253b6d0738aec6235ef1c2e723ad36fcd346 (patch)
tree4727c105293e239028eae5a7ce5a77b7e6b101e4
parentfd43dc6723e721c41fb5e0d84258672a036cc006 (diff)
downloadnative-c175253b6d0738aec6235ef1c2e723ad36fcd346.tar.gz
Fix getDisplayInfo() for SurfaceFlinger in HWC2 mode.
When HWC2 mode is enabled in SurfaceFlinger, the getDisplayInfo() function would fail to return the correct active mode in some cases. This bug was only noticable if you had more than one mode registered by the HWC2 backend. The SurfaceComposerClient::getDisplayInfo() function works by calling getDisplayConfigs(), and de-referencing the config at the index returned by getActiveConfig(). The active config returned was correct, but the getDisplayConfigs() array was not properly sorted. Tracing this back, this problem occurs because the configId is stored alongside the config in an unordered_map, so when this is converted to a vector and the configId is discarded, the conversion must be sorted correctly; it can't just be the hash order returned from the unordered_map. There are a few ways to fix this problem, but the easiest was to nip the problem in the bud by not allowing an unsorted list of configs to exist on the base HWC2 class. It may be better still to just get rid of the map and go back to a vector, as this data is more often used as an array than it is indexed by configId, so the use of an unordered_map was probably overkill. Change-Id: Ibfb015a6d9b49c870f37a1c892f15f90abbd1e2c Bug: 62617569 Test: ./cts-tradefed run cts -m CtsViewTestCases -t android.view.cts.DisplayRefreshRateTest#testRefreshRate
-rw-r--r--services/surfaceflinger/DisplayHardware/HWC2.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/services/surfaceflinger/DisplayHardware/HWC2.h b/services/surfaceflinger/DisplayHardware/HWC2.h
index 97582a7a99..7f26e56a63 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2.h
+++ b/services/surfaceflinger/DisplayHardware/HWC2.h
@@ -35,6 +35,7 @@
#include <unordered_map>
#include <unordered_set>
#include <vector>
+#include <map>
namespace android {
class Fence;
@@ -283,7 +284,9 @@ private:
bool mIsConnected;
DisplayType mType;
std::unordered_map<hwc2_layer_t, std::weak_ptr<Layer>> mLayers;
- std::unordered_map<hwc2_config_t, std::shared_ptr<const Config>> mConfigs;
+ // The ordering in this map matters, for getConfigs(), when it is
+ // converted to a vector
+ std::map<hwc2_config_t, std::shared_ptr<const Config>> mConfigs;
};
// Convenience C++ class to access hwc2_device_t Layer functions directly.