Remove BufferContentType and add ValidBufferSize (bug 1399692 part 3, r=bas)

BufferContentType and BufferSizeOkFor make more sense as general functions for
any RotatedBuffer, and this helps out in a later patch.

MozReview-Commit-ID: EAVodvl4WTu

--HG--
extra : rebase_source : 6b3406713414a5fe5c1ace6cd0db86c811557323
extra : source : b57a3f0d08478f094328b5a50c57eed35798fdf0
This commit is contained in:
Ryan Hunt 2017-10-23 14:56:13 -04:00
Родитель 94edce8cf6
Коммит acf6bf600e
4 изменённых файлов: 26 добавлений и 27 удалений

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

@ -389,6 +389,12 @@ RotatedBuffer::AdjustTo(const gfx::IntRect& aDestBufferRect,
return true;
}
RotatedBuffer::ContentType
RotatedBuffer::GetContentType() const
{
return ContentForFormat(GetFormat());
}
DrawTarget*
RotatedBuffer::BorrowDrawTargetForQuadrantUpdate(const IntRect& aBounds,
ContextSource aSource,

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

@ -203,6 +203,11 @@ public:
*/
void ClearDidSelfCopy() { mDidSelfCopy = false; }
/**
* Gets the content type for this buffer.
*/
ContentType GetContentType() const;
virtual bool IsLocked() = 0;
virtual bool Lock(OpenMode aMode) = 0;
virtual void Unlock() = 0;

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

@ -127,17 +127,17 @@ ContentClient::BeginPaint(PaintedLayer* aLayer,
MOZ_ASSERT(dest.mValidRegion.IsEmpty());
result.mRegionToInvalidate = aLayer->GetValidRegion();
Clear();
#if defined(MOZ_DUMP_PAINTING)
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
if (result.mContentType != BufferContentType()) {
if (result.mContentType != mBuffer->GetContentType()) {
printf_stderr("Invalidating entire rotated buffer (layer %p): content type changed\n", aLayer);
} else if ((dest.mBufferMode == SurfaceMode::SURFACE_COMPONENT_ALPHA) != mBuffer->HaveBufferOnWhite()) {
printf_stderr("Invalidating entire rotated buffer (layer %p): component alpha changed\n", aLayer);
}
}
#endif
Clear();
}
result.mRegionToDraw.Sub(dest.mNeededRegion,
@ -380,7 +380,9 @@ ContentClient::CalculateBufferForPaint(PaintedLayer* aLayer,
while (true) {
mode = aLayer->GetSurfaceMode();
neededRegion = aLayer->GetVisibleRegion().ToUnknownRegion();
canReuseBuffer = canReuseBuffer && BufferSizeOkFor(neededRegion.GetBounds().Size());
canReuseBuffer = canReuseBuffer && ValidBufferSize(mBufferSizePolicy,
mBuffer->BufferRect().Size(),
neededRegion.GetBounds().Size());
contentType = layerContentType;
if (canReuseBuffer) {
@ -433,7 +435,7 @@ ContentClient::CalculateBufferForPaint(PaintedLayer* aLayer,
// have transitioned into/out of component alpha, then we need to recreate it.
if (canKeepBufferContents &&
mBuffer &&
(contentType != BufferContentType() ||
(contentType != mBuffer->GetContentType() ||
(mode == SurfaceMode::SURFACE_COMPONENT_ALPHA) != mBuffer->HaveBufferOnWhite()))
{
// Restart the decision process; we won't re-enter since we guard on
@ -461,22 +463,14 @@ ContentClient::CalculateBufferForPaint(PaintedLayer* aLayer,
return dest;
}
gfxContentType
ContentClient::BufferContentType()
{
if (mBuffer) {
return ContentForFormat(mBuffer->GetFormat());
}
return gfxContentType::SENTINEL;
}
bool
ContentClient::BufferSizeOkFor(const IntSize& aSize)
ContentClient::ValidBufferSize(BufferSizePolicy aPolicy,
const gfx::IntSize& aBufferSize,
const gfx::IntSize& aVisibleBoundsSize)
{
MOZ_ASSERT(mBuffer);
return (aSize == mBuffer->BufferRect().Size() ||
(SizedToVisibleBounds != mBufferSizePolicy &&
aSize < mBuffer->BufferRect().Size()));
return (aVisibleBoundsSize == aBufferSize ||
(SizedToVisibleBounds != aPolicy &&
aVisibleBoundsSize < aBufferSize));
}
void

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

@ -203,15 +203,9 @@ protected:
BufferDecision CalculateBufferForPaint(PaintedLayer* aLayer,
uint32_t aFlags);
/**
* Return the buffer's content type. Requires a valid buffer.
*/
gfxContentType BufferContentType();
/**
* Returns whether the specified size is adequate for the current
* buffer and buffer size policy.
*/
bool BufferSizeOkFor(const gfx::IntSize& aSize);
static bool ValidBufferSize(BufferSizePolicy aPolicy,
const gfx::IntSize& aBufferSize,
const gfx::IntSize& aVisibleBoundsSize);
/**
* Any actions that should be performed at the last moment before we begin