diff options
author | jvanverth <jvanverth@google.com> | 2015-03-10 11:53:39 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-10 11:53:39 -0700 |
commit | be03bb6cef8c698a20aa5c9dbac827686aabc623 (patch) | |
tree | ed0f5f401bfda1c1584ed7c2ea2ba7089f9f8edd /src/gpu | |
parent | c41df8d92d885ecb71af7795b22ebc7417187f61 (diff) |
Adjust distance field glyph and font atlas sizes to maximize storage.
Because of high DPI devices, we need more room in the glyph
atlas for the larger glyphs. These settings will allow 4 of
the distance field glyphs to fit in one Plot (increasing
the storage from 32 large glyphs to 128), and still permit
us to handle glyphs up to a 312 point size.
BUG=chromium:458791
Committed: https://skia.googlesource.com/skia/+/d2737ad7dd8f4ea94a74034027014fd3d78923cb
Committed: https://skia.googlesource.com/skia/+/07e245ffe1ca7f781590fcff904c2922c2269781
Review URL: https://codereview.chromium.org/986343002
Diffstat (limited to 'src/gpu')
-rwxr-xr-x | src/gpu/GrBitmapTextContext.cpp | 2 | ||||
-rwxr-xr-x | src/gpu/GrDistanceFieldTextContext.cpp | 10 | ||||
-rw-r--r-- | src/gpu/GrFontAtlasSizes.h | 25 |
3 files changed, 23 insertions, 14 deletions
diff --git a/src/gpu/GrBitmapTextContext.cpp b/src/gpu/GrBitmapTextContext.cpp index d06df1c16b..a8ac78a209 100755 --- a/src/gpu/GrBitmapTextContext.cpp +++ b/src/gpu/GrBitmapTextContext.cpp @@ -586,7 +586,7 @@ void GrBitmapTextContext::flush() { SkFAIL("Unexpected mask format."); } - GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kNone_FilterMode); + GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kNone_FilterMode); uint32_t textureUniqueID = fCurrTexture->getUniqueID(); if (textureUniqueID != fEffectTextureUniqueID || fCachedGeometryProcessor->color() != color || diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp index 47d408f7f8..a9fe4c9bf6 100755 --- a/src/gpu/GrDistanceFieldTextContext.cpp +++ b/src/gpu/GrDistanceFieldTextContext.cpp @@ -10,6 +10,7 @@ #include "GrBitmapTextContext.h" #include "GrDrawTarget.h" #include "GrDrawTargetCaps.h" +#include "GrFontAtlasSizes.h" #include "GrFontCache.h" #include "GrFontScaler.h" #include "GrGpu.h" @@ -33,9 +34,10 @@ SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, static const int kSmallDFFontSize = 32; static const int kSmallDFFontLimit = 32; -static const int kMediumDFFontSize = 78; -static const int kMediumDFFontLimit = 78; -static const int kLargeDFFontSize = 192; +static const int kMediumDFFontSize = 70; +static const int kMediumDFFontLimit = 70; +static const int kLargeDFFontSize = 156; +SK_COMPILE_ASSERT(GR_SDF_MAX_SIZE >= kLargeDFFontSize, sdf_too_big); static const int kVerticesPerGlyph = 4; static const int kIndicesPerGlyph = 6; @@ -400,7 +402,7 @@ static void* alloc_vertices(GrDrawTarget* drawTarget, } void GrDistanceFieldTextContext::setupCoverageEffect(const SkColor& filteredColor) { - GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBilerp_FilterMode); + GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBilerp_FilterMode); GrTextureParams gammaParams(SkShader::kClamp_TileMode, GrTextureParams::kNone_FilterMode); uint32_t textureUniqueID = fCurrTexture->getUniqueID(); diff --git a/src/gpu/GrFontAtlasSizes.h b/src/gpu/GrFontAtlasSizes.h index 24897e4a7a..5a1821cdce 100644 --- a/src/gpu/GrFontAtlasSizes.h +++ b/src/gpu/GrFontAtlasSizes.h @@ -9,20 +9,27 @@ #ifndef GrFontAtlasSizes_DEFINED #define GrFontAtlasSizes_DEFINED -#define GR_FONT_ATLAS_TEXTURE_WIDTH 1024 -#define GR_FONT_ATLAS_TEXTURE_HEIGHT 2048 +#include "SkDistanceFieldGen.h" -#define GR_FONT_ATLAS_PLOT_WIDTH 256 -#define GR_FONT_ATLAS_PLOT_HEIGHT 256 +#define GR_SDF_MAX_SIZE 156 -#define GR_FONT_ATLAS_NUM_PLOTS_X (GR_FONT_ATLAS_TEXTURE_WIDTH / GR_FONT_ATLAS_PLOT_WIDTH) -#define GR_FONT_ATLAS_NUM_PLOTS_Y (GR_FONT_ATLAS_TEXTURE_HEIGHT / GR_FONT_ATLAS_PLOT_HEIGHT) +// allows us to fit four of the largest distance field glyphs +#define GR_FONT_ATLAS_PLOT_WIDTH (2*(GR_SDF_MAX_SIZE+2*SK_DistanceFieldPad)) +#define GR_FONT_ATLAS_PLOT_HEIGHT (2*(GR_SDF_MAX_SIZE+2*SK_DistanceFieldPad)) + +#define GR_FONT_ATLAS_NUM_PLOTS_X 5 +#define GR_FONT_ATLAS_NUM_PLOTS_Y 6 + +#define GR_FONT_ATLAS_TEXTURE_WIDTH (GR_FONT_ATLAS_PLOT_WIDTH*GR_FONT_ATLAS_NUM_PLOTS_X) +SK_COMPILE_ASSERT(GR_FONT_ATLAS_TEXTURE_WIDTH == 1640, font_atlas_unexpected_size); +#define GR_FONT_ATLAS_TEXTURE_HEIGHT (GR_FONT_ATLAS_PLOT_HEIGHT*GR_FONT_ATLAS_NUM_PLOTS_Y) +SK_COMPILE_ASSERT(GR_FONT_ATLAS_TEXTURE_HEIGHT == 1968, font_atlas_unexpected_size); // one over width and height -#define GR_FONT_ATLAS_RECIP_WIDTH "0.0009765625" -#define GR_FONT_ATLAS_RECIP_HEIGHT "0.00048828125" +#define GR_FONT_ATLAS_RECIP_WIDTH "0.00060975609" +#define GR_FONT_ATLAS_RECIP_HEIGHT "0.00050813008" // 1/(3*width) -#define GR_FONT_ATLAS_LCD_DELTA "0.00032552083" +#define GR_FONT_ATLAS_LCD_DELTA "0.00020325203" #endif |