зеркало из https://github.com/mozilla/gecko-dev.git
Add a RemoteRotatedBuffer. (bug 1409871 part 4, r=nical)
This adds a new implementation of rotated buffer, which is backed by texture clients. This will be the rotated buffer that remote content clients use. MozReview-Commit-ID: 3Y776uk5mFG --HG-- extra : rebase_source : 40acce3f4150c5f6f51bf73f0b3c7e974ed8fd72
This commit is contained in:
Родитель
cbde30661f
Коммит
d7d2f8b642
|
@ -347,6 +347,78 @@ RotatedBuffer::BorrowDrawTargetForQuadrantUpdate(const IntRect& aBounds,
|
|||
return mLoanedDrawTarget;
|
||||
}
|
||||
|
||||
bool
|
||||
RemoteRotatedBuffer::Lock(OpenMode aMode)
|
||||
{
|
||||
MOZ_ASSERT(!mTarget);
|
||||
MOZ_ASSERT(!mTargetOnWhite);
|
||||
|
||||
bool locked = mClient->Lock(aMode) &&
|
||||
(!mClientOnWhite || mClientOnWhite->Lock(aMode));
|
||||
if (!locked) {
|
||||
Unlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
mTarget = mClient->BorrowDrawTarget();
|
||||
if (!mTarget || !mTarget->IsValid()) {
|
||||
gfxCriticalNote << "Invalid draw target " << hexa(mTarget)
|
||||
<< "in RemoteRotatedBuffer::Lock";
|
||||
Unlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mClientOnWhite) {
|
||||
mTargetOnWhite = mClientOnWhite->BorrowDrawTarget();
|
||||
if (!mTargetOnWhite || !mTargetOnWhite->IsValid()) {
|
||||
gfxCriticalNote << "Invalid draw target(s) " << hexa(mTarget)
|
||||
<< " and " << hexa(mTargetOnWhite)
|
||||
<< "in RemoteRotatedBuffer::Lock";
|
||||
Unlock();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
RemoteRotatedBuffer::Unlock()
|
||||
{
|
||||
mTarget = nullptr;
|
||||
mTargetOnWhite = nullptr;
|
||||
|
||||
if (mClient->IsLocked()) {
|
||||
mClient->Unlock();
|
||||
}
|
||||
if (mClientOnWhite && mClientOnWhite->IsLocked()) {
|
||||
mClientOnWhite->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<gfx::SourceSurface>
|
||||
RemoteRotatedBuffer::GetSourceSurface(ContextSource aSource) const
|
||||
{
|
||||
if (aSource == ContextSource::BUFFER_BLACK) {
|
||||
return mTarget->Snapshot();
|
||||
} else {
|
||||
MOZ_ASSERT(aSource == ContextSource::BUFFER_WHITE);
|
||||
return mTargetOnWhite->Snapshot();
|
||||
}
|
||||
}
|
||||
|
||||
gfx::DrawTarget*
|
||||
RemoteRotatedBuffer::GetDTBuffer() const
|
||||
{
|
||||
return mTarget;
|
||||
}
|
||||
|
||||
gfx::DrawTarget*
|
||||
RemoteRotatedBuffer::GetDTBufferOnWhite() const
|
||||
{
|
||||
return mTargetOnWhite;
|
||||
}
|
||||
|
||||
already_AddRefed<SourceSurface>
|
||||
SourceRotatedBuffer::GetSourceSurface(ContextSource aSource) const
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "mozilla/RefPtr.h" // for RefPtr, already_AddRefed
|
||||
#include "mozilla/gfx/2D.h" // for DrawTarget, etc
|
||||
#include "mozilla/gfx/MatrixFwd.h" // for Matrix
|
||||
#include "mozilla/layers/TextureClient.h" // for TextureClient
|
||||
#include "mozilla/mozalloc.h" // for operator delete
|
||||
#include "nsCOMPtr.h" // for already_AddRefed
|
||||
#include "nsDebug.h" // for NS_RUNTIMEABORT
|
||||
|
@ -26,7 +27,6 @@ class CapturedPaintState;
|
|||
|
||||
typedef bool (*PrepDrawTargetForPaintingCallback)(CapturedPaintState*);
|
||||
|
||||
class TextureClient;
|
||||
class PaintedLayer;
|
||||
|
||||
// Mixin class for classes which need logic for loaning out a draw target.
|
||||
|
@ -200,6 +200,37 @@ protected:
|
|||
bool mDidSelfCopy;
|
||||
};
|
||||
|
||||
class RemoteRotatedBuffer : public RotatedBuffer
|
||||
{
|
||||
public:
|
||||
RemoteRotatedBuffer(TextureClient* aClient, TextureClient* aClientOnWhite,
|
||||
const gfx::IntRect& aBufferRect,
|
||||
const gfx::IntPoint& aBufferRotation)
|
||||
: RotatedBuffer(aBufferRect, aBufferRotation)
|
||||
, mClient(aClient)
|
||||
, mClientOnWhite(aClientOnWhite)
|
||||
{ }
|
||||
|
||||
bool Lock(OpenMode aMode);
|
||||
void Unlock();
|
||||
|
||||
virtual bool HaveBuffer() const override { return !!mClient; }
|
||||
virtual bool HaveBufferOnWhite() const override { return !!mClientOnWhite; }
|
||||
|
||||
virtual already_AddRefed<gfx::SourceSurface> GetSourceSurface(ContextSource aSource) const override;
|
||||
|
||||
protected:
|
||||
virtual gfx::DrawTarget* GetDTBuffer() const override;
|
||||
virtual gfx::DrawTarget* GetDTBufferOnWhite() const override;
|
||||
|
||||
private:
|
||||
RefPtr<TextureClient> mClient;
|
||||
RefPtr<TextureClient> mClientOnWhite;
|
||||
|
||||
RefPtr<gfx::DrawTarget> mTarget;
|
||||
RefPtr<gfx::DrawTarget> mTargetOnWhite;
|
||||
};
|
||||
|
||||
class SourceRotatedBuffer : public RotatedBuffer
|
||||
{
|
||||
public:
|
||||
|
|
Загрузка…
Ссылка в новой задаче