frameworks/native
Revision | 0a07fe7e1dfa610b0dae742278be88103be798b8 (tree) |
---|---|
Time | 2021-12-26 16:20:01 |
Author | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
Determine the density according to DisplayDevice (q-x86)
Previously we use hwConfig to get the dimension of the display.
However, there may be several hwConfig modes of a display. Only
the first mode is used to calculate the density. But first mode
may not be the default mode. Hence the calculated density may not
be suitable to the default mode.
Now use the dimension of the DisplayDevice to calculate the density.
(q-x86) Changelog:
@@ -845,11 +845,11 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& displayToken, | ||
845 | 845 | public: |
846 | 846 | static float getEmuDensity() { |
847 | 847 | return getDensityFromProperty("qemu.sf.lcd_density"); } |
848 | - static float getBuildDensity(const DisplayInfo& info) { | |
848 | + static float getBuildDensity(const sp<const DisplayDevice>& hw) { | |
849 | 849 | static float density = getDensityFromProperty("ro.sf.lcd_density"); |
850 | 850 | #if defined(__i386__) || defined(__x86_64__) |
851 | - if (density == 0.0f) { | |
852 | - uint32_t area = info.w * info.h; | |
851 | + if (density == 0.0f && hw) { | |
852 | + uint32_t area = hw->getWidth() * hw->getHeight(); | |
853 | 853 | if (area <= 800 * 480) { |
854 | 854 | density = 120.0f; |
855 | 855 | } else if (area <= 1024 * 600) { |
@@ -863,7 +863,7 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& displayToken, | ||
863 | 863 | } else { |
864 | 864 | density = 320.0f; |
865 | 865 | } |
866 | - ALOGI("auto set density to %f", density); | |
866 | + ALOGI("auto set density to %f for primary display %d x %d", density, hw->getWidth(), hw->getHeight()); | |
867 | 867 | } |
868 | 868 | #endif |
869 | 869 | return density; |
@@ -879,16 +879,14 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& displayToken, | ||
879 | 879 | float ydpi = hwConfig->getDpiY(); |
880 | 880 | info.w = hwConfig->getWidth(); |
881 | 881 | info.h = hwConfig->getHeight(); |
882 | - | |
883 | - info.w = hwConfig->getWidth(); | |
884 | - info.h = hwConfig->getHeight(); | |
885 | 882 | // Default display viewport to display width and height |
886 | 883 | info.viewportW = info.w; |
887 | 884 | info.viewportH = info.h; |
888 | 885 | |
889 | 886 | if (displayId == getInternalDisplayIdLocked()) { |
887 | + const auto display = getDefaultDisplayDeviceLocked(); | |
890 | 888 | // The density of the device is provided by a build property |
891 | - float density = Density::getBuildDensity(info) / 160.0f; | |
889 | + float density = Density::getBuildDensity(display) / 160.0f; | |
892 | 890 | if (density == 0) { |
893 | 891 | // the build doesn't provide a density -- this is wrong! |
894 | 892 | // use xdpi instead |
@@ -903,7 +901,6 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& displayToken, | ||
903 | 901 | info.density = density; |
904 | 902 | |
905 | 903 | // TODO: this needs to go away (currently needed only by webkit) |
906 | - const auto display = getDefaultDisplayDeviceLocked(); | |
907 | 904 | info.orientation = display ? display->getOrientation() : 0; |
908 | 905 | |
909 | 906 | // This is for screenrecord |