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; ScreenRotation mScreenRotation;
virtual gfx::IntSize GetWidgetSize() const = 0; virtual LayoutDeviceIntSize GetWidgetSize() const = 0;
RefPtr<gfx::DrawTarget> mTarget; RefPtr<gfx::DrawTarget> mTarget;
gfx::IntRect mTargetBounds; gfx::IntRect mTargetBounds;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -544,7 +544,7 @@ public:
return nsCocoaUtils::DevPixelsToCocoaPoints(aRect, BackingScaleFactor()); 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 EndRemoteDrawing() override;
void CleanupRemoteDrawing() override; void CleanupRemoteDrawing() override;
bool InitCompositor(mozilla::layers::Compositor* aCompositor) override; bool InitCompositor(mozilla::layers::Compositor* aCompositor) override;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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