Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 11:12:37 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* 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/. */
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
|
|
|
|
#ifndef imgFrame_h
|
|
|
|
#define imgFrame_h
|
|
|
|
|
|
|
|
#include "nsRect.h"
|
|
|
|
#include "nsPoint.h"
|
|
|
|
#include "nsSize.h"
|
|
|
|
#include "gfxTypes.h"
|
|
|
|
#include "nsID.h"
|
|
|
|
#include "gfxContext.h"
|
|
|
|
#include "gfxPattern.h"
|
2010-08-13 13:30:27 +00:00
|
|
|
#include "gfxDrawable.h"
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
#include "gfxImageSurface.h"
|
|
|
|
#if defined(XP_WIN)
|
|
|
|
#include "gfxWindowsSurface.h"
|
|
|
|
#elif defined(XP_MACOSX)
|
|
|
|
#include "gfxQuartzImageSurface.h"
|
|
|
|
#endif
|
|
|
|
#include "nsAutoPtr.h"
|
2012-04-17 22:04:15 +00:00
|
|
|
#include "imgIContainer.h"
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
|
|
|
|
class imgFrame
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
imgFrame();
|
|
|
|
~imgFrame();
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult Init(int32_t aX, int32_t aY, int32_t aWidth, int32_t aHeight, gfxASurface::gfxImageFormat aFormat, uint8_t aPaletteDepth = 0);
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
nsresult Optimize();
|
|
|
|
|
|
|
|
void Draw(gfxContext *aContext, gfxPattern::GraphicsFilter aFilter,
|
|
|
|
const gfxMatrix &aUserSpaceToImageSpace, const gfxRect& aFill,
|
2012-04-17 22:04:15 +00:00
|
|
|
const nsIntMargin &aPadding, const nsIntRect &aSubimage,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aImageFlags = imgIContainer::FLAG_NONE);
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
|
|
|
|
nsresult Extract(const nsIntRect& aRegion, imgFrame** aResult);
|
|
|
|
|
|
|
|
nsresult ImageUpdated(const nsIntRect &aUpdateRect);
|
|
|
|
|
|
|
|
nsIntRect GetRect() const;
|
|
|
|
gfxASurface::gfxImageFormat GetFormat() const;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool GetNeedsBackground() const;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t GetImageBytesPerRow() const;
|
|
|
|
uint32_t GetImageDataLength() const;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool GetIsPaletted() const;
|
|
|
|
bool GetHasAlpha() const;
|
2012-08-22 15:56:38 +00:00
|
|
|
void GetImageData(uint8_t **aData, uint32_t *length) const;
|
|
|
|
void GetPaletteData(uint32_t **aPalette, uint32_t *length) const;
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t GetTimeout() const;
|
|
|
|
void SetTimeout(int32_t aTimeout);
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t GetFrameDisposalMethod() const;
|
|
|
|
void SetFrameDisposalMethod(int32_t aFrameDisposalMethod);
|
|
|
|
int32_t GetBlendMethod() const;
|
|
|
|
void SetBlendMethod(int32_t aBlendMethod);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool ImageComplete() const;
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
|
|
|
|
void SetHasNoAlpha();
|
2012-03-23 22:10:50 +00:00
|
|
|
void SetAsNonPremult(bool aIsNonPremult);
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool GetCompositingFailed() const;
|
|
|
|
void SetCompositingFailed(bool val);
|
2009-11-12 23:18:40 +00:00
|
|
|
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
nsresult LockImageData();
|
|
|
|
nsresult UnlockImageData();
|
|
|
|
|
|
|
|
nsresult GetSurface(gfxASurface **aSurface) const
|
|
|
|
{
|
|
|
|
*aSurface = ThebesSurface();
|
|
|
|
NS_IF_ADDREF(*aSurface);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult GetPattern(gfxPattern **aPattern) const
|
|
|
|
{
|
|
|
|
if (mSinglePixel)
|
|
|
|
*aPattern = new gfxPattern(mSinglePixelColor);
|
|
|
|
else
|
|
|
|
*aPattern = new gfxPattern(ThebesSurface());
|
|
|
|
NS_ADDREF(*aPattern);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfxASurface* ThebesSurface() const
|
|
|
|
{
|
|
|
|
if (mOptSurface)
|
|
|
|
return mOptSurface;
|
2011-05-05 21:14:27 +00:00
|
|
|
#if defined(XP_WIN)
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
if (mWinSurface)
|
|
|
|
return mWinSurface;
|
|
|
|
#elif defined(XP_MACOSX)
|
|
|
|
if (mQuartzSurface)
|
|
|
|
return mQuartzSurface;
|
|
|
|
#endif
|
|
|
|
return mImageSurface;
|
|
|
|
}
|
|
|
|
|
2012-02-20 03:51:48 +00:00
|
|
|
size_t SizeOfExcludingThisWithComputedFallbackIfHeap(
|
|
|
|
gfxASurface::MemoryLocation aLocation,
|
|
|
|
nsMallocSizeOfFun aMallocSizeOf) const;
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t GetPaletteDepth() const { return mPaletteDepth; }
|
2011-07-14 18:47:43 +00:00
|
|
|
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
private: // methods
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t PaletteDataLength() const {
|
|
|
|
return ((1 << mPaletteDepth) * sizeof(uint32_t));
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2010-08-13 13:30:02 +00:00
|
|
|
struct SurfaceWithFormat {
|
2010-08-13 13:30:27 +00:00
|
|
|
nsRefPtr<gfxDrawable> mDrawable;
|
2010-08-13 13:30:02 +00:00
|
|
|
gfxImageSurface::gfxImageFormat mFormat;
|
|
|
|
SurfaceWithFormat() {}
|
2010-08-13 13:30:27 +00:00
|
|
|
SurfaceWithFormat(gfxDrawable* aDrawable, gfxImageSurface::gfxImageFormat aFormat)
|
|
|
|
: mDrawable(aDrawable), mFormat(aFormat) {}
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsValid() { return !!mDrawable; }
|
2010-08-13 13:30:02 +00:00
|
|
|
};
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
SurfaceWithFormat SurfaceForDrawing(bool aDoPadding,
|
|
|
|
bool aDoPartialDecode,
|
|
|
|
bool aDoTile,
|
2010-08-13 13:30:02 +00:00
|
|
|
const nsIntMargin& aPadding,
|
|
|
|
gfxMatrix& aUserSpaceToImageSpace,
|
|
|
|
gfxRect& aFill,
|
|
|
|
gfxRect& aSubimage,
|
|
|
|
gfxRect& aSourceRect,
|
|
|
|
gfxRect& aImageRect);
|
2010-03-12 10:08:25 +00:00
|
|
|
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
private: // data
|
|
|
|
nsRefPtr<gfxImageSurface> mImageSurface;
|
|
|
|
nsRefPtr<gfxASurface> mOptSurface;
|
2011-05-05 21:14:27 +00:00
|
|
|
#if defined(XP_WIN)
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
nsRefPtr<gfxWindowsSurface> mWinSurface;
|
|
|
|
#elif defined(XP_MACOSX)
|
|
|
|
nsRefPtr<gfxQuartzImageSurface> mQuartzSurface;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsIntSize mSize;
|
|
|
|
nsIntPoint mOffset;
|
|
|
|
|
|
|
|
nsIntRect mDecoded;
|
|
|
|
|
|
|
|
// The palette and image data for images that are paletted, since Cairo
|
|
|
|
// doesn't support these images.
|
|
|
|
// The paletted data comes first, then the image data itself.
|
|
|
|
// Total length is PaletteDataLength() + GetImageDataLength().
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t* mPalettedImageData;
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
|
2012-03-23 22:10:50 +00:00
|
|
|
// Note that the data stored in gfxRGBA is *non-alpha-premultiplied*.
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
gfxRGBA mSinglePixelColor;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mTimeout; // -1 means display forever
|
|
|
|
int32_t mDisposalMethod;
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
|
|
|
|
gfxASurface::gfxImageFormat mFormat;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t mPaletteDepth;
|
|
|
|
int8_t mBlendMethod;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mSinglePixel;
|
|
|
|
bool mNeverUseDeviceSurface;
|
|
|
|
bool mFormatChanged;
|
|
|
|
bool mCompositingFailed;
|
2012-03-23 22:10:50 +00:00
|
|
|
bool mNonPremult;
|
2012-09-28 22:00:28 +00:00
|
|
|
/** Indicates if the image data is currently locked */
|
|
|
|
bool mLocked;
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
|
2012-03-15 20:30:41 +00:00
|
|
|
/** Have we called DiscardTracker::InformAllocation()? */
|
|
|
|
bool mInformedDiscardTracker;
|
|
|
|
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
#ifdef XP_WIN
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mIsDDBSurface;
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* imgFrame_h */
|