From e543191fe720e1e7e09de8a3fcc3159cdaccb2e3 Mon Sep 17 00:00:00 2001 From: Stark Li Date: Wed, 08 Mar 2017 10:01:46 +0000 Subject: PD#140524: optimization direct composer remove limit of offset, scale, crop etc. Change-Id: If6f9a8349f745033d15b37355356e564be02ace4 --- diff --git a/hwc2/common/composers/GE2DComposer.cpp b/hwc2/common/composers/GE2DComposer.cpp index bbe2f41..ddaa229 100644 --- a/hwc2/common/composers/GE2DComposer.cpp +++ b/hwc2/common/composers/GE2DComposer.cpp @@ -64,7 +64,7 @@ int32_t GE2DComposer::allocBuffer(private_module_t* module, size_t size, int32_t if ( ret != 0) { - ETRACE("Failed to ion_alloc from ion_client:%d", module->ion_client); + ETRACE("Failed to ion_alloc from ion_client:%d,size=%d", module->ion_client, size); return -1; } @@ -140,28 +140,11 @@ void GE2DComposer::freeBuffer(private_handle_t const* hnd, private_module_t* m) bool GE2DComposer::initialize(framebuffer_info_t* fbInfo) { - Mutex::Autolock _l(mLock); - if (mInitialized) { WTRACE("object has been initialized"); return true; } - // create a release fence timeline. - mSyncTimelineFd = HwcFenceControl::createFenceTimeline(); - if (mSyncTimelineFd == -1) { - DEINIT_AND_RETURN_FALSE("sync timeline create failed!"); - } - mCurrentSyncTime = 1; - - // create ge2d composer thread. - mExitThread = false; - mThread = new GE2DRenderThread(this); - if (!mThread.get()) { - DEINIT_AND_RETURN_FALSE("failed to create ge2d composer thread."); - } - mThread->run("GE2DComposer", PRIORITY_URGENT_DISPLAY); - // framebuffer stuff. mFbInfo = fbInfo; mSingleFbSize = fbInfo->finfo.line_length * fbInfo->info.yres; @@ -171,8 +154,7 @@ bool GE2DComposer::initialize(framebuffer_info_t* fbInfo) int32_t usage = GRALLOC_USAGE_HW_COMPOSER; int32_t ret = allocBuffer(mFbInfo->grallocModule, mFbInfo->fbSize, usage, &mGe2dBufHnd); if (ret < 0) { - ETRACE("allocBuffer failed!"); - return false; + DEINIT_AND_RETURN_FALSE("allocBuffer failed!"); } private_handle_t const *pHandle = reinterpret_cast (mGe2dBufHnd); if (pHandle) { @@ -182,6 +164,21 @@ bool GE2DComposer::initialize(framebuffer_info_t* fbInfo) DTRACE("Buffer alloced already."); } + // create a release fence timeline. + mSyncTimelineFd = HwcFenceControl::createFenceTimeline(); + if (mSyncTimelineFd == -1) { + DEINIT_AND_RETURN_FALSE("sync timeline create failed!"); + } + mCurrentSyncTime = 1; + + // create ge2d composer thread. + mExitThread = false; + mThread = new GE2DRenderThread(this); + if (!mThread.get()) { + DEINIT_AND_RETURN_FALSE("failed to create ge2d composer thread."); + } + mThread->run("GE2DComposer", PRIORITY_URGENT_DISPLAY); + // ge2d info. mSrcBufferInfo = new aml_ge2d_info_t(); @@ -214,6 +211,11 @@ void GE2DComposer::deinitialize() // ge2d exit. ge2d_close(mGe2dFd); + + if (mSyncTimelineFd != -1) { + close(mSyncTimelineFd); + mSyncTimelineFd = -1; + } mInitialized = false; } diff --git a/hwc2/common/devices/PhysicalDevice.cpp b/hwc2/common/devices/PhysicalDevice.cpp index fda3773..5b1ccc8 100644 --- a/hwc2/common/devices/PhysicalDevice.cpp +++ b/hwc2/common/devices/PhysicalDevice.cpp @@ -599,9 +599,17 @@ void PhysicalDevice::directCompose(framebuffer_info_t * fbInfo) { DTRACE("Hit only one non video overlay layer, handle: %08" PRIxPTR ", fence: %d", intptr_t(mClientTargetHnd), mTargetAcquireFence); - /* hwc_rect_t displayframe = layer->getDisplayFrame(); - fbInfo->info.xoffset = displayframe.left; - fbInfo->info.yoffset = displayframe.top; */ + // fill up fb sync request struct. + hwc_frect_t srcCrop = layer->getSourceCrop(); + hwc_rect_t displayFrame = layer->getDisplayFrame(); + mFbSyncRequest.xoffset = (unsigned int)srcCrop.left; + mFbSyncRequest.yoffset = (unsigned int)srcCrop.top; + mFbSyncRequest.width = (unsigned int)(srcCrop.right - srcCrop.left); + mFbSyncRequest.height = (unsigned int)(srcCrop.bottom - srcCrop.top); + mFbSyncRequest.dst_x = displayFrame.left; + mFbSyncRequest.dst_y = displayFrame.top; + mFbSyncRequest.dst_w = displayFrame.right - displayFrame.left; + mFbSyncRequest.dst_h = displayFrame.bottom - displayFrame.top; return; } @@ -677,12 +685,7 @@ int32_t PhysicalDevice::postFramebuffer(int32_t* outRetireFence, bool hasVideoOv } if (mRenderMode == GLES_COMPOSE_MODE) { - /*private_handle_t const* buffer = reinterpret_cast(mClientTargetHnd); - if (buffer && private_handle_t::validate(buffer) == 0) { - uint32_t slot = buffer->offset / fbInfo.finfo.line_length; - mComposer->setCurGlesFbSlot(slot); - DTRACE("GLES compose Slot: %d", slot); - }*/ + } else if (mRenderMode == DIRECT_COMPOSE_MODE) { // if only one layer exists, let hwc do her work. directCompose(&fbInfo); } @@ -691,7 +694,8 @@ int32_t PhysicalDevice::postFramebuffer(int32_t* outRetireFence, bool hasVideoOv ge2dCompose(&fbInfo, hasVideoOverlay); } #endif - fbInfo.renderMode = mRenderMode; + // fbInfo.renderMode = mRenderMode; + mFbSyncRequest.type = mRenderMode; bool needBlankFb0 = false; uint32_t layerNum = mHwcLayers.size(); @@ -699,9 +703,9 @@ int32_t PhysicalDevice::postFramebuffer(int32_t* outRetireFence, bool hasVideoOv if (mIsContinuousBuf) { // bit 0 is osd blank flag. - fbInfo.op &= ~0x00000001; + mFbSyncRequest.op &= ~0x00000001; if (needBlankFb0) { - fbInfo.op |= 0x00000001; + mFbSyncRequest.op |= 0x00000001; } mFramebufferContext->setStatus(needBlankFb0); } else { @@ -731,11 +735,13 @@ int32_t PhysicalDevice::postFramebuffer(int32_t* outRetireFence, bool hasVideoOv mPriorFrameRetireFence = -1; // real post framebuffer here. - DTRACE("fbInfo->renderMode: %d", fbInfo.renderMode); + DTRACE("render type: %d", mFbSyncRequest.type); if (!mIsContinuousBuf) { mPriorFrameRetireFence = fb_post_with_fence_locked(&fbInfo, mClientTargetHnd, mTargetAcquireFence); } else { - mPriorFrameRetireFence = hwc_fb_post_with_fence_locked(&fbInfo, mClientTargetHnd, mTargetAcquireFence); + // acquire fence. + mFbSyncRequest.in_fen_fd = mTargetAcquireFence; + mPriorFrameRetireFence = hwc_fb_post_with_fence_locked(&fbInfo, &mFbSyncRequest, mClientTargetHnd); } mTargetAcquireFence = -1; @@ -1026,6 +1032,7 @@ bool PhysicalDevice::layersStateCheck(int32_t renderMode, **************************************************************/ int32_t PhysicalDevice::composersFilter( KeyedVector & composeLayers) { + memset(&mFbSyncRequest, 0, sizeof(mFbSyncRequest)); // direct Composer. if (composeLayers.size() == HWC2_ONE_LAYER) { @@ -1130,7 +1137,7 @@ int32_t PhysicalDevice::validateDisplay(uint32_t* outNumTypes, DTRACE("continous buffer flag is not set, bufhnd: 0x%" PRIxPTR "", intptr_t(layer->getBufferHandle())); mIsContinuousBuf = false; } -#ifdef GRALLOC_ENABLE_SECURE_LAYER +#ifdef HWC_ENABLE_SECURE_LAYER // secure or protected layer. if (!mSecure && (hnd->flags & private_handle_t::PRIV_FLAGS_SECURE_PROTECTED)) { ETRACE("layer's secure or protected buffer flag is set!"); diff --git a/hwc2/include/PhysicalDevice.h b/hwc2/include/PhysicalDevice.h index 8478abc..57e181f 100644 --- a/hwc2/include/PhysicalDevice.h +++ b/hwc2/include/PhysicalDevice.h @@ -241,6 +241,9 @@ private: // HDR Capabilities hdr_capabilities_t mHdrCapabilities; + // fb sync requests. + hwc_fb_sync_request_t mFbSyncRequest; + // record the release fence of layer. KeyedVector mLayerReleaseFences[2]; KeyedVector * mHwcCurReleaseFences; -- cgit