зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1254897 - Recycle back buffer in BasicCompositor r=jrmuizel
This commit is contained in:
Родитель
916e86a26e
Коммит
ccef41ec11
|
@ -172,7 +172,7 @@ BasicCompositor::CreateRenderTargetForWindow(const LayoutDeviceIntRect& aRect, S
|
|||
IntRect rect = aRect.ToUnknownRect();
|
||||
|
||||
if (aBufferMode != BufferMode::BUFFER_NONE) {
|
||||
RefPtr<DrawTarget> target = mWidget->CreateBackBufferDrawTarget(mDrawTarget, aRect);
|
||||
RefPtr<DrawTarget> target = mWidget->CreateBackBufferDrawTarget(mDrawTarget, aRect, aInit == INIT_MODE_CLEAR);
|
||||
if (!target) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -2643,6 +2643,7 @@ nsChildView::StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion,
|
|||
}
|
||||
|
||||
aInvalidRegion = mBasicCompositorImage->GetUpdateRegion();
|
||||
*aBufferMode = BufferMode::BUFFER_NONE;
|
||||
|
||||
return drawTarget.forget();
|
||||
}
|
||||
|
@ -2657,6 +2658,7 @@ nsChildView::EndRemoteDrawing()
|
|||
void
|
||||
nsChildView::CleanupRemoteDrawing()
|
||||
{
|
||||
nsBaseWidget::CleanupRemoteDrawing();
|
||||
mBasicCompositorImage = nullptr;
|
||||
mCornerMaskImage = nullptr;
|
||||
mResizerImage = nullptr;
|
||||
|
|
|
@ -1355,18 +1355,45 @@ CompositorBridgeChild* nsBaseWidget::GetRemoteRenderer()
|
|||
return mCompositorBridgeChild;
|
||||
}
|
||||
|
||||
already_AddRefed<mozilla::gfx::DrawTarget> nsBaseWidget::StartRemoteDrawing()
|
||||
already_AddRefed<mozilla::gfx::DrawTarget>
|
||||
nsBaseWidget::StartRemoteDrawing()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
nsBaseWidget::CleanupRemoteDrawing()
|
||||
{
|
||||
mLastBackBuffer = nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<mozilla::gfx::DrawTarget>
|
||||
nsBaseWidget::CreateBackBufferDrawTarget(mozilla::gfx::DrawTarget* aScreenTarget,
|
||||
const LayoutDeviceIntRect& aRect)
|
||||
const LayoutDeviceIntRect& aRect,
|
||||
const bool aInitModeClear)
|
||||
{
|
||||
MOZ_ASSERT(aScreenTarget);
|
||||
gfx::SurfaceFormat format = gfx::SurfaceFormat::B8G8R8A8;
|
||||
return aScreenTarget->CreateSimilarDrawTarget(aRect.ToUnknownRect().Size(), format);
|
||||
gfx::IntSize size = aRect.ToUnknownRect().Size();
|
||||
gfx::IntSize clientSize(GetClientSize().ToUnknownSize());
|
||||
|
||||
RefPtr<gfx::DrawTarget> target;
|
||||
// Re-use back buffer if possible
|
||||
if (mLastBackBuffer &&
|
||||
mLastBackBuffer->GetBackendType() == aScreenTarget->GetBackendType() &&
|
||||
mLastBackBuffer->GetFormat() == format &&
|
||||
size <= mLastBackBuffer->GetSize() &&
|
||||
mLastBackBuffer->GetSize() <= clientSize) {
|
||||
target = mLastBackBuffer;
|
||||
target->SetTransform(gfx::Matrix());
|
||||
if (aInitModeClear) {
|
||||
target->ClearRect(gfx::Rect(0, 0, size.width, size.height));
|
||||
}
|
||||
} else {
|
||||
target = aScreenTarget->CreateSimilarDrawTarget(size, format);
|
||||
mLastBackBuffer = target;
|
||||
}
|
||||
return target.forget();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
|
|
@ -32,6 +32,10 @@ class Accessible;
|
|||
}
|
||||
#endif
|
||||
|
||||
namespace gfx {
|
||||
class DrawTarget;
|
||||
} // namespace gfx
|
||||
|
||||
namespace layers {
|
||||
class BasicLayerManager;
|
||||
class CompositorBridgeChild;
|
||||
|
@ -90,6 +94,7 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference
|
|||
|
||||
protected:
|
||||
typedef base::Thread Thread;
|
||||
typedef mozilla::gfx::DrawTarget DrawTarget;
|
||||
typedef mozilla::layers::BasicLayerManager BasicLayerManager;
|
||||
typedef mozilla::layers::BufferMode BufferMode;
|
||||
typedef mozilla::layers::CompositorBridgeChild CompositorBridgeChild;
|
||||
|
@ -171,9 +176,10 @@ public:
|
|||
virtual void DrawWindowOverlay(LayerManagerComposite* aManager, LayoutDeviceIntRect aRect) override {}
|
||||
virtual already_AddRefed<mozilla::gfx::DrawTarget> StartRemoteDrawing() override;
|
||||
virtual void EndRemoteDrawing() override { };
|
||||
virtual void CleanupRemoteDrawing() override { };
|
||||
virtual void CleanupRemoteDrawing() override;
|
||||
virtual already_AddRefed<mozilla::gfx::DrawTarget> CreateBackBufferDrawTarget(mozilla::gfx::DrawTarget* aScreenTarget,
|
||||
const LayoutDeviceIntRect& aRect) override;
|
||||
const LayoutDeviceIntRect& aRect,
|
||||
const bool aInitModeClear) override;
|
||||
virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) override {}
|
||||
NS_IMETHOD SetModal(bool aModal) override;
|
||||
virtual uint32_t GetMaxTouchPoints() const override;
|
||||
|
@ -522,6 +528,8 @@ protected:
|
|||
RefPtr<mozilla::CompositorVsyncDispatcher> mCompositorVsyncDispatcher;
|
||||
RefPtr<APZCTreeManager> mAPZC;
|
||||
RefPtr<APZEventState> mAPZEventState;
|
||||
// Back buffer of BasicCompositor
|
||||
RefPtr<DrawTarget> mLastBackBuffer;
|
||||
SetAllowedTouchBehaviorCallback mSetAllowedTouchBehaviorCallback;
|
||||
RefPtr<WidgetShutdownObserver> mShutdownObserver;
|
||||
RefPtr<TextEventDispatcher> mTextEventDispatcher;
|
||||
|
|
|
@ -1324,7 +1324,8 @@ class nsIWidget : public nsISupports {
|
|||
* Create DrawTarget used as BackBuffer of the screen
|
||||
*/
|
||||
virtual already_AddRefed<mozilla::gfx::DrawTarget> CreateBackBufferDrawTarget(mozilla::gfx::DrawTarget* aScreenTarget,
|
||||
const LayoutDeviceIntRect& aRect) = 0;
|
||||
const LayoutDeviceIntRect& aRect,
|
||||
const bool aInitModeClear) = 0;
|
||||
|
||||
/**
|
||||
* A hook for the widget to prepare a Compositor, during the latter's initialization.
|
||||
|
|
Загрузка…
Ссылка в новой задаче