diff --git a/gfx/webrender_bindings/RenderCompositorSWGL.cpp b/gfx/webrender_bindings/RenderCompositorSWGL.cpp index 1c24407b3493..ec5be61f4d10 100644 --- a/gfx/webrender_bindings/RenderCompositorSWGL.cpp +++ b/gfx/webrender_bindings/RenderCompositorSWGL.cpp @@ -10,6 +10,8 @@ #include "mozilla/widget/CompositorWidget.h" namespace mozilla { +using namespace gfx; + namespace wr { /* static */ @@ -53,7 +55,8 @@ bool RenderCompositorSWGL::BeginFrame() { return true; } -bool RenderCompositorSWGL::AllocateMappedBuffer() { +bool RenderCompositorSWGL::AllocateMappedBuffer( + const wr::DeviceIntRect* aOpaqueRects, size_t aNumOpaqueRects) { // Request a new draw target to use from the widget... MOZ_ASSERT(!mDT); layers::BufferMode bufferMode = layers::BufferMode::BUFFERED; @@ -113,6 +116,25 @@ bool RenderCompositorSWGL::AllocateMappedBuffer() { MOZ_ASSERT(mMappedData != nullptr && mMappedStride > 0); wr_swgl_init_default_framebuffer(mContext, bounds.x, bounds.y, bounds.width, bounds.height, mMappedStride, mMappedData); + + LayoutDeviceIntRegion opaque; + for (size_t i = 0; i < aNumOpaqueRects; i++) { + const auto& rect = aOpaqueRects[i]; + opaque.OrWith(LayoutDeviceIntRect(rect.origin.x, rect.origin.y, + rect.size.width, rect.size.height)); + } + + RefPtr dt = gfx::Factory::CreateDrawTargetForData( + BackendType::SKIA, mMappedData, bounds.Size().ToUnknownSize(), + mMappedStride, SurfaceFormat::B8G8R8A8, false); + + LayoutDeviceIntRegion clear; + clear.Sub(mRegion, opaque); + for (auto iter = clear.RectIter(); !iter.Done(); iter.Next()) { + dt->ClearRect( + IntRectToRect((iter.Get() - bounds.TopLeft()).ToUnknownRect())); + } + return true; } @@ -140,7 +162,7 @@ void RenderCompositorSWGL::StartCompositing( // Now that the dirty rects have been supplied and the composition region // is known, allocate and install a framebuffer encompassing the composition // region. - if (!AllocateMappedBuffer()) { + if (!AllocateMappedBuffer(aOpaqueRects, aNumOpaqueRects)) { gfxCriticalNote << "RenderCompositorSWGL failed mapping default framebuffer"; // If allocation of the mapped default framebuffer failed, then just install diff --git a/gfx/webrender_bindings/RenderCompositorSWGL.h b/gfx/webrender_bindings/RenderCompositorSWGL.h index fa78d3021491..b0f53520e05d 100644 --- a/gfx/webrender_bindings/RenderCompositorSWGL.h +++ b/gfx/webrender_bindings/RenderCompositorSWGL.h @@ -67,7 +67,8 @@ class RenderCompositorSWGL : public RenderCompositor { void ClearMappedBuffer(); - bool AllocateMappedBuffer(); + bool AllocateMappedBuffer(const wr::DeviceIntRect* aOpaqueRects, + size_t aNumOpaqueRects); void CommitMappedBuffer(bool aDirty = true); };