From d5258260762009e1e8e6de8a1f184b1ba7b6b32b Mon Sep 17 00:00:00 2001 From: shuze.ma Date: Thu, 02 Nov 2017 09:15:44 +0000 Subject: hwc2: cursor operation reconstruction [1/1] PD# 153576 cursor operation reconstruction. Change-Id: If73f8d83bfba233dbdb032069017f3360b63cc44 --- diff --git a/hwc2/common/devices/PhysicalDevice.cpp b/hwc2/common/devices/PhysicalDevice.cpp index 7daffdd..69264f8 100644 --- a/hwc2/common/devices/PhysicalDevice.cpp +++ b/hwc2/common/devices/PhysicalDevice.cpp @@ -644,42 +644,11 @@ void PhysicalDevice::ge2dCompose(framebuffer_info_t * fbInfo, bool hasVideoOverl #endif int32_t PhysicalDevice::postFramebuffer(int32_t* outRetireFence, bool hasVideoOverlay) { - HwcLayer* layer = NULL; - void *cbuffer; bool bUseHwcPost = true; - // deal physical display's client target layer framebuffer_info_t fbInfo = *(mFramebufferContext->getInfo()); - framebuffer_info_t* cbInfo = mCursorContext->getInfo(); bool cursorShow = false; - bool haveCursorLayer = false; - for (uint32_t i=0; igetCompositionType()== HWC2_COMPOSITION_CURSOR) { - private_handle_t *hnd = private_handle_t::dynamicCast(layer->getBufferHandle()); - if (!hnd) { - ETRACE("invalid cursor layer handle."); - break; - } - haveCursorLayer = true; - DTRACE("This is a Sprite, hnd->stride is %d, hnd->height is %d", hnd->stride, hnd->height); - if (cbInfo->info.xres != (uint32_t)hnd->stride || cbInfo->info.yres != (uint32_t)hnd->height) { - DTRACE("disp: %d cursor need to redrew", mId); - update_cursor_buffer_locked(cbInfo, hnd->stride, hnd->height); - cbuffer = mmap(NULL, hnd->size, PROT_READ|PROT_WRITE, MAP_SHARED, cbInfo->fd, 0); - if (cbuffer != MAP_FAILED) { - memcpy(cbuffer, hnd->base, hnd->size); - munmap(cbuffer, hnd->size); - DTRACE("setCursor ok"); - } else { - ETRACE("Cursor display buffer mmap fail!"); - } - } - cursorShow = true; - break; - } - } + cursorShow = updateCursorBuffer(); if (mRenderMode == GLES_COMPOSE_MODE) { //if no layers to compose, post blank op to osd. @@ -726,7 +695,7 @@ int32_t PhysicalDevice::postFramebuffer(int32_t* outRetireFence, bool hasVideoOv if (hasVideoOverlay && (layerNum == 1 || (layerNum == 2 - && haveCursorLayer))) { + && cursorShow))) { needBlankFb0 = true; } @@ -771,11 +740,7 @@ int32_t PhysicalDevice::postFramebuffer(int32_t* outRetireFence, bool hasVideoOv } // finally we need to update cursor's blank status. - if (cbInfo->fd > 0 && cursorShow != mCursorContext->getStatus()) { - mCursorContext->setStatus(cursorShow); - DTRACE("UPDATE FB1 status to %d", !cursorShow); - ioctl(cbInfo->fd, FBIOBLANK, !cursorShow); - } + setOSD1Blank(cursorShow); } if (mRenderMode != GE2D_COMPOSE_MODE) { @@ -785,6 +750,62 @@ int32_t PhysicalDevice::postFramebuffer(int32_t* outRetireFence, bool hasVideoOv return HWC2_ERROR_NONE; } +// deal physical display's client target layer +bool PhysicalDevice::updateCursorBuffer() { + framebuffer_info_t* cbInfo = mCursorContext->getInfo(); + HwcLayer* layer = NULL; + void *cbuffer; + + for (uint32_t i=0; igetCompositionType()== HWC2_COMPOSITION_CURSOR) { + private_handle_t *hnd = private_handle_t::dynamicCast(layer->getBufferHandle()); + if (!hnd) { + ETRACE("invalid cursor layer handle."); + break; + } + DTRACE("This is a Sprite, hnd->width is %d(%d), hnd->height is %d", + hnd->width, hnd->stride, hnd->height); + if (cbInfo->info.xres != (uint32_t)hnd->stride || cbInfo->info.yres != (uint32_t)hnd->height) { + DTRACE("disp: %d cursor need to redrew", mId); + update_cursor_buffer_locked(cbInfo, hnd->stride, hnd->height); + cbuffer = mmap(NULL, hnd->size, PROT_READ|PROT_WRITE, MAP_SHARED, cbInfo->fd, 0); + if (cbuffer != MAP_FAILED) { + memset(cbuffer, 1, hnd->size); + + uint32_t irow = 0; + char* cpyDst = (char*)cbuffer; + char* cpySrc = (char*)hnd->base; + for (irow = 0; irow < hnd->height; irow++) { + memcpy(cpyDst, cpySrc, 4 * hnd->width); + cpyDst += 4 * hnd->stride; + cpySrc += 4 * hnd->stride; + } + munmap(cbuffer, hnd->size); + DTRACE("setCursor ok"); + } else { + ETRACE("Cursor display buffer mmap fail!"); + } + } + return true; + } + } + return false; +} + +int32_t PhysicalDevice::setOSD1Blank(bool cursorShow) { + framebuffer_info_t* cbInfo = mCursorContext->getInfo(); + + if (cbInfo->fd > 0 && cursorShow != mCursorContext->getStatus()) { + mCursorContext->setStatus(cursorShow); + DTRACE("UPDATE FB1 status to %d", !cursorShow); + ioctl(cbInfo->fd, FBIOBLANK, !cursorShow); + } + + return HWC2_ERROR_NONE; +} + // TODO: need add fence wait. int32_t PhysicalDevice::setOSD0Blank(bool blank) { framebuffer_info_t* fbInfo = mFramebufferContext->getInfo(); diff --git a/hwc2/include/PhysicalDevice.h b/hwc2/include/PhysicalDevice.h index b4e6858..aaa0292 100644 --- a/hwc2/include/PhysicalDevice.h +++ b/hwc2/include/PhysicalDevice.h @@ -148,6 +148,7 @@ private: // For use by Device int32_t initDisplay(); int32_t postFramebuffer(int32_t* outRetireFence, bool hasVideoOverlay); + bool updateCursorBuffer(); int32_t getLineValue(const char *lineStr, const char *magicStr); int32_t clearLayersStats(); @@ -155,6 +156,7 @@ private: int32_t parseHdrCapabilities(); void directCompose(framebuffer_info_t * fbInfo); void ge2dCompose(framebuffer_info_t * fbInfo, bool hasVideoOverlay); + int32_t setOSD1Blank(bool cursorShow); int32_t setOSD0Blank(bool blank); bool layersStateCheck(int32_t renderMode, KeyedVector & composeLayers); int32_t composersFilter(KeyedVector& composeLayers); -- cgit