Skip to content

Commit

Permalink
Backed out changeset 0b797601dc36 (bug 1343499) for build bustages. r…
Browse files Browse the repository at this point in the history
…=backout
  • Loading branch information
aosmond committed Mar 22, 2017
1 parent 6a03d19 commit c647464
Show file tree
Hide file tree
Showing 24 changed files with 119 additions and 530 deletions.
6 changes: 0 additions & 6 deletions image/DynamicImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,6 @@ DynamicImage::GetHeight(int32_t* aHeight)
return NS_OK;
}

nsresult
DynamicImage::GetNativeSizes(nsTArray<IntSize>& aNativeSizes) const
{
return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
DynamicImage::GetIntrinsicSize(nsSize* aSize)
{
Expand Down
1 change: 0 additions & 1 deletion image/DynamicImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class DynamicImage : public Image
}

// Inherited methods from Image.
nsresult GetNativeSizes(nsTArray<gfx::IntSize>& aNativeSizes) const override;
virtual already_AddRefed<ProgressTracker> GetProgressTracker() override;
virtual size_t SizeOfSourceWithComputedFallback(
MallocSizeOf aMallocSizeOf) const override;
Expand Down
119 changes: 0 additions & 119 deletions image/FrameTimeout.h

This file was deleted.

13 changes: 2 additions & 11 deletions image/ImageMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
#include "mozilla/Maybe.h"
#include "nsSize.h"
#include "Orientation.h"
#include "FrameTimeout.h"

namespace mozilla {
namespace image {

class RasterImage;

// The metadata about an image that decoders accumulate as they decode.
class ImageMetadata
{
Expand Down Expand Up @@ -63,13 +64,6 @@ class ImageMetadata
nsIntSize GetSize() const { return *mSize; }
bool HasSize() const { return mSize.isSome(); }

void AddNativeSize(const nsIntSize& aSize)
{
mNativeSizes.AppendElement(aSize);
}

const nsTArray<nsIntSize>& GetNativeSizes() const { return mNativeSizes; }

Orientation GetOrientation() const { return *mOrientation; }
bool HasOrientation() const { return mOrientation.isSome(); }

Expand All @@ -96,9 +90,6 @@ class ImageMetadata
Maybe<nsIntSize> mSize;
Maybe<Orientation> mOrientation;

// Sizes the image can natively decode to.
nsTArray<nsIntSize> mNativeSizes;

bool mHasAnimation : 1;
};

Expand Down
110 changes: 7 additions & 103 deletions image/ImageOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "FrozenImage.h"
#include "IDecodingTask.h"
#include "Image.h"
#include "ImageMetadata.h"
#include "imgIContainer.h"
#include "mozilla/gfx/2D.h"
#include "nsStreamUtils.h"
Expand Down Expand Up @@ -80,27 +79,10 @@ ImageOps::CreateFromDrawable(gfxDrawable* aDrawable)
return drawableImage.forget();
}

class ImageOps::ImageBufferImpl final : public ImageOps::ImageBuffer {
public:
ImageBufferImpl(already_AddRefed<SourceBuffer> aSourceBuffer)
: mSourceBuffer(aSourceBuffer)
{ }

protected:
~ImageBufferImpl() override { }

virtual already_AddRefed<SourceBuffer> GetSourceBuffer()
{
RefPtr<SourceBuffer> sourceBuffer = mSourceBuffer;
return sourceBuffer.forget();
}

private:
RefPtr<SourceBuffer> mSourceBuffer;
};

/* static */ already_AddRefed<ImageOps::ImageBuffer>
ImageOps::CreateImageBuffer(nsIInputStream* aInputStream)
/* static */ already_AddRefed<gfx::SourceSurface>
ImageOps::DecodeToSurface(nsIInputStream* aInputStream,
const nsACString& aMimeType,
uint32_t aFlags)
{
MOZ_ASSERT(aInputStream);

Expand All @@ -125,7 +107,7 @@ ImageOps::CreateImageBuffer(nsIInputStream* aInputStream)
}

// Write the data into a SourceBuffer.
RefPtr<SourceBuffer> sourceBuffer = new SourceBuffer();
NotNull<RefPtr<SourceBuffer>> sourceBuffer = WrapNotNull(new SourceBuffer());
sourceBuffer->ExpectLength(length);
rv = sourceBuffer->AppendFromInputStream(inputStream, length);
if (NS_FAILED(rv)) {
Expand All @@ -140,90 +122,12 @@ ImageOps::CreateImageBuffer(nsIInputStream* aInputStream)
}
sourceBuffer->Complete(NS_OK);

RefPtr<ImageBuffer> imageBuffer = new ImageBufferImpl(sourceBuffer.forget());
return imageBuffer.forget();
}

/* static */ nsresult
ImageOps::DecodeMetadata(nsIInputStream* aInputStream,
const nsACString& aMimeType,
ImageMetadata& aMetadata)
{
RefPtr<ImageBuffer> buffer = CreateImageBuffer(aInputStream);
return DecodeMetadata(buffer, aMimeType, aMetadata);
}

/* static */ nsresult
ImageOps::DecodeMetadata(ImageBuffer* aBuffer,
const nsACString& aMimeType,
ImageMetadata& aMetadata)
{
if (!aBuffer) {
return NS_ERROR_FAILURE;
}

RefPtr<SourceBuffer> sourceBuffer = aBuffer->GetSourceBuffer();
if (NS_WARN_IF(!sourceBuffer)) {
return NS_ERROR_FAILURE;
}

// Create a decoder.
DecoderType decoderType =
DecoderFactory::GetDecoderType(PromiseFlatCString(aMimeType).get());
RefPtr<Decoder> decoder =
DecoderFactory::CreateAnonymousMetadataDecoder(decoderType,
WrapNotNull(sourceBuffer));
if (!decoder) {
return NS_ERROR_FAILURE;
}

// Run the decoder synchronously.
RefPtr<IDecodingTask> task = new AnonymousDecodingTask(WrapNotNull(decoder));
task->Run();
if (!decoder->GetDecodeDone() || decoder->HasError()) {
return NS_ERROR_FAILURE;
}

aMetadata = decoder->GetImageMetadata();
if (aMetadata.GetNativeSizes().IsEmpty() && aMetadata.HasSize()) {
aMetadata.AddNativeSize(aMetadata.GetSize());
}

return NS_OK;
}

/* static */ already_AddRefed<gfx::SourceSurface>
ImageOps::DecodeToSurface(nsIInputStream* aInputStream,
const nsACString& aMimeType,
uint32_t aFlags,
Maybe<IntSize> aSize /* = Nothing() */)
{
RefPtr<ImageBuffer> buffer = CreateImageBuffer(aInputStream);
return DecodeToSurface(buffer, aMimeType, aFlags, aSize);
}

/* static */ already_AddRefed<gfx::SourceSurface>
ImageOps::DecodeToSurface(ImageBuffer* aBuffer,
const nsACString& aMimeType,
uint32_t aFlags,
Maybe<IntSize> aSize /* = Nothing() */)
{
if (!aBuffer) {
return nullptr;
}

RefPtr<SourceBuffer> sourceBuffer = aBuffer->GetSourceBuffer();
if (NS_WARN_IF(!sourceBuffer)) {
return nullptr;
}

// Create a decoder.
DecoderType decoderType =
DecoderFactory::GetDecoderType(PromiseFlatCString(aMimeType).get());
RefPtr<Decoder> decoder =
DecoderFactory::CreateAnonymousDecoder(decoderType,
WrapNotNull(sourceBuffer),
aSize, ToSurfaceFlags(aFlags));
DecoderFactory::CreateAnonymousDecoder(decoderType, sourceBuffer,
Nothing(), ToSurfaceFlags(aFlags));
if (!decoder) {
return nullptr;
}
Expand Down
Loading

0 comments on commit c647464

Please sign in to comment.