From 5b9a7a77b6a097b58050876b3b0ea82f7c40d63f Mon Sep 17 00:00:00 2001 From: djowel Date: Wed, 13 Mar 2024 13:07:05 +0800 Subject: [PATCH] Reverted shadow changes --- examples/host/macos/skia_app.mm | 2 +- lib/impl/macos/quartz2d/canvas.mm | 3 +-- lib/impl/skia/canvas.cpp | 4 +++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/host/macos/skia_app.mm b/examples/host/macos/skia_app.mm index e2625df9..22d3bf0c 100755 --- a/examples/host/macos/skia_app.mm +++ b/examples/host/macos/skia_app.mm @@ -127,8 +127,8 @@ - (void) drawRect : (NSRect) dirty { SkCanvas* gpu_canvas = surface->getCanvas(); gpu_canvas->save(); + gpu_canvas->scale(_scale, _scale); auto cnv = canvas{gpu_canvas}; - cnv.pre_scale(_scale); draw(cnv); diff --git a/lib/impl/macos/quartz2d/canvas.mm b/lib/impl/macos/quartz2d/canvas.mm index 625d7018..926a8133 100755 --- a/lib/impl/macos/quartz2d/canvas.mm +++ b/lib/impl/macos/quartz2d/canvas.mm @@ -607,9 +607,8 @@ void round_rect(canvas& c, rect bounds, float radius) void canvas::shadow_style(point offset, float blur, color c) { - auto [scx, scy] = device_to_user({1.0, 1.0}); CGContextSetShadowWithColor( - CGContextRef(_context), CGSizeMake(offset.x/scx, -offset.y/scx), blur, + CGContextRef(_context), CGSizeMake(offset.x, -offset.y), blur, [ [NSColor colorWithRed : c.red diff --git a/lib/impl/skia/canvas.cpp b/lib/impl/skia/canvas.cpp index 9394cb3a..72507d96 100755 --- a/lib/impl/skia/canvas.cpp +++ b/lib/impl/skia/canvas.cpp @@ -403,7 +403,9 @@ namespace cycfi::artist void canvas::shadow_style(point offset, float blur, color c) { constexpr auto blur_factor = 1.0f; - auto [scx, scy] = device_to_user({1.0, 1.0}); + auto matrix = _context->getTotalMatrix(); + float scx = matrix.getScaleX(); + float scy = matrix.getScaleY(); auto shadow = SkImageFilters::DropShadow( offset.x / scx