2012-12-18 21:59:30 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2012-05-21 04:12:37 -07:00
|
|
|
* 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-20 18:50:15 -07:00
|
|
|
|
|
|
|
#include "imgFrame.h"
|
2012-03-15 13:30:41 -07:00
|
|
|
#include "DiscardTracker.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-20 18:50:15 -07:00
|
|
|
|
|
|
|
#include "prenv.h"
|
|
|
|
|
2014-02-09 00:04:38 -08:00
|
|
|
#include "gfx2DGlue.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-20 18:50:15 -07:00
|
|
|
#include "gfxPlatform.h"
|
2010-08-13 06:30:02 -07:00
|
|
|
#include "gfxUtils.h"
|
2014-02-24 19:37:51 -08:00
|
|
|
#include "gfxAlphaRecovery.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-20 18:50:15 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool gDisableOptimize = false;
|
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-20 18:50:15 -07:00
|
|
|
|
|
|
|
#include "cairo.h"
|
2013-03-18 07:25:50 -07:00
|
|
|
#include "GeckoProfiler.h"
|
2012-10-26 06:32:10 -07:00
|
|
|
#include "mozilla/Likely.h"
|
2013-06-23 05:03:39 -07:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2013-09-06 19:15:49 -07:00
|
|
|
#include "nsMargin.h"
|
2013-10-02 07:44:53 -07:00
|
|
|
#include "mozilla/CheckedInt.h"
|
2014-04-19 18:28:38 -07:00
|
|
|
#include "mozilla/gfx/Tools.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-20 18:50:15 -07:00
|
|
|
|
2013-07-04 11:45:57 -07:00
|
|
|
using namespace mozilla;
|
2014-02-09 00:04:38 -08:00
|
|
|
using namespace mozilla::gfx;
|
2012-03-15 13:30:41 -07:00
|
|
|
using namespace mozilla::image;
|
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
static UserDataKey kVolatileBuffer;
|
2014-02-24 19:37:51 -08:00
|
|
|
|
|
|
|
static void
|
|
|
|
VolatileBufferRelease(void *vbuf)
|
|
|
|
{
|
|
|
|
delete static_cast<VolatileBufferPtr<unsigned char>*>(vbuf);
|
|
|
|
}
|
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
static TemporaryRef<DataSourceSurface>
|
|
|
|
CreateLockedSurface(VolatileBuffer *vbuf,
|
|
|
|
const IntSize& size,
|
|
|
|
SurfaceFormat format)
|
2014-02-24 19:37:51 -08:00
|
|
|
{
|
|
|
|
VolatileBufferPtr<unsigned char> *vbufptr =
|
|
|
|
new VolatileBufferPtr<unsigned char>(vbuf);
|
|
|
|
MOZ_ASSERT(!vbufptr->WasBufferPurged(), "Expected image data!");
|
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
int32_t stride = size.width * BytesPerPixel(format);
|
|
|
|
RefPtr<DataSourceSurface> surf =
|
|
|
|
Factory::CreateWrappingDataSourceSurface(*vbufptr, stride, size, format);
|
|
|
|
if (!surf) {
|
2014-02-24 19:37:51 -08:00
|
|
|
delete vbufptr;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
surf->AddUserData(&kVolatileBuffer, vbufptr, VolatileBufferRelease);
|
|
|
|
return surf;
|
2014-02-24 19:37:51 -08:00
|
|
|
}
|
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
static TemporaryRef<VolatileBuffer>
|
|
|
|
AllocateBufferForImage(const IntSize& size, SurfaceFormat format)
|
2014-02-24 19:37:51 -08:00
|
|
|
{
|
2014-04-19 18:28:38 -07:00
|
|
|
int32_t stride = size.width * BytesPerPixel(format);
|
2014-02-24 19:37:51 -08:00
|
|
|
RefPtr<VolatileBuffer> buf = new VolatileBuffer();
|
|
|
|
if (buf->Init(stride * size.height,
|
|
|
|
1 << gfxAlphaRecovery::GoodAlignmentLog2()))
|
|
|
|
return buf;
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
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-20 18:50:15 -07:00
|
|
|
// Returns true if an image of aWidth x aHeight is allowed and legal.
|
2012-08-22 08:56:38 -07:00
|
|
|
static bool AllowedImageSize(int32_t aWidth, int32_t aHeight)
|
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-20 18:50:15 -07:00
|
|
|
{
|
|
|
|
// reject over-wide or over-tall images
|
2012-08-22 08:56:38 -07:00
|
|
|
const int32_t k64KLimit = 0x0000FFFF;
|
2012-10-26 06:32:10 -07:00
|
|
|
if (MOZ_UNLIKELY(aWidth > k64KLimit || aHeight > k64KLimit )) {
|
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-20 18:50:15 -07:00
|
|
|
NS_WARNING("image too big");
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
|
2011-07-01 10:03:47 -07:00
|
|
|
// protect against invalid sizes
|
2012-10-26 06:32:10 -07:00
|
|
|
if (MOZ_UNLIKELY(aHeight <= 0 || aWidth <= 0)) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// check to make sure we don't overflow a 32-bit
|
2013-10-02 07:44:53 -07:00
|
|
|
CheckedInt32 requiredBytes = CheckedInt32(aWidth) * CheckedInt32(aHeight) * 4;
|
|
|
|
if (MOZ_UNLIKELY(!requiredBytes.isValid())) {
|
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-20 18:50:15 -07:00
|
|
|
NS_WARNING("width or height too large");
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
// CoreGraphics is limited to images < 32K in *height*, so clamp all surfaces on the Mac to that height
|
2012-10-26 06:32:10 -07:00
|
|
|
if (MOZ_UNLIKELY(aHeight > SHRT_MAX)) {
|
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-20 18:50:15 -07:00
|
|
|
NS_WARNING("image too big");
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
#endif
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
imgFrame::imgFrame() :
|
|
|
|
mDecoded(0, 0, 0, 0),
|
2014-04-19 18:28:38 -07:00
|
|
|
mDecodedMutex("imgFrame::mDecoded"),
|
2012-07-30 07:20:58 -07:00
|
|
|
mPalettedImageData(nullptr),
|
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-20 18:50:15 -07:00
|
|
|
mTimeout(100),
|
|
|
|
mDisposalMethod(0), /* imgIContainer::kDisposeNotSpecified */
|
2012-09-26 08:33:06 -07:00
|
|
|
mLockCount(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-20 18:50:15 -07:00
|
|
|
mBlendMethod(1), /* imgIContainer::kBlendOver */
|
2011-10-17 07:59:28 -07:00
|
|
|
mSinglePixel(false),
|
2012-03-23 15:10:50 -07:00
|
|
|
mCompositingFailed(false),
|
|
|
|
mNonPremult(false),
|
2014-02-24 19:37:51 -08:00
|
|
|
mDiscardable(false),
|
2014-04-19 18:28:38 -07:00
|
|
|
mInformedDiscardTracker(false)
|
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-20 18:50:15 -07:00
|
|
|
{
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool hasCheckedOptimize = false;
|
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-20 18:50:15 -07:00
|
|
|
if (!hasCheckedOptimize) {
|
|
|
|
if (PR_GetEnv("MOZ_DISABLE_IMAGE_OPTIMIZE")) {
|
2011-10-17 07:59:28 -07:00
|
|
|
gDisableOptimize = true;
|
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-20 18:50:15 -07:00
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
hasCheckedOptimize = true;
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
imgFrame::~imgFrame()
|
|
|
|
{
|
2012-10-03 11:10:31 -07:00
|
|
|
moz_free(mPalettedImageData);
|
|
|
|
mPalettedImageData = nullptr;
|
2012-03-15 13:30:41 -07:00
|
|
|
|
|
|
|
if (mInformedDiscardTracker) {
|
2013-12-16 03:31:00 -08:00
|
|
|
DiscardTracker::InformDeallocation(4 * mSize.height * mSize.width);
|
2012-03-15 13:30:41 -07: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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
|
2013-03-29 13:14:19 -07:00
|
|
|
nsresult imgFrame::Init(int32_t aX, int32_t aY, int32_t aWidth, int32_t aHeight,
|
2014-04-19 18:28:38 -07:00
|
|
|
SurfaceFormat 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-20 18:50:15 -07:00
|
|
|
{
|
|
|
|
// assert for properties that should be verified by decoders, warn for properties related to bad content
|
2013-05-22 02:10:38 -07:00
|
|
|
if (!AllowedImageSize(aWidth, aHeight)) {
|
|
|
|
NS_WARNING("Should have legal image size");
|
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-20 18:50:15 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
2013-05-22 02:10:38 -07: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-20 18:50:15 -07:00
|
|
|
|
|
|
|
mOffset.MoveTo(aX, aY);
|
|
|
|
mSize.SizeTo(aWidth, aHeight);
|
|
|
|
|
|
|
|
mFormat = aFormat;
|
|
|
|
mPaletteDepth = aPaletteDepth;
|
|
|
|
|
|
|
|
if (aPaletteDepth != 0) {
|
|
|
|
// We're creating for a paletted image.
|
|
|
|
if (aPaletteDepth > 8) {
|
2013-05-22 02:10:38 -07:00
|
|
|
NS_WARNING("Should have legal palette depth");
|
2010-06-17 13:28:38 -07:00
|
|
|
NS_ERROR("This Depth is not supported");
|
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-20 18:50:15 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2010-08-23 15:42:51 -07:00
|
|
|
// Use the fallible allocator here
|
2012-08-22 08:56:38 -07:00
|
|
|
mPalettedImageData = (uint8_t*)moz_malloc(PaletteDataLength() + GetImageDataLength());
|
2013-05-22 02:10:38 -07:00
|
|
|
if (!mPalettedImageData)
|
|
|
|
NS_WARNING("moz_malloc for paletted image data should succeed");
|
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-20 18:50:15 -07:00
|
|
|
NS_ENSURE_TRUE(mPalettedImageData, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
} else {
|
2013-12-16 03:31:00 -08:00
|
|
|
// Inform the discard tracker that we are going to allocate some memory.
|
|
|
|
if (!DiscardTracker::TryAllocation(4 * mSize.width * mSize.height)) {
|
|
|
|
NS_WARNING("Exceed the hard limit of decode image size");
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2014-02-24 19:37:51 -08:00
|
|
|
if (!mImageSurface) {
|
2014-04-19 18:28:38 -07:00
|
|
|
mVBuf = AllocateBufferForImage(mSize, mFormat);
|
2014-02-24 19:37:51 -08:00
|
|
|
if (!mVBuf) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2014-04-19 18:28:38 -07:00
|
|
|
mImageSurface = CreateLockedSurface(mVBuf, mSize, mFormat);
|
2014-02-24 19:37:51 -08: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-20 18:50:15 -07:00
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
if (!mImageSurface) {
|
|
|
|
NS_WARNING("Failed to create VolatileDataSourceSurface");
|
2013-12-16 03:31:00 -08:00
|
|
|
// Image surface allocation is failed, need to return
|
|
|
|
// the booked buffer size.
|
|
|
|
DiscardTracker::InformDeallocation(4 * mSize.width * mSize.height);
|
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-20 18:50:15 -07:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2013-12-16 03:31:00 -08:00
|
|
|
mInformedDiscardTracker = true;
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult imgFrame::Optimize()
|
|
|
|
{
|
2013-05-24 06:52:34 -07:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
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-20 18:50:15 -07:00
|
|
|
if (gDisableOptimize)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
if (mPalettedImageData || mOptSurface || mSinglePixel)
|
|
|
|
return NS_OK;
|
|
|
|
|
2012-03-23 15:10:50 -07:00
|
|
|
// Don't do single-color opts on non-premult data.
|
|
|
|
// Cairo doesn't support non-premult single-colors.
|
|
|
|
if (mNonPremult)
|
|
|
|
return NS_OK;
|
|
|
|
|
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-20 18:50:15 -07:00
|
|
|
/* Figure out if the entire image is a constant color */
|
|
|
|
|
|
|
|
// this should always be true
|
|
|
|
if (mImageSurface->Stride() == mSize.width * 4) {
|
2014-04-19 18:28:38 -07:00
|
|
|
uint32_t *imgData = (uint32_t*) ((uint8_t *)mVBufPtr);
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t firstPixel = * (uint32_t*) imgData;
|
|
|
|
uint32_t pixelCount = mSize.width * mSize.height + 1;
|
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-20 18:50:15 -07:00
|
|
|
|
|
|
|
while (--pixelCount && *imgData++ == firstPixel)
|
|
|
|
;
|
|
|
|
|
|
|
|
if (pixelCount == 0) {
|
|
|
|
// all pixels were the same
|
2014-04-19 18:28:38 -07:00
|
|
|
if (mFormat == SurfaceFormat::B8G8R8A8 ||
|
|
|
|
mFormat == SurfaceFormat::B8G8R8X8) {
|
2011-10-17 07:59:28 -07:00
|
|
|
mSinglePixel = true;
|
2014-04-19 18:28:38 -07:00
|
|
|
mSinglePixelColor.a = ((firstPixel >> 24) & 0xFF) * (1.0f / 255.0f);
|
|
|
|
mSinglePixelColor.r = ((firstPixel >> 16) & 0xFF) * (1.0f / 255.0f);
|
|
|
|
mSinglePixelColor.g = ((firstPixel >> 8) & 0xFF) * (1.0f / 255.0f);
|
|
|
|
mSinglePixelColor.b = ((firstPixel >> 0) & 0xFF) * (1.0f / 255.0f);
|
|
|
|
mSinglePixelColor.r /= mSinglePixelColor.a;
|
|
|
|
mSinglePixelColor.g /= mSinglePixelColor.a;
|
|
|
|
mSinglePixelColor.b /= mSinglePixelColor.a;
|
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-20 18:50:15 -07:00
|
|
|
|
|
|
|
// blow away the older surfaces (if they exist), to release their memory
|
2014-02-24 19:37:51 -08:00
|
|
|
mVBuf = nullptr;
|
2014-04-19 18:28:38 -07:00
|
|
|
mVBufPtr = nullptr;
|
2012-07-30 07:20:58 -07:00
|
|
|
mImageSurface = nullptr;
|
|
|
|
mOptSurface = nullptr;
|
2012-03-15 13:30:41 -07:00
|
|
|
|
|
|
|
// We just dumped most of our allocated memory, so tell the discard
|
|
|
|
// tracker that we're not using any at all.
|
|
|
|
if (mInformedDiscardTracker) {
|
2013-12-16 03:31:00 -08:00
|
|
|
DiscardTracker::InformDeallocation(4 * mSize.width * mSize.height);
|
2012-03-15 13:30:41 -07:00
|
|
|
mInformedDiscardTracker = false;
|
|
|
|
}
|
|
|
|
|
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-20 18:50:15 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if it's not RGB24/ARGB32, don't optimize, but we never hit this at the moment
|
|
|
|
}
|
|
|
|
|
2014-02-25 02:57:41 -08:00
|
|
|
#ifdef ANDROID
|
2014-04-19 18:28:38 -07:00
|
|
|
SurfaceFormat optFormat =
|
|
|
|
gfxPlatform::GetPlatform()->Optimal2DFormatForContent(gfxContentType::COLOR);
|
2014-02-25 02:57:41 -08:00
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
if (!GetHasAlpha() && optFormat == SurfaceFormat::R5G6B5) {
|
2014-02-25 02:57:41 -08:00
|
|
|
RefPtr<VolatileBuffer> buf =
|
2014-04-19 18:28:38 -07:00
|
|
|
AllocateBufferForImage(mSize, optFormat);
|
2014-02-25 02:57:41 -08:00
|
|
|
if (!buf)
|
|
|
|
return NS_OK;
|
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
RefPtr<DataSourceSurface> surf =
|
|
|
|
CreateLockedSurface(buf, mSize, optFormat);
|
|
|
|
if (!surf)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2014-02-25 02:57:41 -08:00
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
DataSourceSurface::MappedSurface mapping;
|
|
|
|
DebugOnly<bool> success =
|
|
|
|
surf->Map(DataSourceSurface::MapType::WRITE, &mapping);
|
|
|
|
NS_ASSERTION(success, "Failed to map surface");
|
|
|
|
RefPtr<DrawTarget> target =
|
|
|
|
Factory::CreateDrawTargetForData(BackendType::CAIRO,
|
|
|
|
mapping.mData,
|
|
|
|
mSize,
|
|
|
|
mapping.mStride,
|
|
|
|
optFormat);
|
|
|
|
|
|
|
|
Rect rect(0, 0, mSize.width, mSize.height);
|
|
|
|
target->DrawSurface(mImageSurface, rect, rect);
|
|
|
|
target->Flush();
|
|
|
|
surf->Unmap();
|
2014-02-25 02:57:41 -08:00
|
|
|
|
|
|
|
mImageSurface = surf;
|
|
|
|
mVBuf = buf;
|
|
|
|
mFormat = optFormat;
|
|
|
|
}
|
|
|
|
#else
|
2014-04-19 18:28:38 -07:00
|
|
|
mOptSurface = gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget()->OptimizeSourceSurface(mImageSurface);
|
|
|
|
if (mOptSurface == mImageSurface)
|
|
|
|
mOptSurface = nullptr;
|
2014-02-25 02:57:41 -08:00
|
|
|
#endif
|
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-20 18:50:15 -07:00
|
|
|
|
|
|
|
if (mOptSurface) {
|
2014-02-24 19:37:51 -08:00
|
|
|
mVBuf = nullptr;
|
2014-04-19 18:28:38 -07:00
|
|
|
mVBufPtr = nullptr;
|
2012-07-30 07:20:58 -07:00
|
|
|
mImageSurface = nullptr;
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-13 06:30:02 -07:00
|
|
|
imgFrame::SurfaceWithFormat
|
2011-09-28 23:19:26 -07:00
|
|
|
imgFrame::SurfaceForDrawing(bool aDoPadding,
|
|
|
|
bool aDoPartialDecode,
|
|
|
|
bool aDoTile,
|
2010-08-13 06:30:02 -07:00
|
|
|
const nsIntMargin& aPadding,
|
|
|
|
gfxMatrix& aUserSpaceToImageSpace,
|
|
|
|
gfxRect& aFill,
|
|
|
|
gfxRect& aSubimage,
|
|
|
|
gfxRect& aSourceRect,
|
2014-03-02 08:17:26 -08:00
|
|
|
gfxRect& aImageRect,
|
2014-04-19 18:28:38 -07:00
|
|
|
SourceSurface* aSurface)
|
2010-08-13 06:30:02 -07:00
|
|
|
{
|
2014-02-09 00:04:38 -08:00
|
|
|
IntSize size(int32_t(aImageRect.Width()), int32_t(aImageRect.Height()));
|
2010-08-13 06:30:02 -07:00
|
|
|
if (!aDoPadding && !aDoPartialDecode) {
|
|
|
|
NS_ASSERTION(!mSinglePixel, "This should already have been handled");
|
2014-03-02 08:17:26 -08:00
|
|
|
return SurfaceWithFormat(new gfxSurfaceDrawable(aSurface, ThebesIntSize(size)), mFormat);
|
2010-08-13 06:30:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
gfxRect available = gfxRect(mDecoded.x, mDecoded.y, mDecoded.width, mDecoded.height);
|
|
|
|
|
|
|
|
if (aDoTile || mSinglePixel) {
|
|
|
|
// Create a temporary surface.
|
|
|
|
// Give this surface an alpha channel because there are
|
|
|
|
// transparent pixels in the padding or undecoded area
|
2014-04-19 18:28:38 -07:00
|
|
|
RefPtr<DrawTarget> target =
|
|
|
|
gfxPlatform::GetPlatform()->
|
|
|
|
CreateOffscreenContentDrawTarget(size, SurfaceFormat::B8G8R8A8);
|
|
|
|
if (!target)
|
2010-08-13 06:30:02 -07:00
|
|
|
return SurfaceWithFormat();
|
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
Rect fillRect(aFill.x, aFill.y, aFill.width, aFill.height);
|
2010-08-13 06:30:02 -07:00
|
|
|
// Fill 'available' with whatever we've got
|
|
|
|
if (mSinglePixel) {
|
2014-04-19 18:28:38 -07:00
|
|
|
target->FillRect(fillRect, ColorPattern(mSinglePixelColor),
|
|
|
|
DrawOptions(1.0f, CompositionOp::OP_SOURCE));
|
2010-08-13 06:30:02 -07:00
|
|
|
} else {
|
2014-04-19 18:28:38 -07:00
|
|
|
gfxMatrix imageSpaceToUserSpace = aUserSpaceToImageSpace;
|
|
|
|
imageSpaceToUserSpace.Invert();
|
|
|
|
SurfacePattern pattern(aSurface,
|
|
|
|
ExtendMode::REPEAT,
|
|
|
|
Matrix(imageSpaceToUserSpace.xx,
|
|
|
|
imageSpaceToUserSpace.xy,
|
|
|
|
imageSpaceToUserSpace.yx,
|
|
|
|
imageSpaceToUserSpace.yy,
|
|
|
|
imageSpaceToUserSpace.x0,
|
|
|
|
imageSpaceToUserSpace.y0));
|
|
|
|
target->FillRect(fillRect, pattern);
|
2010-08-13 06:30:02 -07:00
|
|
|
}
|
2012-03-23 15:10:50 -07:00
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
RefPtr<SourceSurface> newsurf = target->Snapshot();
|
|
|
|
return SurfaceWithFormat(new gfxSurfaceDrawable(newsurf, ThebesIntSize(size)), target->GetFormat());
|
2010-08-13 06:30:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Not tiling, and we have a surface, so we can account for
|
|
|
|
// padding and/or a partial decode just by twiddling parameters.
|
|
|
|
// First, update our user-space fill rect.
|
|
|
|
aSourceRect = aSourceRect.Intersect(available);
|
|
|
|
gfxMatrix imageSpaceToUserSpace = aUserSpaceToImageSpace;
|
|
|
|
imageSpaceToUserSpace.Invert();
|
|
|
|
aFill = imageSpaceToUserSpace.Transform(aSourceRect);
|
|
|
|
|
|
|
|
aSubimage = aSubimage.Intersect(available) - gfxPoint(aPadding.left, aPadding.top);
|
|
|
|
aUserSpaceToImageSpace.Multiply(gfxMatrix().Translate(-gfxPoint(aPadding.left, aPadding.top)));
|
|
|
|
aSourceRect = aSourceRect - gfxPoint(aPadding.left, aPadding.top);
|
|
|
|
aImageRect = gfxRect(0, 0, mSize.width, mSize.height);
|
|
|
|
|
2010-08-13 06:30:27 -07:00
|
|
|
gfxIntSize availableSize(mDecoded.width, mDecoded.height);
|
2014-03-02 08:17:26 -08:00
|
|
|
return SurfaceWithFormat(new gfxSurfaceDrawable(aSurface, availableSize),
|
2010-08-13 06:30:27 -07:00
|
|
|
mFormat);
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
|
2014-03-02 08:17:26 -08:00
|
|
|
bool imgFrame::Draw(gfxContext *aContext, GraphicsFilter aFilter,
|
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-20 18:50:15 -07:00
|
|
|
const gfxMatrix &aUserSpaceToImageSpace, const gfxRect& aFill,
|
2012-04-17 15:04:15 -07:00
|
|
|
const nsIntMargin &aPadding, const nsIntRect &aSubimage,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aImageFlags)
|
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-20 18:50:15 -07:00
|
|
|
{
|
2014-05-23 14:12:29 -07:00
|
|
|
PROFILER_LABEL("imgFrame", "Draw",
|
|
|
|
js::ProfileEntry::Category::GRAPHICS);
|
|
|
|
|
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-20 18:50:15 -07:00
|
|
|
NS_ASSERTION(!aFill.IsEmpty(), "zero dest size --- fix caller");
|
|
|
|
NS_ASSERTION(!aSubimage.IsEmpty(), "zero source size --- fix caller");
|
|
|
|
NS_ASSERTION(!mPalettedImageData, "Directly drawing a paletted image!");
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool doPadding = aPadding != nsIntMargin(0,0,0,0);
|
|
|
|
bool doPartialDecode = !ImageComplete();
|
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-20 18:50:15 -07:00
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
RefPtr<DrawTarget> dt = aContext->GetDrawTarget();
|
|
|
|
|
2010-08-13 06:30:02 -07:00
|
|
|
if (mSinglePixel && !doPadding && !doPartialDecode) {
|
2014-04-19 18:28:38 -07:00
|
|
|
if (mSinglePixelColor.a == 0.0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Rect target(aFill.x, aFill.y, aFill.width, aFill.height);
|
|
|
|
dt->FillRect(target, ColorPattern(mSinglePixelColor),
|
|
|
|
DrawOptions(1.0f, CompositionOpForOp(aContext->CurrentOperator())));
|
2014-03-02 08:17:26 -08:00
|
|
|
return true;
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
gfxMatrix userSpaceToImageSpace = aUserSpaceToImageSpace;
|
2013-08-25 00:19:43 -07:00
|
|
|
gfxRect sourceRect = userSpaceToImageSpace.TransformBounds(aFill);
|
2010-08-13 06:30:02 -07:00
|
|
|
gfxRect imageRect(0, 0, mSize.width + aPadding.LeftRight(),
|
|
|
|
mSize.height + aPadding.TopBottom());
|
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-20 18:50:15 -07:00
|
|
|
gfxRect subimage(aSubimage.x, aSubimage.y, aSubimage.width, aSubimage.height);
|
|
|
|
gfxRect fill = aFill;
|
|
|
|
|
|
|
|
NS_ASSERTION(!sourceRect.Intersect(subimage).IsEmpty(),
|
|
|
|
"We must be allowed to sample *some* source pixels!");
|
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
RefPtr<SourceSurface> surf = GetSurface();
|
|
|
|
if (!surf) {
|
|
|
|
return false;
|
2014-03-02 08:17:26 -08:00
|
|
|
}
|
|
|
|
|
2012-04-17 15:04:15 -07:00
|
|
|
bool doTile = !imageRect.Contains(sourceRect) &&
|
|
|
|
!(aImageFlags & imgIContainer::FLAG_CLAMP);
|
2010-08-13 06:30:02 -07:00
|
|
|
SurfaceWithFormat surfaceResult =
|
|
|
|
SurfaceForDrawing(doPadding, doPartialDecode, doTile, aPadding,
|
|
|
|
userSpaceToImageSpace, fill, subimage, sourceRect,
|
2014-03-02 08:17:26 -08:00
|
|
|
imageRect, surf);
|
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-20 18:50:15 -07:00
|
|
|
|
2010-08-13 06:30:02 -07:00
|
|
|
if (surfaceResult.IsValid()) {
|
2010-08-13 06:30:27 -07:00
|
|
|
gfxUtils::DrawPixelSnapped(aContext, surfaceResult.mDrawable,
|
2010-08-13 06:30:02 -07:00
|
|
|
userSpaceToImageSpace,
|
|
|
|
subimage, sourceRect, imageRect, fill,
|
2012-04-17 15:04:15 -07:00
|
|
|
surfaceResult.mFormat, aFilter, aImageFlags);
|
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-20 18:50:15 -07:00
|
|
|
}
|
2014-03-02 08:17:26 -08:00
|
|
|
return true;
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
|
2013-05-24 06:52:34 -07:00
|
|
|
// This can be called from any thread, but not simultaneously.
|
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-20 18:50:15 -07:00
|
|
|
nsresult imgFrame::ImageUpdated(const nsIntRect &aUpdateRect)
|
|
|
|
{
|
2014-04-19 18:28:38 -07:00
|
|
|
MutexAutoLock lock(mDecodedMutex);
|
2013-07-04 11:45:57 -07: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-20 18:50:15 -07:00
|
|
|
mDecoded.UnionRect(mDecoded, aUpdateRect);
|
|
|
|
|
|
|
|
// clamp to bounds, in case someone sends a bogus updateRect (I'm looking at
|
|
|
|
// you, gif decoder)
|
2014-04-19 18:28:38 -07:00
|
|
|
nsIntRect boundsRect(mOffset, nsIntSize(mSize.width, mSize.height));
|
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-20 18:50:15 -07:00
|
|
|
mDecoded.IntersectRect(mDecoded, boundsRect);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIntRect imgFrame::GetRect() const
|
|
|
|
{
|
2014-04-19 18:28:38 -07:00
|
|
|
return nsIntRect(mOffset, nsIntSize(mSize.width, mSize.height));
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
SurfaceFormat imgFrame::GetFormat() 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-20 18:50:15 -07:00
|
|
|
{
|
|
|
|
return mFormat;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool imgFrame::GetNeedsBackground() 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-20 18:50:15 -07:00
|
|
|
{
|
|
|
|
// We need a background painted if we have alpha or we're incomplete.
|
2014-04-19 18:28:38 -07:00
|
|
|
return (mFormat == SurfaceFormat::B8G8R8A8 || !ImageComplete());
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t imgFrame::GetImageBytesPerRow() 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-20 18:50:15 -07:00
|
|
|
{
|
2014-02-24 19:37:51 -08:00
|
|
|
if (mVBuf)
|
2014-04-19 18:28:38 -07:00
|
|
|
return mSize.width * BytesPerPixel(mFormat);
|
2014-02-24 19:37:51 -08:00
|
|
|
|
2010-05-21 21:10:14 -07:00
|
|
|
if (mPaletteDepth)
|
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-20 18:50:15 -07:00
|
|
|
return mSize.width;
|
2010-05-21 21:10:14 -07:00
|
|
|
|
|
|
|
return 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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t imgFrame::GetImageDataLength() 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-20 18:50:15 -07:00
|
|
|
{
|
2010-05-21 21:10:14 -07:00
|
|
|
return GetImageBytesPerRow() * mSize.height;
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void imgFrame::GetImageData(uint8_t **aData, 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-20 18:50:15 -07:00
|
|
|
{
|
2012-09-26 08:33:06 -07:00
|
|
|
NS_ABORT_IF_FALSE(mLockCount != 0, "Can't GetImageData unless frame is locked");
|
|
|
|
|
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-20 18:50:15 -07:00
|
|
|
if (mImageSurface)
|
2014-04-19 18:28:38 -07:00
|
|
|
*aData = mVBufPtr;
|
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-20 18:50:15 -07:00
|
|
|
else if (mPalettedImageData)
|
|
|
|
*aData = mPalettedImageData + PaletteDataLength();
|
|
|
|
else
|
2012-07-30 07:20:58 -07:00
|
|
|
*aData = nullptr;
|
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-20 18:50:15 -07:00
|
|
|
|
|
|
|
*length = GetImageDataLength();
|
|
|
|
}
|
|
|
|
|
2013-06-14 06:42:01 -07:00
|
|
|
uint8_t* imgFrame::GetImageData() const
|
|
|
|
{
|
|
|
|
uint8_t *data;
|
|
|
|
uint32_t length;
|
|
|
|
GetImageData(&data, &length);
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool imgFrame::GetIsPaletted() 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-20 18:50:15 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
return mPalettedImageData != nullptr;
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool imgFrame::GetHasAlpha() 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-20 18:50:15 -07:00
|
|
|
{
|
2014-04-19 18:28:38 -07:00
|
|
|
return mFormat == SurfaceFormat::B8G8R8A8;
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void imgFrame::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-20 18:50:15 -07:00
|
|
|
{
|
2012-09-26 08:33:06 -07:00
|
|
|
NS_ABORT_IF_FALSE(mLockCount != 0, "Can't GetPaletteData unless frame is locked");
|
|
|
|
|
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-20 18:50:15 -07:00
|
|
|
if (!mPalettedImageData) {
|
2012-07-30 07:20:58 -07:00
|
|
|
*aPalette = nullptr;
|
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-20 18:50:15 -07:00
|
|
|
*length = 0;
|
|
|
|
} else {
|
2012-08-22 08:56:38 -07:00
|
|
|
*aPalette = (uint32_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-20 18:50:15 -07:00
|
|
|
*length = PaletteDataLength();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-14 06:42:01 -07:00
|
|
|
uint32_t* imgFrame::GetPaletteData() const
|
|
|
|
{
|
|
|
|
uint32_t* data;
|
|
|
|
uint32_t length;
|
|
|
|
GetPaletteData(&data, &length);
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
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-20 18:50:15 -07:00
|
|
|
nsresult imgFrame::LockImageData()
|
|
|
|
{
|
2013-05-24 06:52:34 -07:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
2012-09-26 08:33:06 -07:00
|
|
|
NS_ABORT_IF_FALSE(mLockCount >= 0, "Unbalanced locks and unlocks");
|
|
|
|
if (mLockCount < 0) {
|
2012-09-28 15:00:28 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
2012-09-26 08:33:06 -07:00
|
|
|
}
|
2012-09-26 08:33:06 -07:00
|
|
|
|
|
|
|
mLockCount++;
|
|
|
|
|
|
|
|
// If we are not the first lock, there's nothing to do.
|
|
|
|
if (mLockCount != 1) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Paletted images don't have surfaces, so there's nothing to do.
|
|
|
|
if (mPalettedImageData)
|
|
|
|
return NS_OK;
|
2010-02-25 10:14:30 -08:00
|
|
|
|
2014-02-24 19:37:51 -08:00
|
|
|
if (!mImageSurface) {
|
|
|
|
if (mVBuf) {
|
|
|
|
VolatileBufferPtr<uint8_t> ref(mVBuf);
|
|
|
|
if (ref.WasBufferPurged())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
mImageSurface = CreateLockedSurface(mVBuf, mSize, mFormat);
|
|
|
|
if (!mImageSurface)
|
2014-02-24 19:37:51 -08:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2014-02-25 02:57:41 -08:00
|
|
|
}
|
2014-04-19 18:28:38 -07:00
|
|
|
if (mOptSurface || mSinglePixel || mFormat == SurfaceFormat::R5G6B5) {
|
|
|
|
SurfaceFormat format = mFormat;
|
|
|
|
if (mFormat == SurfaceFormat::R5G6B5)
|
|
|
|
format = SurfaceFormat::B8G8R8A8;
|
2014-02-25 02:57:41 -08:00
|
|
|
|
2014-02-24 19:37:51 -08:00
|
|
|
// Recover the pixels
|
2014-02-25 02:57:41 -08:00
|
|
|
RefPtr<VolatileBuffer> buf =
|
2014-04-19 18:28:38 -07:00
|
|
|
AllocateBufferForImage(mSize, format);
|
2014-02-25 02:57:41 -08:00
|
|
|
if (!buf) {
|
2014-02-24 19:37:51 -08:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
RefPtr<DataSourceSurface> surf =
|
|
|
|
CreateLockedSurface(buf, mSize, format);
|
|
|
|
if (!surf)
|
2014-02-24 19:37:51 -08:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
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-20 18:50:15 -07:00
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
DataSourceSurface::MappedSurface mapping;
|
|
|
|
DebugOnly<bool> success =
|
|
|
|
surf->Map(DataSourceSurface::MapType::WRITE, &mapping);
|
|
|
|
NS_ASSERTION(success, "Failed to map surface");
|
|
|
|
RefPtr<DrawTarget> target =
|
|
|
|
Factory::CreateDrawTargetForData(BackendType::CAIRO,
|
|
|
|
mapping.mData,
|
|
|
|
mSize,
|
|
|
|
mapping.mStride,
|
|
|
|
format);
|
|
|
|
|
|
|
|
Rect rect(0, 0, mSize.width, mSize.height);
|
2014-02-24 19:37:51 -08:00
|
|
|
if (mSinglePixel)
|
2014-04-19 18:28:38 -07:00
|
|
|
target->FillRect(rect, ColorPattern(mSinglePixelColor),
|
|
|
|
DrawOptions(1.0f, CompositionOp::OP_SOURCE));
|
|
|
|
else if (mFormat == SurfaceFormat::R5G6B5)
|
|
|
|
target->DrawSurface(mImageSurface, rect, rect);
|
2014-02-24 19:37:51 -08:00
|
|
|
else
|
2014-04-19 18:28:38 -07:00
|
|
|
target->DrawSurface(mOptSurface, rect, rect,
|
|
|
|
DrawSurfaceOptions(),
|
|
|
|
DrawOptions(1.0f, CompositionOp::OP_SOURCE));
|
|
|
|
target->Flush();
|
|
|
|
surf->Unmap();
|
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-20 18:50:15 -07:00
|
|
|
|
2014-02-25 02:57:41 -08:00
|
|
|
mFormat = format;
|
|
|
|
mVBuf = buf;
|
|
|
|
mImageSurface = surf;
|
2014-02-24 19:37:51 -08:00
|
|
|
mOptSurface = nullptr;
|
|
|
|
}
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
mVBufPtr = mVBuf;
|
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-20 18:50:15 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult imgFrame::UnlockImageData()
|
|
|
|
{
|
2013-05-24 06:52:34 -07:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
2012-09-26 08:33:06 -07:00
|
|
|
NS_ABORT_IF_FALSE(mLockCount != 0, "Unlocking an unlocked image!");
|
|
|
|
if (mLockCount == 0) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
mLockCount--;
|
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-20 18:50:15 -07:00
|
|
|
|
2012-09-26 08:33:06 -07:00
|
|
|
NS_ABORT_IF_FALSE(mLockCount >= 0, "Unbalanced locks and unlocks");
|
|
|
|
if (mLockCount < 0) {
|
2010-02-25 10:14:30 -08:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-09-26 08:33:06 -07:00
|
|
|
// If we are not the last lock, there's nothing to do.
|
|
|
|
if (mLockCount != 0) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Paletted images don't have surfaces, so there's nothing to do.
|
|
|
|
if (mPalettedImageData)
|
|
|
|
return NS_OK;
|
2010-02-25 10:14:30 -08:00
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
mVBufPtr = nullptr;
|
2014-02-24 19:37:51 -08:00
|
|
|
if (mVBuf && mDiscardable) {
|
|
|
|
mImageSurface = nullptr;
|
|
|
|
}
|
|
|
|
|
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-20 18:50:15 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-24 19:37:51 -08:00
|
|
|
void imgFrame::SetDiscardable()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mLockCount, "Expected to be locked when SetDiscardable is called");
|
2014-04-21 15:50:54 -07:00
|
|
|
// Disabled elsewhere due to the cost of calling GetSourceSurfaceForSurface.
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2014-02-24 19:37:51 -08:00
|
|
|
mDiscardable = true;
|
2014-04-21 15:50:54 -07:00
|
|
|
#endif
|
2014-02-24 19:37:51 -08:00
|
|
|
}
|
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
TemporaryRef<SourceSurface>
|
|
|
|
imgFrame::GetSurface()
|
|
|
|
{
|
|
|
|
if (mOptSurface) {
|
|
|
|
if (mOptSurface->IsValid())
|
|
|
|
return mOptSurface;
|
|
|
|
else
|
|
|
|
mOptSurface = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mImageSurface)
|
|
|
|
return mImageSurface;
|
|
|
|
|
|
|
|
if (!mVBuf)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
VolatileBufferPtr<char> buf(mVBuf);
|
|
|
|
if (buf.WasBufferPurged())
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
return CreateLockedSurface(mVBuf, mSize, mFormat);
|
|
|
|
}
|
|
|
|
|
2013-12-06 01:45:24 -08:00
|
|
|
int32_t imgFrame::GetRawTimeout() 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-20 18:50:15 -07:00
|
|
|
{
|
2013-12-06 01:45:24 -08:00
|
|
|
return mTimeout;
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
|
2013-12-06 01:45:24 -08:00
|
|
|
void imgFrame::SetRawTimeout(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-20 18:50:15 -07:00
|
|
|
{
|
|
|
|
mTimeout = aTimeout;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t imgFrame::GetFrameDisposalMethod() 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-20 18:50:15 -07:00
|
|
|
{
|
|
|
|
return mDisposalMethod;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void imgFrame::SetFrameDisposalMethod(int32_t aFrameDisposalMethod)
|
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-20 18:50:15 -07:00
|
|
|
{
|
|
|
|
mDisposalMethod = aFrameDisposalMethod;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t imgFrame::GetBlendMethod() 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-20 18:50:15 -07:00
|
|
|
{
|
|
|
|
return mBlendMethod;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void imgFrame::SetBlendMethod(int32_t aBlendMethod)
|
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-20 18:50:15 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
mBlendMethod = (int8_t)aBlendMethod;
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
|
2013-07-15 11:38:59 -07:00
|
|
|
// This can be called from any thread.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool imgFrame::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-20 18:50:15 -07:00
|
|
|
{
|
2014-04-19 18:28:38 -07:00
|
|
|
MutexAutoLock lock(mDecodedMutex);
|
2013-07-15 11:38:59 -07:00
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
return mDecoded.IsEqualInterior(nsIntRect(mOffset.x, mOffset.y,
|
|
|
|
mSize.width, mSize.height));
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// A hint from the image decoders that this image has no alpha, even
|
|
|
|
// though we created is ARGB32. This changes our format to RGB24,
|
|
|
|
// which in turn will cause us to Optimize() to RGB24. Has no effect
|
|
|
|
// after Optimize() is called, though in all cases it will be just a
|
|
|
|
// performance win -- the pixels are still correct and have the A byte
|
|
|
|
// set to 0xff.
|
|
|
|
void imgFrame::SetHasNoAlpha()
|
|
|
|
{
|
2014-04-19 18:28:38 -07:00
|
|
|
if (mFormat == SurfaceFormat::B8G8R8A8) {
|
|
|
|
mFormat = SurfaceFormat::B8G8R8X8;
|
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-20 18:50:15 -07:00
|
|
|
}
|
|
|
|
}
|
2009-11-12 15:18:40 -08:00
|
|
|
|
2012-03-23 15:10:50 -07:00
|
|
|
void imgFrame::SetAsNonPremult(bool aIsNonPremult)
|
|
|
|
{
|
|
|
|
mNonPremult = aIsNonPremult;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool imgFrame::GetCompositingFailed() const
|
2009-11-12 15:18:40 -08:00
|
|
|
{
|
|
|
|
return mCompositingFailed;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
void imgFrame::SetCompositingFailed(bool val)
|
2009-11-12 15:18:40 -08:00
|
|
|
{
|
|
|
|
mCompositingFailed = val;
|
|
|
|
}
|
2010-03-12 02:08:25 -08:00
|
|
|
|
2012-11-26 16:29:56 -08:00
|
|
|
// If |aLocation| indicates this is heap memory, we try to measure things with
|
|
|
|
// |aMallocSizeOf|. If that fails (because the platform doesn't support it) or
|
|
|
|
// it's non-heap memory, we fall back to computing the size analytically.
|
2012-02-19 19:51:48 -08:00
|
|
|
size_t
|
2013-09-24 13:45:13 -07:00
|
|
|
imgFrame::SizeOfExcludingThisWithComputedFallbackIfHeap(gfxMemoryLocation aLocation, mozilla::MallocSizeOf aMallocSizeOf) const
|
2010-05-21 21:10:14 -07:00
|
|
|
{
|
2014-01-23 10:26:40 -08:00
|
|
|
// aMallocSizeOf is only used if aLocation==gfxMemoryLocation::IN_PROCESS_HEAP. It
|
2013-08-23 12:51:00 -07:00
|
|
|
// should be nullptr otherwise.
|
2012-02-19 19:51:48 -08:00
|
|
|
NS_ABORT_IF_FALSE(
|
2014-01-23 10:26:40 -08:00
|
|
|
(aLocation == gfxMemoryLocation::IN_PROCESS_HEAP && aMallocSizeOf) ||
|
|
|
|
(aLocation != gfxMemoryLocation::IN_PROCESS_HEAP && !aMallocSizeOf),
|
2012-02-19 19:51:48 -08:00
|
|
|
"mismatch between aLocation and aMallocSizeOf");
|
2010-05-21 21:10:14 -07:00
|
|
|
|
2012-02-19 19:51:48 -08:00
|
|
|
size_t n = 0;
|
2010-05-21 21:10:14 -07:00
|
|
|
|
2014-01-23 10:26:40 -08:00
|
|
|
if (mPalettedImageData && aLocation == gfxMemoryLocation::IN_PROCESS_HEAP) {
|
2012-11-26 16:29:56 -08:00
|
|
|
size_t n2 = aMallocSizeOf(mPalettedImageData);
|
|
|
|
if (n2 == 0) {
|
|
|
|
n2 = GetImageDataLength() + PaletteDataLength();
|
2012-02-19 19:51:48 -08:00
|
|
|
}
|
2012-11-26 16:29:56 -08:00
|
|
|
n += n2;
|
2010-05-21 21:10:14 -07:00
|
|
|
}
|
|
|
|
|
2014-04-19 18:28:38 -07:00
|
|
|
if (mImageSurface && aLocation == gfxMemoryLocation::IN_PROCESS_HEAP) {
|
|
|
|
n += aMallocSizeOf(mImageSurface);
|
2014-02-24 19:37:51 -08:00
|
|
|
}
|
2014-04-19 18:28:38 -07:00
|
|
|
if (mOptSurface && aLocation == gfxMemoryLocation::IN_PROCESS_HEAP) {
|
|
|
|
n += aMallocSizeOf(mOptSurface);
|
2010-05-21 21:10:14 -07:00
|
|
|
}
|
|
|
|
|
2014-02-24 19:37:51 -08:00
|
|
|
if (mVBuf && aLocation == gfxMemoryLocation::IN_PROCESS_HEAP) {
|
|
|
|
n += aMallocSizeOf(mVBuf);
|
|
|
|
n += mVBuf->HeapSizeOfExcludingThis(aMallocSizeOf);
|
|
|
|
}
|
|
|
|
|
2014-04-14 22:24:01 -07:00
|
|
|
if (mVBuf && aLocation == gfxMemoryLocation::IN_PROCESS_NONHEAP) {
|
|
|
|
n += mVBuf->NonHeapSizeOfExcludingThis();
|
|
|
|
}
|
|
|
|
|
2012-02-19 19:51:48 -08:00
|
|
|
return n;
|
2010-05-21 21:10:14 -07:00
|
|
|
}
|