2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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 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 TextDrawTarget_h
|
|
|
|
#define TextDrawTarget_h
|
|
|
|
|
|
|
|
#include "mozilla/gfx/2D.h"
|
2019-01-08 00:33:10 +03:00
|
|
|
#include "mozilla/layers/RenderRootStateManager.h"
|
2017-09-21 22:15:58 +03:00
|
|
|
#include "mozilla/layers/WebRenderLayerManager.h"
|
|
|
|
#include "mozilla/layers/WebRenderBridgeChild.h"
|
|
|
|
#include "mozilla/webrender/WebRenderAPI.h"
|
|
|
|
#include "mozilla/layers/StackingContextHelper.h"
|
2018-08-21 19:36:48 +03:00
|
|
|
#include "mozilla/layers/IpcResourceUpdateQueue.h"
|
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
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layout {
|
|
|
|
|
|
|
|
using namespace gfx;
|
|
|
|
|
|
|
|
// This class is fake DrawTarget, used to intercept text draw calls, while
|
|
|
|
// also collecting up the other aspects of text natively.
|
|
|
|
//
|
|
|
|
// When using advanced-layers in nsDisplayText's constructor, we construct this
|
|
|
|
// and run the full painting algorithm with this as the DrawTarget. This is
|
|
|
|
// done to avoid having to massively refactor gecko's text painting code (which
|
|
|
|
// has lots of components shared between other rendering algorithms).
|
|
|
|
//
|
|
|
|
// In some phases of the painting algorithm, we can grab the relevant values
|
|
|
|
// and feed them directly into TextDrawTarget. For instance, selections,
|
|
|
|
// decorations, and shadows are handled in this manner. In those cases we can
|
|
|
|
// also short-circuit the painting algorithm to save work.
|
|
|
|
//
|
|
|
|
// In other phases, the computed values are sufficiently buried in complex
|
|
|
|
// code that it's best for us to just intercept the final draw calls. This
|
|
|
|
// is how we handle computing the glyphs of the main text and text-emphasis
|
|
|
|
// (see our overloaded FillGlyphs implementation).
|
|
|
|
//
|
|
|
|
// To be clear: this is a big hack. With time we hope to refactor the codebase
|
|
|
|
// so that all the elements of text are handled directly by TextDrawTarget,
|
|
|
|
// which is to say everything is done like we do selections and shadows now.
|
|
|
|
// This design is a good step for doing this work incrementally.
|
|
|
|
//
|
|
|
|
// This is also likely to be a bit buggy (missing or misinterpreted info)
|
|
|
|
// while we further develop the design.
|
|
|
|
//
|
2017-10-06 20:06:10 +03:00
|
|
|
// TextDrawTarget doesn't yet support all features. See mHasUnsupportedFeatures
|
|
|
|
// for details.
|
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
|
|
|
class TextDrawTarget : public DrawTarget {
|
|
|
|
public:
|
2017-10-06 20:06:10 +03:00
|
|
|
explicit TextDrawTarget(wr::DisplayListBuilder& aBuilder,
|
2018-08-21 19:36:48 +03:00
|
|
|
wr::IpcResourceUpdateQueue& aResources,
|
2017-10-06 20:06:10 +03:00
|
|
|
const layers::StackingContextHelper& aSc,
|
2019-01-08 00:33:10 +03:00
|
|
|
layers::RenderRootStateManager* aManager,
|
2018-12-12 05:48:33 +03:00
|
|
|
nsDisplayItem* aItem, nsRect& aBounds,
|
|
|
|
bool aCallerDoesSaveRestore = false)
|
|
|
|
: mCallerDoesSaveRestore(aCallerDoesSaveRestore), mBuilder(aBuilder) {
|
2018-11-26 01:57:04 +03:00
|
|
|
Reinitialize(aResources, aSc, aManager, aItem, aBounds);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Prevent this from being copied
|
|
|
|
TextDrawTarget(const TextDrawTarget& src) = delete;
|
|
|
|
TextDrawTarget& operator=(const TextDrawTarget&) = delete;
|
|
|
|
|
2018-12-12 05:48:33 +03:00
|
|
|
~TextDrawTarget() { MOZ_ASSERT(mFinished); }
|
2018-11-26 01:57:04 +03:00
|
|
|
|
|
|
|
void Reinitialize(wr::IpcResourceUpdateQueue& aResources,
|
|
|
|
const layers::StackingContextHelper& aSc,
|
2019-01-08 00:33:10 +03:00
|
|
|
layers::RenderRootStateManager* aManager,
|
2018-11-26 01:57:04 +03:00
|
|
|
nsDisplayItem* aItem, nsRect& aBounds) {
|
|
|
|
mResources = &aResources;
|
|
|
|
mSc = &aSc;
|
|
|
|
mManager = aManager;
|
|
|
|
mHasUnsupportedFeatures = false;
|
|
|
|
mHasShadows = false;
|
|
|
|
|
2017-10-20 05:54:28 +03:00
|
|
|
SetPermitSubpixelAA(!aItem->IsSubpixelAADisabled());
|
2017-10-06 20:06:10 +03:00
|
|
|
|
|
|
|
// Compute clip/bounds
|
|
|
|
auto appUnitsPerDevPixel =
|
|
|
|
aItem->Frame()->PresContext()->AppUnitsPerDevPixel();
|
|
|
|
LayoutDeviceRect layoutBoundsRect =
|
|
|
|
LayoutDeviceRect::FromAppUnits(aBounds, appUnitsPerDevPixel);
|
|
|
|
LayoutDeviceRect layoutClipRect = layoutBoundsRect;
|
2018-03-30 00:57:43 +03:00
|
|
|
mBoundsRect = wr::ToRoundedLayoutRect(layoutBoundsRect);
|
2018-01-08 05:59:01 +03:00
|
|
|
|
|
|
|
// Add 1 pixel of dirty area around clip rect to allow us to paint
|
|
|
|
// antialiased pixels beyond the measured text extents.
|
|
|
|
layoutClipRect.Inflate(1);
|
2018-04-17 06:05:48 +03:00
|
|
|
mSize = IntSize::Ceil(layoutClipRect.Width(), layoutClipRect.Height());
|
2018-11-26 01:57:04 +03:00
|
|
|
mClipStack.ClearAndRetainStorage();
|
2018-01-16 12:54:57 +03:00
|
|
|
mClipStack.AppendElement(layoutClipRect);
|
2017-10-06 20:06:10 +03:00
|
|
|
|
|
|
|
mBackfaceVisible = !aItem->BackfaceIsHidden();
|
|
|
|
|
2018-12-12 05:48:33 +03:00
|
|
|
if (!mCallerDoesSaveRestore) {
|
|
|
|
mBuilder.Save();
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2018-11-26 01:57:04 +03:00
|
|
|
void FoundUnsupportedFeature() { mHasUnsupportedFeatures = true; }
|
2018-12-12 05:48:33 +03:00
|
|
|
bool CheckHasUnsupportedFeatures() {
|
|
|
|
MOZ_ASSERT(mCallerDoesSaveRestore);
|
|
|
|
#ifdef DEBUG
|
|
|
|
MOZ_ASSERT(!mFinished);
|
|
|
|
mFinished = true;
|
|
|
|
#endif
|
|
|
|
return mHasUnsupportedFeatures;
|
|
|
|
}
|
2018-11-26 01:57:04 +03:00
|
|
|
|
|
|
|
bool Finish() {
|
2018-12-12 05:48:33 +03:00
|
|
|
MOZ_ASSERT(!mCallerDoesSaveRestore);
|
|
|
|
#ifdef DEBUG
|
|
|
|
mFinished = true;
|
|
|
|
#endif
|
2017-10-06 20:06:10 +03:00
|
|
|
if (mHasUnsupportedFeatures) {
|
|
|
|
mBuilder.Restore();
|
2018-11-26 01:57:04 +03:00
|
|
|
return false;
|
2017-09-12 23:50:44 +03:00
|
|
|
}
|
2018-11-26 01:57:04 +03:00
|
|
|
mBuilder.ClearSave();
|
|
|
|
return true;
|
2017-09-12 23:50:44 +03:00
|
|
|
}
|
|
|
|
|
2018-01-17 15:51:20 +03:00
|
|
|
wr::FontInstanceFlags GetWRGlyphFlags() const { return mWRGlyphFlags; }
|
|
|
|
void SetWRGlyphFlags(wr::FontInstanceFlags aFlags) { mWRGlyphFlags = aFlags; }
|
|
|
|
|
|
|
|
class AutoRestoreWRGlyphFlags {
|
|
|
|
public:
|
|
|
|
~AutoRestoreWRGlyphFlags() {
|
|
|
|
if (mTarget) {
|
|
|
|
mTarget->SetWRGlyphFlags(mFlags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Save(TextDrawTarget* aTarget) {
|
|
|
|
// This allows for recursive saves, in case the flags need to be modified
|
|
|
|
// under multiple conditions (i.e. transforms and synthetic italics),
|
|
|
|
// since the flags will be restored to the first saved value in the
|
|
|
|
// destructor on scope exit.
|
|
|
|
if (!mTarget) {
|
|
|
|
// Only record the first save with the original flags that will be
|
|
|
|
// restored.
|
|
|
|
mTarget = aTarget;
|
|
|
|
mFlags = aTarget->GetWRGlyphFlags();
|
|
|
|
} else {
|
|
|
|
// Ensure that this is actually a recursive save to the same target
|
|
|
|
MOZ_ASSERT(
|
|
|
|
mTarget == aTarget,
|
|
|
|
"Recursive save of WR glyph flags to different TextDrawTargets");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
TextDrawTarget* mTarget = nullptr;
|
|
|
|
wr::FontInstanceFlags mFlags = {0};
|
|
|
|
};
|
|
|
|
|
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 overload just stores the glyphs/font/color.
|
|
|
|
void FillGlyphs(ScaledFont* aFont, const GlyphBuffer& aBuffer,
|
|
|
|
const Pattern& aPattern,
|
2017-11-03 04:42:56 +03:00
|
|
|
const DrawOptions& aOptions) override {
|
2017-10-06 20:06:10 +03:00
|
|
|
// Make sure we're only given boring color patterns
|
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
|
|
|
MOZ_RELEASE_ASSERT(aOptions.mCompositionOp == CompositionOp::OP_OVER);
|
|
|
|
MOZ_RELEASE_ASSERT(aOptions.mAlpha == 1.0f);
|
|
|
|
MOZ_RELEASE_ASSERT(aPattern.GetType() == PatternType::COLOR);
|
|
|
|
|
2017-10-06 20:06:10 +03:00
|
|
|
// Make sure the font exists, and can be serialized
|
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
|
|
|
MOZ_RELEASE_ASSERT(aFont);
|
2017-10-06 20:06:10 +03:00
|
|
|
if (!aFont->CanSerialize()) {
|
|
|
|
FoundUnsupportedFeature();
|
|
|
|
return;
|
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-12-04 21:01:55 +03:00
|
|
|
auto* colorPat = static_cast<const ColorPattern*>(&aPattern);
|
|
|
|
auto color = wr::ToColorF(colorPat->mColor);
|
|
|
|
MOZ_ASSERT(aBuffer.mNumGlyphs);
|
|
|
|
auto glyphs = Range<const wr::GlyphInstance>(
|
|
|
|
reinterpret_cast<const wr::GlyphInstance*>(aBuffer.mGlyphs),
|
|
|
|
aBuffer.mNumGlyphs);
|
|
|
|
// MSVC won't let us use offsetof on the following directly so we give it a
|
|
|
|
// name with typedef
|
|
|
|
typedef std::remove_reference<decltype(aBuffer.mGlyphs[0])>::type GlyphType;
|
|
|
|
// Compare gfx::Glyph and wr::GlyphInstance to make sure that they are
|
|
|
|
// structurally equivalent to ensure that our cast above was ok
|
|
|
|
static_assert(
|
|
|
|
std::is_same<decltype(aBuffer.mGlyphs[0].mIndex),
|
|
|
|
decltype(glyphs[0].index)>() &&
|
|
|
|
std::is_same<decltype(aBuffer.mGlyphs[0].mPosition.x),
|
|
|
|
decltype(glyphs[0].point.x)>() &&
|
|
|
|
std::is_same<decltype(aBuffer.mGlyphs[0].mPosition.y),
|
|
|
|
decltype(glyphs[0].point.y)>() &&
|
|
|
|
offsetof(GlyphType, mIndex) == offsetof(wr::GlyphInstance, index) &&
|
|
|
|
offsetof(GlyphType, mPosition) ==
|
|
|
|
offsetof(wr::GlyphInstance, point) &&
|
|
|
|
offsetof(decltype(aBuffer.mGlyphs[0].mPosition), x) ==
|
|
|
|
offsetof(decltype(glyphs[0].point), x) &&
|
|
|
|
offsetof(decltype(aBuffer.mGlyphs[0].mPosition), y) ==
|
|
|
|
offsetof(decltype(glyphs[0].point), y) &&
|
|
|
|
std::is_standard_layout<
|
|
|
|
std::remove_reference<decltype(aBuffer.mGlyphs[0])>>::value &&
|
|
|
|
std::is_standard_layout<
|
|
|
|
std::remove_reference<decltype(glyphs[0])>>::value &&
|
|
|
|
sizeof(aBuffer.mGlyphs[0]) == sizeof(glyphs[0]) &&
|
|
|
|
sizeof(aBuffer.mGlyphs[0].mPosition) == sizeof(glyphs[0].point),
|
|
|
|
"glyph buf types don't match");
|
2017-10-06 20:06:10 +03:00
|
|
|
|
2017-10-20 05:54:28 +03:00
|
|
|
wr::GlyphOptions glyphOptions;
|
|
|
|
glyphOptions.render_mode =
|
|
|
|
wr::ToFontRenderMode(aOptions.mAntialiasMode, GetPermitSubpixelAA());
|
2018-01-17 15:51:20 +03:00
|
|
|
glyphOptions.flags = mWRGlyphFlags;
|
2017-10-20 05:54:28 +03:00
|
|
|
|
2018-11-26 01:57:04 +03:00
|
|
|
mManager->WrBridge()->PushGlyphs(mBuilder, glyphs, aFont, color, *mSc,
|
2018-01-16 12:54:57 +03:00
|
|
|
mBoundsRect, ClipRect(), mBackfaceVisible,
|
|
|
|
&glyphOptions);
|
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-24 19:44:38 +03:00
|
|
|
void PushClipRect(const Rect& aRect) override {
|
2018-01-16 12:54:57 +03:00
|
|
|
LayoutDeviceRect rect = LayoutDeviceRect::FromUnknownRect(aRect);
|
|
|
|
rect = rect.Intersect(mClipStack.LastElement());
|
|
|
|
mClipStack.AppendElement(rect);
|
2017-10-24 19:44:38 +03:00
|
|
|
}
|
|
|
|
|
2018-03-13 16:51:33 +03:00
|
|
|
void PopClip() override { mClipStack.RemoveLastElement(); }
|
2017-10-24 19:44:38 +03:00
|
|
|
|
2018-04-17 06:05:48 +03:00
|
|
|
IntSize GetSize() const override { return mSize; }
|
|
|
|
|
2017-10-06 20:06:10 +03:00
|
|
|
void AppendShadow(const wr::Shadow& aShadow) {
|
2018-01-16 12:54:57 +03:00
|
|
|
mBuilder.PushShadow(mBoundsRect, ClipRect(), mBackfaceVisible, aShadow);
|
2017-10-13 19:58:32 +03:00
|
|
|
mHasShadows = true;
|
2017-09-12 23:50:44 +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
|
|
|
|
2017-10-06 20:06:10 +03:00
|
|
|
void TerminateShadows() {
|
2017-10-13 19:58:32 +03:00
|
|
|
if (mHasShadows) {
|
|
|
|
mBuilder.PopAllShadows();
|
|
|
|
mHasShadows = false;
|
2017-10-06 20:06:10 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppendSelectionRect(const LayoutDeviceRect& aRect, const Color& aColor) {
|
|
|
|
auto rect = wr::ToLayoutRect(aRect);
|
|
|
|
auto color = wr::ToColorF(aColor);
|
2018-01-16 12:54:57 +03:00
|
|
|
mBuilder.PushRect(rect, ClipRect(), mBackfaceVisible, 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
|
|
|
}
|
|
|
|
|
2017-10-24 19:44:38 +03:00
|
|
|
// This function is basically designed to slide into the decoration drawing
|
|
|
|
// code of nsCSSRendering with minimum disruption, to minimize the
|
|
|
|
// chances of implementation drift. As such, it mostly looks like a call
|
|
|
|
// to a skia-style StrokeLine method: two end-points, with a thickness
|
|
|
|
// and style. Notably the end-points are *centered* in the block direction,
|
|
|
|
// even though webrender wants a rect-like representation, where the points
|
|
|
|
// are on corners.
|
|
|
|
//
|
|
|
|
// So we mangle the format here in a single centralized place, where neither
|
|
|
|
// webrender nor nsCSSRendering has to care about this mismatch.
|
|
|
|
//
|
|
|
|
// NOTE: we assume the points are axis-aligned, and aStart should be used
|
|
|
|
// as the top-left corner of the rect.
|
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 AppendDecoration(const Point& aStart, const Point& aEnd,
|
|
|
|
const float aThickness, const bool aVertical,
|
|
|
|
const Color& aColor, const uint8_t aStyle) {
|
2017-10-24 19:44:38 +03:00
|
|
|
auto pos = LayoutDevicePoint::FromUnknownPoint(aStart);
|
|
|
|
LayoutDeviceSize size;
|
|
|
|
|
|
|
|
if (aVertical) {
|
|
|
|
pos.x -= aThickness / 2; // adjust from center to corner
|
|
|
|
size = LayoutDeviceSize(aThickness, aEnd.y - aStart.y);
|
|
|
|
} else {
|
|
|
|
pos.y -= aThickness / 2; // adjust from center to corner
|
|
|
|
size = LayoutDeviceSize(aEnd.x - aStart.x, aThickness);
|
|
|
|
}
|
2017-10-25 16:32:17 +03:00
|
|
|
|
2017-10-24 19:44:38 +03:00
|
|
|
wr::Line decoration;
|
2018-03-30 00:57:43 +03:00
|
|
|
decoration.bounds = wr::ToRoundedLayoutRect(LayoutDeviceRect(pos, size));
|
2017-10-24 19:44:38 +03:00
|
|
|
decoration.wavyLineThickness = 0; // dummy value, unused
|
2017-10-06 20:06:10 +03:00
|
|
|
decoration.color = wr::ToColorF(aColor);
|
|
|
|
decoration.orientation = aVertical ? wr::LineOrientation::Vertical
|
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::LineOrientation::Horizontal;
|
|
|
|
|
|
|
|
switch (aStyle) {
|
|
|
|
case NS_STYLE_TEXT_DECORATION_STYLE_SOLID:
|
2017-10-06 20:06:10 +03:00
|
|
|
decoration.style = wr::LineStyle::Solid;
|
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
|
|
|
break;
|
|
|
|
case NS_STYLE_TEXT_DECORATION_STYLE_DOTTED:
|
2017-10-06 20:06:10 +03:00
|
|
|
decoration.style = wr::LineStyle::Dotted;
|
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
|
|
|
break;
|
|
|
|
case NS_STYLE_TEXT_DECORATION_STYLE_DASHED:
|
2017-10-06 20:06:10 +03:00
|
|
|
decoration.style = wr::LineStyle::Dashed;
|
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
|
|
|
break;
|
2017-10-24 19:44:38 +03:00
|
|
|
// Wavy lines should go through AppendWavyDecoration
|
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
|
|
|
case NS_STYLE_TEXT_DECORATION_STYLE_WAVY:
|
|
|
|
// Double lines should be lowered to two solid lines
|
|
|
|
case NS_STYLE_TEXT_DECORATION_STYLE_DOUBLE:
|
|
|
|
default:
|
|
|
|
MOZ_CRASH("TextDrawTarget received unsupported line style");
|
|
|
|
}
|
|
|
|
|
2018-01-16 12:54:57 +03:00
|
|
|
mBuilder.PushLine(ClipRect(), mBackfaceVisible, decoration);
|
2017-09-21 22:15:58 +03:00
|
|
|
}
|
|
|
|
|
2017-10-24 19:44:38 +03:00
|
|
|
// Seperated out from AppendDecoration because Wavy Lines are completely
|
|
|
|
// different, and trying to merge the concept is more of a mess than it's
|
|
|
|
// worth.
|
|
|
|
void AppendWavyDecoration(const Rect& aBounds, const float aThickness,
|
|
|
|
const bool aVertical, const Color& aColor) {
|
|
|
|
wr::Line decoration;
|
|
|
|
|
2018-03-30 00:57:43 +03:00
|
|
|
decoration.bounds =
|
2017-10-24 19:44:38 +03:00
|
|
|
wr::ToRoundedLayoutRect(LayoutDeviceRect::FromUnknownRect(aBounds));
|
|
|
|
decoration.wavyLineThickness = aThickness;
|
|
|
|
decoration.color = wr::ToColorF(aColor);
|
|
|
|
decoration.orientation = aVertical ? wr::LineOrientation::Vertical
|
|
|
|
: wr::LineOrientation::Horizontal;
|
|
|
|
decoration.style = wr::LineStyle::Wavy;
|
|
|
|
|
2018-01-16 12:54:57 +03:00
|
|
|
mBuilder.PushLine(ClipRect(), mBackfaceVisible, decoration);
|
2017-10-24 19:44:38 +03:00
|
|
|
}
|
|
|
|
|
2018-08-21 19:36:48 +03:00
|
|
|
layers::WebRenderBridgeChild* WrBridge() { return mManager->WrBridge(); }
|
2019-01-08 00:33:10 +03:00
|
|
|
layers::WebRenderLayerManager* WrLayerManager() {
|
|
|
|
return mManager->LayerManager();
|
|
|
|
}
|
2018-08-21 19:36:48 +03:00
|
|
|
|
|
|
|
Maybe<wr::ImageKey> DefineImage(const IntSize& aSize, uint32_t aStride,
|
|
|
|
SurfaceFormat aFormat, const uint8_t* aData) {
|
|
|
|
wr::ImageKey key = mManager->WrBridge()->GetNextImageKey();
|
|
|
|
wr::ImageDescriptor desc(aSize, aStride, aFormat);
|
|
|
|
Range<uint8_t> bytes(const_cast<uint8_t*>(aData), aStride * aSize.height);
|
2018-11-26 01:57:04 +03:00
|
|
|
if (mResources->AddImage(key, desc, bytes)) {
|
2018-08-21 19:36:48 +03:00
|
|
|
return Some(key);
|
|
|
|
}
|
|
|
|
return Nothing();
|
|
|
|
}
|
|
|
|
|
2018-12-15 01:30:08 +03:00
|
|
|
void PushImage(wr::ImageKey aKey, const Rect& aBounds, const Rect& aClip,
|
|
|
|
wr::ImageRendering aFilter, const wr::ColorF& aColor) {
|
|
|
|
if (!aClip.Intersects(GeckoClipRect().ToUnknownRect())) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mBuilder.PushImage(wr::ToLayoutRect(aBounds), wr::ToLayoutRect(aClip), true,
|
|
|
|
aFilter, aKey, true, aColor);
|
2018-08-21 19:36:48 +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
|
|
|
private:
|
2018-04-26 21:15:19 +03:00
|
|
|
wr::LayoutRect ClipRect() {
|
2018-03-30 00:57:43 +03:00
|
|
|
return wr::ToRoundedLayoutRect(mClipStack.LastElement());
|
2018-01-16 12:54:57 +03:00
|
|
|
}
|
2018-12-15 01:30:08 +03:00
|
|
|
LayoutDeviceRect GeckoClipRect() { return mClipStack.LastElement(); }
|
2017-10-06 20:06:10 +03:00
|
|
|
// Whether anything unsupported was encountered. Currently:
|
|
|
|
//
|
|
|
|
// * Synthetic bold/italics
|
|
|
|
// * SVG fonts
|
|
|
|
// * Unserializable fonts
|
|
|
|
// * Tofu glyphs
|
|
|
|
// * Pratial ligatures
|
|
|
|
// * Text writing-mode
|
|
|
|
// * Text stroke
|
|
|
|
bool mHasUnsupportedFeatures = false;
|
|
|
|
|
2018-12-12 05:48:33 +03:00
|
|
|
// The caller promises to call Save/Restore on the builder as needed.
|
|
|
|
bool mCallerDoesSaveRestore = false;
|
|
|
|
#ifdef DEBUG
|
|
|
|
bool mFinished = false;
|
|
|
|
#endif
|
|
|
|
|
2017-10-13 19:58:32 +03:00
|
|
|
// Whether PopAllShadows needs to be called
|
|
|
|
bool mHasShadows = false;
|
2017-10-06 20:06:10 +03:00
|
|
|
|
|
|
|
// Things used to push to webrender
|
|
|
|
wr::DisplayListBuilder& mBuilder;
|
2018-11-26 01:57:04 +03:00
|
|
|
wr::IpcResourceUpdateQueue* mResources;
|
|
|
|
const layers::StackingContextHelper* mSc;
|
2019-01-08 00:33:10 +03:00
|
|
|
layers::RenderRootStateManager* mManager;
|
2017-10-06 20:06:10 +03:00
|
|
|
|
|
|
|
// Computed facts
|
2018-04-17 06:05:48 +03:00
|
|
|
IntSize mSize;
|
2018-04-26 21:15:19 +03:00
|
|
|
wr::LayoutRect mBoundsRect;
|
2018-11-26 01:57:04 +03:00
|
|
|
AutoTArray<LayoutDeviceRect, 3> mClipStack;
|
2017-10-06 20:06:10 +03:00
|
|
|
bool mBackfaceVisible;
|
2017-10-04 20:49:51 +03:00
|
|
|
|
2018-01-17 15:51:20 +03:00
|
|
|
wr::FontInstanceFlags mWRGlyphFlags = {0};
|
|
|
|
|
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
|
|
|
// The rest of this is dummy implementations of DrawTarget's API
|
|
|
|
public:
|
|
|
|
DrawTargetType GetType() const override {
|
2017-09-21 22:15:58 +03:00
|
|
|
return DrawTargetType::SOFTWARE_RASTER;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
BackendType GetBackendType() const override {
|
2017-09-21 22:15:58 +03:00
|
|
|
return BackendType::WEBRENDER_TEXT;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
bool IsRecording() const override { return true; }
|
|
|
|
bool IsCaptureDT() const override { return false; }
|
|
|
|
|
|
|
|
already_AddRefed<SourceSurface> Snapshot() override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
|
|
|
return nullptr;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<SourceSurface> IntoLuminanceSource(
|
|
|
|
LuminanceType aLuminanceType, float aOpacity) override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
|
|
|
return nullptr;
|
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 Flush() override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
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 DrawCapturedDT(DrawTargetCapture* aCaptureDT,
|
|
|
|
const Matrix& aTransform) override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
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 DrawSurface(SourceSurface* aSurface, const Rect& aDest,
|
|
|
|
const Rect& aSource, const DrawSurfaceOptions& aSurfOptions,
|
|
|
|
const DrawOptions& aOptions) override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
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 DrawFilter(FilterNode* aNode, const Rect& aSourceRect,
|
|
|
|
const Point& aDestPoint,
|
|
|
|
const DrawOptions& aOptions) override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
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 DrawSurfaceWithShadow(SourceSurface* aSurface, const Point& aDest,
|
|
|
|
const Color& aColor, const Point& aOffset,
|
|
|
|
Float aSigma, CompositionOp aOperator) override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
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 ClearRect(const Rect& aRect) override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
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 CopySurface(SourceSurface* aSurface, const IntRect& aSourceRect,
|
|
|
|
const IntPoint& aDestination) override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
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 FillRect(const Rect& aRect, const Pattern& aPattern,
|
|
|
|
const DrawOptions& aOptions = DrawOptions()) override {
|
2018-01-19 00:10:14 +03:00
|
|
|
MOZ_RELEASE_ASSERT(aPattern.GetType() == PatternType::COLOR);
|
|
|
|
|
2018-12-15 01:30:08 +03:00
|
|
|
if (!aRect.Intersects(GeckoClipRect().ToUnknownRect())) {
|
|
|
|
return;
|
|
|
|
}
|
2018-03-30 00:57:43 +03:00
|
|
|
auto rect =
|
|
|
|
wr::ToRoundedLayoutRect(LayoutDeviceRect::FromUnknownRect(aRect));
|
2018-01-19 00:10:14 +03:00
|
|
|
auto color =
|
|
|
|
wr::ToColorF(static_cast<const ColorPattern&>(aPattern).mColor);
|
2018-01-16 12:54:57 +03:00
|
|
|
mBuilder.PushRect(rect, ClipRect(), mBackfaceVisible, 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
|
|
|
}
|
|
|
|
|
|
|
|
void StrokeRect(const Rect& aRect, const Pattern& aPattern,
|
|
|
|
const StrokeOptions& aStrokeOptions,
|
|
|
|
const DrawOptions& aOptions) override {
|
2018-01-19 00:10:14 +03:00
|
|
|
MOZ_RELEASE_ASSERT(aPattern.GetType() == PatternType::COLOR &&
|
|
|
|
aStrokeOptions.mDashLength == 0);
|
|
|
|
|
2018-09-18 16:01:36 +03:00
|
|
|
wr::LayoutSideOffsets widths = {
|
2018-08-21 19:36:48 +03:00
|
|
|
aStrokeOptions.mLineWidth, aStrokeOptions.mLineWidth,
|
|
|
|
aStrokeOptions.mLineWidth, aStrokeOptions.mLineWidth};
|
|
|
|
wr::ColorF color =
|
|
|
|
wr::ToColorF(static_cast<const ColorPattern&>(aPattern).mColor);
|
|
|
|
wr::BorderSide sides[4] = {{color, wr::BorderStyle::Solid},
|
|
|
|
{color, wr::BorderStyle::Solid},
|
|
|
|
{color, wr::BorderStyle::Solid},
|
|
|
|
{color, wr::BorderStyle::Solid}};
|
|
|
|
wr::BorderRadius radius = {{0, 0}, {0, 0}, {0, 0}, {0, 0}};
|
2018-12-15 01:30:08 +03:00
|
|
|
LayoutDeviceRect rect = LayoutDeviceRect::FromUnknownRect(aRect);
|
2018-08-21 19:36:48 +03:00
|
|
|
rect.Inflate(aStrokeOptions.mLineWidth / 2);
|
2018-12-15 01:30:08 +03:00
|
|
|
if (!rect.Intersects(GeckoClipRect())) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
wr::LayoutRect bounds = wr::ToRoundedLayoutRect(rect);
|
2018-08-21 19:36:48 +03:00
|
|
|
mBuilder.PushBorder(bounds, ClipRect(), true, widths,
|
|
|
|
Range<const wr::BorderSide>(sides, 4), radius);
|
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 StrokeLine(const Point& aStart, const Point& aEnd,
|
|
|
|
const Pattern& aPattern, const StrokeOptions& aStrokeOptions,
|
|
|
|
const DrawOptions& aOptions) override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
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 Stroke(const Path* aPath, const Pattern& aPattern,
|
|
|
|
const StrokeOptions& aStrokeOptions,
|
|
|
|
const DrawOptions& aOptions) override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
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 Fill(const Path* aPath, const Pattern& aPattern,
|
|
|
|
const DrawOptions& aOptions) override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
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 StrokeGlyphs(ScaledFont* aFont, const GlyphBuffer& aBuffer,
|
|
|
|
const Pattern& aPattern,
|
|
|
|
const StrokeOptions& aStrokeOptions,
|
2017-11-03 04:42:56 +03:00
|
|
|
const DrawOptions& aOptions) override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
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 Mask(const Pattern& aSource, const Pattern& aMask,
|
|
|
|
const DrawOptions& aOptions) override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
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 MaskSurface(const Pattern& aSource, SourceSurface* aMask, Point aOffset,
|
|
|
|
const DrawOptions& aOptions) override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
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
|
|
|
}
|
|
|
|
|
|
|
|
bool Draw3DTransformedSurface(SourceSurface* aSurface,
|
|
|
|
const Matrix4x4& aMatrix) override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
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 PushClip(const Path* aPath) override {
|
2017-10-24 19:44:38 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
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 PushDeviceSpaceClipRects(const IntRect* aRects,
|
|
|
|
uint32_t aCount) override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
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 PushLayer(bool aOpaque, Float aOpacity, SourceSurface* aMask,
|
|
|
|
const Matrix& aMaskTransform, const IntRect& aBounds,
|
|
|
|
bool aCopyBackground) override {
|
2017-09-16 17:42:11 +03:00
|
|
|
// Fine to pretend we do this
|
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 PopLayer() override {
|
2017-09-16 17:42:11 +03:00
|
|
|
// Fine to pretend we do this
|
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
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<SourceSurface> CreateSourceSurfaceFromData(
|
|
|
|
unsigned char* aData, const IntSize& aSize, int32_t aStride,
|
|
|
|
SurfaceFormat aFormat) const override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
|
|
|
return nullptr;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<SourceSurface> OptimizeSourceSurface(
|
|
|
|
SourceSurface* aSurface) const override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
|
|
|
return nullptr;
|
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-09-16 17:42:11 +03:00
|
|
|
already_AddRefed<SourceSurface> CreateSourceSurfaceFromNativeSurface(
|
|
|
|
const NativeSurface& aSurface) const override {
|
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
|
|
|
return nullptr;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<DrawTarget> CreateSimilarDrawTarget(
|
2017-09-16 17:42:11 +03:00
|
|
|
const IntSize& aSize, SurfaceFormat aFormat) const override {
|
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
|
|
|
return nullptr;
|
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
|
|
|
}
|
|
|
|
|
2018-11-13 13:39:02 +03:00
|
|
|
bool CanCreateSimilarDrawTarget(const IntSize& aSize,
|
|
|
|
SurfaceFormat aFormat) const override {
|
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
already_AddRefed<PathBuilder> CreatePathBuilder(
|
|
|
|
FillRule aFillRule) const override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
|
|
|
return nullptr;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<FilterNode> CreateFilter(FilterType aType) override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
|
|
|
return nullptr;
|
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-09-18 21:15:03 +03:00
|
|
|
already_AddRefed<GradientStops> CreateGradientStops(
|
2017-09-16 17:42:11 +03:00
|
|
|
GradientStop* aStops, uint32_t aNumStops,
|
|
|
|
ExtendMode aExtendMode) const override {
|
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
|
|
|
return nullptr;
|
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-09-18 21:15:03 +03:00
|
|
|
void* GetNativeSurface(NativeSurfaceType aType) override {
|
2017-09-16 17:42:11 +03:00
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
|
|
|
return nullptr;
|
2017-09-16 17:42:11 +03:00
|
|
|
}
|
2017-09-18 21:15:03 +03:00
|
|
|
|
2017-09-16 17:42:11 +03:00
|
|
|
void DetachAllSnapshots() override {
|
|
|
|
MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
|
|
|
|
}
|
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
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace layout
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|