aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Jim Van Verth <jvanverth@google.com>2017-10-31 14:44:25 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-01 13:59:50 +0000
commit56c37143830d8318853663bf2bcd5bc99c960a75 (patch)
tree7816ca7f36b5b0170f46a678fd57c6fb5fd87c2c
parent503bdcda6ee5087f28416d31502118fbe550f63a (diff)
More attempts at clipping perf.
With the 1.5x allocation strategy, it can take more reallocations to reach a similar size as before. Increasing this initial size reduces the number of reallocations. Also reduce size of Geometry struct slightly. Bug: skia:7230 Change-Id: Ied3f275b01b07aa300e0b7e1f24abc5fc3853ea7 Reviewed-on: https://skia-review.googlesource.com/64500 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
-rw-r--r--src/gpu/ops/GrAtlasTextOp.cpp6
-rw-r--r--src/gpu/ops/GrAtlasTextOp.h6
-rw-r--r--src/gpu/text/GrAtlasTextBlob.cpp13
-rw-r--r--src/gpu/text/GrAtlasTextBlob.h4
4 files changed, 17 insertions, 12 deletions
diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp
index f0a9300d9e..2383510a47 100644
--- a/src/gpu/ops/GrAtlasTextOp.cpp
+++ b/src/gpu/ops/GrAtlasTextOp.cpp
@@ -318,19 +318,19 @@ bool GrAtlasTextOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) {
// Keep the batch vertex buffer size below 32K so we don't have to create a special one
// We use the largest possible vertex size for this
static const int kVertexSize = sizeof(SkPoint) + sizeof(SkColor) + 2 * sizeof(uint16_t);
- static const int kMaxGlyphs = 32768 / (4 * kVertexSize);
+ static const int kMaxGlyphs = 32768 / (kVerticesPerGlyph * kVertexSize);
if (this->fNumGlyphs + that->fNumGlyphs > kMaxGlyphs) {
return false;
}
fNumGlyphs += that->numGlyphs();
- // Reallocate space for geo data if necessary and then import that's geo data.
+ // Reallocate space for geo data if necessary and then import that geo's data.
int newGeoCount = that->fGeoCount + fGeoCount;
// We reallocate at a rate of 1.5x to try to get better total memory usage
if (newGeoCount > fGeoDataAllocSize) {
- int newAllocSize = fGeoDataAllocSize + fGeoDataAllocSize/2;
+ int newAllocSize = fGeoDataAllocSize + fGeoDataAllocSize / 2;
while (newAllocSize < newGeoCount) {
newAllocSize += newAllocSize / 2;
}
diff --git a/src/gpu/ops/GrAtlasTextOp.h b/src/gpu/ops/GrAtlasTextOp.h
index 622b993d44..1814676445 100644
--- a/src/gpu/ops/GrAtlasTextOp.h
+++ b/src/gpu/ops/GrAtlasTextOp.h
@@ -32,8 +32,8 @@ public:
Blob* fBlob;
SkScalar fX;
SkScalar fY;
- int fRun;
- int fSubRun;
+ uint16_t fRun;
+ uint16_t fSubRun;
GrColor fColor;
};
@@ -118,7 +118,7 @@ public:
private:
// The minimum number of Geometry we will try to allocate.
- static constexpr auto kMinGeometryAllocated = 4;
+ static constexpr auto kMinGeometryAllocated = 12;
GrAtlasTextOp(GrPaint&& paint)
: INHERITED(ClassID())
diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp
index f083c85d8f..17f81a2188 100644
--- a/src/gpu/text/GrAtlasTextBlob.cpp
+++ b/src/gpu/text/GrAtlasTextBlob.cpp
@@ -257,7 +257,7 @@ bool GrAtlasTextBlob::mustRegenerate(const GrTextUtils::Paint& paint,
}
inline std::unique_ptr<GrAtlasTextOp> GrAtlasTextBlob::makeOp(
- const Run::SubRunInfo& info, int glyphCount, int run, int subRun,
+ const Run::SubRunInfo& info, int glyphCount, uint16_t run, uint16_t subRun,
const SkMatrix& viewMatrix, SkScalar x, SkScalar y, const SkIRect& clipRect,
const GrTextUtils::Paint& paint, const SkSurfaceProps& props,
const GrDistanceFieldAdjustTable* distanceAdjustTable, GrAtlasGlyphCache* cache,
@@ -295,7 +295,12 @@ inline void GrAtlasTextBlob::flushRun(GrTextUtils::Target* target, const GrClip&
const GrTextUtils::Paint& paint, const SkSurfaceProps& props,
const GrDistanceFieldAdjustTable* distanceAdjustTable,
GrAtlasGlyphCache* cache) {
- int lastRun = fRuns[run].fSubRunInfo.count() - 1;
+ // GrAtlasTextBlob::makeOp only takes uint16_t values for run and subRun indices.
+ // Encountering something larger than this is highly unlikely, so we'll just not draw it.
+ if (run >= (1 << 16)) {
+ return;
+ }
+ int lastRun = SkTMin(fRuns[run].fSubRunInfo.count(), 1 << 16) - 1;
for (int subRun = 0; subRun <= lastRun; subRun++) {
const Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun];
int glyphCount = info.glyphCount();
@@ -451,8 +456,8 @@ void GrAtlasTextBlob::flushThrowaway(GrContext* context, GrTextUtils::Target* ta
}
std::unique_ptr<GrDrawOp> GrAtlasTextBlob::test_makeOp(
- int glyphCount, int run, int subRun, const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
- const GrTextUtils::Paint& paint, const SkSurfaceProps& props,
+ int glyphCount, uint16_t run, uint16_t subRun, const SkMatrix& viewMatrix,
+ SkScalar x, SkScalar y, const GrTextUtils::Paint& paint, const SkSurfaceProps& props,
const GrDistanceFieldAdjustTable* distanceAdjustTable, GrAtlasGlyphCache* cache,
GrTextUtils::Target* target) {
const GrAtlasTextBlob::Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun];
diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h
index 79f2bf3cc4..495e72aa92 100644
--- a/src/gpu/text/GrAtlasTextBlob.h
+++ b/src/gpu/text/GrAtlasTextBlob.h
@@ -270,7 +270,7 @@ public:
////////////////////////////////////////////////////////////////////////////////////////////////
// Internal test methods
- std::unique_ptr<GrDrawOp> test_makeOp(int glyphCount, int run, int subRun,
+ std::unique_ptr<GrDrawOp> test_makeOp(int glyphCount, uint16_t run, uint16_t subRun,
const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
const GrTextUtils::Paint&, const SkSurfaceProps&,
const GrDistanceFieldAdjustTable*, GrAtlasGlyphCache*,
@@ -498,7 +498,7 @@ private:
size_t vertexStride, GrColor color, SkScalar transX, SkScalar transY) const;
inline std::unique_ptr<GrAtlasTextOp> makeOp(
- const Run::SubRunInfo& info, int glyphCount, int run, int subRun,
+ const Run::SubRunInfo& info, int glyphCount, uint16_t run, uint16_t subRun,
const SkMatrix& viewMatrix, SkScalar x, SkScalar y, const SkIRect& clipRect,
const GrTextUtils::Paint& paint, const SkSurfaceProps& props,
const GrDistanceFieldAdjustTable* distanceAdjustTable, GrAtlasGlyphCache* cache,