2017-01-10 12:17:30 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2017-10-28 02:10:06 +03:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2017-01-10 12:17:30 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef MOZILLA_LAYERS_WEBRENDERAPI_H
|
|
|
|
#define MOZILLA_LAYERS_WEBRENDERAPI_H
|
|
|
|
|
2017-06-08 18:34:00 +03:00
|
|
|
#include <vector>
|
2017-06-16 22:12:24 +03:00
|
|
|
#include <unordered_map>
|
2017-10-24 22:45:58 +03:00
|
|
|
#include <unordered_set>
|
2017-06-08 18:34:00 +03:00
|
|
|
|
2017-01-10 12:17:30 +03:00
|
|
|
#include "mozilla/AlreadyAddRefed.h"
|
2017-11-15 19:39:44 +03:00
|
|
|
#include "mozilla/gfx/CompositorHitTestInfo.h"
|
2017-08-07 13:15:25 +03:00
|
|
|
#include "mozilla/layers/SyncObject.h"
|
2017-01-13 13:25:07 +03:00
|
|
|
#include "mozilla/Range.h"
|
2017-01-17 03:22:01 +03:00
|
|
|
#include "mozilla/webrender/webrender_ffi.h"
|
2017-01-17 03:21:52 +03:00
|
|
|
#include "mozilla/webrender/WebRenderTypes.h"
|
2017-05-12 20:58:09 +03:00
|
|
|
#include "FrameMetrics.h"
|
2017-03-03 18:45:29 +03:00
|
|
|
#include "GLTypes.h"
|
2017-01-16 17:22:47 +03:00
|
|
|
#include "Units.h"
|
2017-01-10 12:17:30 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
Bug 1465935 - Fix hit-testing for fixed-pos items inside iframes. r=mstange
Without this patch, the scrollId for display items inside a fixed-pos
item end as the ASR of the item. In the case of fixed-pos items that are
inside iframes, the ASR is the outer document's root scrollframe. This
means that e.g. wheel-scrolling while over a fixed-pos item inside an
iframe ends up scrolling the outer document's root scrollframe instead
of the iframe's root scrollframe.
In the non-WR codepath, there some APZ machinery that walks up in the
HitTestingTreeNode tree from the hit result, looking to see if that node
has a fixed-pos ancestor, and if so, uses the fixed-pos item's target
APZ as the real hit result. This machinery doesn't exist in WR, because
we don't use the HitTestingTreeNode tree for hit-testing in APZ.
Instead, we need to make sure that the item tag for those display items
already has the appropriate scrollid set.
This patch accomplishes this by introducing a new RAII class that is
pushed into the wr::DisplayListBuilder while we are building display
items inside a nsDisplayFixedPosition, and allows the desired scroll id to
be set on the hit-testing display items.
This behaviour is exercised by test_group_wheelevents, which can now be
enabled with this fix.
MozReview-Commit-ID: L2erPVzJeql
--HG--
extra : rebase_source : 1db630513cb1dc16d4e38649812e81f62c8da99c
2018-06-07 20:06:33 +03:00
|
|
|
struct ActiveScrolledRoot;
|
|
|
|
|
2017-01-10 12:17:30 +03:00
|
|
|
namespace widget {
|
|
|
|
class CompositorWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace layers {
|
2018-04-10 19:29:55 +03:00
|
|
|
class CompositorBridgeParent;
|
2017-06-02 02:07:59 +03:00
|
|
|
class WebRenderBridgeParent;
|
2017-01-17 03:22:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace wr {
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-01-13 13:25:07 +03:00
|
|
|
class DisplayListBuilder;
|
2017-01-10 12:17:30 +03:00
|
|
|
class RendererOGL;
|
2017-01-17 22:46:31 +03:00
|
|
|
class RendererEvent;
|
2017-01-10 12:17:30 +03:00
|
|
|
|
Bug 1357545 - handle text-shadows/decorations with webrender (layers-free) r=jrmuizel
This replaces our DrawTargetCapture hack with a similar but more powerful TextDrawTarget
hack. The old design had several limitations:
* It couldn't handle shadows
* It couldn't handle selections
* It couldn't handle font/color changes in a single text-run
* It couldn't handle decorations (underline, overline, line-through)
Mostly this was a consequence of the fact that it only modified the start and end
of the rendering algorithm, and therefore couldn't distinguish draw calls for different
parts of the text.
This new design is based on a similar principle as DrawTargetCapture, but also passes
down the TextDrawTarget in the drawing arguments, so that the drawing algorithm can
notify us of changes in phase (e.g. "now we're doing underlines"). This also lets us
directly pass data to TextDrawTarget when possible (as is done for shadows and selections).
In doing this, I also improved the logic copied from ContainsOnlyColoredGlyphs to handle
changes in font/color mid-text-run (which can happen because of font fallback).
The end result is:
* We handle all shadows natively
* We handle all selections natively
* We handle all decorations natively
* We handle font/color changes in a single text-run
* Although we still hackily intercept draw calls
* But we don't need to buffer commands, reducing total memcopies
In addition, this change integrates webrender's PushTextShadow and PushLine APIs,
which were designed for this use case. This is only done in the layerless path;
WebrenderTextLayer continues to be semantically limited, as we aren't actively
maintaining non-layers-free webrender anymore.
This also doesn't modify TextLayers, to minimize churn. In theory they can be
augmented to support the richer semantics that TextDrawTarget has, but there's
little motivation since the API is largely unused with this change.
MozReview-Commit-ID: 4IjTsSW335h
--HG--
extra : rebase_source : d69f69648ade5c7a8e6bb756f4b8ab9e2543e576
2017-06-19 17:58:28 +03:00
|
|
|
// This isn't part of WR's API, but we define it here to simplify layout's
|
|
|
|
// logic and data plumbing.
|
|
|
|
struct Line {
|
2017-10-24 19:44:38 +03:00
|
|
|
wr::LayoutRect bounds;
|
|
|
|
float wavyLineThickness;
|
2017-10-25 16:32:17 +03:00
|
|
|
wr::LineOrientation orientation;
|
2017-10-24 19:44:38 +03:00
|
|
|
wr::ColorF color;
|
Bug 1357545 - handle text-shadows/decorations with webrender (layers-free) r=jrmuizel
This replaces our DrawTargetCapture hack with a similar but more powerful TextDrawTarget
hack. The old design had several limitations:
* It couldn't handle shadows
* It couldn't handle selections
* It couldn't handle font/color changes in a single text-run
* It couldn't handle decorations (underline, overline, line-through)
Mostly this was a consequence of the fact that it only modified the start and end
of the rendering algorithm, and therefore couldn't distinguish draw calls for different
parts of the text.
This new design is based on a similar principle as DrawTargetCapture, but also passes
down the TextDrawTarget in the drawing arguments, so that the drawing algorithm can
notify us of changes in phase (e.g. "now we're doing underlines"). This also lets us
directly pass data to TextDrawTarget when possible (as is done for shadows and selections).
In doing this, I also improved the logic copied from ContainsOnlyColoredGlyphs to handle
changes in font/color mid-text-run (which can happen because of font fallback).
The end result is:
* We handle all shadows natively
* We handle all selections natively
* We handle all decorations natively
* We handle font/color changes in a single text-run
* Although we still hackily intercept draw calls
* But we don't need to buffer commands, reducing total memcopies
In addition, this change integrates webrender's PushTextShadow and PushLine APIs,
which were designed for this use case. This is only done in the layerless path;
WebrenderTextLayer continues to be semantically limited, as we aren't actively
maintaining non-layers-free webrender anymore.
This also doesn't modify TextLayers, to minimize churn. In theory they can be
augmented to support the richer semantics that TextDrawTarget has, but there's
little motivation since the API is largely unused with this change.
MozReview-Commit-ID: 4IjTsSW335h
--HG--
extra : rebase_source : d69f69648ade5c7a8e6bb756f4b8ab9e2543e576
2017-06-19 17:58:28 +03:00
|
|
|
wr::LineStyle style;
|
|
|
|
};
|
|
|
|
|
2018-01-29 16:33:39 +03:00
|
|
|
|
|
|
|
class TransactionBuilder {
|
2017-01-10 12:17:30 +03:00
|
|
|
public:
|
2018-05-11 16:09:19 +03:00
|
|
|
explicit TransactionBuilder(bool aUseSceneBuilderThread = true);
|
2018-01-29 16:33:39 +03:00
|
|
|
|
|
|
|
~TransactionBuilder();
|
|
|
|
|
|
|
|
void UpdateEpoch(PipelineId aPipelineId, Epoch aEpoch);
|
|
|
|
|
|
|
|
void SetRootPipeline(PipelineId aPipelineId);
|
|
|
|
|
|
|
|
void RemovePipeline(PipelineId aPipelineId);
|
|
|
|
|
|
|
|
void SetDisplayList(gfx::Color aBgColor,
|
|
|
|
Epoch aEpoch,
|
|
|
|
mozilla::LayerSize aViewportSize,
|
|
|
|
wr::WrPipelineId pipeline_id,
|
|
|
|
const wr::LayoutSize& content_size,
|
|
|
|
wr::BuiltDisplayListDescriptor dl_descriptor,
|
|
|
|
wr::Vec<uint8_t>& dl_data);
|
|
|
|
|
|
|
|
void ClearDisplayList(Epoch aEpoch, wr::WrPipelineId aPipeline);
|
|
|
|
|
|
|
|
void GenerateFrame();
|
|
|
|
|
|
|
|
void UpdateDynamicProperties(const nsTArray<wr::WrOpacityProperty>& aOpacityArray,
|
|
|
|
const nsTArray<wr::WrTransformProperty>& aTransformArray);
|
|
|
|
|
|
|
|
void SetWindowParameters(const LayoutDeviceIntSize& aWindowSize,
|
|
|
|
const LayoutDeviceIntRect& aDocRect);
|
|
|
|
|
|
|
|
void UpdateScrollPosition(const wr::WrPipelineId& aPipelineId,
|
|
|
|
const layers::FrameMetrics::ViewID& aScrollId,
|
|
|
|
const wr::LayoutPoint& aScrollPosition);
|
|
|
|
|
|
|
|
bool IsEmpty() const;
|
2017-01-16 17:22:47 +03:00
|
|
|
|
2017-02-22 21:19:57 +03:00
|
|
|
void AddImage(wr::ImageKey aKey,
|
|
|
|
const ImageDescriptor& aDescriptor,
|
2018-01-04 21:23:34 +03:00
|
|
|
wr::Vec<uint8_t>& aBytes);
|
2017-01-16 17:22:47 +03:00
|
|
|
|
2017-03-27 14:44:52 +03:00
|
|
|
void AddBlobImage(wr::ImageKey aKey,
|
|
|
|
const ImageDescriptor& aDescriptor,
|
2018-01-04 21:23:34 +03:00
|
|
|
wr::Vec<uint8_t>& aBytes);
|
2017-03-27 14:44:52 +03:00
|
|
|
|
2017-03-02 04:22:40 +03:00
|
|
|
void AddExternalImageBuffer(ImageKey key,
|
2017-03-09 05:10:09 +03:00
|
|
|
const ImageDescriptor& aDescriptor,
|
2017-04-19 12:59:53 +03:00
|
|
|
ExternalImageId aHandle);
|
2017-01-16 17:22:47 +03:00
|
|
|
|
2017-05-18 17:59:07 +03:00
|
|
|
void AddExternalImage(ImageKey key,
|
|
|
|
const ImageDescriptor& aDescriptor,
|
|
|
|
ExternalImageId aExtID,
|
2018-01-26 18:09:30 +03:00
|
|
|
wr::WrExternalImageBufferType aBufferType,
|
2017-07-28 15:08:11 +03:00
|
|
|
uint8_t aChannelIndex = 0);
|
2017-05-18 17:59:07 +03:00
|
|
|
|
2017-01-17 03:22:09 +03:00
|
|
|
void UpdateImageBuffer(wr::ImageKey aKey,
|
2017-02-14 21:34:15 +03:00
|
|
|
const ImageDescriptor& aDescriptor,
|
2018-01-04 21:23:34 +03:00
|
|
|
wr::Vec<uint8_t>& aBytes);
|
2017-01-16 17:22:47 +03:00
|
|
|
|
2017-07-28 15:08:11 +03:00
|
|
|
void UpdateBlobImage(wr::ImageKey aKey,
|
|
|
|
const ImageDescriptor& aDescriptor,
|
2018-01-04 21:23:34 +03:00
|
|
|
wr::Vec<uint8_t>& aBytes,
|
2017-08-03 23:38:33 +03:00
|
|
|
const wr::DeviceUintRect& aDirtyRect);
|
2017-07-28 15:08:11 +03:00
|
|
|
|
|
|
|
void UpdateExternalImage(ImageKey aKey,
|
|
|
|
const ImageDescriptor& aDescriptor,
|
|
|
|
ExternalImageId aExtID,
|
|
|
|
wr::WrExternalImageBufferType aBufferType,
|
|
|
|
uint8_t aChannelIndex = 0);
|
|
|
|
|
2018-07-12 18:43:09 +03:00
|
|
|
void UpdateExternalImageWithDirtyRect(ImageKey aKey,
|
|
|
|
const ImageDescriptor& aDescriptor,
|
|
|
|
ExternalImageId aExtID,
|
|
|
|
wr::WrExternalImageBufferType aBufferType,
|
|
|
|
const wr::DeviceUintRect& aDirtyRect,
|
|
|
|
uint8_t aChannelIndex = 0);
|
|
|
|
|
2018-07-19 23:33:05 +03:00
|
|
|
void SetImageVisibleArea(ImageKey aKey, const wr::NormalizedRect& aArea);
|
|
|
|
|
2017-01-17 03:22:09 +03:00
|
|
|
void DeleteImage(wr::ImageKey aKey);
|
2017-01-16 17:22:47 +03:00
|
|
|
|
2018-01-04 21:23:34 +03:00
|
|
|
void AddRawFont(wr::FontKey aKey, wr::Vec<uint8_t>& aBytes, uint32_t aIndex);
|
2017-01-16 17:22:47 +03:00
|
|
|
|
2018-01-04 21:23:34 +03:00
|
|
|
void AddFontDescriptor(wr::FontKey aKey, wr::Vec<uint8_t>& aBytes, uint32_t aIndex);
|
2017-11-07 04:19:46 +03:00
|
|
|
|
2017-01-17 03:22:09 +03:00
|
|
|
void DeleteFont(wr::FontKey aKey);
|
2017-01-16 17:22:47 +03:00
|
|
|
|
2017-08-30 20:45:11 +03:00
|
|
|
void AddFontInstance(wr::FontInstanceKey aKey,
|
|
|
|
wr::FontKey aFontKey,
|
|
|
|
float aGlyphSize,
|
|
|
|
const wr::FontInstanceOptions* aOptions,
|
2017-09-21 06:18:23 +03:00
|
|
|
const wr::FontInstancePlatformOptions* aPlatformOptions,
|
2018-01-04 21:23:34 +03:00
|
|
|
wr::Vec<uint8_t>& aVariations);
|
2017-08-30 20:45:11 +03:00
|
|
|
|
|
|
|
void DeleteFontInstance(wr::FontInstanceKey aKey);
|
|
|
|
|
2017-09-04 14:59:36 +03:00
|
|
|
void Clear();
|
|
|
|
|
2018-05-10 20:05:22 +03:00
|
|
|
bool UseSceneBuilderThread() const { return mUseSceneBuilderThread; }
|
2018-01-12 14:23:59 +03:00
|
|
|
Transaction* Raw() { return mTxn; }
|
|
|
|
protected:
|
2018-05-10 20:05:22 +03:00
|
|
|
bool mUseSceneBuilderThread;
|
2018-01-12 14:23:59 +03:00
|
|
|
Transaction* mTxn;
|
|
|
|
};
|
|
|
|
|
2018-04-17 00:39:26 +03:00
|
|
|
class TransactionWrapper
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit TransactionWrapper(Transaction* aTxn);
|
|
|
|
|
|
|
|
void AppendTransformProperties(const nsTArray<wr::WrTransformProperty>& aTransformArray);
|
|
|
|
void UpdateScrollPosition(const wr::WrPipelineId& aPipelineId,
|
|
|
|
const layers::FrameMetrics::ViewID& aScrollId,
|
|
|
|
const wr::LayoutPoint& aScrollPosition);
|
|
|
|
private:
|
|
|
|
Transaction* mTxn;
|
|
|
|
};
|
|
|
|
|
2017-09-04 14:59:12 +03:00
|
|
|
class WebRenderAPI
|
|
|
|
{
|
2017-12-06 21:36:58 +03:00
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WebRenderAPI);
|
2017-09-04 14:59:12 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
/// This can be called on the compositor thread only.
|
2018-04-10 19:29:55 +03:00
|
|
|
static already_AddRefed<WebRenderAPI> Create(layers::CompositorBridgeParent* aBridge,
|
2017-09-04 14:59:12 +03:00
|
|
|
RefPtr<widget::CompositorWidget>&& aWidget,
|
2018-04-10 19:29:55 +03:00
|
|
|
const wr::WrWindowId& aWindowId,
|
2017-09-04 14:59:12 +03:00
|
|
|
LayoutDeviceIntSize aSize);
|
|
|
|
|
2018-01-29 16:33:35 +03:00
|
|
|
already_AddRefed<WebRenderAPI> CreateDocument(LayoutDeviceIntSize aSize, int8_t aLayerIndex);
|
|
|
|
|
2017-09-04 14:59:12 +03:00
|
|
|
already_AddRefed<WebRenderAPI> Clone();
|
|
|
|
|
|
|
|
wr::WindowId GetId() const { return mId; }
|
|
|
|
|
2017-11-15 19:39:44 +03:00
|
|
|
bool HitTest(const wr::WorldPoint& aPoint,
|
|
|
|
wr::WrPipelineId& aOutPipelineId,
|
|
|
|
layers::FrameMetrics::ViewID& aOutScrollId,
|
|
|
|
gfx::CompositorHitTestInfo& aOutHitInfo);
|
2017-09-04 14:59:12 +03:00
|
|
|
|
2018-01-12 14:23:59 +03:00
|
|
|
void SendTransaction(TransactionBuilder& aTxn);
|
|
|
|
|
2017-07-28 02:05:56 +03:00
|
|
|
void SetFrameStartTime(const TimeStamp& aTime);
|
|
|
|
|
2017-01-28 00:08:17 +03:00
|
|
|
void RunOnRenderThread(UniquePtr<RendererEvent> aEvent);
|
2017-09-04 14:59:12 +03:00
|
|
|
|
2018-06-26 00:37:35 +03:00
|
|
|
void Readback(const TimeStamp& aStartTime, gfx::IntSize aSize, uint8_t *aBuffer, uint32_t aBufferSize);
|
2017-01-17 22:46:31 +03:00
|
|
|
|
2017-04-05 17:12:11 +03:00
|
|
|
void Pause();
|
|
|
|
bool Resume();
|
|
|
|
|
2018-04-10 19:29:55 +03:00
|
|
|
void WakeSceneBuilder();
|
2018-04-27 17:46:21 +03:00
|
|
|
void FlushSceneBuilder();
|
2018-04-10 19:29:55 +03:00
|
|
|
|
2017-06-28 02:20:36 +03:00
|
|
|
wr::WrIdNamespace GetNamespace();
|
2017-08-12 08:41:56 +03:00
|
|
|
uint32_t GetMaxTextureSize() const { return mMaxTextureSize; }
|
2017-02-23 11:46:56 +03:00
|
|
|
bool GetUseANGLE() const { return mUseANGLE; }
|
2018-07-20 16:58:40 +03:00
|
|
|
bool GetUseDComp() const { return mUseDComp; }
|
2017-08-07 13:15:25 +03:00
|
|
|
layers::SyncHandle GetSyncHandle() const { return mSyncHandle; }
|
2017-01-18 22:50:00 +03:00
|
|
|
|
2018-01-26 18:09:30 +03:00
|
|
|
void Capture();
|
|
|
|
|
2017-01-10 12:17:30 +03:00
|
|
|
protected:
|
2018-07-20 16:58:40 +03:00
|
|
|
WebRenderAPI(wr::DocumentHandle* aHandle, wr::WindowId aId, uint32_t aMaxTextureSize, bool aUseANGLE, bool aUseDComp, layers::SyncHandle aSyncHandle)
|
2017-08-09 15:46:24 +03:00
|
|
|
: mDocHandle(aHandle)
|
2017-01-25 00:06:17 +03:00
|
|
|
, mId(aId)
|
|
|
|
, mMaxTextureSize(aMaxTextureSize)
|
2017-02-23 11:46:56 +03:00
|
|
|
, mUseANGLE(aUseANGLE)
|
2018-07-20 16:58:40 +03:00
|
|
|
, mUseDComp(aUseDComp)
|
2017-08-07 13:15:25 +03:00
|
|
|
, mSyncHandle(aSyncHandle)
|
2017-01-10 12:17:30 +03:00
|
|
|
{}
|
|
|
|
|
|
|
|
~WebRenderAPI();
|
2017-03-07 13:37:28 +03:00
|
|
|
// Should be used only for shutdown handling
|
|
|
|
void WaitFlushed();
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-08-09 15:46:24 +03:00
|
|
|
wr::DocumentHandle* mDocHandle;
|
2017-01-17 03:22:09 +03:00
|
|
|
wr::WindowId mId;
|
2017-08-12 08:41:56 +03:00
|
|
|
uint32_t mMaxTextureSize;
|
2017-02-23 11:46:56 +03:00
|
|
|
bool mUseANGLE;
|
2018-07-20 16:58:40 +03:00
|
|
|
bool mUseDComp;
|
2017-08-07 13:15:25 +03:00
|
|
|
layers::SyncHandle mSyncHandle;
|
2018-01-29 16:33:35 +03:00
|
|
|
|
|
|
|
// We maintain alive the root api to know when to shut the render backend down,
|
|
|
|
// and the root api for the document to know when to delete the document.
|
|
|
|
// mRootApi is null for the api object that owns the channel (and is responsible
|
|
|
|
// for shutting it down), and mRootDocumentApi is null for the api object owning
|
|
|
|
// (and responsible for destroying) a given document.
|
|
|
|
// All api objects in the same window use the same channel, and some api objects
|
|
|
|
// write to the same document (but there is only one owner for each channel and
|
|
|
|
// for each document).
|
2017-08-09 15:46:25 +03:00
|
|
|
RefPtr<wr::WebRenderAPI> mRootApi;
|
2018-01-29 16:33:35 +03:00
|
|
|
RefPtr<wr::WebRenderAPI> mRootDocumentApi;
|
2017-01-11 15:51:27 +03:00
|
|
|
|
2017-01-13 13:25:07 +03:00
|
|
|
friend class DisplayListBuilder;
|
2017-06-02 02:07:59 +03:00
|
|
|
friend class layers::WebRenderBridgeParent;
|
2017-01-13 13:25:07 +03:00
|
|
|
};
|
|
|
|
|
2018-05-08 15:49:44 +03:00
|
|
|
// This is a RAII class that automatically sends the transaction on
|
|
|
|
// destruction. This is useful for code that has multiple exit points and we
|
|
|
|
// want to ensure that the stuff accumulated in the transaction gets sent
|
|
|
|
// regardless of which exit we take. Note that if the caller explicitly calls
|
|
|
|
// mApi->SendTransaction() that's fine too because that empties out the
|
|
|
|
// TransactionBuilder and leaves it as a valid empty transaction, so calling
|
|
|
|
// SendTransaction on it again ends up being a no-op.
|
|
|
|
class MOZ_RAII AutoTransactionSender
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AutoTransactionSender(WebRenderAPI* aApi, TransactionBuilder* aTxn)
|
|
|
|
: mApi(aApi)
|
|
|
|
, mTxn(aTxn)
|
|
|
|
{}
|
|
|
|
|
|
|
|
~AutoTransactionSender() {
|
|
|
|
mApi->SendTransaction(*mTxn);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
WebRenderAPI* mApi;
|
|
|
|
TransactionBuilder* mTxn;
|
|
|
|
};
|
|
|
|
|
2017-01-17 17:32:25 +03:00
|
|
|
/// This is a simple C++ wrapper around WrState defined in the rust bindings.
|
2017-01-13 13:25:07 +03:00
|
|
|
/// We may want to turn this into a direct wrapper on top of WebRenderFrameBuilder
|
|
|
|
/// instead, so the interface may change a bit.
|
|
|
|
class DisplayListBuilder {
|
|
|
|
public:
|
2017-05-15 22:13:31 +03:00
|
|
|
explicit DisplayListBuilder(wr::PipelineId aId,
|
2017-10-05 05:31:51 +03:00
|
|
|
const wr::LayoutSize& aContentSize,
|
|
|
|
size_t aCapacity = 0);
|
2017-01-13 13:25:07 +03:00
|
|
|
DisplayListBuilder(DisplayListBuilder&&) = default;
|
|
|
|
|
|
|
|
~DisplayListBuilder();
|
|
|
|
|
2017-10-06 20:06:10 +03:00
|
|
|
void Save();
|
|
|
|
void Restore();
|
|
|
|
void ClearSave();
|
2018-07-19 22:30:30 +03:00
|
|
|
usize Dump(usize aIndent, const Maybe<usize>& aStart, const Maybe<usize>& aEnd);
|
2017-10-06 20:06:10 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void Finalize(wr::LayoutSize& aOutContentSize,
|
2017-05-15 22:13:31 +03:00
|
|
|
wr::BuiltDisplayList& aOutDisplayList);
|
2017-01-13 13:25:07 +03:00
|
|
|
|
2018-05-08 16:16:26 +03:00
|
|
|
Maybe<wr::WrClipId> PushStackingContext(
|
|
|
|
const wr::LayoutRect& aBounds, // TODO: We should work with strongly typed rects
|
|
|
|
const wr::WrClipId* aClipNodeId,
|
|
|
|
const wr::WrAnimationProperty* aAnimation,
|
|
|
|
const float* aOpacity,
|
|
|
|
const gfx::Matrix4x4* aTransform,
|
|
|
|
wr::TransformStyle aTransformStyle,
|
|
|
|
const gfx::Matrix4x4* aPerspective,
|
|
|
|
const wr::MixBlendMode& aMixBlendMode,
|
|
|
|
const nsTArray<wr::WrFilterOp>& aFilters,
|
|
|
|
bool aIsBackfaceVisible,
|
|
|
|
const wr::GlyphRasterSpace& aRasterSpace);
|
2018-05-16 17:47:08 +03:00
|
|
|
void PopStackingContext(bool aIsReferenceFrame);
|
2017-01-13 13:25:07 +03:00
|
|
|
|
2018-05-08 16:08:39 +03:00
|
|
|
wr::WrClipChainId DefineClipChain(const Maybe<wr::WrClipChainId>& aParent,
|
|
|
|
const nsTArray<wr::WrClipId>& aClips);
|
|
|
|
|
|
|
|
wr::WrClipId DefineClip(const Maybe<wr::WrClipId>& aParentId,
|
2017-10-24 22:45:57 +03:00
|
|
|
const wr::LayoutRect& aClipRect,
|
2017-10-04 00:51:49 +03:00
|
|
|
const nsTArray<wr::ComplexClipRegion>* aComplex = nullptr,
|
2017-08-08 22:43:17 +03:00
|
|
|
const wr::WrImageMask* aMask = nullptr);
|
2018-05-08 16:08:39 +03:00
|
|
|
void PushClip(const wr::WrClipId& aClipId);
|
|
|
|
void PopClip();
|
|
|
|
|
|
|
|
wr::WrClipId DefineStickyFrame(const wr::LayoutRect& aContentRect,
|
|
|
|
const float* aTopMargin,
|
|
|
|
const float* aRightMargin,
|
|
|
|
const float* aBottomMargin,
|
|
|
|
const float* aLeftMargin,
|
|
|
|
const StickyOffsetBounds& aVerticalBounds,
|
|
|
|
const StickyOffsetBounds& aHorizontalBounds,
|
|
|
|
const wr::LayoutVector2D& aAppliedOffset);
|
|
|
|
|
|
|
|
Maybe<wr::WrClipId> GetScrollIdForDefinedScrollLayer(layers::FrameMetrics::ViewID aViewId) const;
|
|
|
|
wr::WrClipId DefineScrollLayer(const layers::FrameMetrics::ViewID& aViewId,
|
|
|
|
const Maybe<wr::WrClipId>& aParentId,
|
|
|
|
const wr::LayoutRect& aContentRect, // TODO: We should work with strongly typed rects
|
|
|
|
const wr::LayoutRect& aClipRect);
|
|
|
|
|
|
|
|
void PushClipAndScrollInfo(const wr::WrClipId& aScrollId,
|
|
|
|
const wr::WrClipChainId* aClipChainId);
|
2017-06-08 18:34:01 +03:00
|
|
|
void PopClipAndScrollInfo();
|
2017-02-14 21:34:15 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void PushRect(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::ColorF& aColor);
|
2017-01-13 13:25:07 +03:00
|
|
|
|
2017-10-31 18:31:00 +03:00
|
|
|
void PushClearRect(const wr::LayoutRect& aBounds);
|
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void PushLinearGradient(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::LayoutPoint& aStartPoint,
|
|
|
|
const wr::LayoutPoint& aEndPoint,
|
2017-07-19 08:47:07 +03:00
|
|
|
const nsTArray<wr::GradientStop>& aStops,
|
|
|
|
wr::ExtendMode aExtendMode,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::LayoutSize aTileSize,
|
|
|
|
const wr::LayoutSize aTileSpacing);
|
2017-06-28 02:20:36 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void PushRadialGradient(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::LayoutPoint& aCenter,
|
|
|
|
const wr::LayoutSize& aRadius,
|
2017-07-19 08:47:07 +03:00
|
|
|
const nsTArray<wr::GradientStop>& aStops,
|
|
|
|
wr::ExtendMode aExtendMode,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::LayoutSize aTileSize,
|
|
|
|
const wr::LayoutSize aTileSpacing);
|
2017-02-17 03:51:32 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void PushImage(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2017-02-14 21:34:15 +03:00
|
|
|
wr::ImageRendering aFilter,
|
2018-01-17 20:55:40 +03:00
|
|
|
wr::ImageKey aImage,
|
|
|
|
bool aPremultipliedAlpha = true);
|
2017-01-13 13:25:07 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void PushImage(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::LayoutSize& aStretchSize,
|
|
|
|
const wr::LayoutSize& aTileSpacing,
|
2017-04-07 09:53:16 +03:00
|
|
|
wr::ImageRendering aFilter,
|
2018-01-17 20:55:40 +03:00
|
|
|
wr::ImageKey aImage,
|
|
|
|
bool aPremultipliedAlpha = true);
|
2017-04-07 09:53:16 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void PushYCbCrPlanarImage(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2017-04-29 00:00:57 +03:00
|
|
|
wr::ImageKey aImageChannel0,
|
|
|
|
wr::ImageKey aImageChannel1,
|
|
|
|
wr::ImageKey aImageChannel2,
|
2017-06-28 02:20:36 +03:00
|
|
|
wr::WrYuvColorSpace aColorSpace,
|
2017-06-01 15:57:10 +03:00
|
|
|
wr::ImageRendering aFilter);
|
2017-04-29 00:00:57 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void PushNV12Image(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2017-04-29 00:00:57 +03:00
|
|
|
wr::ImageKey aImageChannel0,
|
|
|
|
wr::ImageKey aImageChannel1,
|
2017-06-28 02:20:36 +03:00
|
|
|
wr::WrYuvColorSpace aColorSpace,
|
2017-06-01 15:57:10 +03:00
|
|
|
wr::ImageRendering aFilter);
|
2017-04-29 00:00:57 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void PushYCbCrInterleavedImage(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2017-05-18 17:59:07 +03:00
|
|
|
wr::ImageKey aImageChannel0,
|
2017-06-28 02:20:36 +03:00
|
|
|
wr::WrYuvColorSpace aColorSpace,
|
2017-06-01 15:57:10 +03:00
|
|
|
wr::ImageRendering aFilter);
|
2017-05-18 17:59:07 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void PushIFrame(const wr::LayoutRect& aBounds,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2018-05-18 17:31:18 +03:00
|
|
|
wr::PipelineId aPipeline,
|
|
|
|
bool aIgnoreMissingPipeline);
|
2017-01-13 13:25:07 +03:00
|
|
|
|
2017-07-01 02:22:25 +03:00
|
|
|
// XXX WrBorderSides are passed with Range.
|
|
|
|
// It is just to bypass compiler bug. See Bug 1357734.
|
2017-07-19 01:32:46 +03:00
|
|
|
void PushBorder(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2017-07-19 08:56:20 +03:00
|
|
|
const wr::BorderWidths& aWidths,
|
|
|
|
const Range<const wr::BorderSide>& aSides,
|
|
|
|
const wr::BorderRadius& aRadius);
|
2017-06-28 02:20:36 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void PushBorderImage(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2017-07-19 08:56:20 +03:00
|
|
|
const wr::BorderWidths& aWidths,
|
2017-03-13 06:46:03 +03:00
|
|
|
wr::ImageKey aImage,
|
2018-05-08 17:36:23 +03:00
|
|
|
const uint32_t aWidth,
|
|
|
|
const uint32_t aHeight,
|
|
|
|
const wr::SideOffsets2D<uint32_t>& aSlice,
|
2018-01-04 21:23:34 +03:00
|
|
|
const wr::SideOffsets2D<float>& aOutset,
|
2017-07-19 08:56:20 +03:00
|
|
|
const wr::RepeatMode& aRepeatHorizontal,
|
|
|
|
const wr::RepeatMode& aRepeatVertical);
|
2017-06-28 02:20:36 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void PushBorderGradient(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2017-07-19 08:56:20 +03:00
|
|
|
const wr::BorderWidths& aWidths,
|
2018-06-14 01:40:13 +03:00
|
|
|
const uint32_t aWidth,
|
|
|
|
const uint32_t aHeight,
|
|
|
|
const wr::SideOffsets2D<uint32_t>& aSlice,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::LayoutPoint& aStartPoint,
|
|
|
|
const wr::LayoutPoint& aEndPoint,
|
2017-07-19 08:47:07 +03:00
|
|
|
const nsTArray<wr::GradientStop>& aStops,
|
|
|
|
wr::ExtendMode aExtendMode,
|
2018-01-04 21:23:34 +03:00
|
|
|
const wr::SideOffsets2D<float>& aOutset);
|
2017-06-28 02:20:36 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void PushBorderRadialGradient(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2017-07-19 08:56:20 +03:00
|
|
|
const wr::BorderWidths& aWidths,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::LayoutPoint& aCenter,
|
|
|
|
const wr::LayoutSize& aRadius,
|
2017-07-19 08:47:07 +03:00
|
|
|
const nsTArray<wr::GradientStop>& aStops,
|
|
|
|
wr::ExtendMode aExtendMode,
|
2018-01-04 21:23:34 +03:00
|
|
|
const wr::SideOffsets2D<float>& aOutset);
|
2017-04-10 12:27:30 +03:00
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void PushText(const wr::LayoutRect& aBounds,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2017-10-04 20:49:51 +03:00
|
|
|
const wr::ColorF& aColor,
|
2017-08-30 20:45:11 +03:00
|
|
|
wr::FontInstanceKey aFontKey,
|
2017-07-19 01:53:09 +03:00
|
|
|
Range<const wr::GlyphInstance> aGlyphBuffer,
|
2017-08-30 20:45:11 +03:00
|
|
|
const wr::GlyphOptions* aGlyphOptions = nullptr);
|
2017-01-13 13:25:07 +03:00
|
|
|
|
Bug 1357545 - handle text-shadows/decorations with webrender (layers-free) r=jrmuizel
This replaces our DrawTargetCapture hack with a similar but more powerful TextDrawTarget
hack. The old design had several limitations:
* It couldn't handle shadows
* It couldn't handle selections
* It couldn't handle font/color changes in a single text-run
* It couldn't handle decorations (underline, overline, line-through)
Mostly this was a consequence of the fact that it only modified the start and end
of the rendering algorithm, and therefore couldn't distinguish draw calls for different
parts of the text.
This new design is based on a similar principle as DrawTargetCapture, but also passes
down the TextDrawTarget in the drawing arguments, so that the drawing algorithm can
notify us of changes in phase (e.g. "now we're doing underlines"). This also lets us
directly pass data to TextDrawTarget when possible (as is done for shadows and selections).
In doing this, I also improved the logic copied from ContainsOnlyColoredGlyphs to handle
changes in font/color mid-text-run (which can happen because of font fallback).
The end result is:
* We handle all shadows natively
* We handle all selections natively
* We handle all decorations natively
* We handle font/color changes in a single text-run
* Although we still hackily intercept draw calls
* But we don't need to buffer commands, reducing total memcopies
In addition, this change integrates webrender's PushTextShadow and PushLine APIs,
which were designed for this use case. This is only done in the layerless path;
WebrenderTextLayer continues to be semantically limited, as we aren't actively
maintaining non-layers-free webrender anymore.
This also doesn't modify TextLayers, to minimize churn. In theory they can be
augmented to support the richer semantics that TextDrawTarget has, but there's
little motivation since the API is largely unused with this change.
MozReview-Commit-ID: 4IjTsSW335h
--HG--
extra : rebase_source : d69f69648ade5c7a8e6bb756f4b8ab9e2543e576
2017-06-19 17:58:28 +03:00
|
|
|
void PushLine(const wr::LayoutRect& aClip,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
Bug 1357545 - handle text-shadows/decorations with webrender (layers-free) r=jrmuizel
This replaces our DrawTargetCapture hack with a similar but more powerful TextDrawTarget
hack. The old design had several limitations:
* It couldn't handle shadows
* It couldn't handle selections
* It couldn't handle font/color changes in a single text-run
* It couldn't handle decorations (underline, overline, line-through)
Mostly this was a consequence of the fact that it only modified the start and end
of the rendering algorithm, and therefore couldn't distinguish draw calls for different
parts of the text.
This new design is based on a similar principle as DrawTargetCapture, but also passes
down the TextDrawTarget in the drawing arguments, so that the drawing algorithm can
notify us of changes in phase (e.g. "now we're doing underlines"). This also lets us
directly pass data to TextDrawTarget when possible (as is done for shadows and selections).
In doing this, I also improved the logic copied from ContainsOnlyColoredGlyphs to handle
changes in font/color mid-text-run (which can happen because of font fallback).
The end result is:
* We handle all shadows natively
* We handle all selections natively
* We handle all decorations natively
* We handle font/color changes in a single text-run
* Although we still hackily intercept draw calls
* But we don't need to buffer commands, reducing total memcopies
In addition, this change integrates webrender's PushTextShadow and PushLine APIs,
which were designed for this use case. This is only done in the layerless path;
WebrenderTextLayer continues to be semantically limited, as we aren't actively
maintaining non-layers-free webrender anymore.
This also doesn't modify TextLayers, to minimize churn. In theory they can be
augmented to support the richer semantics that TextDrawTarget has, but there's
little motivation since the API is largely unused with this change.
MozReview-Commit-ID: 4IjTsSW335h
--HG--
extra : rebase_source : d69f69648ade5c7a8e6bb756f4b8ab9e2543e576
2017-06-19 17:58:28 +03:00
|
|
|
const wr::Line& aLine);
|
|
|
|
|
2017-10-04 21:54:37 +03:00
|
|
|
void PushShadow(const wr::LayoutRect& aBounds,
|
Bug 1357545 - handle text-shadows/decorations with webrender (layers-free) r=jrmuizel
This replaces our DrawTargetCapture hack with a similar but more powerful TextDrawTarget
hack. The old design had several limitations:
* It couldn't handle shadows
* It couldn't handle selections
* It couldn't handle font/color changes in a single text-run
* It couldn't handle decorations (underline, overline, line-through)
Mostly this was a consequence of the fact that it only modified the start and end
of the rendering algorithm, and therefore couldn't distinguish draw calls for different
parts of the text.
This new design is based on a similar principle as DrawTargetCapture, but also passes
down the TextDrawTarget in the drawing arguments, so that the drawing algorithm can
notify us of changes in phase (e.g. "now we're doing underlines"). This also lets us
directly pass data to TextDrawTarget when possible (as is done for shadows and selections).
In doing this, I also improved the logic copied from ContainsOnlyColoredGlyphs to handle
changes in font/color mid-text-run (which can happen because of font fallback).
The end result is:
* We handle all shadows natively
* We handle all selections natively
* We handle all decorations natively
* We handle font/color changes in a single text-run
* Although we still hackily intercept draw calls
* But we don't need to buffer commands, reducing total memcopies
In addition, this change integrates webrender's PushTextShadow and PushLine APIs,
which were designed for this use case. This is only done in the layerless path;
WebrenderTextLayer continues to be semantically limited, as we aren't actively
maintaining non-layers-free webrender anymore.
This also doesn't modify TextLayers, to minimize churn. In theory they can be
augmented to support the richer semantics that TextDrawTarget has, but there's
little motivation since the API is largely unused with this change.
MozReview-Commit-ID: 4IjTsSW335h
--HG--
extra : rebase_source : d69f69648ade5c7a8e6bb756f4b8ab9e2543e576
2017-06-19 17:58:28 +03:00
|
|
|
const wr::LayoutRect& aClip,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2017-10-04 21:54:37 +03:00
|
|
|
const wr::Shadow& aShadow);
|
Bug 1357545 - handle text-shadows/decorations with webrender (layers-free) r=jrmuizel
This replaces our DrawTargetCapture hack with a similar but more powerful TextDrawTarget
hack. The old design had several limitations:
* It couldn't handle shadows
* It couldn't handle selections
* It couldn't handle font/color changes in a single text-run
* It couldn't handle decorations (underline, overline, line-through)
Mostly this was a consequence of the fact that it only modified the start and end
of the rendering algorithm, and therefore couldn't distinguish draw calls for different
parts of the text.
This new design is based on a similar principle as DrawTargetCapture, but also passes
down the TextDrawTarget in the drawing arguments, so that the drawing algorithm can
notify us of changes in phase (e.g. "now we're doing underlines"). This also lets us
directly pass data to TextDrawTarget when possible (as is done for shadows and selections).
In doing this, I also improved the logic copied from ContainsOnlyColoredGlyphs to handle
changes in font/color mid-text-run (which can happen because of font fallback).
The end result is:
* We handle all shadows natively
* We handle all selections natively
* We handle all decorations natively
* We handle font/color changes in a single text-run
* Although we still hackily intercept draw calls
* But we don't need to buffer commands, reducing total memcopies
In addition, this change integrates webrender's PushTextShadow and PushLine APIs,
which were designed for this use case. This is only done in the layerless path;
WebrenderTextLayer continues to be semantically limited, as we aren't actively
maintaining non-layers-free webrender anymore.
This also doesn't modify TextLayers, to minimize churn. In theory they can be
augmented to support the richer semantics that TextDrawTarget has, but there's
little motivation since the API is largely unused with this change.
MozReview-Commit-ID: 4IjTsSW335h
--HG--
extra : rebase_source : d69f69648ade5c7a8e6bb756f4b8ab9e2543e576
2017-06-19 17:58:28 +03:00
|
|
|
|
2017-10-13 19:58:32 +03:00
|
|
|
void PopAllShadows();
|
Bug 1357545 - handle text-shadows/decorations with webrender (layers-free) r=jrmuizel
This replaces our DrawTargetCapture hack with a similar but more powerful TextDrawTarget
hack. The old design had several limitations:
* It couldn't handle shadows
* It couldn't handle selections
* It couldn't handle font/color changes in a single text-run
* It couldn't handle decorations (underline, overline, line-through)
Mostly this was a consequence of the fact that it only modified the start and end
of the rendering algorithm, and therefore couldn't distinguish draw calls for different
parts of the text.
This new design is based on a similar principle as DrawTargetCapture, but also passes
down the TextDrawTarget in the drawing arguments, so that the drawing algorithm can
notify us of changes in phase (e.g. "now we're doing underlines"). This also lets us
directly pass data to TextDrawTarget when possible (as is done for shadows and selections).
In doing this, I also improved the logic copied from ContainsOnlyColoredGlyphs to handle
changes in font/color mid-text-run (which can happen because of font fallback).
The end result is:
* We handle all shadows natively
* We handle all selections natively
* We handle all decorations natively
* We handle font/color changes in a single text-run
* Although we still hackily intercept draw calls
* But we don't need to buffer commands, reducing total memcopies
In addition, this change integrates webrender's PushTextShadow and PushLine APIs,
which were designed for this use case. This is only done in the layerless path;
WebrenderTextLayer continues to be semantically limited, as we aren't actively
maintaining non-layers-free webrender anymore.
This also doesn't modify TextLayers, to minimize churn. In theory they can be
augmented to support the richer semantics that TextDrawTarget has, but there's
little motivation since the API is largely unused with this change.
MozReview-Commit-ID: 4IjTsSW335h
--HG--
extra : rebase_source : d69f69648ade5c7a8e6bb756f4b8ab9e2543e576
2017-06-19 17:58:28 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
2017-07-19 01:32:46 +03:00
|
|
|
void PushBoxShadow(const wr::LayoutRect& aRect,
|
|
|
|
const wr::LayoutRect& aClip,
|
2017-09-21 09:41:38 +03:00
|
|
|
bool aIsBackfaceVisible,
|
2017-07-19 01:32:46 +03:00
|
|
|
const wr::LayoutRect& aBoxBounds,
|
|
|
|
const wr::LayoutVector2D& aOffset,
|
|
|
|
const wr::ColorF& aColor,
|
2017-02-16 21:23:22 +03:00
|
|
|
const float& aBlurRadius,
|
|
|
|
const float& aSpreadRadius,
|
2017-10-24 09:44:29 +03:00
|
|
|
const wr::BorderRadius& aBorderRadius,
|
2017-07-19 10:28:58 +03:00
|
|
|
const wr::BoxShadowClipMode& aClipMode);
|
2017-02-16 21:23:22 +03:00
|
|
|
|
Bug 1465935 - Fix hit-testing for fixed-pos items inside iframes. r=mstange
Without this patch, the scrollId for display items inside a fixed-pos
item end as the ASR of the item. In the case of fixed-pos items that are
inside iframes, the ASR is the outer document's root scrollframe. This
means that e.g. wheel-scrolling while over a fixed-pos item inside an
iframe ends up scrolling the outer document's root scrollframe instead
of the iframe's root scrollframe.
In the non-WR codepath, there some APZ machinery that walks up in the
HitTestingTreeNode tree from the hit result, looking to see if that node
has a fixed-pos ancestor, and if so, uses the fixed-pos item's target
APZ as the real hit result. This machinery doesn't exist in WR, because
we don't use the HitTestingTreeNode tree for hit-testing in APZ.
Instead, we need to make sure that the item tag for those display items
already has the appropriate scrollid set.
This patch accomplishes this by introducing a new RAII class that is
pushed into the wr::DisplayListBuilder while we are building display
items inside a nsDisplayFixedPosition, and allows the desired scroll id to
be set on the hit-testing display items.
This behaviour is exercised by test_group_wheelevents, which can now be
enabled with this fix.
MozReview-Commit-ID: L2erPVzJeql
--HG--
extra : rebase_source : 1db630513cb1dc16d4e38649812e81f62c8da99c
2018-06-07 20:06:33 +03:00
|
|
|
// Checks to see if the innermost enclosing fixed pos item has the same
|
|
|
|
// ASR. If so, it returns the scroll target for that fixed-pos item.
|
|
|
|
// Otherwise, it returns Nothing().
|
|
|
|
Maybe<layers::FrameMetrics::ViewID> GetContainingFixedPosScrollTarget(const ActiveScrolledRoot* aAsr);
|
|
|
|
|
2017-11-15 19:39:44 +03:00
|
|
|
// Set the hit-test info to be used for all display items until the next call
|
|
|
|
// to SetHitTestInfo or ClearHitTestInfo.
|
|
|
|
void SetHitTestInfo(const layers::FrameMetrics::ViewID& aScrollId,
|
|
|
|
gfx::CompositorHitTestInfo aHitInfo);
|
|
|
|
// Clears the hit-test info so that subsequent display items will not have it.
|
|
|
|
void ClearHitTestInfo();
|
|
|
|
|
2017-01-13 13:25:07 +03:00
|
|
|
// Try to avoid using this when possible.
|
2017-06-28 02:20:36 +03:00
|
|
|
wr::WrState* Raw() { return mWrState; }
|
2017-09-19 12:05:22 +03:00
|
|
|
|
Bug 1465935 - Fix hit-testing for fixed-pos items inside iframes. r=mstange
Without this patch, the scrollId for display items inside a fixed-pos
item end as the ASR of the item. In the case of fixed-pos items that are
inside iframes, the ASR is the outer document's root scrollframe. This
means that e.g. wheel-scrolling while over a fixed-pos item inside an
iframe ends up scrolling the outer document's root scrollframe instead
of the iframe's root scrollframe.
In the non-WR codepath, there some APZ machinery that walks up in the
HitTestingTreeNode tree from the hit result, looking to see if that node
has a fixed-pos ancestor, and if so, uses the fixed-pos item's target
APZ as the real hit result. This machinery doesn't exist in WR, because
we don't use the HitTestingTreeNode tree for hit-testing in APZ.
Instead, we need to make sure that the item tag for those display items
already has the appropriate scrollid set.
This patch accomplishes this by introducing a new RAII class that is
pushed into the wr::DisplayListBuilder while we are building display
items inside a nsDisplayFixedPosition, and allows the desired scroll id to
be set on the hit-testing display items.
This behaviour is exercised by test_group_wheelevents, which can now be
enabled with this fix.
MozReview-Commit-ID: L2erPVzJeql
--HG--
extra : rebase_source : 1db630513cb1dc16d4e38649812e81f62c8da99c
2018-06-07 20:06:33 +03:00
|
|
|
// A chain of RAII objects, each holding a (ASR, ViewID) tuple of data. The
|
|
|
|
// topmost object is pointed to by the mActiveFixedPosTracker pointer in
|
|
|
|
// the wr::DisplayListBuilder.
|
|
|
|
class MOZ_RAII FixedPosScrollTargetTracker {
|
|
|
|
public:
|
|
|
|
FixedPosScrollTargetTracker(DisplayListBuilder& aBuilder,
|
|
|
|
const ActiveScrolledRoot* aAsr,
|
|
|
|
layers::FrameMetrics::ViewID aScrollId);
|
|
|
|
~FixedPosScrollTargetTracker();
|
|
|
|
Maybe<layers::FrameMetrics::ViewID> GetScrollTargetForASR(const ActiveScrolledRoot* aAsr);
|
|
|
|
|
|
|
|
private:
|
|
|
|
FixedPosScrollTargetTracker* mParentTracker;
|
|
|
|
DisplayListBuilder& mBuilder;
|
|
|
|
const ActiveScrolledRoot* mAsr;
|
|
|
|
layers::FrameMetrics::ViewID mScrollId;
|
|
|
|
};
|
|
|
|
|
2017-01-13 13:25:07 +03:00
|
|
|
protected:
|
2017-06-28 02:20:36 +03:00
|
|
|
wr::WrState* mWrState;
|
2017-01-16 17:22:47 +03:00
|
|
|
|
2017-10-24 22:45:58 +03:00
|
|
|
// Track each scroll id that we encountered. We use this structure to
|
|
|
|
// ensure that we don't define a particular scroll layer multiple times,
|
|
|
|
// as that results in undefined behaviour in WR.
|
2018-05-08 16:08:39 +03:00
|
|
|
std::unordered_map<layers::FrameMetrics::ViewID, wr::WrClipId> mScrollIds;
|
2017-09-19 12:05:22 +03:00
|
|
|
|
Bug 1465935 - Fix hit-testing for fixed-pos items inside iframes. r=mstange
Without this patch, the scrollId for display items inside a fixed-pos
item end as the ASR of the item. In the case of fixed-pos items that are
inside iframes, the ASR is the outer document's root scrollframe. This
means that e.g. wheel-scrolling while over a fixed-pos item inside an
iframe ends up scrolling the outer document's root scrollframe instead
of the iframe's root scrollframe.
In the non-WR codepath, there some APZ machinery that walks up in the
HitTestingTreeNode tree from the hit result, looking to see if that node
has a fixed-pos ancestor, and if so, uses the fixed-pos item's target
APZ as the real hit result. This machinery doesn't exist in WR, because
we don't use the HitTestingTreeNode tree for hit-testing in APZ.
Instead, we need to make sure that the item tag for those display items
already has the appropriate scrollid set.
This patch accomplishes this by introducing a new RAII class that is
pushed into the wr::DisplayListBuilder while we are building display
items inside a nsDisplayFixedPosition, and allows the desired scroll id to
be set on the hit-testing display items.
This behaviour is exercised by test_group_wheelevents, which can now be
enabled with this fix.
MozReview-Commit-ID: L2erPVzJeql
--HG--
extra : rebase_source : 1db630513cb1dc16d4e38649812e81f62c8da99c
2018-06-07 20:06:33 +03:00
|
|
|
FixedPosScrollTargetTracker* mActiveFixedPosTracker;
|
|
|
|
|
2017-01-16 17:22:47 +03:00
|
|
|
friend class WebRenderAPI;
|
2017-01-10 12:17:30 +03:00
|
|
|
};
|
|
|
|
|
2017-07-19 10:28:58 +03:00
|
|
|
Maybe<wr::ImageFormat>
|
|
|
|
SurfaceFormatToImageFormat(gfx::SurfaceFormat aFormat);
|
2017-01-17 23:13:41 +03:00
|
|
|
|
2017-01-25 00:06:17 +03:00
|
|
|
} // namespace wr
|
|
|
|
} // namespace mozilla
|
2017-01-10 12:17:30 +03:00
|
|
|
|
2017-01-24 16:44:23 +03:00
|
|
|
#endif
|