mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 13:07:52 +00:00
Remove drawWidgetAsOnScreen. (bug 1264393, r=mattwoodrow, webidl r=khuey)
--HG-- extra : rebase_source : c885b1db5ede6caa8b1e141d6d76769bac82b16c
This commit is contained in:
parent
d6470a3040
commit
ef94ddb6f5
@ -5111,51 +5111,6 @@ CanvasRenderingContext2D::AsyncDrawXULElement(nsXULElement& aElem,
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
CanvasRenderingContext2D::DrawWidgetAsOnScreen(nsGlobalWindow& aWindow,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
EnsureTarget();
|
||||
|
||||
// This is an internal API.
|
||||
if (!nsContentUtils::IsCallerChrome()) {
|
||||
aError.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<nsPresContext> presContext;
|
||||
nsIDocShell* docshell = aWindow.GetDocShell();
|
||||
if (docshell) {
|
||||
docshell->GetPresContext(getter_AddRefs(presContext));
|
||||
}
|
||||
if (!presContext) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
nsIWidget* widget = presContext->GetRootWidget();
|
||||
if (!widget) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
RefPtr<SourceSurface> snapshot = widget->SnapshotWidgetOnScreen();
|
||||
if (!snapshot) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
gfx::Rect sourceRect(gfx::Point(0, 0), gfx::Size(snapshot->GetSize()));
|
||||
mTarget->DrawSurface(snapshot, sourceRect, sourceRect,
|
||||
DrawSurfaceOptions(gfx::Filter::POINT),
|
||||
DrawOptions(GlobalAlpha(), CompositionOp::OP_OVER,
|
||||
AntialiasMode::NONE));
|
||||
mTarget->Flush();
|
||||
|
||||
RedrawUser(gfxRect(0, 0,
|
||||
std::min(mWidth, snapshot->GetSize().width),
|
||||
std::min(mHeight, snapshot->GetSize().height)));
|
||||
}
|
||||
|
||||
//
|
||||
// device pixel getting/setting
|
||||
//
|
||||
|
@ -409,8 +409,6 @@ public:
|
||||
double aW, double aH,
|
||||
const nsAString& aBgColor, uint32_t aFlags,
|
||||
mozilla::ErrorResult& aError);
|
||||
void DrawWidgetAsOnScreen(nsGlobalWindow& aWindow,
|
||||
mozilla::ErrorResult& aError);
|
||||
void AsyncDrawXULElement(nsXULElement& aElem, double aX, double aY, double aW,
|
||||
double aH, const nsAString& aBgColor, uint32_t aFlags,
|
||||
mozilla::ErrorResult& aError);
|
||||
|
@ -231,17 +231,6 @@ interface CanvasRenderingContext2D {
|
||||
double h, DOMString bgColor,
|
||||
optional unsigned long flags = 0);
|
||||
|
||||
/**
|
||||
* Render the root widget of a window into the canvas. Unlike drawWindow,
|
||||
* this uses the operating system to snapshot the widget on-screen, rather
|
||||
* than reading from our own compositor.
|
||||
*
|
||||
* Currently, this is only supported on Windows, and only on widgets that
|
||||
* use OMTC, and only from within the chrome process.
|
||||
*/
|
||||
[Throws, ChromeOnly]
|
||||
void drawWidgetAsOnScreen(Window window);
|
||||
|
||||
/**
|
||||
* This causes a context that is currently using a hardware-accelerated
|
||||
* backend to fallback to a software one. All state should be preserved.
|
||||
|
@ -828,22 +828,6 @@ CompositorBridgeParent::RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorBridgeParent::RecvMakeWidgetSnapshot(const SurfaceDescriptor& aInSnapshot)
|
||||
{
|
||||
if (!mCompositor || !mCompositor->GetWidget()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<DrawTarget> target = GetDrawTargetForDescriptor(aInSnapshot, gfx::BackendType::CAIRO);
|
||||
MOZ_ASSERT(target);
|
||||
if (!target) {
|
||||
return false;
|
||||
}
|
||||
mCompositor->GetWidget()->CaptureWidgetOnScreen(target);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorBridgeParent::RecvFlushRendering()
|
||||
{
|
||||
@ -1939,8 +1923,6 @@ public:
|
||||
virtual bool RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot,
|
||||
const gfx::IntRect& aRect) override
|
||||
{ return true; }
|
||||
virtual bool RecvMakeWidgetSnapshot(const SurfaceDescriptor& aInSnapshot) override
|
||||
{ return true; }
|
||||
virtual bool RecvFlushRendering() override { return true; }
|
||||
virtual bool RecvForcePresent() override { return true; }
|
||||
virtual bool RecvNotifyRegionInvalidated(const nsIntRegion& aRegion) override { return true; }
|
||||
|
@ -236,7 +236,6 @@ public:
|
||||
virtual bool RecvAdoptChild(const uint64_t& child) override;
|
||||
virtual bool RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot,
|
||||
const gfx::IntRect& aRect) override;
|
||||
virtual bool RecvMakeWidgetSnapshot(const SurfaceDescriptor& aInSnapshot) override;
|
||||
virtual bool RecvFlushRendering() override;
|
||||
virtual bool RecvForcePresent() override;
|
||||
|
||||
|
@ -138,14 +138,6 @@ parent:
|
||||
// and so forth being interpolated. That's what we want to happen.
|
||||
sync MakeSnapshot(SurfaceDescriptor inSnapshot, IntRect dirtyRect);
|
||||
|
||||
// Same as Makesnapshot(), except the snapshot is read from the underlying
|
||||
// operating system desktop rather than the compositor's backbuffer. This
|
||||
// is intended for testing whether hardware acceleration works.
|
||||
//
|
||||
// This call is part of IPDL, even though it simply wraps an nsIWidget
|
||||
// call, to make sure it does not occur in the middle of a composite.
|
||||
sync MakeWidgetSnapshot(SurfaceDescriptor inSnapshot);
|
||||
|
||||
// Make sure any pending composites are started immediately and
|
||||
// block until they are completed.
|
||||
sync FlushRendering();
|
||||
|
@ -2107,60 +2107,6 @@ nsIWidget::UpdateRegisteredPluginWindowVisibility(uintptr_t aOwnerWidget,
|
||||
#endif
|
||||
}
|
||||
|
||||
already_AddRefed<mozilla::gfx::SourceSurface>
|
||||
nsIWidget::SnapshotWidgetOnScreen()
|
||||
{
|
||||
// This is only supported on a widget with a compositor.
|
||||
LayerManager* layerManager = GetLayerManager();
|
||||
if (!layerManager) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ClientLayerManager* lm = layerManager->AsClientLayerManager();
|
||||
if (!lm) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CompositorBridgeChild* cc = lm->GetRemoteRenderer();
|
||||
if (!cc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
LayoutDeviceIntRect bounds;
|
||||
GetBounds(bounds);
|
||||
if (bounds.IsEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
gfx::IntSize size(bounds.width, bounds.height);
|
||||
|
||||
ShadowLayerForwarder* forwarder = lm->AsShadowForwarder();
|
||||
SurfaceDescriptor surface;
|
||||
if (!forwarder->AllocSurfaceDescriptor(size, gfxContentType::COLOR_ALPHA, &surface)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!cc->SendMakeWidgetSnapshot(surface)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<gfx::DataSourceSurface> snapshot = GetSurfaceForDescriptor(surface);
|
||||
RefPtr<gfx::DrawTarget> dt =
|
||||
gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(size, gfx::SurfaceFormat::B8G8R8A8);
|
||||
if (!snapshot || !dt) {
|
||||
forwarder->DestroySurfaceDescriptor(&surface);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
dt->DrawSurface(snapshot,
|
||||
gfx::Rect(gfx::Point(), gfx::Size(size)),
|
||||
gfx::Rect(gfx::Point(), gfx::Size(size)),
|
||||
gfx::DrawSurfaceOptions(gfx::Filter::POINT));
|
||||
|
||||
forwarder->DestroySurfaceDescriptor(&surface);
|
||||
return dt->Snapshot();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsIWidget::NativeIMEContext)
|
||||
nsIWidget::GetNativeIMEContext()
|
||||
{
|
||||
|
@ -323,10 +323,6 @@ public:
|
||||
virtual const SizeConstraints GetSizeConstraints() override;
|
||||
virtual void SetSizeConstraints(const SizeConstraints& aConstraints) override;
|
||||
|
||||
virtual bool CaptureWidgetOnScreen(RefPtr<mozilla::gfx::DrawTarget> aDT) override {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void StartAsyncScrollbarDrag(const AsyncDragMetrics& aDragMetrics) override;
|
||||
|
||||
/**
|
||||
|
@ -1721,23 +1721,6 @@ class nsIWidget : public nsISupports {
|
||||
*/
|
||||
virtual nsresult ClearNativeTouchSequence(nsIObserver* aObserver);
|
||||
|
||||
/*
|
||||
* Snapshot the contents of the widget by reading pixels back from the
|
||||
* Operating System. Unlike RenderDocument(), this does not read from our
|
||||
* own backbuffers, so that we can test if there is a difference in how
|
||||
* our buffers are being presented.
|
||||
*
|
||||
* This is only supported for widgets using OMTC.
|
||||
*/
|
||||
already_AddRefed<mozilla::gfx::SourceSurface> SnapshotWidgetOnScreen();
|
||||
|
||||
/*
|
||||
* Implementation of SnapshotWidgetOnScreen. This is invoked by the
|
||||
* compositor for SnapshotWidgetOnScreen(), and should not be called
|
||||
* otherwise.
|
||||
*/
|
||||
virtual bool CaptureWidgetOnScreen(RefPtr<mozilla::gfx::DrawTarget> aDT) = 0;
|
||||
|
||||
virtual void StartAsyncScrollbarDrag(const AsyncDragMetrics& aDragMetrics) = 0;
|
||||
|
||||
private:
|
||||
|
@ -7793,47 +7793,6 @@ void nsWindow::PickerClosed()
|
||||
}
|
||||
}
|
||||
|
||||
bool nsWindow::CaptureWidgetOnScreen(RefPtr<DrawTarget> aDT)
|
||||
{
|
||||
BOOL dwmEnabled = false;
|
||||
if (WinUtils::dwmIsCompositionEnabledPtr &&
|
||||
WinUtils::dwmFlushProcPtr &&
|
||||
WinUtils::dwmIsCompositionEnabledPtr(&dwmEnabled) &&
|
||||
dwmEnabled)
|
||||
{
|
||||
WinUtils::dwmFlushProcPtr();
|
||||
}
|
||||
|
||||
HDC dc = ::GetDC(mWnd);
|
||||
uint32_t flags = (mTransparencyMode == eTransparencyOpaque)
|
||||
? 0
|
||||
: gfxWindowsSurface::FLAG_IS_TRANSPARENT;
|
||||
|
||||
RefPtr<gfxASurface> surf = new gfxWindowsSurface(dc, flags);
|
||||
IntSize size(surf->GetSize().width, surf->GetSize().height);
|
||||
if (size.width <= 0 || size.height <= 0) {
|
||||
::ReleaseDC(mWnd, dc);
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<DrawTarget> source = Factory::CreateDrawTargetForCairoSurface(surf->CairoSurface(), size);
|
||||
if (!source) {
|
||||
::ReleaseDC(mWnd, dc);
|
||||
return false;
|
||||
}
|
||||
RefPtr<SourceSurface> snapshot = source->Snapshot();
|
||||
if (!snapshot) {
|
||||
::ReleaseDC(mWnd, dc);
|
||||
return false;
|
||||
}
|
||||
|
||||
aDT->DrawSurface(snapshot,
|
||||
Rect(0, 0, size.width, size.height),
|
||||
Rect(0, 0, size.width, size.height));
|
||||
::ReleaseDC(mWnd, dc);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool nsWindow::PreRender(LayerManagerComposite*)
|
||||
{
|
||||
// This can block waiting for WM_SETTEXT to finish
|
||||
|
@ -304,8 +304,6 @@ public:
|
||||
bool IsPopup();
|
||||
virtual bool ShouldUseOffMainThreadCompositing() override;
|
||||
|
||||
bool CaptureWidgetOnScreen(RefPtr<mozilla::gfx::DrawTarget> aDT) override;
|
||||
|
||||
const IMEContext& DefaultIMC() const { return mDefaultIMC; }
|
||||
|
||||
virtual void SetCandidateWindowForPlugin(
|
||||
|
Loading…
x
Reference in New Issue
Block a user