Skip to content

Commit

Permalink
Enable antialiasing by default in native Skia DOM (#1131)
Browse files Browse the repository at this point in the history
Co-authored-by: William Candillon <[email protected]>
  • Loading branch information
wcandillon and william-candillon authored Nov 21, 2022
1 parent 608747f commit 47a5701
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion package/cpp/rnskia/RNSkDomView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ void RNSkDomRenderer::renderCanvas(SkCanvas *canvas, float scaledWidth,
canvas->scale(pd, pd);

if (_drawingContext == nullptr) {
auto paint = std::make_shared<SkPaint>();
paint->setAntiAlias(true);
_drawingContext =
std::make_shared<DrawingContext>(std::make_shared<SkPaint>(), 1.0f);
std::make_shared<DrawingContext>(paint, 1.0f);

_drawingContext->setRequestRedraw([weakSelf = weak_from_this()]() {
auto self = weakSelf.lock();
Expand Down
4 changes: 3 additions & 1 deletion package/cpp/rnskia/dom/nodes/JsiPaintNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class JsiPaintNode : public JsiBaseDomDeclarationNode,
// ...and it should be a totally new paint, not inheriting from parent
// paint.
if (_localContext->isChanged()) {
_localContext->setMutablePaint(std::make_shared<SkPaint>());
auto paint = std::make_shared<SkPaint>();
paint->setAntiAlias(true);
_localContext->setMutablePaint(paint);
}

// Let's decorate paint props
Expand Down
1 change: 1 addition & 0 deletions package/cpp/rnskia/dom/props/BoxShadowProps.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class BoxShadowProps : public DerivedProp<SkPaint> {
SkScalar blur = _blurProp->value().getAsNumber();

auto paint = SkPaint();
paint.setAntiAlias(true);
paint.setColor(color);
auto filter = SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, blur, true);
paint.setMaskFilter(filter);
Expand Down

0 comments on commit 47a5701

Please sign in to comment.