OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrStencilAndCoverTextContext.h" | 8 #include "GrStencilAndCoverTextContext.h" |
9 #include "GrDrawTarget.h" | 9 #include "GrDrawTarget.h" |
10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 GrStencilAndCoverTextContext::GrStencilAndCoverTextContext( | 22 GrStencilAndCoverTextContext::GrStencilAndCoverTextContext( |
23 GrContext* context, const SkDeviceProperties& properties) | 23 GrContext* context, const SkDeviceProperties& properties) |
24 : GrTextContext(context, properties) | 24 : GrTextContext(context, properties) |
25 , fPendingGlyphCount(0) { | 25 , fPendingGlyphCount(0) { |
26 } | 26 } |
27 | 27 |
28 GrStencilAndCoverTextContext::~GrStencilAndCoverTextContext() { | 28 GrStencilAndCoverTextContext::~GrStencilAndCoverTextContext() { |
29 } | 29 } |
30 | 30 |
| 31 bool GrStencilAndCoverTextContext::canDraw(const SkPaint& paint) { |
| 32 if (paint.getRasterizer()) { |
| 33 return false; |
| 34 } |
| 35 if (paint.getMaskFilter()) { |
| 36 return false; |
| 37 } |
| 38 if (paint.getPathEffect()) { |
| 39 return false; |
| 40 } |
| 41 |
| 42 // No hairlines unless we can map the 1 px width to the object space. |
| 43 if (paint.getStyle() == SkPaint::kStroke_Style |
| 44 && paint.getStrokeWidth() == 0 |
| 45 && fContext->getMatrix().hasPerspective()) { |
| 46 return false; |
| 47 } |
| 48 |
| 49 // No color bitmap fonts. |
| 50 SkScalerContext::Rec rec; |
| 51 SkScalerContext::MakeRec(paint, &fDeviceProperties, NULL, &rec); |
| 52 return rec.getFormat() != SkMask::kARGB32_Format; |
| 53 } |
| 54 |
31 void GrStencilAndCoverTextContext::drawText(const GrPaint& paint, | 55 void GrStencilAndCoverTextContext::drawText(const GrPaint& paint, |
32 const SkPaint& skPaint, | 56 const SkPaint& skPaint, |
33 const char text[], | 57 const char text[], |
34 size_t byteLength, | 58 size_t byteLength, |
35 SkScalar x, SkScalar y) { | 59 SkScalar x, SkScalar y) { |
36 SkASSERT(byteLength == 0 || text != NULL); | 60 SkASSERT(byteLength == 0 || text != NULL); |
37 | 61 |
38 if (text == NULL || byteLength == 0 /*|| fRC->isEmpty()*/) { | 62 if (text == NULL || byteLength == 0 /*|| fRC->isEmpty()*/) { |
39 return; | 63 return; |
40 } | 64 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 206 |
183 this->appendGlyph(glyph.getGlyphID(), loc.x(), loc.y()); | 207 this->appendGlyph(glyph.getGlyphID(), loc.x(), loc.y()); |
184 } | 208 } |
185 pos += scalarsPerPosition; | 209 pos += scalarsPerPosition; |
186 } | 210 } |
187 } | 211 } |
188 | 212 |
189 this->finish(); | 213 this->finish(); |
190 } | 214 } |
191 | 215 |
192 bool GrStencilAndCoverTextContext::canDraw(const SkPaint& paint) { | |
193 if (paint.getRasterizer()) { | |
194 return false; | |
195 } | |
196 if (paint.getMaskFilter()) { | |
197 return false; | |
198 } | |
199 if (paint.getPathEffect()) { | |
200 return false; | |
201 } | |
202 | |
203 // No hairlines unless we can map the 1 px width to the object space. | |
204 if (paint.getStyle() == SkPaint::kStroke_Style | |
205 && paint.getStrokeWidth() == 0 | |
206 && fContext->getMatrix().hasPerspective()) { | |
207 return false; | |
208 } | |
209 | |
210 // No color bitmap fonts. | |
211 SkScalerContext::Rec rec; | |
212 SkScalerContext::MakeRec(paint, &fDeviceProperties, NULL, &rec); | |
213 return rec.getFormat() != SkMask::kARGB32_Format; | |
214 } | |
215 | |
216 static GrPathRange* get_gr_glyphs(GrContext* ctx, | 216 static GrPathRange* get_gr_glyphs(GrContext* ctx, |
217 const SkTypeface* typeface, | 217 const SkTypeface* typeface, |
218 const SkDescriptor* desc, | 218 const SkDescriptor* desc, |
219 const SkStrokeRec& stroke) { | 219 const SkStrokeRec& stroke) { |
220 static const GrCacheID::Domain gGlyphsDomain = GrCacheID::GenerateDomain(); | 220 static const GrCacheID::Domain gGlyphsDomain = GrCacheID::GenerateDomain(); |
221 | 221 |
222 GrCacheID::Key key; | 222 GrCacheID::Key key; |
223 uint64_t* keyData = key.fData64; | 223 uint64_t* keyData = key.fData64; |
224 keyData[0] = desc ? desc->getChecksum() : 0; | 224 keyData[0] = desc ? desc->getChecksum() : 0; |
225 keyData[0] = (keyData[0] << 32) | (typeface ? typeface->uniqueID() : 0); | 225 keyData[0] = (keyData[0] << 32) | (typeface ? typeface->uniqueID() : 0); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 | 416 |
417 SkGlyphCache::AttachCache(fGlyphCache); | 417 SkGlyphCache::AttachCache(fGlyphCache); |
418 fGlyphCache = NULL; | 418 fGlyphCache = NULL; |
419 | 419 |
420 fDrawTarget->drawState()->stencil()->setDisabled(); | 420 fDrawTarget->drawState()->stencil()->setDisabled(); |
421 fStateRestore.set(NULL); | 421 fStateRestore.set(NULL); |
422 fContext->setMatrix(fContextInitialMatrix); | 422 fContext->setMatrix(fContextInitialMatrix); |
423 GrTextContext::finish(); | 423 GrTextContext::finish(); |
424 } | 424 } |
425 | 425 |
OLD | NEW |