mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1102048 (Part 30, imgTools) - Make image/src files comply with the Mozilla Coding Style Guide. r=seth
This commit is contained in:
parent
abf7e02404
commit
3eda954ef7
@ -45,9 +45,10 @@ imgTools::~imgTools()
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP imgTools::DecodeImageData(nsIInputStream* aInStr,
|
||||
NS_IMETHODIMP
|
||||
imgTools::DecodeImageData(nsIInputStream* aInStr,
|
||||
const nsACString& aMimeType,
|
||||
imgIContainer **aContainer)
|
||||
imgIContainer** aContainer)
|
||||
{
|
||||
MOZ_ASSERT(*aContainer == nullptr,
|
||||
"Cannot provide an existing image container to DecodeImageData");
|
||||
@ -55,9 +56,10 @@ NS_IMETHODIMP imgTools::DecodeImageData(nsIInputStream* aInStr,
|
||||
return DecodeImage(aInStr, aMimeType, aContainer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP imgTools::DecodeImage(nsIInputStream* aInStr,
|
||||
NS_IMETHODIMP
|
||||
imgTools::DecodeImage(nsIInputStream* aInStr,
|
||||
const nsACString& aMimeType,
|
||||
imgIContainer **aContainer)
|
||||
imgIContainer** aContainer)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@ -68,17 +70,19 @@ NS_IMETHODIMP imgTools::DecodeImage(nsIInputStream* aInStr,
|
||||
nsRefPtr<image::Image> image = ImageFactory::CreateAnonymousImage(mimeType);
|
||||
nsRefPtr<ProgressTracker> tracker = image->GetProgressTracker();
|
||||
|
||||
if (image->HasError())
|
||||
if (image->HasError()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Prepare the input stream.
|
||||
nsCOMPtr<nsIInputStream> inStream = aInStr;
|
||||
if (!NS_InputStreamIsBuffered(aInStr)) {
|
||||
nsCOMPtr<nsIInputStream> bufStream;
|
||||
rv = NS_NewBufferedInputStream(getter_AddRefs(bufStream), aInStr, 1024);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
inStream = bufStream;
|
||||
}
|
||||
}
|
||||
|
||||
// Figure out how much data we've been passed.
|
||||
uint64_t length;
|
||||
@ -87,7 +91,8 @@ NS_IMETHODIMP imgTools::DecodeImage(nsIInputStream* aInStr,
|
||||
NS_ENSURE_TRUE(length <= UINT32_MAX, NS_ERROR_FILE_TOO_BIG);
|
||||
|
||||
// Send the source data to the Image.
|
||||
rv = image->OnImageDataAvailable(nullptr, nullptr, inStream, 0, uint32_t(length));
|
||||
rv = image->OnImageDataAvailable(nullptr, nullptr, inStream, 0,
|
||||
uint32_t(length));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Let the Image know we've sent all the data.
|
||||
@ -106,10 +111,11 @@ NS_IMETHODIMP imgTools::DecodeImage(nsIInputStream* aInStr,
|
||||
* GetDataSurface on such surfaces since that may incure a conversion to
|
||||
* SurfaceType::DATA which we don't need.
|
||||
*/
|
||||
static nsresult EncodeImageData(DataSourceSurface* aDataSurface,
|
||||
static nsresult
|
||||
EncodeImageData(DataSourceSurface* aDataSurface,
|
||||
const nsACString& aMimeType,
|
||||
const nsAString& aOutputOptions,
|
||||
nsIInputStream **aStream)
|
||||
nsIInputStream** aStream)
|
||||
{
|
||||
MOZ_ASSERT(aDataSurface->GetFormat() == SurfaceFormat::B8G8R8A8,
|
||||
"We're assuming B8G8R8A8");
|
||||
@ -119,8 +125,9 @@ static nsresult EncodeImageData(DataSourceSurface* aDataSurface,
|
||||
NS_LITERAL_CSTRING("@mozilla.org/image/encoder;2?type=") + aMimeType);
|
||||
|
||||
nsCOMPtr<imgIEncoder> encoder = do_CreateInstance(encoderCID.get());
|
||||
if (!encoder)
|
||||
if (!encoder) {
|
||||
return NS_IMAGELIB_ERROR_NO_ENCODER;
|
||||
}
|
||||
|
||||
DataSourceSurface::MappedSurface map;
|
||||
if (!aDataSurface->Map(DataSourceSurface::MapType::READ, &map)) {
|
||||
@ -145,10 +152,11 @@ static nsresult EncodeImageData(DataSourceSurface* aDataSurface,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP imgTools::EncodeImage(imgIContainer *aContainer,
|
||||
NS_IMETHODIMP
|
||||
imgTools::EncodeImage(imgIContainer* aContainer,
|
||||
const nsACString& aMimeType,
|
||||
const nsAString& aOutputOptions,
|
||||
nsIInputStream **aStream)
|
||||
nsIInputStream** aStream)
|
||||
{
|
||||
// Use frame 0 from the image container.
|
||||
RefPtr<SourceSurface> frame =
|
||||
@ -172,12 +180,13 @@ NS_IMETHODIMP imgTools::EncodeImage(imgIContainer *aContainer,
|
||||
return EncodeImageData(dataSurface, aMimeType, aOutputOptions, aStream);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP imgTools::EncodeScaledImage(imgIContainer *aContainer,
|
||||
NS_IMETHODIMP
|
||||
imgTools::EncodeScaledImage(imgIContainer* aContainer,
|
||||
const nsACString& aMimeType,
|
||||
int32_t aScaledWidth,
|
||||
int32_t aScaledHeight,
|
||||
const nsAString& aOutputOptions,
|
||||
nsIInputStream **aStream)
|
||||
nsIInputStream** aStream)
|
||||
{
|
||||
NS_ENSURE_ARG(aScaledWidth >= 0 && aScaledHeight >= 0);
|
||||
|
||||
@ -238,14 +247,15 @@ NS_IMETHODIMP imgTools::EncodeScaledImage(imgIContainer *aContainer,
|
||||
return EncodeImageData(dataSurface, aMimeType, aOutputOptions, aStream);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP imgTools::EncodeCroppedImage(imgIContainer *aContainer,
|
||||
NS_IMETHODIMP
|
||||
imgTools::EncodeCroppedImage(imgIContainer* aContainer,
|
||||
const nsACString& aMimeType,
|
||||
int32_t aOffsetX,
|
||||
int32_t aOffsetY,
|
||||
int32_t aWidth,
|
||||
int32_t aHeight,
|
||||
const nsAString& aOutputOptions,
|
||||
nsIInputStream **aStream)
|
||||
nsIInputStream** aStream)
|
||||
{
|
||||
NS_ENSURE_ARG(aOffsetX >= 0 && aOffsetY >= 0 && aWidth >= 0 && aHeight >= 0);
|
||||
|
||||
@ -300,7 +310,8 @@ NS_IMETHODIMP imgTools::EncodeCroppedImage(imgIContainer *aContainer,
|
||||
map.mStride,
|
||||
SurfaceFormat::B8G8R8A8);
|
||||
if (!dt) {
|
||||
gfxWarning() << "imgTools::EncodeCroppedImage failed in CreateDrawTargetForData";
|
||||
gfxWarning() <<
|
||||
"imgTools::EncodeCroppedImage failed in CreateDrawTargetForData";
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
dt->CopySurface(frame,
|
||||
@ -312,7 +323,8 @@ NS_IMETHODIMP imgTools::EncodeCroppedImage(imgIContainer *aContainer,
|
||||
return EncodeImageData(dataSurface, aMimeType, aOutputOptions, aStream);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP imgTools::CreateScriptedObserver(imgIScriptedNotificationObserver* aInner,
|
||||
NS_IMETHODIMP
|
||||
imgTools::CreateScriptedObserver(imgIScriptedNotificationObserver* aInner,
|
||||
imgINotificationObserver** aObserver)
|
||||
{
|
||||
NS_ADDREF(*aObserver = new ScriptedNotificationObserver(aInner));
|
||||
|
@ -4,6 +4,9 @@
|
||||
* 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_image_src_imgITools_h
|
||||
#define mozilla_image_src_imgITools_h
|
||||
|
||||
#include "imgITools.h"
|
||||
|
||||
#define NS_IMGTOOLS_CID \
|
||||
@ -25,3 +28,4 @@ public:
|
||||
private:
|
||||
virtual ~imgTools();
|
||||
};
|
||||
#endif // mozilla_image_src_imgITools_h
|
||||
|
Loading…
Reference in New Issue
Block a user