| Index: src/gpu/text/GrAtlasTextBlob.h
|
| diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h
|
| index 8b175c8e96042e536b7ea290700012d4246692f3..a026693012a592856cc0951823e9ab2349d36abe 100644
|
| --- a/src/gpu/text/GrAtlasTextBlob.h
|
| +++ b/src/gpu/text/GrAtlasTextBlob.h
|
| @@ -173,8 +173,7 @@ public:
|
| }
|
| }
|
|
|
| - bool mustRegenerate(SkScalar* outTransX, SkScalar* outTransY, const SkPaint& paint,
|
| - GrColor color, const SkMaskFilter::BlurRec& blurRec,
|
| + bool mustRegenerate(const SkPaint& paint, GrColor color, const SkMaskFilter::BlurRec& blurRec,
|
| const SkMatrix& viewMatrix, SkScalar x, SkScalar y);
|
|
|
| // flush a GrAtlasTextBlob associated with a SkTextBlob
|
| @@ -189,8 +188,7 @@ public:
|
| const GrClip& clip,
|
| const SkMatrix& viewMatrix,
|
| const SkIRect& clipBounds,
|
| - SkScalar x, SkScalar y,
|
| - SkScalar transX, SkScalar transY);
|
| + SkScalar x, SkScalar y);
|
|
|
| // flush a throwaway GrAtlasTextBlob *not* associated with an SkTextBlob
|
| void flushThrowaway(GrContext* context,
|
| @@ -200,9 +198,12 @@ public:
|
| const SkPaint& skPaint,
|
| const GrPaint& grPaint,
|
| const GrClip& clip,
|
| - const SkIRect& clipBounds);
|
| + const SkMatrix& viewMatrix,
|
| + const SkIRect& clipBounds,
|
| + SkScalar x, SkScalar y);
|
|
|
| - void computeSubRunBounds(SkRect* outBounds, int runIndex, int subRunIndex) {
|
| + void computeSubRunBounds(SkRect* outBounds, int runIndex, int subRunIndex,
|
| + const SkMatrix& viewMatrix, SkScalar x, SkScalar y) {
|
| // We don't yet position distance field text on the cpu, so we have to map the vertex bounds
|
| // into device space.
|
| // We handle vertex bounds differently for distance field text and bitmap text because
|
| @@ -214,8 +215,8 @@ public:
|
| if (subRun.drawAsDistanceFields()) {
|
| // Distance field text is positioned with the (X,Y) as part of the glyph position,
|
| // and currently the view matrix is applied on the GPU
|
| - outBounds->offset(fX - fInitialX, fY - fInitialY);
|
| - fViewMatrix.mapRect(outBounds);
|
| + outBounds->offset(x - fInitialX, y - fInitialY);
|
| + viewMatrix.mapRect(outBounds);
|
| } else {
|
| // Bitmap text is fully positioned on the CPU, and offset by an (X,Y) translate in
|
| // device space.
|
| @@ -223,9 +224,9 @@ public:
|
|
|
| boundsMatrix.postTranslate(-fInitialX, -fInitialY);
|
|
|
| - boundsMatrix.postTranslate(fX, fY);
|
| + boundsMatrix.postTranslate(x, y);
|
|
|
| - boundsMatrix.postConcat(fViewMatrix);
|
| + boundsMatrix.postConcat(viewMatrix);
|
| boundsMatrix.mapRect(outBounds);
|
|
|
| // Due to floating point numerical inaccuracies, we have to round out here
|
| @@ -233,9 +234,6 @@ public:
|
| }
|
| }
|
|
|
| - const SkMatrix& viewMatrix() const { return fViewMatrix; }
|
| -
|
| -
|
| // position + local coord
|
| static const size_t kColorTextVASize = sizeof(SkPoint) + sizeof(SkIPoint16);
|
| static const size_t kGrayTextVASize = sizeof(SkPoint) + sizeof(GrColor) + sizeof(SkIPoint16);
|
| @@ -261,7 +259,8 @@ public:
|
| GrBlobRegenHelper *helper, int run, int subRun, SkGlyphCache** cache,
|
| SkTypeface** typeface, GrFontScaler** scaler,
|
| const SkDescriptor** desc, size_t vertexStride,
|
| - GrColor color, SkScalar transX, SkScalar transY,
|
| + const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
|
| + GrColor color,
|
| void** vertices, size_t* byteCount, int* glyphCount);
|
|
|
| const Key& key() const { return fKey; }
|
| @@ -275,7 +274,7 @@ public:
|
| ////////////////////////////////////////////////////////////////////////////////////////////////
|
| // Internal test methods
|
| GrDrawBatch* test_createBatch(int glyphCount, int run, int subRun,
|
| - GrColor color, SkScalar transX, SkScalar transY,
|
| + const SkMatrix& viewMatrix, SkScalar x, SkScalar y, GrColor color,
|
| const SkPaint& skPaint, const SkSurfaceProps& props,
|
| const GrDistanceFieldAdjustTable* distanceAdjustTable,
|
| GrBatchFontCache* cache);
|
| @@ -290,15 +289,14 @@ private:
|
| SkScalar x, SkScalar y, SkScalar scale, bool applyVM);
|
|
|
| inline void flushRun(GrDrawContext* dc, GrPipelineBuilder* pipelineBuilder,
|
| - int run, GrColor color,
|
| - SkScalar transX, SkScalar transY,
|
| + int run, const SkMatrix& viewMatrix, SkScalar x, SkScalar y, GrColor color,
|
| const SkPaint& skPaint, const SkSurfaceProps& props,
|
| const GrDistanceFieldAdjustTable* distanceAdjustTable,
|
| GrBatchFontCache* cache);
|
|
|
| void flushBigGlyphs(GrContext* context, GrDrawContext* dc,
|
| const GrClip& clip, const SkPaint& skPaint,
|
| - SkScalar transX, SkScalar transY,
|
| + const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
|
| const SkIRect& clipBounds);
|
|
|
| void flushRunAsPaths(GrContext* context,
|
| @@ -309,18 +307,23 @@ 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
|
| + // This function will only be called when we are generating 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;
|
| + fInitialViewMatrix = viewMatrix;
|
| if (!viewMatrix.invert(&fInitialViewMatrixInverse)) {
|
| fInitialViewMatrixInverse = SkMatrix::I();
|
| SkDebugf("Could not invert viewmatrix\n");
|
| }
|
| - fX = fInitialX = x;
|
| - fY = fInitialY = y;
|
| + fInitialX = x;
|
| + fInitialY = y;
|
| +
|
| + // make sure all initial subruns have the correct VM and X/Y applied
|
| + for (int i = 0; i < fRunCount; i++) {
|
| + fRuns[i].fSubRunInfo[0].init(fInitialViewMatrix, x, y);
|
| + }
|
| }
|
|
|
| /*
|
| @@ -369,12 +372,15 @@ private:
|
| SubRunInfo(const SubRunInfo& that)
|
| : fBulkUseToken(that.fBulkUseToken)
|
| , fStrike(SkSafeRef(that.fStrike.get()))
|
| + , fCurrentViewMatrix(that.fCurrentViewMatrix)
|
| , fVertexBounds(that.fVertexBounds)
|
| , fAtlasGeneration(that.fAtlasGeneration)
|
| , fVertexStartIndex(that.fVertexStartIndex)
|
| , fVertexEndIndex(that.fVertexEndIndex)
|
| , fGlyphStartIndex(that.fGlyphStartIndex)
|
| , fGlyphEndIndex(that.fGlyphEndIndex)
|
| + , fX(that.fX)
|
| + , fY(that.fY)
|
| , fColor(that.fColor)
|
| , fMaskFormat(that.fMaskFormat)
|
| , fDrawAsDistanceFields(that.fDrawAsDistanceFields)
|
| @@ -412,6 +418,9 @@ private:
|
|
|
| fVertexStartIndex = prev.vertexEndIndex();
|
| fVertexEndIndex = prev.vertexEndIndex();
|
| +
|
| + // copy over viewmatrix settings
|
| + this->init(prev.fCurrentViewMatrix, prev.fX, prev.fY);
|
| }
|
|
|
| const SkRect& vertexBounds() const { return fVertexBounds; }
|
| @@ -419,6 +428,16 @@ private:
|
| fVertexBounds.joinNonEmptyArg(glyphBounds);
|
| }
|
|
|
| + void init(const SkMatrix& viewMatrix, SkScalar x, SkScalar y) {
|
| + fCurrentViewMatrix = viewMatrix;
|
| + fX = x;
|
| + fY = y;
|
| + }
|
| +
|
| + // This function assumes the translation will be applied before it is called again
|
| + void computeTranslation(const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
|
| + SkScalar*transX, SkScalar* transY);
|
| +
|
| // df properties
|
| void setUseLCDText(bool useLCDText) { fUseLCDText = useLCDText; }
|
| bool hasUseLCDText() const { return fUseLCDText; }
|
| @@ -428,12 +447,15 @@ private:
|
| private:
|
| GrBatchAtlas::BulkUseTokenUpdater fBulkUseToken;
|
| SkAutoTUnref<GrBatchTextStrike> fStrike;
|
| + SkMatrix fCurrentViewMatrix;
|
| SkRect fVertexBounds;
|
| uint64_t fAtlasGeneration;
|
| size_t fVertexStartIndex;
|
| size_t fVertexEndIndex;
|
| uint32_t fGlyphStartIndex;
|
| uint32_t fGlyphEndIndex;
|
| + SkScalar fX;
|
| + SkScalar fY;
|
| GrColor fColor;
|
| GrMaskFormat fMaskFormat;
|
| bool fDrawAsDistanceFields; // df property
|
| @@ -475,7 +497,8 @@ private:
|
|
|
| inline GrDrawBatch* createBatch(const Run::SubRunInfo& info,
|
| int glyphCount, int run, int subRun,
|
| - GrColor color, SkScalar transX, SkScalar transY,
|
| + const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
|
| + GrColor color,
|
| const SkPaint& skPaint, const SkSurfaceProps& props,
|
| const GrDistanceFieldAdjustTable* distanceAdjustTable,
|
| GrBatchFontCache* cache);
|
| @@ -483,14 +506,14 @@ private:
|
| struct BigGlyph {
|
| BigGlyph(const SkPath& path, SkScalar vx, SkScalar vy, SkScalar scale, bool applyVM)
|
| : fPath(path)
|
| - , fVx(vx)
|
| - , fVy(vy)
|
| , fScale(scale)
|
| + , fX(vx)
|
| + , fY(vy)
|
| , fApplyVM(applyVM) {}
|
| SkPath fPath;
|
| - SkScalar fVx;
|
| - SkScalar fVy;
|
| SkScalar fScale;
|
| + SkScalar fX;
|
| + SkScalar fY;
|
| bool fApplyVM;
|
| };
|
|
|
| @@ -514,14 +537,12 @@ private:
|
| StrokeInfo fStrokeInfo;
|
| SkTArray<BigGlyph> fBigGlyphs;
|
| Key fKey;
|
| - SkMatrix fViewMatrix;
|
| + SkMatrix fInitialViewMatrix;
|
| SkMatrix fInitialViewMatrixInverse;
|
| size_t fSize;
|
| GrColor fPaintColor;
|
| SkScalar fInitialX;
|
| SkScalar fInitialY;
|
| - SkScalar fX;
|
| - SkScalar fY;
|
|
|
| // We can reuse distance field text, but only if the new viewmatrix would not result in
|
| // a mip change. Because there can be multiple runs in a blob, we track the overall
|
|
|