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

Side by Side Diff: src/core/SkPaint.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 unified diff | Download patch
« no previous file with comments | « src/core/SkMaskGamma.h ('k') | src/core/SkScalerContext.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkPaint.h" 8 #include "SkPaint.h"
9 #include "SkAnnotation.h" 9 #include "SkAnnotation.h"
10 #include "SkAutoKern.h" 10 #include "SkAutoKern.h"
(...skipping 1796 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 } 1807 }
1808 1808
1809 #define MIN_SIZE_FOR_EFFECT_BUFFER 1024 1809 #define MIN_SIZE_FOR_EFFECT_BUFFER 1024
1810 1810
1811 #ifdef SK_DEBUG 1811 #ifdef SK_DEBUG
1812 #define TEST_DESC 1812 #define TEST_DESC
1813 #endif 1813 #endif
1814 1814
1815 /* 1815 /*
1816 * ignoreGamma tells us that the caller just wants metrics that are unaffected 1816 * ignoreGamma tells us that the caller just wants metrics that are unaffected
1817 * by gamma correction, so we set the rec to ignore preblend: i.e. gamma = 1, 1817 * by gamma correction, so we jam the luminance field to 0 (most common value
1818 * contrast = 0, luminanceColor = transparent black. 1818 * for black text) in hopes that we get a cache hit easier. A better solution
1819 * would be for the fontcache lookup to know to ignore the luminance field
1820 * entirely, but not sure how to do that and keep it fast.
1819 */ 1821 */
1820 void SkPaint::descriptorProc(const SkDeviceProperties* deviceProperties, 1822 void SkPaint::descriptorProc(const SkDeviceProperties* deviceProperties,
1821 const SkMatrix* deviceMatrix, 1823 const SkMatrix* deviceMatrix,
1822 void (*proc)(SkTypeface*, const SkDescriptor*, void *), 1824 void (*proc)(SkTypeface*, const SkDescriptor*, void *),
1823 void* context, bool ignoreGamma) const { 1825 void* context, bool ignoreGamma) const {
1824 SkScalerContext::Rec rec; 1826 SkScalerContext::Rec rec;
1825 1827
1826 SkScalerContext::MakeRec(*this, deviceProperties, deviceMatrix, &rec); 1828 SkScalerContext::MakeRec(*this, deviceProperties, deviceMatrix, &rec);
1827 if (ignoreGamma) { 1829 if (ignoreGamma) {
1828 rec.ignorePreBlend(); 1830 rec.setLuminanceColor(0);
1829 } 1831 }
1830 1832
1831 size_t descSize = sizeof(rec); 1833 size_t descSize = sizeof(rec);
1832 int entryCount = 1; 1834 int entryCount = 1;
1833 SkPathEffect* pe = this->getPathEffect(); 1835 SkPathEffect* pe = this->getPathEffect();
1834 SkMaskFilter* mf = this->getMaskFilter(); 1836 SkMaskFilter* mf = this->getMaskFilter();
1835 SkRasterizer* ra = this->getRasterizer(); 1837 SkRasterizer* ra = this->getRasterizer();
1836 1838
1837 SkWriteBuffer peBuffer, mfBuffer, raBuffer; 1839 SkWriteBuffer peBuffer, mfBuffer, raBuffer;
1838 1840
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 desc2->computeChecksum(); 1944 desc2->computeChecksum();
1943 SkASSERT(!memcmp(desc, desc1, descSize)); 1945 SkASSERT(!memcmp(desc, desc1, descSize));
1944 SkASSERT(!memcmp(desc, desc2, descSize)); 1946 SkASSERT(!memcmp(desc, desc2, descSize));
1945 } 1947 }
1946 #endif 1948 #endif
1947 1949
1948 proc(fTypeface, desc, context); 1950 proc(fTypeface, desc, context);
1949 } 1951 }
1950 1952
1951 SkGlyphCache* SkPaint::detachCache(const SkDeviceProperties* deviceProperties, 1953 SkGlyphCache* SkPaint::detachCache(const SkDeviceProperties* deviceProperties,
1952 const SkMatrix* deviceMatrix, 1954 const SkMatrix* deviceMatrix) const {
1953 bool ignoreGamma) const {
1954 SkGlyphCache* cache; 1955 SkGlyphCache* cache;
1955 this->descriptorProc(deviceProperties, deviceMatrix, DetachDescProc, &cache, ignoreGamma); 1956 this->descriptorProc(deviceProperties, deviceMatrix, DetachDescProc, &cache, false);
1956 return cache; 1957 return cache;
1957 } 1958 }
1958 1959
1959 /** 1960 /**
1960 * Expands fDeviceGamma, fPaintGamma, fContrast, and fLumBits into a mask pre-bl end. 1961 * Expands fDeviceGamma, fPaintGamma, fContrast, and fLumBits into a mask pre-bl end.
1961 */ 1962 */
1962 //static 1963 //static
1963 SkMaskGamma::PreBlend SkScalerContext::GetMaskPreBlend(const SkScalerContext::Re c& rec) { 1964 SkMaskGamma::PreBlend SkScalerContext::GetMaskPreBlend(const SkScalerContext::Re c& rec) {
1964 SkAutoMutexAcquire ama(gMaskGammaCacheMutex); 1965 SkAutoMutexAcquire ama(gMaskGammaCacheMutex);
1965 const SkMaskGamma& maskGamma = cachedMaskGamma(rec.getContrast(), 1966 const SkMaskGamma& maskGamma = cachedMaskGamma(rec.getContrast(),
1966 rec.getPaintGamma(), 1967 rec.getPaintGamma(),
1967 rec.getDeviceGamma()); 1968 rec.getDeviceGamma());
1968 return maskGamma.preBlend(rec.getLuminanceColor()); 1969 return maskGamma.preBlend(rec.getLuminanceColor());
1969 } 1970 }
1970 1971
1971 size_t SkScalerContext::GetGammaLUTSize(SkScalar contrast, SkScalar paintGamma,
1972 SkScalar deviceGamma, int* width, int* h eight) {
1973 SkAutoMutexAcquire ama(gMaskGammaCacheMutex);
1974 const SkMaskGamma& maskGamma = cachedMaskGamma(contrast,
1975 paintGamma,
1976 deviceGamma);
1977
1978 maskGamma.getGammaTableDimensions(width, height);
1979 size_t size = (*width)*(*height)*sizeof(uint8_t);
1980
1981 return size;
1982 }
1983
1984 void SkScalerContext::GetGammaLUTData(SkScalar contrast, SkScalar paintGamma, Sk Scalar deviceGamma,
1985 void* data) {
1986 SkAutoMutexAcquire ama(gMaskGammaCacheMutex);
1987 const SkMaskGamma& maskGamma = cachedMaskGamma(contrast,
1988 paintGamma,
1989 deviceGamma);
1990 int width, height;
1991 maskGamma.getGammaTableDimensions(&width, &height);
1992 size_t size = width*height*sizeof(uint8_t);
1993 const uint8_t* gammaTables = maskGamma.getGammaTables();
1994 memcpy(data, gammaTables, size);
1995 }
1996
1997
1998 /////////////////////////////////////////////////////////////////////////////// 1972 ///////////////////////////////////////////////////////////////////////////////
1999 1973
2000 #include "SkStream.h" 1974 #include "SkStream.h"
2001 1975
2002 static uintptr_t asint(const void* p) { 1976 static uintptr_t asint(const void* p) {
2003 return reinterpret_cast<uintptr_t>(p); 1977 return reinterpret_cast<uintptr_t>(p);
2004 } 1978 }
2005 1979
2006 union Scalar32 { 1980 union Scalar32 {
2007 SkScalar fScalar; 1981 SkScalar fScalar;
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
2576 } 2550 }
2577 } else { 2551 } else {
2578 fScale = SK_Scalar1; 2552 fScale = SK_Scalar1;
2579 } 2553 }
2580 2554
2581 if (!applyStrokeAndPathEffects) { 2555 if (!applyStrokeAndPathEffects) {
2582 fPaint.setStyle(SkPaint::kFill_Style); 2556 fPaint.setStyle(SkPaint::kFill_Style);
2583 fPaint.setPathEffect(NULL); 2557 fPaint.setPathEffect(NULL);
2584 } 2558 }
2585 2559
2586 fCache = fPaint.detachCache(NULL, NULL, false); 2560 fCache = fPaint.detachCache(NULL, NULL);
2587 2561
2588 SkPaint::Style style = SkPaint::kFill_Style; 2562 SkPaint::Style style = SkPaint::kFill_Style;
2589 SkPathEffect* pe = NULL; 2563 SkPathEffect* pe = NULL;
2590 2564
2591 if (!applyStrokeAndPathEffects) { 2565 if (!applyStrokeAndPathEffects) {
2592 style = paint.getStyle(); // restore 2566 style = paint.getStyle(); // restore
2593 pe = paint.getPathEffect(); // restore 2567 pe = paint.getPathEffect(); // restore
2594 } 2568 }
2595 fPaint.setStyle(style); 2569 fPaint.setStyle(style);
2596 fPaint.setPathEffect(pe); 2570 fPaint.setPathEffect(pe);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
2755 } 2729 }
2756 #ifdef SK_BUILD_FOR_ANDROID 2730 #ifdef SK_BUILD_FOR_ANDROID
2757 if (dirty & kPaintOptionsAndroid_DirtyBit) { 2731 if (dirty & kPaintOptionsAndroid_DirtyBit) {
2758 SkPaintOptionsAndroid options; 2732 SkPaintOptionsAndroid options;
2759 options.unflatten(buffer); 2733 options.unflatten(buffer);
2760 paint->setPaintOptionsAndroid(options); 2734 paint->setPaintOptionsAndroid(options);
2761 } 2735 }
2762 #endif 2736 #endif
2763 SkASSERT(dirty == paint->fDirtyBits); 2737 SkASSERT(dirty == paint->fDirtyBits);
2764 } 2738 }
OLDNEW
« no previous file with comments | « src/core/SkMaskGamma.h ('k') | src/core/SkScalerContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698