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

Side by Side Diff: src/gpu/text/GrTextUtils.cpp

Issue 1552513003: Revert of Make draw* lines responsible for cache management (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanuptext13reallytexutilsdf
Patch Set: Created 4 years, 12 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/text/GrTextUtils.h ('k') | no next file » | 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 2015 Google Inc. 2 * Copyright 2015 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 "GrTextUtils.h" 8 #include "GrTextUtils.h"
9 9
10 #include "GrAtlasTextBlob.h" 10 #include "GrAtlasTextBlob.h"
11 #include "GrBatchFontCache.h" 11 #include "GrBatchFontCache.h"
12 #include "GrBlurUtils.h" 12 #include "GrBlurUtils.h"
13 #include "GrContext.h" 13 #include "GrContext.h"
14 #include "GrDrawContext.h" 14 #include "GrDrawContext.h"
15 #include "GrTextContext.h" 15 #include "GrTextContext.h"
16 #include "SkDrawProcs.h" 16 #include "SkDrawProcs.h"
17 #include "SkFindAndPlaceGlyph.h" 17 #include "SkFindAndPlaceGlyph.h"
18 #include "SkGlyphCache.h" 18 #include "SkGlyphCache.h"
19 #include "SkPaint.h" 19 #include "SkPaint.h"
20 #include "SkRect.h" 20 #include "SkRect.h"
21 #include "SkTextMapStateProc.h" 21 #include "SkTextMapStateProc.h"
22 #include "SkTextToPathIter.h" 22 #include "SkTextToPathIter.h"
23 23
24 void GrTextUtils::DrawBmpText(GrAtlasTextBlob* blob, int runIndex, 24 void GrTextUtils::DrawBmpText(GrAtlasTextBlob* blob, int runIndex,
25 GrBatchFontCache* fontCache, 25 GrBatchFontCache* fontCache,
26 const SkSurfaceProps& props, const SkPaint& skPain t, 26 SkGlyphCache* cache, const SkPaint& skPaint,
27 GrColor color, 27 GrColor color,
28 const SkMatrix& viewMatrix, 28 const SkMatrix& viewMatrix,
29 const char text[], size_t byteLength, 29 const char text[], size_t byteLength,
30 SkScalar x, SkScalar y) { 30 SkScalar x, SkScalar y) {
31 SkASSERT(byteLength == 0 || text != nullptr); 31 SkASSERT(byteLength == 0 || text != nullptr);
32 32
33 // nothing to draw 33 // nothing to draw
34 if (text == nullptr || byteLength == 0) { 34 if (text == nullptr || byteLength == 0) {
35 return; 35 return;
36 } 36 }
37 37
38 GrBatchTextStrike* currStrike = nullptr; 38 GrBatchTextStrike* currStrike = nullptr;
39 39
40 // Get GrFontScaler from cache 40 // Get GrFontScaler from cache
41 SkGlyphCache* cache = blob->setupCache(runIndex, props, skPaint, &viewMatrix , false);
42 GrFontScaler* fontScaler = GrTextContext::GetGrFontScaler(cache); 41 GrFontScaler* fontScaler = GrTextContext::GetGrFontScaler(cache);
43 42
44 SkFindAndPlaceGlyph::ProcessText( 43 SkFindAndPlaceGlyph::ProcessText(
45 skPaint.getTextEncoding(), text, byteLength, 44 skPaint.getTextEncoding(), text, byteLength,
46 {x, y}, viewMatrix, skPaint.getTextAlign(), 45 {x, y}, viewMatrix, skPaint.getTextAlign(),
47 cache, 46 cache,
48 [&](const SkGlyph& glyph, SkPoint position, SkPoint rounding) { 47 [&](const SkGlyph& glyph, SkPoint position, SkPoint rounding) {
49 position += rounding; 48 position += rounding;
50 BmpAppendGlyph( 49 BmpAppendGlyph(
51 blob, runIndex, fontCache, &currStrike, glyph, 50 blob, runIndex, fontCache, &currStrike, glyph,
52 SkScalarFloorToInt(position.fX), SkScalarFloorToInt(position.fY) , 51 SkScalarFloorToInt(position.fX), SkScalarFloorToInt(position.fY) ,
53 color, fontScaler); 52 color, fontScaler);
54 } 53 }
55 ); 54 );
56
57 SkGlyphCache::AttachCache(cache);
58 } 55 }
59 56
60 void GrTextUtils::DrawBmpPosText(GrAtlasTextBlob* blob, int runIndex, 57 void GrTextUtils::DrawBmpPosText(GrAtlasTextBlob* blob, int runIndex,
61 GrBatchFontCache* fontCache, 58 GrBatchFontCache* fontCache,
62 const SkSurfaceProps& props, const SkPaint& skP aint, 59 SkGlyphCache* cache, const SkPaint& skPaint,
63 GrColor color, 60 GrColor color,
64 const SkMatrix& viewMatrix, 61 const SkMatrix& viewMatrix,
65 const char text[], size_t byteLength, 62 const char text[], size_t byteLength,
66 const SkScalar pos[], int scalarsPerPosition, 63 const SkScalar pos[], int scalarsPerPosition,
67 const SkPoint& offset) { 64 const SkPoint& offset) {
68 SkASSERT(byteLength == 0 || text != nullptr); 65 SkASSERT(byteLength == 0 || text != nullptr);
69 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition); 66 SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
70 67
71 // nothing to draw 68 // nothing to draw
72 if (text == nullptr || byteLength == 0) { 69 if (text == nullptr || byteLength == 0) {
73 return; 70 return;
74 } 71 }
75 72
76 GrBatchTextStrike* currStrike = nullptr; 73 GrBatchTextStrike* currStrike = nullptr;
77 74
78 // Get GrFontScaler from cache 75 // Get GrFontScaler from cache
79 SkGlyphCache* cache = blob->setupCache(runIndex, props, skPaint, &viewMatrix , false);
80 GrFontScaler* fontScaler = GrTextContext::GetGrFontScaler(cache); 76 GrFontScaler* fontScaler = GrTextContext::GetGrFontScaler(cache);
81 77
82 SkFindAndPlaceGlyph::ProcessPosText( 78 SkFindAndPlaceGlyph::ProcessPosText(
83 skPaint.getTextEncoding(), text, byteLength, 79 skPaint.getTextEncoding(), text, byteLength,
84 offset, viewMatrix, pos, scalarsPerPosition, 80 offset, viewMatrix, pos, scalarsPerPosition,
85 skPaint.getTextAlign(), cache, 81 skPaint.getTextAlign(), cache,
86 [&](const SkGlyph& glyph, SkPoint position, SkPoint rounding) { 82 [&](const SkGlyph& glyph, SkPoint position, SkPoint rounding) {
87 position += rounding; 83 position += rounding;
88 BmpAppendGlyph( 84 BmpAppendGlyph(
89 blob, runIndex, fontCache, &currStrike, glyph, 85 blob, runIndex, fontCache, &currStrike, glyph,
90 SkScalarFloorToInt(position.fX), SkScalarFloorToInt(position.fY) , 86 SkScalarFloorToInt(position.fX), SkScalarFloorToInt(position.fY) ,
91 color, fontScaler); 87 color, fontScaler);
92 } 88 }
93 ); 89 );
94
95 SkGlyphCache::AttachCache(cache);
96 } 90 }
97 91
98 void GrTextUtils::BmpAppendGlyph(GrAtlasTextBlob* blob, int runIndex, 92 void GrTextUtils::BmpAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
99 GrBatchFontCache* fontCache, 93 GrBatchFontCache* fontCache,
100 GrBatchTextStrike** strike, const SkGlyph& skGl yph, 94 GrBatchTextStrike** strike, const SkGlyph& skGl yph,
101 int vx, int vy, GrColor color, GrFontScaler* sc aler) { 95 int vx, int vy, GrColor color, GrFontScaler* sc aler) {
102 if (!*strike) { 96 if (!*strike) {
103 *strike = fontCache->getStrike(scaler); 97 *strike = fontCache->getStrike(scaler);
104 } 98 }
105 99
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 191
198 matrix[SkMatrix::kMTransX] = loc.fX; 192 matrix[SkMatrix::kMTransX] = loc.fX;
199 matrix[SkMatrix::kMTransY] = loc.fY; 193 matrix[SkMatrix::kMTransY] = loc.fY;
200 GrBlurUtils::drawPathWithMaskFilter(context, dc, clip, *path, pa int, 194 GrBlurUtils::drawPathWithMaskFilter(context, dc, clip, *path, pa int,
201 viewMatrix, &matrix, clipBou nds, false); 195 viewMatrix, &matrix, clipBou nds, false);
202 } 196 }
203 } 197 }
204 pos += scalarsPerPosition; 198 pos += scalarsPerPosition;
205 } 199 }
206 } 200 }
OLDNEW
« no previous file with comments | « src/gpu/text/GrTextUtils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698