Bug 1405465 - Handle WR paint codepath with no frame r=kats

This commit is contained in:
sotaro 2018-06-29 08:32:26 +09:00
Родитель ae4d702ed7
Коммит 58705ea969
5 изменённых файлов: 45 добавлений и 7 удалений

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

@ -240,16 +240,15 @@ WebRenderLayerManager::EndTransaction(DrawPaintedLayerCallback aCallback,
void
WebRenderLayerManager::EndTransactionWithoutLayer(nsDisplayList* aDisplayList,
nsDisplayListBuilder* aDisplayListBuilder,
const nsTArray<wr::WrFilterOp>& aFilters)
const nsTArray<wr::WrFilterOp>& aFilters,
WebRenderBackgroundData* aBackground)
{
MOZ_ASSERT(aDisplayList && aDisplayListBuilder);
AUTO_PROFILER_TRACING("Paint", "RenderLayers");
#if DUMP_LISTS
// Useful for debugging, it dumps the display list *before* we try to build
// WR commands from it
if (XRE_IsContentProcess()) nsFrame::PrintDisplayList(aDisplayListBuilder, *aDisplayList);
if (XRE_IsContentProcess() && aDisplayList) nsFrame::PrintDisplayList(aDisplayListBuilder, *aDisplayList);
#endif
#ifdef XP_WIN
@ -266,7 +265,9 @@ WebRenderLayerManager::EndTransactionWithoutLayer(nsDisplayList* aDisplayList,
wr::DisplayListBuilder builder(WrBridge()->GetPipeline(), contentSize, mLastDisplayListSize);
wr::IpcResourceUpdateQueue resourceUpdates(WrBridge());
{ // Record the time spent "layerizing". WR doesn't actually layerize but
if (aDisplayList) {
MOZ_ASSERT(aDisplayListBuilder && !aBackground);
// Record the time spent "layerizing". WR doesn't actually layerize but
// generating the WR display list is the closest equivalent
PaintTelemetry::AutoRecord record(PaintTelemetry::Metric::Layerization);
@ -277,6 +278,10 @@ WebRenderLayerManager::EndTransactionWithoutLayer(nsDisplayList* aDisplayList,
mScrollData,
contentSize,
aFilters);
} else {
// ViewToPaint does not have frame yet, then render only background clolor.
MOZ_ASSERT(!aDisplayListBuilder && aBackground);
aBackground->AddWebRenderCommands(builder);
}
DiscardCompositorAnimations();

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

@ -71,7 +71,8 @@ public:
virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT) override;
void EndTransactionWithoutLayer(nsDisplayList* aDisplayList,
nsDisplayListBuilder* aDisplayListBuilder,
const nsTArray<wr::WrFilterOp>& aFilters = nsTArray<wr::WrFilterOp>());
const nsTArray<wr::WrFilterOp>& aFilters = nsTArray<wr::WrFilterOp>(),
WebRenderBackgroundData* aBackground = nullptr);
virtual void EndTransaction(DrawPaintedLayerCallback aCallback,
void* aCallbackData,
EndTransactionFlags aFlags = END_DEFAULT) override;

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

@ -20,6 +20,15 @@
namespace mozilla {
namespace layers {
void
WebRenderBackgroundData::AddWebRenderCommands(wr::DisplayListBuilder& aBuilder)
{
aBuilder.PushRect(mBounds,
mBounds,
true,
mColor);
}
/* static */ bool
WebRenderUserData::SupportsAsyncUpdate(nsIFrame* aFrame)
{

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

@ -37,6 +37,19 @@ class WebRenderFallbackData;
class WebRenderLayerManager;
class WebRenderGroupData;
class WebRenderBackgroundData
{
public:
WebRenderBackgroundData(wr::LayoutRect aBounds, wr::ColorF aColor)
: mBounds(aBounds)
, mColor(aColor)
{ }
void AddWebRenderCommands(wr::DisplayListBuilder& aBuilder);
protected:
wr::LayoutRect mBounds;
wr::ColorF mColor;
};
class WebRenderUserData
{
public:

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

@ -176,6 +176,8 @@
#include "nsLayoutStylesheetCache.h"
#include "mozilla/layers/InputAPZContext.h"
#include "mozilla/layers/FocusTarget.h"
#include "mozilla/layers/WebRenderLayerManager.h"
#include "mozilla/layers/WebRenderUserData.h"
#include "mozilla/ServoBindings.h"
#include "mozilla/ServoStyleSet.h"
#include "mozilla/StyleSheet.h"
@ -6319,7 +6321,15 @@ PresShell::Paint(nsView* aViewToPaint,
}
if (layerManager->GetBackendType() == layers::LayersBackend::LAYERS_WR) {
// TODO: bug 1405465 - create a WR display list which simulates the color layer below.
nsPresContext* pc = GetPresContext();
LayoutDeviceRect bounds =
LayoutDeviceRect::FromAppUnits(pc->GetVisibleArea(), pc->AppUnitsPerDevPixel());
bgcolor = NS_ComposeColors(bgcolor, mCanvasBackgroundColor);
WebRenderBackgroundData data(wr::ToLayoutRect(bounds), wr::ToColorF(ToDeviceColor(bgcolor)));
nsTArray<wr::WrFilterOp> wrFilters;
MaybeSetupTransactionIdAllocator(layerManager, presContext);
layerManager->AsWebRenderLayerManager()->EndTransactionWithoutLayer(nullptr, nullptr, wrFilters, &data);
return;
}