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

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: Fix builds 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
« no previous file with comments | « src/gpu/GrPathRange.h ('k') | src/gpu/GrPathRendering.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 kPathsPerGroup = 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(SkRef(pathGenerator)),
20 fNumPaths(fPathGenerator->getNumPaths()),
21 fStroke(stroke) {
22 const int numGroups = (fNumPaths + kPathsPerGroup - 1) / kPathsPerGroup;
23 fGeneratedPaths.reset((numGroups + 7) / 8); // 1 bit per path group.
24 memset(&fGeneratedPaths.front(), 0, fGeneratedPaths.count());
25 }
26
27 GrPathRange::GrPathRange(GrGpu* gpu,
28 int 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] < static_cast<uint32_t>(fNumPaths));
44
45 const int groupIndex = indices[i] / kPathsPerGroup;
46 const int groupByte = groupIndex / 8;
47 const uint8_t groupBit = 1 << (groupIndex % 8);
48
49 const bool hasPath = SkToBool(fGeneratedPaths[groupByte] & groupBit);
50 if (!hasPath) {
51 // We track which paths are loaded in groups of kPathsPerGroup. To
52 // mark a path as loaded we need to load the entire group.
53 const int groupFirstPath = groupIndex * kPathsPerGroup;
54 const int groupLastPath = SkTMin(groupFirstPath + kPathsPerGroup, fN umPaths) - 1;
55
56 SkPath path;
57 for (int pathIdx = groupFirstPath; pathIdx <= groupLastPath; ++pathI dx) {
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
« no previous file with comments | « src/gpu/GrPathRange.h ('k') | src/gpu/GrPathRendering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698