TextureCache::TextureCache(): mCache(LruCache<const SkPixelRef*, Texture*>::kUnlimitedCapacity), mSize(0), mMaxSize(MB(DEFAULT_TEXTURE_CACHE_SIZE)), mFlushRate(DEFAULT_TEXTURE_CACHE_FLUSH_RATE) { bool setSizeByProperty = false; char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_TEXTURE_CACHE_SIZE, property, NULL) > 0) { INIT_LOGD(" Setting texture cache size to %sMB", property); setMaxSize(MB(atof(property))); setSizeByProperty = true; } else { INIT_LOGD(" Using default texture cache size of %.2fMB", DEFAULT_TEXTURE_CACHE_SIZE); } if (property_get(PROPERTY_TEXTURE_CACHE_FLUSH_RATE, property, NULL) > 0) { float flushRate = atof(property); INIT_LOGD(" Setting texture cache flush rate to %.2f%%", flushRate * 100.0f); setFlushRate(flushRate); } else { INIT_LOGD(" Using default texture cache flush rate of %.2f%%", DEFAULT_TEXTURE_CACHE_FLUSH_RATE * 100.0f); } /// M: Expand texture cache size for project with large resolution. if (!setSizeByProperty) { if (DEFAULT_TEXTURE_CACHE_SCREEN_BASED_SIZE > DEFAULT_TEXTURE_CACHE_SIZE) { INIT_LOGD(" Setting texture cache size to %.2fMB by screen based size", DEFAULT_TEXTURE_CACHE_SCREEN_BASED_SIZE); setMaxSize(MB(DEFAULT_TEXTURE_CACHE_SCREEN_BASED_SIZE)); } } init(); }
TextureCache::TextureCache() : mCache(LruCache<uint32_t, Texture*>::kUnlimitedCapacity) , mSize(0) , mMaxSize(MB(DEFAULT_TEXTURE_CACHE_SIZE)) , mFlushRate(DEFAULT_TEXTURE_CACHE_FLUSH_RATE) , mAssetAtlas(nullptr) { char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_TEXTURE_CACHE_SIZE, property, nullptr) > 0) { INIT_LOGD(" Setting texture cache size to %sMB", property); setMaxSize(MB(atof(property))); } else { INIT_LOGD(" Using default texture cache size of %.2fMB", DEFAULT_TEXTURE_CACHE_SIZE); } if (property_get(PROPERTY_TEXTURE_CACHE_FLUSH_RATE, property, nullptr) > 0) { float flushRate = atof(property); INIT_LOGD(" Setting texture cache flush rate to %.2f%%", flushRate * 100.0f); setFlushRate(flushRate); } else { INIT_LOGD(" Using default texture cache flush rate of %.2f%%", DEFAULT_TEXTURE_CACHE_FLUSH_RATE * 100.0f); } mCache.setOnEntryRemovedListener(this); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); INIT_LOGD(" Maximum texture dimension is %d pixels", mMaxTextureSize); mDebugEnabled = Properties::debugLevel & kDebugCaches; }
LayerCache::LayerCache(): mSize(0), mMaxSize(MB(DEFAULT_LAYER_CACHE_SIZE)) { char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_LAYER_CACHE_SIZE, property, NULL) > 0) { INIT_LOGD(" Setting layer cache size to %sMB", property); setMaxSize(MB(atof(property))); } else { INIT_LOGD(" Using default layer cache size of %.2fMB", DEFAULT_LAYER_CACHE_SIZE); } }
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); } }
RenderBufferCache::RenderBufferCache(): mSize(0), mMaxSize(MB(DEFAULT_RENDER_BUFFER_CACHE_SIZE)) { char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_RENDER_BUFFER_CACHE_SIZE, property, NULL) > 0) { INIT_LOGD(" Setting render buffer cache size to %sMB", property); setMaxSize(MB(atof(property))); } else { INIT_LOGD(" Using default render buffer cache size of %.2fMB", DEFAULT_RENDER_BUFFER_CACHE_SIZE); } }
PatchCache::PatchCache(): mSize(0), mCache(LruCache<PatchDescription, Patch*>::kUnlimitedCapacity), mMeshBuffer(0), mFreeBlocks(NULL), mGenerationId(0) { char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_PATCH_CACHE_SIZE, property, NULL) > 0) { INIT_LOGD(" Setting patch cache size to %skB", property); mMaxSize = KB(atoi(property)); } else { INIT_LOGD(" Using default patch cache size of %dkB", DEFAULT_PATCH_CACHE_SIZE); mMaxSize = KB(DEFAULT_PATCH_CACHE_SIZE); } }
TextDropShadowCache::TextDropShadowCache(): mCache(GenerationCache<ShadowText, ShadowTexture*>::kUnlimitedCapacity), mSize(0), mMaxSize(MB(DEFAULT_DROP_SHADOW_CACHE_SIZE)) { char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_DROP_SHADOW_CACHE_SIZE, property, NULL) > 0) { INIT_LOGD(" Setting drop shadow cache size to %sMB", property); setMaxSize(MB(atof(property))); } else { INIT_LOGD(" Using default drop shadow cache size of %.2fMB", DEFAULT_DROP_SHADOW_CACHE_SIZE); } init(); }
void Caches::initProperties() { char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_DEBUG_LAYERS_UPDATES, property, NULL) > 0) { INIT_LOGD(" Layers updates debug enabled: %s", property); debugLayersUpdates = !strcmp(property, "true"); } else { debugLayersUpdates = false; } if (property_get(PROPERTY_DEBUG_OVERDRAW, property, NULL) > 0) { INIT_LOGD(" Overdraw debug enabled: %s", property); debugOverdraw = !strcmp(property, "true"); } else { debugOverdraw = false; } }
TessellationCache::TessellationCache() : mSize(0) , mMaxSize(MB(DEFAULT_VERTEX_CACHE_SIZE)) , mCache(LruCache<Description, Buffer*>::kUnlimitedCapacity) , mShadowCache(LruCache<ShadowDescription, Task<vertexBuffer_pair_t*>*>::kUnlimitedCapacity) { char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_VERTEX_CACHE_SIZE, property, NULL) > 0) { INIT_LOGD(" Setting %s cache size to %sMB", name, property); setMaxSize(MB(atof(property))); } else { INIT_LOGD(" Using default %s cache size of %.2fMB", name, DEFAULT_VERTEX_CACHE_SIZE); } mCache.setOnEntryRemovedListener(&mBufferRemovedListener); mShadowCache.setOnEntryRemovedListener(&mBufferPairRemovedListener); mDebugEnabled = readDebugLevel() & kDebugCaches; }
void TextureCache::init() { mCache.setOnEntryRemovedListener(this); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); INIT_LOGD(" Maximum texture dimension is %d pixels", mMaxTextureSize); mDebugEnabled = readDebugLevel() & kDebugCaches; }
PathCache::PathCache(): mCache(LruCache<PathDescription, PathTexture*>::kUnlimitedCapacity), mSize(0), mMaxSize(MB(DEFAULT_PATH_CACHE_SIZE)) { char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_PATH_CACHE_SIZE, property, NULL) > 0) { INIT_LOGD(" Setting %s cache size to %sMB", name, property); setMaxSize(MB(atof(property))); } else { INIT_LOGD(" Using default %s cache size of %.2fMB", name, DEFAULT_PATH_CACHE_SIZE); } mCache.setOnEntryRemovedListener(this); GLint maxTextureSize; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); mMaxTextureSize = maxTextureSize; mDebugEnabled = readDebugLevel() & kDebugCaches; }
TextureCache::TextureCache() : mCache(LruCache<uint32_t, Texture*>::kUnlimitedCapacity) , mSize(0) , mMaxSize(Properties::textureCacheSize) , mFlushRate(Properties::textureCacheFlushRate) , mAssetAtlas(nullptr) { mCache.setOnEntryRemovedListener(this); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); INIT_LOGD(" Maximum texture dimension is %d pixels", mMaxTextureSize); mDebugEnabled = Properties::debugLevel & kDebugCaches; }
TextureCache::TextureCache(): mCache(GenerationCache<SkBitmap*, Texture*>::kUnlimitedCapacity), mSize(0), mMaxSize(MB(DEFAULT_TEXTURE_CACHE_SIZE)), mFlushRate(DEFAULT_TEXTURE_CACHE_FLUSH_RATE) { char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_TEXTURE_CACHE_SIZE, property, NULL) > 0) { INIT_LOGD(" Setting texture cache size to %sMB", property); setMaxSize(MB(atof(property))); } else { INIT_LOGD(" Using default texture cache size of %.2fMB", DEFAULT_TEXTURE_CACHE_SIZE); } if (property_get(PROPERTY_TEXTURE_CACHE_FLUSH_RATE, property, NULL) > 0) { float flushRate = atof(property); INIT_LOGD(" Setting texture cache flush rate to %.2f%%", flushRate * 100.0f); setFlushRate(flushRate); } else { INIT_LOGD(" Using default texture cache flush rate of %.2f%%", DEFAULT_TEXTURE_CACHE_FLUSH_RATE * 100.0f); } init(); }
Caches::Caches(): Singleton<Caches>(), mInitialized(false) { GLint maxTextureUnits; glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits); if (maxTextureUnits < REQUIRED_TEXTURE_UNITS_COUNT) { LOGW("At least %d texture units are required!", REQUIRED_TEXTURE_UNITS_COUNT); } glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); init(); mDebugLevel = readDebugLevel(); LOGD("Enabling debug mode %d", mDebugLevel); #if RENDER_LAYERS_AS_REGIONS INIT_LOGD("Layers will be composited as regions"); #endif }
bool Properties::load() { char property[PROPERTY_VALUE_MAX]; bool prevDebugLayersUpdates = debugLayersUpdates; bool prevDebugOverdraw = debugOverdraw; StencilClipDebug prevDebugStencilClip = debugStencilClip; debugOverdraw = false; if (property_get(PROPERTY_DEBUG_OVERDRAW, property, nullptr) > 0) { INIT_LOGD(" Overdraw debug enabled: %s", property); if (!strcmp(property, "show")) { debugOverdraw = true; overdrawColorSet = OverdrawColorSet::Default; } else if (!strcmp(property, "show_deuteranomaly")) { debugOverdraw = true; overdrawColorSet = OverdrawColorSet::Deuteranomaly; } } // See Properties.h for valid values if (property_get(PROPERTY_DEBUG_STENCIL_CLIP, property, nullptr) > 0) { INIT_LOGD(" Stencil clip debug enabled: %s", property); if (!strcmp(property, "hide")) { debugStencilClip = StencilClipDebug::Hide; } else if (!strcmp(property, "highlight")) { debugStencilClip = StencilClipDebug::ShowHighlight; } else if (!strcmp(property, "region")) { debugStencilClip = StencilClipDebug::ShowRegion; } } else { debugStencilClip = StencilClipDebug::Hide; } sProfileType = ProfileType::None; if (property_get(PROPERTY_PROFILE, property, "") > 0) { if (!strcmp(property, PROPERTY_PROFILE_VISUALIZE_BARS)) { sProfileType = ProfileType::Bars; } else if (!strcmp(property, "true")) { sProfileType = ProfileType::Console; } } debugLayersUpdates = property_get_bool(PROPERTY_DEBUG_LAYERS_UPDATES, false); INIT_LOGD(" Layers updates debug enabled: %d", debugLayersUpdates); drawDeferDisabled = property_get_bool(PROPERTY_DISABLE_DRAW_DEFER, false); INIT_LOGD(" Draw defer %s", drawDeferDisabled ? "disabled" : "enabled"); drawReorderDisabled = property_get_bool(PROPERTY_DISABLE_DRAW_REORDER, false); INIT_LOGD(" Draw reorder %s", drawReorderDisabled ? "disabled" : "enabled"); showDirtyRegions = property_get_bool(PROPERTY_DEBUG_SHOW_DIRTY_REGIONS, false); debugLevel = kDebugDisabled; if (property_get(PROPERTY_DEBUG, property, nullptr) > 0) { debugLevel = (DebugLevel) atoi(property); } skipEmptyFrames = property_get_bool(PROPERTY_SKIP_EMPTY_DAMAGE, true); swapBuffersWithDamage = property_get_bool(PROPERTY_SWAP_WITH_DAMAGE, true); return (prevDebugLayersUpdates != debugLayersUpdates) || (prevDebugOverdraw != debugOverdraw) || (prevDebugStencilClip != debugStencilClip); }