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

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

Issue 563283004: Use per-typeface sets of glyphs for nvpr text (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_glyphmemorypath
Patch Set: Created 6 years, 3 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "GrPathRange.h"
9 #include "SkPath.h"
10
11 enum {
12 kPathGroupSize = 16 // Paths get tracked in groups of 16 for lazy loading.
13 };
14
15 GrPathRange::GrPathRange(GrGpu* gpu,
16 PathGenerator* pathGenerator,
17 const SkStrokeRec& stroke)
18 : INHERITED(gpu, kIsWrapped),
19 fPathGenerator(pathGenerator),
20 fNumPaths(fPathGenerator->getNumPaths()),
21 fStroke(stroke) {
22 const uint32_t groupCount = (fNumPaths + kPathGroupSize - 1) / kPathGroupSiz e;
23 fGeneratedPaths.reset((groupCount + 7) / 8); // 1 bit per path group.
24 memset(&fGeneratedPaths.front(), 0, fGeneratedPaths.count());
25 }
26
27 GrPathRange::GrPathRange(GrGpu* gpu,
28 uint32_t numPaths,
29 const SkStrokeRec& stroke)
30 : INHERITED(gpu, kIsWrapped),
31 fNumPaths(numPaths),
32 fStroke(stroke) {
33 }
34
35 void GrPathRange::willDrawPaths(const uint32_t indices[], int count) const {
36 if (NULL == fPathGenerator.get()) {
37 return;
38 }
39
40 bool didLoadPaths = false;
41
42 for (int i = 0; i < count; ++i) {
43 SkASSERT(indices[i] < fNumPaths);
44
45 const uint32_t groupIndex = indices[i] / kPathGroupSize;
46 const uint32_t groupByte = groupIndex / 8;
47 const uint8_t groupBit = 1 << (groupIndex % 8);
48
49 const bool hasPath = 0 != (fGeneratedPaths[groupByte] & groupBit);
50 if (!hasPath) {
51 // We track which paths are loaded in groups of kPathGroupSize. To
52 // mark a path as loaded we need to load the entire group.
53 const uint32_t groupFirstPath = groupIndex * kPathGroupSize;
54 const uint32_t groupLastPath = SkTMin(groupFirstPath + kPathGroupSiz e, fNumPaths) - 1;
55
56 SkPath path;
57 for (uint32_t pathIdx = groupFirstPath; pathIdx <= groupLastPath; ++ pathIdx) {
58 fPathGenerator->generatePath(pathIdx, &path);
59 this->onInitPath(pathIdx, path);
60 }
61
62 fGeneratedPaths[groupByte] |= groupBit;
63 didLoadPaths = true;
64 }
65 }
66
67 if (didLoadPaths) {
68 this->didChangeGpuMemorySize();
69 }
70 }
OLDNEW
« src/gpu/GrPathRange.h ('K') | « src/gpu/GrPathRange.h ('k') | src/gpu/GrPathRendering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698