Bug 1368846 - Display the window buttons when webrender is used. r=kats,mattwoodrow

MozReview-Commit-ID: Ki4ONGxtzyO

--HG--
extra : rebase_source : b4b223ad64a117cee60fc19819833855b871f95a
This commit is contained in:
Markus Stange 2017-06-21 18:58:41 -04:00
parent fe0bdb5e71
commit 99dd420f6b
6 changed files with 82 additions and 3 deletions

View File

@ -96,6 +96,11 @@ public:
mIdNamespace = aIdNamespace;
}
WrImageKey GetNextImageKey()
{
return WrImageKey{ GetNamespace(), GetNextResourceId() };
}
void PushGlyphs(wr::DisplayListBuilder& aBuilder, const nsTArray<GlyphArray>& aGlyphs,
gfx::ScaledFont* aFont, const StackingContextHelper& aSc,
const LayerRect& aBounds, const LayerRect& aClip);

View File

@ -74,6 +74,8 @@ WebRenderLayerManager::Destroy()
return;
}
mWidget->CleanupWebRenderWindowOverlay(WrBridge());
LayerManager::Destroy();
DiscardImages();
DiscardCompositorAnimations();
@ -203,6 +205,7 @@ WebRenderLayerManager::EndTransactionInternal(DrawPaintedLayerCallback aCallback
WrSize contentSize { (float)size.width, (float)size.height };
wr::DisplayListBuilder builder(WrBridge()->GetPipeline(), contentSize);
WebRenderLayer::ToWebRenderLayer(mRoot)->RenderLayer(builder, sc);
mWidget->AddWindowOverlayWebRenderCommands(WrBridge(), builder);
WrBridge()->ClearReadLocks();
// We can't finish this transaction so return. This usually

View File

@ -121,14 +121,11 @@ RendererOGL::Render()
return false;
}
// XXX set clear color if MOZ_WIDGET_ANDROID is defined.
// XXX pass the actual render bounds instead of an empty rect.
mWidget->DrawWindowUnderlay(&widgetContext, LayoutDeviceIntRect());
auto size = mWidget->GetClientSize();
wr_renderer_render(mWrRenderer, size.width, size.height);
mGL->SwapBuffers();
mWidget->DrawWindowOverlay(&widgetContext, LayoutDeviceIntRect());
mWidget->PostRender(&widgetContext);
// TODO: Flush pending actions such as texture deletions/unlocks and

View File

@ -24,6 +24,7 @@
#include "nsRegion.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/webrender/WebRenderTypes.h"
#include "nsString.h"
#include "nsIDragService.h"
@ -451,6 +452,12 @@ public:
virtual void CreateCompositor() override;
virtual void PrepareWindowEffects() override;
virtual void CleanupWindowEffects() override;
virtual void AddWindowOverlayWebRenderCommands(mozilla::layers::WebRenderBridgeChild* aWrBridge,
mozilla::wr::DisplayListBuilder& aBuilder) override;
virtual void CleanupWebRenderWindowOverlay(mozilla::layers::WebRenderBridgeChild* aWrBridge) override;
virtual bool PreRender(mozilla::widget::WidgetRenderingContext* aContext) override;
virtual void PostRender(mozilla::widget::WidgetRenderingContext* aContext) override;
virtual void DrawWindowOverlay(mozilla::widget::WidgetRenderingContext* aManager,
@ -626,6 +633,9 @@ protected:
mozilla::UniquePtr<mozilla::widget::RectTextureImage> mTitlebarImage;
mozilla::UniquePtr<mozilla::widget::RectTextureImage> mBasicCompositorImage;
// Main thread + webrender only
mozilla::Maybe<mozilla::wr::ImageKey> mTitlebarImageKey;
// The area of mTitlebarCGContext that has changed and needs to be
// uploaded to to mTitlebarImage. Main thread only.
nsIntRegion mDirtyTitlebarRegion;

View File

@ -68,6 +68,8 @@
#include "mozilla/layers/CompositorBridgeParent.h"
#include "mozilla/layers/BasicCompositor.h"
#include "mozilla/layers/InputAPZContext.h"
#include "mozilla/layers/WebRenderBridgeChild.h"
#include "mozilla/webrender/WebRenderAPI.h"
#include "mozilla/widget/CompositorWidget.h"
#include "gfxUtils.h"
#include "gfxPrefs.h"
@ -2074,6 +2076,52 @@ nsChildView::CleanupWindowEffects()
mTitlebarImage = nullptr;
}
void
nsChildView::AddWindowOverlayWebRenderCommands(layers::WebRenderBridgeChild* aWrBridge,
wr::DisplayListBuilder& aBuilder)
{
PrepareWindowEffects();
LayoutDeviceIntRegion updatedTitlebarRegion;
updatedTitlebarRegion.And(mUpdatedTitlebarRegion, mTitlebarRect);
mUpdatedTitlebarRegion.SetEmpty();
if (mTitlebarCGContext) {
gfx::IntSize size(CGBitmapContextGetWidth(mTitlebarCGContext),
CGBitmapContextGetHeight(mTitlebarCGContext));
size_t stride = CGBitmapContextGetBytesPerRow(mTitlebarCGContext);
size_t titlebarCGContextDataLength = stride * size.height;
gfx::SurfaceFormat format = gfx::SurfaceFormat::B8G8R8A8;
wr::ByteBuffer buffer(
titlebarCGContextDataLength,
static_cast<uint8_t *>(CGBitmapContextGetData(mTitlebarCGContext)));
if (!mTitlebarImageKey) {
mTitlebarImageKey = Some(aWrBridge->GetNextImageKey());
aWrBridge->SendAddImage(*mTitlebarImageKey, size, stride, format, buffer);
updatedTitlebarRegion.SetEmpty();
}
if (!updatedTitlebarRegion.IsEmpty()) {
aWrBridge->SendUpdateImage(*mTitlebarImageKey, size, format, buffer);
}
WrRect rect = wr::ToWrRect(mTitlebarRect);
WrClipRegionToken clip = aBuilder.PushClipRegion(rect, nullptr);
aBuilder.PushImage(WrRect{ 0, 0, float(size.width), float(size.height) },
clip, wr::ImageRendering::Auto, *mTitlebarImageKey);
}
}
void
nsChildView::CleanupWebRenderWindowOverlay(layers::WebRenderBridgeChild* aWrBridge)
{
if (mTitlebarImageKey) {
aWrBridge->SendDeleteImage(*mTitlebarImageKey);
mTitlebarImageKey = Nothing();
}
}
bool
nsChildView::PreRender(WidgetRenderingContext* aContext)
{

View File

@ -61,6 +61,7 @@ class CompositorBridgeChild;
class LayerManager;
class LayerManagerComposite;
class PLayerTransactionChild;
class WebRenderBridgeChild;
struct ScrollableLayerGuid;
} // namespace layers
namespace gfx {
@ -73,6 +74,9 @@ class TextEventDispatcherListener;
class CompositorWidget;
class CompositorWidgetInitData;
} // namespace widget
namespace wr {
class DisplayListBuilder;
} // namespace wr
} // namespace mozilla
/**
@ -1279,6 +1283,18 @@ class nsIWidget : public nsISupports
*/
virtual void PrepareWindowEffects() = 0;
/**
* Called on the main thread at the end of WebRender display list building.
*/
virtual void AddWindowOverlayWebRenderCommands(mozilla::layers::WebRenderBridgeChild* aWrBridge,
mozilla::wr::DisplayListBuilder& aBuilder) {}
/**
* Called on the main thread when WebRender resources used for
* AddWindowOverlayWebRenderCommands need to be destroyed.
*/
virtual void CleanupWebRenderWindowOverlay(mozilla::layers::WebRenderBridgeChild* aWrBridge) {}
/**
* Called when Gecko knows which themed widgets exist in this window.
* The passed array contains an entry for every themed widget of the right