Bug 1400382 - Implement CreateWebRenderCommands for nsDisplayTextOverflow. r=mstange

MozReview-Commit-ID: EQtFvLQCT2U

--HG--
extra : rebase_source : 12548860b96a7a700c793d9cc8c2164e32e568fb
This commit is contained in:
Alexis Beingessner 2017-09-21 15:15:58 -04:00
Родитель c9ae89e98d
Коммит 4dd753b7ab
2 изменённых файлов: 70 добавлений и 5 удалений

Просмотреть файл

@ -124,6 +124,7 @@
#include "DisplayItemClip.h"
#include "mozilla/layers/WebRenderLayerManager.h"
#include "prenv.h"
#include "TextDrawTarget.h"
#ifdef MOZ_XUL
#include "nsXULPopupManager.h"
@ -6067,6 +6068,29 @@ nsLayoutUtils::PaintTextShadow(const nsIFrame* aFrame,
nsPresContext* presCtx = aFrame->PresContext();
nsContextBoxBlur contextBoxBlur;
nscolor shadowColor;
if (shadowDetails->mHasColor)
shadowColor = shadowDetails->mColor;
else
shadowColor = aForegroundColor;
// Webrender just needs the shadow details
if (auto* textDrawer = aContext->GetTextDrawer()) {
wr::TextShadow wrShadow;
wrShadow.offset = {
presCtx->AppUnitsToFloatDevPixels(shadowDetails->mXOffset),
presCtx->AppUnitsToFloatDevPixels(shadowDetails->mYOffset)
};
wrShadow.blur_radius = presCtx->AppUnitsToFloatDevPixels(shadowDetails->mRadius);
wrShadow.color = wr::ToColorF(ToDeviceColor(shadowColor));
textDrawer->AppendShadow(wrShadow);
return;
}
gfxContext* shadowContext = contextBoxBlur.Init(shadowRect, 0, blurRadius,
presCtx->AppUnitsPerDevPixel(),
aDestCtx, aDirtyRect, nullptr,
@ -6074,11 +6098,7 @@ nsLayoutUtils::PaintTextShadow(const nsIFrame* aFrame,
if (!shadowContext)
continue;
nscolor shadowColor;
if (shadowDetails->mHasColor)
shadowColor = shadowDetails->mColor;
else
shadowColor = aForegroundColor;
aDestCtx->Save();
aDestCtx->NewPath();

Просмотреть файл

@ -24,6 +24,7 @@
#include "mozilla/ArrayUtils.h"
#include "mozilla/Likely.h"
#include "nsISelection.h"
#include "TextDrawTarget.h"
namespace mozilla {
namespace css {
@ -208,6 +209,13 @@ public:
}
void PaintTextToContext(gfxContext* aCtx,
nsPoint aOffsetFromRect);
virtual bool CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
mozilla::wr::IpcResourceUpdateQueue& aResources,
const StackingContextHelper& aSc,
layers::WebRenderLayerManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder) override;
NS_DISPLAY_DECL_NAME("TextOverflow", TYPE_TEXT_OVERFLOW)
private:
nsRect mRect; // in reference frame coordinates
@ -278,6 +286,43 @@ nsDisplayTextOverflowMarker::PaintTextToContext(gfxContext* aCtx,
}
}
bool
nsDisplayTextOverflowMarker::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
mozilla::wr::IpcResourceUpdateQueue& aResources,
const StackingContextHelper& aSc,
layers::WebRenderLayerManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder)
{
if (!aManager->IsLayersFreeTransaction() ||
!gfxPrefs::LayersAllowTextLayers() ||
!CanUseAdvancedLayer(aDisplayListBuilder->GetWidgetLayerManager())) {
return false;
}
bool snap;
nsRect bounds = GetBounds(aDisplayListBuilder, &snap);
if (bounds.IsEmpty()) {
return true;
}
// Run the rendering algorithm to capture the glyphs and shadows
RefPtr<TextDrawTarget> textDrawer = new TextDrawTarget();
RefPtr<gfxContext> captureCtx = gfxContext::CreateOrNull(textDrawer);
// TextOverflowMarker only draws glyphs
textDrawer->StartDrawing(TextDrawTarget::Phase::eGlyphs);
Paint(aDisplayListBuilder, captureCtx);
if (!textDrawer->CanSerializeFonts()) {
return false;
}
textDrawer->CreateWebRenderCommands(aBuilder, aSc, aManager, this, bounds);
return true;
}
TextOverflow::TextOverflow(nsDisplayListBuilder* aBuilder,
nsIFrame* aBlockFrame)
: mContentArea(aBlockFrame->GetWritingMode(),