Source/WebCore/ChangeLog

 12020-11-04 Said Abou-Hallawa <said@apple.com>
 2
 3 [GPU Process] Draw a debugging border and badge for the 2D canvas if it's drawn through GPU process
 4 https://bugs.webkit.org/show_bug.cgi?id=217166
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 GraphicsContextExtras.cpp is introduced to be the place where other complex
 9 graphical commands can be added later.
 10
 11 Use drawDebugBadges() to draw the badges in drawRepaintIndicator(). The
 12 new function allows more flexibility since it can draw four badges one in
 13 each corner or the border rectangle.
 14
 15 * Headers.cmake:
 16 * Sources.txt:
 17 * WebCore.xcodeproj/project.pbxproj:
 18 * platform/graphics/GraphicsContextExtras.cpp: Added.
 19 (WebCore::drawDebugBadgesInternal):
 20 (WebCore::drawDebugBadges):
 21 (WebCore::drawDebugBorderAndBadges):
 22 * platform/graphics/GraphicsContextExtras.h: Added.
 23 * platform/graphics/ca/PlatformCALayer.cpp:
 24 (WebCore::PlatformCALayer::drawRepaintIndicator):
 25
1262020-11-04 Simon Fraser <simon.fraser@apple.com>
227
328 A programmatic scroll should stop any rubberbanding

Source/WebKit/ChangeLog

 12020-11-04 Said Abou-Hallawa <said@apple.com>
 2
 3 [GPU Process] Draw a debugging border and badge for the 2D canvas if it's drawn through GPU process
 4 https://bugs.webkit.org/show_bug.cgi?id=217166
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * GPUProcess/graphics/RemoteRenderingBackend.cpp:
 9 (WebKit::RemoteRenderingBackend::drawDebugBadge):
 10 (WebKit::RemoteRenderingBackend::applyResourceItem):
 11 (WebKit::RemoteRenderingBackend::flushDisplayList):
 12 (WebKit::RemoteRenderingBackend::flushDisplayListAndCommit):
 13 * GPUProcess/graphics/RemoteRenderingBackend.h:
 14 Draw a debugging badge for the canvas when it is drawn as an image into
 15 another canvas in GPUP.
 16
 17 * GPUProcess/graphics/RemoteRenderingBackend.messages.in:
 18 Pass the 'showDebugBorders' from WebPorcess to GPUP.
 19
 20 * WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
 21 * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
 22 (WebKit::RemoteRenderingBackendProxy::create):
 23 (WebKit::RemoteRenderingBackendProxy::RemoteRenderingBackendProxy):
 24 RemoteRenderingBackendProxy can read the page settings through the WebPage.
 25
 26 (WebKit::RemoteRenderingBackendProxy::showDebugBorders const):
 27 (WebKit::RemoteRenderingBackendProxy::drawDebugBorderAndBadge):
 28 (WebKit::RemoteRenderingBackendProxy::flushDisplayList):
 29 (WebKit::RemoteRenderingBackendProxy::flushDisplayListAndCommit):
 30 Draw a debugging badge for the canvas when it is drawn in GPUP.
 31
 32 * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h:
 33 * WebProcess/WebCoreSupport/WebChromeClient.cpp:
 34 (WebKit::WebChromeClient::ensureRemoteRenderingBackendProxy const):
 35 WebPage will pass itself to RemoteRenderingBackendProxy when it is created.
 36
1372020-11-04 Luming Yin <luming_yin@apple.com>
238
339 [watchOS] Don't allow managed preference to enable legacy sync XHRs on watchOS

Source/WebCore/Headers.cmake

@@set(WebCore_PRIVATE_FRAMEWORK_HEADERS
11681168 platform/graphics/GlyphPage.h
11691169 platform/graphics/Gradient.h
11701170 platform/graphics/GraphicsContext.h
 1171 platform/graphics/GraphicsContextExtras.h
11711172 platform/graphics/GraphicsContextGL.h
11721173 platform/graphics/GraphicsContextGLAttributes.h
11731174 platform/graphics/GraphicsContextImpl.h

Source/WebCore/Sources.txt

@@platform/graphics/GeometryUtilities.cpp
19141914platform/graphics/Gradient.cpp
19151915platform/graphics/GradientImage.cpp
19161916platform/graphics/GraphicsContext.cpp
 1917platform/graphics/GraphicsContextExtras.cpp
19171918platform/graphics/GraphicsContextGL.cpp
19181919platform/graphics/GraphicsContextGLImageExtractor.cpp
19191920platform/graphics/GraphicsContextImpl.cpp

Source/WebCore/WebCore.xcodeproj/project.pbxproj

21652165 7299BC6823D6A53E00CC6883 /* RenderingMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 7299BC6623D686C600CC6883 /* RenderingMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
21662166 729D05302531424300422098 /* RenderingResourceIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 729D052E25313E2600422098 /* RenderingResourceIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
21672167 72A73BEF245A3F90001C9D03 /* AnimationFrameRate.h in Headers */ = {isa = PBXBuildFile; fileRef = 722A815C238FD50500C00583 /* AnimationFrameRate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 2168 72ABE7172553AD390012CF37 /* GraphicsContextExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 72ABE713255333530012CF37 /* GraphicsContextExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
21682169 72BAC3AE23E1F0B0008D741C /* ImageBufferBackend.h in Headers */ = {isa = PBXBuildFile; fileRef = 72BAC3A523E17328008D741C /* ImageBufferBackend.h */; settings = {ATTRIBUTES = (Private, ); }; };
21692170 7553CFE8108F473F00EA281E /* TimelineRecordFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 7553CFE6108F473F00EA281E /* TimelineRecordFactory.h */; };
21702171 75793E840D0CE0B3007FC0AC /* MessageEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 75793E810D0CE0B3007FC0AC /* MessageEvent.h */; };

99689969 7299BC6423D686A600CC6883 /* AlphaPremultiplication.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AlphaPremultiplication.h; sourceTree = "<group>"; };
99699970 7299BC6623D686C600CC6883 /* RenderingMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderingMode.h; sourceTree = "<group>"; };
99709971 729D052E25313E2600422098 /* RenderingResourceIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderingResourceIdentifier.h; sourceTree = "<group>"; };
 9972 72ABE712255333530012CF37 /* GraphicsContextExtras.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContextExtras.cpp; sourceTree = "<group>"; };
 9973 72ABE713255333530012CF37 /* GraphicsContextExtras.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GraphicsContextExtras.h; sourceTree = "<group>"; };
99719974 72BAC3A423E17327008D741C /* ImageBufferBackend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageBufferBackend.cpp; sourceTree = "<group>"; };
99729975 72BAC3A523E17328008D741C /* ImageBufferBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageBufferBackend.h; sourceTree = "<group>"; };
99739976 72BAC3A623E17328008D741C /* PlatformImageBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformImageBuffer.h; sourceTree = "<group>"; };

2632226325 2D2FC0571460CD6F00263633 /* GradientImage.h */,
2632326326 B2A015920AF6CD53006BCE0E /* GraphicsContext.cpp */,
2632426327 B2A015930AF6CD53006BCE0E /* GraphicsContext.h */,
 26328 72ABE712255333530012CF37 /* GraphicsContextExtras.cpp */,
 26329 72ABE713255333530012CF37 /* GraphicsContextExtras.h */,
2632526330 313DE86D23A96966008FC47B /* GraphicsContextGL.cpp */,
2632626331 313DE86F23A96967008FC47B /* GraphicsContextGL.h */,
2632726332 7C330A011DF8FAC600D3395C /* GraphicsContextGLAttributes.h */,

3187231877 2D481F04146B5C6B00AA7834 /* GradientImage.h in Headers */,
3187331878 B2A015A90AF6CD53006BCE0E /* GraphicsContext.h in Headers */,
3187431879 934907E4125BBBC8007F23A0 /* GraphicsContextCG.h in Headers */,
 31880 72ABE7172553AD390012CF37 /* GraphicsContextExtras.h in Headers */,
3187531881 313DE87023A96973008FC47B /* GraphicsContextGL.h in Headers */,
3187631882 7BB34A1725345CB200029D08 /* GraphicsContextGLANGLEUtilities.h in Headers */,
3187731883 7C330A021DF8FAC600D3395C /* GraphicsContextGLAttributes.h in Headers */,

Source/WebCore/platform/graphics/GraphicsContextExtras.cpp

 1/*
 2 * Copyright (C) 2020 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "GraphicsContextExtras.h"
 28
 29#include "Color.h"
 30#include "FloatRect.h"
 31#include "FontCascade.h"
 32#include "GraphicsContext.h"
 33#include "TextRun.h"
 34#include <wtf/text/WTFString.h>
 35
 36namespace WebCore {
 37
 38static inline void drawDebugBadgesInternal(GraphicsContext& context, const FloatRect& borderRect, const Vector<DebugBadge>& badges)
 39{
 40 auto cornerPoint = [](const FloatRect& borderRect, DebugBadge::Corner corner) {
 41 auto point = borderRect.location();
 42 if (corner == DebugBadge::Corner::TopRight || corner == DebugBadge::Corner::BottomRight)
 43 point.move(borderRect.width(), 0);
 44 if (corner == DebugBadge::Corner::BottomLeft || corner == DebugBadge::Corner::BottomRight)
 45 point.move(0, borderRect.height());
 46 return point;
 47 };
 48
 49 auto cornerRect = [&](const FloatRect& borderRect, DebugBadge::Corner corner, const FloatSize size) {
 50 auto point = cornerPoint(borderRect, corner);
 51 if (corner == DebugBadge::Corner::TopRight || corner == DebugBadge::Corner::BottomRight)
 52 point.move(-size.width(), 0);
 53 if (corner == DebugBadge::Corner::BottomLeft || corner == DebugBadge::Corner::BottomRight)
 54 point.move(0, -size.height());
 55 return FloatRect(point, size);
 56 };
 57
 58 auto drawDebugBadge = [&](GraphicsContext& context, const FloatRect& borderRect, const DebugBadge& badge) {
 59 FontCascadeDescription fontDescription;
 60 fontDescription.setOneFamily("Helvetica");
 61 fontDescription.setSpecifiedSize(badge.fontSize);
 62 fontDescription.setComputedSize(badge.fontSize);
 63
 64 FontCascade cascade(WTFMove(fontDescription));
 65 cascade.update(nullptr);
 66
 67 const float horizontalMargin = badge.fontSize / 4;
 68 const float verticalMargin = horizontalMargin / 2;
 69
 70 TextRun textRun(badge.text);
 71 float textWidth = cascade.width(textRun);
 72
 73 FloatSize badgeSize(horizontalMargin * 2 + textWidth, verticalMargin * 2 + badge.fontSize);
 74
 75 auto badgeRect = cornerRect(borderRect, badge.corner, badgeSize);
 76
 77 context.setFillColor(badge.color);
 78 context.fillRect(badgeRect);
 79
 80 context.setFillColor(badge.textColor);
 81 context.drawText(cascade, textRun, FloatPoint(badgeRect.x() + horizontalMargin, badgeRect.y() + badge.fontSize));
 82 };
 83
 84 for (auto badge : badges)
 85 drawDebugBadge(context, borderRect, badge);
 86}
 87
 88void drawDebugBadges(GraphicsContext& context, const FloatRect& borderRect, const Vector<DebugBadge>& badges)
 89{
 90 GraphicsContextStateSaver stateSaver(context);
 91 FloatRect borderRectAdjusted = borderRect;
 92 borderRectAdjusted.inflate(-1);
 93 drawDebugBadgesInternal(context, borderRectAdjusted, badges);
 94}
 95
 96void drawDebugBorderAndBadges(GraphicsContext& context, const FloatRect& borderRect, const Color& color, const Vector<DebugBadge>& badges)
 97{
 98 GraphicsContextStateSaver stateSaver(context);
 99
 100 FloatRect borderRectAdjusted = borderRect;
 101 borderRectAdjusted.inflate(-1);
 102
 103 context.setStrokeColor(color);
 104 context.setShouldAntialias(false);
 105 context.strokeRect(borderRectAdjusted, 0.5);
 106
 107 drawDebugBadgesInternal(context, borderRectAdjusted, badges);
 108}
 109
 110} // namespace WebCore

Source/WebCore/platform/graphics/GraphicsContextExtras.h

 1/*
 2 * Copyright (C) 2020 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#include "Color.h"
 29#include <wtf/Vector.h>
 30#include <wtf/text/WTFString.h>
 31
 32namespace WebCore {
 33
 34class GraphicsContext;
 35class FloatRect;
 36
 37struct DebugBadge {
 38 enum class Corner {
 39 TopLeft,
 40 TopRight,
 41 BottomLeft,
 42 BottomRight,
 43 };
 44 Corner corner;
 45 Color color;
 46 Color textColor;
 47 unsigned fontSize;
 48 String text;
 49};
 50
 51WEBCORE_EXPORT void drawDebugBadges(GraphicsContext&, const FloatRect& borderRect, const Vector<DebugBadge>&);
 52WEBCORE_EXPORT void drawDebugBorderAndBadges(GraphicsContext&, const FloatRect& borderRect, const Color&, const Vector<DebugBadge>&);
 53
 54} // namespace WebCore

Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp

2929#if USE(CA)
3030
3131#include "GraphicsContextCG.h"
 32#include "GraphicsContextExtras.h"
3233#include "LayerPool.h"
3334#include "PlatformCALayerClient.h"
3435#include <CoreFoundation/CoreFoundation.h>

@@bool PlatformCALayer::canHaveBackingStore() const
8182
8283void PlatformCALayer::drawRepaintIndicator(GraphicsContext& graphicsContext, PlatformCALayer* platformCALayer, int repaintCount, Color customBackgroundColor)
8384{
84  const float verticalMargin = 2.5;
85  const float horizontalMargin = 5;
86  const unsigned fontSize = 22;
 85 const unsigned largeFontSize = 22;
 86 const unsigned smallFontSize = 10;
8787 constexpr auto backgroundColor = SRGBA<uint8_t> { 128, 64, 255 };
88  constexpr auto acceleratedContextLabelColor = Color::red;
89  constexpr auto unacceleratedContextLabelColor = Color::white;
90  constexpr auto linearGlyphMaskOutlineColor = Color::black.colorWithAlphaByte(192);
91  constexpr auto displayListBorderColor = Color::black.colorWithAlphaByte(166);
92 
93  TextRun textRun(String::number(repaintCount));
94 
95  FontCascadeDescription fontDescription;
96  fontDescription.setOneFamily("Helvetica");
97  fontDescription.setSpecifiedSize(fontSize);
98  fontDescription.setComputedSize(fontSize);
99 
100  FontCascade cascade(WTFMove(fontDescription));
101  cascade.update(nullptr);
102 
103  float textWidth = cascade.width(textRun);
104 
105  GraphicsContextStateSaver stateSaver(graphicsContext);
106 
107  graphicsContext.beginTransparencyLayer(0.5f);
108 
109  graphicsContext.setFillColor(customBackgroundColor.isValid() ? customBackgroundColor : backgroundColor);
110  FloatRect indicatorBox(1, 1, horizontalMargin * 2 + textWidth, verticalMargin * 2 + fontSize);
111  if (platformCALayer->isOpaque())
112  graphicsContext.fillRect(indicatorBox);
113  else {
114  Path boundsPath;
115  boundsPath.moveTo(indicatorBox.maxXMinYCorner());
116  boundsPath.addLineTo(indicatorBox.maxXMaxYCorner());
117  boundsPath.addLineTo(indicatorBox.minXMaxYCorner());
118 
119  const float cornerChunk = 8;
120  boundsPath.addLineTo(FloatPoint(indicatorBox.x(), indicatorBox.y() + cornerChunk));
121  boundsPath.addLineTo(FloatPoint(indicatorBox.x() + cornerChunk, indicatorBox.y()));
122  boundsPath.closeSubpath();
123 
124  graphicsContext.fillPath(boundsPath);
125  }
 88 constexpr auto acceleratedTextColor = Color::red;
 89 constexpr auto unacceleratedTextColor = Color::white;
 90
 91 Vector<DebugBadge> badges = { {
 92 DebugBadge::Corner::TopLeft,
 93 customBackgroundColor.isValid() ? customBackgroundColor : backgroundColor,
 94 platformCALayer->acceleratesDrawing() ? acceleratedTextColor : unacceleratedTextColor,
 95 largeFontSize,
 96 String::number(repaintCount)
 97 } };
12698
12799 if (platformCALayer->owner()->isUsingDisplayListDrawing(platformCALayer)) {
128  graphicsContext.setStrokeColor(displayListBorderColor);
129  graphicsContext.strokeRect(indicatorBox, 2);
 100 badges.append({
 101 DebugBadge::Corner::BottomLeft,
 102 Color::blue,
 103 platformCALayer->acceleratesDrawing() ? acceleratedTextColor : unacceleratedTextColor,
 104 largeFontSize,
 105 "DL"_s
 106 });
130107 }
131108
132  if (!platformCALayer->isOpaque() && platformCALayer->supportsSubpixelAntialiasedText() && platformCALayer->acceleratesDrawing()) {
133  graphicsContext.setStrokeColor(linearGlyphMaskOutlineColor);
134  graphicsContext.setStrokeThickness(4.5);
135  graphicsContext.setTextDrawingMode(TextDrawingModeFlags { TextDrawingMode::Fill, TextDrawingMode::Stroke });
 109 if (!platformCALayer->isOpaque() && platformCALayer->supportsSubpixelAntialiasedText()) {
 110 badges.append({
 111 DebugBadge::Corner::BottomRight,
 112 Color::green,
 113 platformCALayer->acceleratesDrawing() ? acceleratedTextColor : unacceleratedTextColor,
 114 smallFontSize,
 115 "sub-pixel"_s
 116 });
136117 }
137118
138  graphicsContext.setFillColor(platformCALayer->acceleratesDrawing() ? acceleratedContextLabelColor : unacceleratedContextLabelColor);
139 
140  graphicsContext.drawText(cascade, textRun, FloatPoint(indicatorBox.x() + horizontalMargin, indicatorBox.y() + fontSize));
 119 graphicsContext.beginTransparencyLayer(0.5f);
 120 drawDebugBadges(graphicsContext, platformCALayer->bounds(), badges);
141121 graphicsContext.endTransparencyLayer();
142122}
143123

Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp

3232#include "PlatformRemoteImageBuffer.h"
3333#include "RemoteRenderingBackendMessages.h"
3434#include "RemoteRenderingBackendProxyMessages.h"
 35#include <WebCore/GraphicsContextExtras.h>
 36#include <wtf/SetForScope.h>
3537
3638namespace WebKit {
3739using namespace WebCore;

@@uint64_t RemoteRenderingBackend::messageSenderDestinationID() const
7274 return m_renderingBackendIdentifier.toUInt64();
7375}
7476
 77void RemoteRenderingBackend::drawDebugBadge(GraphicsContext& context, const FloatRect& borderRect, const String& text)
 78{
 79 if (!m_showDebugBorders)
 80 return;
 81
 82 const unsigned fontSize = 10;
 83 constexpr auto backgroundColor = Color::blue;
 84 constexpr auto textColor = Color::white;
 85
 86 DebugBadge badge = { DebugBadge::Corner::BottomRight, backgroundColor, textColor, fontSize, text };
 87 drawDebugBadges(context, borderRect, { badge });
 88}
 89
7590bool RemoteRenderingBackend::applyResourceItem(const DisplayList::Item& item, GraphicsContext& context)
7691{
7792 if (item.type() == DisplayList::ItemType::DrawImageBuffer) {

@@bool RemoteRenderingBackend::applyResourceItem(const DisplayList::Item& item, Gr
8196 return false;
8297
8398 imageBuffer->draw(context, drawItem.destinationRect(), drawItem.source(), drawItem.options());
 99 drawDebugBadge(context, drawItem.destinationRect(), "CANVAS"_s);
84100 return true;
85101 }
86102

@@void RemoteRenderingBackend::createImageBuffer(const FloatSize& logicalSize, Ren
140156 ASSERT_NOT_REACHED();
141157}
142158
143 void RemoteRenderingBackend::flushDisplayList(const DisplayList::DisplayList& displayList, RenderingResourceIdentifier renderingResourceIdentifier)
 159void RemoteRenderingBackend::flushDisplayList(const DisplayList::DisplayList& displayList, bool showDebugBorders, RenderingResourceIdentifier renderingResourceIdentifier)
144160{
 161 SetForScope<bool> change(m_showDebugBorders, showDebugBorders);
145162 if (auto imageBuffer = m_remoteResourceCache.cachedImageBuffer(renderingResourceIdentifier))
146163 imageBuffer->flushDisplayList(displayList);
147164}
148165
149 void RemoteRenderingBackend::flushDisplayListAndCommit(const DisplayList::DisplayList& displayList, DisplayListFlushIdentifier flushIdentifier, RenderingResourceIdentifier renderingResourceIdentifier)
 166void RemoteRenderingBackend::flushDisplayListAndCommit(const DisplayList::DisplayList& displayList, bool showDebugBorders, DisplayListFlushIdentifier flushIdentifier, RenderingResourceIdentifier renderingResourceIdentifier)
150167{
 168 SetForScope<bool> change(m_showDebugBorders, showDebugBorders);
151169 if (auto imageBuffer = m_remoteResourceCache.cachedImageBuffer(renderingResourceIdentifier)) {
152170 imageBuffer->flushDisplayList(displayList);
153171 imageBuffer->flushContext();

Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h

@@public:
6363 GPUConnectionToWebProcess* gpuConnectionToWebProcess() const;
6464
6565 // Rendering operations.
 66 void drawDebugBadge(WebCore::GraphicsContext&, const WebCore::FloatRect& borderRect, const String& text);
6667 bool applyResourceItem(const WebCore::DisplayList::Item&, WebCore::GraphicsContext&);
6768 bool applyMediaItem(const WebCore::DisplayList::Item&, WebCore::GraphicsContext&);
6869

@@private:
8384
8485 // Messages to be received.
8586 void createImageBuffer(const WebCore::FloatSize& logicalSize, WebCore::RenderingMode, float resolutionScale, WebCore::ColorSpace, WebCore::RenderingResourceIdentifier);
86  void flushDisplayList(const WebCore::DisplayList::DisplayList&, WebCore::RenderingResourceIdentifier);
87  void flushDisplayListAndCommit(const WebCore::DisplayList::DisplayList&, DisplayListFlushIdentifier, WebCore::RenderingResourceIdentifier);
 87 void flushDisplayList(const WebCore::DisplayList::DisplayList&, bool showDebugBorders, WebCore::RenderingResourceIdentifier);
 88 void flushDisplayListAndCommit(const WebCore::DisplayList::DisplayList&, bool showDebugBorders, DisplayListFlushIdentifier, WebCore::RenderingResourceIdentifier);
8889 void getImageData(WebCore::AlphaPremultiplication outputFormat, WebCore::IntRect srcRect, WebCore::RenderingResourceIdentifier, CompletionHandler<void(IPC::ImageDataReference&&)>&&);
8990 void releaseRemoteResource(WebCore::RenderingResourceIdentifier);
9091
9192 RemoteResourceCache m_remoteResourceCache;
9293 WeakPtr<GPUConnectionToWebProcess> m_gpuConnectionToWebProcess;
9394 RenderingBackendIdentifier m_renderingBackendIdentifier;
 95 bool m_showDebugBorders { false };
9496};
9597
9698} // namespace WebKit

Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.messages.in

2424
2525messages -> RemoteRenderingBackend NotRefCounted {
2626 void CreateImageBuffer(WebCore::FloatSize logicalSize, WebCore::RenderingMode renderingMode, float resolutionScale, WebCore::ColorSpace colorSpace, WebCore::RenderingResourceIdentifier renderingResourceIdentifier)
27  void FlushDisplayList(WebCore::DisplayList::DisplayList displayList, WebCore::RenderingResourceIdentifier renderingResourceIdentifier)
28  void FlushDisplayListAndCommit(WebCore::DisplayList::DisplayList displayList, WebKit::DisplayListFlushIdentifier flushIdentifier, WebCore::RenderingResourceIdentifier renderingResourceIdentifier)
 27 void FlushDisplayList(WebCore::DisplayList::DisplayList displayList, bool showDebugBorders, WebCore::RenderingResourceIdentifier renderingResourceIdentifier)
 28 void FlushDisplayListAndCommit(WebCore::DisplayList::DisplayList displayList, bool showDebugBorders, WebKit::DisplayListFlushIdentifier flushIdentifier, WebCore::RenderingResourceIdentifier renderingResourceIdentifier)
2929 GetImageData(enum:uint8_t WebCore::AlphaPremultiplication outputFormat, WebCore::IntRect srcRect, WebCore::RenderingResourceIdentifier renderingResourceIdentifier) -> (IPC::ImageDataReference imageData) Synchronous
3030 void ReleaseRemoteResource(WebCore::RenderingResourceIdentifier renderingResourceIdentifier)
3131}

Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h

@@class RemoteImageBufferProxy : public WebCore::DisplayList::ImageBuffer<BackendT
4040 using BaseDisplayListImageBuffer = WebCore::DisplayList::ImageBuffer<BackendType>;
4141 using BaseDisplayListImageBuffer::m_backend;
4242 using BaseDisplayListImageBuffer::m_drawingContext;
 43 using BaseDisplayListImageBuffer::context;
4344
4445public:
4546 static RefPtr<RemoteImageBufferProxy> create(const WebCore::FloatSize& size, float resolutionScale, RemoteRenderingBackendProxy& remoteRenderingBackendProxy)

@@protected:
148149 return;
149150
150151 TraceScope tracingScope(FlushRemoteImageBufferStart, FlushRemoteImageBufferEnd, 1);
 152 m_remoteRenderingBackendProxy->drawDebugBorderAndBadge(context(), { { }, m_backend->logicalSize() }, "GPU"_s);
151153 m_sentFlushIdentifier = m_remoteRenderingBackendProxy->flushDisplayListAndCommit(displayList, m_renderingResourceIdentifier);
152154 m_remoteRenderingBackendProxy->remoteResourceCacheProxy().unlockRemoteResourcesForRemoteClient(m_renderingResourceIdentifier);
153155 m_itemCountInCurrentDisplayList = 0;

Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp

3535#include "RemoteRenderingBackendMessages.h"
3636#include "RemoteRenderingBackendProxyMessages.h"
3737#include "WebProcess.h"
 38#include <WebCore/GraphicsContextExtras.h>
 39#include <WebCore/Settings.h>
3840
3941namespace WebKit {
4042
4143using namespace WebCore;
4244
43 std::unique_ptr<RemoteRenderingBackendProxy> RemoteRenderingBackendProxy::create()
 45std::unique_ptr<RemoteRenderingBackendProxy> RemoteRenderingBackendProxy::create(WebPage& page)
4446{
45  return std::unique_ptr<RemoteRenderingBackendProxy>(new RemoteRenderingBackendProxy());
 47 return std::unique_ptr<RemoteRenderingBackendProxy>(new RemoteRenderingBackendProxy(page));
4648}
4749
48 RemoteRenderingBackendProxy::RemoteRenderingBackendProxy()
 50RemoteRenderingBackendProxy::RemoteRenderingBackendProxy(WebPage& page)
 51 : m_page(page)
4952{
5053 // Register itself as a MessageReceiver in the GPUProcessConnection.
5154 IPC::MessageReceiverMap& messageReceiverMap = WebProcess::singleton().ensureGPUProcessConnection().messageReceiverMap();

@@uint64_t RemoteRenderingBackendProxy::messageSenderDestinationID() const
7578 return m_renderingBackendIdentifier.toUInt64();
7679}
7780
 81bool RemoteRenderingBackendProxy::showDebugBorders() const
 82{
 83 return m_page.corePage()->settings().showDebugBorders();
 84}
 85
 86void RemoteRenderingBackendProxy::drawDebugBorderAndBadge(GraphicsContext& context, const FloatRect& borderRect, const String& text)
 87{
 88 if (!showDebugBorders())
 89 return;
 90
 91 const unsigned fontSize = 10;
 92 constexpr auto backgroundColor = Color::red;
 93 constexpr auto textColor = Color::white;
 94
 95 DebugBadge badge = { DebugBadge::Corner::TopRight, backgroundColor, textColor, fontSize, text };
 96 drawDebugBorderAndBadges(context, borderRect, backgroundColor, { badge });
 97}
 98
7899bool RemoteRenderingBackendProxy::waitForImageBufferBackendWasCreated()
79100{
80101 Ref<IPC::Connection> connection = WebProcess::singleton().ensureGPUProcessConnection().connection();

@@RefPtr<ImageData> RemoteRenderingBackendProxy::getImageData(AlphaPremultiplicati
116137
117138void RemoteRenderingBackendProxy::flushDisplayList(const DisplayList::DisplayList& displayList, RenderingResourceIdentifier renderingResourceIdentifier)
118139{
119  send(Messages::RemoteRenderingBackend::FlushDisplayList(displayList, renderingResourceIdentifier), m_renderingBackendIdentifier);
 140 send(Messages::RemoteRenderingBackend::FlushDisplayList(displayList, showDebugBorders(), renderingResourceIdentifier), m_renderingBackendIdentifier);
120141}
121142
122143DisplayListFlushIdentifier RemoteRenderingBackendProxy::flushDisplayListAndCommit(const DisplayList::DisplayList& displayList, RenderingResourceIdentifier renderingResourceIdentifier)
123144{
124145 DisplayListFlushIdentifier sentFlushIdentifier = DisplayListFlushIdentifier::generate();
125  send(Messages::RemoteRenderingBackend::FlushDisplayListAndCommit(displayList, sentFlushIdentifier, renderingResourceIdentifier), m_renderingBackendIdentifier);
 146 send(Messages::RemoteRenderingBackend::FlushDisplayListAndCommit(displayList, showDebugBorders(), sentFlushIdentifier, renderingResourceIdentifier), m_renderingBackendIdentifier);
126147 return sentFlushIdentifier;
127148}
128149

Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h

@@enum class RenderingMode : bool;
5050
5151namespace WebKit {
5252
 53class WebPage;
 54
5355class RemoteRenderingBackendProxy
5456 : public IPC::MessageSender
5557 , private IPC::MessageReceiver
5658 , public CanMakeWeakPtr<RemoteRenderingBackendProxy> {
5759public:
58  static std::unique_ptr<RemoteRenderingBackendProxy> create();
 60 static std::unique_ptr<RemoteRenderingBackendProxy> create(WebPage&);
5961
6062 ~RemoteRenderingBackendProxy();
6163

@@public:
6870 // IPC::MessageReceiver
6971 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
7072
 73 // Rendering operations.
 74 bool showDebugBorders() const;
 75 void drawDebugBorderAndBadge(WebCore::GraphicsContext&, const WebCore::FloatRect& borderRect, const String& text);
 76
7177 // Messages to be sent.
7278 RefPtr<WebCore::ImageBuffer> createImageBuffer(const WebCore::FloatSize&, WebCore::RenderingMode, float resolutionScale, WebCore::ColorSpace);
7379 RefPtr<WebCore::ImageData> getImageData(WebCore::AlphaPremultiplication outputFormat, const WebCore::IntRect& srcRect, WebCore::RenderingResourceIdentifier);

@@public:
7985 bool waitForFlushDisplayListWasCommitted();
8086
8187private:
82  RemoteRenderingBackendProxy();
 88 RemoteRenderingBackendProxy(WebPage&);
8389
8490 // Messages to be received.
8591 void imageBufferBackendWasCreated(const WebCore::FloatSize& logicalSize, const WebCore::IntSize& backendSize, float resolutionScale, WebCore::ColorSpace, ImageBufferBackendHandle, WebCore::RenderingResourceIdentifier);

@@private:
8793
8894 RemoteResourceCacheProxy m_remoteResourceCacheProxy { *this };
8995 RenderingBackendIdentifier m_renderingBackendIdentifier { RenderingBackendIdentifier::generate() };
 96 WebPage& m_page;
9097};
9198
9299} // namespace WebKit

Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp

@@RefPtr<DisplayRefreshMonitor> WebChromeClient::createDisplayRefreshMonitor(Platf
906906RemoteRenderingBackendProxy& WebChromeClient::ensureRemoteRenderingBackendProxy() const
907907{
908908 if (!m_remoteRenderingBackendProxy)
909  m_remoteRenderingBackendProxy = RemoteRenderingBackendProxy::create();
 909 m_remoteRenderingBackendProxy = RemoteRenderingBackendProxy::create(m_page);
910910 return *m_remoteRenderingBackendProxy;
911911}
912912