/* Copyright Statement: * * This software/firmware and related documentation ("MediaTek Software") are * protected under relevant copyright laws. The information contained herein is * confidential and proprietary to MediaTek Inc. and/or its licensors. Without * the prior written permission of MediaTek inc. and/or its licensors, any * reproduction, modification, use or disclosure of MediaTek Software, and * information contained herein, in whole or in part, shall be strictly * prohibited. * * MediaTek Inc. (C) 2021. All rights reserved. * * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER * ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR * NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, * INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES * TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK * SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE * RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE * MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE * CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. * * The following software/firmware and/or related documentation ("MediaTek * Software") have been modified by MediaTek Inc. All revisions are subject to * any receiver's applicable license agreements with MediaTek Inc. */ //#define LOG_NDEBUG 0 #undef LOG_TAG #define LOG_TAG "RenderEngine" #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include "../skia/SkiaGLRenderEngine.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef MTK_CUTTLESTONE #ifdef MTK_SKIP_SKIA_EXTERNAL_TEXTURE_CACHE #include #endif #endif //MTK_CUTTLESTONE namespace android { namespace renderengine { namespace skia { #ifdef MTK_SKIP_SKIA_EXTERNAL_TEXTURE_CACHE bool SkiaGLRenderEngine::isSkipExternalTexureCache(const sp& buffer){ #ifndef MTK_CUTTLESTONE GRALLOC_EXTRA_RESULT result = GRALLOC_EXTRA_OK; int ion_fd = -1; int status = 0; bool videoPqEnable = false; bool isUnknwonFormat = false; result = gralloc_extra_query(buffer->handle, GRALLOC_EXTRA_GET_ION_FD, &ion_fd); if ((GRALLOC_EXTRA_OK == result) && (-1 != ion_fd)) { gralloc_extra_ion_sf_info_t sf_info; result = gralloc_extra_query(buffer->handle, GRALLOC_EXTRA_GET_IOCTL_ION_SF_INFO, &sf_info); if (GRALLOC_EXTRA_OK == result) { status = sf_info.status2; } } videoPqEnable = (status & GRALLOC_EXTRA_MASK2_VIDEO_PQ) == GRALLOC_EXTRA_BIT2_VIDEO_PQ_ON; if (decodePixelFormat(buffer->getPixelFormat()).find("Unknown") != std::string::npos ){ isUnknwonFormat = true; //skip unknown format } if (isUnknwonFormat|| videoPqEnable) { return true; } return false; #else return true; #endif //MTK_CUTTLESTONE } #endif #ifdef MTK_SF_PQ_MANAGEMENT void SkiaGLRenderEngine::setDeviceInfo(const bool is_primary) { mIsPrimary = is_primary; //ALOGD("set mIsPrimary:%d", mIsPrimary); } bool SkiaGLRenderEngine::getAndClearDeviceInfo() { bool is_primary = mIsPrimary;// get the current DeviceInfo mIsPrimary = false;// clear to defualt value false //ALOGD("getAndClear is_primary:%d", is_primary); return is_primary; } void SkiaGLRenderEngine::updatePQFlag (const sp& buffer, const bool isHDR, const bool is_primary) { #ifndef MTK_CUTTLESTONE GRALLOC_EXTRA_RESULT result = GRALLOC_EXTRA_OK; int ion_fd = -1; int status = 0; bool videoPqEnable = false; bool doraInterface = false; bool mdpSupport = false; ge_ai_pq_info_t pqInfo; gralloc_extra_ion_sf_info_t sf_info; result = gralloc_extra_query(buffer->handle, GRALLOC_EXTRA_GET_ION_FD, &ion_fd); if ((GRALLOC_EXTRA_OK == result) && (-1 != ion_fd)) { result = gralloc_extra_query(buffer->handle, GRALLOC_EXTRA_GET_IOCTL_ION_SF_INFO, &sf_info); if (GRALLOC_EXTRA_OK == result) { status = sf_info.status2; } } videoPqEnable = (status & GRALLOC_EXTRA_MASK2_VIDEO_PQ) == GRALLOC_EXTRA_BIT2_VIDEO_PQ_ON; result = gralloc_extra_query(buffer->handle, GRALLOC_EXTRA_GET_AI_PQ_INFO, &pqInfo); if (result != GRALLOC_EXTRA_OK) { ALOGE("%s: get gralloc GRALLOC_EXTRA_GET_AI_PQ_INFO fail, return", __FUNCTION__); return; } doraInterface = (pqInfo.param != 0); if (videoPqEnable || doraInterface) { int width = buffer->getWidth(); int height = buffer->getHeight(); buffer_handle_t handle = buffer->handle; if (!width || !height || !handle || !mdpSupport) { return; } ALOGD("%s, is_primary:%d, isHDR: %d", __FUNCTION__, is_primary, isHDR); if (is_primary && (!isHDR)) { //ALOGD("set GPU_VIDEO_PQ_ON flg+); result = gralloc_extra_sf_set_status2(&sf_info, GRALLOC_EXTRA_MASK2_GPU_VIDEO_PQ_MASK, GRALLOC_EXTRA_BIT2_GPU_VIDEO_PQ_ON); if (result != GRALLOC_EXTRA_OK) { ALOGE("%s: update GRALLOC_EXTRA_BIT2_GPU_VIDEO_PQ_ON fail, return", __FUNCTION__); return; } result = gralloc_extra_perform(handle, GRALLOC_EXTRA_SET_IOCTL_ION_SF_INFO, &sf_info); if (result != GRALLOC_EXTRA_OK) { ALOGE("%s: set GRALLOC_EXTRA_SET_IOCTL_ION_SF_INFO fail, return", __FUNCTION__); return; } } } #else return; #endif //MTK_CUTTLESTONE } #endif } // namespace skia } // namespace renderengine } // nam