Bug 1239530 (part 2) - Use LayoutDevice coordinates in {Start,End}RemoteDrawingInRegion() and related functions. r=kats.

This commit is contained in:
Nicholas Nethercote 2015-12-02 22:29:54 -08:00
parent 56879cdd59
commit 60484915e6
16 changed files with 70 additions and 62 deletions

View File

@ -532,7 +532,7 @@ protected:
ScreenRotation mScreenRotation;
virtual gfx::IntSize GetWidgetSize() const = 0;
virtual LayoutDeviceIntSize GetWidgetSize() const = 0;
RefPtr<gfx::DrawTarget> mTarget;
gfx::IntRect mTargetBounds;

View File

@ -520,11 +520,11 @@ BasicCompositor::BeginFrame(const nsIntRegion& aInvalidRegion,
gfx::Rect *aClipRectOut /* = nullptr */,
gfx::Rect *aRenderBoundsOut /* = nullptr */)
{
mWidgetSize = mWidget->GetClientSize().ToUnknownSize();
IntRect intRect = gfx::IntRect(IntPoint(), mWidgetSize);
mWidgetSize = mWidget->GetClientSize();
LayoutDeviceIntRect intRect(LayoutDeviceIntPoint(), mWidgetSize);
Rect rect = Rect(0, 0, intRect.width, intRect.height);
nsIntRegion invalidRegionSafe;
LayoutDeviceIntRegion invalidRegionSafe;
if (mDidExternalComposition) {
// We do not know rendered region during external composition, just redraw
// whole widget.
@ -532,7 +532,8 @@ BasicCompositor::BeginFrame(const nsIntRegion& aInvalidRegion,
mDidExternalComposition = false;
} else {
// Sometimes the invalid region is larger than we want to draw.
invalidRegionSafe.And(aInvalidRegion, intRect);
invalidRegionSafe.And(
LayoutDeviceIntRegion::FromUnknownRegion(aInvalidRegion), intRect);
}
mInvalidRegion = invalidRegionSafe;
@ -562,7 +563,8 @@ BasicCompositor::BeginFrame(const nsIntRegion& aInvalidRegion,
// Setup an intermediate render target to buffer all compositing. We will
// copy this into mDrawTarget (the widget), and/or mTarget in EndFrame()
RefPtr<CompositingRenderTarget> target = CreateRenderTarget(mInvalidRect, INIT_MODE_CLEAR);
RefPtr<CompositingRenderTarget> target =
CreateRenderTarget(mInvalidRect.ToUnknownRect(), INIT_MODE_CLEAR);
if (!target) {
if (!mTarget) {
mWidget->EndRemoteDrawingInRegion(mDrawTarget, mInvalidRegion);
@ -576,7 +578,8 @@ BasicCompositor::BeginFrame(const nsIntRegion& aInvalidRegion,
mRenderTarget->mDrawTarget->SetTransform(Matrix::Translation(-mInvalidRect.x,
-mInvalidRect.y));
gfxUtils::ClipToRegion(mRenderTarget->mDrawTarget, mInvalidRegion);
gfxUtils::ClipToRegion(mRenderTarget->mDrawTarget,
mInvalidRegion.ToUnknownRegion());
if (aRenderBoundsOut) {
*aRenderBoundsOut = rect;
@ -603,8 +606,9 @@ BasicCompositor::EndFrame()
float g = float(rand()) / RAND_MAX;
float b = float(rand()) / RAND_MAX;
// We're still clipped to mInvalidRegion, so just fill the bounds.
mRenderTarget->mDrawTarget->FillRect(IntRectToRect(mInvalidRegion.GetBounds()),
ColorPattern(Color(r, g, b, 0.2f)));
mRenderTarget->mDrawTarget->FillRect(
IntRectToRect(mInvalidRegion.GetBounds()).ToUnknownRect(),
ColorPattern(Color(r, g, b, 0.2f)));
}
// Pop aInvalidregion
@ -620,8 +624,8 @@ BasicCompositor::EndFrame()
// The source DrawTarget is clipped to the invalidation region, so we have
// to copy the individual rectangles in the region or else we'll draw blank
// pixels.
nsIntRegionRectIterator iter(mInvalidRegion);
for (const IntRect *r = iter.Next(); r; r = iter.Next()) {
LayoutDeviceIntRegion::RectIterator iter(mInvalidRegion);
for (const LayoutDeviceIntRect *r = iter.Next(); r; r = iter.Next()) {
dest->CopySurface(source,
IntRect(r->x - mInvalidRect.x, r->y - mInvalidRect.y, r->width, r->height),
IntPoint(r->x - offset.x, r->y - offset.y));

View File

@ -116,19 +116,19 @@ public:
private:
virtual gfx::IntSize GetWidgetSize() const override { return mWidgetSize; }
virtual LayoutDeviceIntSize GetWidgetSize() const override { return mWidgetSize; }
// Widget associated with this compositor
nsIWidget *mWidget;
gfx::IntSize mWidgetSize;
LayoutDeviceIntSize mWidgetSize;
// The final destination surface
RefPtr<gfx::DrawTarget> mDrawTarget;
// The current render target for drawing
RefPtr<BasicCompositingRenderTarget> mRenderTarget;
gfx::IntRect mInvalidRect;
nsIntRegion mInvalidRegion;
LayoutDeviceIntRect mInvalidRect;
LayoutDeviceIntRegion mInvalidRegion;
bool mDidExternalComposition;
uint32_t mMaxTextureSize;

View File

@ -1037,7 +1037,7 @@ CompositorD3D11::BeginFrame(const nsIntRegion& aInvalidRegion,
return;
}
IntSize oldSize = mSize;
LayoutDeviceIntSize oldSize = mSize;
// Failed to create a render target or the view.
if (!UpdateRenderTarget() || !mDefaultRT || !mDefaultRT->mRTView ||
@ -1053,7 +1053,7 @@ CompositorD3D11::BeginFrame(const nsIntRegion& aInvalidRegion,
UINT offset = 0;
mContext->IASetVertexBuffers(0, 1, &buffer, &size, &offset);
IntRect intRect = IntRect(IntPoint(0, 0), mSize);
IntRect intRect = IntRect(IntPoint(0, 0), mSize.ToUnknownSize());
// Sometimes the invalid region is larger than we want to draw.
nsIntRegion invalidRegionSafe;
@ -1108,7 +1108,7 @@ CompositorD3D11::EndFrame()
return;
}
IntSize oldSize = mSize;
LayoutDeviceIntSize oldSize = mSize;
EnsureSize();
if (mSize.width <= 0 || mSize.height <= 0) {
return;
@ -1206,7 +1206,7 @@ CompositorD3D11::EnsureSize()
LayoutDeviceIntRect rect;
mWidget->GetClientBounds(rect);
mSize = rect.Size().ToUnknownSize();
mSize = rect.Size();
}
bool
@ -1322,7 +1322,7 @@ CompositorD3D11::UpdateRenderTarget()
}
mDefaultRT = new CompositingRenderTargetD3D11(backBuf, IntPoint(0, 0));
mDefaultRT->SetSize(mSize);
mDefaultRT->SetSize(mSize.ToUnknownSize());
return true;
}

View File

@ -171,7 +171,7 @@ private:
void SetPSForEffect(Effect *aEffect, MaskType aMaskType, gfx::SurfaceFormat aFormat);
void PaintToTarget();
virtual gfx::IntSize GetWidgetSize() const override { return mSize; }
virtual LayoutDeviceIntSize GetWidgetSize() const override { return mSize; }
RefPtr<ID3D11DeviceContext> mContext;
RefPtr<ID3D11Device> mDevice;
@ -183,7 +183,7 @@ private:
nsIWidget* mWidget;
gfx::IntSize mSize;
LayoutDeviceIntSize mSize;
HWND mHwnd;

View File

@ -663,7 +663,7 @@ CompositorD3D9::EndFrame()
if (mDeviceManager) {
device()->EndScene();
IntSize oldSize = mSize;
LayoutDeviceIntSize oldSize = mSize;
EnsureSize();
if (oldSize == mSize) {
if (mTarget) {
@ -705,7 +705,7 @@ CompositorD3D9::EnsureSize()
LayoutDeviceIntRect rect;
mWidget->GetClientBounds(rect);
mSize = rect.Size().ToUnknownSize();
mSize = rect.Size();
}
void

View File

@ -152,7 +152,7 @@ private:
void ReportFailure(const nsACString &aMsg, HRESULT aCode);
virtual gfx::IntSize GetWidgetSize() const override
virtual LayoutDeviceIntSize GetWidgetSize() const override
{
return mSize;
}
@ -169,7 +169,7 @@ private:
RefPtr<CompositingRenderTargetD3D9> mDefaultRT;
RefPtr<CompositingRenderTargetD3D9> mCurrentRT;
gfx::IntSize mSize;
LayoutDeviceIntSize mSize;
uint32_t mDeviceResetCount;
uint32_t mFailedResetAttempts;

View File

@ -679,8 +679,9 @@ CompositorOGL::BeginFrame(const nsIntRegion& aInvalidRegion,
mGLContext->fEnable(LOCAL_GL_SCISSOR_TEST);
// Prefer the native windowing system's provided window size for the viewport.
IntSize viewportSize = mGLContext->GetTargetSize().valueOr(mWidgetSize);
if (viewportSize != mWidgetSize) {
IntSize viewportSize =
mGLContext->GetTargetSize().valueOr(mWidgetSize.ToUnknownSize());
if (viewportSize != mWidgetSize.ToUnknownSize()) {
mGLContext->fScissor(0, 0, viewportSize.width, viewportSize.height);
}

View File

@ -305,7 +305,7 @@ public:
}
private:
virtual gfx::IntSize GetWidgetSize() const override
virtual LayoutDeviceIntSize GetWidgetSize() const override
{
return mWidgetSize;
}
@ -323,7 +323,7 @@ private:
/** Widget associated with this compositor */
nsIWidget *mWidget;
gfx::IntSize mWidgetSize;
LayoutDeviceIntSize mWidgetSize;
RefPtr<GLContext> mGLContext;
UniquePtr<GLBlitTextureImageHelper> mBlitTextureImageHelper;
gfx::Matrix4x4 mProjMatrix;

View File

@ -544,7 +544,7 @@ public:
return nsCocoaUtils::DevPixelsToCocoaPoints(aRect, BackingScaleFactor());
}
already_AddRefed<mozilla::gfx::DrawTarget> StartRemoteDrawingInRegion(nsIntRegion& aInvalidRegion) override;
already_AddRefed<mozilla::gfx::DrawTarget> StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion) override;
void EndRemoteDrawing() override;
void CleanupRemoteDrawing() override;
bool InitCompositor(mozilla::layers::Compositor* aCompositor) override;

View File

@ -2637,7 +2637,7 @@ nsChildView::SwipeFinished()
}
already_AddRefed<gfx::DrawTarget>
nsChildView::StartRemoteDrawingInRegion(nsIntRegion& aInvalidRegion)
nsChildView::StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion)
{
// should have created the GLPresenter in InitCompositor.
MOZ_ASSERT(mGLPresenter);
@ -2649,7 +2649,7 @@ nsChildView::StartRemoteDrawingInRegion(nsIntRegion& aInvalidRegion)
}
}
LayoutDeviceIntRegion dirtyRegion(LayoutDeviceIntRegion::FromUnknownRegion(aInvalidRegion));
LayoutDeviceIntRegion dirtyRegion(aInvalidRegion);
LayoutDeviceIntSize renderSize =
LayoutDeviceIntSize::FromUnknownSize(mBounds.Size());
@ -2666,7 +2666,7 @@ nsChildView::StartRemoteDrawingInRegion(nsIntRegion& aInvalidRegion)
return nullptr;
}
aInvalidRegion = mBasicCompositorImage->GetUpdateRegion().ToUnknownRegion();
aInvalidRegion = mBasicCompositorImage->GetUpdateRegion();
return drawTarget.forget();
}

View File

@ -2228,7 +2228,7 @@ nsWindow::OnExposeEvent(cairo_t *cr)
return TRUE;
}
RefPtr<DrawTarget> dt = GetDrawTarget(region.ToUnknownRegion());
RefPtr<DrawTarget> dt = GetDrawTarget(region);
if (!dt) {
return FALSE;
}
@ -2312,7 +2312,7 @@ nsWindow::OnExposeEvent(cairo_t *cr)
# ifdef MOZ_HAVE_SHMIMAGE
if (mShmImage && MOZ_LIKELY(!mIsDestroyed)) {
mShmImage->Put(mXDisplay, mXWindow, region.ToUnknownRegion());
mShmImage->Put(mXDisplay, mXWindow, region);
}
# endif // MOZ_HAVE_SHMIMAGE
#endif // MOZ_X11
@ -6462,14 +6462,14 @@ nsWindow::GetSurfaceForGdkDrawable(GdkDrawable* aDrawable,
#endif
already_AddRefed<DrawTarget>
nsWindow::GetDrawTarget(const nsIntRegion& aRegion)
nsWindow::GetDrawTarget(const LayoutDeviceIntRegion& aRegion)
{
if (!mGdkWindow) {
return nullptr;
}
nsIntRect bounds = aRegion.GetBounds();
IntSize size(bounds.XMost(), bounds.YMost());
LayoutDeviceIntRect bounds = aRegion.GetBounds();
LayoutDeviceIntSize size(bounds.XMost(), bounds.YMost());
if (size.width <= 0 || size.height <= 0) {
return nullptr;
}
@ -6480,12 +6480,11 @@ nsWindow::GetDrawTarget(const nsIntRegion& aRegion)
# ifdef MOZ_HAVE_SHMIMAGE
if (nsShmImage::UseShm()) {
dt = nsShmImage::EnsureShmImage(size,
mXDisplay, mXVisual, mXDepth,
mShmImage);
mXDisplay, mXVisual, mXDepth, mShmImage);
}
# endif // MOZ_HAVE_SHMIMAGE
if (!dt) {
RefPtr<gfxXlibSurface> surf = new gfxXlibSurface(mXDisplay, mXWindow, mXVisual, size);
RefPtr<gfxXlibSurface> surf = new gfxXlibSurface(mXDisplay, mXWindow, mXVisual, size.ToUnknownSize());
if (!surf->CairoStatus()) {
dt = gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(surf.get(), surf->GetSize());
}
@ -6496,13 +6495,14 @@ nsWindow::GetDrawTarget(const nsIntRegion& aRegion)
}
already_AddRefed<DrawTarget>
nsWindow::StartRemoteDrawingInRegion(nsIntRegion& aInvalidRegion)
nsWindow::StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion)
{
return GetDrawTarget(aInvalidRegion);
}
void
nsWindow::EndRemoteDrawingInRegion(DrawTarget* aDrawTarget, nsIntRegion& aInvalidRegion)
nsWindow::EndRemoteDrawingInRegion(DrawTarget* aDrawTarget,
LayoutDeviceIntRegion& aInvalidRegion)
{
#ifdef MOZ_X11
# ifdef MOZ_HAVE_SHMIMAGE

View File

@ -215,9 +215,9 @@ public:
#endif
virtual already_AddRefed<mozilla::gfx::DrawTarget>
StartRemoteDrawingInRegion(nsIntRegion& aInvalidRegion) override;
StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion) override;
virtual void EndRemoteDrawingInRegion(mozilla::gfx::DrawTarget* aDrawTarget,
nsIntRegion& aInvalidRegion) override;
LayoutDeviceIntRegion& aInvalidRegion) override;
private:
void UpdateAlpha(mozilla::gfx::SourceSurface* aSourceSurface, nsIntRect aBoundsRect);
@ -308,7 +308,7 @@ public:
virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations) override;
nsresult UpdateTranslucentWindowAlphaInternal(const nsIntRect& aRect,
uint8_t* aAlphas, int32_t aStride);
virtual already_AddRefed<mozilla::gfx::DrawTarget> GetDrawTarget(const nsIntRegion& aRegion);
virtual already_AddRefed<mozilla::gfx::DrawTarget> GetDrawTarget(const LayoutDeviceIntRegion& aRegion);
#if (MOZ_WIDGET_GTK == 2)
static already_AddRefed<gfxASurface> GetSurfaceForGdkDrawable(GdkDrawable* aDrawable,

View File

@ -1288,7 +1288,7 @@ class nsIWidget : public nsISupports {
* before each composition.
*/
virtual already_AddRefed<mozilla::gfx::DrawTarget> StartRemoteDrawing() = 0;
virtual already_AddRefed<mozilla::gfx::DrawTarget> StartRemoteDrawingInRegion(nsIntRegion& aInvalidRegion) {
virtual already_AddRefed<mozilla::gfx::DrawTarget> StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion) {
return StartRemoteDrawing();
}
@ -1300,7 +1300,7 @@ class nsIWidget : public nsISupports {
* after each composition.
*/
virtual void EndRemoteDrawing() = 0;
virtual void EndRemoteDrawingInRegion(mozilla::gfx::DrawTarget* aDrawTarget, nsIntRegion& aInvalidRegion) {
virtual void EndRemoteDrawingInRegion(mozilla::gfx::DrawTarget* aDrawTarget, LayoutDeviceIntRegion& aInvalidRegion) {
EndRemoteDrawing();
}

View File

@ -46,7 +46,7 @@ TrapShmError(Display* aDisplay, XErrorEvent* aEvent)
#endif
already_AddRefed<nsShmImage>
nsShmImage::Create(const IntSize& aSize,
nsShmImage::Create(const LayoutDeviceIntSize& aSize,
Display* aDisplay, Visual* aVisual, unsigned int aDepth)
{
RefPtr<nsShmImage> shm = new nsShmImage();
@ -128,20 +128,22 @@ nsShmImage::CreateDrawTarget()
{
return gfxPlatform::GetPlatform()->CreateDrawTargetForData(
static_cast<unsigned char*>(mSegment->memory()),
mSize,
mSize.ToUnknownSize(),
mImage->bytes_per_line,
mFormat);
}
#ifdef MOZ_WIDGET_GTK
void
nsShmImage::Put(Display* aDisplay, Drawable aWindow, const nsIntRegion& aRegion)
nsShmImage::Put(Display* aDisplay, Drawable aWindow,
const LayoutDeviceIntRegion& aRegion)
{
GC gc = XCreateGC(aDisplay, aWindow, 0, nullptr);
nsIntRegion bounded;
bounded.And(aRegion, nsIntRect(0, 0, mImage->width, mImage->height));
nsIntRegionRectIterator iter(bounded);
for (const nsIntRect *r = iter.Next(); r; r = iter.Next()) {
LayoutDeviceIntRegion bounded;
bounded.And(aRegion,
LayoutDeviceIntRect(0, 0, mImage->width, mImage->height));
LayoutDeviceIntRegion::RectIterator iter(bounded);
for (const LayoutDeviceIntRect *r = iter.Next(); r; r = iter.Next()) {
XShmPutImage(aDisplay, aWindow, gc, mImage,
r->x, r->y,
r->x, r->y,
@ -180,7 +182,7 @@ nsShmImage::Put(QWindow* aWindow, QRect& aRect)
#endif
already_AddRefed<DrawTarget>
nsShmImage::EnsureShmImage(const IntSize& aSize,
nsShmImage::EnsureShmImage(const LayoutDeviceIntSize& aSize,
Display* aDisplay, Visual* aVisual, unsigned int aDepth,
RefPtr<nsShmImage>& aImage)
{

View File

@ -38,10 +38,10 @@ class nsShmImage {
public:
static bool UseShm();
static already_AddRefed<nsShmImage>
Create(const mozilla::gfx::IntSize& aSize,
Create(const mozilla::LayoutDeviceIntSize& aSize,
Display* aDisplay, Visual* aVisual, unsigned int aDepth);
static already_AddRefed<mozilla::gfx::DrawTarget>
EnsureShmImage(const mozilla::gfx::IntSize& aSize,
EnsureShmImage(const mozilla::LayoutDeviceIntSize& aSize,
Display* aDisplay, Visual* aVisual, unsigned int aDepth,
RefPtr<nsShmImage>& aImage);
@ -60,12 +60,13 @@ public:
already_AddRefed<mozilla::gfx::DrawTarget> CreateDrawTarget();
#ifdef MOZ_WIDGET_GTK
void Put(Display* aDisplay, Drawable aWindow, const nsIntRegion& aRegion);
void Put(Display* aDisplay, Drawable aWindow,
const LayoutDeviceIntRegion& aRegion);
#elif defined(MOZ_WIDGET_QT)
void Put(QWindow* aWindow, QRect& aRect);
#endif
mozilla::gfx::IntSize Size() const { return mSize; }
mozilla::LayoutDeviceIntSize Size() const { return mSize; }
private:
nsShmImage()
@ -79,7 +80,7 @@ private:
XImage* mImage;
Display* mDisplay;
XShmSegmentInfo mInfo;
mozilla::gfx::IntSize mSize;
mozilla::LayoutDeviceIntSize mSize;
mozilla::gfx::SurfaceFormat mFormat;
bool mXAttached;
};