Skip to content

Commit

Permalink
Reverted shadow changes
Browse files Browse the repository at this point in the history
  • Loading branch information
djowel committed Mar 13, 2024
1 parent 51c68f9 commit 5b9a7a7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/host/macos/skia_app.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 1 addition & 2 deletions lib/impl/macos/quartz2d/canvas.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/impl/skia/canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5b9a7a7

Please sign in to comment.