mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-23 15:11:51 +00:00
commit
b4655e7081
@ -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_;
|
||||
|
@ -213,6 +213,10 @@ bool EglWrapperLayer::LoadLayers()
|
||||
{
|
||||
WLOGD("");
|
||||
std::vector<std::string> 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;
|
||||
|
@ -60,7 +60,7 @@ void CacheData::ReadFromFile()
|
||||
}
|
||||
|
||||
size_t fileSize = static_cast<size_t>(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<unsigned long>(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;
|
||||
|
@ -167,12 +167,12 @@ private:
|
||||
std::vector<ShaderPointer> 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_;
|
||||
|
Loading…
Reference in New Issue
Block a user