Skip to content

Commit

Permalink
Bug 1683557 - Make image buildable outside of unified-build envir…
Browse files Browse the repository at this point in the history
…onment. r=aosmond

Differential Revision: https://phabricator.services.mozilla.com/D100211
  • Loading branch information
abpostelnicu committed Jan 4, 2021
1 parent d5cca8c commit 0fd4f87
Show file tree
Hide file tree
Showing 22 changed files with 105 additions and 66 deletions.
1 change: 1 addition & 0 deletions build/non-unified-compat
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,4 @@ gfx/wgpu_bindings/
gfx/wr/
gfx/ycbcr/
hal/
image/
1 change: 1 addition & 0 deletions image/Decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "GeckoProfiler.h"
#include "IDecodingTask.h"
#include "ISurfaceProvider.h"
#include "gfxPlatform.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/Point.h"
#include "mozilla/Telemetry.h"
Expand Down
1 change: 1 addition & 0 deletions image/FrameAnimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "FrameAnimator.h"
#include "GeckoProfiler.h"

#include <utility>

Expand Down
37 changes: 20 additions & 17 deletions image/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "nsIObserverService.h"
#include "nsRefreshDriver.h"
#include "nsContentUtils.h"
#include "mozilla/gfx/Point.h"
#include "mozilla/gfx/Rect.h"
#include "mozilla/Services.h"
#include "mozilla/SizeOfState.h"
#include "mozilla/TimeStamp.h"
Expand Down Expand Up @@ -106,9 +108,9 @@ bool ImageResource::GetSpecTruncatedTo1k(nsCString& aSpec) const {
return false;
}

void ImageResource::SetCurrentImage(ImageContainer* aContainer,
SourceSurface* aSurface,
const Maybe<IntRect>& aDirtyRect) {
void ImageResource::SetCurrentImage(layers::ImageContainer* aContainer,
gfx::SourceSurface* aSurface,
const Maybe<gfx::IntRect>& aDirtyRect) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aContainer);

Expand All @@ -128,8 +130,8 @@ void ImageResource::SetCurrentImage(ImageContainer* aContainer,
// so that another object cannot add its own. Similarly the frame ID is
// only used internally to ensure it is always increasing, and skipping
// IDs from an individual container's perspective is acceptable.
AutoTArray<ImageContainer::NonOwningImage, 1> imageList;
imageList.AppendElement(ImageContainer::NonOwningImage(
AutoTArray<layers::ImageContainer::NonOwningImage, 1> imageList;
imageList.AppendElement(layers::ImageContainer::NonOwningImage(
image, TimeStamp(), mLastFrameID++, mImageProducerID));

if (aDirtyRect) {
Expand All @@ -146,17 +148,17 @@ void ImageResource::SetCurrentImage(ImageContainer* aContainer,
layers::SharedSurfacesChild::UpdateAnimation(aContainer, aSurface,
aDirtyRect.ref());
} else {
IntRect dirtyRect(IntPoint(0, 0), aSurface->GetSize());
gfx::IntRect dirtyRect(gfx::IntPoint(0, 0), aSurface->GetSize());
layers::SharedSurfacesChild::UpdateAnimation(aContainer, aSurface,
dirtyRect);
}
}
}

ImgDrawResult ImageResource::GetImageContainerImpl(
LayerManager* aManager, const IntSize& aSize,
layers::LayerManager* aManager, const gfx::IntSize& aSize,
const Maybe<SVGImageContext>& aSVGContext, uint32_t aFlags,
ImageContainer** aOutContainer) {
layers::ImageContainer** aOutContainer) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aManager);
MOZ_ASSERT(
Expand All @@ -165,7 +167,7 @@ ImgDrawResult ImageResource::GetImageContainerImpl(
"Unsupported flag passed to GetImageContainer");

ImgDrawResult drawResult;
IntSize size;
gfx::IntSize size;
Tie(drawResult, size) = GetImageContainerSize(aManager, aSize, aFlags);
if (drawResult != ImgDrawResult::SUCCESS) {
return drawResult;
Expand Down Expand Up @@ -221,8 +223,8 @@ ImgDrawResult ImageResource::GetImageContainerImpl(
NotifyDrawingObservers();
#endif

IntSize bestSize;
RefPtr<SourceSurface> surface;
gfx::IntSize bestSize;
RefPtr<gfx::SourceSurface> surface;
Tie(drawResult, bestSize, surface) = GetFrameInternal(
size, aSVGContext, FRAME_CURRENT, aFlags | FLAG_ASYNC_NOTIFY);

Expand Down Expand Up @@ -282,7 +284,7 @@ ImgDrawResult ImageResource::GetImageContainerImpl(

if (!container) {
// We need a new ImageContainer, so create one.
container = LayerManager::CreateImageContainer();
container = layers::LayerManager::CreateImageContainer();

if (i >= 0) {
entry->mContainer = container;
Expand All @@ -298,15 +300,16 @@ ImgDrawResult ImageResource::GetImageContainerImpl(
return drawResult;
}

bool ImageResource::UpdateImageContainer(const Maybe<IntRect>& aDirtyRect) {
bool ImageResource::UpdateImageContainer(
const Maybe<gfx::IntRect>& aDirtyRect) {
MOZ_ASSERT(NS_IsMainThread());

for (int i = mImageContainers.Length() - 1; i >= 0; --i) {
ImageContainerEntry& entry = mImageContainers[i];
RefPtr<layers::ImageContainer> container(entry.mContainer);
if (container) {
IntSize bestSize;
RefPtr<SourceSurface> surface;
gfx::IntSize bestSize;
RefPtr<gfx::SourceSurface> surface;
Tie(entry.mLastDrawResult, bestSize, surface) = GetFrameInternal(
entry.mSize, entry.mSVGContext, FRAME_CURRENT, entry.mFlags);

Expand All @@ -317,7 +320,7 @@ bool ImageResource::UpdateImageContainer(const Maybe<IntRect>& aDirtyRect) {
if (aDirtyRect) {
SetCurrentImage(container, surface, aDirtyRect);
} else {
IntRect dirtyRect(IntPoint(0, 0), bestSize);
gfx::IntRect dirtyRect(gfx::IntPoint(0, 0), bestSize);
SetCurrentImage(container, surface, Some(dirtyRect));
}
} else {
Expand All @@ -343,7 +346,7 @@ ImageResource::ImageResource(nsIURI* aURI)
mInitialized(false),
mAnimating(false),
mError(false),
mImageProducerID(ImageContainer::AllocateProducerID()),
mImageProducerID(layers::ImageContainer::AllocateProducerID()),
mLastFrameID(0) {}

ImageResource::~ImageResource() {
Expand Down
2 changes: 2 additions & 0 deletions image/ImageFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

#include "mozilla/Likely.h"

#include "nsIChannel.h"
#include "nsIFileChannel.h"
#include "nsIObserverService.h"
#include "nsIFile.h"
#include "nsMimeTypes.h"
#include "nsIRequest.h"
Expand Down
4 changes: 4 additions & 0 deletions image/ImageRegion.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
#define mozilla_image_ImageRegion_h

#include "gfxMatrix.h"
#include "gfxPoint.h"
#include "gfxRect.h"
#include "gfxTypes.h"
#include "mozilla/gfx/Matrix.h"
#include "mozilla/gfx/Types.h"
#include "nsSize.h"

namespace mozilla {
namespace image {
Expand Down
1 change: 1 addition & 0 deletions image/SVGDocumentWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "mozilla/PresShell.h"
#include "mozilla/SMILAnimationController.h"
#include "mozilla/SVGObserverUtils.h"
#include "mozilla/dom/Animation.h"
#include "mozilla/dom/Document.h"
#include "mozilla/dom/DocumentTimeline.h"
#include "mozilla/dom/Element.h"
Expand Down
1 change: 1 addition & 0 deletions image/SurfaceCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "nsRefPtrHashtable.h"
#include "nsSize.h"
#include "nsTArray.h"
#include "Orientation.h"
#include "prsystem.h"

using std::max;
Expand Down
2 changes: 2 additions & 0 deletions image/VectorImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "VectorImage.h"

#include "GeckoProfiler.h"
#include "gfx2DGlue.h"
#include "gfxContext.h"
#include "gfxDrawable.h"
Expand All @@ -19,6 +20,7 @@
#include "mozilla/dom/SVGDocument.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/gfxVars.h"
#include "mozilla/layers/LayerManager.h"
#include "mozilla/PendingAnimationTracker.h"
#include "mozilla/PresShell.h"
#include "mozilla/RefPtr.h"
Expand Down
18 changes: 10 additions & 8 deletions image/VectorImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "Image.h"
#include "nsIStreamListener.h"
#include "mozilla/gfx/Point.h"
#include "mozilla/MemoryReporting.h"

class nsIRequest;
Expand Down Expand Up @@ -79,21 +80,22 @@ class VectorImage final : public ImageResource, public nsIStreamListener {
virtual bool ShouldAnimate() override;

private:
Tuple<ImgDrawResult, IntSize, RefPtr<SourceSurface>> GetFrameInternal(
const IntSize& aSize, const Maybe<SVGImageContext>& aSVGContext,
uint32_t aWhichFrame, uint32_t aFlags) override;
Tuple<ImgDrawResult, gfx::IntSize, RefPtr<gfx::SourceSurface>>
GetFrameInternal(const gfx::IntSize& aSize,
const Maybe<SVGImageContext>& aSVGContext,
uint32_t aWhichFrame, uint32_t aFlags) override;

Tuple<ImgDrawResult, IntSize> GetImageContainerSize(
layers::LayerManager* aManager, const IntSize& aSize,
Tuple<ImgDrawResult, gfx::IntSize> GetImageContainerSize(
layers::LayerManager* aManager, const gfx::IntSize& aSize,
uint32_t aFlags) override;

/**
* Attempt to find a matching cached surface in the SurfaceCache. Returns the
* cached surface, if found, and the size to rasterize at, if applicable.
* If we cannot rasterize, it will be the requested size to draw at (aSize).
*/
Tuple<RefPtr<SourceSurface>, IntSize> LookupCachedSurface(
const IntSize& aSize, const Maybe<SVGImageContext>& aSVGContext,
Tuple<RefPtr<gfx::SourceSurface>, gfx::IntSize> LookupCachedSurface(
const gfx::IntSize& aSize, const Maybe<SVGImageContext>& aSVGContext,
uint32_t aFlags);

bool MaybeRestrictSVGContext(Maybe<SVGImageContext>& aNewSVGContext,
Expand All @@ -106,7 +108,7 @@ class VectorImage final : public ImageResource, public nsIStreamListener {

/// Rasterize the SVG into a surface. aWillCache will be set to whether or
/// not the new surface was put into the cache.
already_AddRefed<SourceSurface> CreateSurface(
already_AddRefed<gfx::SourceSurface> CreateSurface(
const SVGDrawingParameters& aParams, gfxDrawable* aSVGDrawable,
bool& aWillCache);

Expand Down
1 change: 1 addition & 0 deletions image/decoders/icon/nsIconURI.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "nsString.h"
#include "nsINestedURI.h"
#include "nsIURIMutator.h"
#include "nsISerializable.h"

#define NS_THIS_ICONURI_IMPLEMENTATION_CID \
{ /* 0b9bb0c2-fee6-470b-b9b9-9fd9462b5e19 */ \
Expand Down
2 changes: 1 addition & 1 deletion image/decoders/nsGIFDecoder2.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class nsGIFDecoder2 : public Decoder {

gif_struct mGIFStruct;

SwizzleRowFn mSwizzleFn; /// Method to unpack color tables from RGB.
gfx::SwizzleRowFn mSwizzleFn; /// Method to unpack color tables from RGB.
SurfacePipe mPipe; /// The SurfacePipe used to write to the output surface.
};

Expand Down
1 change: 1 addition & 0 deletions image/decoders/nsIconDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "nsIconDecoder.h"
#include "RasterImage.h"
#include "SurfacePipeFactory.h"
#include "gfxPlatform.h"

using namespace mozilla::gfx;

Expand Down
7 changes: 4 additions & 3 deletions image/decoders/nsJPEGDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -931,9 +931,10 @@ static void cmyk_convert_bgra(uint32_t* aInput, uint32_t* aOutput,
const uint8_t g = iM * iK / 255;
const uint8_t b = iY * iK / 255;

*aOutput++ = (0xFF << SurfaceFormatBit::OS_A) |
(r << SurfaceFormatBit::OS_R) | (g << SurfaceFormatBit::OS_G) |
(b << SurfaceFormatBit::OS_B);
*aOutput++ = (0xFF << mozilla::gfx::SurfaceFormatBit::OS_A) |
(r << mozilla::gfx::SurfaceFormatBit::OS_R) |
(g << mozilla::gfx::SurfaceFormatBit::OS_G) |
(b << mozilla::gfx::SurfaceFormatBit::OS_B);
input += 4;
}
}
2 changes: 2 additions & 0 deletions image/decoders/nsWebPDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "ImageLogging.h" // Must appear first
#include "gfxPlatform.h"
#include "mozilla/TelemetryHistogramEnums.h"
#include "nsWebPDecoder.h"

#include "RasterImage.h"
Expand Down
4 changes: 2 additions & 2 deletions image/decoders/nsWebPDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class nsWebPDecoder final : public Decoder {
void EndFrame();

LexerResult ReadSingle(const uint8_t* aData, size_t aLength,
const IntRect& aFrameRect);
const gfx::IntRect& aFrameRect);

LexerResult ReadMultiple(WebPDemuxer* aDemuxer, bool aIsComplete);

Expand Down Expand Up @@ -75,7 +75,7 @@ class nsWebPDecoder final : public Decoder {
gfx::SurfaceFormat mFormat;

/// Frame rect for the current frame.
IntRect mFrameRect;
gfx::IntRect mFrameRect;

/// The last row of decoded pixels written to mPipe.
int mLastRow;
Expand Down
2 changes: 2 additions & 0 deletions image/imgFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "prenv.h"

#include "gfx2DGlue.h"
#include "gfxContext.h"
#include "gfxPlatform.h"

#include "gfxUtils.h"
Expand All @@ -27,6 +28,7 @@
#include "mozilla/Likely.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/StaticPrefs_browser.h"
#include "mozilla/StaticPrefs_image.h"
#include "nsMargin.h"
#include "nsRefreshDriver.h"
#include "nsThreadUtils.h"
Expand Down
1 change: 1 addition & 0 deletions image/imgRequestProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "ImageTypes.h"
#include "imgINotificationObserver.h"
#include "imgLoader.h"
#include "mozilla/dom/Document.h"
#include "mozilla/Telemetry.h" // for Telemetry
#include "mozilla/dom/DocGroup.h" // for DocGroup
#include "nsCRTGlue.h"
Expand Down
1 change: 1 addition & 0 deletions image/imgTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "js/ArrayBuffer.h"
#include "js/RootingAPI.h" // JS::{Handle,Rooted}
#include "js/Value.h" // JS::Value
#include "Orientation.h"

using namespace mozilla::gfx;

Expand Down
5 changes: 5 additions & 0 deletions image/test/gtest/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,11 @@ ImageTestCase PerfRgbLossyWebPTestCase();
ImageTestCase PerfRgbAlphaLossyWebPTestCase();
ImageTestCase PerfRgbGIFTestCase();

ImageTestCase CorruptAVIFTestCase();
ImageTestCase DownscaledAVIFTestCase();
ImageTestCase LargeAVIFTestCase();
ImageTestCase MultiLayerAVIFTestCase();
ImageTestCase TransparentAVIFTestCase();
} // namespace image
} // namespace mozilla

Expand Down
Loading

0 comments on commit 0fd4f87

Please sign in to comment.