Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/webrender/WebRenderAPI.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef MOZILLA_LAYERS_WEBRENDERAPI_H
8
#define MOZILLA_LAYERS_WEBRENDERAPI_H
9
10
#include <vector>
11
#include <unordered_map>
12
#include <unordered_set>
13
14
#include "mozilla/AlreadyAddRefed.h"
15
#include "mozilla/gfx/CompositorHitTestInfo.h"
16
#include "mozilla/layers/SyncObject.h"
17
#include "mozilla/Range.h"
18
#include "mozilla/webrender/webrender_ffi.h"
19
#include "mozilla/webrender/WebRenderTypes.h"
20
#include "FrameMetrics.h"
21
#include "GLTypes.h"
22
#include "Units.h"
23
24
namespace mozilla {
25
26
struct ActiveScrolledRoot;
27
28
namespace widget {
29
class CompositorWidget;
30
}
31
32
namespace layers {
33
class CompositorBridgeParent;
34
class WebRenderBridgeParent;
35
}
36
37
namespace wr {
38
39
class DisplayListBuilder;
40
class RendererOGL;
41
class RendererEvent;
42
43
// This isn't part of WR's API, but we define it here to simplify layout's
44
// logic and data plumbing.
45
struct Line {
46
  wr::LayoutRect bounds;
47
  float wavyLineThickness;
48
  wr::LineOrientation orientation;
49
  wr::ColorF color;
50
  wr::LineStyle style;
51
};
52
53
/// A handler that can be bundled into a transaction and notified at specific
54
/// points in the rendering pipeline, such as after scene building or after
55
/// frame building.
56
///
57
/// If for any reason the handler is dropped before reaching the requested
58
/// point, it is notified with the value Checkpoint::TransactionDropped.
59
/// So it is safe to assume that the handler will be notified "at some point".
60
class NotificationHandler {
61
public:
62
  virtual void Notify(wr::Checkpoint aCheckpoint) = 0;
63
0
  virtual ~NotificationHandler() = default;
64
};
65
66
class TransactionBuilder {
67
public:
68
  explicit TransactionBuilder(bool aUseSceneBuilderThread = true);
69
70
  ~TransactionBuilder();
71
72
  void SetLowPriority(bool aIsLowPriority);
73
74
  void UpdateEpoch(PipelineId aPipelineId, Epoch aEpoch);
75
76
  void SetRootPipeline(PipelineId aPipelineId);
77
78
  void RemovePipeline(PipelineId aPipelineId);
79
80
  void SetDisplayList(gfx::Color aBgColor,
81
                      Epoch aEpoch,
82
                      mozilla::LayerSize aViewportSize,
83
                      wr::WrPipelineId pipeline_id,
84
                      const wr::LayoutSize& content_size,
85
                      wr::BuiltDisplayListDescriptor dl_descriptor,
86
                      wr::Vec<uint8_t>& dl_data);
87
88
  void ClearDisplayList(Epoch aEpoch, wr::WrPipelineId aPipeline);
89
90
  void GenerateFrame();
91
92
  void UpdateDynamicProperties(const nsTArray<wr::WrOpacityProperty>& aOpacityArray,
93
                               const nsTArray<wr::WrTransformProperty>& aTransformArray);
94
95
  void SetWindowParameters(const LayoutDeviceIntSize& aWindowSize,
96
                           const LayoutDeviceIntRect& aDocRect);
97
98
  void UpdateScrollPosition(const wr::WrPipelineId& aPipelineId,
99
                            const layers::FrameMetrics::ViewID& aScrollId,
100
                            const wr::LayoutPoint& aScrollPosition);
101
102
  bool IsEmpty() const;
103
104
  void AddImage(wr::ImageKey aKey,
105
                const ImageDescriptor& aDescriptor,
106
                wr::Vec<uint8_t>& aBytes);
107
108
  void AddBlobImage(wr::ImageKey aKey,
109
                    const ImageDescriptor& aDescriptor,
110
                    wr::Vec<uint8_t>& aBytes);
111
112
  void AddExternalImageBuffer(ImageKey key,
113
                              const ImageDescriptor& aDescriptor,
114
                              ExternalImageId aHandle);
115
116
  void AddExternalImage(ImageKey key,
117
                        const ImageDescriptor& aDescriptor,
118
                        ExternalImageId aExtID,
119
                        wr::WrExternalImageBufferType aBufferType,
120
                        uint8_t aChannelIndex = 0);
121
122
  void UpdateImageBuffer(wr::ImageKey aKey,
123
                         const ImageDescriptor& aDescriptor,
124
                         wr::Vec<uint8_t>& aBytes);
125
126
  void UpdateBlobImage(wr::ImageKey aKey,
127
                       const ImageDescriptor& aDescriptor,
128
                       wr::Vec<uint8_t>& aBytes,
129
                       const wr::DeviceUintRect& aDirtyRect);
130
131
  void UpdateExternalImage(ImageKey aKey,
132
                           const ImageDescriptor& aDescriptor,
133
                           ExternalImageId aExtID,
134
                           wr::WrExternalImageBufferType aBufferType,
135
                           uint8_t aChannelIndex = 0);
136
137
  void UpdateExternalImageWithDirtyRect(ImageKey aKey,
138
                                        const ImageDescriptor& aDescriptor,
139
                                        ExternalImageId aExtID,
140
                                        wr::WrExternalImageBufferType aBufferType,
141
                                        const wr::DeviceUintRect& aDirtyRect,
142
                                        uint8_t aChannelIndex = 0);
143
144
  void SetImageVisibleArea(ImageKey aKey, const wr::NormalizedRect& aArea);
145
146
  void DeleteImage(wr::ImageKey aKey);
147
148
  void AddRawFont(wr::FontKey aKey, wr::Vec<uint8_t>& aBytes, uint32_t aIndex);
149
150
  void AddFontDescriptor(wr::FontKey aKey, wr::Vec<uint8_t>& aBytes, uint32_t aIndex);
151
152
  void DeleteFont(wr::FontKey aKey);
153
154
  void AddFontInstance(wr::FontInstanceKey aKey,
155
                       wr::FontKey aFontKey,
156
                       float aGlyphSize,
157
                       const wr::FontInstanceOptions* aOptions,
158
                       const wr::FontInstancePlatformOptions* aPlatformOptions,
159
                       wr::Vec<uint8_t>& aVariations);
160
161
  void DeleteFontInstance(wr::FontInstanceKey aKey);
162
163
  void Notify(wr::Checkpoint aWhen, UniquePtr<NotificationHandler> aHandler);
164
165
  void Clear();
166
167
  bool UseSceneBuilderThread() const { return mUseSceneBuilderThread; }
168
  Transaction* Raw() { return mTxn; }
169
protected:
170
  bool mUseSceneBuilderThread;
171
  Transaction* mTxn;
172
};
173
174
class TransactionWrapper
175
{
176
public:
177
  explicit TransactionWrapper(Transaction* aTxn);
178
179
  void AppendTransformProperties(const nsTArray<wr::WrTransformProperty>& aTransformArray);
180
  void UpdateScrollPosition(const wr::WrPipelineId& aPipelineId,
181
                            const layers::FrameMetrics::ViewID& aScrollId,
182
                            const wr::LayoutPoint& aScrollPosition);
183
private:
184
  Transaction* mTxn;
185
};
186
187
class WebRenderAPI
188
{
189
  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WebRenderAPI);
190
191
public:
192
  /// This can be called on the compositor thread only.
193
  static already_AddRefed<WebRenderAPI> Create(layers::CompositorBridgeParent* aBridge,
194
                                               RefPtr<widget::CompositorWidget>&& aWidget,
195
                                               const wr::WrWindowId& aWindowId,
196
                                               LayoutDeviceIntSize aSize);
197
198
  already_AddRefed<WebRenderAPI> CreateDocument(LayoutDeviceIntSize aSize, int8_t aLayerIndex);
199
200
  already_AddRefed<WebRenderAPI> Clone();
201
202
0
  wr::WindowId GetId() const { return mId; }
203
204
  bool HitTest(const wr::WorldPoint& aPoint,
205
               wr::WrPipelineId& aOutPipelineId,
206
               layers::FrameMetrics::ViewID& aOutScrollId,
207
               gfx::CompositorHitTestInfo& aOutHitInfo);
208
209
  void SendTransaction(TransactionBuilder& aTxn);
210
211
  void SetFrameStartTime(const TimeStamp& aTime);
212
213
  void RunOnRenderThread(UniquePtr<RendererEvent> aEvent);
214
215
  void Readback(const TimeStamp& aStartTime, gfx::IntSize aSize, uint8_t *aBuffer, uint32_t aBufferSize);
216
217
  void ClearAllCaches();
218
219
  void Pause();
220
  bool Resume();
221
222
  void WakeSceneBuilder();
223
  void FlushSceneBuilder();
224
225
  void NotifyMemoryPressure();
226
  void AccumulateMemoryReport(wr::MemoryReport*);
227
228
  wr::WrIdNamespace GetNamespace();
229
0
  uint32_t GetMaxTextureSize() const { return mMaxTextureSize; }
230
0
  bool GetUseANGLE() const { return mUseANGLE; }
231
0
  bool GetUseDComp() const { return mUseDComp; }
232
0
  layers::SyncHandle GetSyncHandle() const { return mSyncHandle; }
233
234
  void Capture();
235
236
protected:
237
  WebRenderAPI(wr::DocumentHandle* aHandle, wr::WindowId aId, uint32_t aMaxTextureSize, bool aUseANGLE, bool aUseDComp, layers::SyncHandle aSyncHandle)
238
    : mDocHandle(aHandle)
239
    , mId(aId)
240
    , mMaxTextureSize(aMaxTextureSize)
241
    , mUseANGLE(aUseANGLE)
242
    , mUseDComp(aUseDComp)
243
    , mSyncHandle(aSyncHandle)
244
  {}
245
246
  ~WebRenderAPI();
247
  // Should be used only for shutdown handling
248
  void WaitFlushed();
249
250
  wr::DocumentHandle* mDocHandle;
251
  wr::WindowId mId;
252
  uint32_t mMaxTextureSize;
253
  bool mUseANGLE;
254
  bool mUseDComp;
255
  layers::SyncHandle mSyncHandle;
256
257
  // We maintain alive the root api to know when to shut the render backend down,
258
  // and the root api for the document to know when to delete the document.
259
  // mRootApi is null for the api object that owns the channel (and is responsible
260
  // for shutting it down), and mRootDocumentApi is null for the api object owning
261
  // (and responsible for destroying) a given document.
262
  // All api objects in the same window use the same channel, and some api objects
263
  // write to the same document (but there is only one owner for each channel and
264
  // for each document).
265
  RefPtr<wr::WebRenderAPI> mRootApi;
266
  RefPtr<wr::WebRenderAPI> mRootDocumentApi;
267
268
  friend class DisplayListBuilder;
269
  friend class layers::WebRenderBridgeParent;
270
};
271
272
// This is a RAII class that automatically sends the transaction on
273
// destruction. This is useful for code that has multiple exit points and we
274
// want to ensure that the stuff accumulated in the transaction gets sent
275
// regardless of which exit we take. Note that if the caller explicitly calls
276
// mApi->SendTransaction() that's fine too because that empties out the
277
// TransactionBuilder and leaves it as a valid empty transaction, so calling
278
// SendTransaction on it again ends up being a no-op.
279
class MOZ_RAII AutoTransactionSender
280
{
281
public:
282
  AutoTransactionSender(WebRenderAPI* aApi, TransactionBuilder* aTxn)
283
    : mApi(aApi)
284
    , mTxn(aTxn)
285
0
  {}
286
287
0
  ~AutoTransactionSender() {
288
0
    mApi->SendTransaction(*mTxn);
289
0
  }
290
291
private:
292
  WebRenderAPI* mApi;
293
  TransactionBuilder* mTxn;
294
};
295
296
/// This is a simple C++ wrapper around WrState defined in the rust bindings.
297
/// We may want to turn this into a direct wrapper on top of WebRenderFrameBuilder
298
/// instead, so the interface may change a bit.
299
class DisplayListBuilder {
300
public:
301
  explicit DisplayListBuilder(wr::PipelineId aId,
302
                              const wr::LayoutSize& aContentSize,
303
                              size_t aCapacity = 0);
304
  DisplayListBuilder(DisplayListBuilder&&) = default;
305
306
  ~DisplayListBuilder();
307
308
  void Save();
309
  void Restore();
310
  void ClearSave();
311
  usize Dump(usize aIndent, const Maybe<usize>& aStart, const Maybe<usize>& aEnd);
312
313
  void Finalize(wr::LayoutSize& aOutContentSize,
314
                wr::BuiltDisplayList& aOutDisplayList);
315
316
  Maybe<wr::WrClipId> PushStackingContext(
317
          const wr::LayoutRect& aBounds, // TODO: We should work with strongly typed rects
318
          const wr::WrClipId* aClipNodeId,
319
          const wr::WrAnimationProperty* aAnimation,
320
          const float* aOpacity,
321
          const gfx::Matrix4x4* aTransform,
322
          wr::TransformStyle aTransformStyle,
323
          const gfx::Matrix4x4* aPerspective,
324
          const wr::MixBlendMode& aMixBlendMode,
325
          const nsTArray<wr::WrFilterOp>& aFilters,
326
          bool aIsBackfaceVisible,
327
          const wr::RasterSpace& aRasterSpace);
328
  void PopStackingContext(bool aIsReferenceFrame);
329
330
  wr::WrClipChainId DefineClipChain(const Maybe<wr::WrClipChainId>& aParent,
331
                                    const nsTArray<wr::WrClipId>& aClips);
332
333
  wr::WrClipId DefineClip(const Maybe<wr::WrClipId>& aParentId,
334
                          const wr::LayoutRect& aClipRect,
335
                          const nsTArray<wr::ComplexClipRegion>* aComplex = nullptr,
336
                          const wr::WrImageMask* aMask = nullptr);
337
  void PushClip(const wr::WrClipId& aClipId);
338
  void PopClip();
339
340
  wr::WrClipId DefineStickyFrame(const wr::LayoutRect& aContentRect,
341
                                 const float* aTopMargin,
342
                                 const float* aRightMargin,
343
                                 const float* aBottomMargin,
344
                                 const float* aLeftMargin,
345
                                 const StickyOffsetBounds& aVerticalBounds,
346
                                 const StickyOffsetBounds& aHorizontalBounds,
347
                                 const wr::LayoutVector2D& aAppliedOffset);
348
349
  Maybe<wr::WrClipId> GetScrollIdForDefinedScrollLayer(layers::FrameMetrics::ViewID aViewId) const;
350
  wr::WrClipId DefineScrollLayer(const layers::FrameMetrics::ViewID& aViewId,
351
                                 const Maybe<wr::WrClipId>& aParentId,
352
                                 const wr::LayoutRect& aContentRect, // TODO: We should work with strongly typed rects
353
                                 const wr::LayoutRect& aClipRect);
354
355
  void PushClipAndScrollInfo(const wr::WrClipId* aScrollId,
356
                             const wr::WrClipChainId* aClipChainId,
357
                             const Maybe<wr::LayoutRect>& aClipChainLeaf);
358
  void PopClipAndScrollInfo(const wr::WrClipId* aScrollId);
359
360
  void PushRect(const wr::LayoutRect& aBounds,
361
                const wr::LayoutRect& aClip,
362
                bool aIsBackfaceVisible,
363
                const wr::ColorF& aColor);
364
365
  void PushClearRect(const wr::LayoutRect& aBounds);
366
367
  void PushLinearGradient(const wr::LayoutRect& aBounds,
368
                          const wr::LayoutRect& aClip,
369
                          bool aIsBackfaceVisible,
370
                          const wr::LayoutPoint& aStartPoint,
371
                          const wr::LayoutPoint& aEndPoint,
372
                          const nsTArray<wr::GradientStop>& aStops,
373
                          wr::ExtendMode aExtendMode,
374
                          const wr::LayoutSize aTileSize,
375
                          const wr::LayoutSize aTileSpacing);
376
377
  void PushRadialGradient(const wr::LayoutRect& aBounds,
378
                          const wr::LayoutRect& aClip,
379
                          bool aIsBackfaceVisible,
380
                          const wr::LayoutPoint& aCenter,
381
                          const wr::LayoutSize& aRadius,
382
                          const nsTArray<wr::GradientStop>& aStops,
383
                          wr::ExtendMode aExtendMode,
384
                          const wr::LayoutSize aTileSize,
385
                          const wr::LayoutSize aTileSpacing);
386
387
  void PushImage(const wr::LayoutRect& aBounds,
388
                 const wr::LayoutRect& aClip,
389
                 bool aIsBackfaceVisible,
390
                 wr::ImageRendering aFilter,
391
                 wr::ImageKey aImage,
392
                 bool aPremultipliedAlpha = true,
393
                 const wr::ColorF& aColor = wr::ColorF{1.0f, 1.0f, 1.0f, 1.0f});
394
395
  void PushImage(const wr::LayoutRect& aBounds,
396
                 const wr::LayoutRect& aClip,
397
                 bool aIsBackfaceVisible,
398
                 const wr::LayoutSize& aStretchSize,
399
                 const wr::LayoutSize& aTileSpacing,
400
                 wr::ImageRendering aFilter,
401
                 wr::ImageKey aImage,
402
                 bool aPremultipliedAlpha = true,
403
                 const wr::ColorF& aColor = wr::ColorF{1.0f, 1.0f, 1.0f, 1.0f});
404
405
  void PushYCbCrPlanarImage(const wr::LayoutRect& aBounds,
406
                            const wr::LayoutRect& aClip,
407
                            bool aIsBackfaceVisible,
408
                            wr::ImageKey aImageChannel0,
409
                            wr::ImageKey aImageChannel1,
410
                            wr::ImageKey aImageChannel2,
411
                            wr::WrYuvColorSpace aColorSpace,
412
                            wr::ImageRendering aFilter);
413
414
  void PushNV12Image(const wr::LayoutRect& aBounds,
415
                     const wr::LayoutRect& aClip,
416
                     bool aIsBackfaceVisible,
417
                     wr::ImageKey aImageChannel0,
418
                     wr::ImageKey aImageChannel1,
419
                     wr::WrYuvColorSpace aColorSpace,
420
                     wr::ImageRendering aFilter);
421
422
  void PushYCbCrInterleavedImage(const wr::LayoutRect& aBounds,
423
                                 const wr::LayoutRect& aClip,
424
                                 bool aIsBackfaceVisible,
425
                                 wr::ImageKey aImageChannel0,
426
                                 wr::WrYuvColorSpace aColorSpace,
427
                                 wr::ImageRendering aFilter);
428
429
  void PushIFrame(const wr::LayoutRect& aBounds,
430
                  bool aIsBackfaceVisible,
431
                  wr::PipelineId aPipeline,
432
                  bool aIgnoreMissingPipeline);
433
434
  // XXX WrBorderSides are passed with Range.
435
  // It is just to bypass compiler bug. See Bug 1357734.
436
  void PushBorder(const wr::LayoutRect& aBounds,
437
                  const wr::LayoutRect& aClip,
438
                  bool aIsBackfaceVisible,
439
                  const wr::LayoutSideOffsets& aWidths,
440
                  const Range<const wr::BorderSide>& aSides,
441
                  const wr::BorderRadius& aRadius);
442
443
  void PushBorderImage(const wr::LayoutRect& aBounds,
444
                       const wr::LayoutRect& aClip,
445
                       bool aIsBackfaceVisible,
446
                       const wr::LayoutSideOffsets& aWidths,
447
                       wr::ImageKey aImage,
448
                       const uint32_t aWidth,
449
                       const uint32_t aHeight,
450
                       const wr::SideOffsets2D<uint32_t>& aSlice,
451
                       const wr::SideOffsets2D<float>& aOutset,
452
                       const wr::RepeatMode& aRepeatHorizontal,
453
                       const wr::RepeatMode& aRepeatVertical);
454
455
  void PushBorderGradient(const wr::LayoutRect& aBounds,
456
                          const wr::LayoutRect& aClip,
457
                          bool aIsBackfaceVisible,
458
                          const wr::LayoutSideOffsets& aWidths,
459
                          const uint32_t aWidth,
460
                          const uint32_t aHeight,
461
                          const wr::SideOffsets2D<uint32_t>& aSlice,
462
                          const wr::LayoutPoint& aStartPoint,
463
                          const wr::LayoutPoint& aEndPoint,
464
                          const nsTArray<wr::GradientStop>& aStops,
465
                          wr::ExtendMode aExtendMode,
466
                          const wr::SideOffsets2D<float>& aOutset);
467
468
  void PushBorderRadialGradient(const wr::LayoutRect& aBounds,
469
                                const wr::LayoutRect& aClip,
470
                                bool aIsBackfaceVisible,
471
                                const wr::LayoutSideOffsets& aWidths,
472
                                const wr::LayoutPoint& aCenter,
473
                                const wr::LayoutSize& aRadius,
474
                                const nsTArray<wr::GradientStop>& aStops,
475
                                wr::ExtendMode aExtendMode,
476
                                const wr::SideOffsets2D<float>& aOutset);
477
478
  void PushText(const wr::LayoutRect& aBounds,
479
                const wr::LayoutRect& aClip,
480
                bool aIsBackfaceVisible,
481
                const wr::ColorF& aColor,
482
                wr::FontInstanceKey aFontKey,
483
                Range<const wr::GlyphInstance> aGlyphBuffer,
484
                const wr::GlyphOptions* aGlyphOptions = nullptr);
485
486
  void PushLine(const wr::LayoutRect& aClip,
487
                bool aIsBackfaceVisible,
488
                const wr::Line& aLine);
489
490
  void PushShadow(const wr::LayoutRect& aBounds,
491
                      const wr::LayoutRect& aClip,
492
                      bool aIsBackfaceVisible,
493
                      const wr::Shadow& aShadow);
494
495
  void PopAllShadows();
496
497
498
499
  void PushBoxShadow(const wr::LayoutRect& aRect,
500
                     const wr::LayoutRect& aClip,
501
                     bool aIsBackfaceVisible,
502
                     const wr::LayoutRect& aBoxBounds,
503
                     const wr::LayoutVector2D& aOffset,
504
                     const wr::ColorF& aColor,
505
                     const float& aBlurRadius,
506
                     const float& aSpreadRadius,
507
                     const wr::BorderRadius& aBorderRadius,
508
                     const wr::BoxShadowClipMode& aClipMode);
509
510
  // Checks to see if the innermost enclosing fixed pos item has the same
511
  // ASR. If so, it returns the scroll target for that fixed-pos item.
512
  // Otherwise, it returns Nothing().
513
  Maybe<layers::FrameMetrics::ViewID> GetContainingFixedPosScrollTarget(const ActiveScrolledRoot* aAsr);
514
515
  // Set the hit-test info to be used for all display items until the next call
516
  // to SetHitTestInfo or ClearHitTestInfo.
517
  void SetHitTestInfo(const layers::FrameMetrics::ViewID& aScrollId,
518
                      gfx::CompositorHitTestInfo aHitInfo);
519
  // Clears the hit-test info so that subsequent display items will not have it.
520
  void ClearHitTestInfo();
521
522
  // Try to avoid using this when possible.
523
0
  wr::WrState* Raw() { return mWrState; }
524
525
  // A chain of RAII objects, each holding a (ASR, ViewID) tuple of data. The
526
  // topmost object is pointed to by the mActiveFixedPosTracker pointer in
527
  // the wr::DisplayListBuilder.
528
  class MOZ_RAII FixedPosScrollTargetTracker {
529
  public:
530
    FixedPosScrollTargetTracker(DisplayListBuilder& aBuilder,
531
                                const ActiveScrolledRoot* aAsr,
532
                                layers::FrameMetrics::ViewID aScrollId);
533
    ~FixedPosScrollTargetTracker();
534
    Maybe<layers::FrameMetrics::ViewID> GetScrollTargetForASR(const ActiveScrolledRoot* aAsr);
535
536
  private:
537
    FixedPosScrollTargetTracker* mParentTracker;
538
    DisplayListBuilder& mBuilder;
539
    const ActiveScrolledRoot* mAsr;
540
    layers::FrameMetrics::ViewID mScrollId;
541
  };
542
543
protected:
544
  wr::LayoutRect MergeClipLeaf(const wr::LayoutRect& aClip)
545
  {
546
    if (mClipChainLeaf) {
547
      return wr::IntersectLayoutRect(*mClipChainLeaf, aClip);
548
    }
549
    return aClip;
550
  }
551
552
  wr::WrState* mWrState;
553
554
  // Track each scroll id that we encountered. We use this structure to
555
  // ensure that we don't define a particular scroll layer multiple times,
556
  // as that results in undefined behaviour in WR.
557
  std::unordered_map<layers::FrameMetrics::ViewID, wr::WrClipId> mScrollIds;
558
559
  // Contains the current leaf of the clip chain to be merged with the
560
  // display item's clip rect when pushing an item. May be set to Nothing() if
561
  // there is no clip rect to merge with.
562
  Maybe<wr::LayoutRect> mClipChainLeaf;
563
564
  FixedPosScrollTargetTracker* mActiveFixedPosTracker;
565
566
  friend class WebRenderAPI;
567
};
568
569
Maybe<wr::ImageFormat>
570
SurfaceFormatToImageFormat(gfx::SurfaceFormat aFormat);
571
572
} // namespace wr
573
} // namespace mozilla
574
575
#endif