Skip to content

Commit

Permalink
Bug 1387514: Upgrade BaseRect (derived classes) width and height dire…
Browse files Browse the repository at this point in the history
…ct member variable use to instead use Width()/SetWidth() and Height()/SetHeight() in image/*. r=aosmond

MozReview-Commit-ID: 8gyxxLziVe7

--HG--
extra : rebase_source : c79e81e10c54106645539c590bf81a03a300a909
  • Loading branch information
msreckovic committed Aug 14, 2017
1 parent e3cd0a3 commit 5c01b57
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 89 deletions.
22 changes: 11 additions & 11 deletions image/ClippedImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ ClippedImage::GetWidth(int32_t* aWidth)
return InnerImage()->GetWidth(aWidth);
}

*aWidth = mClip.width;
*aWidth = mClip.Width();
return NS_OK;
}

Expand All @@ -230,7 +230,7 @@ ClippedImage::GetHeight(int32_t* aHeight)
return InnerImage()->GetHeight(aHeight);
}

*aHeight = mClip.height;
*aHeight = mClip.Height();
return NS_OK;
}

Expand All @@ -241,7 +241,7 @@ ClippedImage::GetIntrinsicSize(nsSize* aSize)
return InnerImage()->GetIntrinsicSize(aSize);
}

*aSize = nsSize(mClip.width, mClip.height);
*aSize = nsSize(mClip.Width(), mClip.Height());
return NS_OK;
}

Expand All @@ -252,7 +252,7 @@ ClippedImage::GetIntrinsicRatio(nsSize* aRatio)
return InnerImage()->GetIntrinsicRatio(aRatio);
}

*aRatio = nsSize(mClip.width, mClip.height);
*aRatio = nsSize(mClip.Width(), mClip.Height());
return NS_OK;
}

Expand Down Expand Up @@ -428,7 +428,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()) {
Expand All @@ -443,8 +443,8 @@ ClippedImage::DrawSingleTile(gfxContext* aContext,
}

if (needScale) {
double scaleX = aSize.width / clip.width;
double scaleY = aSize.height / clip.height;
double scaleX = aSize.width / clip.Width();
double scaleY = aSize.height / clip.Height();

// Map the clip and size to the scale requested by the caller.
clip.Scale(scaleX, scaleY);
Expand Down Expand Up @@ -472,9 +472,9 @@ ClippedImage::DrawSingleTile(gfxContext* aContext,
if (oldViewport) {
CSSIntSize newViewport;
newViewport.width =
ceil(oldViewport->width * double(innerSize.width) / mClip.width);
ceil(oldViewport->width * double(innerSize.width) / mClip.Width());
newViewport.height =
ceil(oldViewport->height * double(innerSize.height) / mClip.height);
ceil(oldViewport->height * double(innerSize.height) / mClip.Height());
context.SetViewportSize(Some(newViewport));
}
return context;
Expand Down Expand Up @@ -533,8 +533,8 @@ ClippedImage::OptimalImageSizeForDest(const gfxSize& aDest,

// First, we select a scale that's good for ClippedImage. An integer
// multiple of the size of the clipping region is always fine.
IntSize scale = IntSize::Ceil(aDest.width / mClip.width,
aDest.height / mClip.height);
IntSize scale = IntSize::Ceil(aDest.width / mClip.Width(),
aDest.height / mClip.Height());

if (forceUniformScaling) {
scale.width = scale.height = max(scale.height, scale.width);
Expand Down
2 changes: 1 addition & 1 deletion image/Decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ Decoder::AllocateFrameInternal(uint32_t aFrameNum,
}

if (aOutputSize.width <= 0 || aOutputSize.height <= 0 ||
aFrameRect.width <= 0 || aFrameRect.height <= 0) {
aFrameRect.Width() <= 0 || aFrameRect.Height() <= 0) {
NS_WARNING("Trying to add frame with zero or negative size");
return RawAccessFrameRef();
}
Expand Down
4 changes: 2 additions & 2 deletions image/Downscaler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Downscaler::BeginFrame(const nsIntSize& aOriginalSize,

mFrameRect = aFrameRect.valueOr(nsIntRect(nsIntPoint(), aOriginalSize));
MOZ_ASSERT(mFrameRect.x >= 0 && mFrameRect.y >= 0 &&
mFrameRect.width >= 0 && mFrameRect.height >= 0,
mFrameRect.Width() >= 0 && mFrameRect.Height() >= 0,
"Frame rect must have non-negative components");
MOZ_ASSERT(nsIntRect(0, 0, aOriginalSize.width, aOriginalSize.height)
.Contains(mFrameRect),
Expand Down Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion image/Downscaler.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Downscaler

const nsIntSize& OriginalSize() const { return mOriginalSize; }
const nsIntSize& TargetSize() const { return mTargetSize; }
const nsIntSize FrameSize() const { return nsIntSize(mFrameRect.width, mFrameRect.height); }
const nsIntSize FrameSize() const { return nsIntSize(mFrameRect.Width(), mFrameRect.Height()); }
const gfxSize& Scale() const { return mScale; }

/**
Expand Down
66 changes: 33 additions & 33 deletions image/FrameAnimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,8 @@ FrameAnimator::DoBlend(DrawableSurface& aFrames,
: prevFrameData.mRect;

bool isFullPrevFrame = prevRect.x == 0 && prevRect.y == 0 &&
prevRect.width == mSize.width &&
prevRect.height == mSize.height;
prevRect.Width() == mSize.width &&
prevRect.Height() == mSize.height;

// Optimization: DisposeClearAll if the previous frame is the same size as
// container and it's clearing itself
Expand All @@ -618,8 +618,8 @@ FrameAnimator::DoBlend(DrawableSurface& aFrames,
: nextFrameData.mRect;

bool isFullNextFrame = nextRect.x == 0 && nextRect.y == 0 &&
nextRect.width == mSize.width &&
nextRect.height == mSize.height;
nextRect.Width() == mSize.width &&
nextRect.Height() == mSize.height;

if (!nextFrame->GetIsPaletted()) {
// Optimization: Skip compositing if the previous frame wants to clear the
Expand Down Expand Up @@ -718,8 +718,8 @@ FrameAnimator::DoBlend(DrawableSurface& aFrames,
needToBlankComposite = false;
} else {
if ((prevRect.x >= nextRect.x) && (prevRect.y >= nextRect.y) &&
(prevRect.x + prevRect.width <= nextRect.x + nextRect.width) &&
(prevRect.y + prevRect.height <= nextRect.y + nextRect.height)) {
(prevRect.XMost() <= nextRect.XMost()) &&
(prevRect.YMost() <= nextRect.YMost())) {
// Optimization: No need to dispose prev.frame when
// next frame fully overlaps previous frame.
doDisposal = false;
Expand Down Expand Up @@ -872,16 +872,16 @@ FrameAnimator::ClearFrame(uint8_t* aFrameData, const IntRect& aFrameRect)
return;
}

memset(aFrameData, 0, aFrameRect.width * aFrameRect.height * 4);
memset(aFrameData, 0, aFrameRect.Width() * aFrameRect.Height() * 4);
}

//******************************************************************************
void
FrameAnimator::ClearFrame(uint8_t* aFrameData, const IntRect& aFrameRect,
const IntRect& aRectToClear)
{
if (!aFrameData || aFrameRect.width <= 0 || aFrameRect.height <= 0 ||
aRectToClear.width <= 0 || aRectToClear.height <= 0) {
if (!aFrameData || aFrameRect.Width() <= 0 || aFrameRect.Height() <= 0 ||
aRectToClear.Width() <= 0 || aRectToClear.Height() <= 0) {
return;
}

Expand All @@ -890,10 +890,10 @@ FrameAnimator::ClearFrame(uint8_t* aFrameData, const IntRect& aFrameRect,
return;
}

uint32_t bytesPerRow = aFrameRect.width * 4;
for (int row = toClear.y; row < toClear.y + toClear.height; ++row) {
uint32_t bytesPerRow = aFrameRect.Width() * 4;
for (int row = toClear.y; row < toClear.YMost(); ++row) {
memset(aFrameData + toClear.x * 4 + row * bytesPerRow, 0,
toClear.width * 4);
toClear.Width() * 4);
}
}

Expand All @@ -906,8 +906,8 @@ FrameAnimator::CopyFrameImage(const uint8_t* aDataSrc,
uint8_t* aDataDest,
const IntRect& aRectDest)
{
uint32_t dataLengthSrc = aRectSrc.width * aRectSrc.height * 4;
uint32_t dataLengthDest = aRectDest.width * aRectDest.height * 4;
uint32_t dataLengthSrc = aRectSrc.Width() * aRectSrc.Height() * 4;
uint32_t dataLengthDest = aRectDest.Width() * aRectDest.Height() * 4;

if (!aDataDest || !aDataSrc || dataLengthSrc != dataLengthDest) {
return false;
Expand All @@ -933,23 +933,23 @@ FrameAnimator::DrawFrameTo(const uint8_t* aSrcData, const IntRect& aSrcRect,
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),
(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
NS_ASSERTION((width <= aSrcRect.width) && (height <= aSrcRect.height),
NS_ASSERTION((width <= aSrcRect.Width()) && (height <= aSrcRect.Height()),
"FrameAnimator::DrawFrameTo: source must be smaller than dest");

// Get pointers to image data
Expand All @@ -958,15 +958,15 @@ 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++) {
dstPixels[c] = colormap[srcPixels[c]];
}
// Go to the next row in the source resp. destination image
srcPixels += aSrcRect.width;
dstPixels += aDstRect.width;
srcPixels += aSrcRect.Width();
dstPixels += aDstRect.Width();
}
} else {
for (int32_t r = height; r > 0; --r) {
Expand All @@ -977,26 +977,26 @@ FrameAnimator::DrawFrameTo(const uint8_t* aSrcData, const IntRect& aSrcRect,
}
}
// Go to the next row in the source resp. destination image
srcPixels += aSrcRect.width;
dstPixels += aDstRect.width;
srcPixels += aSrcRect.Width();
dstPixels += aDstRect.Width();
}
}
} else {
pixman_image_t* src =
pixman_image_create_bits(
aSrcHasAlpha ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
aSrcRect.width, aSrcRect.height,
aSrcRect.Width(), aSrcRect.Height(),
reinterpret_cast<uint32_t*>(const_cast<uint8_t*>(aSrcData)),
aSrcRect.width * 4);
aSrcRect.Width() * 4);
if (!src) {
return NS_ERROR_OUT_OF_MEMORY;
}
pixman_image_t* dst =
pixman_image_create_bits(PIXMAN_a8r8g8b8,
aDstRect.width,
aDstRect.height,
aDstRect.Width(),
aDstRect.Height(),
reinterpret_cast<uint32_t*>(aDstPixels),
aDstRect.width * 4);
aDstRect.Width() * 4);
if (!dst) {
pixman_image_unref(src);
return NS_ERROR_OUT_OF_MEMORY;
Expand Down Expand Up @@ -1029,7 +1029,7 @@ FrameAnimator::DrawFrameTo(const uint8_t* aSrcData, const IntRect& aSrcRect,
0, 0,
0, 0,
aSrcRect.x, aSrcRect.y,
aSrcRect.width, aSrcRect.height);
aSrcRect.Width(), aSrcRect.Height());
} else {
// We need to do the OVER followed by SOURCE trick above.
pixman_image_composite32(PIXMAN_OP_OVER,
Expand All @@ -1039,15 +1039,15 @@ FrameAnimator::DrawFrameTo(const uint8_t* aSrcData, const IntRect& aSrcRect,
0, 0,
0, 0,
aSrcRect.x, aSrcRect.y,
aSrcRect.width, aSrcRect.height);
aSrcRect.Width(), aSrcRect.Height());
pixman_image_composite32(PIXMAN_OP_SRC,
src,
nullptr,
dst,
aBlendRect->x, aBlendRect->y,
0, 0,
aBlendRect->x, aBlendRect->y,
aBlendRect->width, aBlendRect->height);
aBlendRect->Width(), aBlendRect->Height());
}

pixman_image_unref(src);
Expand Down
4 changes: 2 additions & 2 deletions image/OrientedImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,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,
rect.width, rect.height)));
rect.Width(), rect.Height())));

return IntRect::RoundOut(invalidRect.x, invalidRect.y,
invalidRect.width, invalidRect.height);
invalidRect.Width(), invalidRect.Height());
}

} // namespace image
Expand Down
10 changes: 5 additions & 5 deletions image/SurfaceFilters.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ class RemoveFrameRectFilter final : public SurfaceFilter
gfx::IntSize outputSize = mNext.InputSize();

// Forbid frame rects with negative size.
if (aConfig.mFrameRect.width < 0 || aConfig.mFrameRect.height < 0) {
if (aConfig.mFrameRect.Width() < 0 || aConfig.mFrameRect.Height() < 0) {
return NS_ERROR_INVALID_ARG;
}

Expand All @@ -395,14 +395,14 @@ class RemoveFrameRectFilter final : public SurfaceFilter
// width is larger than the clamped frame rect width. In that case, the
// caller will end up writing data that won't end up in the final image at
// all, and we'll need a buffer to give that data a place to go.
if (mFrameRect.width < mUnclampedFrameRect.width) {
mBuffer.reset(new (fallible) uint8_t[mUnclampedFrameRect.width *
if (mFrameRect.Width() < mUnclampedFrameRect.Width()) {
mBuffer.reset(new (fallible) uint8_t[mUnclampedFrameRect.Width() *
sizeof(uint32_t)]);
if (MOZ_UNLIKELY(!mBuffer)) {
return NS_ERROR_OUT_OF_MEMORY;
}

memset(mBuffer.get(), 0, mUnclampedFrameRect.width * sizeof(uint32_t));
memset(mBuffer.get(), 0, mUnclampedFrameRect.Width() * sizeof(uint32_t));
}

ConfigureFilter(mUnclampedFrameRect.Size(), sizeof(uint32_t));
Expand Down Expand Up @@ -480,7 +480,7 @@ class RemoveFrameRectFilter final : public SurfaceFilter
// 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;
Expand Down
2 changes: 1 addition & 1 deletion image/SurfacePipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ PalettedSurfaceSink::Configure(const PalettedSurfaceConfig& aConfig)

MOZ_ASSERT(mImageData);
MOZ_ASSERT(mImageDataLength ==
uint32_t(mFrameRect.width * mFrameRect.height * sizeof(uint8_t)));
uint32_t(mFrameRect.Width() * mFrameRect.Height() * sizeof(uint8_t)));

ConfigureFilter(surfaceSize, sizeof(uint8_t));
return NS_OK;
Expand Down
Loading

0 comments on commit 5c01b57

Please sign in to comment.