зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset f3b490c076d6 (bug 1602643) for causing bustages regarding CompositorKindChanged
CLOSED TREE
This commit is contained in:
Родитель
c4e4fdbd64
Коммит
d8a8849254
|
@ -2500,13 +2500,6 @@ void CompositorBridgeParent::NotifyWebRenderContextPurge() {
|
|||
api->ClearAllCaches();
|
||||
}
|
||||
|
||||
void CompositorBridgeParent::NotifyWebRenderDisableNativeCompositor() {
|
||||
MOZ_ASSERT(CompositorLoop() == MessageLoop::current());
|
||||
if (mWrBridge) {
|
||||
mWrBridge->DisableNativeCompositor();
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
|
||||
//#define PLUGINS_LOG(...) printf_stderr("CP [%s]: ", __FUNCTION__);
|
||||
// printf_stderr(__VA_ARGS__);
|
||||
|
|
|
@ -443,8 +443,6 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase,
|
|||
bool IsSameProcess() const override;
|
||||
|
||||
void NotifyWebRenderContextPurge();
|
||||
void NotifyWebRenderDisableNativeCompositor();
|
||||
|
||||
void NotifyPipelineRendered(const wr::PipelineId& aPipelineId,
|
||||
const wr::Epoch& aEpoch,
|
||||
const VsyncId& aCompositeStartId,
|
||||
|
|
|
@ -1734,15 +1734,6 @@ void WebRenderBridgeParent::FlushFramePresentation() {
|
|||
mApis[wr::RenderRoot::Default]->WaitFlushed();
|
||||
}
|
||||
|
||||
void WebRenderBridgeParent::DisableNativeCompositor() {
|
||||
// Make sure that SceneBuilder thread does not have a task.
|
||||
mApis[wr::RenderRoot::Default]->FlushSceneBuilder();
|
||||
// Disable WebRender's native compositor usage
|
||||
mApis[wr::RenderRoot::Default]->EnableNativeCompositor(false);
|
||||
// Ensure we generate and render a frame immediately.
|
||||
ScheduleForcedGenerateFrame();
|
||||
}
|
||||
|
||||
void WebRenderBridgeParent::UpdateQualitySettings() {
|
||||
for (auto& api : mApis) {
|
||||
if (!api) {
|
||||
|
|
|
@ -317,8 +317,6 @@ class WebRenderBridgeParent final
|
|||
*/
|
||||
RefPtr<wr::WebRenderAPI::GetCollectedFramesPromise> GetCollectedFrames();
|
||||
|
||||
void DisableNativeCompositor();
|
||||
|
||||
private:
|
||||
class ScheduleSharedSurfaceRelease;
|
||||
|
||||
|
|
|
@ -52,12 +52,9 @@ DCLayerTree::DCLayerTree(gl::GLContext* aGL, EGLConfig aEGLConfig,
|
|||
mDebugCounter(false),
|
||||
mDebugVisualRedrawRegions(false),
|
||||
mEGLImage(EGL_NO_IMAGE),
|
||||
mColorRBO(0),
|
||||
mPendingCommit(false) {}
|
||||
mColorRBO(0) {}
|
||||
|
||||
DCLayerTree::~DCLayerTree() { ReleaseNativeCompositorResources(); }
|
||||
|
||||
void DCLayerTree::ReleaseNativeCompositorResources() {
|
||||
DCLayerTree::~DCLayerTree() {
|
||||
const auto gl = GetGLContext();
|
||||
|
||||
DestroyEGLSurface();
|
||||
|
@ -123,7 +120,7 @@ void DCLayerTree::SetDefaultSwapChain(IDXGISwapChain1* aSwapChain) {
|
|||
// Default SwapChain's visual does not need linear interporation.
|
||||
mDefaultSwapChainVisual->SetBitmapInterpolationMode(
|
||||
DCOMPOSITION_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR);
|
||||
mPendingCommit = true;
|
||||
mCompositionDevice->Commit();
|
||||
}
|
||||
|
||||
void DCLayerTree::MaybeUpdateDebug() {
|
||||
|
@ -131,30 +128,14 @@ void DCLayerTree::MaybeUpdateDebug() {
|
|||
updated |= MaybeUpdateDebugCounter();
|
||||
updated |= MaybeUpdateDebugVisualRedrawRegions();
|
||||
if (updated) {
|
||||
mPendingCommit = true;
|
||||
mCompositionDevice->Commit();
|
||||
}
|
||||
}
|
||||
|
||||
void DCLayerTree::MaybeCommit() {
|
||||
if (!mPendingCommit) {
|
||||
return;
|
||||
}
|
||||
mCompositionDevice->Commit();
|
||||
}
|
||||
|
||||
void DCLayerTree::WaitForCommitCompletion() {
|
||||
mCompositionDevice->WaitForCommitCompletion();
|
||||
}
|
||||
|
||||
void DCLayerTree::DisableNativeCompositor() {
|
||||
MOZ_ASSERT(mCurrentSurface.isNothing());
|
||||
MOZ_ASSERT(mCurrentLayers.empty());
|
||||
|
||||
ReleaseNativeCompositorResources();
|
||||
mPrevLayers.clear();
|
||||
mRootVisual->RemoveAllVisuals();
|
||||
}
|
||||
|
||||
bool DCLayerTree::MaybeUpdateDebugCounter() {
|
||||
bool debugCounter = StaticPrefs::gfx_webrender_debug_dcomp_counter();
|
||||
if (mDebugCounter == debugCounter) {
|
||||
|
|
|
@ -60,9 +60,7 @@ class DCLayerTree {
|
|||
|
||||
void SetDefaultSwapChain(IDXGISwapChain1* aSwapChain);
|
||||
void MaybeUpdateDebug();
|
||||
void MaybeCommit();
|
||||
void WaitForCommitCompletion();
|
||||
void DisableNativeCompositor();
|
||||
|
||||
// Interface for wr::Compositor
|
||||
void CompositorBeginFrame();
|
||||
|
@ -98,7 +96,6 @@ class DCLayerTree {
|
|||
wr::DeviceIntRect aDirtyRect, wr::DeviceIntPoint* aOffset,
|
||||
RefPtr<IDCompositionSurface> aCompositionSurface,
|
||||
wr::DeviceIntPoint aSurfaceOffset);
|
||||
void ReleaseNativeCompositorResources();
|
||||
|
||||
RefPtr<gl::GLContext> mGL;
|
||||
EGLConfig mEGLConfig;
|
||||
|
@ -150,8 +147,6 @@ class DCLayerTree {
|
|||
// TODO(gw): Might be faster as a hashmap? The length is typically much less
|
||||
// than 10.
|
||||
std::vector<CachedFrameBuffer> mFrameBuffers;
|
||||
|
||||
bool mPendingCommit;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -70,11 +70,6 @@ void wr_compositor_end_frame(void* aCompositor) {
|
|||
compositor->CompositorEndFrame();
|
||||
}
|
||||
|
||||
void wr_compositor_enable_native_compositor(void* aCompositor, bool aEnable) {
|
||||
RenderCompositor* compositor = static_cast<RenderCompositor*>(aCompositor);
|
||||
compositor->EnableNativeCompositor(aEnable);
|
||||
}
|
||||
|
||||
void wr_compositor_unbind(void* aCompositor) {
|
||||
RenderCompositor* compositor = static_cast<RenderCompositor*>(aCompositor);
|
||||
compositor->Unbind();
|
||||
|
|
|
@ -79,8 +79,6 @@ class RenderCompositor {
|
|||
|
||||
virtual bool IsContextLost();
|
||||
|
||||
virtual bool SupportAsyncScreenshot() { return true; }
|
||||
|
||||
virtual bool ShouldUseNativeCompositor() { return false; }
|
||||
virtual uint32_t GetMaxUpdateRects() { return 0; }
|
||||
|
||||
|
@ -97,7 +95,6 @@ class RenderCompositor {
|
|||
virtual void DestroyTile(wr::NativeSurfaceId, int32_t aX, int32_t aY) {}
|
||||
virtual void AddSurface(wr::NativeSurfaceId aId, wr::DeviceIntPoint aPosition,
|
||||
wr::DeviceIntRect aClipRect) {}
|
||||
virtual void EnableNativeCompositor(bool aEnable) {}
|
||||
|
||||
// Interface for partial present
|
||||
virtual bool UsePartialPresent() { return false; }
|
||||
|
|
|
@ -63,10 +63,8 @@ RenderCompositorANGLE::RenderCompositorANGLE(
|
|||
mEGLSurface(nullptr),
|
||||
mUseTripleBuffering(false),
|
||||
mUseAlpha(false),
|
||||
mUseNativeCompositor(true),
|
||||
mUsePartialPresent(false),
|
||||
mFullRender(false),
|
||||
mDisablingNativeCompositor(false) {}
|
||||
mFullRender(false) {}
|
||||
|
||||
RenderCompositorANGLE::~RenderCompositorANGLE() {
|
||||
DestroyEGLSurface();
|
||||
|
@ -498,16 +496,8 @@ RenderedFrameId RenderCompositorANGLE::EndFrame(
|
|||
}
|
||||
}
|
||||
|
||||
if (mDisablingNativeCompositor) {
|
||||
// During disabling native compositor, we need to wait all gpu tasks
|
||||
// complete. Otherwise, rendering window could cause white flash.
|
||||
WaitForPreviousGraphicsCommandsFinishedQuery(/* aWaitAll */ true);
|
||||
mDisablingNativeCompositor = false;
|
||||
}
|
||||
|
||||
if (mDCLayerTree) {
|
||||
mDCLayerTree->MaybeUpdateDebug();
|
||||
mDCLayerTree->MaybeCommit();
|
||||
}
|
||||
|
||||
return frameId;
|
||||
|
@ -700,12 +690,8 @@ void RenderCompositorANGLE::InsertGraphicsCommandsFinishedWaitQuery(
|
|||
mWaitForPresentQueries.emplace(aFrameId, query);
|
||||
}
|
||||
|
||||
bool RenderCompositorANGLE::WaitForPreviousGraphicsCommandsFinishedQuery(
|
||||
bool aWaitAll) {
|
||||
bool RenderCompositorANGLE::WaitForPreviousGraphicsCommandsFinishedQuery() {
|
||||
size_t waitLatency = mUseTripleBuffering ? 3 : 2;
|
||||
if (aWaitAll) {
|
||||
waitLatency = 1;
|
||||
}
|
||||
|
||||
while (mWaitForPresentQueries.size() >= waitLatency) {
|
||||
auto queryPair = mWaitForPresentQueries.front();
|
||||
|
@ -757,20 +743,12 @@ bool RenderCompositorANGLE::IsContextLost() {
|
|||
}
|
||||
|
||||
bool RenderCompositorANGLE::UseCompositor() {
|
||||
if (!mUseNativeCompositor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mDCLayerTree || !gfx::gfxVars::UseWebRenderCompositor()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RenderCompositorANGLE::SupportAsyncScreenshot() {
|
||||
return !UseCompositor() && !mDisablingNativeCompositor;
|
||||
}
|
||||
|
||||
bool RenderCompositorANGLE::ShouldUseNativeCompositor() {
|
||||
return UseCompositor();
|
||||
}
|
||||
|
@ -825,42 +803,6 @@ void RenderCompositorANGLE::AddSurface(wr::NativeSurfaceId aId,
|
|||
mDCLayerTree->AddSurface(aId, aPosition, aClipRect);
|
||||
}
|
||||
|
||||
void RenderCompositorANGLE::EnableNativeCompositor(bool aEnable) {
|
||||
// XXX Re-enable native compositor is not handled yet.
|
||||
MOZ_RELEASE_ASSERT(!mDisablingNativeCompositor);
|
||||
MOZ_RELEASE_ASSERT(!aEnable);
|
||||
|
||||
if (!UseCompositor()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mUseNativeCompositor = false;
|
||||
mDCLayerTree->DisableNativeCompositor();
|
||||
|
||||
bool useAlpha = mWidget->AsWindows()->HasGlass();
|
||||
DestroyEGLSurface();
|
||||
mBufferSize.reset();
|
||||
|
||||
RefPtr<IDXGISwapChain1> swapChain1 =
|
||||
CreateSwapChainForDComp(mUseTripleBuffering, useAlpha);
|
||||
if (swapChain1) {
|
||||
mSwapChain = swapChain1;
|
||||
mUseAlpha = useAlpha;
|
||||
mDCLayerTree->SetDefaultSwapChain(swapChain1);
|
||||
// When alpha is used, we want to disable partial present.
|
||||
// See Bug 1595027.
|
||||
if (useAlpha) {
|
||||
mFullRender = true;
|
||||
}
|
||||
ResizeBufferIfNeeded();
|
||||
} else {
|
||||
gfxCriticalNote << "Failed to re-create SwapChain";
|
||||
RenderThread::Get()->HandleWebRenderError(WebRenderError::NEW_SURFACE);
|
||||
return;
|
||||
}
|
||||
mDisablingNativeCompositor = true;
|
||||
}
|
||||
|
||||
void RenderCompositorANGLE::InitializeUsePartialPresent() {
|
||||
if (UseCompositor() || !mSwapChain1 ||
|
||||
mWidget->AsWindows()->HasFxrOutputHandler() ||
|
||||
|
|
|
@ -64,8 +64,6 @@ class RenderCompositorANGLE : public RenderCompositor {
|
|||
|
||||
bool SurfaceOriginIsTopLeft() override { return true; }
|
||||
|
||||
bool SupportAsyncScreenshot() override;
|
||||
|
||||
bool ShouldUseNativeCompositor() override;
|
||||
uint32_t GetMaxUpdateRects() override;
|
||||
|
||||
|
@ -82,7 +80,6 @@ class RenderCompositorANGLE : public RenderCompositor {
|
|||
void DestroyTile(wr::NativeSurfaceId aId, int32_t aX, int32_t aY) override;
|
||||
void AddSurface(wr::NativeSurfaceId aId, wr::DeviceIntPoint aPosition,
|
||||
wr::DeviceIntRect aClipRect) override;
|
||||
void EnableNativeCompositor(bool aEnable) override;
|
||||
|
||||
// Interface for partial present
|
||||
bool UsePartialPresent() override;
|
||||
|
@ -98,7 +95,7 @@ class RenderCompositorANGLE : public RenderCompositor {
|
|||
void InitializeUsePartialPresent();
|
||||
void InsertGraphicsCommandsFinishedWaitQuery(
|
||||
RenderedFrameId aRenderedFrameId);
|
||||
bool WaitForPreviousGraphicsCommandsFinishedQuery(bool aWaitAll = false);
|
||||
bool WaitForPreviousGraphicsCommandsFinishedQuery();
|
||||
bool ResizeBufferIfNeeded();
|
||||
bool CreateEGLSurface();
|
||||
void DestroyEGLSurface();
|
||||
|
@ -109,7 +106,6 @@ class RenderCompositorANGLE : public RenderCompositor {
|
|||
bool aUseAlpha);
|
||||
bool SutdownEGLLibraryIfNecessary();
|
||||
RefPtr<ID3D11Query> GetD3D11Query();
|
||||
void ReleaseNativeCompositorResources();
|
||||
|
||||
EGLConfig mEGLConfig;
|
||||
EGLSurface mEGLSurface;
|
||||
|
@ -130,11 +126,8 @@ class RenderCompositorANGLE : public RenderCompositor {
|
|||
RenderedFrameId mLastCompletedFrameId;
|
||||
|
||||
Maybe<LayoutDeviceIntSize> mBufferSize;
|
||||
bool mUseNativeCompositor;
|
||||
bool mUsePartialPresent;
|
||||
bool mFullRender;
|
||||
// Used to know a timing of disabling native compositor.
|
||||
bool mDisablingNativeCompositor;
|
||||
};
|
||||
|
||||
} // namespace wr
|
||||
|
|
|
@ -493,8 +493,7 @@ void RenderThread::UpdateAndRender(
|
|||
|
||||
if (latestFrameId.IsValid()) {
|
||||
auto recorderIt = mCompositionRecorders.find(aWindowId);
|
||||
if (recorderIt != mCompositionRecorders.end() &&
|
||||
renderer->EnsureAsyncScreenshot()) {
|
||||
if (recorderIt != mCompositionRecorders.end()) {
|
||||
recorderIt->second->MaybeRecordFrame(renderer->GetRenderer(), info.get());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,8 +70,7 @@ RendererOGL::RendererOGL(RefPtr<RenderThread>&& aThread,
|
|||
mCompositor(std::move(aCompositor)),
|
||||
mRenderer(aRenderer),
|
||||
mBridge(aBridge),
|
||||
mWindowId(aWindowId),
|
||||
mDisableNativeCompositor(false) {
|
||||
mWindowId(aWindowId) {
|
||||
MOZ_ASSERT(mThread);
|
||||
MOZ_ASSERT(mCompositor);
|
||||
MOZ_ASSERT(mRenderer);
|
||||
|
@ -108,11 +107,6 @@ static void DoNotifyWebRenderContextPurge(
|
|||
aBridge->NotifyWebRenderContextPurge();
|
||||
}
|
||||
|
||||
static void DoWebRenderDisableNativeCompositor(
|
||||
layers::CompositorBridgeParent* aBridge) {
|
||||
aBridge->NotifyWebRenderDisableNativeCompositor();
|
||||
}
|
||||
|
||||
RenderedFrameId RendererOGL::UpdateAndRender(
|
||||
const Maybe<gfx::IntSize>& aReadbackSize,
|
||||
const Maybe<wr::ImageFormat>& aReadbackFormat,
|
||||
|
@ -174,7 +168,7 @@ RenderedFrameId RendererOGL::UpdateAndRender(
|
|||
}
|
||||
}
|
||||
|
||||
mScreenshotGrabber.MaybeGrabScreenshot(this, size.ToUnknownSize());
|
||||
mScreenshotGrabber.MaybeGrabScreenshot(mRenderer, size.ToUnknownSize());
|
||||
|
||||
RenderedFrameId frameId = mCompositor->EndFrame(result.DirtyRects());
|
||||
|
||||
|
@ -190,7 +184,7 @@ RenderedFrameId RendererOGL::UpdateAndRender(
|
|||
mFrameStartTime = TimeStamp();
|
||||
#endif
|
||||
|
||||
mScreenshotGrabber.MaybeProcessQueue(this);
|
||||
mScreenshotGrabber.MaybeProcessQueue(mRenderer);
|
||||
|
||||
// TODO: Flush pending actions such as texture deletions/unlocks and
|
||||
// textureHosts recycling.
|
||||
|
@ -198,21 +192,6 @@ RenderedFrameId RendererOGL::UpdateAndRender(
|
|||
return frameId;
|
||||
}
|
||||
|
||||
bool RendererOGL::EnsureAsyncScreenshot() {
|
||||
if (mCompositor->SupportAsyncScreenshot()) {
|
||||
return true;
|
||||
}
|
||||
if (!mDisableNativeCompositor) {
|
||||
layers::CompositorThreadHolder::Loop()->PostTask(
|
||||
NewRunnableFunction("DoWebRenderDisableNativeCompositorRunnable",
|
||||
&DoWebRenderDisableNativeCompositor, mBridge));
|
||||
|
||||
mDisableNativeCompositor = true;
|
||||
gfxCriticalNote << "Disable native compositor for async screenshot";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void RendererOGL::CheckGraphicsResetStatus() {
|
||||
if (!mCompositor || !mCompositor->gl()) {
|
||||
return;
|
||||
|
|
|
@ -109,8 +109,6 @@ class RendererOGL {
|
|||
|
||||
gl::GLContext* gl() const;
|
||||
|
||||
bool EnsureAsyncScreenshot();
|
||||
|
||||
protected:
|
||||
RefPtr<RenderThread> mThread;
|
||||
UniquePtr<RenderCompositor> mCompositor;
|
||||
|
@ -119,8 +117,6 @@ class RendererOGL {
|
|||
wr::WindowId mWindowId;
|
||||
TimeStamp mFrameStartTime;
|
||||
|
||||
bool mDisableNativeCompositor;
|
||||
|
||||
RendererScreenshotGrabber mScreenshotGrabber;
|
||||
};
|
||||
|
||||
|
|
|
@ -16,33 +16,27 @@ RendererScreenshotGrabber::RendererScreenshotGrabber() {
|
|||
}
|
||||
|
||||
void RendererScreenshotGrabber::MaybeGrabScreenshot(
|
||||
RendererOGL* aRendererOGL, const gfx::IntSize& aWindowSize) {
|
||||
bool isEnabled =
|
||||
ProfilerScreenshots::IsEnabled() && aRendererOGL->EnsureAsyncScreenshot();
|
||||
|
||||
if (isEnabled) {
|
||||
Renderer* aRenderer, const gfx::IntSize& aWindowSize) {
|
||||
if (ProfilerScreenshots::IsEnabled()) {
|
||||
if (!mProfilerScreenshots) {
|
||||
mProfilerScreenshots = new ProfilerScreenshots();
|
||||
}
|
||||
|
||||
GrabScreenshot(aRendererOGL->GetRenderer(), aWindowSize);
|
||||
GrabScreenshot(aRenderer, aWindowSize);
|
||||
} else if (mProfilerScreenshots) {
|
||||
Destroy(aRendererOGL->GetRenderer());
|
||||
Destroy(aRenderer);
|
||||
}
|
||||
}
|
||||
|
||||
void RendererScreenshotGrabber::MaybeProcessQueue(RendererOGL* aRendererOGL) {
|
||||
bool isEnabled =
|
||||
ProfilerScreenshots::IsEnabled() && aRendererOGL->EnsureAsyncScreenshot();
|
||||
|
||||
if (isEnabled) {
|
||||
void RendererScreenshotGrabber::MaybeProcessQueue(Renderer* aRenderer) {
|
||||
if (ProfilerScreenshots::IsEnabled()) {
|
||||
if (!mProfilerScreenshots) {
|
||||
mProfilerScreenshots = new ProfilerScreenshots();
|
||||
}
|
||||
|
||||
ProcessQueue(aRendererOGL->GetRenderer());
|
||||
ProcessQueue(aRenderer);
|
||||
} else if (mProfilerScreenshots) {
|
||||
Destroy(aRendererOGL->GetRenderer());
|
||||
Destroy(aRenderer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,14 +32,14 @@ class RendererScreenshotGrabber final {
|
|||
* The captured screenshot will not be mapped until the second call to
|
||||
* |MaybeProcessQueue| after this call to |MaybeGrabScreenshot|.
|
||||
*/
|
||||
void MaybeGrabScreenshot(RendererOGL* aRendererOGL,
|
||||
void MaybeGrabScreenshot(Renderer* aRenderer,
|
||||
const gfx::IntSize& aWindowSize);
|
||||
|
||||
/**
|
||||
* Process the screenshots pending in the queue if we are profiling and
|
||||
* screenshots are enabled.
|
||||
*/
|
||||
void MaybeProcessQueue(RendererOGL* aRenderer);
|
||||
void MaybeProcessQueue(Renderer* aRenderer);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
|
|
@ -521,10 +521,6 @@ void WebRenderAPI::Readback(const TimeStamp& aStartTime, gfx::IntSize size,
|
|||
|
||||
void WebRenderAPI::ClearAllCaches() { wr_api_clear_all_caches(mDocHandle); }
|
||||
|
||||
void WebRenderAPI::EnableNativeCompositor(bool aEnable) {
|
||||
wr_api_enable_native_compositor(mDocHandle, aEnable);
|
||||
}
|
||||
|
||||
void WebRenderAPI::Pause() {
|
||||
class PauseEvent : public RendererEvent {
|
||||
public:
|
||||
|
|
|
@ -247,7 +247,6 @@ class WebRenderAPI final {
|
|||
const Range<uint8_t>& aBuffer);
|
||||
|
||||
void ClearAllCaches();
|
||||
void EnableNativeCompositor(bool aEnable);
|
||||
|
||||
void Pause();
|
||||
bool Resume();
|
||||
|
|
|
@ -1220,10 +1220,6 @@ extern "C" {
|
|||
clip_rect: DeviceIntRect,
|
||||
);
|
||||
fn wr_compositor_end_frame(compositor: *mut c_void);
|
||||
fn wr_compositor_enable_native_compositor(
|
||||
compositor: *mut c_void,
|
||||
enable: bool,
|
||||
);
|
||||
}
|
||||
|
||||
pub struct WrCompositor(*mut c_void);
|
||||
|
@ -1349,15 +1345,6 @@ impl Compositor for WrCompositor {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn enable_native_compositor(&mut self, enable: bool) {
|
||||
unsafe {
|
||||
wr_compositor_enable_native_compositor(
|
||||
self.0,
|
||||
enable,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1598,11 +1585,6 @@ pub unsafe extern "C" fn wr_api_clear_all_caches(dh: &mut DocumentHandle) {
|
|||
dh.api.send_debug_cmd(DebugCommand::ClearCaches(ClearCache::all()));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wr_api_enable_native_compositor(dh: &mut DocumentHandle, enable: bool) {
|
||||
dh.api.send_debug_cmd(DebugCommand::EnableNativeCompositor(enable));
|
||||
}
|
||||
|
||||
fn make_transaction(do_async: bool) -> Transaction {
|
||||
let mut transaction = Transaction::new();
|
||||
// Ensure that we either use async scene building or not based on the
|
||||
|
|
|
@ -94,19 +94,6 @@ pub enum CompositorConfig {
|
|||
}
|
||||
}
|
||||
|
||||
impl CompositorConfig {
|
||||
pub fn compositor(&mut self) -> Option<&mut Box<dyn Compositor>> {
|
||||
match self {
|
||||
CompositorConfig::Native { ref mut compositor, .. } => {
|
||||
Some(compositor)
|
||||
}
|
||||
CompositorConfig::Draw { .. } => {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for CompositorConfig {
|
||||
/// Default compositor config is full present without partial present.
|
||||
fn default() -> Self {
|
||||
|
@ -519,9 +506,6 @@ pub trait Compositor {
|
|||
/// this once when all surface and visual updates are complete, to signal
|
||||
/// that the OS composite transaction should be applied.
|
||||
fn end_frame(&mut self);
|
||||
|
||||
/// Enable/disable native compositor usage
|
||||
fn enable_native_compositor(&mut self, enable: bool);
|
||||
}
|
||||
|
||||
/// Return the total area covered by a set of occluders, accounting for
|
||||
|
|
|
@ -608,8 +608,6 @@ pub enum InvalidationReason {
|
|||
/// What changed in the primitive that was different
|
||||
prim_compare_result: PrimitiveCompareResult,
|
||||
},
|
||||
// The compositor type changed
|
||||
CompositorKindChanged,
|
||||
}
|
||||
|
||||
/// A minimal subset of Tile for debug capturing
|
||||
|
@ -2102,36 +2100,6 @@ impl TileCacheInstance {
|
|||
frame_state.resource_cache,
|
||||
);
|
||||
|
||||
// If compositor mode is changed, need to drop all incompatible tiles.
|
||||
match (frame_context.config.compositor_kind, self.native_surface_id) {
|
||||
(CompositorKind::Draw { .. }, Some(_)) => {
|
||||
frame_state.composite_state.destroy_native_tiles(
|
||||
self.tiles.values_mut(),
|
||||
frame_state.resource_cache,
|
||||
);
|
||||
for tile in self.tiles.values_mut() {
|
||||
tile.surface = None;
|
||||
// Invalidate the entire tile to force a redraw.
|
||||
tile.invalidate(None, InvalidationReason::CompositorKindChanged);
|
||||
}
|
||||
if let Some(native_surface_id) = self.native_surface_id.take() {
|
||||
frame_state.resource_cache.destroy_compositor_surface(native_surface_id);
|
||||
}
|
||||
}
|
||||
(CompositorKind::Native { .. }, None) => {
|
||||
// This could hit even when compositor mode is not changed,
|
||||
// then we need to check if there are incompatible tiles.
|
||||
for tile in self.tiles.values_mut() {
|
||||
if let Some(TileSurface::Texture { descriptor: SurfaceTextureDescriptor::TextureCache { .. }, .. }) = tile.surface {
|
||||
tile.surface = None;
|
||||
// Invalidate the entire tile to force a redraw.
|
||||
tile.invalidate(None, InvalidationReason::CompositorKindChanged);
|
||||
}
|
||||
}
|
||||
}
|
||||
(_, _) => {}
|
||||
}
|
||||
|
||||
world_culling_rect
|
||||
}
|
||||
|
||||
|
|
|
@ -711,7 +711,6 @@ pub struct RenderBackend {
|
|||
resource_cache: ResourceCache,
|
||||
|
||||
frame_config: FrameBuilderConfig,
|
||||
default_compositor_kind: CompositorKind,
|
||||
documents: FastHashMap<DocumentId, Document>,
|
||||
|
||||
notifier: Box<dyn RenderNotifier>,
|
||||
|
@ -756,7 +755,6 @@ impl RenderBackend {
|
|||
resource_cache,
|
||||
gpu_cache: GpuCache::new(),
|
||||
frame_config,
|
||||
default_compositor_kind : frame_config.compositor_kind,
|
||||
documents: FastHashMap::default(),
|
||||
notifier,
|
||||
recorder,
|
||||
|
@ -1227,33 +1225,6 @@ impl RenderBackend {
|
|||
self.resource_cache.clear(mask);
|
||||
return RenderBackendStatus::Continue;
|
||||
}
|
||||
DebugCommand::EnableNativeCompositor(enable) => {
|
||||
// Default CompositorKind should be Native
|
||||
if let CompositorKind::Draw { .. } = self.default_compositor_kind {
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
let compositor_kind = if enable {
|
||||
self.default_compositor_kind
|
||||
} else {
|
||||
CompositorKind::default()
|
||||
};
|
||||
|
||||
for (_, doc) in &mut self.documents {
|
||||
doc.scene.config.compositor_kind = compositor_kind;
|
||||
doc.frame_is_valid = false;
|
||||
}
|
||||
|
||||
self.frame_config.compositor_kind = compositor_kind;
|
||||
|
||||
// Update config in SceneBuilder
|
||||
self.low_priority_scene_tx.send(SceneBuilderRequest::SetFrameBuilderConfig(
|
||||
self.frame_config.clone()
|
||||
)).unwrap();
|
||||
|
||||
// We don't want to forward this message to the renderer.
|
||||
return RenderBackendStatus::Continue;
|
||||
}
|
||||
DebugCommand::SimulateLongSceneBuild(time_ms) => {
|
||||
self.scene_tx.send(SceneBuilderRequest::SimulateLongSceneBuild(time_ms)).unwrap();
|
||||
return RenderBackendStatus::Continue;
|
||||
|
@ -1543,7 +1514,7 @@ impl RenderBackend {
|
|||
// external image with NativeTexture or when platform requested to composite frame.
|
||||
if invalidate_rendered_frame {
|
||||
doc.rendered_frame_is_valid = false;
|
||||
if let CompositorKind::Draw { max_partial_present_rects } = doc.scene.config.compositor_kind {
|
||||
if let CompositorKind::Draw { max_partial_present_rects } = self.frame_config.compositor_kind {
|
||||
// When partial present is enabled, we need to force redraw.
|
||||
if max_partial_present_rects > 0 {
|
||||
let msg = ResultMsg::ForceRedraw;
|
||||
|
|
|
@ -1896,8 +1896,6 @@ pub struct Renderer {
|
|||
/// The compositing config, affecting how WR composites into the final scene.
|
||||
compositor_config: CompositorConfig,
|
||||
|
||||
current_compositor_kind: CompositorKind,
|
||||
|
||||
/// Maintains a set of allocated native composite surfaces. This allows any
|
||||
/// currently allocated surfaces to be cleaned up as soon as deinit() is
|
||||
/// called (the normal bookkeeping for native surfaces exists in the
|
||||
|
@ -2425,7 +2423,6 @@ impl Renderer {
|
|||
documents_seen: FastHashSet::default(),
|
||||
force_redraw: true,
|
||||
compositor_config: options.compositor_config,
|
||||
current_compositor_kind: compositor_kind,
|
||||
allocated_native_surfaces: FastHashSet::default(),
|
||||
debug_overlay_state: DebugOverlayState::new(),
|
||||
};
|
||||
|
@ -2873,8 +2870,7 @@ impl Renderer {
|
|||
}
|
||||
DebugCommand::ClearCaches(_)
|
||||
| DebugCommand::SimulateLongSceneBuild(_)
|
||||
| DebugCommand::SimulateLongLowPrioritySceneBuild(_)
|
||||
| DebugCommand::EnableNativeCompositor(_) => {}
|
||||
| DebugCommand::SimulateLongLowPrioritySceneBuild(_) => {}
|
||||
DebugCommand::InvalidateGpuCache => {
|
||||
match self.gpu_cache_texture.bus {
|
||||
GpuCacheBus::PixelBuffer { ref mut rows, .. } => {
|
||||
|
@ -2965,9 +2961,7 @@ impl Renderer {
|
|||
);
|
||||
|
||||
// Update the debug overlay surface, if we are running in native compositor mode.
|
||||
if let CompositorKind::Native { .. } = self.current_compositor_kind {
|
||||
let compositor = self.compositor_config.compositor().unwrap();
|
||||
|
||||
if let CompositorConfig::Native { ref mut compositor, .. } = self.compositor_config {
|
||||
// If there is a current surface, destroy it if we don't need it for this frame, or if
|
||||
// the size has changed.
|
||||
if let Some(current_size) = self.debug_overlay_state.current_size {
|
||||
|
@ -2996,8 +2990,7 @@ impl Renderer {
|
|||
fn bind_debug_overlay(&mut self) {
|
||||
// Debug overlay setup are only required in native compositing mode
|
||||
if self.debug_overlay_state.is_enabled {
|
||||
if let CompositorKind::Native { .. } = self.current_compositor_kind {
|
||||
let compositor = self.compositor_config.compositor().unwrap();
|
||||
if let CompositorConfig::Native { ref mut compositor, .. } = self.compositor_config {
|
||||
let surface_size = self.debug_overlay_state.current_size.unwrap();
|
||||
|
||||
// Bind the native surface
|
||||
|
@ -3031,8 +3024,7 @@ impl Renderer {
|
|||
fn unbind_debug_overlay(&mut self) {
|
||||
// Debug overlay setup are only required in native compositing mode
|
||||
if self.debug_overlay_state.is_enabled {
|
||||
if let CompositorKind::Native { .. } = self.current_compositor_kind {
|
||||
let compositor = self.compositor_config.compositor().unwrap();
|
||||
if let CompositorConfig::Native { ref mut compositor, .. } = self.compositor_config {
|
||||
// Unbind the draw target and add it to the visual tree to be composited
|
||||
compositor.unbind();
|
||||
|
||||
|
@ -3063,35 +3055,6 @@ impl Renderer {
|
|||
return Ok(results);
|
||||
}
|
||||
|
||||
let compositor_kind = self.active_documents[0].1.frame.composite_state.compositor_kind;
|
||||
// CompositorKind is updated
|
||||
if self.current_compositor_kind != compositor_kind {
|
||||
let enable = match (self.current_compositor_kind, compositor_kind) {
|
||||
(CompositorKind::Native { .. }, CompositorKind::Draw { .. }) => {
|
||||
if self.debug_overlay_state.current_size.is_some() {
|
||||
self.compositor_config
|
||||
.compositor()
|
||||
.unwrap()
|
||||
.destroy_surface(NativeSurfaceId::DEBUG_OVERLAY);
|
||||
self.debug_overlay_state.current_size = None;
|
||||
}
|
||||
false
|
||||
}
|
||||
(CompositorKind::Draw { .. }, CompositorKind::Native { .. }) => {
|
||||
true
|
||||
}
|
||||
(_, _) => {
|
||||
unreachable!();
|
||||
}
|
||||
};
|
||||
|
||||
self.compositor_config
|
||||
.compositor()
|
||||
.unwrap()
|
||||
.enable_native_compositor(enable);
|
||||
self.current_compositor_kind = compositor_kind;
|
||||
}
|
||||
|
||||
let mut frame_profiles = Vec::new();
|
||||
let mut profile_timers = RendererProfileTimers::new();
|
||||
|
||||
|
@ -3140,8 +3103,7 @@ impl Renderer {
|
|||
// Inform the client that we are starting a composition transaction if native
|
||||
// compositing is enabled. This needs to be done early in the frame, so that
|
||||
// we can create debug overlays after drawing the main surfaces.
|
||||
if let CompositorKind::Native { .. } = self.current_compositor_kind {
|
||||
let compositor = self.compositor_config.compositor().unwrap();
|
||||
if let CompositorConfig::Native { ref mut compositor, .. } = self.compositor_config {
|
||||
compositor.begin_frame();
|
||||
}
|
||||
|
||||
|
@ -3158,8 +3120,6 @@ impl Renderer {
|
|||
|
||||
let last_document_index = active_documents.len() - 1;
|
||||
for (doc_index, (document_id, RenderedDocument { ref mut frame, .. })) in active_documents.iter_mut().enumerate() {
|
||||
assert!(self.current_compositor_kind == frame.composite_state.compositor_kind);
|
||||
|
||||
if self.shared_texture_cache_cleared {
|
||||
assert!(self.documents_seen.contains(&document_id),
|
||||
"Cleared texture cache without sending new document frame.");
|
||||
|
@ -3320,9 +3280,9 @@ impl Renderer {
|
|||
let scale = if small_screen { 1.6 } else { 1.0 };
|
||||
// TODO(gw): Tidy this up so that compositor config integrates better
|
||||
// with the (non-compositor) surface y-flip options.
|
||||
let surface_origin_is_top_left = match self.current_compositor_kind {
|
||||
CompositorKind::Native { .. } => true,
|
||||
CompositorKind::Draw { .. } => self.device.surface_origin_is_top_left(),
|
||||
let surface_origin_is_top_left = match self.compositor_config {
|
||||
CompositorConfig::Native { .. } => true,
|
||||
CompositorConfig::Draw { .. } => self.device.surface_origin_is_top_left(),
|
||||
};
|
||||
debug_renderer.render(
|
||||
&mut self.device,
|
||||
|
@ -3351,8 +3311,7 @@ impl Renderer {
|
|||
// Inform the client that we are finished this composition transaction if native
|
||||
// compositing is enabled. This must be called after any debug / profiling compositor
|
||||
// surfaces have been drawn and added to the visual tree.
|
||||
if let CompositorKind::Native { .. } = self.current_compositor_kind {
|
||||
let compositor = self.compositor_config.compositor().unwrap();
|
||||
if let CompositorConfig::Native { ref mut compositor, .. } = self.compositor_config {
|
||||
compositor.end_frame();
|
||||
}
|
||||
|
||||
|
@ -5255,12 +5214,11 @@ impl Renderer {
|
|||
if frame.composite_state.picture_caching_is_enabled {
|
||||
// If we have a native OS compositor, then make use of that interface
|
||||
// to specify how to composite each of the picture cache surfaces.
|
||||
match self.current_compositor_kind {
|
||||
CompositorKind::Native { .. } => {
|
||||
let compositor = self.compositor_config.compositor().unwrap();
|
||||
match self.compositor_config {
|
||||
CompositorConfig::Native { ref mut compositor, .. } => {
|
||||
frame.composite_state.composite_native(&mut **compositor);
|
||||
}
|
||||
CompositorKind::Draw { max_partial_present_rects, .. } => {
|
||||
CompositorConfig::Draw { max_partial_present_rects, .. } => {
|
||||
self.composite_simple(
|
||||
&frame.composite_state,
|
||||
clear_framebuffer,
|
||||
|
@ -5339,12 +5297,11 @@ impl Renderer {
|
|||
)
|
||||
}
|
||||
ResolvedSurfaceTexture::Native { id, size } => {
|
||||
let surface_info = match self.current_compositor_kind {
|
||||
CompositorKind::Native { .. } => {
|
||||
let compositor = self.compositor_config.compositor().unwrap();
|
||||
let surface_info = match self.compositor_config {
|
||||
CompositorConfig::Native { ref mut compositor, .. } => {
|
||||
compositor.bind(id, picture_target.dirty_rect)
|
||||
}
|
||||
CompositorKind::Draw { .. } => {
|
||||
CompositorConfig::Draw { .. } => {
|
||||
unreachable!();
|
||||
}
|
||||
};
|
||||
|
@ -5377,12 +5334,11 @@ impl Renderer {
|
|||
|
||||
// Native OS surfaces must be unbound at the end of drawing to them
|
||||
if let ResolvedSurfaceTexture::Native { .. } = picture_target.surface {
|
||||
match self.current_compositor_kind {
|
||||
CompositorKind::Native { .. } => {
|
||||
let compositor = self.compositor_config.compositor().unwrap();
|
||||
match self.compositor_config {
|
||||
CompositorConfig::Native { ref mut compositor, .. } => {
|
||||
compositor.unbind();
|
||||
}
|
||||
CompositorKind::Draw { .. } => {
|
||||
CompositorConfig::Draw { .. } => {
|
||||
unreachable!();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -967,8 +967,6 @@ pub enum DebugCommand {
|
|||
LoadCapture(PathBuf, MsgSender<CapturedDocument>),
|
||||
/// Clear cached resources, forcing them to be re-uploaded from templates.
|
||||
ClearCaches(ClearCache),
|
||||
/// Enable/disable native compositor usage
|
||||
EnableNativeCompositor(bool),
|
||||
/// Invalidate GPU cache, forcing the update from the CPU mirror.
|
||||
InvalidateGpuCache,
|
||||
/// Causes the scene builder to pause for a given amount of milliseconds each time it
|
||||
|
|
Загрузка…
Ссылка в новой задаче