Make setBlender the real name

Change-Id: Ifd590a3653760c5d3967c0b1bcf00d0be1a7658f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/424396
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2021-07-06 11:29:45 -04:00 committed by Skia Commit-Bot
parent ad77b4db8d
commit 3037d9f322
3 changed files with 31 additions and 16 deletions

View File

@ -479,6 +479,7 @@ public:
void setColorFilter(sk_sp<SkColorFilter> colorFilter);
/** DEPRECATED
* Use asBlendMode() instead.
*
* This attempts to inspect the current blender, and if it claims to be equivalent to
* one of the predefiend SkBlendMode enums, returns that mode. If the blender does not,
@ -486,10 +487,16 @@ public:
*/
SkBlendMode getBlendMode() const;
/** If the current blender can be represented as a SkBlendMode enum, this returns that
* enum in the optional's value(). If it cannot, then the returned optional does not
* contain a value.
*/
skstd::optional<SkBlendMode> asBlendMode() const;
/** Returns true iff the current blender claims to be equivalent to SkBlendMode::kSrcOver.
*/
*
* Also returns true of the current blender is nullptr.
*/
bool isSrcOver() const;
/** Helper method for calling setBlender().
@ -499,23 +506,32 @@ public:
void setBlendMode(SkBlendMode mode);
/** Returns the user-supplied blend function, if one has been set.
Does not alter SkBlender's SkRefCnt.
@return the SkBlender assigned to this paint, otherwise nullptr
*/
* Does not alter SkBlender's SkRefCnt.
*
* A nullptr blender signifies the default SrcOver behavior.
*
* @return the SkBlender assigned to this paint, otherwise nullptr
*/
SkBlender* getBlender() const { return fBlender.get(); }
/** Returns the user-supplied blend function, if one has been set.
Increments the SkBlender's SkRefCnt by one.
@return the SkBlender assigned to this paint, otherwise nullptr
*/
* Increments the SkBlender's SkRefCnt by one.
*
* A nullptr blender signifies the default SrcOver behavior.
*
* @return the SkBlender assigned to this paint, otherwise nullptr
*/
sk_sp<SkBlender> refBlender() const;
/** Sets the current blender, increasing its refcnt, and if a blender is already
* present, decreasing that object's refcnt.
*
* A nullptr blender signifies the default SrcOver behavior.
*
* For convenience, you can call setBlendMode() if the blend effect can be expressed
* as one of those values.
*/
void experimental_setBlender(sk_sp<SkBlender> blend);
void setBlender(sk_sp<SkBlender> blender);
/** Returns SkPathEffect if set, or nullptr.
Does not alter SkPathEffect SkRefCnt.

View File

@ -168,12 +168,11 @@ bool SkPaint::isSrcOver() const {
}
void SkPaint::setBlendMode(SkBlendMode mode) {
this->experimental_setBlender(mode == SkBlendMode::kSrcOver ? nullptr
: SkBlender::Mode(mode));
this->setBlender(mode == SkBlendMode::kSrcOver ? nullptr : SkBlender::Mode(mode));
}
void SkPaint::experimental_setBlender(sk_sp<SkBlender> blend) {
fBlender = std::move(blend);
void SkPaint::setBlender(sk_sp<SkBlender> blender) {
fBlender = std::move(blender);
}
void SkPaint::setStrokeWidth(SkScalar width) {
@ -369,7 +368,7 @@ SkReadPaintResult SkPaintPriv::Unflatten(SkPaint* paint, SkReadBuffer& buffer, S
paint->setMaskFilter(buffer.readMaskFilter());
paint->setColorFilter(buffer.readColorFilter());
paint->setImageFilter(buffer.readImageFilter());
paint->experimental_setBlender(buffer.readBlender());
paint->setBlender(buffer.readBlender());
}
if (!buffer.validate(safe)) {

View File

@ -415,7 +415,7 @@ public:
SkCanvas* canvas = fSurface->getCanvas();
SkPaint paint;
paint.experimental_setBlender(std::move(blender));
paint.setBlender(std::move(blender));
paint.setColor(SK_ColorGRAY);
paint_canvas(canvas, &paint, preTestCallback);