Cleanup yes/no enums in Ganesh

Yes/no enums should have a base type of bool, and kYes should always
be true. Also, there is no need for a "GrEnumToBool()" function, as we
can just use the enum itself directly: e.g. "GrAA(bool)".

Bug: skia:
Change-Id: I7bb3c2983f717f3467fca4ce6b32920d71026894
Reviewed-on: https://skia-review.googlesource.com/74860
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Chris Dalton 2017-11-27 14:33:06 -07:00 committed by Skia Commit-Bot
parent 4b9506bc3c
commit 3b51df1211
10 changed files with 57 additions and 63 deletions

View File

@ -208,27 +208,21 @@ typedef intptr_t GrBackendContext;
/**
* Used to control antialiasing in draw calls.
*/
enum class GrAA {
kYes,
kNo
enum class GrAA : bool {
kNo = false,
kYes = true
};
static inline GrAA GrBoolToAA(bool aa) { return aa ? GrAA::kYes : GrAA::kNo; }
///////////////////////////////////////////////////////////////////////////////
/**
* Used to say whether a texture has mip levels allocated or not.
*/
enum class GrMipMapped {
kYes,
kNo
enum class GrMipMapped : bool {
kNo = false,
kYes = true
};
static inline GrMipMapped GrBoolToMipMapped(bool mipMapped) {
return mipMapped ? GrMipMapped::kYes : GrMipMapped::kNo;
}
///////////////////////////////////////////////////////////////////////////////
/**
@ -484,9 +478,9 @@ static const uint32_t kAll_GrBackendState = 0xffffffff;
// Enum used as return value when flush with semaphores so the client knows whether the
// semaphores were submitted to GPU or not.
enum class GrSemaphoresSubmitted : int {
kNo,
kYes,
enum class GrSemaphoresSubmitted : bool {
kNo = false,
kYes = true
};
#endif

View File

@ -85,7 +85,7 @@ enum class GrFSAAType {
* Not all drawing code paths support using mixed samples when available and instead use
* coverage-based aa.
*/
enum class GrAllowMixedSamples { kNo, kYes };
enum class GrAllowMixedSamples : bool { kNo = false, kYes = true };
GrAAType GrChooseAAType(GrAA, GrFSAAType, GrAllowMixedSamples, const GrCaps&);
@ -94,8 +94,8 @@ GrAAType GrChooseAAType(GrAA, GrFSAAType, GrAllowMixedSamples, const GrCaps&);
* range. This is important for blending - the latter category may require manual clamping.
*/
enum class GrPixelConfigIsClamped : bool {
kNo, // F16 or F32
kYes, // Any UNORM type
kNo = false, // F16 or F32
kYes = true, // Any UNORM type
};
/**

View File

@ -19,7 +19,7 @@ GrBackendTexture::GrBackendTexture(int width,
: fWidth(width)
, fHeight(height)
, fConfig(GrVkFormatToPixelConfig(vkInfo.fFormat))
, fMipMapped(GrBoolToMipMapped(vkInfo.fLevelCount > 1))
, fMipMapped(GrMipMapped(vkInfo.fLevelCount > 1))
, fBackend(kVulkan_GrBackend)
, fVkInfo(vkInfo) {}
#endif

View File

@ -296,7 +296,7 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
&grPaint)) {
return;
}
GrAA aa = GrBoolToAA(paint.isAntiAlias());
GrAA aa = GrAA(paint.isAntiAlias());
SkMaskFilter* mf = paint.getMaskFilter();
if (mf && !mf->asFragmentProcessor(nullptr)) {
// The MaskFilter wasn't already handled in SkPaintToGrPaint

View File

@ -53,7 +53,7 @@ bool GrClipStackClip::isRRect(const SkRect& origRTBounds, SkRRect* rr, GrAA* aa)
const SkRect* rtBounds = &origRTBounds;
bool isAA;
if (fStack->isRRect(*rtBounds, rr, &isAA)) {
*aa = GrBoolToAA(isAA);
*aa = GrAA(isAA);
return true;
}
return false;
@ -121,7 +121,7 @@ bool GrClipStackClip::PathNeedsSWRenderer(GrContext* context,
canDrawArgs.fClipConservativeBounds = &scissorRect;
canDrawArgs.fViewMatrix = &viewMatrix;
canDrawArgs.fShape = &shape;
canDrawArgs.fAAType = GrChooseAAType(GrBoolToAA(element->isAA()),
canDrawArgs.fAAType = GrChooseAAType(GrAA(element->isAA()),
renderTargetContext->fsaaType(),
GrAllowMixedSamples::kYes,
*context->caps());
@ -383,7 +383,7 @@ static void draw_clip_elements_to_mask_helper(GrSWMaskHelper& helper, const Elem
for (ElementList::Iter iter(elements); iter.get(); iter.next()) {
const Element* element = iter.get();
SkClipOp op = element->getOp();
GrAA aa = GrBoolToAA(element->isAA());
GrAA aa = GrAA(element->isAA());
if (kIntersect_SkClipOp == op || kReverseDifference_SkClipOp == op) {
// Intersect and reverse difference require modifying pixels outside of the geometry

View File

@ -108,7 +108,7 @@ GrReducedClip::GrReducedClip(const SkClipStack& stack, const SkRect& queryBounds
}
if (SK_InvalidGenID != fAAClipRectGenID && // Is there an AA clip rect?
ClipResult::kNotClipped == this->addAnalyticFP(fAAClipRect, Invert::kNo, true)) {
ClipResult::kNotClipped == this->addAnalyticFP(fAAClipRect, Invert::kNo, GrAA::kYes)) {
if (fMaskElements.isEmpty()) {
// Use a replace since it is faster than intersect.
fMaskElements.addToHead(fAAClipRect, SkMatrix::I(), kReplace_SkClipOp, true /*doAA*/);
@ -485,10 +485,11 @@ GrReducedClip::ClipResult GrReducedClip::clipInsideElement(const Element* elemen
case Element::DeviceSpaceType::kRRect:
return this->addAnalyticFP(element->getDeviceSpaceRRect(), Invert::kNo,
element->isAA());
GrAA(element->isAA()));
case Element::DeviceSpaceType::kPath:
return this->addAnalyticFP(element->getDeviceSpacePath(), Invert::kNo, element->isAA());
return this->addAnalyticFP(element->getDeviceSpacePath(), Invert::kNo,
GrAA(element->isAA()));
}
SK_ABORT("Unexpected DeviceSpaceType");
@ -510,11 +511,12 @@ GrReducedClip::ClipResult GrReducedClip::clipOutsideElement(const Element* eleme
}
}
return this->addAnalyticFP(element->getDeviceSpaceRect(), Invert::kYes,
element->isAA());
GrAA(element->isAA()));
case Element::DeviceSpaceType::kRRect: {
const SkRRect& clipRRect = element->getDeviceSpaceRRect();
ClipResult clipResult = this->addAnalyticFP(clipRRect, Invert::kYes, element->isAA());
ClipResult clipResult = this->addAnalyticFP(clipRRect, Invert::kYes,
GrAA(element->isAA()));
if (fWindowRects.count() >= fMaxWindowRectangles) {
return clipResult;
}
@ -552,7 +554,7 @@ GrReducedClip::ClipResult GrReducedClip::clipOutsideElement(const Element* eleme
case Element::DeviceSpaceType::kPath:
return this->addAnalyticFP(element->getDeviceSpacePath(), Invert::kYes,
element->isAA());
GrAA(element->isAA()));
}
SK_ABORT("Unexpected DeviceSpaceType");
@ -573,16 +575,17 @@ inline void GrReducedClip::addWindowRectangle(const SkRect& elementInteriorRect,
template<typename T>
inline GrReducedClip::ClipResult GrReducedClip::addAnalyticFP(const T& deviceSpaceShape,
Invert invert, bool aa) {
Invert invert, GrAA aa) {
if (fAnalyticFPs.count() >= fMaxAnalyticFPs) {
return ClipResult::kNotClipped;
}
GrClipEdgeType edgeType;
if (Invert::kNo == invert) {
edgeType = aa ? GrClipEdgeType::kFillAA : GrClipEdgeType::kFillBW;
edgeType = (GrAA::kYes == aa) ? GrClipEdgeType::kFillAA : GrClipEdgeType::kFillBW;
} else {
edgeType = aa ? GrClipEdgeType::kInverseFillAA : GrClipEdgeType::kInverseFillBW;
edgeType = (GrAA::kYes == aa) ? GrClipEdgeType::kInverseFillAA
: GrClipEdgeType::kInverseFillBW;
}
if (auto fp = make_analytic_clip_fp(edgeType, deviceSpaceShape)) {
@ -624,7 +627,7 @@ static bool stencil_element(GrRenderTargetContext* rtc,
const GrUserStencilSettings* ss,
const SkMatrix& viewMatrix,
const SkClipStack::Element* element) {
GrAA aa = GrBoolToAA(element->isAA());
GrAA aa = GrAA(element->isAA());
switch (element->getDeviceSpaceType()) {
case SkClipStack::Element::DeviceSpaceType::kEmpty:
SkDEBUGFAIL("Should never get here with an empty element.");
@ -700,7 +703,7 @@ bool GrReducedClip::drawAlphaClipMask(GrRenderTargetContext* rtc) const {
for (ElementList::Iter iter(fMaskElements); iter.get(); iter.next()) {
const Element* element = iter.get();
SkRegion::Op op = (SkRegion::Op)element->getOp();
GrAA aa = GrBoolToAA(element->isAA());
GrAA aa = GrAA(element->isAA());
bool invert = element->isInverseFilled();
if (invert || SkRegion::kIntersect_Op == op || SkRegion::kReverseDifference_Op == op) {
// draw directly into the result with the stencil set to make the pixels affected

View File

@ -109,11 +109,11 @@ private:
void addWindowRectangle(const SkRect& elementInteriorRect, bool elementIsAA);
enum class Invert : bool {
kNo,
kYes
kNo = false,
kYes = true
};
template<typename T> ClipResult addAnalyticFP(const T& deviceSpaceShape, Invert, bool aa);
template<typename T> ClipResult addAnalyticFP(const T& deviceSpaceShape, Invert, GrAA);
void makeEmpty();

View File

@ -307,8 +307,8 @@ void SkGpuDevice::drawPoints(SkCanvas::PointMode mode,
path.setIsVolatile(true);
path.moveTo(pts[0]);
path.lineTo(pts[1]);
fRenderTargetContext->drawPath(this->clip(), std::move(grPaint),
GrBoolToAA(paint.isAntiAlias()), this->ctm(), path, style);
fRenderTargetContext->drawPath(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
this->ctm(), path, style);
return;
}
@ -380,8 +380,8 @@ void SkGpuDevice::drawRect(const SkRect& rect, const SkPaint& paint) {
}
GrStyle style(paint);
fRenderTargetContext->drawRect(this->clip(), std::move(grPaint),
GrBoolToAA(paint.isAntiAlias()), this->ctm(), rect, &style);
fRenderTargetContext->drawRect(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
this->ctm(), rect, &style);
}
///////////////////////////////////////////////////////////////////////////////
@ -434,8 +434,8 @@ void SkGpuDevice::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
SkASSERT(!style.pathEffect());
fRenderTargetContext->drawRRect(this->clip(), std::move(grPaint),
GrBoolToAA(paint.isAntiAlias()), this->ctm(), rrect, style);
fRenderTargetContext->drawRRect(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
this->ctm(), rrect, style);
}
@ -461,8 +461,7 @@ void SkGpuDevice::drawDRRect(const SkRRect& outer,
}
fRenderTargetContext->drawDRRect(this->clip(), std::move(grPaint),
GrBoolToAA(paint.isAntiAlias()), this->ctm(), outer,
inner);
GrAA(paint.isAntiAlias()), this->ctm(), outer, inner);
return;
}
@ -493,9 +492,8 @@ void SkGpuDevice::drawRegion(const SkRegion& region, const SkPaint& paint) {
return;
}
fRenderTargetContext->drawRegion(this->clip(), std::move(grPaint),
GrBoolToAA(paint.isAntiAlias()), this->ctm(), region,
GrStyle(paint));
fRenderTargetContext->drawRegion(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
this->ctm(), region, GrStyle(paint));
}
void SkGpuDevice::drawOval(const SkRect& oval, const SkPaint& paint) {
@ -522,9 +520,8 @@ void SkGpuDevice::drawOval(const SkRect& oval, const SkPaint& paint) {
return;
}
fRenderTargetContext->drawOval(this->clip(), std::move(grPaint),
GrBoolToAA(paint.isAntiAlias()), this->ctm(), oval,
GrStyle(paint));
fRenderTargetContext->drawOval(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
this->ctm(), oval, GrStyle(paint));
}
void SkGpuDevice::drawArc(const SkRect& oval, SkScalar startAngle,
@ -541,7 +538,7 @@ void SkGpuDevice::drawArc(const SkRect& oval, SkScalar startAngle,
return;
}
fRenderTargetContext->drawArc(this->clip(), std::move(grPaint), GrBoolToAA(paint.isAntiAlias()),
fRenderTargetContext->drawArc(this->clip(), std::move(grPaint), GrAA(paint.isAntiAlias()),
this->ctm(), oval, startAngle, sweepAngle, useCenter,
GrStyle(paint));
}
@ -598,7 +595,7 @@ void SkGpuDevice::drawStrokedLine(const SkPoint points[2],
}
fRenderTargetContext->fillRectWithLocalMatrix(
this->clip(), std::move(grPaint), GrBoolToAA(newPaint.isAntiAlias()), m, rect, local);
this->clip(), std::move(grPaint), GrAA(newPaint.isAntiAlias()), m, rect, local);
}
void SkGpuDevice::drawPath(const SkPath& origSrcPath,
@ -1033,8 +1030,8 @@ void SkGpuDevice::drawBitmapTile(const SkBitmap& bitmap,
}
// Coverage-based AA would cause seams between tiles.
GrAA aa = GrBoolToAA(paint.isAntiAlias() &&
GrFSAAType::kNone != fRenderTargetContext->fsaaType());
GrAA aa = GrAA(paint.isAntiAlias() &&
GrFSAAType::kNone != fRenderTargetContext->fsaaType());
fRenderTargetContext->drawRect(this->clip(), std::move(grPaint), aa, viewMatrix, dstRect);
}
@ -1108,7 +1105,7 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special1, int left, int top, const
fRenderTargetContext->fillRectToRect(
this->clip(),
std::move(grPaint),
GrBoolToAA(paint.isAntiAlias()),
GrAA(paint.isAntiAlias()),
SkMatrix::I(),
SkRect::Make(SkIRect::MakeXYWH(left + offset.fX, top + offset.fY, subset.width(),
subset.height())),

View File

@ -297,7 +297,7 @@ void SkGpuDevice::drawTextureProducerImpl(GrTextureProducer* producer,
&grPaint)) {
return;
}
GrAA aa = GrBoolToAA(paint.isAntiAlias());
GrAA aa = GrAA(paint.isAntiAlias());
if (canUseTextureCoordsAsLocalCoords) {
fRenderTargetContext->fillRectToRect(this->clip(), std::move(grPaint), aa, viewMatrix,
clippedDstRect, clippedSrcRect);

View File

@ -164,17 +164,17 @@ protected:
* purpose of ensuring that the fragment shader runs on partially covered pixels for
* non-MSAA antialiasing.
*/
enum class HasAABloat {
kYes,
kNo
enum class HasAABloat : bool {
kNo = false,
kYes = true
};
/**
* Indicates that the geometry represented by the op has zero area (e.g. it is hairline or
* points).
*/
enum class IsZeroArea {
kYes,
kNo
enum class IsZeroArea : bool {
kNo = false,
kYes = true
};
void setBounds(const SkRect& newBounds, HasAABloat aabloat, IsZeroArea zeroArea) {