1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
|
/*
* Copyright (C) 2012-2023 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "Connection.h"
#include "DrawingAreaInfo.h"
#include "EditorState.h"
#include "PlatformCAAnimationRemote.h"
#include "PlaybackSessionContextIdentifier.h"
#include "RemoteLayerBackingStore.h"
#include "TransactionID.h"
#include <WebCore/Color.h>
#include <WebCore/FixedContainerEdges.h>
#include <WebCore/FloatPoint3D.h>
#include <WebCore/FloatSize.h>
#include <WebCore/HTMLMediaElementIdentifier.h>
#include <WebCore/LayoutMilestone.h>
#include <WebCore/MediaPlayerEnums.h>
#include <WebCore/PlatformCALayer.h>
#include <WebCore/ScrollTypes.h>
#include <wtf/CheckedPtr.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/TZoneMalloc.h>
#include <wtf/text/StringHash.h>
#include <wtf/text/WTFString.h>
#if PLATFORM(IOS_FAMILY)
#include "DynamicViewportSizeUpdate.h"
#endif
#if ENABLE(THREADED_ANIMATION_RESOLUTION)
#include <WebCore/AcceleratedEffect.h>
#include <WebCore/AcceleratedEffectValues.h>
#endif
#if ENABLE(MODEL_ELEMENT)
#include <WebCore/Model.h>
#endif
#if ENABLE(MODEL_PROCESS)
#include <WebCore/ModelContext.h>
#endif
namespace WebKit {
struct LayerProperties;
typedef HashMap<WebCore::PlatformLayerIdentifier, UniqueRef<LayerProperties>> LayerPropertiesMap;
struct ChangedLayers {
HashSet<Ref<PlatformCALayerRemote>> changedLayers; // Only used in the Web process.
LayerPropertiesMap changedLayerProperties; // Only used in the UI process.
ChangedLayers();
ChangedLayers(ChangedLayers&&);
ChangedLayers& operator=(ChangedLayers&&);
ChangedLayers(LayerPropertiesMap&&);
~ChangedLayers();
};
class RemoteLayerTreeTransaction : public CanMakeCheckedPtr<RemoteLayerTreeTransaction> {
WTF_MAKE_TZONE_ALLOCATED(RemoteLayerTreeTransaction);
WTF_OVERRIDE_DELETE_FOR_CHECKED_PTR(RemoteLayerTreeTransaction);
public:
struct LayerCreationProperties {
struct NoAdditionalData { };
struct CustomData {
uint32_t hostingContextID { 0 };
float hostingDeviceScaleFactor { 1 };
bool preservesFlip { false };
};
struct VideoElementData {
PlaybackSessionContextIdentifier playerIdentifier;
WebCore::FloatSize initialSize;
WebCore::FloatSize naturalSize;
};
using AdditionalData = std::variant<
NoAdditionalData, // PlatformCALayerRemote and PlatformCALayerRemoteTiledBacking
CustomData, // PlatformCALayerRemoteCustom
#if ENABLE(MODEL_ELEMENT)
Ref<WebCore::Model>, // PlatformCALayerRemoteModelHosting
#if ENABLE(MODEL_PROCESS)
Ref<WebCore::ModelContext>, // PlatformCALayerRemoteCustom
#endif
#endif
WebCore::LayerHostingContextIdentifier // PlatformCALayerRemoteHost
>;
Markable<WebCore::PlatformLayerIdentifier> layerID;
WebCore::PlatformCALayer::LayerType type { WebCore::PlatformCALayer::LayerType::LayerTypeLayer };
std::optional<VideoElementData> videoElementData;
AdditionalData additionalData;
LayerCreationProperties();
LayerCreationProperties(Markable<WebCore::PlatformLayerIdentifier>, WebCore::PlatformCALayer::LayerType, std::optional<VideoElementData>&&, AdditionalData&&);
LayerCreationProperties(LayerCreationProperties&&);
LayerCreationProperties& operator=(LayerCreationProperties&&);
std::optional<WebCore::LayerHostingContextIdentifier> hostIdentifier() const;
uint32_t hostingContextID() const;
bool preservesFlip() const;
float hostingDeviceScaleFactor() const;
#if ENABLE(MODEL_PROCESS)
RefPtr<WebCore::ModelContext> modelContext() const;
#endif
};
explicit RemoteLayerTreeTransaction(TransactionID);
~RemoteLayerTreeTransaction();
RemoteLayerTreeTransaction(RemoteLayerTreeTransaction&&);
RemoteLayerTreeTransaction& operator=(RemoteLayerTreeTransaction&&);
std::optional<WebCore::PlatformLayerIdentifier> rootLayerID() const { return m_rootLayerID.asOptional(); }
void setRootLayerID(WebCore::PlatformLayerIdentifier);
void layerPropertiesChanged(PlatformCALayerRemote&);
void setCreatedLayers(Vector<LayerCreationProperties>);
void setDestroyedLayerIDs(Vector<WebCore::PlatformLayerIdentifier>);
void setLayerIDsWithNewlyUnreachableBackingStore(Vector<WebCore::PlatformLayerIdentifier>);
#if !defined(NDEBUG) || !LOG_DISABLED
String description() const;
void dump() const;
#endif
bool hasAnyLayerChanges() const;
const Vector<LayerCreationProperties>& createdLayers() const { return m_createdLayers; }
const Vector<WebCore::PlatformLayerIdentifier>& destroyedLayers() const { return m_destroyedLayerIDs; }
const Vector<WebCore::PlatformLayerIdentifier>& layerIDsWithNewlyUnreachableBackingStore() const { return m_layerIDsWithNewlyUnreachableBackingStore; }
HashSet<Ref<PlatformCALayerRemote>>& changedLayers();
const LayerPropertiesMap& changedLayerProperties() const;
LayerPropertiesMap& changedLayerProperties();
void setRemoteContextHostedIdentifier(Markable<WebCore::LayerHostingContextIdentifier> identifier) { m_remoteContextHostedIdentifier = identifier; }
Markable<WebCore::LayerHostingContextIdentifier> remoteContextHostedIdentifier() const { return m_remoteContextHostedIdentifier; }
bool isMainFrameProcessTransaction() const { return !m_remoteContextHostedIdentifier; }
WebCore::IntSize contentsSize() const { return m_contentsSize; }
void setContentsSize(const WebCore::IntSize& size) { m_contentsSize = size; };
WebCore::IntPoint scrollOrigin() const { return m_scrollOrigin; }
void setScrollOrigin(const WebCore::IntPoint& origin) { m_scrollOrigin = origin; };
WebCore::LayoutSize baseLayoutViewportSize() const { return m_baseLayoutViewportSize; }
void setBaseLayoutViewportSize(const WebCore::LayoutSize& size) { m_baseLayoutViewportSize = size; };
WebCore::LayoutPoint minStableLayoutViewportOrigin() const { return m_minStableLayoutViewportOrigin; }
void setMinStableLayoutViewportOrigin(const WebCore::LayoutPoint& point) { m_minStableLayoutViewportOrigin = point; };
WebCore::LayoutPoint maxStableLayoutViewportOrigin() const { return m_maxStableLayoutViewportOrigin; }
void setMaxStableLayoutViewportOrigin(const WebCore::LayoutPoint& point) { m_maxStableLayoutViewportOrigin = point; };
WebCore::Color themeColor() const { return m_themeColor; }
void setThemeColor(WebCore::Color color) { m_themeColor = color; }
WebCore::Color pageExtendedBackgroundColor() const { return m_pageExtendedBackgroundColor; }
void setPageExtendedBackgroundColor(WebCore::Color color) { m_pageExtendedBackgroundColor = color; }
WebCore::Color sampledPageTopColor() const { return m_sampledPageTopColor; }
void setSampledPageTopColor(WebCore::Color color) { m_sampledPageTopColor = color; }
WebCore::IntPoint scrollPosition() const { return m_scrollPosition; }
void setScrollPosition(WebCore::IntPoint p) { m_scrollPosition = p; }
double pageScaleFactor() const { return m_pageScaleFactor; }
void setPageScaleFactor(double pageScaleFactor) { m_pageScaleFactor = pageScaleFactor; }
bool scaleWasSetByUIProcess() const { return m_scaleWasSetByUIProcess; }
void setScaleWasSetByUIProcess(bool scaleWasSetByUIProcess) { m_scaleWasSetByUIProcess = scaleWasSetByUIProcess; }
#if PLATFORM(MAC)
std::optional<WebCore::PlatformLayerIdentifier> pageScalingLayerID() const { return m_pageScalingLayerID.asOptional(); }
void setPageScalingLayerID(std::optional<WebCore::PlatformLayerIdentifier> layerID) { m_pageScalingLayerID = layerID; }
std::optional<WebCore::PlatformLayerIdentifier> scrolledContentsLayerID() const { return m_scrolledContentsLayerID.asOptional(); }
void setScrolledContentsLayerID(std::optional<WebCore::PlatformLayerIdentifier> layerID) { m_scrolledContentsLayerID = layerID; }
#endif
uint64_t renderTreeSize() const { return m_renderTreeSize; }
void setRenderTreeSize(uint64_t renderTreeSize) { m_renderTreeSize = renderTreeSize; }
double minimumScaleFactor() const { return m_minimumScaleFactor; }
void setMinimumScaleFactor(double scale) { m_minimumScaleFactor = scale; }
double maximumScaleFactor() const { return m_maximumScaleFactor; }
void setMaximumScaleFactor(double scale) { m_maximumScaleFactor = scale; }
double initialScaleFactor() const { return m_initialScaleFactor; }
void setInitialScaleFactor(double scale) { m_initialScaleFactor = scale; }
double viewportMetaTagWidth() const { return m_viewportMetaTagWidth; }
void setViewportMetaTagWidth(double width) { m_viewportMetaTagWidth = width; }
bool viewportMetaTagWidthWasExplicit() const { return m_viewportMetaTagWidthWasExplicit; }
void setViewportMetaTagWidthWasExplicit(bool widthWasExplicit) { m_viewportMetaTagWidthWasExplicit = widthWasExplicit; }
bool viewportMetaTagCameFromImageDocument() const { return m_viewportMetaTagCameFromImageDocument; }
void setViewportMetaTagCameFromImageDocument(bool cameFromImageDocument) { m_viewportMetaTagCameFromImageDocument = cameFromImageDocument; }
bool isInStableState() const { return m_isInStableState; }
void setIsInStableState(bool isInStableState) { m_isInStableState = isInStableState; }
bool allowsUserScaling() const { return m_allowsUserScaling; }
void setAllowsUserScaling(bool allowsUserScaling) { m_allowsUserScaling = allowsUserScaling; }
bool avoidsUnsafeArea() const { return m_avoidsUnsafeArea; }
void setAvoidsUnsafeArea(bool avoidsUnsafeArea) { m_avoidsUnsafeArea = avoidsUnsafeArea; }
TransactionID transactionID() const { return m_transactionID; }
ActivityStateChangeID activityStateChangeID() const { return m_activityStateChangeID; }
void setActivityStateChangeID(ActivityStateChangeID activityStateChangeID) { m_activityStateChangeID = activityStateChangeID; }
using TransactionCallbackID = IPC::AsyncReplyID;
const Vector<TransactionCallbackID>& callbackIDs() const { return m_callbackIDs; }
void setCallbackIDs(Vector<TransactionCallbackID>&& callbackIDs) { m_callbackIDs = WTFMove(callbackIDs); }
OptionSet<WebCore::LayoutMilestone> newlyReachedPaintingMilestones() const { return m_newlyReachedPaintingMilestones; }
void setNewlyReachedPaintingMilestones(OptionSet<WebCore::LayoutMilestone> milestones) { m_newlyReachedPaintingMilestones = milestones; }
bool hasEditorState() const { return !!m_editorState; }
const EditorState& editorState() const { return m_editorState.value(); }
void setEditorState(const EditorState& editorState) { m_editorState = editorState; }
#if PLATFORM(IOS_FAMILY)
std::optional<DynamicViewportSizeUpdateID> dynamicViewportSizeUpdateID() const { return m_dynamicViewportSizeUpdateID; }
void setDynamicViewportSizeUpdateID(DynamicViewportSizeUpdateID resizeID) { m_dynamicViewportSizeUpdateID = resizeID; }
#endif
#if ENABLE(THREADED_ANIMATION_RESOLUTION)
Seconds acceleratedTimelineTimeOrigin() const { return m_acceleratedTimelineTimeOrigin; }
void setAcceleratedTimelineTimeOrigin(Seconds timeOrigin) { m_acceleratedTimelineTimeOrigin = timeOrigin; }
#endif
const WebCore::FixedContainerEdges& fixedContainerEdges() const { return m_fixedContainerEdges; }
void setFixedContainerEdges(WebCore::FixedContainerEdges&& edges) { m_fixedContainerEdges = WTFMove(edges); }
private:
friend struct IPC::ArgumentCoder<RemoteLayerTreeTransaction, void>;
// Do not use, IPC constructor only
explicit RemoteLayerTreeTransaction();
Markable<WebCore::PlatformLayerIdentifier> m_rootLayerID;
ChangedLayers m_changedLayers;
Markable<WebCore::LayerHostingContextIdentifier> m_remoteContextHostedIdentifier;
Vector<LayerCreationProperties> m_createdLayers;
Vector<WebCore::PlatformLayerIdentifier> m_destroyedLayerIDs;
Vector<WebCore::PlatformLayerIdentifier> m_videoLayerIDsPendingFullscreen;
Vector<WebCore::PlatformLayerIdentifier> m_layerIDsWithNewlyUnreachableBackingStore;
Vector<TransactionCallbackID> m_callbackIDs;
WebCore::IntSize m_contentsSize;
WebCore::IntPoint m_scrollOrigin;
WebCore::LayoutSize m_baseLayoutViewportSize;
WebCore::LayoutPoint m_minStableLayoutViewportOrigin;
WebCore::LayoutPoint m_maxStableLayoutViewportOrigin;
WebCore::IntPoint m_scrollPosition;
WebCore::Color m_themeColor;
WebCore::Color m_pageExtendedBackgroundColor;
WebCore::Color m_sampledPageTopColor;
WebCore::FixedContainerEdges m_fixedContainerEdges;
#if PLATFORM(MAC)
Markable<WebCore::PlatformLayerIdentifier> m_pageScalingLayerID; // Only used for non-delegated scaling.
Markable<WebCore::PlatformLayerIdentifier> m_scrolledContentsLayerID;
#endif
double m_pageScaleFactor { 1 };
double m_minimumScaleFactor { 1 };
double m_maximumScaleFactor { 1 };
double m_initialScaleFactor { 1 };
double m_viewportMetaTagWidth { -1 };
uint64_t m_renderTreeSize { 0 };
TransactionID m_transactionID;
ActivityStateChangeID m_activityStateChangeID { ActivityStateChangeAsynchronous };
OptionSet<WebCore::LayoutMilestone> m_newlyReachedPaintingMilestones;
bool m_scaleWasSetByUIProcess { false };
bool m_allowsUserScaling { false };
bool m_avoidsUnsafeArea { true };
bool m_viewportMetaTagWidthWasExplicit { false };
bool m_viewportMetaTagCameFromImageDocument { false };
bool m_isInStableState { false };
std::optional<EditorState> m_editorState;
#if PLATFORM(IOS_FAMILY)
std::optional<DynamicViewportSizeUpdateID> m_dynamicViewportSizeUpdateID;
#endif
#if ENABLE(THREADED_ANIMATION_RESOLUTION)
Seconds m_acceleratedTimelineTimeOrigin;
#endif
};
} // namespace WebKit
|