Use value_or in getBlendMode_or.

Support for `value_or` was recently added to skstd::optional. (Thanks
herb@!)

Change-Id: Ie343f8d06f8a26bcd111af8334757c203944b052
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/427036
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
John Stiles 2021-07-12 12:06:23 -04:00 committed by Skia Commit-Bot
parent 586d61dd7a
commit 526b0b92c9
2 changed files with 2 additions and 4 deletions

View File

@ -485,7 +485,7 @@ public:
skstd::optional<SkBlendMode> asBlendMode() const; skstd::optional<SkBlendMode> asBlendMode() const;
/** /**
* Queries the blender, and if it can be represented as a SkBendMode, return that mode, * Queries the blender, and if it can be represented as a SkBlendMode, return that mode,
* else return the defaultMode provided. * else return the defaultMode provided.
*/ */
SkBlendMode getBlendMode_or(SkBlendMode defaultMode) const; SkBlendMode getBlendMode_or(SkBlendMode defaultMode) const;

View File

@ -152,9 +152,7 @@ skstd::optional<SkBlendMode> SkPaint::asBlendMode() const {
} }
SkBlendMode SkPaint::getBlendMode_or(SkBlendMode defaultMode) const { SkBlendMode SkPaint::getBlendMode_or(SkBlendMode defaultMode) const {
// todo: add value_or() to skstd::optional? return this->asBlendMode().value_or(defaultMode);
const auto bm = this->asBlendMode();
return bm ? bm.value() : defaultMode;
} }
bool SkPaint::isSrcOver() const { bool SkPaint::isSrcOver() const {