mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 1390440
- Support nsDisplayPlugin for webrender layers-free mode. r=mattwoodrow
MozReview-Commit-ID: 2DoBo7OkTsb --HG-- extra : rebase_source : 751562bb54e309ab5eff64d4e423125367c7fa9f
This commit is contained in:
parent
85a270b2ce
commit
46edacd44f
@ -57,6 +57,7 @@
|
|||||||
#include "Layers.h"
|
#include "Layers.h"
|
||||||
#include "ReadbackLayer.h"
|
#include "ReadbackLayer.h"
|
||||||
#include "ImageContainer.h"
|
#include "ImageContainer.h"
|
||||||
|
#include "mozilla/layers/WebRenderLayerManager.h"
|
||||||
|
|
||||||
// accessibility support
|
// accessibility support
|
||||||
#ifdef ACCESSIBILITY
|
#ifdef ACCESSIBILITY
|
||||||
@ -1042,6 +1043,20 @@ nsDisplayPlugin::GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
nsDisplayPlugin::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
|
||||||
|
const StackingContextHelper& aSc,
|
||||||
|
nsTArray<WebRenderParentCommand>& aParentCommands,
|
||||||
|
mozilla::layers::WebRenderLayerManager* aManager,
|
||||||
|
nsDisplayListBuilder* aDisplayListBuilder)
|
||||||
|
{
|
||||||
|
return static_cast<nsPluginFrame*>(mFrame)->CreateWebRenderCommands(this,
|
||||||
|
aBuilder,
|
||||||
|
aSc,
|
||||||
|
aManager,
|
||||||
|
aDisplayListBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsPluginFrame::PluginEventNotifier::Run() {
|
nsPluginFrame::PluginEventNotifier::Run() {
|
||||||
nsCOMPtr<nsIObserverService> obsSvc =
|
nsCOMPtr<nsIObserverService> obsSvc =
|
||||||
@ -1355,22 +1370,19 @@ private:
|
|||||||
RefPtr<LayerManager> mLayerManager;
|
RefPtr<LayerManager> mLayerManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
already_AddRefed<Layer>
|
bool
|
||||||
nsPluginFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
|
nsPluginFrame::GetBounds(nsDisplayItem* aItem, IntSize& aSize, gfxRect& aRect)
|
||||||
LayerManager* aManager,
|
|
||||||
nsDisplayItem* aItem,
|
|
||||||
const ContainerLayerParameters& aContainerParameters)
|
|
||||||
{
|
{
|
||||||
if (!mInstanceOwner)
|
if (!mInstanceOwner)
|
||||||
return nullptr;
|
return false;
|
||||||
|
|
||||||
NPWindow* window = nullptr;
|
NPWindow* window = nullptr;
|
||||||
mInstanceOwner->GetWindow(window);
|
mInstanceOwner->GetWindow(window);
|
||||||
if (!window)
|
if (!window)
|
||||||
return nullptr;
|
return false;
|
||||||
|
|
||||||
if (window->width <= 0 || window->height <= 0)
|
if (window->width <= 0 || window->height <= 0)
|
||||||
return nullptr;
|
return false;
|
||||||
|
|
||||||
#if defined(XP_MACOSX)
|
#if defined(XP_MACOSX)
|
||||||
// window is in "display pixels", but size needs to be in device pixels
|
// window is in "display pixels", but size needs to be in device pixels
|
||||||
@ -1385,12 +1397,68 @@ nsPluginFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
|
|||||||
size_t intScaleFactor = 1;
|
size_t intScaleFactor = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
IntSize size(window->width * intScaleFactor, window->height * intScaleFactor);
|
aSize = IntSize(window->width * intScaleFactor, window->height * intScaleFactor);
|
||||||
|
|
||||||
nsRect area = GetContentRectRelativeToSelf() + aItem->ToReferenceFrame();
|
nsRect area = GetContentRectRelativeToSelf() + aItem->ToReferenceFrame();
|
||||||
gfxRect r = nsLayoutUtils::RectToGfxRect(area, PresContext()->AppUnitsPerDevPixel());
|
aRect = nsLayoutUtils::RectToGfxRect(area, PresContext()->AppUnitsPerDevPixel());
|
||||||
// to provide crisper and faster drawing.
|
// to provide crisper and faster drawing.
|
||||||
r.Round();
|
aRect.Round();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
nsPluginFrame::CreateWebRenderCommands(nsDisplayItem* aItem,
|
||||||
|
mozilla::wr::DisplayListBuilder& aBuilder,
|
||||||
|
const StackingContextHelper& aSc,
|
||||||
|
mozilla::layers::WebRenderLayerManager* aManager,
|
||||||
|
nsDisplayListBuilder* aDisplayListBuilder)
|
||||||
|
{
|
||||||
|
IntSize size;
|
||||||
|
gfxRect r;
|
||||||
|
if (!GetBounds(aItem, size, r)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
RefPtr<ImageContainer> container;
|
||||||
|
// Image for Windowed plugins that support window capturing for scroll
|
||||||
|
// operations or async windowless rendering.
|
||||||
|
container = mInstanceOwner->GetImageContainer();
|
||||||
|
if (!container) {
|
||||||
|
// This can occur if our instance is gone or if the current plugin
|
||||||
|
// configuration does not require a backing image layer.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef XP_MACOSX
|
||||||
|
if (!mInstanceOwner->UseAsyncRendering()) {
|
||||||
|
mInstanceOwner->DoCocoaEventDrawRect(r, nullptr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
RefPtr<LayerManager> lm = aDisplayListBuilder->GetWidgetLayerManager();
|
||||||
|
if (!mDidCompositeObserver || !mDidCompositeObserver->IsValid(lm)) {
|
||||||
|
mDidCompositeObserver = MakeUnique<PluginFrameDidCompositeObserver>(mInstanceOwner, lm);
|
||||||
|
}
|
||||||
|
lm->AddDidCompositeObserver(mDidCompositeObserver.get());
|
||||||
|
|
||||||
|
LayerRect dest(r.x, r.y, size.width, size.height);
|
||||||
|
return aManager->PushImage(aItem, container, aBuilder, aSc, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
already_AddRefed<Layer>
|
||||||
|
nsPluginFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
|
||||||
|
LayerManager* aManager,
|
||||||
|
nsDisplayItem* aItem,
|
||||||
|
const ContainerLayerParameters& aContainerParameters)
|
||||||
|
{
|
||||||
|
IntSize size;
|
||||||
|
gfxRect r;
|
||||||
|
if (!GetBounds(aItem, size, r)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
RefPtr<Layer> layer =
|
RefPtr<Layer> layer =
|
||||||
(aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem));
|
(aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem));
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
#include "nsDisplayList.h"
|
#include "nsDisplayList.h"
|
||||||
#include "nsIReflowCallback.h"
|
#include "nsIReflowCallback.h"
|
||||||
#include "Units.h"
|
#include "Units.h"
|
||||||
|
#include "mozilla/layers/StackingContextHelper.h"
|
||||||
|
#include "mozilla/webrender/WebRenderAPI.h"
|
||||||
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
#include <windows.h> // For HWND :(
|
#include <windows.h> // For HWND :(
|
||||||
@ -60,6 +62,9 @@ public:
|
|||||||
typedef mozilla::layers::Layer Layer;
|
typedef mozilla::layers::Layer Layer;
|
||||||
typedef mozilla::layers::LayerManager LayerManager;
|
typedef mozilla::layers::LayerManager LayerManager;
|
||||||
typedef mozilla::layers::ImageContainer ImageContainer;
|
typedef mozilla::layers::ImageContainer ImageContainer;
|
||||||
|
typedef mozilla::layers::StackingContextHelper StackingContextHelper;
|
||||||
|
typedef mozilla::layers::WebRenderLayerManager WebRenderLayerManager;
|
||||||
|
typedef mozilla::layers::WebRenderParentCommand WebRenderParentCommand;
|
||||||
typedef mozilla::ContainerLayerParameters ContainerLayerParameters;
|
typedef mozilla::ContainerLayerParameters ContainerLayerParameters;
|
||||||
|
|
||||||
NS_DECL_FRAMEARENA_HELPERS(nsPluginFrame)
|
NS_DECL_FRAMEARENA_HELPERS(nsPluginFrame)
|
||||||
@ -221,6 +226,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool WantsToHandleWheelEventAsDefaultAction() const;
|
bool WantsToHandleWheelEventAsDefaultAction() const;
|
||||||
|
|
||||||
|
bool CreateWebRenderCommands(nsDisplayItem* aItem,
|
||||||
|
mozilla::wr::DisplayListBuilder& aBuilder,
|
||||||
|
const StackingContextHelper& aSc,
|
||||||
|
mozilla::layers::WebRenderLayerManager* aManager,
|
||||||
|
nsDisplayListBuilder* aDisplayListBuilder);
|
||||||
protected:
|
protected:
|
||||||
explicit nsPluginFrame(nsStyleContext* aContext);
|
explicit nsPluginFrame(nsStyleContext* aContext);
|
||||||
virtual ~nsPluginFrame();
|
virtual ~nsPluginFrame();
|
||||||
@ -267,6 +277,7 @@ protected:
|
|||||||
|
|
||||||
nsView* GetViewInternal() const override { return mOuterView; }
|
nsView* GetViewInternal() const override { return mOuterView; }
|
||||||
void SetViewInternal(nsView* aView) override { mOuterView = aView; }
|
void SetViewInternal(nsView* aView) override { mOuterView = aView; }
|
||||||
|
bool GetBounds(nsDisplayItem* aItem, mozilla::gfx::IntSize& aSize, gfxRect& aRect);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Registers the plugin for a geometry update, and requests a geometry
|
// Registers the plugin for a geometry update, and requests a geometry
|
||||||
@ -377,6 +388,12 @@ public:
|
|||||||
return static_cast<nsPluginFrame*>(mFrame)->GetLayerState(aBuilder,
|
return static_cast<nsPluginFrame*>(mFrame)->GetLayerState(aBuilder,
|
||||||
aManager);
|
aManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
|
||||||
|
const StackingContextHelper& aSc,
|
||||||
|
nsTArray<WebRenderParentCommand>& aParentCommands,
|
||||||
|
mozilla::layers::WebRenderLayerManager* aManager,
|
||||||
|
nsDisplayListBuilder* aDisplayListBuilder) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* nsPluginFrame_h___ */
|
#endif /* nsPluginFrame_h___ */
|
||||||
|
Loading…
Reference in New Issue
Block a user