OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkPaint.h" | 9 #include "SkPaint.h" |
10 #include "SkAnnotation.h" | 10 #include "SkAnnotation.h" |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 fPrivFlags = SkSetClearMask(fPrivFlags, isNoDraw, kNoDrawAnnotation_PrivFlag
); | 407 fPrivFlags = SkSetClearMask(fPrivFlags, isNoDraw, kNoDrawAnnotation_PrivFlag
); |
408 | 408 |
409 return annotation; | 409 return annotation; |
410 } | 410 } |
411 | 411 |
412 /////////////////////////////////////////////////////////////////////////////// | 412 /////////////////////////////////////////////////////////////////////////////// |
413 | 413 |
414 #include "SkGlyphCache.h" | 414 #include "SkGlyphCache.h" |
415 #include "SkUtils.h" | 415 #include "SkUtils.h" |
416 | 416 |
417 static void DetachDescProc(const SkDescriptor* desc, void* context) { | 417 static void DetachDescProc(SkTypeface* typeface, const SkDescriptor* desc, |
418 *((SkGlyphCache**)context) = SkGlyphCache::DetachCache(desc); | 418 void* context) { |
| 419 *((SkGlyphCache**)context) = SkGlyphCache::DetachCache(typeface, desc); |
419 } | 420 } |
420 | 421 |
421 #ifdef SK_BUILD_FOR_ANDROID | 422 #ifdef SK_BUILD_FOR_ANDROID |
422 const SkGlyph& SkPaint::getUnicharMetrics(SkUnichar text, | 423 const SkGlyph& SkPaint::getUnicharMetrics(SkUnichar text, |
423 const SkMatrix* deviceMatrix) { | 424 const SkMatrix* deviceMatrix) { |
424 SkGlyphCache* cache; | 425 SkGlyphCache* cache; |
425 descriptorProc(NULL, deviceMatrix, DetachDescProc, &cache, true); | 426 descriptorProc(NULL, deviceMatrix, DetachDescProc, &cache, true); |
426 | 427 |
427 const SkGlyph& glyph = cache->getUnicharMetrics(text); | 428 const SkGlyph& glyph = cache->getUnicharMetrics(text); |
428 | 429 |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1199 text - stop + length : stop - text + length; | 1200 text - stop + length : stop - text + length; |
1200 } | 1201 } |
1201 | 1202 |
1202 /////////////////////////////////////////////////////////////////////////////// | 1203 /////////////////////////////////////////////////////////////////////////////// |
1203 | 1204 |
1204 static bool FontMetricsCacheProc(const SkGlyphCache* cache, void* context) { | 1205 static bool FontMetricsCacheProc(const SkGlyphCache* cache, void* context) { |
1205 *(SkPaint::FontMetrics*)context = cache->getFontMetricsY(); | 1206 *(SkPaint::FontMetrics*)context = cache->getFontMetricsY(); |
1206 return false; // don't detach the cache | 1207 return false; // don't detach the cache |
1207 } | 1208 } |
1208 | 1209 |
1209 static void FontMetricsDescProc(const SkDescriptor* desc, void* context) { | 1210 static void FontMetricsDescProc(SkTypeface* typeface, const SkDescriptor* desc, |
1210 SkGlyphCache::VisitCache(desc, FontMetricsCacheProc, context); | 1211 void* context) { |
| 1212 SkGlyphCache::VisitCache(typeface, desc, FontMetricsCacheProc, context); |
1211 } | 1213 } |
1212 | 1214 |
1213 SkScalar SkPaint::getFontMetrics(FontMetrics* metrics, SkScalar zoom) const { | 1215 SkScalar SkPaint::getFontMetrics(FontMetrics* metrics, SkScalar zoom) const { |
1214 SkScalar scale = 0; | 1216 SkScalar scale = 0; |
1215 SkAutoRestorePaintTextSizeAndFrame restore(this); | 1217 SkAutoRestorePaintTextSizeAndFrame restore(this); |
1216 | 1218 |
1217 if (this->isLinearText()) { | 1219 if (this->isLinearText()) { |
1218 scale = fTextSize / kCanonicalTextSizeForPaths; | 1220 scale = fTextSize / kCanonicalTextSizeForPaths; |
1219 // this gets restored by restore | 1221 // this gets restored by restore |
1220 ((SkPaint*)this)->setTextSize(SkIntToScalar(kCanonicalTextSizeForPaths))
; | 1222 ((SkPaint*)this)->setTextSize(SkIntToScalar(kCanonicalTextSizeForPaths))
; |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1754 | 1756 |
1755 /* | 1757 /* |
1756 * ignoreGamma tells us that the caller just wants metrics that are unaffected | 1758 * ignoreGamma tells us that the caller just wants metrics that are unaffected |
1757 * by gamma correction, so we jam the luminance field to 0 (most common value | 1759 * by gamma correction, so we jam the luminance field to 0 (most common value |
1758 * for black text) in hopes that we get a cache hit easier. A better solution | 1760 * for black text) in hopes that we get a cache hit easier. A better solution |
1759 * would be for the fontcache lookup to know to ignore the luminance field | 1761 * would be for the fontcache lookup to know to ignore the luminance field |
1760 * entirely, but not sure how to do that and keep it fast. | 1762 * entirely, but not sure how to do that and keep it fast. |
1761 */ | 1763 */ |
1762 void SkPaint::descriptorProc(const SkDeviceProperties* deviceProperties, | 1764 void SkPaint::descriptorProc(const SkDeviceProperties* deviceProperties, |
1763 const SkMatrix* deviceMatrix, | 1765 const SkMatrix* deviceMatrix, |
1764 void (*proc)(const SkDescriptor*, void*), | 1766 void (*proc)(SkTypeface*, const SkDescriptor*, void
*), |
1765 void* context, bool ignoreGamma) const { | 1767 void* context, bool ignoreGamma) const { |
1766 SkScalerContext::Rec rec; | 1768 SkScalerContext::Rec rec; |
1767 | 1769 |
1768 SkScalerContext::MakeRec(*this, deviceProperties, deviceMatrix, &rec); | 1770 SkScalerContext::MakeRec(*this, deviceProperties, deviceMatrix, &rec); |
1769 if (ignoreGamma) { | 1771 if (ignoreGamma) { |
1770 rec.setLuminanceColor(0); | 1772 rec.setLuminanceColor(0); |
1771 } | 1773 } |
1772 | 1774 |
1773 size_t descSize = sizeof(rec); | 1775 size_t descSize = sizeof(rec); |
1774 int entryCount = 1; | 1776 int entryCount = 1; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1866 | 1868 |
1867 SkASSERT(descSize == desc1->getLength()); | 1869 SkASSERT(descSize == desc1->getLength()); |
1868 SkASSERT(descSize == desc2->getLength()); | 1870 SkASSERT(descSize == desc2->getLength()); |
1869 desc1->computeChecksum(); | 1871 desc1->computeChecksum(); |
1870 desc2->computeChecksum(); | 1872 desc2->computeChecksum(); |
1871 SkASSERT(!memcmp(desc, desc1, descSize)); | 1873 SkASSERT(!memcmp(desc, desc1, descSize)); |
1872 SkASSERT(!memcmp(desc, desc2, descSize)); | 1874 SkASSERT(!memcmp(desc, desc2, descSize)); |
1873 } | 1875 } |
1874 #endif | 1876 #endif |
1875 | 1877 |
1876 proc(desc, context); | 1878 proc(fTypeface, desc, context); |
1877 } | 1879 } |
1878 | 1880 |
1879 SkGlyphCache* SkPaint::detachCache(const SkDeviceProperties* deviceProperties, | 1881 SkGlyphCache* SkPaint::detachCache(const SkDeviceProperties* deviceProperties, |
1880 const SkMatrix* deviceMatrix) const { | 1882 const SkMatrix* deviceMatrix) const { |
1881 SkGlyphCache* cache; | 1883 SkGlyphCache* cache; |
1882 this->descriptorProc(deviceProperties, deviceMatrix, DetachDescProc, &cache,
false); | 1884 this->descriptorProc(deviceProperties, deviceMatrix, DetachDescProc, &cache,
false); |
1883 return cache; | 1885 return cache; |
1884 } | 1886 } |
1885 | 1887 |
1886 /** | 1888 /** |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2565 if (firstTime) { | 2567 if (firstTime) { |
2566 *dst = r; | 2568 *dst = r; |
2567 } else { | 2569 } else { |
2568 dst->join(r); | 2570 dst->join(r); |
2569 } | 2571 } |
2570 } else { | 2572 } else { |
2571 break; | 2573 break; |
2572 } | 2574 } |
2573 } | 2575 } |
2574 } | 2576 } |
OLD | NEW |