diff options
author | Jesse Hall <jessehall@google.com> | 2013-04-05 13:44:52 -0700 |
---|---|---|
committer | Jesse Hall <jessehall@google.com> | 2013-04-05 14:38:52 -0700 |
commit | 1c569c4d45f89ec05abf8f8fe3a560e68bf39a8e (patch) | |
tree | 10dbbd7692d2138f1f2b227efa4a2514898ff2a5 /services | |
parent | 39c24a20bbc697630d2b92c251b70c04d6f9d00c (diff) | |
download | frameworks_native-1c569c4d45f89ec05abf8f8fe3a560e68bf39a8e.zip frameworks_native-1c569c4d45f89ec05abf8f8fe3a560e68bf39a8e.tar.gz frameworks_native-1c569c4d45f89ec05abf8f8fe3a560e68bf39a8e.tar.bz2 |
Tell HWComposer the dimensions of virtual displays
HWComposer queries the HWC for dimensions of physical displays, but
can't do that for virtual displays. The dimensions are used to set the
display frame of the framebuffer target layer passed to HWC, and
implicitly the dimensions of the virtual display.
Bug: 8316155
Change-Id: I9cbd2530d2fa878f86128a1472def520b5d694a5
Diffstat (limited to 'services')
-rw-r--r-- | services/surfaceflinger/DisplayHardware/HWComposer.cpp | 36 | ||||
-rw-r--r-- | services/surfaceflinger/DisplayHardware/HWComposer.h | 3 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 9 |
3 files changed, 34 insertions, 14 deletions
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp index a29c068..3f00f07 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp +++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp @@ -38,6 +38,8 @@ #include <hardware/hardware.h> #include <hardware/hwcomposer.h> +#include <android/configuration.h> + #include <cutils/log.h> #include <cutils/properties.h> @@ -297,6 +299,11 @@ void HWComposer::hotplug(int disp, int connected) { mEventHandler.onHotplugReceived(disp, bool(connected)); } +static float getDefaultDensity(uint32_t height) { + if (height >= 1080) return ACONFIGURATION_DENSITY_XHIGH; + else return ACONFIGURATION_DENSITY_TV; +} + static const uint32_t DISPLAY_ATTRIBUTES[] = { HWC_DISPLAY_VSYNC_PERIOD, HWC_DISPLAY_WIDTH, @@ -307,10 +314,6 @@ static const uint32_t DISPLAY_ATTRIBUTES[] = { }; #define NUM_DISPLAY_ATTRIBUTES (sizeof(DISPLAY_ATTRIBUTES) / sizeof(DISPLAY_ATTRIBUTES)[0]) -// http://developer.android.com/reference/android/util/DisplayMetrics.html -#define ANDROID_DENSITY_TV 213 -#define ANDROID_DENSITY_XHIGH 320 - status_t HWComposer::queryDisplayProperties(int disp) { LOG_ALWAYS_FATAL_IF(!mHwc || !hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)); @@ -364,18 +367,26 @@ status_t HWComposer::queryDisplayProperties(int disp) { mDisplayData[disp].format = HAL_PIXEL_FORMAT_RGBA_8888; mDisplayData[disp].connected = true; if (mDisplayData[disp].xdpi == 0.0f || mDisplayData[disp].ydpi == 0.0f) { - // is there anything smarter we can do? - if (h >= 1080) { - mDisplayData[disp].xdpi = ANDROID_DENSITY_XHIGH; - mDisplayData[disp].ydpi = ANDROID_DENSITY_XHIGH; - } else { - mDisplayData[disp].xdpi = ANDROID_DENSITY_TV; - mDisplayData[disp].ydpi = ANDROID_DENSITY_TV; - } + float dpi = getDefaultDensity(h); + mDisplayData[disp].xdpi = dpi; + mDisplayData[disp].ydpi = dpi; } return NO_ERROR; } +status_t HWComposer::setVirtualDisplayProperties(int32_t id, + uint32_t w, uint32_t h, uint32_t format) { + if (id < VIRTUAL_DISPLAY_ID_BASE || id >= int32_t(mNumDisplays) || + !mAllocatedDisplayIDs.hasBit(id)) { + return BAD_INDEX; + } + mDisplayData[id].width = w; + mDisplayData[id].height = h; + mDisplayData[id].format = format; + mDisplayData[id].xdpi = mDisplayData[id].ydpi = getDefaultDensity(h); + return NO_ERROR; +} + int32_t HWComposer::allocateDisplayId() { if (mAllocatedDisplayIDs.count() >= mNumDisplays) { return NO_MEMORY; @@ -416,7 +427,6 @@ sp<Fence> HWComposer::getDisplayFence(int disp) const { return mDisplayData[disp].lastDisplayFence; } - uint32_t HWComposer::getWidth(int disp) const { return mDisplayData[disp].width; } diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.h b/services/surfaceflinger/DisplayHardware/HWComposer.h index 58f7e8f..604de38 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.h +++ b/services/surfaceflinger/DisplayHardware/HWComposer.h @@ -253,6 +253,9 @@ public: float getDpiY(int disp) const; bool isConnected(int disp) const; + status_t setVirtualDisplayProperties(int32_t id, uint32_t w, uint32_t h, + uint32_t format); + // this class is only used to fake the VSync event on systems that don't // have it. class VSyncThread : public Thread { diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 9102f5c..a4426cd 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1187,8 +1187,15 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) state.viewport, state.frame); hw->setDisplayName(state.displayName); mDisplays.add(display, hw); - if (state.type < DisplayDevice::NUM_DISPLAY_TYPES) + if (state.isVirtualDisplay()) { + if (hwcDisplayId >= 0) { + mHwc->setVirtualDisplayProperties(hwcDisplayId, + hw->getWidth(), hw->getHeight(), + hw->getFormat()); + } + } else { mEventThread->onHotplugReceived(state.type, true); + } } } } |