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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrPathRange.cpp
diff --git a/src/gpu/GrPathRange.cpp b/src/gpu/GrPathRange.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a6ad99a3bd6c920f8dd57d01911c0a5c431c4e98
--- /dev/null
+++ b/src/gpu/GrPathRange.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrPathRange.h"
+#include "SkPath.h"
+
+enum {
+ kPathGroupSize = 16 // Paths get tracked in groups of 16 for lazy loading.
+};
+
+GrPathRange::GrPathRange(GrGpu* gpu,
+ PathGenerator* pathGenerator,
+ const SkStrokeRec& stroke)
+ : INHERITED(gpu, kIsWrapped),
+ fPathGenerator(pathGenerator),
+ fNumPaths(fPathGenerator->getNumPaths()),
+ fStroke(stroke) {
+ const uint32_t groupCount = (fNumPaths + kPathGroupSize - 1) / kPathGroupSize;
+ fGeneratedPaths.reset((groupCount + 7) / 8); // 1 bit per path group.
+ memset(&fGeneratedPaths.front(), 0, fGeneratedPaths.count());
+}
+
+GrPathRange::GrPathRange(GrGpu* gpu,
+ uint32_t numPaths,
+ const SkStrokeRec& stroke)
+ : INHERITED(gpu, kIsWrapped),
+ fNumPaths(numPaths),
+ fStroke(stroke) {
+}
+
+void GrPathRange::willDrawPaths(const uint32_t indices[], int count) const {
+ if (NULL == fPathGenerator.get()) {
+ return;
+ }
+
+ bool didLoadPaths = false;
+
+ for (int i = 0; i < count; ++i) {
+ SkASSERT(indices[i] < fNumPaths);
+
+ const uint32_t groupIndex = indices[i] / kPathGroupSize;
+ const uint32_t groupByte = groupIndex / 8;
+ const uint8_t groupBit = 1 << (groupIndex % 8);
+
+ const bool hasPath = 0 != (fGeneratedPaths[groupByte] & groupBit);
+ if (!hasPath) {
+ // We track which paths are loaded in groups of kPathGroupSize. To
+ // mark a path as loaded we need to load the entire group.
+ const uint32_t groupFirstPath = groupIndex * kPathGroupSize;
+ const uint32_t groupLastPath = SkTMin(groupFirstPath + kPathGroupSize, fNumPaths) - 1;
+
+ SkPath path;
+ for (uint32_t pathIdx = groupFirstPath; pathIdx <= groupLastPath; ++pathIdx) {
+ fPathGenerator->generatePath(pathIdx, &path);
+ this->onInitPath(pathIdx, path);
+ }
+
+ fGeneratedPaths[groupByte] |= groupBit;
+ didLoadPaths = true;
+ }
+ }
+
+ if (didLoadPaths) {
+ this->didChangeGpuMemorySize();
+ }
+}
« 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