Clean up some methods on ContentClient (bug 1409871 part 17, r=nical)

This commit does some more cleanup on the content client class hierarchy.
Some methods were virtual or instance methods when they didn't need to be.

MozReview-Commit-ID: 2y2D3zYtYvM

--HG--
extra : rebase_source : ebd137e4a1ee8eba10467e987bd2d91ea44ca5a2
This commit is contained in:
Ryan Hunt 2017-10-18 14:54:26 -04:00
Родитель 7f1dd327e3
Коммит 23a0d9c85e
4 изменённых файлов: 46 добавлений и 67 удалений

Просмотреть файл

@ -187,13 +187,13 @@ BasicPaintedLayer::Validate(LayerManager::DrawPaintedLayerCallback aCallback,
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) PaintThebes", this));
Mutated();
ctx = nullptr;
mContentClient->ReturnDrawTargetToBuffer(target);
mContentClient->ReturnDrawTarget(target);
target = nullptr;
RenderTraceInvalidateEnd(this, "FFFF00");
} else {
if (target) {
mContentClient->ReturnDrawTargetToBuffer(target);
mContentClient->ReturnDrawTarget(target);
target = nullptr;
}

Просмотреть файл

@ -152,7 +152,7 @@ ClientPaintedLayer::PaintThebes(nsTArray<ReadbackProcessor::Update>* aReadbackUp
while (DrawTarget* target = mContentClient->BorrowDrawTargetForPainting(state, &iter)) {
if (!target || !target->IsValid()) {
if (target) {
mContentClient->ReturnDrawTargetToBuffer(target);
mContentClient->ReturnDrawTarget(target);
}
continue;
}
@ -171,7 +171,7 @@ ClientPaintedLayer::PaintThebes(nsTArray<ReadbackProcessor::Update>* aReadbackUp
ClientManager()->GetPaintedLayerCallbackData());
ctx = nullptr;
mContentClient->ReturnDrawTargetToBuffer(target);
mContentClient->ReturnDrawTarget(target);
didUpdate = true;
}
@ -227,7 +227,7 @@ ClientPaintedLayer::PaintOffMainThread()
DrawTarget* target = captureState->mTargetDual;
if (!target || !target->IsValid()) {
if (target) {
mContentClient->ReturnDrawTargetToBuffer(target);
mContentClient->ReturnDrawTarget(target);
}
continue;
}
@ -257,7 +257,7 @@ ClientPaintedLayer::PaintOffMainThread()
PaintThread::Get()->PaintContents(captureState,
ContentClient::PrepareDrawTargetForPainting);
mContentClient->ReturnDrawTargetToBuffer(target);
mContentClient->ReturnDrawTarget(target);
didUpdate = true;
}

Просмотреть файл

@ -256,6 +256,27 @@ ContentClient::BorrowDrawTargetForPainting(ContentClient::PaintState& aPaintStat
return capturedState->mTargetDual;
}
nsIntRegion
ExpandDrawRegion(ContentClient::PaintState& aPaintState,
RotatedBuffer::DrawIterator* aIter,
BackendType aBackendType)
{
nsIntRegion* drawPtr = &aPaintState.mRegionToDraw;
if (aIter) {
// The iterators draw region currently only contains the bounds of the region,
// this makes it the precise region.
aIter->mDrawRegion.And(aIter->mDrawRegion, aPaintState.mRegionToDraw);
drawPtr = &aIter->mDrawRegion;
}
if (aBackendType == BackendType::DIRECT2D ||
aBackendType == BackendType::DIRECT2D1_1) {
// Simplify the draw region to avoid hitting expensive drawing paths
// for complex regions.
drawPtr->SimplifyOutwardByArea(100 * 100);
}
return *drawPtr;
}
RefPtr<CapturedPaintState>
ContentClient::BorrowDrawTargetForRecording(ContentClient::PaintState& aPaintState,
RotatedBuffer::DrawIterator* aIter,
@ -291,32 +312,11 @@ ContentClient::BorrowDrawTargetForRecording(ContentClient::PaintState& aPaintSta
}
void
ContentClient::ReturnDrawTargetToBuffer(gfx::DrawTarget*& aReturned)
ContentClient::ReturnDrawTarget(gfx::DrawTarget*& aReturned)
{
mBuffer->ReturnDrawTarget(aReturned);
}
nsIntRegion
ContentClient::ExpandDrawRegion(ContentClient::PaintState& aPaintState,
RotatedBuffer::DrawIterator* aIter,
BackendType aBackendType)
{
nsIntRegion* drawPtr = &aPaintState.mRegionToDraw;
if (aIter) {
// The iterators draw region currently only contains the bounds of the region,
// this makes it the precise region.
aIter->mDrawRegion.And(aIter->mDrawRegion, aPaintState.mRegionToDraw);
drawPtr = &aIter->mDrawRegion;
}
if (aBackendType == BackendType::DIRECT2D ||
aBackendType == BackendType::DIRECT2D1_1) {
// Simplify the draw region to avoid hitting expensive drawing paths
// for complex regions.
drawPtr->SimplifyOutwardByArea(100 * 100);
}
return *drawPtr;
}
/*static */ bool
ContentClient::PrepareDrawTargetForPainting(CapturedPaintState* aState)
{
@ -631,19 +631,6 @@ private:
nsIntPoint mBufferRotation;
};
void
ContentClientRemoteBuffer::BeginPaint()
{
EnsureBackBufferIfFrontBuffer();
}
void
ContentClientRemoteBuffer::BeginAsyncPaint()
{
BeginPaint();
mInAsyncPaint = true;
}
void
ContentClientRemoteBuffer::EndPaint(nsTArray<ReadbackProcessor::Update>* aReadbackUpdates)
{
@ -835,6 +822,13 @@ ContentClientDoubleBuffered::Dump(std::stringstream& aStream,
aCompress);
}
void
ContentClientDoubleBuffered::Clear()
{
ContentClient::Clear();
mFrontBuffer = nullptr;
}
void
ContentClientDoubleBuffered::SwapBuffers(const nsIntRegion& aFrontUpdatedRegion)
{
@ -854,7 +848,7 @@ ContentClientDoubleBuffered::SwapBuffers(const nsIntRegion& aFrontUpdatedRegion)
void
ContentClientDoubleBuffered::BeginPaint()
{
ContentClientRemoteBuffer::BeginPaint();
EnsureBackBufferIfFrontBuffer();
mIsNewBuffer = false;

Просмотреть файл

@ -173,22 +173,13 @@ public:
RotatedBuffer::DrawIterator* aIter,
bool aSetTransform = false);
virtual void ReturnDrawTargetToBuffer(gfx::DrawTarget*& aReturned);
// Called as part of the layers transation reply. Conveys data about our
// buffer(s) from the compositor. If appropriate we should swap references
// to our buffers.
virtual void SwapBuffers(const nsIntRegion& aFrontUpdatedRegion) {}
void ReturnDrawTarget(gfx::DrawTarget*& aReturned);
// Call before and after painting into this content client
virtual void BeginPaint() {}
virtual void BeginAsyncPaint();
virtual void EndPaint(nsTArray<ReadbackProcessor::Update>* aReadbackUpdates = nullptr);
nsIntRegion ExpandDrawRegion(PaintState& aPaintState,
RotatedBuffer::DrawIterator* aIter,
gfx::BackendType aBackendType);
static bool PrepareDrawTargetForPainting(CapturedPaintState*);
enum {
@ -316,8 +307,6 @@ public:
RotatedBuffer::DrawIterator* aIter,
bool aSetTransform) override;
virtual void BeginPaint() override;
virtual void BeginAsyncPaint() override;
virtual void EndPaint(nsTArray<ReadbackProcessor::Update>* aReadbackUpdates = nullptr) override;
virtual void Updated(const nsIntRegion& aRegionToDraw,
@ -329,15 +318,15 @@ public:
}
protected:
/**
* Called when we have been updated and should swap references to our
* buffers.
*/
virtual void SwapBuffers(const nsIntRegion& aFrontUpdatedRegion) {}
virtual nsIntRegion GetUpdatedRegion(const nsIntRegion& aRegionToDraw,
const nsIntRegion& aVisibleRegion);
/**
* Ensure we have a valid back buffer if we have a valid front buffer (i.e.
* if a backbuffer has been created.)
*/
virtual void EnsureBackBufferIfFrontBuffer() {}
virtual RefPtr<RotatedBuffer> CreateBuffer(gfxContentType aType,
const gfx::IntRect& aRect,
uint32_t aFlags) override;
@ -378,11 +367,7 @@ public:
bool aDumpHtml=false,
TextureDumpMode aCompress=TextureDumpMode::Compress) override;
virtual void Clear() override
{
ContentClient::Clear();
mFrontBuffer = nullptr;
}
virtual void Clear() override;
virtual void SwapBuffers(const nsIntRegion& aFrontUpdatedRegion) override;
@ -391,14 +376,14 @@ public:
virtual void FinalizeFrame(const nsIntRegion& aRegionToDraw) override;
virtual void EnsureBackBufferIfFrontBuffer() override;
virtual TextureInfo GetTextureInfo() const override
{
return TextureInfo(CompositableType::CONTENT_DOUBLE, mTextureFlags);
}
private:
void EnsureBackBufferIfFrontBuffer();
RefPtr<RemoteRotatedBuffer> mFrontBuffer;
nsIntRegion mFrontUpdatedRegion;
bool mFrontAndBackBufferDiffer;