constify GrAtlasTextOp::Geometry

fSubRunPtr is currently mutable, but that will change in future CLs.

Change-Id: Ia3ab40855d7ea7c42eadf8889688fefb064f1bc9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/304696
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Herb Derby 2020-07-21 11:45:04 -04:00 committed by Skia Commit-Bot
parent 6c452a50e9
commit 1d17e49041
4 changed files with 32 additions and 32 deletions

View File

@ -340,7 +340,7 @@ public:
if (count > kCount) {
if (fPtr == fTStorage) {
fPtr = (T*)sk_malloc_throw(count, sizeof(T));
memcpy(fPtr, fTStorage, kCount * sizeof(T));
memcpy((void*)fPtr, fTStorage, kCount * sizeof(T));
} else {
fPtr = (T*)sk_realloc_throw(fPtr, count, sizeof(T));
}

View File

@ -38,8 +38,8 @@ GrAtlasTextOp::GrAtlasTextOp(MaskType maskType,
bool needsTransform,
int glyphCount,
SkRect deviceRect,
GrPaint&& paint,
Geometry&& geo)
const Geometry& geo,
GrPaint&& paint)
: INHERITED{ClassID()}
, fMaskType{maskType}
, fNeedsGlyphTransform{needsTransform}
@ -49,7 +49,7 @@ GrAtlasTextOp::GrAtlasTextOp(MaskType maskType,
, fGeoDataAllocSize{kMinGeometryAllocated}
, fProcessors{std::move(paint)}
, fNumGlyphs{glyphCount} {
fGeoData[0] = std::move(geo);
new (&fGeoData[0]) Geometry{geo};
fGeoCount = 1;
// We don't have tight bounds on the glyph paths in device space. For the purposes of bounds
@ -64,8 +64,8 @@ GrAtlasTextOp::GrAtlasTextOp(MaskType maskType,
SkColor luminanceColor,
bool useGammaCorrectDistanceTable,
uint32_t DFGPFlags,
GrPaint&& paint,
Geometry&& geo)
const Geometry& geo,
GrPaint&& paint)
: INHERITED{ClassID()}
, fMaskType{maskType}
, fNeedsGlyphTransform{needsTransform}
@ -75,7 +75,7 @@ GrAtlasTextOp::GrAtlasTextOp(MaskType maskType,
, fGeoDataAllocSize{kMinGeometryAllocated}
, fProcessors{std::move(paint)}
, fNumGlyphs{glyphCount} {
fGeoData[0] = std::move(geo);
new (&fGeoData[0]) Geometry{geo};
fGeoCount = 1;
// We don't have tight bounds on the glyph paths in device space. For the purposes of bounds
@ -230,7 +230,7 @@ void GrAtlasTextOp::onPrepareDraws(Target* target) {
resetVertexBuffer();
for (const Geometry& geo : SkMakeSpan(fGeoData.get(), fGeoCount)) {
GrAtlasSubRun* subRun = geo.fSubRunPtr;
GrAtlasSubRun* const subRun = geo.fSubRunPtr;
SkASSERT((int)subRun->vertexStride() == vertexStride);
const int subRunEnd = subRun->glyphCount();
@ -390,12 +390,10 @@ GrOp::CombineResult GrAtlasTextOp::onCombineIfPossible(GrOp* t, GrRecordingConte
// We steal the ref on the blobs from the other AtlasTextOp and set its count to 0 so that
// it doesn't try to unref them.
memcpy(&fGeoData[fGeoCount], that->fGeoData.get(), that->fGeoCount * sizeof(Geometry));
#ifdef SK_DEBUG
for (int i = 0; i < that->fGeoCount; ++i) {
that->fGeoData.get()[i].fBlob = (GrTextBlob*)0x1;
for (int i = 0; i < that->fGeoCount; i++) {
new (&fGeoData[fGeoCount + i]) Geometry{that->fGeoData[i]};
}
#endif
that->fGeoCount = 0;
fGeoCount = newGeoCount;

View File

@ -27,14 +27,16 @@ public:
static const int kIndicesPerGlyph = 6;
struct Geometry {
GrTextBlob* fBlob;
GrAtlasSubRun* fSubRunPtr;
SkMatrix fDrawMatrix;
SkPoint fDrawOrigin;
SkIRect fClipRect;
SkPMColor4f fColor;
void fillVertexData(void* dst, int offset, int count) const;
GrAtlasSubRun* const fSubRunPtr;
const SkMatrix fDrawMatrix;
const SkPoint fDrawOrigin;
const SkIRect fClipRect;
GrTextBlob* const fBlob; // mutable to make unref call in Op dtor.
// Strangely, the color is mutated as part of the onPrepare process.
SkPMColor4f fColor;
};
const char* name() const override { return "AtlasTextOp"; }
@ -82,8 +84,8 @@ private:
bool needsTransform,
int glyphCount,
SkRect deviceRect,
GrPaint&& paint,
Geometry&& geo);
const Geometry& geo,
GrPaint&& paint);
GrAtlasTextOp(MaskType maskType,
bool needsTransform,
@ -92,8 +94,8 @@ private:
SkColor luminanceColor,
bool useGammaCorrectDistanceTable,
uint32_t DFGPFlags,
GrPaint&& paint,
Geometry&& geo);
const Geometry& geo,
GrPaint&& paint);
struct FlushInfo {
sk_sp<const GrBuffer> fVertexBuffer;

View File

@ -348,11 +348,11 @@ GrDirectMaskSubRun::makeAtlasTextOp(const GrClip* clip, const SkMatrixProvider&
const SkPMColor4f drawingColor =
calculate_colors(rtc, drawPaint, viewMatrix, fMaskFormat, &grPaint);
GrAtlasTextOp::Geometry geometry = {
SkRef(fBlob),
this,
drawMatrix,
drawOrigin,
clipRect,
SkRef(fBlob),
drawingColor
};
@ -361,8 +361,8 @@ GrDirectMaskSubRun::makeAtlasTextOp(const GrClip* clip, const SkMatrixProvider&
false,
this->glyphCount(),
subRunBounds,
std::move(grPaint),
std::move(geometry));
geometry,
std::move(grPaint));
return {clip, std::move(op)};
}
@ -514,11 +514,11 @@ GrMaskSubRun::makeAtlasTextOp(const GrClip* clip,
// We can clip geometrically using clipRect and ignore clip if we're not using SDFs or
// transformed glyphs, and we have an axis-aligned rectangular non-AA clip.
GrAtlasTextOp::Geometry geometry = {
SkRef(fBlob),
this,
drawMatrix,
drawOrigin,
SkIRect::MakeEmpty(),
SkRef(fBlob),
drawingColor
};
std::unique_ptr<GrDrawOp> op;
@ -530,8 +530,8 @@ GrMaskSubRun::makeAtlasTextOp(const GrClip* clip,
true,
this->glyphCount(),
this->deviceRect(drawMatrix, drawOrigin),
std::move(grPaint),
std::move(geometry));
geometry,
std::move(grPaint));
} else {
const GrColorInfo& colorInfo = rtc->colorInfo();
const SkSurfaceProps& props = rtc->surfaceProps();
@ -564,8 +564,8 @@ GrMaskSubRun::makeAtlasTextOp(const GrClip* clip,
SkPaintPriv::ComputeLuminanceColor(drawPaint),
useGammaCorrectDistanceTable,
DFGPFlags,
std::move(grPaint),
std::move(geometry));
geometry,
std::move(grPaint));
}
return {clip, std::move(op)};