Bug 227895 - [Cairo] Don't pass the current GraphicsContext state to CairoOperations
Summary: [Cairo] Don't pass the current GraphicsContext state to CairoOperations
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Fujii Hironori
URL:
Keywords: InRadar
Depends on:
Blocks: 227780
  Show dependency treegraph
 
Reported: 2021-07-12 21:51 PDT by Fujii Hironori
Modified: 2021-07-26 04:39 PDT (History)
8 users (show)

See Also:


Attachments
Patch (41.08 KB, patch)
2021-07-12 21:56 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (59.62 KB, patch)
2021-07-25 23:31 PDT, Fujii Hironori
Hironori.Fujii: review?
ews-feeder: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fujii Hironori 2021-07-12 21:51:49 PDT
[Cairo] Don't pass the current GraphicsContext state to CairoOperations

r279658 (Bug 227721) changed CairoOperations to take a
GraphicsContextCairo as the first argument. No longer need to
pass the current state.
Comment 1 Fujii Hironori 2021-07-12 21:56:04 PDT
Created attachment 433386 [details]
Patch
Comment 2 Zan Dobersek 2021-07-12 23:28:58 PDT
Comment on attachment 433386 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=433386&action=review

> Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp:672
> -    auto& state = this->state();
> -    append(createCommand<DrawEllipse>(rect, state.fillColor, state.strokeStyle, state.strokeColor, state.strokeThickness));
> +    append(createCommand<DrawEllipse>(rect));

How does the replay context get hold of all the relevant state that's not included in the PaintingOperation structs anymore but is then used in Cairo::drawEllipse() or other similar functions?
Comment 3 Fujii Hironori 2021-07-12 23:44:34 PDT
Comment on attachment 433386 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=433386&action=review

>> Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp:672
>> +    append(createCommand<DrawEllipse>(rect));
> 
> How does the replay context get hold of all the relevant state that's not included in the PaintingOperation structs anymore but is then used in Cairo::drawEllipse() or other similar functions?

Good point. CairoOperationRecorder::updateState should call GraphicsContextCairo::updateState. Will fix. Thank you.
Comment 4 Said Abou-Hallawa 2021-07-13 14:23:19 PDT
I have a question.

Why can't we merge CairoOperations.cpp in GraphicsContextCairo.cpp? What is the point of having functions like these:

void drawRect(GraphicsContextCairo& platformContext, const FloatRect& rect, ...)
{
    cairo_t* cr = platformContext.cr();
    cairo_save(cr);

    fillRectWithColor(cr, rect, fillColor);

    ...

    cairo_restore(cr);
}

void GraphicsContextCairo::drawRect(const FloatRect& rect, float borderThickness)
{
    ASSERT(!rect.isEmpty());
    auto& state = this->state();
    Cairo::drawRect(*this, rect, borderThickness, state.fillColor, state.strokeStyle, state.strokeColor);
}

Why do not we move the code inside Cairo::drawRect() to GraphicsContextCairo::drawRect especially Cairo::drawRect() takes an argument of type GraphicsContextCairo?
Comment 5 Fujii Hironori 2021-07-13 14:45:35 PDT
(In reply to Said Abou-Hallawa from comment #4)

That's exactly what I want to do.
Bug 227780 – [Cairo] All functions in CairoOperations.cpp should be GraphicsContextCairo's methods

However, I found out that this is not simple as what I thought.
CairoOperationRecorder is a thread-safe display list that transfers drawing commands to worker threads.
However, WebCore::Pattern isn't a thread-safe object. So CairoOperationRecorder append a command by converting the object to cairo object.
Comment 6 Radar WebKit Bug Importer 2021-07-19 21:52:16 PDT
<rdar://problem/80818847>
Comment 7 Fujii Hironori 2021-07-25 23:31:04 PDT
Created attachment 434192 [details]
Patch