Bug 1423567: Use BaseRect access methods instead of member variables in image/ r=aosmond

MozReview-Commit-ID: JNYZsts6pCO

--HG--
extra : rebase_source : d37ce77ec84af302018f95285cff61b2ba28c957
This commit is contained in:
Milan Sreckovic 2017-12-20 16:46:28 -05:00
Родитель dfea46545e
Коммит d0d070b48c
10 изменённых файлов: 57 добавлений и 57 удалений

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

@ -459,7 +459,7 @@ ClippedImage::DrawSingleTile(gfxContext* aContext,
MOZ_ASSERT(!MustCreateSurface(aContext, aSize, aRegion, aFlags),
"Shouldn't need to create a surface");
gfxRect clip(mClip.x, mClip.y, mClip.Width(), mClip.Height());
gfxRect clip(mClip.X(), mClip.Y(), mClip.Width(), mClip.Height());
nsIntSize size(aSize), innerSize(aSize);
bool needScale = false;
if (mSVGViewportSize && !mSVGViewportSize->IsEmpty()) {
@ -486,11 +486,11 @@ ClippedImage::DrawSingleTile(gfxContext* aContext,
// We restrict our drawing to only the clipping region, and translate so that
// the clipping region is placed at the position the caller expects.
ImageRegion region(aRegion);
region.MoveBy(clip.x, clip.y);
region.MoveBy(clip.X(), clip.Y());
region = region.Intersect(clip);
gfxContextMatrixAutoSaveRestore saveMatrix(aContext);
aContext->Multiply(gfxMatrix::Translation(-clip.x, -clip.y));
aContext->Multiply(gfxMatrix::Translation(-clip.X(), -clip.Y()));
auto unclipViewport = [&](const SVGImageContext& aOldContext) {
// Map the viewport to the inner image. Note that we don't take the aSize
@ -601,7 +601,7 @@ ClippedImage::GetImageSpaceInvalidationRect(const nsIntRect& aRect)
nsIntRect rect(InnerImage()->GetImageSpaceInvalidationRect(aRect));
rect = rect.Intersect(mClip);
rect.MoveBy(-mClip.x, -mClip.y);
rect.MoveBy(-mClip.X(), -mClip.Y());
return rect;
}

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

@ -78,7 +78,7 @@ Downscaler::BeginFrame(const nsIntSize& aOriginalSize,
}
mFrameRect = aFrameRect.valueOr(nsIntRect(nsIntPoint(), aOriginalSize));
MOZ_ASSERT(mFrameRect.x >= 0 && mFrameRect.y >= 0 &&
MOZ_ASSERT(mFrameRect.X() >= 0 && mFrameRect.Y() >= 0 &&
mFrameRect.Width() >= 0 && mFrameRect.Height() >= 0,
"Frame rect must have non-negative components");
MOZ_ASSERT(nsIntRect(0, 0, aOriginalSize.width, aOriginalSize.height)
@ -168,7 +168,7 @@ Downscaler::ResetForNextProgressivePass()
SkipToRow(mOriginalSize.height - 1);
} else {
// If we have a vertical offset, commit rows to shift us past it.
SkipToRow(mFrameRect.y);
SkipToRow(mFrameRect.Y());
}
}
@ -219,7 +219,7 @@ Downscaler::CommitRow()
// If we're at the end of the part of the original image that has data, commit
// rows to shift us to the end.
if (mCurrentInLine == (mFrameRect.y + mFrameRect.Height())) {
if (mCurrentInLine == (mFrameRect.Y() + mFrameRect.Height())) {
SkipToRow(mOriginalSize.height - 1);
}
}

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

@ -89,7 +89,7 @@ public:
/// Retrieves the buffer into which the Decoder should write each row.
uint8_t* RowBuffer()
{
return mRowBuffer.get() + mFrameRect.x * sizeof(uint32_t);
return mRowBuffer.get() + mFrameRect.X() * sizeof(uint32_t);
}
/// Clears the current row buffer.

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

@ -602,9 +602,7 @@ FrameAnimator::DoBlend(DrawableSurface& aFrames,
? prevFrameData.mRect.Intersect(*prevFrameData.mBlendRect)
: prevFrameData.mRect;
bool isFullPrevFrame = prevRect.x == 0 && prevRect.y == 0 &&
prevRect.Width() == mSize.width &&
prevRect.Height() == mSize.height;
bool isFullPrevFrame = prevRect.IsEqualRect(0, 0, mSize.width, mSize.height);
// Optimization: DisposeClearAll if the previous frame is the same size as
// container and it's clearing itself
@ -619,9 +617,7 @@ FrameAnimator::DoBlend(DrawableSurface& aFrames,
? nextFrameData.mRect.Intersect(*nextFrameData.mBlendRect)
: nextFrameData.mRect;
bool isFullNextFrame = nextRect.x == 0 && nextRect.y == 0 &&
nextRect.Width() == mSize.width &&
nextRect.Height() == mSize.height;
bool isFullNextFrame = nextRect.IsEqualRect(0, 0, mSize.width, mSize.height);
if (!nextFrame->GetIsPaletted()) {
// Optimization: Skip compositing if the previous frame wants to clear the
@ -719,7 +715,7 @@ FrameAnimator::DoBlend(DrawableSurface& aFrames,
// No need to blank the composite frame
needToBlankComposite = false;
} else {
if ((prevRect.x >= nextRect.x) && (prevRect.y >= nextRect.y) &&
if ((prevRect.X() >= nextRect.X()) && (prevRect.Y() >= nextRect.Y()) &&
(prevRect.XMost() <= nextRect.XMost()) &&
(prevRect.YMost() <= nextRect.YMost())) {
// Optimization: No need to dispose prev.frame when
@ -893,8 +889,8 @@ FrameAnimator::ClearFrame(uint8_t* aFrameData, const IntRect& aFrameRect,
}
uint32_t bytesPerRow = aFrameRect.Width() * 4;
for (int row = toClear.y; row < toClear.YMost(); ++row) {
memset(aFrameData + toClear.x * 4 + row * bytesPerRow, 0,
for (int row = toClear.Y(); row < toClear.YMost(); ++row) {
memset(aFrameData + toClear.X() * 4 + row * bytesPerRow, 0,
toClear.Width() * 4);
}
}
@ -930,24 +926,25 @@ FrameAnimator::DrawFrameTo(const uint8_t* aSrcData, const IntRect& aSrcRect,
NS_ENSURE_ARG_POINTER(aDstPixels);
// According to both AGIF and APNG specs, offsets are unsigned
if (aSrcRect.x < 0 || aSrcRect.y < 0) {
if (aSrcRect.X() < 0 || aSrcRect.Y() < 0) {
NS_WARNING("FrameAnimator::DrawFrameTo: negative offsets not allowed");
return NS_ERROR_FAILURE;
}
// Outside the destination frame, skip it
if ((aSrcRect.x > aDstRect.Width()) || (aSrcRect.y > aDstRect.Height())) {
if ((aSrcRect.X() > aDstRect.Width()) || (aSrcRect.Y() > aDstRect.Height())) {
return NS_OK;
}
if (aSrcPaletteLength) {
// Larger than the destination frame, clip it
int32_t width = std::min(aSrcRect.Width(), aDstRect.Width() - aSrcRect.x);
int32_t height = std::min(aSrcRect.Height(), aDstRect.Height() - aSrcRect.y);
int32_t width = std::min(aSrcRect.Width(), aDstRect.Width() - aSrcRect.X());
int32_t height = std::min(aSrcRect.Height(), aDstRect.Height() - aSrcRect.Y());
// The clipped image must now fully fit within destination image frame
NS_ASSERTION((aSrcRect.x >= 0) && (aSrcRect.y >= 0) &&
(aSrcRect.x + width <= aDstRect.Width()) &&
(aSrcRect.y + height <= aDstRect.Height()),
NS_ASSERTION((aSrcRect.X() >= 0) && (aSrcRect.Y() >= 0) &&
(aSrcRect.X() + width <= aDstRect.Width()) &&
(aSrcRect.Y() + height <= aDstRect.Height()),
"FrameAnimator::DrawFrameTo: Invalid aSrcRect");
// clipped image size may be smaller than source, but not larger
@ -960,7 +957,7 @@ FrameAnimator::DrawFrameTo(const uint8_t* aSrcData, const IntRect& aSrcRect,
const uint32_t* colormap = reinterpret_cast<const uint32_t*>(aSrcData);
// Skip to the right offset
dstPixels += aSrcRect.x + (aSrcRect.y * aDstRect.Width());
dstPixels += aSrcRect.X() + (aSrcRect.Y() * aDstRect.Width());
if (!aSrcHasAlpha) {
for (int32_t r = height; r > 0; --r) {
for (int32_t c = 0; c < width; c++) {
@ -1030,7 +1027,7 @@ FrameAnimator::DrawFrameTo(const uint8_t* aSrcData, const IntRect& aSrcRect,
dst,
0, 0,
0, 0,
aSrcRect.x, aSrcRect.y,
aSrcRect.X(), aSrcRect.Y(),
aSrcRect.Width(), aSrcRect.Height());
} else {
// We need to do the OVER followed by SOURCE trick above.
@ -1040,15 +1037,15 @@ FrameAnimator::DrawFrameTo(const uint8_t* aSrcData, const IntRect& aSrcRect,
dst,
0, 0,
0, 0,
aSrcRect.x, aSrcRect.y,
aSrcRect.X(), aSrcRect.Y(),
aSrcRect.Width(), aSrcRect.Height());
pixman_image_composite32(PIXMAN_OP_SRC,
src,
nullptr,
dst,
aBlendRect->x, aBlendRect->y,
aBlendRect->X(), aBlendRect->Y(),
0, 0,
aBlendRect->x, aBlendRect->y,
aBlendRect->X(), aBlendRect->Y(),
aBlendRect->Width(), aBlendRect->Height());
}

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

@ -395,10 +395,10 @@ OrientedImage::GetImageSpaceInvalidationRect(const nsIntRect& aRect)
// Transform the invalidation rect into the correct orientation.
gfxMatrix matrix(OrientationMatrix(innerSize));
gfxRect invalidRect(matrix.TransformBounds(gfxRect(rect.x, rect.y,
gfxRect invalidRect(matrix.TransformBounds(gfxRect(rect.X(), rect.Y(),
rect.Width(), rect.Height())));
return IntRect::RoundOut(invalidRect.x, invalidRect.y,
return IntRect::RoundOut(invalidRect.X(), invalidRect.Y(),
invalidRect.Width(), invalidRect.Height());
}

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

@ -401,10 +401,13 @@ ProgressTracker::SyncNotify(IProgressObserver* aObserver)
nsIntRect rect;
if (image) {
if (NS_FAILED(image->GetWidth(&rect.width)) ||
NS_FAILED(image->GetHeight(&rect.height))) {
int32_t width, height;
if (NS_FAILED(image->GetWidth(&width)) ||
NS_FAILED(image->GetHeight(&height))) {
// Either the image has no intrinsic size, or it has an error.
rect = GetMaxSizedIntRect();
} else {
rect.SizeTo(width, height);
}
}

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

@ -423,12 +423,12 @@ protected:
return nullptr;
}
mRow = mUnclampedFrameRect.y;
mRow = mUnclampedFrameRect.Y();
// Advance the next pipeline stage to the beginning of the frame rect,
// outputting blank rows.
if (mFrameRect.y > 0) {
for (int32_t rowToOutput = 0; rowToOutput < mFrameRect.y ; ++rowToOutput) {
if (mFrameRect.Y() > 0) {
for (int32_t rowToOutput = 0; rowToOutput < mFrameRect.Y() ; ++rowToOutput) {
mNext.WriteEmptyRow();
}
}
@ -459,7 +459,7 @@ protected:
const int32_t currentRow = mRow;
mRow++;
if (currentRow < mFrameRect.y) {
if (currentRow < mFrameRect.Y()) {
// This row is outside of the frame rect, so just drop it on the floor.
rowPtr = mBuffer ? mBuffer.get() : mNext.CurrentRowPointer();
return AdjustRowPointer(rowPtr);
@ -474,13 +474,13 @@ protected:
// is negative; if that's the case, we have to skip the portion of the
// unclamped frame rect that's outside the row.
uint32_t* source = reinterpret_cast<uint32_t*>(mBuffer.get()) -
std::min(mUnclampedFrameRect.x, 0);
std::min(mUnclampedFrameRect.X(), 0);
// We write |mFrameRect.width| columns starting at |mFrameRect.x|; we've
// already clamped these values to the size of the output, so we don't
// have to worry about bounds checking here (though WriteBuffer() will do
// it for us in any case).
WriteState state = mNext.WriteBuffer(source, mFrameRect.x, mFrameRect.Width());
WriteState state = mNext.WriteBuffer(source, mFrameRect.X(), mFrameRect.Width());
rowPtr = state == WriteState::NEED_MORE_DATA ? mBuffer.get()
: nullptr;
@ -516,7 +516,7 @@ private:
return nullptr; // Nothing left to write.
}
return aNextRowPointer + mFrameRect.x * sizeof(uint32_t);
return aNextRowPointer + mFrameRect.X() * sizeof(uint32_t);
}
Next mNext; /// The next SurfaceFilter in the chain.

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

@ -797,10 +797,10 @@ nsGIFDecoder2::FinishImageDescriptor(const char* aData)
IntRect frameRect;
// Get image offsets with respect to the screen origin.
frameRect.x = LittleEndian::readUint16(aData + 0);
frameRect.y = LittleEndian::readUint16(aData + 2);
frameRect.SetWidth(LittleEndian::readUint16(aData + 4));
frameRect.SetHeight(LittleEndian::readUint16(aData + 6));
frameRect.SetRect(LittleEndian::readUint16(aData + 0),
LittleEndian::readUint16(aData + 2),
LittleEndian::readUint16(aData + 4),
LittleEndian::readUint16(aData + 6));
if (!mGIFStruct.images_decoded) {
// Work around GIF files where

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

@ -507,7 +507,7 @@ imgFrame::SurfaceForDrawing(bool aDoPartialDecode,
mFormat);
}
gfxRect available = gfxRect(mDecoded.x, mDecoded.y, mDecoded.Width(),
gfxRect available = gfxRect(mDecoded.X(), mDecoded.Y(), mDecoded.Width(),
mDecoded.Height());
if (aDoTile) {
@ -523,7 +523,7 @@ imgFrame::SurfaceForDrawing(bool aDoPartialDecode,
SurfacePattern pattern(aSurface,
aRegion.GetExtendMode(),
Matrix::Translation(mDecoded.x, mDecoded.y));
Matrix::Translation(mDecoded.X(), mDecoded.Y()));
target->FillRect(ToRect(aRegion.Intersect(available).Rect()), pattern);
RefPtr<SourceSurface> newsurf = target->Snapshot();

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

@ -170,7 +170,7 @@ PalettedRowsAreSolidColor(Decoder* aDecoder,
{
RawAccessFrameRef currentFrame = aDecoder->GetCurrentFrameRef();
IntRect frameRect = currentFrame->GetRect();
IntRect solidColorRect(frameRect.x, aStartRow, frameRect.Width(), aRowCount);
IntRect solidColorRect(frameRect.X(), aStartRow, frameRect.Width(), aRowCount);
return PalettedRectIsSolidColor(aDecoder, solidColorRect, aColor);
}
@ -196,8 +196,8 @@ RectIsSolidColor(SourceSurface* aSurface,
ASSERT_TRUE_OR_RETURN(data != nullptr, false);
int32_t rowLength = mapping.GetStride();
for (int32_t row = rect.y; row < rect.YMost(); ++row) {
for (int32_t col = rect.x; col < rect.XMost(); ++col) {
for (int32_t row = rect.Y(); row < rect.YMost(); ++row) {
for (int32_t col = rect.X(); col < rect.XMost(); ++col) {
int32_t i = row * rowLength + col * 4;
if (aFuzz != 0) {
ASSERT_LE_OR_RETURN(abs(aColor.mBlue - data[i + 0]), aFuzz, false);
@ -243,8 +243,8 @@ PalettedRectIsSolidColor(Decoder* aDecoder, const IntRect& aRect, uint8_t aColor
// Walk through the image data and make sure that the entire rect has the
// palette index |aColor|.
int32_t rowLength = frameRect.Width();
for (int32_t row = rect.y; row < rect.YMost(); ++row) {
for (int32_t col = rect.x; col < rect.XMost(); ++col) {
for (int32_t row = rect.Y(); row < rect.YMost(); ++row) {
for (int32_t col = rect.X(); col < rect.XMost(); ++col) {
int32_t i = row * rowLength + col;
ASSERT_EQ_OR_RETURN(aColor, imageData[i], false);
}
@ -342,18 +342,18 @@ CheckGeneratedImage(Decoder* aDecoder,
// Check that the area above the output rect is transparent. (Region 'A'.)
EXPECT_TRUE(RectIsSolidColor(surface,
IntRect(0, 0, surfaceSize.width, aRect.y),
IntRect(0, 0, surfaceSize.width, aRect.Y()),
BGRAColor::Transparent(), aFuzz));
// Check that the area to the left of the output rect is transparent. (Region 'B'.)
EXPECT_TRUE(RectIsSolidColor(surface,
IntRect(0, aRect.y, aRect.x, aRect.YMost()),
IntRect(0, aRect.Y(), aRect.X(), aRect.YMost()),
BGRAColor::Transparent(), aFuzz));
// Check that the area to the right of the output rect is transparent. (Region 'D'.)
const int32_t widthOnRight = surfaceSize.width - aRect.XMost();
EXPECT_TRUE(RectIsSolidColor(surface,
IntRect(aRect.XMost(), aRect.y, widthOnRight, aRect.YMost()),
IntRect(aRect.XMost(), aRect.Y(), widthOnRight, aRect.YMost()),
BGRAColor::Transparent(), aFuzz));
// Check that the area below the output rect is transparent. (Region 'E'.)
@ -386,18 +386,18 @@ CheckGeneratedPalettedImage(Decoder* aDecoder, const IntRect& aRect)
// Check that the area above the output rect is all 0's. (Region 'A'.)
EXPECT_TRUE(PalettedRectIsSolidColor(aDecoder,
IntRect(0, 0, imageSize.width, aRect.y),
IntRect(0, 0, imageSize.width, aRect.Y()),
0));
// Check that the area to the left of the output rect is all 0's. (Region 'B'.)
EXPECT_TRUE(PalettedRectIsSolidColor(aDecoder,
IntRect(0, aRect.y, aRect.x, aRect.YMost()),
IntRect(0, aRect.Y(), aRect.X(), aRect.YMost()),
0));
// Check that the area to the right of the output rect is all 0's. (Region 'D'.)
const int32_t widthOnRight = imageSize.width - aRect.XMost();
EXPECT_TRUE(PalettedRectIsSolidColor(aDecoder,
IntRect(aRect.XMost(), aRect.y, widthOnRight, aRect.YMost()),
IntRect(aRect.XMost(), aRect.Y(), widthOnRight, aRect.YMost()),
0));
// Check that the area below the output rect is transparent. (Region 'E'.)