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

Unified Diff: src/gpu/GrDistanceFieldTextContext.cpp

Issue 323513005: Revert of Gamma correction for distance field text. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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
« no previous file with comments | « src/gpu/GrDistanceFieldTextContext.h ('k') | src/gpu/effects/GrDistanceFieldTextureEffect.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDistanceFieldTextContext.cpp
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp
index a7299393bdaa729da726e916e97e86c29d43b2e0..2d2f9a14432dd7aae4a719e6469858f30bb8ef84 100755
--- a/src/gpu/GrDistanceFieldTextContext.cpp
+++ b/src/gpu/GrDistanceFieldTextContext.cpp
@@ -7,12 +7,10 @@
#include "GrDistanceFieldTextContext.h"
#include "GrAtlas.h"
-#include "SkColorFilter.h"
#include "GrDrawTarget.h"
#include "GrDrawTargetCaps.h"
#include "GrFontScaler.h"
#include "SkGlyphCache.h"
-#include "GrGpu.h"
#include "GrIndexBuffer.h"
#include "GrTextStrike.h"
#include "GrTextStrike_impl.h"
@@ -45,7 +43,6 @@
fEnableDFRendering = enable;
#endif
fStrike = NULL;
- fGammaTexture = NULL;
fCurrTexture = NULL;
fCurrVertex = 0;
@@ -56,7 +53,6 @@
GrDistanceFieldTextContext::~GrDistanceFieldTextContext() {
this->flushGlyphs();
- SkSafeSetNull(fGammaTexture);
}
bool GrDistanceFieldTextContext::canDraw(const SkPaint& paint) {
@@ -111,26 +107,14 @@
SkASSERT(SkIsAlign4(fCurrVertex));
SkASSERT(fCurrTexture);
GrTextureParams params(SkShader::kRepeat_TileMode, GrTextureParams::kBilerp_FilterMode);
- GrTextureParams gammaParams(SkShader::kClamp_TileMode, GrTextureParams::kNone_FilterMode);
// Effects could be stored with one of the cache objects (atlas?)
- SkColor filteredColor;
- SkColorFilter* colorFilter = fSkPaint.getColorFilter();
- if (NULL != colorFilter) {
- filteredColor = colorFilter->filterColor(fSkPaint.getColor());
- } else {
- filteredColor = fSkPaint.getColor();
- }
if (fUseLCDText) {
- GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredColor);
bool useBGR = SkDeviceProperties::Geometry::kBGR_Layout ==
fDeviceProperties.fGeometry.getLayout();
drawState->addCoverageEffect(GrDistanceFieldLCDTextureEffect::Create(
fCurrTexture,
params,
- fGammaTexture,
- gammaParams,
- colorNoPreMul,
fContext->getMatrix().rectStaysRect() &&
fContext->getMatrix().isSimilarity(),
useBGR),
@@ -149,24 +133,13 @@
// paintAlpha
drawState->setColor(SkColorSetARGB(a, a, a, a));
// paintColor
- drawState->setBlendConstant(colorNoPreMul);
+ drawState->setBlendConstant(skcolor_to_grcolor_nopremultiply(fSkPaint.getColor()));
drawState->setBlendFunc(kConstC_GrBlendCoeff, kISC_GrBlendCoeff);
} else {
-#ifdef SK_GAMMA_APPLY_TO_A8
- U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDeviceProperties.fGamma,
- filteredColor);
- drawState->addCoverageEffect(GrDistanceFieldTextureEffect::Create(
- fCurrTexture, params,
- fGammaTexture, gammaParams,
- lum/255.f,
+ drawState->addCoverageEffect(GrDistanceFieldTextureEffect::Create(fCurrTexture, params,
fContext->getMatrix().isSimilarity()),
kGlyphCoordsAttributeIndex)->unref();
-#else
- drawState->addCoverageEffect(GrDistanceFieldTextureEffect::Create(
- fCurrTexture, params,
- fContext->getMatrix().isSimilarity()),
- kGlyphCoordsAttributeIndex)->unref();
-#endif
+
// set back to normal in case we took LCD path previously.
drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDstBlendCoeff());
drawState->setColor(fPaint.getColor());
@@ -383,55 +356,13 @@
fSkPaint.setLCDRenderText(false);
fSkPaint.setAutohinted(false);
- fSkPaint.setHinting(SkPaint::kNormal_Hinting);
fSkPaint.setSubpixelText(true);
-
}
inline void GrDistanceFieldTextContext::finish() {
flushGlyphs();
GrTextContext::finish();
-}
-
-static void setup_gamma_texture(GrContext* context, const SkGlyphCache* cache,
- const SkDeviceProperties& deviceProperties,
- GrTexture** gammaTexture) {
- if (NULL == *gammaTexture) {
- int width, height;
- size_t size;
-
-#ifdef SK_GAMMA_CONTRAST
- SkScalar contrast = SK_GAMMA_CONTRAST;
-#else
- SkScalar contrast = 0.5f;
-#endif
- SkScalar paintGamma = deviceProperties.fGamma;
- SkScalar deviceGamma = deviceProperties.fGamma;
-
- size = SkScalerContext::GetGammaLUTSize(contrast, paintGamma, deviceGamma,
- &width, &height);
-
- SkAutoTArray<uint8_t> data((int)size);
- SkScalerContext::GetGammaLUTData(contrast, paintGamma, deviceGamma, data.get());
-
- // TODO: Update this to use the cache rather than directly creating a texture.
- GrTextureDesc desc;
- desc.fFlags = kDynamicUpdate_GrTextureFlagBit;
- desc.fWidth = width;
- desc.fHeight = height;
- desc.fConfig = kAlpha_8_GrPixelConfig;
-
- *gammaTexture = context->getGpu()->createTexture(desc, NULL, 0);
- if (NULL == *gammaTexture) {
- return;
- }
-
- context->writeTexturePixels(*gammaTexture,
- 0, 0, width, height,
- (*gammaTexture)->config(), data.get(), 0,
- GrContext::kDontFlush_PixelOpsFlag);
- }
}
void GrDistanceFieldTextContext::drawText(const GrPaint& paint, const SkPaint& skPaint,
@@ -451,11 +382,9 @@
SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
- SkAutoGlyphCacheNoGamma autoCache(fSkPaint, &fDeviceProperties, NULL);
- SkGlyphCache* cache = autoCache.getCache();
- GrFontScaler* fontScaler = GetGrFontScaler(cache);
-
- setup_gamma_texture(fContext, cache, fDeviceProperties, &fGammaTexture);
+ SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, NULL);
+ SkGlyphCache* cache = autoCache.getCache();
+ GrFontScaler* fontScaler = GetGrFontScaler(cache);
// need to measure first
// TODO - generate positions and pre-load cache as well?
@@ -526,11 +455,9 @@
SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
- SkAutoGlyphCacheNoGamma autoCache(fSkPaint, &fDeviceProperties, NULL);
- SkGlyphCache* cache = autoCache.getCache();
- GrFontScaler* fontScaler = GetGrFontScaler(cache);
-
- setup_gamma_texture(fContext, cache, fDeviceProperties, &fGammaTexture);
+ SkAutoGlyphCache autoCache(fSkPaint, &fDeviceProperties, NULL);
+ SkGlyphCache* cache = autoCache.getCache();
+ GrFontScaler* fontScaler = GetGrFontScaler(cache);
const char* stop = text + byteLength;
« no previous file with comments | « src/gpu/GrDistanceFieldTextContext.h ('k') | src/gpu/effects/GrDistanceFieldTextureEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698