From 68fda9d9fde26384b9889b1076557264bb1cf1a3 Mon Sep 17 00:00:00 2001 From: limingkang Date: Mon, 6 May 2024 11:38:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: limingkang Change-Id: I2a14af5c1f143a3337b0f5fb2aa1958f78b3a00b --- .../opengl_wrapper/src/EGL/egl_blob_cache.cpp | 2 +- .../opengl_wrapper/src/EGL/egl_wrapper_layer.cpp | 4 ++++ .../2d_graphics/src/render_context/cache_data.cpp | 14 +++++++------- .../2d_graphics/src/render_context/cache_data.h | 8 ++++---- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/frameworks/opengl_wrapper/src/EGL/egl_blob_cache.cpp b/frameworks/opengl_wrapper/src/EGL/egl_blob_cache.cpp index 556be77031..9f103bd498 100644 --- a/frameworks/opengl_wrapper/src/EGL/egl_blob_cache.cpp +++ b/frameworks/opengl_wrapper/src/EGL/egl_blob_cache.cpp @@ -212,7 +212,7 @@ EGLsizeiANDROID BlobCache::GetBlob(const void *key, EGLsizeiANDROID keySize, voi errno_t ret = memcpy_s(value, valueSize, it->second->data, it->second->dataSize); if (ret != EOK) { WLOGE("memcpy_s failed"); - return false; + return ret; } auto moveblob = it->first; moveblob->prev_->next_ = moveblob->next_; diff --git a/frameworks/opengl_wrapper/src/EGL/egl_wrapper_layer.cpp b/frameworks/opengl_wrapper/src/EGL/egl_wrapper_layer.cpp index a4271bf910..380ae08563 100644 --- a/frameworks/opengl_wrapper/src/EGL/egl_wrapper_layer.cpp +++ b/frameworks/opengl_wrapper/src/EGL/egl_wrapper_layer.cpp @@ -213,6 +213,10 @@ bool EglWrapperLayer::LoadLayers() { WLOGD(""); std::vector layers = GetDebugLayers(); + if (layers.empty()) { + WLOGD("layers is empty"); + return false; + } for (int32_t i = layers.size() - 1; i >= 0; i--) { std::string layerLib = std::string(DEBUG_LAYERS_PREFIX) + layers[i] + std::string(DEBUG_LAYERS_SUFFIX); std::string layerPath = std::string(DEBUG_LAYERS_LIB_DIR) + layerLib; diff --git a/rosen/modules/2d_graphics/src/render_context/cache_data.cpp b/rosen/modules/2d_graphics/src/render_context/cache_data.cpp index 5a0dba869e..006c4cf8ec 100644 --- a/rosen/modules/2d_graphics/src/render_context/cache_data.cpp +++ b/rosen/modules/2d_graphics/src/render_context/cache_data.cpp @@ -60,7 +60,7 @@ void CacheData::ReadFromFile() } size_t fileSize = static_cast(statBuf.st_size); - if (fileSize == 0 || fileSize > maxTotalSize_ * MAX_MULTIPLE_SIZE) { + if (fileSize == 0 || fileSize > maxTotalSize_ * maxMultipleSize_) { LOGD("abandon, illegal file size"); close(fd); return; @@ -318,7 +318,7 @@ bool CacheData::IfSizeValidate(const size_t newSize, const size_t addedSize) con bool CacheData::IfSkipClean(const size_t addedSize) const { // check if the new shader is still too large after cleaning - size_t maxPermittedSize = maxTotalSize_ - maxTotalSize_ / CLEAN_LEVEL; + size_t maxPermittedSize = maxTotalSize_ - maxTotalSize_ / cleanLevel_; if (addedSize > maxPermittedSize) { LOGD("new shader is too large, abandon insert"); return true; @@ -329,7 +329,7 @@ bool CacheData::IfSkipClean(const size_t addedSize) const bool CacheData::IfCleanFinished() { if (!cleanThreshold_) { - RandClean(maxTotalSize_ / CLEAN_LEVEL); + RandClean(maxTotalSize_ / cleanLevel_); return true; } else { LOGD("abandon, failed to clean the shaders"); @@ -350,10 +350,10 @@ void CacheData::RandClean(const size_t cleanThreshold) return; } unsigned long currentTime = static_cast(now); - for (int indexRand = 0; indexRand < RAND_LENGTH; ++indexRand) { - cleanInit_[indexRand] = (currentTime >> (indexRand * RAND_SHIFT)) & 0xFFFF; - cleanInit_[indexRand] = (currentTime >> (indexRand * RAND_SHIFT)) & 0xFFFF; - cleanInit_[indexRand] = (currentTime >> (indexRand * RAND_SHIFT)) & 0xFFFF; + for (int indexRand = 0; indexRand < randLength_; ++indexRand) { + cleanInit_[indexRand] = (currentTime >> (indexRand * randShift_)) & 0xFFFF; + cleanInit_[indexRand] = (currentTime >> (indexRand * randShift_)) & 0xFFFF; + cleanInit_[indexRand] = (currentTime >> (indexRand * randShift_)) & 0xFFFF; } } cleanThreshold_ = cleanThreshold; diff --git a/rosen/modules/2d_graphics/src/render_context/cache_data.h b/rosen/modules/2d_graphics/src/render_context/cache_data.h index 0da1c8284b..0394620856 100644 --- a/rosen/modules/2d_graphics/src/render_context/cache_data.h +++ b/rosen/modules/2d_graphics/src/render_context/cache_data.h @@ -167,12 +167,12 @@ private: std::vector shaderPointers_; size_t numShaders_ = 0; - const size_t MAX_MULTIPLE_SIZE = 2; - const size_t CLEAN_LEVEL = 2; + const size_t maxMultipleSize_ = 2; + const size_t cleanLevel_ = 2; static const size_t ALIGN_FOUR = 3; static const int ERR_NUMBER = -1; - const int RAND_SHIFT = 16; - const int RAND_LENGTH = 3; + const int randShift_ = 16; + const int randLength_ = 3; size_t maxKeySize_; size_t maxValueSize_;