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

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

Issue 1486923004: Retract GrRenderTarget a bit (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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/GrTextContext.h ('k') | src/gpu/SkGpuDevice.cpp » ('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 2010 Google Inc. 2 * Copyright 2010 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 "GrTextContext.h" 8 #include "GrTextContext.h"
9 #include "GrBlurUtils.h" 9 #include "GrBlurUtils.h"
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 do { 44 do {
45 if (textContext->canDraw(rt, clip, paint, skPaint, viewMatrix)) { 45 if (textContext->canDraw(rt, clip, paint, skPaint, viewMatrix)) {
46 textContext->onDrawText(dc, rt, clip, paint, skPaint, viewMatrix, 46 textContext->onDrawText(dc, rt, clip, paint, skPaint, viewMatrix,
47 text, byteLength, x, y, clipBounds); 47 text, byteLength, x, y, clipBounds);
48 return; 48 return;
49 } 49 }
50 textContext = textContext->fFallbackTextContext; 50 textContext = textContext->fFallbackTextContext;
51 } while (textContext); 51 } while (textContext);
52 52
53 // fall back to drawing as a path 53 // fall back to drawing as a path
54 this->drawTextAsPath(dc, rt, clip, skPaint, viewMatrix, 54 this->drawTextAsPath(dc, clip, skPaint, viewMatrix,
55 text, byteLength, x, y, clipBounds); 55 text, byteLength, x, y, clipBounds);
56 } 56 }
57 57
58 void GrTextContext::drawPosText(GrDrawContext* dc, GrRenderTarget* rt, 58 void GrTextContext::drawPosText(GrDrawContext* dc, GrRenderTarget* rt,
59 const GrClip& clip, const GrPaint& paint, 59 const GrClip& clip, const GrPaint& paint,
60 const SkPaint& skPaint, const SkMatrix& viewMatr ix, 60 const SkPaint& skPaint, const SkMatrix& viewMatr ix,
61 const char text[], size_t byteLength, 61 const char text[], size_t byteLength,
62 const SkScalar pos[], int scalarsPerPosition, 62 const SkScalar pos[], int scalarsPerPosition,
63 const SkPoint& offset, const SkIRect& clipBounds ) { 63 const SkPoint& offset, const SkIRect& clipBounds ) {
64 if (fContext->abandoned()) { 64 if (fContext->abandoned()) {
65 return; 65 return;
66 } 66 }
67 67
68 GrTextContext* textContext = this; 68 GrTextContext* textContext = this;
69 do { 69 do {
70 if (textContext->canDraw(rt, clip, paint, skPaint, viewMatrix)) { 70 if (textContext->canDraw(rt, clip, paint, skPaint, viewMatrix)) {
71 textContext->onDrawPosText(dc, rt, clip, paint, skPaint, viewMatrix, 71 textContext->onDrawPosText(dc, rt, clip, paint, skPaint, viewMatrix,
72 text, byteLength, pos, 72 text, byteLength, pos,
73 scalarsPerPosition, offset, clipBounds); 73 scalarsPerPosition, offset, clipBounds);
74 return; 74 return;
75 } 75 }
76 textContext = textContext->fFallbackTextContext; 76 textContext = textContext->fFallbackTextContext;
77 } while (textContext); 77 } while (textContext);
78 78
79 // fall back to drawing as a path 79 // fall back to drawing as a path
80 this->drawPosTextAsPath(dc, rt, clip, skPaint, viewMatrix, text, byteLength, pos, 80 this->drawPosTextAsPath(dc, clip, skPaint, viewMatrix, text, byteLength, pos ,
81 scalarsPerPosition, offset, clipBounds); 81 scalarsPerPosition, offset, clipBounds);
82 } 82 }
83 83
84 bool GrTextContext::ShouldDisableLCD(const SkPaint& paint) { 84 bool GrTextContext::ShouldDisableLCD(const SkPaint& paint) {
85 if (!SkXfermode::AsMode(paint.getXfermode(), nullptr) || 85 if (!SkXfermode::AsMode(paint.getXfermode(), nullptr) ||
86 paint.getMaskFilter() || 86 paint.getMaskFilter() ||
87 paint.getRasterizer() || 87 paint.getRasterizer() ||
88 paint.getPathEffect() || 88 paint.getPathEffect() ||
89 paint.isFakeBoldText() || 89 paint.isFakeBoldText() ||
90 paint.getStyle() != SkPaint::kFill_Style) 90 paint.getStyle() != SkPaint::kFill_Style)
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 SkFAIL("unhandled positioning mode"); 154 SkFAIL("unhandled positioning mode");
155 } 155 }
156 156
157 if (drawFilter) { 157 if (drawFilter) {
158 // A draw filter may change the paint arbitrarily, so we must re-see d in this case. 158 // A draw filter may change the paint arbitrarily, so we must re-see d in this case.
159 runPaint = skPaint; 159 runPaint = skPaint;
160 } 160 }
161 } 161 }
162 } 162 }
163 163
164 void GrTextContext::drawTextAsPath(GrDrawContext* dc, GrRenderTarget* rt, 164 void GrTextContext::drawTextAsPath(GrDrawContext* dc,
165 const GrClip& clip, 165 const GrClip& clip,
166 const SkPaint& skPaint, const SkMatrix& viewM atrix, 166 const SkPaint& skPaint, const SkMatrix& viewM atrix,
167 const char text[], size_t byteLength, SkScala r x, SkScalar y, 167 const char text[], size_t byteLength, SkScala r x, SkScalar y,
168 const SkIRect& clipBounds) { 168 const SkIRect& clipBounds) {
169 SkTextToPathIter iter(text, byteLength, skPaint, true); 169 SkTextToPathIter iter(text, byteLength, skPaint, true);
170 170
171 SkMatrix matrix; 171 SkMatrix matrix;
172 matrix.setScale(iter.getPathScale(), iter.getPathScale()); 172 matrix.setScale(iter.getPathScale(), iter.getPathScale());
173 matrix.postTranslate(x, y); 173 matrix.postTranslate(x, y);
174 174
175 const SkPath* iterPath; 175 const SkPath* iterPath;
176 SkScalar xpos, prevXPos = 0; 176 SkScalar xpos, prevXPos = 0;
177 177
178 while (iter.next(&iterPath, &xpos)) { 178 while (iter.next(&iterPath, &xpos)) {
179 matrix.postTranslate(xpos - prevXPos, 0); 179 matrix.postTranslate(xpos - prevXPos, 0);
180 if (iterPath) { 180 if (iterPath) {
181 const SkPaint& pnt = iter.getPaint(); 181 const SkPaint& pnt = iter.getPaint();
182 GrBlurUtils::drawPathWithMaskFilter(fContext, dc, rt, clip, *iterPat h, 182 GrBlurUtils::drawPathWithMaskFilter(fContext, dc, clip, *iterPath,
183 pnt, viewMatrix, &matrix, clipBo unds, false); 183 pnt, viewMatrix, &matrix, clipBo unds, false);
184 } 184 }
185 prevXPos = xpos; 185 prevXPos = xpos;
186 } 186 }
187 } 187 }
188 188
189 void GrTextContext::drawPosTextAsPath(GrDrawContext* dc, GrRenderTarget* rt, 189 void GrTextContext::drawPosTextAsPath(GrDrawContext* dc,
190 const GrClip& clip, 190 const GrClip& clip,
191 const SkPaint& origPaint, const SkMatrix& viewMatrix, 191 const SkPaint& origPaint, const SkMatrix& viewMatrix,
192 const char text[], size_t byteLength, 192 const char text[], size_t byteLength,
193 const SkScalar pos[], int scalarsPerPositi on, 193 const SkScalar pos[], int scalarsPerPositi on,
194 const SkPoint& offset, const SkIRect& clip Bounds) { 194 const SkPoint& offset, const SkIRect& clip Bounds) {
195 // setup our std paint, in hopes of getting hits in the cache 195 // setup our std paint, in hopes of getting hits in the cache
196 SkPaint paint(origPaint); 196 SkPaint paint(origPaint);
197 SkScalar matrixScale = paint.setupForAsPaths(); 197 SkScalar matrixScale = paint.setupForAsPaths();
198 198
199 SkMatrix matrix; 199 SkMatrix matrix;
(...skipping 20 matching lines...) Expand all
220 if (glyph.fWidth) { 220 if (glyph.fWidth) {
221 const SkPath* path = cache->findPath(glyph); 221 const SkPath* path = cache->findPath(glyph);
222 if (path) { 222 if (path) {
223 SkPoint tmsLoc; 223 SkPoint tmsLoc;
224 tmsProc(pos, &tmsLoc); 224 tmsProc(pos, &tmsLoc);
225 SkPoint loc; 225 SkPoint loc;
226 alignProc(tmsLoc, glyph, &loc); 226 alignProc(tmsLoc, glyph, &loc);
227 227
228 matrix[SkMatrix::kMTransX] = loc.fX; 228 matrix[SkMatrix::kMTransX] = loc.fX;
229 matrix[SkMatrix::kMTransY] = loc.fY; 229 matrix[SkMatrix::kMTransY] = loc.fY;
230 GrBlurUtils::drawPathWithMaskFilter(fContext, dc, rt, clip, *pat h, paint, 230 GrBlurUtils::drawPathWithMaskFilter(fContext, dc, clip, *path, p aint,
231 viewMatrix, &matrix, clipBou nds, false); 231 viewMatrix, &matrix, clipBou nds, false);
232 } 232 }
233 } 233 }
234 pos += scalarsPerPosition; 234 pos += scalarsPerPosition;
235 } 235 }
236 } 236 }
237 237
238 // *** change to output positions? 238 // *** change to output positions?
239 int GrTextContext::MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCachePr oc, 239 int GrTextContext::MeasureText(SkGlyphCache* cache, SkDrawCacheProc glyphCachePr oc,
240 const char text[], size_t byteLength, SkVector* stopVector) { 240 const char text[], size_t byteLength, SkVector* stopVector) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 if (cache->getAuxProcData(GlyphCacheAuxProc, &auxData)) { 272 if (cache->getAuxProcData(GlyphCacheAuxProc, &auxData)) {
273 scaler = (GrFontScaler*)auxData; 273 scaler = (GrFontScaler*)auxData;
274 } 274 }
275 if (nullptr == scaler) { 275 if (nullptr == scaler) {
276 scaler = new GrFontScaler(cache); 276 scaler = new GrFontScaler(cache);
277 cache->setAuxProc(GlyphCacheAuxProc, scaler); 277 cache->setAuxProc(GlyphCacheAuxProc, scaler);
278 } 278 }
279 279
280 return scaler; 280 return scaler;
281 } 281 }
OLDNEW
« no previous file with comments | « src/gpu/GrTextContext.h ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698