aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-06-19 04:46:45 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-06-19 04:46:45 -0700
commit9fc8275a9b87716775919ec302469a7cfd68ba97 (patch)
tree9b4d733ddffed285463e02a836d0bbc4c4c9a078 /src/gpu
parentce777c9ea30f7c1192f75bbfa34df3d7b34cd962 (diff)
Remove gamma field from SkDeviceProperties
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrAtlasTextContext.cpp30
-rw-r--r--src/gpu/GrAtlasTextContext.h11
2 files changed, 15 insertions, 26 deletions
diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp
index 900d681b50..7252d76ca2 100644
--- a/src/gpu/GrAtlasTextContext.cpp
+++ b/src/gpu/GrAtlasTextContext.cpp
@@ -99,7 +99,7 @@ GrAtlasTextContext::GrAtlasTextContext(GrContext* context,
GrDrawContext* drawContext,
const SkDeviceProperties& properties)
: INHERITED(context, drawContext, properties)
- , fDistanceAdjustTable(SkNEW_ARGS(DistanceAdjustTable, (properties.gamma()))) {
+ , fDistanceAdjustTable(SkNEW(DistanceAdjustTable)) {
// We overallocate vertices in our textblobs based on the assumption that A8 has the greatest
// vertexStride
SK_COMPILE_ASSERT(kGrayTextVASize >= kColorTextVASize && kGrayTextVASize >= kLCDTextVASize,
@@ -108,7 +108,7 @@ GrAtlasTextContext::GrAtlasTextContext(GrContext* context,
fCache = context->getTextBlobCache();
}
-void GrAtlasTextContext::DistanceAdjustTable::buildDistanceAdjustTable(float gamma) {
+void GrAtlasTextContext::DistanceAdjustTable::buildDistanceAdjustTable() {
// This is used for an approximation of the mask gamma hack, used by raster and bitmap
// text. The mask gamma hack is based off of guessing what the blend color is going to
@@ -153,8 +153,8 @@ void GrAtlasTextContext::DistanceAdjustTable::buildDistanceAdjustTable(float gam
#else
SkScalar contrast = 0.5f;
#endif
- SkScalar paintGamma = gamma;
- SkScalar deviceGamma = gamma;
+ SkScalar paintGamma = SK_GAMMA_EXPONENT;
+ SkScalar deviceGamma = SK_GAMMA_EXPONENT;
size = SkScalerContext::GetGammaLUTSize(contrast, paintGamma, deviceGamma,
&width, &height);
@@ -1450,9 +1450,9 @@ public:
GrBatchFontCache* fontCache,
DistanceAdjustTable* distanceAdjustTable,
SkColor filteredColor, bool useLCDText,
- bool useBGR, float gamma) {
+ bool useBGR) {
return SkNEW_ARGS(BitmapTextBatch, (maskFormat, glyphCount, fontCache, distanceAdjustTable,
- filteredColor, useLCDText, useBGR, gamma));
+ filteredColor, useLCDText, useBGR));
}
const char* name() const override { return "BitmapTextBatch"; }
@@ -1773,7 +1773,7 @@ private:
BitmapTextBatch(GrMaskFormat maskFormat, int glyphCount, GrBatchFontCache* fontCache,
DistanceAdjustTable* distanceAdjustTable, SkColor filteredColor,
- bool useLCDText, bool useBGR, float gamma)
+ bool useLCDText, bool useBGR)
: fMaskFormat(maskFormat)
, fPixelConfig(fontCache->getPixelConfig(maskFormat))
, fFontCache(fontCache)
@@ -1781,8 +1781,7 @@ private:
, fFilteredColor(filteredColor)
, fUseDistanceFields(true)
, fUseLCDText(useLCDText)
- , fUseBGR(useBGR)
- , fGamma(gamma) {
+ , fUseBGR(useBGR) {
this->initClassID<BitmapTextBatch>();
fBatch.fNumGlyphs = glyphCount;
fInstanceCount = 1;
@@ -1912,10 +1911,6 @@ private:
return false;
}
- if (fGamma != that->fGamma) {
- return false;
- }
-
// TODO see note above
if (fUseLCDText && this->color() != that->color()) {
return false;
@@ -1986,7 +1981,7 @@ private:
} else {
flags |= kColorAttr_DistanceFieldEffectFlag;
#ifdef SK_GAMMA_APPLY_TO_A8
- U8CPU lum = SkColorSpaceLuminance::computeLuminance(fGamma, filteredColor);
+ U8CPU lum = SkColorSpaceLuminance::computeLuminance(SK_GAMMA_EXPONENT, filteredColor);
float correction = (*fDistanceAdjustTable)[lum >> kDistanceAdjustLumShift];
return GrDistanceFieldA8TextGeoProc::Create(color,
viewMatrix,
@@ -2025,12 +2020,11 @@ private:
GrBatchFontCache* fFontCache;
// Distance field properties
- SkAutoTUnref<DistanceAdjustTable> fDistanceAdjustTable;
+ SkAutoTUnref<const DistanceAdjustTable> fDistanceAdjustTable;
SkColor fFilteredColor;
bool fUseDistanceFields;
bool fUseLCDText;
bool fUseBGR;
- float fGamma;
};
void GrAtlasTextContext::flushRunAsPaths(GrRenderTarget* rt, const SkTextBlob::RunIterator& it,
@@ -2095,11 +2089,9 @@ GrAtlasTextContext::createBatch(BitmapTextBlob* cacheBlob, const PerSubRunInfo&
filteredColor = skPaint.getColor();
}
bool useBGR = SkPixelGeometryIsBGR(fDeviceProperties.pixelGeometry());
- float gamma = fDeviceProperties.gamma();
batch = BitmapTextBatch::Create(format, glyphCount, fContext->getBatchFontCache(),
fDistanceAdjustTable, filteredColor,
- info.fUseLCDText, useBGR,
- gamma);
+ info.fUseLCDText, useBGR);
} else {
batch = BitmapTextBatch::Create(format, glyphCount, fContext->getBatchFontCache());
}
diff --git a/src/gpu/GrAtlasTextContext.h b/src/gpu/GrAtlasTextContext.h
index 68ec870039..0805077d9d 100644
--- a/src/gpu/GrAtlasTextContext.h
+++ b/src/gpu/GrAtlasTextContext.h
@@ -366,19 +366,16 @@ private:
// Because the GrAtlasTextContext can go out of scope before the final flush, this needs to be
// refcnted and malloced
struct DistanceAdjustTable : public SkNVRefCnt<DistanceAdjustTable> {
- DistanceAdjustTable(float gamma) { this->buildDistanceAdjustTable(gamma); }
+ DistanceAdjustTable() { this->buildDistanceAdjustTable(); }
~DistanceAdjustTable() { SkDELETE_ARRAY(fTable); }
- void buildDistanceAdjustTable(float gamma);
-
- SkScalar& operator[] (int i) {
- return fTable[i];
- }
-
const SkScalar& operator[] (int i) const {
return fTable[i];
}
+ private:
+ void buildDistanceAdjustTable();
+
SkScalar* fTable;
};