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

Side by Side Diff: src/fonts/SkGScalerContext.cpp

Issue 1872253004: Revert of Pass effects directly to fontcache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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/fonts/SkGScalerContext.h ('k') | src/fonts/SkRandomScalerContext.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 2013 Google Inc. 2 * Copyright 2013 Google Inc.
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 "SkDescriptor.h"
9 #include "SkGScalerContext.h" 8 #include "SkGScalerContext.h"
10 #include "SkGlyph.h" 9 #include "SkGlyph.h"
11 #include "SkPath.h" 10 #include "SkPath.h"
12 #include "SkCanvas.h" 11 #include "SkCanvas.h"
13 12
14 #define STD_SIZE 1
15
16 class SkGScalerContext : public SkScalerContext { 13 class SkGScalerContext : public SkScalerContext {
17 public: 14 public:
18 SkGScalerContext(SkGTypeface* face, const SkScalerContextEffects& effects, 15 SkGScalerContext(SkGTypeface*, const SkDescriptor*);
19 const SkDescriptor* desc) 16 virtual ~SkGScalerContext();
20 : SkScalerContext(face, effects, desc)
21 , fFace(face)
22 {
23
24 size_t descSize = SkDescriptor::ComputeOverhead(1) + sizeof(SkScalerCon text::Rec);
25 SkAutoDescriptor ad(descSize);
26 SkDescriptor* newDesc = ad.getDesc();
27
28 newDesc->init();
29 void* entry = newDesc->addEntry(kRec_SkDescriptorTag,
30 sizeof(SkScalerContext::Rec), &fRec);
31 {
32 SkScalerContext::Rec* rec = (SkScalerContext::Rec*)entry;
33 rec->fTextSize = STD_SIZE;
34 rec->fPreScaleX = SK_Scalar1;
35 rec->fPreSkewX = 0;
36 rec->fPost2x2[0][0] = rec->fPost2x2[1][1] = SK_Scalar1;
37 rec->fPost2x2[1][0] = rec->fPost2x2[0][1] = 0;
38 }
39 SkASSERT(descSize == newDesc->getLength());
40 newDesc->computeChecksum();
41
42 fProxy = face->proxy()->createScalerContext(effects, newDesc);
43
44 fRec.getSingleMatrix(&fMatrix);
45 fMatrix.preScale(SK_Scalar1 / STD_SIZE, SK_Scalar1 / STD_SIZE);
46 }
47 virtual ~SkGScalerContext() { delete fProxy; }
48 17
49 protected: 18 protected:
50 unsigned generateGlyphCount() override; 19 unsigned generateGlyphCount() override;
51 uint16_t generateCharToGlyph(SkUnichar) override; 20 uint16_t generateCharToGlyph(SkUnichar) override;
52 void generateAdvance(SkGlyph*) override; 21 void generateAdvance(SkGlyph*) override;
53 void generateMetrics(SkGlyph*) override; 22 void generateMetrics(SkGlyph*) override;
54 void generateImage(const SkGlyph&) override; 23 void generateImage(const SkGlyph&) override;
55 void generatePath(const SkGlyph&, SkPath*) override; 24 void generatePath(const SkGlyph&, SkPath*) override;
56 void generateFontMetrics(SkPaint::FontMetrics*) override; 25 void generateFontMetrics(SkPaint::FontMetrics*) override;
57 26
58 private: 27 private:
59 SkGTypeface* fFace; 28 SkGTypeface* fFace;
60 SkScalerContext* fProxy; 29 SkScalerContext* fProxy;
61 SkMatrix fMatrix; 30 SkMatrix fMatrix;
62 }; 31 };
63 32
33 #define STD_SIZE 1
34
35 #include "SkDescriptor.h"
36
37 SkGScalerContext::SkGScalerContext(SkGTypeface* face, const SkDescriptor* desc)
38 : SkScalerContext(face, desc)
39 , fFace(face)
40 {
41
42 size_t descSize = SkDescriptor::ComputeOverhead(1) + sizeof(SkScalerContext ::Rec);
43 SkAutoDescriptor ad(descSize);
44 SkDescriptor* newDesc = ad.getDesc();
45
46 newDesc->init();
47 void* entry = newDesc->addEntry(kRec_SkDescriptorTag,
48 sizeof(SkScalerContext::Rec), &fRec);
49 {
50 SkScalerContext::Rec* rec = (SkScalerContext::Rec*)entry;
51 rec->fTextSize = STD_SIZE;
52 rec->fPreScaleX = SK_Scalar1;
53 rec->fPreSkewX = 0;
54 rec->fPost2x2[0][0] = rec->fPost2x2[1][1] = SK_Scalar1;
55 rec->fPost2x2[1][0] = rec->fPost2x2[0][1] = 0;
56 }
57 SkASSERT(descSize == newDesc->getLength());
58 newDesc->computeChecksum();
59
60 fProxy = face->proxy()->createScalerContext(newDesc);
61
62 fRec.getSingleMatrix(&fMatrix);
63 fMatrix.preScale(SK_Scalar1 / STD_SIZE, SK_Scalar1 / STD_SIZE);
64 }
65
66 SkGScalerContext::~SkGScalerContext() { delete fProxy; }
67
64 unsigned SkGScalerContext::generateGlyphCount() { 68 unsigned SkGScalerContext::generateGlyphCount() {
65 return fProxy->getGlyphCount(); 69 return fProxy->getGlyphCount();
66 } 70 }
67 71
68 uint16_t SkGScalerContext::generateCharToGlyph(SkUnichar uni) { 72 uint16_t SkGScalerContext::generateCharToGlyph(SkUnichar uni) {
69 return fProxy->charToGlyphID(uni); 73 return fProxy->charToGlyphID(uni);
70 } 74 }
71 75
72 void SkGScalerContext::generateAdvance(SkGlyph* glyph) { 76 void SkGScalerContext::generateAdvance(SkGlyph* glyph) {
73 fProxy->getAdvance(glyph); 77 fProxy->getAdvance(glyph);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 157
154 SkGTypeface::SkGTypeface(SkTypeface* proxy, const SkPaint& paint) 158 SkGTypeface::SkGTypeface(SkTypeface* proxy, const SkPaint& paint)
155 : SkTypeface(proxy->fontStyle(), SkTypefaceCache::NewFontID(), false) 159 : SkTypeface(proxy->fontStyle(), SkTypefaceCache::NewFontID(), false)
156 , fProxy(SkRef(proxy)) 160 , fProxy(SkRef(proxy))
157 , fPaint(paint) {} 161 , fPaint(paint) {}
158 162
159 SkGTypeface::~SkGTypeface() { 163 SkGTypeface::~SkGTypeface() {
160 fProxy->unref(); 164 fProxy->unref();
161 } 165 }
162 166
163 SkScalerContext* SkGTypeface::onCreateScalerContext(const SkScalerContextEffects & effects, 167 SkScalerContext* SkGTypeface::onCreateScalerContext(
164 const SkDescriptor* desc) co nst { 168 const SkDescriptor* desc) const {
165 return new SkGScalerContext(const_cast<SkGTypeface*>(this), effects, desc); 169 return new SkGScalerContext(const_cast<SkGTypeface*>(this), desc);
166 } 170 }
167 171
168 void SkGTypeface::onFilterRec(SkScalerContextRec* rec) const { 172 void SkGTypeface::onFilterRec(SkScalerContextRec* rec) const {
169 fProxy->filterRec(rec); 173 fProxy->filterRec(rec);
170 rec->setHinting(SkPaint::kNo_Hinting); 174 rec->setHinting(SkPaint::kNo_Hinting);
171 rec->fMaskFormat = SkMask::kARGB32_Format; 175 rec->fMaskFormat = SkMask::kARGB32_Format;
172 } 176 }
173 177
174 SkAdvancedTypefaceMetrics* SkGTypeface::onGetAdvancedTypefaceMetrics( 178 SkAdvancedTypefaceMetrics* SkGTypeface::onGetAdvancedTypefaceMetrics(
175 PerGlyphInfo info, 179 PerGlyphInfo info,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 255
252 friend class SkGFontBuilder; 256 friend class SkGFontBuilder;
253 SkGFont(int count, Glyph* array); 257 SkGFont(int count, Glyph* array);
254 }; 258 };
255 259
256 class SkGFontBuilder { 260 class SkGFontBuilder {
257 public: 261 public:
258 262
259 }; 263 };
260 #endif 264 #endif
OLDNEW
« no previous file with comments | « src/fonts/SkGScalerContext.h ('k') | src/fonts/SkRandomScalerContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698