- This is done by allowing larger Atlas size, but make restriction for max 1024 size
- Padding will be handled when calculating the new atlas size
- If Max Atlas is not enough, we will fall back to default old behavior.
- This will service rendering font size even larger 500pt which services almost all users needs
Change-Id: Ib05abbc0eced6f440451b4ecf8cc8cc4640c09c8
const float ONE(1.0f);
const uint32_t DEFAULT_ATLAS_WIDTH = 512u;
const uint32_t DEFAULT_ATLAS_HEIGHT = 512u;
const float ONE(1.0f);
const uint32_t DEFAULT_ATLAS_WIDTH = 512u;
const uint32_t DEFAULT_ATLAS_HEIGHT = 512u;
+const uint32_t MAX_ATLAS_WIDTH = 1024u;
+const uint32_t MAX_ATLAS_HEIGHT = 1024u;
+const uint32_t DOUBLE_PIXEL_PADDING = 4u;//Padding will be added twice to Atlas
const uint16_t NO_OUTLINE = 0u;
} // namespace
const uint16_t NO_OUTLINE = 0u;
} // namespace
// If CheckAtlas in AtlasManager::Add can't fit the bitmap in the current atlas it will create a new atlas
// Setting the block size and size of new atlas does not mean a new one will be created. An existing atlas may still surffice.
// If CheckAtlas in AtlasManager::Add can't fit the bitmap in the current atlas it will create a new atlas
// Setting the block size and size of new atlas does not mean a new one will be created. An existing atlas may still surffice.
- mGlyphManager.SetNewAtlasSize(DEFAULT_ATLAS_WIDTH,
- DEFAULT_ATLAS_HEIGHT,
+ uint32_t default_width = DEFAULT_ATLAS_WIDTH;
+ uint32_t default_height = DEFAULT_ATLAS_HEIGHT;
+
+ while (
+ (blockSize.mNeededBlockWidth >= (default_width - (DOUBLE_PIXEL_PADDING + 1u)) ||
+ blockSize.mNeededBlockHeight >= (default_height - (DOUBLE_PIXEL_PADDING + 1u)))
+ &&
+ (default_width < MAX_ATLAS_WIDTH &&
+ default_height < MAX_ATLAS_HEIGHT))
+ {
+ default_width <<= 1u;
+ default_height <<= 1u;
+ }
+ mGlyphManager.SetNewAtlasSize(default_width,
+ default_height,
blockSize.mNeededBlockWidth,
blockSize.mNeededBlockHeight);
blockSize.mNeededBlockWidth,
blockSize.mNeededBlockHeight);