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 | 9 |
10 #include "SkScalerContext.h" | 10 #include "SkScalerContext.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 fRsbDelta = 0; | 59 fRsbDelta = 0; |
60 fLsbDelta = 0; | 60 fLsbDelta = 0; |
61 } | 61 } |
62 | 62 |
63 /////////////////////////////////////////////////////////////////////////////// | 63 /////////////////////////////////////////////////////////////////////////////// |
64 | 64 |
65 #ifdef SK_DEBUG | 65 #ifdef SK_DEBUG |
66 #define DUMP_RECx | 66 #define DUMP_RECx |
67 #endif | 67 #endif |
68 | 68 |
69 static SkFlattenable* load_flattenable(const SkDescriptor* desc, uint32_t tag) { | 69 static SkFlattenable* load_flattenable(const SkDescriptor* desc, uint32_t tag, |
| 70 SkEffectType et) { |
70 SkFlattenable* obj = NULL; | 71 SkFlattenable* obj = NULL; |
71 uint32_t len; | 72 uint32_t len; |
72 const void* data = desc->findEntry(tag, &len); | 73 const void* data = desc->findEntry(tag, &len); |
73 | 74 |
74 if (data) { | 75 if (data) { |
75 SkOrderedReadBuffer buffer(data, len); | 76 SkOrderedReadBuffer buffer(data, len); |
76 obj = buffer.readFlattenable(); | 77 obj = buffer.readFlattenable(et); |
77 SkASSERT(buffer.offset() == buffer.size()); | 78 SkASSERT(buffer.offset() == buffer.size()); |
78 } | 79 } |
79 return obj; | 80 return obj; |
80 } | 81 } |
81 | 82 |
82 SkScalerContext::SkScalerContext(SkTypeface* typeface, const SkDescriptor* desc) | 83 SkScalerContext::SkScalerContext(SkTypeface* typeface, const SkDescriptor* desc) |
83 : fRec(*static_cast<const Rec*>(desc->findEntry(kRec_SkDescriptorTag, NULL))
) | 84 : fRec(*static_cast<const Rec*>(desc->findEntry(kRec_SkDescriptorTag, NULL))
) |
84 | 85 |
85 , fBaseGlyphCount(0) | 86 , fBaseGlyphCount(0) |
86 , fTypeface(SkRef(typeface)) | 87 , fTypeface(SkRef(typeface)) |
87 , fPathEffect(static_cast<SkPathEffect*>(load_flattenable(desc, kPathEffect_
SkDescriptorTag))) | 88 , fPathEffect(static_cast<SkPathEffect*>(load_flattenable(desc, kPathEffect_
SkDescriptorTag, kPathEffect_SkEffectType))) |
88 , fMaskFilter(static_cast<SkMaskFilter*>(load_flattenable(desc, kMaskFilter_
SkDescriptorTag))) | 89 , fMaskFilter(static_cast<SkMaskFilter*>(load_flattenable(desc, kMaskFilter_
SkDescriptorTag, kMaskFilter_SkEffectType))) |
89 , fRasterizer(static_cast<SkRasterizer*>(load_flattenable(desc, kRasterizer_
SkDescriptorTag))) | 90 , fRasterizer(static_cast<SkRasterizer*>(load_flattenable(desc, kRasterizer_
SkDescriptorTag, kRasterizer_SkEffectType))) |
90 | 91 |
91 // Initialize based on our settings. Subclasses can also force this. | 92 // Initialize based on our settings. Subclasses can also force this. |
92 , fGenerateImageFromPath(fRec.fFrameWidth > 0 || fPathEffect != NULL || fRas
terizer != NULL) | 93 , fGenerateImageFromPath(fRec.fFrameWidth > 0 || fPathEffect != NULL || fRas
terizer != NULL) |
93 | 94 |
94 , fNextContext(NULL) | 95 , fNextContext(NULL) |
95 | 96 |
96 , fPreBlend(fMaskFilter ? SkMaskGamma::PreBlend() : SkScalerContext::GetMask
PreBlend(fRec)) | 97 , fPreBlend(fMaskFilter ? SkMaskGamma::PreBlend() : SkScalerContext::GetMask
PreBlend(fRec)) |
97 , fPreBlendForFilter(fMaskFilter ? SkScalerContext::GetMaskPreBlend(fRec) | 98 , fPreBlendForFilter(fMaskFilter ? SkScalerContext::GetMaskPreBlend(fRec) |
98 : SkMaskGamma::PreBlend()) | 99 : SkMaskGamma::PreBlend()) |
99 { | 100 { |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 SkScalerContext* SkTypeface::createScalerContext(const SkDescriptor* desc, | 933 SkScalerContext* SkTypeface::createScalerContext(const SkDescriptor* desc, |
933 bool allowFailure) const { | 934 bool allowFailure) const { |
934 SkScalerContext* c = this->onCreateScalerContext(desc); | 935 SkScalerContext* c = this->onCreateScalerContext(desc); |
935 | 936 |
936 if (!c && !allowFailure) { | 937 if (!c && !allowFailure) { |
937 c = SkNEW_ARGS(SkScalerContext_Empty, | 938 c = SkNEW_ARGS(SkScalerContext_Empty, |
938 (const_cast<SkTypeface*>(this), desc)); | 939 (const_cast<SkTypeface*>(this), desc)); |
939 } | 940 } |
940 return c; | 941 return c; |
941 } | 942 } |
OLD | NEW |