simplify setColor, without needing the 4f or the colorspace
Change-Id: I7f6fe83cfb653819c1b5d865421f4fd2121e9b4d Reviewed-on: https://skia-review.googlesource.com/c/skia/+/212418 Reviewed-by: Kevin Lubick <kjlubick@google.com> 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:
parent
af9b7b9f09
commit
dc2b98fd29
@ -256,7 +256,11 @@ public:
|
||||
@param color unpremultiplied RGBA
|
||||
@param colorSpace SkColorSpace describing the encoding of color
|
||||
*/
|
||||
void setColor4f(const SkColor4f& color, SkColorSpace* colorSpace);
|
||||
void setColor(const SkColor4f& color, SkColorSpace* colorSpace = nullptr);
|
||||
|
||||
void setColor4f(const SkColor4f& color, SkColorSpace* colorSpace = nullptr) {
|
||||
this->setColor(color, colorSpace);
|
||||
}
|
||||
|
||||
/** Retrieves alpha from the color used when stroking and filling.
|
||||
|
||||
|
@ -961,7 +961,13 @@ EMSCRIPTEN_BINDINGS(Skia) {
|
||||
.function("getStrokeWidth", &SkPaint::getStrokeWidth)
|
||||
.function("setAntiAlias", &SkPaint::setAntiAlias)
|
||||
.function("setBlendMode", &SkPaint::setBlendMode)
|
||||
.function("setColor", &SkPaint::setColor)
|
||||
.function("setColor", optional_override([](SkPaint& self, SkColor c) {
|
||||
self.setColor(c);
|
||||
}))
|
||||
.function("setColorf", optional_override([](SkPaint& self,
|
||||
float r, float g, float b, float a) {
|
||||
self.setColor({r, g, b, a});
|
||||
}))
|
||||
.function("setFilterQuality", &SkPaint::setFilterQuality)
|
||||
.function("setMaskFilter", &SkPaint::setMaskFilter)
|
||||
.function("setPathEffect", &SkPaint::setPathEffect)
|
||||
|
@ -57,7 +57,7 @@ SkPaint::SkPaint()
|
||||
}
|
||||
|
||||
SkPaint::SkPaint(const SkColor4f& color, SkColorSpace* colorSpace) : SkPaint() {
|
||||
this->setColor4f(color, colorSpace);
|
||||
this->setColor(color, colorSpace);
|
||||
}
|
||||
|
||||
SkPaint::SkPaint(const SkPaint& src) = default;
|
||||
@ -115,7 +115,7 @@ void SkPaint::setColor(SkColor color) {
|
||||
fColor4f = SkColor4f::FromColor(color);
|
||||
}
|
||||
|
||||
void SkPaint::setColor4f(const SkColor4f& color, SkColorSpace* colorSpace) {
|
||||
void SkPaint::setColor(const SkColor4f& color, SkColorSpace* colorSpace) {
|
||||
SkASSERT(fColor4f.fA >= 0 && fColor4f.fA <= 1.0f);
|
||||
|
||||
SkColorSpaceXformSteps steps{colorSpace, kUnpremul_SkAlphaType,
|
||||
@ -362,7 +362,7 @@ SkReadPaintResult SkPaintPriv::Unflatten_PreV68(SkPaint* paint, SkReadBuffer& bu
|
||||
} else {
|
||||
SkColor4f color;
|
||||
buffer.readColor4f(&color);
|
||||
paint->setColor4f(color, sk_srgb_singleton());
|
||||
paint->setColor(color, sk_srgb_singleton());
|
||||
}
|
||||
|
||||
unsigned flatFlags = unpack_paint_flags(paint, buffer.readUInt(), font);
|
||||
@ -417,7 +417,7 @@ SkReadPaintResult SkPaintPriv::Unflatten(SkPaint* paint, SkReadBuffer& buffer, S
|
||||
{
|
||||
SkColor4f color;
|
||||
buffer.readColor4f(&color);
|
||||
paint->setColor4f(color, sk_srgb_singleton());
|
||||
paint->setColor(color, sk_srgb_singleton());
|
||||
}
|
||||
|
||||
unsigned flatFlags = unpack_v68(paint, buffer.readUInt(), safe);
|
||||
|
Loading…
Reference in New Issue
Block a user