Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 48a8f431 authored by Chris Craik's avatar Chris Craik
Browse files

Move several property queries to Properties class

bug:17478770

This removes a lot of redundant property query code, and puts the
queries all in one place, so defining them automatically will be simpler
in the future.

Change-Id: I0428550e6081f07bc6554ffdf73b22284325abb8
parent 37fd29f2
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -27,15 +27,8 @@ namespace uirenderer {
// Constructors/destructor
///////////////////////////////////////////////////////////////////////////////

FboCache::FboCache(): mMaxSize(DEFAULT_FBO_CACHE_SIZE) {
    char property[PROPERTY_VALUE_MAX];
    if (property_get(PROPERTY_FBO_CACHE_SIZE, property, nullptr) > 0) {
        INIT_LOGD("  Setting fbo cache size to %s", property);
        mMaxSize = atoi(property);
    } else {
        INIT_LOGD("  Using default fbo cache size of %d", DEFAULT_FBO_CACHE_SIZE);
    }
}
FboCache::FboCache()
        : mMaxSize(Properties::fboCacheSize) {}

FboCache::~FboCache() {
    clear();
+1 −16
Original line number Diff line number Diff line
@@ -65,17 +65,9 @@ int GradientCacheEntry::compare(const GradientCacheEntry& lhs, const GradientCac
GradientCache::GradientCache(Extensions& extensions)
        : mCache(LruCache<GradientCacheEntry, Texture*>::kUnlimitedCapacity)
        , mSize(0)
        , mMaxSize(MB(DEFAULT_GRADIENT_CACHE_SIZE))
        , mMaxSize(Properties::gradientCacheSize)
        , mUseFloatTexture(extensions.hasFloatTextures())
        , mHasNpot(extensions.hasNPot()){
    char property[PROPERTY_VALUE_MAX];
    if (property_get(PROPERTY_GRADIENT_CACHE_SIZE, property, nullptr) > 0) {
        INIT_LOGD("  Setting gradient cache size to %sMB", property);
        setMaxSize(MB(atof(property)));
    } else {
        INIT_LOGD("  Using default gradient cache size of %.2fMB", DEFAULT_GRADIENT_CACHE_SIZE);
    }

    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);

    mCache.setOnEntryRemovedListener(this);
@@ -97,13 +89,6 @@ uint32_t GradientCache::getMaxSize() {
    return mMaxSize;
}

void GradientCache::setMaxSize(uint32_t maxSize) {
    mMaxSize = maxSize;
    while (mSize > mMaxSize) {
        mCache.removeOldest();
    }
}

///////////////////////////////////////////////////////////////////////////////
// Callbacks
///////////////////////////////////////////////////////////////////////////////
+1 −5
Original line number Diff line number Diff line
@@ -122,10 +122,6 @@ public:
     */
    void clear();

    /**
     * Sets the maximum size of the cache in bytes.
     */
    void setMaxSize(uint32_t maxSize);
    /**
     * Returns the maximum size of the cache in bytes.
     */
@@ -177,7 +173,7 @@ private:
    LruCache<GradientCacheEntry, Texture*> mCache;

    uint32_t mSize;
    uint32_t mMaxSize;
    const uint32_t mMaxSize;

    GLint mMaxTextureSize;
    bool mUseFloatTexture;
+2 −10
Original line number Diff line number Diff line
@@ -32,20 +32,12 @@ namespace uirenderer {

PatchCache::PatchCache(RenderState& renderState)
        : mRenderState(renderState)
        , mMaxSize(Properties::patchCacheSize)
        , mSize(0)
        , mCache(LruCache<PatchDescription, Patch*>::kUnlimitedCapacity)
        , mMeshBuffer(0)
        , mFreeBlocks(nullptr)
        , mGenerationId(0) {
    char property[PROPERTY_VALUE_MAX];
    if (property_get(PROPERTY_PATCH_CACHE_SIZE, property, nullptr) > 0) {
        INIT_LOGD("  Setting patch cache size to %skB", property);
        mMaxSize = KB(atoi(property));
    } else {
        INIT_LOGD("  Using default patch cache size of %.2fkB", DEFAULT_PATCH_CACHE_SIZE);
        mMaxSize = KB(DEFAULT_PATCH_CACHE_SIZE);
    }
}
        , mGenerationId(0) {}

PatchCache::~PatchCache() {
    clear();
+1 −1
Original line number Diff line number Diff line
@@ -169,7 +169,7 @@ private:
#endif

    RenderState& mRenderState;
    uint32_t mMaxSize;
    const uint32_t mMaxSize;
    uint32_t mSize;

    LruCache<PatchDescription, Patch*> mCache;
Loading