void Compositor::DrawDiagnostics(DiagnosticFlags aFlags, const nsIntRegion& aVisibleRegion, const gfx::Rect& aClipRect, const gfx::Matrix4x4& aTransform, uint32_t aFlashCounter) { if (!ShouldDrawDiagnostics(aFlags)) { return; } if (aVisibleRegion.GetNumRects() > 1) { nsIntRegionRectIterator screenIter(aVisibleRegion); while (const gfx::IntRect* rect = screenIter.Next()) { DrawDiagnostics(aFlags | DiagnosticFlags::REGION_RECT, IntRectToRect(*rect), aClipRect, aTransform, aFlashCounter); } } DrawDiagnostics(aFlags, IntRectToRect(aVisibleRegion.GetBounds()), aClipRect, aTransform, aFlashCounter); }
void Compositor::DrawDiagnostics(DiagnosticFlags aFlags, const nsIntRegion& aVisibleRegion, const gfx::IntRect& aClipRect, const gfx::Matrix4x4& aTransform, uint32_t aFlashCounter) { if (!ShouldDrawDiagnostics(aFlags)) { return; } if (aVisibleRegion.GetNumRects() > 1) { for (auto iter = aVisibleRegion.RectIter(); !iter.Done(); iter.Next()) { DrawDiagnostics(aFlags | DiagnosticFlags::REGION_RECT, IntRectToRect(iter.Get()), aClipRect, aTransform, aFlashCounter); } } DrawDiagnostics(aFlags, IntRectToRect(aVisibleRegion.GetBounds()), aClipRect, aTransform, aFlashCounter); }
void BasicCompositor::EndFrame() { // Pop aClipRectIn/bounds rect mRenderTarget->mDrawTarget->PopClip(); if (gfxPrefs::WidgetUpdateFlashing()) { float r = float(rand()) / RAND_MAX; 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()).ToUnknownRect(), ColorPattern(Color(r, g, b, 0.2f))); } // Pop aInvalidregion mRenderTarget->mDrawTarget->PopClip(); if (mTarget || mRenderTarget->mDrawTarget != mDrawTarget) { // Note: Most platforms require us to buffer drawing to the widget surface. // That's why we don't draw to mDrawTarget directly. RefPtr<SourceSurface> source = mRenderTarget->mDrawTarget->Snapshot(); RefPtr<DrawTarget> dest(mTarget ? mTarget : mDrawTarget); nsIntPoint offset = mTarget ? mTargetBounds.TopLeft() : nsIntPoint(); // 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. for (auto iter = mInvalidRegion.RectIter(); !iter.Done(); iter.Next()) { const LayoutDeviceIntRect& r = iter.Get(); dest->CopySurface(source, IntRect(r.x, r.y, r.width, r.height) - mRenderTarget->GetOrigin(), IntPoint(r.x, r.y) - offset); } } if (!mTarget) { mWidget->EndRemoteDrawingInRegion(mDrawTarget, mInvalidRegion); } mDrawTarget = nullptr; mRenderTarget = nullptr; }
static void SubtractTransformedRegion(nsIntRegion& aRegion, const nsIntRegion& aRegionToSubtract, const Matrix4x4& aTransform) { if (aRegionToSubtract.IsEmpty()) { return; } // For each rect in the region, find out its bounds in screen space and // subtract it from the screen region. nsIntRegionRectIterator it(aRegionToSubtract); while (const IntRect* rect = it.Next()) { Rect incompleteRect = aTransform.TransformAndClipBounds(IntRectToRect(*rect), Rect::MaxIntRect()); aRegion.Sub(aRegion, IntRect(incompleteRect.x, incompleteRect.y, incompleteRect.width, incompleteRect.height)); } }