[webkit-changes] [WebKit/WebKit] bcffee: [Skia] Implement inset shadows

Georges Basile Stavracas Neto noreply at github.com
Wed Feb 21 05:19:02 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: bcffee080ac979d3b38875f008acdd39798ac7a4
      https://github.com/WebKit/WebKit/commit/bcffee080ac979d3b38875f008acdd39798ac7a4
  Author: Georges Basile Stavracas Neto <feaneron at igalia.com>
  Date:   2024-02-21 (Wed, 21 Feb 2024)

  Changed paths:
    M Source/WebCore/platform/graphics/skia/FontCascadeSkia.cpp
    M Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
    M Source/WebCore/platform/graphics/skia/GraphicsContextSkia.h

  Log Message:
  -----------
  [Skia] Implement inset shadows
https://bugs.webkit.org/show_bug.cgi?id=269714

Reviewed by Carlos Garcia Campos.

Move the drop shadow filter creation into a helper method, and refactor
all callers of GraphicsContextSkia::createFillPaint() to manually create
and apply a drop shadow. The helper method returns nullptr if there is
no shadow, or if the shadow is effectively hidden, following Cairo's
optimization.

Add a selector enum for inset and outset shadows, used by the helper
method aforementioned, and handle the case for both inset and outset
shadows. The outset shadow case is just what was there before.

The inset shadow case is a combination of two image filters. One creates
a black shadow with the drop shadow parameters, and uses it as a mask to
apply a color blend. The color blend is what uses the actual drop shadow
color, and blends it with the SrcIn mode, which effectively inverts the
drop shadow based on the pixel opacity.

The only place in code that interprets GraphicsContext.dropShadow() as
an inset shadow is inside GraphicsContext::fillRectWithRoundedHole(),
which is implemented in this commit using SkCanvas::drawDRRect().

* Source/WebCore/platform/graphics/skia/FontCascadeSkia.cpp:
(WebCore::FontCascade::drawGlyphs):
* Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp:
(WebCore::GraphicsContextSkia::drawNativeImageInternal):
(WebCore::GraphicsContextSkia::fillPath):
(WebCore::GraphicsContextSkia::createDropShadowFilter const):
(WebCore::GraphicsContextSkia::createFillPaint const):
(WebCore::GraphicsContextSkia::fillRect):
(WebCore::GraphicsContextSkia::fillRoundedRectImpl):
(WebCore::GraphicsContextSkia::fillRectWithRoundedHole):
* Source/WebCore/platform/graphics/skia/GraphicsContextSkia.h:

Canonical link: https://commits.webkit.org/275093@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list