Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,10 @@ void ScrollerCoordinated::updateValues()

canvas->clear(SK_ColorTRANSPARENT);

Damage damage(state.frameRect);
GraphicsContextSkia context(*canvas, RenderingMode::Accelerated, RenderingPurpose::DOM);
context.scale(contentsScale);
scrollerImp->paint(context, state.frameRect, state);
scrollerImp->paint(context, state.frameRect, state, damage);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work? paint expects a pointer

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This calls ScrollerImpAdwaita::paint rather than AdwaitaScrollbarPainter::paint.


grContext->flushAndSubmit(surface.get(), GLFence::isSupported(display.glDisplay()) ? GrSyncCpu::kNo : GrSyncCpu::kYes);
auto buffer = CoordinatedPlatformLayerBufferRGB::create(WTF::move(texture), { TextureMapperFlags::ShouldBlend }, GLFence::create(display.glDisplay()));
Expand All @@ -162,7 +163,7 @@ void ScrollerCoordinated::updateValues()
Locker layerLocker { hostLayer->lock() };
hostLayer->setContentsRect(state.frameRect);
hostLayer->setContentsClippingRect(FloatRoundedRect(state.frameRect));
hostLayer->setContentsBuffer(WTF::move(buffer));
hostLayer->setContentsBuffer(WTF::move(buffer), WTF::move(damage));
}

void ScrollerCoordinated::setHoveredAndPressedParts(ScrollbarPart hoveredPart, ScrollbarPart pressedPart)
Expand Down
18 changes: 17 additions & 1 deletion Source/WebCore/platform/adwaita/AdwaitaScrollbarPainter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@

#if USE(THEME_ADWAITA)

#include "Damage.h"
#include "GraphicsContext.h"

namespace WebCore::AdwaitaScrollbarPainter {

void paint(GraphicsContext& graphicsContext, const IntRect& damageRect, const State& scrollbar)
void paint(GraphicsContext& graphicsContext, const IntRect& damageRect, const State& scrollbar, Damage* damageOut)
{
if (graphicsContext.paintingDisabled())
return;
Expand Down Expand Up @@ -109,6 +110,11 @@ void paint(GraphicsContext& graphicsContext, const IntRect& damageRect, const St
} else
frame.setHeight(scrollbarBorderSize);
graphicsContext.fillRect(frame, scrollbarBorderColor);

if (damageOut && opacity) {
frame.intersect(damageRect);
damageOut->add(frame);
}
} else if (scrollbar.hoveredPart != NoPart) {
int thumbCornerSize = thumbSize / 2;
FloatSize corner(thumbCornerSize, thumbCornerSize);
Expand Down Expand Up @@ -143,6 +149,11 @@ void paint(GraphicsContext& graphicsContext, const IntRect& damageRect, const St
graphicsContext.setFillRule(WindRule::EvenOdd);
graphicsContext.setFillColor(overlayTroughBorderColor);
graphicsContext.fillPath(path);

if (damageOut && opacity) {
troughBorder.intersect(damageRect);
damageOut->add(troughBorder);
}
}

int thumbCornerSize;
Expand Down Expand Up @@ -206,6 +217,11 @@ void paint(GraphicsContext& graphicsContext, const IntRect& damageRect, const St
graphicsContext.setFillRule(WindRule::EvenOdd);
graphicsContext.setFillColor(overlayThumbBorderColor);
graphicsContext.fillPath(path);

if (damageOut && opacity) {
thumbBorder.intersect(damageRect);
damageOut->add(thumbBorder);
}
}

if (opacity != 1)
Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/platform/adwaita/AdwaitaScrollbarPainter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

namespace WebCore {

class Damage;
class GraphicsContext;

namespace AdwaitaScrollbarPainter {
Expand Down Expand Up @@ -76,7 +77,7 @@ struct State {
std::optional<ScrollbarColor> scrollbarColor;
};

void paint(GraphicsContext&, const IntRect&, const State&);
void paint(GraphicsContext&, const IntRect&, const State&, Damage* damageOut = nullptr);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to use std::optional instead of a pointer?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::optional<Damage>& ? this is a raw reference. There is no big difference between raw reference and raw pointer. But, a raw pointer can be nullptr.


} // namespace AdwaitaScrollbarPainter
} // namespace WebCore
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/platform/adwaita/ScrollerImpAdwaita.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ namespace WebCore {

class ScrollerImpAdwaita : public ThreadSafeRefCounted<ScrollerImpAdwaita> {
public:
void paint(GraphicsContext& graphicsContext, const IntRect& damageRect, const AdwaitaScrollbarPainter::State& state)
void paint(GraphicsContext& graphicsContext, const IntRect& damageRect, const AdwaitaScrollbarPainter::State& state, Damage& damageOut)
{
AdwaitaScrollbarPainter::paint(graphicsContext, damageRect, state);
AdwaitaScrollbarPainter::paint(graphicsContext, damageRect, state, &damageOut);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I missed this, here is where we pass the pointer.

}
};

Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/platform/graphics/Damage.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#pragma once

#if USE(COORDINATED_GRAPHICS)
#if USE(COORDINATED_GRAPHICS) || USE(THEME_ADWAITA)
#include "FloatRect.h"
#include "LayoutSize.h"
#include "Region.h"
Expand Down Expand Up @@ -558,4 +558,4 @@ static inline WTF::TextStream& operator<<(WTF::TextStream& ts, const Damage& dam

} // namespace WebCore

#endif // USE(COORDINATED_GRAPHICS)
#endif // USE(COORDINATED_GRAPHICS) || USE(THEME_ADWAITA)