make GrTextBlob::canReuse const
Change-Id: I27b18e63f9f1ff4ae6ada70a7cf781d6e29c9108
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/374356
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp
index 8901097..29f2fc3 100644
--- a/src/gpu/text/GrTextBlob.cpp
+++ b/src/gpu/text/GrTextBlob.cpp
@@ -184,7 +184,7 @@
const SkGlyphRunList& glyphRunList,
GrSurfaceDrawContext* rtc) const override;
- bool canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) override;
+ bool canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) const override;
GrAtlasSubRun* testingOnly_atlasSubRun() override;
@@ -279,7 +279,7 @@
// paths explicitly. This check is needed because if the blob was drawn large, and then small, the
// path would be reused when the blob should be rendered with masks.
// TODO(herb): rethink when paths can be reused.
-bool PathSubRun::canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) {
+bool PathSubRun::canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) const {
const SkMatrix initialMatrix = fBlob.initialMatrix();
if (initialMatrix.hasPerspective() && !SkMatrixPriv::CheapEqual(initialMatrix, drawMatrix)) {
return false;
@@ -474,7 +474,7 @@
const SkGlyphRunList& glyphRunList,
GrSurfaceDrawContext* rtc) const override;
- bool canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) override;
+ bool canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) const override;
GrAtlasSubRun* testingOnly_atlasSubRun() override;
@@ -580,7 +580,7 @@
}
bool
-DirectMaskSubRun::canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) {
+DirectMaskSubRun::canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) const {
if (drawMatrix.hasPerspective()) {
return false;
}
@@ -864,7 +864,7 @@
const SkGlyphRunList& glyphRunList,
GrSurfaceDrawContext* rtc) const override;
- bool canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) override;
+ bool canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) const override;
GrAtlasSubRun* testingOnly_atlasSubRun() override;
@@ -954,7 +954,7 @@
// If we are not scaling the cache entry to be larger, than a cache with smaller glyphs may be
// better.
-bool TransformedMaskSubRun::canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) {
+bool TransformedMaskSubRun::canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) const {
if (fBlob->initialMatrix().getMaxScale() < 1) {
return false;
}
@@ -1114,7 +1114,7 @@
const SkGlyphRunList& glyphRunList,
GrSurfaceDrawContext* rtc) const override;
- bool canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) override;
+ bool canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) const override;
GrAtlasSubRun* testingOnly_atlasSubRun() override;
@@ -1281,7 +1281,7 @@
}
}
-bool SDFTSubRun::canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) {
+bool SDFTSubRun::canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) const {
const SkMatrix& initialMatrix = fBlob->initialMatrix();
if (drawMatrix.hasPerspective()) {
return false;
@@ -1411,7 +1411,7 @@
bool GrTextBlob::hasPerspective() const { return fInitialMatrix.hasPerspective(); }
-bool GrTextBlob::canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) {
+bool GrTextBlob::canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) const {
// A singular matrix will create a GrTextBlob with no SubRuns, but unknown glyphs can
// also cause empty runs. If there are no subRuns, then regenerate.
if ((fSubRunList.isEmpty() || fSomeGlyphsExcluded) && fInitialMatrix != drawMatrix) {
@@ -1426,7 +1426,7 @@
return false;
}
- for (GrSubRun& subRun : this->fSubRunList) {
+ for (const GrSubRun& subRun : fSubRunList) {
if (!subRun.canReuse(paint, drawMatrix)) {
return false;
}
diff --git a/src/gpu/text/GrTextBlob.h b/src/gpu/text/GrTextBlob.h
index 57a60d6..0e8431e 100644
--- a/src/gpu/text/GrTextBlob.h
+++ b/src/gpu/text/GrTextBlob.h
@@ -302,7 +302,7 @@
// Given an already cached subRun, can this subRun handle this combination paint, matrix, and
// position.
- virtual bool canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) = 0;
+ virtual bool canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) const = 0;
// Return the underlying atlas SubRun if it exists. Otherwise, return nullptr.
// * Don't use this API. It is only to support testing.
@@ -410,7 +410,7 @@
return {fMaxMinScale, fMinMaxScale};
}
- bool canReuse(const SkPaint& paint, const SkMatrix& drawMatrix);
+ bool canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) const;
const Key& key() const;
size_t size() const;