Update GrAtlasTextOp::MaskType to enum class

Change-Id: I16a5938f5156fac2e93b8cd0b2a8e2ed45b46386
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/330938
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
Michael Ludwig 2020-11-03 11:04:16 -05:00 committed by Skia Commit-Bot
parent b2c42140ea
commit 136d878002
3 changed files with 48 additions and 50 deletions

View File

@ -118,26 +118,30 @@ GrProcessorSet::Analysis GrAtlasTextOp::finalize(
GrClampType clampType) {
GrProcessorAnalysisCoverage coverage;
GrProcessorAnalysisColor color;
if (kColorBitmapMask_MaskType == fMaskType) {
if (fMaskType == MaskType::kColorBitmap) {
color.setToUnknown();
} else {
// finalize() is called before any merging is done, so at this point there's at most one
// Geometry with a color. Later, for non-bitmap ops, we may have mixed colors.
color.setToConstant(this->color());
}
switch (fMaskType) {
case kGrayscaleCoverageMask_MaskType:
case kAliasedDistanceField_MaskType:
case kGrayscaleDistanceField_MaskType:
case MaskType::kGrayscaleCoverage:
case MaskType::kAliasedDistanceField:
case MaskType::kGrayscaleDistanceField:
coverage = GrProcessorAnalysisCoverage::kSingleChannel;
break;
case kLCDCoverageMask_MaskType:
case kLCDDistanceField_MaskType:
case kLCDBGRDistanceField_MaskType:
case MaskType::kLCDCoverage:
case MaskType::kLCDDistanceField:
case MaskType::kLCDBGRDistanceField:
coverage = GrProcessorAnalysisCoverage::kLCD;
break;
case kColorBitmapMask_MaskType:
case MaskType::kColorBitmap:
coverage = GrProcessorAnalysisCoverage::kNone;
break;
}
auto analysis = fProcessors.finalize(
color, coverage, clip, &GrUserStencilSettings::kUnused, hasMixedSampledCoverage, caps,
clampType, &fGeoData[0].fColor);
@ -367,7 +371,7 @@ GrOp::CombineResult GrAtlasTextOp::onCombineIfPossible(GrOp* t, SkArenaAlloc*, c
return CombineResult::kCannotCombine;
}
} else {
if (kColorBitmapMask_MaskType == fMaskType && this->color() != that->color()) {
if (fMaskType == MaskType::kColorBitmap && this->color() != that->color()) {
return CombineResult::kCannotCombine;
}
}
@ -437,7 +441,7 @@ GrGeometryProcessor* GrAtlasTextOp::setupDfProcessor(SkArenaAlloc* arena,
} else {
#ifdef SK_GAMMA_APPLY_TO_A8
float correction = 0;
if (kAliasedDistanceField_MaskType != fMaskType) {
if (fMaskType != MaskType::kAliasedDistanceField) {
U8CPU lum = SkColorSpaceLuminance::computeLuminance(SK_GAMMA_EXPONENT,
fLuminanceColor);
correction = dfAdjustTable->getAdjustment(lum >> kDistanceAdjustLumShift,
@ -528,5 +532,3 @@ GR_DRAW_OP_TEST_DEFINE(GrAtlasTextOp) {
}
#endif

View File

@ -48,18 +48,16 @@ public:
GrProcessorSet::Analysis finalize(const GrCaps&, const GrAppliedClip*,
bool hasMixedSampledCoverage, GrClampType) override;
enum MaskType {
kGrayscaleCoverageMask_MaskType,
kLCDCoverageMask_MaskType,
kColorBitmapMask_MaskType,
kAliasedDistanceField_MaskType,
kGrayscaleDistanceField_MaskType,
kLCDDistanceField_MaskType,
kLCDBGRDistanceField_MaskType,
enum class MaskType : uint32_t {
kGrayscaleCoverage,
kLCDCoverage,
kColorBitmap,
kAliasedDistanceField,
kGrayscaleDistanceField,
kLCDDistanceField,
kLCDBGRDistanceField
};
MaskType maskType() const { return fMaskType; }
#if GR_TEST_UTILS
static GrOp::Owner CreateOpTestingOnly(GrRenderTargetContext* rtc,
const SkPaint& skPaint,
@ -136,31 +134,32 @@ private:
GrMaskFormat maskFormat() const {
switch (fMaskType) {
case kLCDCoverageMask_MaskType:
case MaskType::kLCDCoverage:
return kA565_GrMaskFormat;
case kColorBitmapMask_MaskType:
case MaskType::kColorBitmap:
return kARGB_GrMaskFormat;
case kGrayscaleCoverageMask_MaskType:
case kAliasedDistanceField_MaskType:
case kGrayscaleDistanceField_MaskType:
case kLCDDistanceField_MaskType:
case kLCDBGRDistanceField_MaskType:
case MaskType::kGrayscaleCoverage:
case MaskType::kAliasedDistanceField:
case MaskType::kGrayscaleDistanceField:
case MaskType::kLCDDistanceField:
case MaskType::kLCDBGRDistanceField:
return kA8_GrMaskFormat;
}
return kA8_GrMaskFormat; // suppress warning
// SkUNREACHABLE;
return kA8_GrMaskFormat;
}
bool usesDistanceFields() const {
return kAliasedDistanceField_MaskType == fMaskType ||
kGrayscaleDistanceField_MaskType == fMaskType ||
kLCDDistanceField_MaskType == fMaskType ||
kLCDBGRDistanceField_MaskType == fMaskType;
return MaskType::kAliasedDistanceField == fMaskType ||
MaskType::kGrayscaleDistanceField == fMaskType ||
MaskType::kLCDDistanceField == fMaskType ||
MaskType::kLCDBGRDistanceField == fMaskType;
}
bool isLCD() const {
return kLCDCoverageMask_MaskType == fMaskType ||
kLCDDistanceField_MaskType == fMaskType ||
kLCDBGRDistanceField_MaskType == fMaskType;
return MaskType::kLCDCoverage == fMaskType ||
MaskType::kLCDDistanceField == fMaskType ||
MaskType::kLCDBGRDistanceField == fMaskType;
}
inline void createDrawForGeneratedGlyphs(

View File

@ -67,12 +67,11 @@ struct ARGB3DVertex {
GrAtlasTextOp::MaskType op_mask_type(GrMaskFormat grMaskFormat) {
switch (grMaskFormat) {
case kA8_GrMaskFormat: return GrAtlasTextOp::kGrayscaleCoverageMask_MaskType;
case kA565_GrMaskFormat: return GrAtlasTextOp::kLCDCoverageMask_MaskType;
case kARGB_GrMaskFormat: return GrAtlasTextOp::kColorBitmapMask_MaskType;
// Needed to placate some compilers.
default: return GrAtlasTextOp::kGrayscaleCoverageMask_MaskType;
case kA8_GrMaskFormat: return GrAtlasTextOp::MaskType::kGrayscaleCoverage;
case kA565_GrMaskFormat: return GrAtlasTextOp::MaskType::kLCDCoverage;
case kARGB_GrMaskFormat: return GrAtlasTextOp::MaskType::kColorBitmap;
}
SkUNREACHABLE;
}
SkPMColor4f calculate_colors(GrRenderTargetContext* rtc,
@ -926,23 +925,21 @@ GrSDFTSubRun::makeAtlasTextOp(const GrClip* clip,
bool isBGR = SkPixelGeometryIsBGR(props.pixelGeometry());
bool isLCD = fUseLCDText && SkPixelGeometryIsH(props.pixelGeometry());
using MT = GrAtlasTextOp::MaskType;
MT maskType = !fAntiAliased ? MT::kAliasedDistanceField_MaskType
: isLCD ? (isBGR ? MT::kLCDBGRDistanceField_MaskType
: MT::kLCDDistanceField_MaskType)
: MT::kGrayscaleDistanceField_MaskType;
MT maskType = !fAntiAliased ? MT::kAliasedDistanceField
: isLCD ? (isBGR ? MT::kLCDBGRDistanceField
: MT::kLCDDistanceField)
: MT::kGrayscaleDistanceField;
bool useGammaCorrectDistanceTable = colorInfo.isLinearlyBlended();
uint32_t DFGPFlags = drawMatrix.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0;
DFGPFlags |= drawMatrix.isScaleTranslate() ? kScaleOnly_DistanceFieldEffectFlag : 0;
DFGPFlags |= drawMatrix.hasPerspective() ? kPerspective_DistanceFieldEffectFlag : 0;
DFGPFlags |= useGammaCorrectDistanceTable ? kGammaCorrect_DistanceFieldEffectFlag : 0;
DFGPFlags |= MT::kAliasedDistanceField_MaskType == maskType ?
kAliased_DistanceFieldEffectFlag : 0;
DFGPFlags |= MT::kAliasedDistanceField == maskType ? kAliased_DistanceFieldEffectFlag : 0;
if (isLCD) {
DFGPFlags |= kUseLCD_DistanceFieldEffectFlag;
DFGPFlags |= MT::kLCDBGRDistanceField_MaskType == maskType ?
kBGR_DistanceFieldEffectFlag : 0;
DFGPFlags |= MT::kLCDBGRDistanceField == maskType ? kBGR_DistanceFieldEffectFlag : 0;
}
GrAtlasTextOp::Geometry geometry = {