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

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

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

Powered by Google App Engine
This is Rietveld 408576698