[canvaskit] Make SkCanvas.drawColor/clear take SkColor4f
CanvasKit converts 4 floats to an int, just to have it be converted back into 4 floats when it goes into the paint. Change-Id: I93cf1c596283b83cc9452fb205b7000ceed09bb9 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/293538 Commit-Queue: Kevin Lubick <kjlubick@google.com> Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
parent
3fdc49f357
commit
2362022e7c
@ -24,6 +24,8 @@ Milestone 85
|
||||
|
||||
* Move SkBitmapRegionDecoder into client_utils/android.
|
||||
|
||||
* SkCanvas.clear and SkCanvas.drawColor now accept SkColor4f in addition to SkColor.
|
||||
|
||||
* Remove SkSurface::MakeFromBackendTextureAsRenderTarget.
|
||||
This factory existed to work around issues with GL_TEXTURE_RECTANGLE that existed
|
||||
in Chrome's command buffer. Those issues have since been resolved. Use
|
||||
|
@ -1133,7 +1133,17 @@ public:
|
||||
|
||||
example: https://fiddle.skia.org/c/@Canvas_drawColor
|
||||
*/
|
||||
void drawColor(SkColor color, SkBlendMode mode = SkBlendMode::kSrcOver);
|
||||
void drawColor(SkColor color, SkBlendMode mode = SkBlendMode::kSrcOver) {
|
||||
this->drawColor(SkColor4f::FromColor(color), mode);
|
||||
}
|
||||
|
||||
/** Fills clip with color color.
|
||||
mode determines how ARGB is combined with destination.
|
||||
|
||||
@param color SkColor4f representing unpremultiplied color.
|
||||
@param mode SkBlendMode used to combine source color and destination
|
||||
*/
|
||||
void drawColor(const SkColor4f& color, SkBlendMode mode = SkBlendMode::kSrcOver);
|
||||
|
||||
/** Fills clip with color color using SkBlendMode::kSrc.
|
||||
This has the effect of replacing all pixels contained by clip with color.
|
||||
@ -1141,6 +1151,15 @@ public:
|
||||
@param color unpremultiplied ARGB
|
||||
*/
|
||||
void clear(SkColor color) {
|
||||
this->clear(SkColor4f::FromColor(color));
|
||||
}
|
||||
|
||||
/** Fills clip with color color using SkBlendMode::kSrc.
|
||||
This has the effect of replacing all pixels contained by clip with color.
|
||||
|
||||
@param color SkColor4f representing unpremultiplied color.
|
||||
*/
|
||||
void clear(const SkColor4f& color) {
|
||||
this->drawColor(color, SkBlendMode::kSrc);
|
||||
}
|
||||
|
||||
|
@ -883,7 +883,7 @@ EMSCRIPTEN_BINDINGS(Skia) {
|
||||
class_<SkCanvas>("SkCanvas")
|
||||
.constructor<>()
|
||||
.function("_clear", optional_override([](SkCanvas& self, uintptr_t /* float* */ cPtr) {
|
||||
self.clear(ptrToSkColor4f(cPtr).toSkColor());
|
||||
self.clear(ptrToSkColor4f(cPtr));
|
||||
}))
|
||||
.function("clipPath", select_overload<void (const SkPath&, SkClipOp, bool)>(&SkCanvas::clipPath))
|
||||
.function("clipRRect", optional_override([](SkCanvas& self, const SimpleRRect& r, SkClipOp op, bool doAntiAlias) {
|
||||
@ -916,10 +916,10 @@ EMSCRIPTEN_BINDINGS(Skia) {
|
||||
}), allow_raw_pointers())
|
||||
.function("drawCircle", select_overload<void (SkScalar, SkScalar, SkScalar, const SkPaint& paint)>(&SkCanvas::drawCircle))
|
||||
.function("_drawColor", optional_override([](SkCanvas& self, uintptr_t /* float* */ cPtr) {
|
||||
self.drawColor(ptrToSkColor4f(cPtr).toSkColor());
|
||||
self.drawColor(ptrToSkColor4f(cPtr));
|
||||
}))
|
||||
.function("_drawColor", optional_override([](SkCanvas& self, uintptr_t /* float* */ cPtr, SkBlendMode mode) {
|
||||
self.drawColor(ptrToSkColor4f(cPtr).toSkColor(), mode);
|
||||
self.drawColor(ptrToSkColor4f(cPtr), mode);
|
||||
}))
|
||||
.function("drawColorInt", optional_override([](SkCanvas& self, int32_t color) {
|
||||
self.drawColor(color);
|
||||
|
@ -2835,7 +2835,7 @@ void SkCanvas::onDrawEdgeAAImageSet(const ImageSetEntry imageSet[], int count,
|
||||
// methods, rather than actually drawing themselves.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SkCanvas::drawColor(SkColor c, SkBlendMode mode) {
|
||||
void SkCanvas::drawColor(const SkColor4f& c, SkBlendMode mode) {
|
||||
SkPaint paint;
|
||||
paint.setColor(c);
|
||||
paint.setBlendMode(mode);
|
||||
|
Loading…
Reference in New Issue
Block a user