Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Unified Diff: src/core/SkPaint.cpp

Issue 258883002: Gamma correction for distance field text. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add comments for the magic bold factor Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/core/SkPaint.cpp
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index f3bf01bfafc5ca30e0507190a8ffee37f8a5efaa..fcd95054bdf33711f9fb0216dfc24cb1e9478f75 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -1773,7 +1773,7 @@ static const SkMaskGamma& cachedMaskGamma(SkScalar contrast, SkScalar paintGamma
/**
* We ensure that the rec is self-consistent and efficient (where possible)
*/
-void SkScalerContext::PostMakeRec(const SkPaint&, SkScalerContext::Rec* rec) {
+void SkScalerContext::PostMakeRec(const SkPaint& paint, SkScalerContext::Rec* rec) {
/**
* If we're asking for A8, we force the colorlum to be gray, since that
* limits the number of unique entries, and the scaler will only look at
@@ -1809,6 +1809,23 @@ void SkScalerContext::PostMakeRec(const SkPaint&, SkScalerContext::Rec* rec) {
rec->ignorePreBlend();
break;
}
+
+ /**
+ * If we're using distance fields we need to reset the rec to default values
+ */
+ if (paint.isDistanceFieldTextTEMP()) {
+ rec->ignorePreBlend();
+
+ rec->fFlags |= SkScalerContext::kSubpixelPositioning_Flag;
+ rec->fFlags &= ~SkScalerContext::kForceAutohinting_Flag;
reed1 2014/05/28 19:45:17 other than preblend, this rest of this change seem
jvanverth1 2014/05/29 18:53:49 This was done in GrDistanceFieldTextContext::init(
+
+ if (SkMask::kLCD16_Format == rec->fMaskFormat ||
+ SkMask::kLCD32_Format == rec->fMaskFormat) {
+ rec->fMaskFormat = SkMask::kA8_Format;
+ }
+ rec->setHinting(SkPaint::kNo_Hinting);
+ }
+
}
#define MIN_SIZE_FOR_EFFECT_BUFFER 1024
@@ -1974,6 +1991,21 @@ SkMaskGamma::PreBlend SkScalerContext::GetMaskPreBlend(const SkScalerContext::Re
return maskGamma.preBlend(rec.getLuminanceColor());
}
+void* SkScalerContext::getGammaLUTData(int& width, int& height, SkScalar contrast,
reed1 2014/05/28 19:45:17 style again: use pointers for out-params
jvanverth1 2014/05/29 18:53:49 Done.
+ SkScalar paintGamma, SkScalar deviceGamma) {
+ SkAutoMutexAcquire ama(gMaskGammaCacheMutex);
+ const SkMaskGamma& maskGamma = cachedMaskGamma(contrast,
+ paintGamma,
+ deviceGamma);
+ const uint8_t* gammaTables = maskGamma.getGammaTables(width, height);
+ size_t size = width*height*sizeof(uint8_t);
+ void* data = SkNEW_ARRAY(uint8_t, size);
+ memcpy(data, gammaTables, size);
+
+ return data;
+}
+
+
///////////////////////////////////////////////////////////////////////////////
#include "SkStream.h"

Powered by Google App Engine
This is Rietveld 408576698