зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1102048 (Part 04, ClippedImage) - Make image/src files comply with the Mozilla Coding Style Guide. r=seth
This commit is contained in:
Родитель
3eda954ef7
Коммит
bcf05b995c
|
@ -128,16 +128,17 @@ ClippedImage::~ClippedImage()
|
|||
bool
|
||||
ClippedImage::ShouldClip()
|
||||
{
|
||||
// We need to evaluate the clipping region against the image's width and height
|
||||
// once they're available to determine if it's valid and whether we actually
|
||||
// need to do any work. We may fail if the image's width and height aren't
|
||||
// available yet, in which case we'll try again later.
|
||||
// We need to evaluate the clipping region against the image's width and
|
||||
// height once they're available to determine if it's valid and whether we
|
||||
// actually need to do any work. We may fail if the image's width and height
|
||||
// aren't available yet, in which case we'll try again later.
|
||||
if (mShouldClip.isNothing()) {
|
||||
int32_t width, height;
|
||||
nsRefPtr<ProgressTracker> progressTracker =
|
||||
InnerImage()->GetProgressTracker();
|
||||
if (InnerImage()->HasError()) {
|
||||
// If there's a problem with the inner image we'll let it handle everything.
|
||||
// If there's a problem with the inner image we'll let it handle
|
||||
// everything.
|
||||
mShouldClip.emplace(false);
|
||||
} else if (NS_SUCCEEDED(InnerImage()->GetWidth(&width)) && width > 0 &&
|
||||
NS_SUCCEEDED(InnerImage()->GetHeight(&height)) && height > 0) {
|
||||
|
@ -146,11 +147,12 @@ ClippedImage::ShouldClip()
|
|||
|
||||
// If the clipping region is the same size as the underlying image we
|
||||
// don't have to do anything.
|
||||
mShouldClip.emplace(!mClip.IsEqualInterior(nsIntRect(0, 0, width, height)));
|
||||
mShouldClip.emplace(!mClip.IsEqualInterior(nsIntRect(0, 0, width,
|
||||
height)));
|
||||
} else if (progressTracker &&
|
||||
!(progressTracker->GetProgress() & FLAG_LOAD_COMPLETE)) {
|
||||
// The image just hasn't finished loading yet. We don't yet know whether
|
||||
// clipping with be needed or not for now. Just return without memoizing
|
||||
// clipping with be needed or not for now. Just return without memorizing
|
||||
// anything.
|
||||
return false;
|
||||
} else {
|
||||
|
@ -279,7 +281,7 @@ ClippedImage::GetImageContainer(LayerManager* aManager, uint32_t aFlags)
|
|||
return InnerImage()->GetImageContainer(aManager, aFlags);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return (nullptr);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -347,7 +349,8 @@ UnclipViewport(const SVGImageContext& aOldContext,
|
|||
// parameter of Draw into account, just the clipping region.)
|
||||
CSSIntSize vSize(aOldContext.GetViewportSize());
|
||||
vSize.width = ceil(vSize.width * double(innerSize.width) / clipSize.width);
|
||||
vSize.height = ceil(vSize.height * double(innerSize.height) / clipSize.height);
|
||||
vSize.height =
|
||||
ceil(vSize.height * double(innerSize.height) / clipSize.height);
|
||||
|
||||
return SVGImageContext(vSize,
|
||||
aOldContext.GetPreserveAspectRatio());
|
||||
|
@ -371,13 +374,14 @@ ClippedImage::DrawSingleTile(gfxContext* aContext,
|
|||
NS_SUCCEEDED(InnerImage()->GetHeight(&innerSize.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);
|
||||
size = innerSize;
|
||||
size.Scale(scaleX, scaleY);
|
||||
} else {
|
||||
MOZ_ASSERT(false, "If ShouldClip() led us to draw then we should never get here");
|
||||
MOZ_ASSERT(false,
|
||||
"If ShouldClip() led us to draw then we should never get here");
|
||||
}
|
||||
|
||||
// We restrict our drawing to only the clipping region, and translate so that
|
||||
|
@ -414,11 +418,13 @@ ClippedImage::GetOrientation()
|
|||
}
|
||||
|
||||
nsIntSize
|
||||
ClippedImage::OptimalImageSizeForDest(const gfxSize& aDest, uint32_t aWhichFrame,
|
||||
ClippedImage::OptimalImageSizeForDest(const gfxSize& aDest,
|
||||
uint32_t aWhichFrame,
|
||||
GraphicsFilter aFilter, uint32_t aFlags)
|
||||
{
|
||||
if (!ShouldClip()) {
|
||||
return InnerImage()->OptimalImageSizeForDest(aDest, aWhichFrame, aFilter, aFlags);
|
||||
return InnerImage()->OptimalImageSizeForDest(aDest, aWhichFrame, aFilter,
|
||||
aFlags);
|
||||
}
|
||||
|
||||
int32_t imgWidth, imgHeight;
|
||||
|
@ -427,8 +433,8 @@ ClippedImage::OptimalImageSizeForDest(const gfxSize& aDest, uint32_t aWhichFrame
|
|||
// To avoid ugly sampling artifacts, ClippedImage needs the image size to
|
||||
// be chosen such that the clipping region lies on pixel boundaries.
|
||||
|
||||
// First, we select a scale that's good for ClippedImage. An integer multiple
|
||||
// of the size of the clipping region is always fine.
|
||||
// First, we select a scale that's good for ClippedImage. An integer
|
||||
// multiple of the size of the clipping region is always fine.
|
||||
nsIntSize scale(ceil(aDest.width / mClip.width),
|
||||
ceil(aDest.height / mClip.height));
|
||||
|
||||
|
@ -446,8 +452,10 @@ ClippedImage::OptimalImageSizeForDest(const gfxSize& aDest, uint32_t aWhichFrame
|
|||
ceil(double(innerDesiredSize.height) / imgHeight));
|
||||
return mClip.Size() * finalScale;
|
||||
} else {
|
||||
MOZ_ASSERT(false, "If ShouldClip() led us to draw then we should never get here");
|
||||
return InnerImage()->OptimalImageSizeForDest(aDest, aWhichFrame, aFilter, aFlags);
|
||||
MOZ_ASSERT(false,
|
||||
"If ShouldClip() led us to draw then we should never get here");
|
||||
return InnerImage()->OptimalImageSizeForDest(aDest, aWhichFrame, aFilter,
|
||||
aFlags);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef MOZILLA_IMAGELIB_CLIPPEDIMAGE_H_
|
||||
#define MOZILLA_IMAGELIB_CLIPPEDIMAGE_H_
|
||||
#ifndef mozilla_image_src_ClippedImage_h
|
||||
#define mozilla_image_src_ClippedImage_h
|
||||
|
||||
#include "ImageWrapper.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
|
@ -49,7 +49,8 @@ public:
|
|||
uint32_t aFlags) override;
|
||||
NS_IMETHOD RequestDiscard() override;
|
||||
NS_IMETHOD_(Orientation) GetOrientation() override;
|
||||
NS_IMETHOD_(nsIntRect) GetImageSpaceInvalidationRect(const nsIntRect& aRect) override;
|
||||
NS_IMETHOD_(nsIntRect) GetImageSpaceInvalidationRect(const nsIntRect& aRect)
|
||||
override;
|
||||
nsIntSize OptimalImageSizeForDest(const gfxSize& aDest,
|
||||
uint32_t aWhichFrame,
|
||||
GraphicsFilter aFilter,
|
||||
|
@ -88,4 +89,4 @@ private:
|
|||
} // namespace image
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // MOZILLA_IMAGELIB_CLIPPEDIMAGE_H_
|
||||
#endif // mozilla_image_src_ClippedImage_h
|
||||
|
|
Загрузка…
Ссылка в новой задаче