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

Side by Side Diff: src/gpu/GrStencilAndCoverTextContext.cpp

Issue 650273003: Change GrTextContext fallbacks to be a linked list chain. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix include Created 6 years, 2 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/gpu/GrStencilAndCoverTextContext.h ('k') | src/gpu/GrTextContext.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 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 "GrBitmapTextContext.h"
9 #include "GrDrawTarget.h" 10 #include "GrDrawTarget.h"
10 #include "GrGpu.h" 11 #include "GrGpu.h"
11 #include "GrPath.h" 12 #include "GrPath.h"
12 #include "GrPathRange.h" 13 #include "GrPathRange.h"
13 #include "SkAutoKern.h" 14 #include "SkAutoKern.h"
14 #include "SkDraw.h" 15 #include "SkDraw.h"
15 #include "SkDrawProcs.h" 16 #include "SkDrawProcs.h"
16 #include "SkGlyphCache.h" 17 #include "SkGlyphCache.h"
17 #include "SkGpuDevice.h" 18 #include "SkGpuDevice.h"
18 #include "SkPath.h" 19 #include "SkPath.h"
19 #include "SkTextMapStateProc.h" 20 #include "SkTextMapStateProc.h"
20 #include "SkTextFormatParams.h" 21 #include "SkTextFormatParams.h"
21 22
22 GrStencilAndCoverTextContext::GrStencilAndCoverTextContext( 23 GrStencilAndCoverTextContext::GrStencilAndCoverTextContext(
23 GrContext* context, const SkDeviceProperties& properties) 24 GrContext* context, const SkDeviceProperties& properties)
24 : GrTextContext(context, properties) 25 : GrTextContext(context, properties)
25 , fPendingGlyphCount(0) { 26 , fPendingGlyphCount(0) {
26 } 27 }
27 28
29 GrStencilAndCoverTextContext* GrStencilAndCoverTextContext::Create(GrContext* co ntext,
30 const SkDeviceP roperties& props) {
31 GrStencilAndCoverTextContext* textContext = SkNEW_ARGS(GrStencilAndCoverText Context,
32 (context, props));
33 textContext->fFallbackTextContext = GrBitmapTextContext::Create(context, pro ps);
34
35 return textContext;
36 }
37
28 GrStencilAndCoverTextContext::~GrStencilAndCoverTextContext() { 38 GrStencilAndCoverTextContext::~GrStencilAndCoverTextContext() {
29 } 39 }
30 40
31 bool GrStencilAndCoverTextContext::canDraw(const SkPaint& paint) { 41 bool GrStencilAndCoverTextContext::canDraw(const SkPaint& paint) {
32 if (paint.getRasterizer()) { 42 if (paint.getRasterizer()) {
33 return false; 43 return false;
34 } 44 }
35 if (paint.getMaskFilter()) { 45 if (paint.getMaskFilter()) {
36 return false; 46 return false;
37 } 47 }
38 if (paint.getPathEffect()) { 48 if (paint.getPathEffect()) {
39 return false; 49 return false;
40 } 50 }
41 51
42 // No hairlines unless we can map the 1 px width to the object space. 52 // No hairlines unless we can map the 1 px width to the object space.
43 if (paint.getStyle() == SkPaint::kStroke_Style 53 if (paint.getStyle() == SkPaint::kStroke_Style
44 && paint.getStrokeWidth() == 0 54 && paint.getStrokeWidth() == 0
45 && fContext->getMatrix().hasPerspective()) { 55 && fContext->getMatrix().hasPerspective()) {
46 return false; 56 return false;
47 } 57 }
48 58
49 // No color bitmap fonts. 59 // No color bitmap fonts.
50 SkScalerContext::Rec rec; 60 SkScalerContext::Rec rec;
51 SkScalerContext::MakeRec(paint, &fDeviceProperties, NULL, &rec); 61 SkScalerContext::MakeRec(paint, &fDeviceProperties, NULL, &rec);
52 return rec.getFormat() != SkMask::kARGB32_Format; 62 return rec.getFormat() != SkMask::kARGB32_Format;
53 } 63 }
54 64
55 void GrStencilAndCoverTextContext::drawText(const GrPaint& paint, 65 void GrStencilAndCoverTextContext::onDrawText(const GrPaint& paint,
56 const SkPaint& skPaint, 66 const SkPaint& skPaint,
57 const char text[], 67 const char text[],
58 size_t byteLength, 68 size_t byteLength,
59 SkScalar x, SkScalar y) { 69 SkScalar x, SkScalar y) {
60 SkASSERT(byteLength == 0 || text != NULL); 70 SkASSERT(byteLength == 0 || text != NULL);
61 71
62 if (text == NULL || byteLength == 0 /*|| fRC->isEmpty()*/) { 72 if (text == NULL || byteLength == 0 /*|| fRC->isEmpty()*/) {
63 return; 73 return;
64 } 74 }
65 75
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 this->appendGlyph(glyph.getGlyphID(), SkFixedToScalar(fx), SkFixedTo Scalar(fy)); 145 this->appendGlyph(glyph.getGlyphID(), SkFixedToScalar(fx), SkFixedTo Scalar(fy));
136 } 146 }
137 147
138 fx += SkFixedMul_portable(glyph.fAdvanceX, fixedSizeRatio); 148 fx += SkFixedMul_portable(glyph.fAdvanceX, fixedSizeRatio);
139 fy += SkFixedMul_portable(glyph.fAdvanceY, fixedSizeRatio); 149 fy += SkFixedMul_portable(glyph.fAdvanceY, fixedSizeRatio);
140 } 150 }
141 151
142 this->finish(); 152 this->finish();
143 } 153 }
144 154
145 void GrStencilAndCoverTextContext::drawPosText(const GrPaint& paint, 155 void GrStencilAndCoverTextContext::onDrawPosText(const GrPaint& paint,
146 const SkPaint& skPaint, 156 const SkPaint& skPaint,
147 const char text[], 157 const char text[],
148 size_t byteLength, 158 size_t byteLength,
149 const SkScalar pos[], 159 const SkScalar pos[],
150 int scalarsPerPosition, 160 int scalarsPerPosition,
151 const SkPoint& offset) { 161 const SkPoint& offset) {
152 SkASSERT(byteLength == 0 || text != NULL); 162 SkASSERT(byteLength == 0 || text != NULL);
153 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition); 163 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
154 164
155 // nothing to draw 165 // nothing to draw
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 426
417 SkGlyphCache::AttachCache(fGlyphCache); 427 SkGlyphCache::AttachCache(fGlyphCache);
418 fGlyphCache = NULL; 428 fGlyphCache = NULL;
419 429
420 fDrawTarget->drawState()->stencil()->setDisabled(); 430 fDrawTarget->drawState()->stencil()->setDisabled();
421 fStateRestore.set(NULL); 431 fStateRestore.set(NULL);
422 fContext->setMatrix(fContextInitialMatrix); 432 fContext->setMatrix(fContextInitialMatrix);
423 GrTextContext::finish(); 433 GrTextContext::finish();
424 } 434 }
425 435
OLDNEW
« no previous file with comments | « src/gpu/GrStencilAndCoverTextContext.h ('k') | src/gpu/GrTextContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698