diff options
author | Herb Derby <herb@google.com> | 2018-02-22 11:10:10 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-22 17:42:50 +0000 |
commit | f5041623ddf416a59ad29a4873a7b7325162a389 (patch) | |
tree | ea690586707efeef677523e2138df19b11aa0b9c /src/core | |
parent | 085bc523634ee3156cd4e5bc05d8907739b54e4c (diff) |
Small cleanup of SkPaint
Change-Id: I79d4e5bace8898c184d8fc80d9e45d39b63b5fe5
Reviewed-on: https://skia-review.googlesource.com/109386
Commit-Queue: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkPaint.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index 2e5d22c538..f754c021eb 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -1214,7 +1214,7 @@ SkRect SkPaint::getFontBounds() const { // return true if the paint is just a single color (i.e. not a shader). If its // a shader, then we can't compute a const luminance for it :( -static bool justAColor(const SkPaint& paint, SkColor* color) { +static bool just_a_color(const SkPaint& paint, SkColor* color) { SkColor c = paint.getColor(); const auto* shader = as_SB(paint.getShader()); @@ -1232,14 +1232,12 @@ static bool justAColor(const SkPaint& paint, SkColor* color) { SkColor SkPaint::computeLuminanceColor() const { SkColor c; - if (!justAColor(*this, &c)) { + if (!just_a_color(*this, &c)) { c = SkColorSetRGB(0x7F, 0x80, 0x7F); } return c; } -#define assert_byte(x) SkASSERT(0 == ((x) >> 8)) - /** * In order to call cachedDeviceLuminance, cachedPaintLuminance, or * cachedMaskGamma the caller must hold the gMaskGammaCacheMutex and continue @@ -1252,11 +1250,13 @@ static SkMaskGamma* gMaskGamma = nullptr; static SkScalar gContrast = SK_ScalarMin; static SkScalar gPaintGamma = SK_ScalarMin; static SkScalar gDeviceGamma = SK_ScalarMin; + /** * The caller must hold the gMaskGammaCacheMutex and continue to hold it until * the returned SkMaskGamma pointer is refed or forgotten. */ -static const SkMaskGamma& cachedMaskGamma(SkScalar contrast, SkScalar paintGamma, SkScalar deviceGamma) { +static const SkMaskGamma& cached_mask_gamma(SkScalar contrast, SkScalar paintGamma, + SkScalar deviceGamma) { gMaskGammaCacheMutex.assertHeld(); if (0 == contrast && SK_Scalar1 == paintGamma && SK_Scalar1 == deviceGamma) { if (nullptr == gLinearMaskGamma) { @@ -1274,25 +1274,23 @@ static const SkMaskGamma& cachedMaskGamma(SkScalar contrast, SkScalar paintGamma return *gMaskGamma; } - /** * Expands fDeviceGamma, fPaintGamma, fContrast, and fLumBits into a mask pre-blend. */ -//static SkMaskGamma::PreBlend SkScalerContext::GetMaskPreBlend(const SkScalerContextRec& rec) { SkAutoMutexAcquire ama(gMaskGammaCacheMutex); - const SkMaskGamma& maskGamma = cachedMaskGamma(rec.getContrast(), - rec.getPaintGamma(), - rec.getDeviceGamma()); + const SkMaskGamma& maskGamma = cached_mask_gamma(rec.getContrast(), + rec.getPaintGamma(), + rec.getDeviceGamma()); return maskGamma.preBlend(rec.getLuminanceColor()); } size_t SkScalerContext::GetGammaLUTSize(SkScalar contrast, SkScalar paintGamma, SkScalar deviceGamma, int* width, int* height) { SkAutoMutexAcquire ama(gMaskGammaCacheMutex); - const SkMaskGamma& maskGamma = cachedMaskGamma(contrast, - paintGamma, - deviceGamma); + const SkMaskGamma& maskGamma = cached_mask_gamma(contrast, + paintGamma, + deviceGamma); maskGamma.getGammaTableDimensions(width, height); size_t size = (*width)*(*height)*sizeof(uint8_t); @@ -1303,9 +1301,9 @@ size_t SkScalerContext::GetGammaLUTSize(SkScalar contrast, SkScalar paintGamma, bool SkScalerContext::GetGammaLUTData(SkScalar contrast, SkScalar paintGamma, SkScalar deviceGamma, uint8_t* data) { SkAutoMutexAcquire ama(gMaskGammaCacheMutex); - const SkMaskGamma& maskGamma = cachedMaskGamma(contrast, - paintGamma, - deviceGamma); + const SkMaskGamma& maskGamma = cached_mask_gamma(contrast, + paintGamma, + deviceGamma); const uint8_t* gammaTables = maskGamma.getGammaTables(); if (!gammaTables) { return false; |