diff options
author | 2016-12-15 10:58:41 -0500 | |
---|---|---|
committer | 2016-12-15 16:58:04 +0000 | |
commit | 344ec42f60fd9d10f14d4ffaf8e7b7916bb20bcc (patch) | |
tree | 23effeb876372f752159f876ce9d9a26abfaf7a2 /src/gpu/batches/GrAtlasTextOp.cpp | |
parent | 09e019eafdc01d7d33e2b9d469a3f5afe2808e38 (diff) |
Rename GrAtlasTextBatch->GrAtlasTextOp and sk_sp
Change-Id: I409048988cccb68daaeb66828e2772fcb6a0cb06
Reviewed-on: https://skia-review.googlesource.com/6104
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/batches/GrAtlasTextOp.cpp')
-rw-r--r-- | src/gpu/batches/GrAtlasTextOp.cpp | 122 |
1 files changed, 48 insertions, 74 deletions
diff --git a/src/gpu/batches/GrAtlasTextOp.cpp b/src/gpu/batches/GrAtlasTextOp.cpp index 0b692d15b3..d576789e26 100644 --- a/src/gpu/batches/GrAtlasTextOp.cpp +++ b/src/gpu/batches/GrAtlasTextOp.cpp @@ -28,7 +28,7 @@ static inline GrColor skcolor_to_grcolor_nopremultiply(SkColor c) { static const int kDistanceAdjustLumShift = 5; -SkString GrAtlasTextBatch::dumpInfo() const { +SkString GrAtlasTextOp::dumpInfo() const { SkString str; for (int i = 0; i < fGeoCount; ++i) { @@ -45,13 +45,13 @@ SkString GrAtlasTextBatch::dumpInfo() const { return str; } -void GrAtlasTextBatch::computePipelineOptimizations(GrInitInvariantOutput* color, - GrInitInvariantOutput* coverage, - GrBatchToXPOverrides* overrides) const { +void GrAtlasTextOp::computePipelineOptimizations(GrInitInvariantOutput* color, + GrInitInvariantOutput* coverage, + GrBatchToXPOverrides* overrides) const { if (kColorBitmapMask_MaskType == fMaskType) { color->setUnknownFourComponents(); } else { - color->setKnownFourComponents(fBatch.fColor); + color->setKnownFourComponents(fColor); } switch (fMaskType) { case kGrayscaleDistanceField_MaskType: @@ -68,21 +68,20 @@ void GrAtlasTextBatch::computePipelineOptimizations(GrInitInvariantOutput* color } } -void GrAtlasTextBatch::initBatchTracker(const GrXPOverridesForBatch& overrides) { +void GrAtlasTextOp::initBatchTracker(const GrXPOverridesForBatch& overrides) { // Handle any color overrides if (!overrides.readsColor()) { fGeoData[0].fColor = GrColor_ILLEGAL; } overrides.getOverrideColorIfSet(&fGeoData[0].fColor); - // setup batch properties - fBatch.fColorIgnored = !overrides.readsColor(); - fBatch.fColor = fGeoData[0].fColor; - fBatch.fUsesLocalCoords = overrides.readsLocalCoords(); - fBatch.fCoverageIgnored = !overrides.readsCoverage(); + fColorIgnored = !overrides.readsColor(); + fColor = fGeoData[0].fColor; + fUsesLocalCoords = overrides.readsLocalCoords(); + fCoverageIgnored = !overrides.readsCoverage(); } -void GrAtlasTextBatch::onPrepareDraws(Target* target) const { +void GrAtlasTextOp::onPrepareDraws(Target* target) const { // if we have RGB, then we won't have any SkShaders so no need to use a localmatrix. // TODO actually only invert if we don't have RGBA SkMatrix localMatrix; @@ -102,15 +101,11 @@ void GrAtlasTextBatch::onPrepareDraws(Target* target) const { FlushInfo flushInfo; if (this->usesDistanceFields()) { flushInfo.fGeometryProcessor = - this->setupDfProcessor(this->viewMatrix(), fFilteredColor, this->color(), texture); + this->setupDfProcessor(this->viewMatrix(), fFilteredColor, this->color(), texture); } else { GrSamplerParams params(SkShader::kClamp_TileMode, GrSamplerParams::kNone_FilterMode); - flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(this->color(), - texture, - params, - maskFormat, - localMatrix, - this->usesLocalCoords()); + flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make( + this->color(), texture, params, maskFormat, localMatrix, this->usesLocalCoords()); } flushInfo.fGlyphsToFlush = 0; @@ -120,10 +115,8 @@ void GrAtlasTextBatch::onPrepareDraws(Target* target) const { int glyphCount = this->numGlyphs(); const GrBuffer* vertexBuffer; - void* vertices = target->makeVertexSpace(vertexStride, - glyphCount * kVerticesPerGlyph, - &vertexBuffer, - &flushInfo.fVertexOffset); + void* vertices = target->makeVertexSpace( + vertexStride, glyphCount * kVerticesPerGlyph, &vertexBuffer, &flushInfo.fVertexOffset); flushInfo.fVertexBuffer.reset(SkRef(vertexBuffer)); flushInfo.fIndexBuffer.reset(target->resourceProvider()->refQuadIndexBuffer()); if (!vertices || !flushInfo.fVertexBuffer) { @@ -152,7 +145,7 @@ void GrAtlasTextBatch::onPrepareDraws(Target* target) const { // bounds sanity check SkRect rect; rect.setLargestInverted(); - SkPoint* vertex = (SkPoint*) ((char*)blobVertices); + SkPoint* vertex = (SkPoint*)((char*)blobVertices); rect.growToInclude(vertex, vertexStride, kVerticesPerGlyph * subRunGlyphCount); if (this->usesDistanceFields()) { @@ -170,21 +163,20 @@ void GrAtlasTextBatch::onPrepareDraws(Target* target) const { this->flush(target, &flushInfo); } -void GrAtlasTextBatch::flush(GrMeshDrawOp::Target* target, FlushInfo* flushInfo) const { +void GrAtlasTextOp::flush(GrMeshDrawOp::Target* target, FlushInfo* flushInfo) const { GrMesh mesh; int maxGlyphsPerDraw = - static_cast<int>(flushInfo->fIndexBuffer->gpuMemorySize() / sizeof(uint16_t) / 6); + static_cast<int>(flushInfo->fIndexBuffer->gpuMemorySize() / sizeof(uint16_t) / 6); mesh.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer.get(), - flushInfo->fIndexBuffer.get(), flushInfo->fVertexOffset, - kVerticesPerGlyph, kIndicesPerGlyph, flushInfo->fGlyphsToFlush, - maxGlyphsPerDraw); + flushInfo->fIndexBuffer.get(), flushInfo->fVertexOffset, kVerticesPerGlyph, + kIndicesPerGlyph, flushInfo->fGlyphsToFlush, maxGlyphsPerDraw); target->draw(flushInfo->fGeometryProcessor.get(), mesh); flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush; flushInfo->fGlyphsToFlush = 0; } -bool GrAtlasTextBatch::onCombineIfPossible(GrOp* t, const GrCaps& caps) { - GrAtlasTextBatch* that = t->cast<GrAtlasTextBatch>(); +bool GrAtlasTextOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) { + GrAtlasTextOp* that = t->cast<GrAtlasTextOp>(); if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(), that->bounds(), caps)) { return false; @@ -215,7 +207,7 @@ bool GrAtlasTextBatch::onCombineIfPossible(GrOp* t, const GrCaps& caps) { } } - fBatch.fNumGlyphs += that->numGlyphs(); + fNumGlyphs += that->numGlyphs(); // Reallocate space for geo data if necessary and then import that's geo data. int newGeoCount = that->fGeoCount + fGeoCount; @@ -229,9 +221,9 @@ bool GrAtlasTextBatch::onCombineIfPossible(GrOp* t, const GrCaps& caps) { fGeoData.realloc(newAllocSize); } - memcpy(&fGeoData[fGeoCount], that->fGeoData.get(), that->fGeoCount * sizeof(Geometry)); - // We steal the ref on the blobs from the other TextBatch and set its count to 0 so that + // 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 = (Blob*)0x1; @@ -246,10 +238,10 @@ bool GrAtlasTextBatch::onCombineIfPossible(GrOp* t, const GrCaps& caps) { // TODO just use class params // TODO trying to figure out why lcd is so whack -sk_sp<GrGeometryProcessor> GrAtlasTextBatch::setupDfProcessor(const SkMatrix& viewMatrix, - SkColor filteredColor, - GrColor color, - GrTexture* texture) const { +sk_sp<GrGeometryProcessor> GrAtlasTextOp::setupDfProcessor(const SkMatrix& viewMatrix, + SkColor filteredColor, + GrColor color, + GrTexture* texture) const { GrSamplerParams params(SkShader::kClamp_TileMode, GrSamplerParams::kBilerp_FilterMode); bool isLCD = this->isLCD(); // set up any flags @@ -265,50 +257,32 @@ sk_sp<GrGeometryProcessor> GrAtlasTextBatch::setupDfProcessor(const SkMatrix& vi GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredColor); float redCorrection = fDistanceAdjustTable->getAdjustment( - GrColorUnpackR(colorNoPreMul) >> kDistanceAdjustLumShift, - fUseGammaCorrectDistanceTable); + GrColorUnpackR(colorNoPreMul) >> kDistanceAdjustLumShift, + fUseGammaCorrectDistanceTable); float greenCorrection = fDistanceAdjustTable->getAdjustment( - GrColorUnpackG(colorNoPreMul) >> kDistanceAdjustLumShift, - fUseGammaCorrectDistanceTable); + GrColorUnpackG(colorNoPreMul) >> kDistanceAdjustLumShift, + fUseGammaCorrectDistanceTable); float blueCorrection = fDistanceAdjustTable->getAdjustment( - GrColorUnpackB(colorNoPreMul) >> kDistanceAdjustLumShift, - fUseGammaCorrectDistanceTable); + GrColorUnpackB(colorNoPreMul) >> kDistanceAdjustLumShift, + fUseGammaCorrectDistanceTable); GrDistanceFieldLCDTextGeoProc::DistanceAdjust widthAdjust = - GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(redCorrection, - greenCorrection, - blueCorrection); - - return GrDistanceFieldLCDTextGeoProc::Make(color, - viewMatrix, - texture, - params, - widthAdjust, - flags, - this->usesLocalCoords()); + GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make( + redCorrection, greenCorrection, blueCorrection); + + return GrDistanceFieldLCDTextGeoProc::Make( + color, viewMatrix, texture, params, widthAdjust, flags, this->usesLocalCoords()); } else { #ifdef SK_GAMMA_APPLY_TO_A8 U8CPU lum = SkColorSpaceLuminance::computeLuminance(SK_GAMMA_EXPONENT, filteredColor); - float correction = fDistanceAdjustTable->getAdjustment( - lum >> kDistanceAdjustLumShift, fUseGammaCorrectDistanceTable); - return GrDistanceFieldA8TextGeoProc::Make(color, - viewMatrix, - texture, - params, - correction, - flags, - this->usesLocalCoords()); + float correction = fDistanceAdjustTable->getAdjustment(lum >> kDistanceAdjustLumShift, + fUseGammaCorrectDistanceTable); + return GrDistanceFieldA8TextGeoProc::Make( + color, viewMatrix, texture, params, correction, flags, this->usesLocalCoords()); #else - return GrDistanceFieldA8TextGeoProc::Make(color, - viewMatrix, - texture, - params, - flags, - this->usesLocalCoords()); + return GrDistanceFieldA8TextGeoProc::Make( + color, viewMatrix, texture, params, flags, this->usesLocalCoords()); #endif } - } -void GrBlobRegenHelper::flush() { - fBatch->flush(fTarget, fFlushInfo); -} +void GrBlobRegenHelper::flush() { fOp->flush(fTarget, fFlushInfo); } |