| /* | |
| * Copyright 2018 Google Inc. | |
| * | |
| * Use of this source code is governed by a BSD-style license that can be | |
| * found in the LICENSE file. | |
| */ | |
| #include "SkFontPriv.h" | |
| #include "SkGraphics.h" | |
| #include "SkMatrix.h" | |
| static SkScalar mag2(SkScalar x, SkScalar y) { | |
| return x * x + y * y; | |
| } | |
| static bool tooBig(const SkMatrix& m, SkScalar ma2max) { | |
| return mag2(m[SkMatrix::kMScaleX], m[SkMatrix::kMSkewY]) > ma2max | |
| || | |
| mag2(m[SkMatrix::kMSkewX], m[SkMatrix::kMScaleY]) > ma2max; | |
| } | |
| bool SkFontPriv::TooBigToUseCache(const SkMatrix& ctm, const SkMatrix& textM, SkScalar maxLimit) { | |
| SkASSERT(!ctm.hasPerspective()); | |
| SkASSERT(!textM.hasPerspective()); | |
| SkMatrix matrix; | |
| matrix.setConcat(ctm, textM); | |
| return tooBig(matrix, MaxCacheSize2(maxLimit)); | |
| } | |
| SkScalar SkFontPriv::MaxCacheSize2(SkScalar maxLimit) { | |
| // we have a self-imposed maximum, just for memory-usage sanity | |
| const int limit = SkMin32(SkGraphics::GetFontCachePointSizeLimit(), maxLimit); | |
| const SkScalar maxSize = SkIntToScalar(limit); | |
| return maxSize * maxSize; | |
| } |