From: Dan Stoza Date: Wed, 15 Oct 2014 23:34:55 +0000 (-0700) Subject: Don't run large virtual displays through HWC X-Git-Tag: android-x86-6.0-r1~270^2~52 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=1f3efb11ff8c884a254f4272f0d1ee0b77ceff2f;p=android-x86%2Fframeworks-native.git Don't run large virtual displays through HWC This change watches for a MAX_VIRTUAL_DISPLAY_DIMENSION value, which will be set (if necessary) in BoardConfig.mk. If the value is set, any virtual displays that have a width or a height greater than that dimension will bypass the hardware composer HAL and be handled only by SurfaceFlinger. Bug: 17701816 Change-Id: Ia6ca44dfd6a7a9bc0f054493d3f13006bc32fa14 --- diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk index 57e94ef64e..76545f3775 100644 --- a/services/surfaceflinger/Android.mk +++ b/services/surfaceflinger/Android.mk @@ -83,6 +83,12 @@ else LOCAL_CFLAGS += -DPRESENT_TIME_OFFSET_FROM_VSYNC_NS=0 endif +ifneq ($(MAX_VIRTUAL_DISPLAY_DIMENSION),) + LOCAL_CFLAGS += -DMAX_VIRTUAL_DISPLAY_DIMENSION=$(MAX_VIRTUAL_DISPLAY_DIMENSION) +else + LOCAL_CFLAGS += -DMAX_VIRTUAL_DISPLAY_DIMENSION=0 +endif + LOCAL_CFLAGS += -fvisibility=hidden -Werror=format LOCAL_CFLAGS += -std=c++11 diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 50968e7936..17e984a1a3 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1328,7 +1328,22 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) // etc.) but no internal state (i.e. a DisplayDevice). if (state.surface != NULL) { - hwcDisplayId = allocateHwcDisplayId(state.type); + int width = 0; + int status = state.surface->query( + NATIVE_WINDOW_WIDTH, &width); + ALOGE_IF(status != NO_ERROR, + "Unable to query width (%d)", status); + int height = 0; + status = state.surface->query( + NATIVE_WINDOW_HEIGHT, &height); + ALOGE_IF(status != NO_ERROR, + "Unable to query height (%d)", status); + if (MAX_VIRTUAL_DISPLAY_DIMENSION == 0 || + (width <= MAX_VIRTUAL_DISPLAY_DIMENSION && + height <= MAX_VIRTUAL_DISPLAY_DIMENSION)) { + hwcDisplayId = allocateHwcDisplayId(state.type); + } + sp vds = new VirtualDisplaySurface( *mHwc, hwcDisplayId, state.surface, bqProducer, bqConsumer, state.displayName);