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

Unified Diff: src/gpu/text/GrAtlasTextBlob.h

Issue 1605013002: Fix GrAtlasTextBlob bounds management (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanuptext17
Patch Set: fix glprograms Created 4 years, 11 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
« no previous file with comments | « src/gpu/batches/GrAtlasTextBatch.cpp ('k') | src/gpu/text/GrAtlasTextBlob.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/text/GrAtlasTextBlob.h
diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h
index 1c5ea5e60ea73d6e8253794e46813d4f922665c8..af6441e003384246a772b493433f21086dc01b67 100644
--- a/src/gpu/text/GrAtlasTextBlob.h
+++ b/src/gpu/text/GrAtlasTextBlob.h
@@ -210,13 +210,11 @@ public:
// We use this color vs the SkPaint color because it has the colorfilter applied.
void initReusableBlob(GrColor color, const SkMatrix& viewMatrix, SkScalar x, SkScalar y) {
fPaintColor = color;
- fViewMatrix = viewMatrix;
- fX = x;
- fY = y;
+ this->setupViewMatrix(viewMatrix, x, y);
}
- void initThrowawayBlob(const SkMatrix& viewMatrix) {
- fViewMatrix = viewMatrix;
+ void initThrowawayBlob(const SkMatrix& viewMatrix, SkScalar x, SkScalar y) {
+ this->setupViewMatrix(viewMatrix, x, y);
}
GrDrawBatch* test_createBatch(int glyphCount, int run, int subRun,
@@ -249,6 +247,20 @@ private:
SkDrawFilter* drawFilter, const SkMatrix& viewMatrix,
const SkIRect& clipBounds, SkScalar x, SkScalar y);
+ // This function will only be called when we are regenerating a blob from scratch. We record the
+ // initial view matrix and initial offsets(x,y), because we record vertex bounds relative to
+ // these numbers. When blobs are reused with new matrices, we need to return to model space so
+ // we can update the vertex bounds appropriately.
+ void setupViewMatrix(const SkMatrix& viewMatrix, SkScalar x, SkScalar y) {
+ fViewMatrix = viewMatrix;
+ if (!viewMatrix.invert(&fInitialViewMatrixInverse)) {
+ fInitialViewMatrixInverse = SkMatrix::I();
+ SkDebugf("Could not invert viewmatrix\n");
+ }
+ fX = fInitialX = x;
+ fY = fInitialY = y;
+ }
+
/*
* Each Run inside of the blob can have its texture coordinates regenerated if required.
* To determine if regeneration is necessary, fAtlasGeneration is used. If there have been
@@ -276,7 +288,6 @@ private:
Run()
: fInitialized(false)
, fDrawAsPaths(false) {
- fVertexBounds.setLargestInverted();
// To ensure we always have one subrun, we push back a fresh run here
fSubRunInfo.push_back();
}
@@ -290,10 +301,13 @@ private:
, fColor(GrColor_ILLEGAL)
, fMaskFormat(kA8_GrMaskFormat)
, fDrawAsDistanceFields(false)
- , fUseLCDText(false) {}
+ , fUseLCDText(false) {
+ fVertexBounds.setLargestInverted();
+ }
SubRunInfo(const SubRunInfo& that)
: fBulkUseToken(that.fBulkUseToken)
, fStrike(SkSafeRef(that.fStrike.get()))
+ , fVertexBounds(that.fVertexBounds)
, fAtlasGeneration(that.fAtlasGeneration)
, fVertexStartIndex(that.fVertexStartIndex)
, fVertexEndIndex(that.fVertexEndIndex)
@@ -338,6 +352,11 @@ private:
fVertexEndIndex = prev.vertexEndIndex();
}
+ const SkRect& vertexBounds() const { return fVertexBounds; }
+ void joinGlyphBounds(const SkRect& glyphBounds) {
+ fVertexBounds.joinNonEmptyArg(glyphBounds);
+ }
+
// df properties
void setUseLCDText(bool useLCDText) { fUseLCDText = useLCDText; }
bool hasUseLCDText() const { return fUseLCDText; }
@@ -347,6 +366,7 @@ private:
private:
GrBatchAtlas::BulkUseTokenUpdater fBulkUseToken;
SkAutoTUnref<GrBatchTextStrike> fStrike;
+ SkRect fVertexBounds;
uint64_t fAtlasGeneration;
size_t fVertexStartIndex;
size_t fVertexEndIndex;
@@ -368,7 +388,6 @@ private:
}
static const int kMinSubRuns = 1;
SkAutoTUnref<SkTypeface> fTypeface;
- SkRect fVertexBounds;
SkSTArray<kMinSubRuns, SubRunInfo> fSubRunInfo;
SkAutoDescriptor fDescriptor;
@@ -423,7 +442,10 @@ private:
SkTArray<BigGlyph> fBigGlyphs;
Key fKey;
SkMatrix fViewMatrix;
+ SkMatrix fInitialViewMatrixInverse;
GrColor fPaintColor;
+ SkScalar fInitialX;
+ SkScalar fInitialY;
SkScalar fX;
SkScalar fY;
« no previous file with comments | « src/gpu/batches/GrAtlasTextBatch.cpp ('k') | src/gpu/text/GrAtlasTextBlob.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698