summaryrefslogtreecommitdiff
path: root/libs/hwui/DeviceInfo.cpp
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2019-04-11 16:11:24 -0700
committerJohn Reck <jreck@google.com>2019-04-18 14:20:56 -0700
commitcf185f5b0d30516ecb34350a585aed7f7d4e0672 (patch)
tree4235b69aa096175a3e01db7ea62e7c1bcab30603 /libs/hwui/DeviceInfo.cpp
parentc4a3f5c3777da82d6f452d26f684a65e97ed963c (diff)
Dynamically adjust renderahead
Tracks refresh rate changes and adjusts renderahead based off of the active refresh rate. Default is 60hz = 0 render ahead & > 70hz is render ahead 1 Bug: 127822449 Test: systraced stuff Change-Id: I9849aa065262f21f7602d44cd1761373279dc28d
Diffstat (limited to 'libs/hwui/DeviceInfo.cpp')
-rw-r--r--libs/hwui/DeviceInfo.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/libs/hwui/DeviceInfo.cpp b/libs/hwui/DeviceInfo.cpp
index cf5d7ce3f738..0a9d965d0444 100644
--- a/libs/hwui/DeviceInfo.cpp
+++ b/libs/hwui/DeviceInfo.cpp
@@ -45,12 +45,12 @@ static constexpr android::DisplayInfo sDummyDisplay{
1920, // viewportH
};
-const DeviceInfo* DeviceInfo::get() {
+DeviceInfo* DeviceInfo::get() {
static DeviceInfo sDeviceInfo;
return &sDeviceInfo;
}
-DisplayInfo QueryDisplayInfo() {
+static DisplayInfo QueryDisplayInfo() {
if (Properties::isolatedProcess) {
return sDummyDisplay;
}
@@ -65,6 +65,27 @@ DisplayInfo QueryDisplayInfo() {
return displayInfo;
}
+static float QueryMaxRefreshRate() {
+ if (Properties::isolatedProcess) {
+ return sDummyDisplay.fps;
+ }
+
+ const sp<IBinder> token = SurfaceComposerClient::getInternalDisplayToken();
+ LOG_ALWAYS_FATAL_IF(token == nullptr,
+ "Failed to get display info because internal display is disconnected");
+
+ Vector<DisplayInfo> configs;
+ configs.reserve(10);
+ status_t status = SurfaceComposerClient::getDisplayConfigs(token, &configs);
+ LOG_ALWAYS_FATAL_IF(status, "Failed to getDisplayConfigs, error %d", status);
+ LOG_ALWAYS_FATAL_IF(configs.size() == 0, "getDisplayConfigs returned 0 configs?");
+ float max = 0.0f;
+ for (auto& info : configs) {
+ max = std::max(max, info.fps);
+ }
+ return max;
+}
+
static void queryWideColorGamutPreference(sk_sp<SkColorSpace>* colorSpace, SkColorType* colorType) {
if (Properties::isolatedProcess) {
*colorSpace = SkColorSpace::MakeSRGB();
@@ -103,7 +124,7 @@ static void queryWideColorGamutPreference(sk_sp<SkColorSpace>* colorSpace, SkCol
}
}
-DeviceInfo::DeviceInfo() {
+DeviceInfo::DeviceInfo() : mMaxRefreshRate(QueryMaxRefreshRate()) {
#if HWUI_NULL_GPU
mMaxTextureSize = NULL_GPU_MAX_TEXTURE_SIZE;
#else
@@ -119,7 +140,11 @@ int DeviceInfo::maxTextureSize() const {
}
void DeviceInfo::setMaxTextureSize(int maxTextureSize) {
- const_cast<DeviceInfo*>(DeviceInfo::get())->mMaxTextureSize = maxTextureSize;
+ DeviceInfo::get()->mMaxTextureSize = maxTextureSize;
+}
+
+void DeviceInfo::onDisplayConfigChanged() {
+ mDisplayInfo = QueryDisplayInfo();
}
} /* namespace uirenderer */