2012-12-19 09:59:30 +04: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 15:12:37 +04: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-21 05:50:15 +04:00
|
|
|
|
|
|
|
#include "imgFrame.h"
|
2014-08-23 00:12:38 +04:00
|
|
|
#include "ImageRegion.h"
|
2014-09-24 02:32:19 +04:00
|
|
|
#include "ShutdownTracker.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 05:50:15 +04:00
|
|
|
|
|
|
|
#include "prenv.h"
|
|
|
|
|
2014-02-09 12:04:38 +04: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-21 05:50:15 +04:00
|
|
|
#include "gfxPlatform.h"
|
2017-02-14 00:34:54 +03:00
|
|
|
#include "gfxPrefs.h"
|
2010-08-13 17:30:02 +04:00
|
|
|
#include "gfxUtils.h"
|
2014-02-25 07:37:51 +04: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-21 05:50:15 +04:00
|
|
|
|
2013-03-18 18:25:50 +04:00
|
|
|
#include "GeckoProfiler.h"
|
2014-11-28 06:55:57 +03:00
|
|
|
#include "MainThreadUtils.h"
|
2016-06-25 09:22:29 +03:00
|
|
|
#include "mozilla/CheckedInt.h"
|
|
|
|
#include "mozilla/gfx/Tools.h"
|
2017-02-08 23:48:59 +03:00
|
|
|
#include "mozilla/layers/SourceSurfaceSharedData.h"
|
2017-01-18 21:31:20 +03:00
|
|
|
#include "mozilla/layers/SourceSurfaceVolatileData.h"
|
2016-06-25 09:22:29 +03:00
|
|
|
#include "mozilla/Likely.h"
|
2013-06-23 16:03:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2013-09-07 06:15:49 +04:00
|
|
|
#include "nsMargin.h"
|
2015-01-08 11:04:31 +03:00
|
|
|
#include "nsThreadUtils.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 05:50:15 +04:00
|
|
|
|
2014-07-10 19:00:31 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
using namespace gfx;
|
|
|
|
|
|
|
|
namespace image {
|
2012-03-16 00:30:41 +04:00
|
|
|
|
2014-02-25 07:37:51 +04:00
|
|
|
static void
|
2017-01-18 21:31:20 +03:00
|
|
|
ScopedMapRelease(void* aMap)
|
2014-02-25 07:37:51 +04:00
|
|
|
{
|
2017-01-18 21:31:20 +03:00
|
|
|
delete static_cast<DataSourceSurface::ScopedMap*>(aMap);
|
2014-02-25 07:37:51 +04:00
|
|
|
}
|
|
|
|
|
2014-06-10 23:44:04 +04:00
|
|
|
static int32_t
|
|
|
|
VolatileSurfaceStride(const IntSize& size, SurfaceFormat format)
|
|
|
|
{
|
|
|
|
// Stride must be a multiple of four or cairo will complain.
|
|
|
|
return (size.width * BytesPerPixel(format) + 0x3) & ~0x3;
|
|
|
|
}
|
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
static already_AddRefed<DataSourceSurface>
|
2017-01-18 21:31:20 +03:00
|
|
|
CreateLockedSurface(DataSourceSurface *aSurface,
|
2014-04-20 05:28:38 +04:00
|
|
|
const IntSize& size,
|
|
|
|
SurfaceFormat format)
|
2014-02-25 07:37:51 +04:00
|
|
|
{
|
2017-02-08 23:48:59 +03:00
|
|
|
// Shared memory is never released until the surface itself is released
|
|
|
|
if (aSurface->GetType() == SurfaceType::DATA_SHARED) {
|
|
|
|
RefPtr<DataSourceSurface> surf(aSurface);
|
|
|
|
return surf.forget();
|
|
|
|
}
|
|
|
|
|
2017-01-18 21:31:20 +03:00
|
|
|
DataSourceSurface::ScopedMap* smap =
|
|
|
|
new DataSourceSurface::ScopedMap(aSurface, DataSourceSurface::READ_WRITE);
|
|
|
|
if (smap->IsMapped()) {
|
|
|
|
// The ScopedMap is held by this DataSourceSurface.
|
|
|
|
RefPtr<DataSourceSurface> surf =
|
|
|
|
Factory::CreateWrappingDataSourceSurface(smap->GetData(),
|
|
|
|
aSurface->Stride(),
|
|
|
|
size,
|
|
|
|
format,
|
|
|
|
&ScopedMapRelease,
|
|
|
|
static_cast<void*>(smap));
|
|
|
|
if (surf) {
|
|
|
|
return surf.forget();
|
|
|
|
}
|
2014-02-25 07:37:51 +04:00
|
|
|
}
|
|
|
|
|
2017-01-18 21:31:20 +03:00
|
|
|
delete smap;
|
|
|
|
return nullptr;
|
2014-02-25 07:37:51 +04:00
|
|
|
}
|
|
|
|
|
2017-01-18 21:31:20 +03:00
|
|
|
static already_AddRefed<DataSourceSurface>
|
|
|
|
AllocateBufferForImage(const IntSize& size,
|
|
|
|
SurfaceFormat format,
|
|
|
|
bool aIsAnimated = false)
|
2014-02-25 07:37:51 +04:00
|
|
|
{
|
2014-06-10 23:44:04 +04:00
|
|
|
int32_t stride = VolatileSurfaceStride(size, format);
|
2017-02-08 23:48:59 +03:00
|
|
|
if (!aIsAnimated && gfxPrefs::ImageMemShared()) {
|
|
|
|
RefPtr<SourceSurfaceSharedData> newSurf = new SourceSurfaceSharedData();
|
|
|
|
if (newSurf->Init(size, stride, format)) {
|
|
|
|
return newSurf.forget();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
RefPtr<SourceSurfaceVolatileData> newSurf= new SourceSurfaceVolatileData();
|
|
|
|
if (newSurf->Init(size, stride, format)) {
|
|
|
|
return newSurf.forget();
|
|
|
|
}
|
2015-03-31 20:48:00 +03:00
|
|
|
}
|
2014-02-25 07:37:51 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-07-01 04:59:29 +03:00
|
|
|
static bool
|
2017-01-18 21:31:20 +03:00
|
|
|
ClearSurface(DataSourceSurface* aSurface, const IntSize& aSize, SurfaceFormat aFormat)
|
2016-07-01 04:59:29 +03:00
|
|
|
{
|
2017-01-18 21:31:20 +03:00
|
|
|
int32_t stride = aSurface->Stride();
|
|
|
|
uint8_t* data = aSurface->GetData();
|
|
|
|
MOZ_ASSERT(data);
|
2016-07-01 04:59:29 +03:00
|
|
|
|
|
|
|
if (aFormat == SurfaceFormat::B8G8R8X8) {
|
|
|
|
// Skia doesn't support RGBX surfaces, so ensure the alpha value is set
|
|
|
|
// to opaque white. While it would be nice to only do this for Skia,
|
|
|
|
// imgFrame can run off main thread and past shutdown where
|
|
|
|
// we might not have gfxPlatform, so just memset everytime instead.
|
2017-01-18 21:31:20 +03:00
|
|
|
memset(data, 0xFF, stride * aSize.height);
|
|
|
|
} else if (aSurface->OnHeap()) {
|
2016-07-01 04:59:29 +03:00
|
|
|
// We only need to memset it if the buffer was allocated on the heap.
|
|
|
|
// Otherwise, it's allocated via mmap and refers to a zeroed page and will
|
|
|
|
// be COW once it's written to.
|
2017-01-18 21:31:20 +03:00
|
|
|
memset(data, 0, stride * aSize.height);
|
2016-07-01 04:59:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-02-08 23:48:59 +03:00
|
|
|
void
|
|
|
|
MarkSurfaceShared(SourceSurface* aSurface)
|
|
|
|
{
|
|
|
|
// Depending on what requested the image decoding, the buffer may or may not
|
|
|
|
// end up being shared with another process (e.g. put in a painted layer,
|
|
|
|
// used inside a canvas). If not shared, we should ensure are not keeping the
|
|
|
|
// handle only because we have yet to share it.
|
|
|
|
if (aSurface && aSurface->GetType() == SurfaceType::DATA_SHARED) {
|
|
|
|
auto sharedSurface = static_cast<SourceSurfaceSharedData*>(aSurface);
|
|
|
|
sharedSurface->FinishedSharing();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 05:50:15 +04:00
|
|
|
// Returns true if an image of aWidth x aHeight is allowed and legal.
|
2015-03-31 20:48:00 +03: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-21 05:50:15 +04:00
|
|
|
{
|
|
|
|
// reject over-wide or over-tall images
|
2012-08-22 19:56:38 +04:00
|
|
|
const int32_t k64KLimit = 0x0000FFFF;
|
2012-10-26 17:32:10 +04: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-21 05:50:15 +04:00
|
|
|
NS_WARNING("image too big");
|
2011-10-17 18:59:28 +04: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-21 05:50:15 +04:00
|
|
|
}
|
|
|
|
|
2011-07-01 21:03:47 +04:00
|
|
|
// protect against invalid sizes
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(aHeight <= 0 || aWidth <= 0)) {
|
2011-10-17 18:59:28 +04: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-21 05:50:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// check to make sure we don't overflow a 32-bit
|
2013-10-02 18:44:53 +04: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-21 05:50:15 +04:00
|
|
|
NS_WARNING("width or height too large");
|
2011-10-17 18:59:28 +04: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-21 05:50:15 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04: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-21 05:50:15 +04:00
|
|
|
}
|
|
|
|
|
2014-11-27 00:22:10 +03:00
|
|
|
static bool AllowedImageAndFrameDimensions(const nsIntSize& aImageSize,
|
|
|
|
const nsIntRect& aFrameRect)
|
|
|
|
{
|
|
|
|
if (!AllowedImageSize(aImageSize.width, aImageSize.height)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!AllowedImageSize(aFrameRect.width, aFrameRect.height)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nsIntRect imageRect(0, 0, aImageSize.width, aImageSize.height);
|
|
|
|
if (!imageRect.Contains(aFrameRect)) {
|
2015-02-07 14:51:40 +03:00
|
|
|
NS_WARNING("Animated image frame does not fit inside bounds of image");
|
2014-11-27 00:22:10 +03:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-01-08 11:04:31 +03:00
|
|
|
imgFrame::imgFrame()
|
2015-01-12 06:28:02 +03:00
|
|
|
: mMonitor("imgFrame")
|
2015-01-08 11:04:31 +03:00
|
|
|
, mDecoded(0, 0, 0, 0)
|
|
|
|
, mLockCount(0)
|
2016-07-20 02:22:34 +03:00
|
|
|
, mTimeout(FrameTimeout::FromRawMilliseconds(100))
|
2015-01-08 11:04:31 +03:00
|
|
|
, mDisposalMethod(DisposalMethod::NOT_SPECIFIED)
|
|
|
|
, mBlendMethod(BlendMethod::OVER)
|
2015-01-12 06:28:02 +03:00
|
|
|
, mAborted(false)
|
2016-03-24 03:31:42 +03:00
|
|
|
, mFinished(false)
|
2015-07-31 17:29:10 +03:00
|
|
|
, mOptimizable(false)
|
2015-01-08 11:04:31 +03:00
|
|
|
, mPalettedImageData(nullptr)
|
|
|
|
, mPaletteDepth(0)
|
|
|
|
, mNonPremult(false)
|
|
|
|
, mCompositingFailed(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-21 05:50:15 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
imgFrame::~imgFrame()
|
|
|
|
{
|
2015-01-12 06:28:02 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
MonitorAutoLock lock(mMonitor);
|
2016-03-24 03:31:42 +03:00
|
|
|
MOZ_ASSERT(mAborted || AreAllPixelsWritten());
|
|
|
|
MOZ_ASSERT(mAborted || mFinished);
|
2015-01-12 06:28:02 +03:00
|
|
|
#endif
|
|
|
|
|
2015-02-19 07:51:06 +03:00
|
|
|
free(mPalettedImageData);
|
2012-10-03 22:10:31 +04: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-21 05:50:15 +04:00
|
|
|
}
|
|
|
|
|
2014-09-15 02:22:45 +04:00
|
|
|
nsresult
|
2014-11-27 00:22:10 +03:00
|
|
|
imgFrame::InitForDecoder(const nsIntSize& aImageSize,
|
|
|
|
const nsIntRect& aRect,
|
2014-09-15 02:22:45 +04:00
|
|
|
SurfaceFormat aFormat,
|
2015-01-08 11:04:31 +03:00
|
|
|
uint8_t aPaletteDepth /* = 0 */,
|
2017-01-18 21:31:20 +03:00
|
|
|
bool aNonPremult /* = false */,
|
|
|
|
bool aIsAnimated /* = 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-21 05:50:15 +04:00
|
|
|
{
|
2014-09-15 02:22:45 +04:00
|
|
|
// Assert for properties that should be verified by decoders,
|
|
|
|
// warn for properties related to bad content.
|
2014-11-27 00:22:10 +03:00
|
|
|
if (!AllowedImageAndFrameDimensions(aImageSize, aRect)) {
|
2013-05-22 13:10:38 +04:00
|
|
|
NS_WARNING("Should have legal image size");
|
2015-01-12 06:28:02 +03:00
|
|
|
mAborted = 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-21 05:50:15 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
2013-05-22 13:10:38 +04: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 05:50:15 +04:00
|
|
|
|
2015-03-29 17:59:08 +03:00
|
|
|
mImageSize = aImageSize;
|
2016-05-27 08:19:38 +03:00
|
|
|
mFrameRect = aRect;
|
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 05:50:15 +04:00
|
|
|
|
2016-07-31 00:47:49 +03:00
|
|
|
// We only allow a non-trivial frame rect (i.e., a frame rect that doesn't
|
|
|
|
// cover the entire image) for paletted animation frames. We never draw those
|
|
|
|
// frames directly; we just use FrameAnimator to composite them and produce a
|
|
|
|
// BGRA surface that we actually draw. We enforce this here to make sure that
|
|
|
|
// imgFrame::Draw(), which is responsible for drawing all other kinds of
|
|
|
|
// frames, never has to deal with a non-trivial frame rect.
|
|
|
|
if (aPaletteDepth == 0 &&
|
|
|
|
!mFrameRect.IsEqualEdges(IntRect(IntPoint(), mImageSize))) {
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Creating a non-paletted imgFrame with a "
|
|
|
|
"non-trivial frame rect");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
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 05:50:15 +04:00
|
|
|
mFormat = aFormat;
|
|
|
|
mPaletteDepth = aPaletteDepth;
|
2015-01-08 11:04:31 +03:00
|
|
|
mNonPremult = aNonPremult;
|
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 05:50:15 +04:00
|
|
|
|
|
|
|
if (aPaletteDepth != 0) {
|
|
|
|
// We're creating for a paletted image.
|
|
|
|
if (aPaletteDepth > 8) {
|
2013-05-22 13:10:38 +04:00
|
|
|
NS_WARNING("Should have legal palette depth");
|
2010-06-18 00:28:38 +04:00
|
|
|
NS_ERROR("This Depth is not supported");
|
2015-01-12 06:28:02 +03:00
|
|
|
mAborted = 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-21 05:50:15 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2015-01-08 11:04:31 +03:00
|
|
|
// Use the fallible allocator here. Paletted images always use 1 byte per
|
|
|
|
// pixel, so calculating the amount of memory we need is straightforward.
|
2016-06-01 21:59:47 +03:00
|
|
|
size_t dataSize = PaletteDataLength() + mFrameRect.Area();
|
|
|
|
mPalettedImageData = static_cast<uint8_t*>(calloc(dataSize, sizeof(uint8_t)));
|
2015-03-31 20:48:00 +03:00
|
|
|
if (!mPalettedImageData) {
|
2016-06-01 21:59:47 +03:00
|
|
|
NS_WARNING("Call to calloc for paletted image data should succeed");
|
2015-03-31 20:48:00 +03: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 05:50:15 +04:00
|
|
|
NS_ENSURE_TRUE(mPalettedImageData, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
} else {
|
2017-01-18 21:31:20 +03:00
|
|
|
MOZ_ASSERT(!mLockedSurface, "Called imgFrame::InitForDecoder() twice?");
|
2014-09-15 02:22:45 +04:00
|
|
|
|
2017-01-18 21:31:20 +03:00
|
|
|
mRawSurface = AllocateBufferForImage(mFrameRect.Size(), mFormat, aIsAnimated);
|
|
|
|
if (!mRawSurface) {
|
2015-01-12 06:28:02 +03:00
|
|
|
mAborted = true;
|
2014-09-15 02:22:45 +04:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2014-02-25 07:37:51 +04:00
|
|
|
}
|
2016-07-01 04:59:29 +03:00
|
|
|
|
2017-01-18 21:31:20 +03:00
|
|
|
mLockedSurface = CreateLockedSurface(mRawSurface, mFrameRect.Size(), mFormat);
|
|
|
|
if (!mLockedSurface) {
|
|
|
|
NS_WARNING("Failed to create LockedSurface");
|
2016-07-01 04:59:29 +03:00
|
|
|
mAborted = true;
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2017-02-14 06:28:45 +03:00
|
|
|
|
|
|
|
if (!ClearSurface(mRawSurface, mFrameRect.Size(), mFormat)) {
|
|
|
|
NS_WARNING("Could not clear allocated buffer");
|
|
|
|
mAborted = true;
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2014-09-15 02:22:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
imgFrame::InitWithDrawable(gfxDrawable* aDrawable,
|
|
|
|
const nsIntSize& aSize,
|
|
|
|
const SurfaceFormat aFormat,
|
2016-05-25 19:01:18 +03:00
|
|
|
SamplingFilter aSamplingFilter,
|
2016-09-15 14:53:12 +03:00
|
|
|
uint32_t aImageFlags,
|
|
|
|
gfx::BackendType aBackend)
|
2014-09-15 02:22:45 +04:00
|
|
|
{
|
|
|
|
// Assert for properties that should be verified by decoders,
|
|
|
|
// warn for properties related to bad content.
|
|
|
|
if (!AllowedImageSize(aSize.width, aSize.height)) {
|
|
|
|
NS_WARNING("Should have legal image size");
|
2015-01-12 06:28:02 +03:00
|
|
|
mAborted = true;
|
2014-09-15 02:22:45 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2015-03-29 17:59:08 +03:00
|
|
|
mImageSize = aSize;
|
2016-05-27 08:19:38 +03:00
|
|
|
mFrameRect = IntRect(IntPoint(0, 0), aSize);
|
2014-09-15 02:22:45 +04:00
|
|
|
|
|
|
|
mFormat = aFormat;
|
|
|
|
mPaletteDepth = 0;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DrawTarget> target;
|
2014-09-15 02:22:45 +04:00
|
|
|
|
|
|
|
bool canUseDataSurface =
|
|
|
|
gfxPlatform::GetPlatform()->CanRenderContentToDataSurface();
|
|
|
|
|
|
|
|
if (canUseDataSurface) {
|
|
|
|
// It's safe to use data surfaces for content on this platform, so we can
|
|
|
|
// get away with using volatile buffers.
|
2017-01-18 21:31:20 +03:00
|
|
|
MOZ_ASSERT(!mLockedSurface, "Called imgFrame::InitWithDrawable() twice?");
|
2014-09-15 02:22:45 +04:00
|
|
|
|
2017-01-18 21:31:20 +03:00
|
|
|
mRawSurface = AllocateBufferForImage(mFrameRect.Size(), mFormat);
|
|
|
|
if (!mRawSurface) {
|
2015-01-12 06:28:02 +03:00
|
|
|
mAborted = true;
|
2014-09-15 02:22:45 +04:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
2017-01-18 21:31:20 +03:00
|
|
|
mLockedSurface = CreateLockedSurface(mRawSurface, mFrameRect.Size(), mFormat);
|
|
|
|
if (!mLockedSurface) {
|
|
|
|
NS_WARNING("Failed to create LockedSurface");
|
2015-01-12 06:28:02 +03:00
|
|
|
mAborted = true;
|
2014-09-15 02:22:45 +04:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2016-07-01 04:59:29 +03:00
|
|
|
|
2017-01-18 21:31:20 +03:00
|
|
|
if (!ClearSurface(mRawSurface, mFrameRect.Size(), mFormat)) {
|
2016-07-01 04:59:29 +03:00
|
|
|
NS_WARNING("Could not clear allocated buffer");
|
|
|
|
mAborted = true;
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
2016-08-12 00:54:08 +03:00
|
|
|
target = gfxPlatform::CreateDrawTargetForData(
|
2017-01-18 21:31:20 +03:00
|
|
|
mLockedSurface->GetData(),
|
2016-08-12 00:54:08 +03:00
|
|
|
mFrameRect.Size(),
|
2017-01-18 21:31:20 +03:00
|
|
|
mLockedSurface->Stride(),
|
2016-08-12 00:54:08 +03:00
|
|
|
mFormat);
|
2014-09-15 02:22:45 +04:00
|
|
|
} else {
|
|
|
|
// We can't use data surfaces for content, so we'll create an offscreen
|
|
|
|
// surface instead. This means if someone later calls RawAccessRef(), we
|
|
|
|
// may have to do an expensive readback, but we warned callers about that in
|
|
|
|
// the documentation for this method.
|
|
|
|
MOZ_ASSERT(!mOptSurface, "Called imgFrame::InitWithDrawable() twice?");
|
|
|
|
|
2016-09-15 14:53:12 +03:00
|
|
|
if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(aBackend)) {
|
|
|
|
target = gfxPlatform::GetPlatform()->
|
|
|
|
CreateDrawTargetForBackend(aBackend, mFrameRect.Size(), mFormat);
|
|
|
|
} else {
|
|
|
|
target = gfxPlatform::GetPlatform()->
|
|
|
|
CreateOffscreenContentDrawTarget(mFrameRect.Size(), mFormat);
|
|
|
|
}
|
2014-09-15 02:22:45 +04:00
|
|
|
}
|
|
|
|
|
2016-04-12 22:18:11 +03:00
|
|
|
if (!target || !target->IsValid()) {
|
2015-01-12 06:28:02 +03:00
|
|
|
mAborted = true;
|
2014-09-15 02:22:45 +04:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw using the drawable the caller provided.
|
2016-06-07 02:39:56 +03:00
|
|
|
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(target);
|
2016-05-27 08:19:38 +03:00
|
|
|
MOZ_ASSERT(ctx); // Already checked the draw target above.
|
|
|
|
gfxUtils::DrawPixelSnapped(ctx, aDrawable, mFrameRect.Size(),
|
|
|
|
ImageRegion::Create(ThebesRect(mFrameRect)),
|
2016-05-25 19:01:18 +03:00
|
|
|
mFormat, aSamplingFilter, aImageFlags);
|
2014-09-15 02:22:45 +04:00
|
|
|
|
2017-01-18 21:31:20 +03:00
|
|
|
if (canUseDataSurface && !mLockedSurface) {
|
2014-09-15 02:22:45 +04:00
|
|
|
NS_WARNING("Failed to create VolatileDataSourceSurface");
|
2015-01-12 06:28:02 +03:00
|
|
|
mAborted = true;
|
2014-09-15 02:22:45 +04:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!canUseDataSurface) {
|
|
|
|
// We used an offscreen surface, which is an "optimized" surface from
|
|
|
|
// imgFrame's perspective.
|
|
|
|
mOptSurface = target->Snapshot();
|
2017-02-08 23:48:59 +03:00
|
|
|
} else {
|
|
|
|
FinalizeSurface();
|
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 05:50:15 +04:00
|
|
|
}
|
|
|
|
|
2015-01-12 06:28:02 +03:00
|
|
|
// If we reach this point, we should regard ourselves as complete.
|
|
|
|
mDecoded = GetRect();
|
2016-03-24 03:31:42 +03:00
|
|
|
mFinished = true;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
MonitorAutoLock lock(mMonitor);
|
|
|
|
MOZ_ASSERT(AreAllPixelsWritten());
|
|
|
|
#endif
|
2015-01-12 06:28:02 +03: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 05:50:15 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-03-31 20:48:00 +03:00
|
|
|
nsresult
|
2016-09-15 14:53:12 +03:00
|
|
|
imgFrame::Optimize(DrawTarget* aTarget)
|
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 05:50:15 +04:00
|
|
|
{
|
2013-05-24 17:52:34 +04:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2015-01-12 06:28:02 +03:00
|
|
|
mMonitor.AssertCurrentThreadOwns();
|
2016-09-15 14:53:12 +03:00
|
|
|
|
|
|
|
if (mLockCount > 0 || !mOptimizable) {
|
|
|
|
// Don't optimize right now.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-05-24 17:52:34 +04:00
|
|
|
|
2016-06-20 16:46:00 +03:00
|
|
|
// Check whether image optimization is disabled -- not thread safe!
|
|
|
|
static bool gDisableOptimize = false;
|
|
|
|
static bool hasCheckedOptimize = false;
|
|
|
|
if (!hasCheckedOptimize) {
|
|
|
|
if (PR_GetEnv("MOZ_DISABLE_IMAGE_OPTIMIZE")) {
|
|
|
|
gDisableOptimize = true;
|
|
|
|
}
|
|
|
|
hasCheckedOptimize = true;
|
|
|
|
}
|
|
|
|
|
2014-09-24 02:32:19 +04:00
|
|
|
// Don't optimize during shutdown because gfxPlatform may not be available.
|
2015-03-31 20:48:00 +03:00
|
|
|
if (ShutdownTracker::ShutdownHasStarted()) {
|
2014-09-24 02:32:19 +04:00
|
|
|
return NS_OK;
|
2015-03-31 20:48:00 +03:00
|
|
|
}
|
2014-09-24 02:32:19 +04:00
|
|
|
|
2016-09-15 14:53:12 +03:00
|
|
|
if (gDisableOptimize) {
|
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 05:50:15 +04:00
|
|
|
return NS_OK;
|
2015-03-31 20:48:00 +03: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 05:50:15 +04:00
|
|
|
|
2016-07-30 23:41:57 +03:00
|
|
|
if (mPalettedImageData || mOptSurface) {
|
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 05:50:15 +04:00
|
|
|
return NS_OK;
|
2015-03-31 20:48:00 +03: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 05:50:15 +04:00
|
|
|
|
2016-07-30 23:41:57 +03:00
|
|
|
// XXX(seth): It's currently unclear if there's any reason why we can't
|
|
|
|
// optimize non-premult surfaces. We should look into removing this.
|
2015-03-31 20:48:00 +03:00
|
|
|
if (mNonPremult) {
|
2012-03-24 02:10:50 +04:00
|
|
|
return NS_OK;
|
2015-03-31 20:48:00 +03:00
|
|
|
}
|
2012-03-24 02:10:50 +04:00
|
|
|
|
2015-03-31 20:48:00 +03:00
|
|
|
mOptSurface = gfxPlatform::GetPlatform()
|
2017-01-18 21:31:20 +03:00
|
|
|
->ScreenReferenceDrawTarget()->OptimizeSourceSurface(mLockedSurface);
|
|
|
|
if (mOptSurface == mLockedSurface) {
|
2014-04-20 05:28:38 +04:00
|
|
|
mOptSurface = nullptr;
|
2015-03-31 20:48:00 +03: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 05:50:15 +04:00
|
|
|
|
|
|
|
if (mOptSurface) {
|
2017-01-18 21:31:20 +03:00
|
|
|
// There's no reason to keep our original surface around if we have an
|
2016-08-10 00:47:26 +03:00
|
|
|
// optimized surface. Release our reference to it. This will leave
|
2017-01-18 21:31:20 +03:00
|
|
|
// |mLockedSurface| as the only thing keeping it alive, so it'll get freed
|
|
|
|
// below.
|
|
|
|
mRawSurface = 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-21 05:50:15 +04:00
|
|
|
}
|
|
|
|
|
2017-01-18 21:31:20 +03:00
|
|
|
// Release all strong references to the surface's memory. If the underlying
|
|
|
|
// surface is volatile, this will allow the operating system to free the
|
|
|
|
// memory if it needs to.
|
|
|
|
mLockedSurface = nullptr;
|
2016-09-15 14:53:12 +03:00
|
|
|
mOptimizable = false;
|
2014-09-19 06:26:01 +04: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 05:50:15 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-09-11 04:06:45 +04:00
|
|
|
DrawableFrameRef
|
|
|
|
imgFrame::DrawableRef()
|
|
|
|
{
|
|
|
|
return DrawableFrameRef(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
RawAccessFrameRef
|
|
|
|
imgFrame::RawAccessRef()
|
|
|
|
{
|
|
|
|
return RawAccessFrameRef(this);
|
|
|
|
}
|
|
|
|
|
2015-01-07 12:40:23 +03:00
|
|
|
void
|
|
|
|
imgFrame::SetRawAccessOnly()
|
|
|
|
{
|
2015-01-08 11:04:31 +03:00
|
|
|
AssertImageDataLocked();
|
|
|
|
|
2015-01-07 12:40:23 +03:00
|
|
|
// Lock our data and throw away the key.
|
|
|
|
LockImageData();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-13 17:30:02 +04:00
|
|
|
imgFrame::SurfaceWithFormat
|
2016-07-31 00:49:03 +03:00
|
|
|
imgFrame::SurfaceForDrawing(bool aDoPartialDecode,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aDoTile,
|
2014-08-23 00:12:38 +04:00
|
|
|
ImageRegion& aRegion,
|
2014-04-20 05:28:38 +04:00
|
|
|
SourceSurface* aSurface)
|
2010-08-13 17:30:02 +04:00
|
|
|
{
|
2015-01-08 11:04:31 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2015-01-12 06:28:02 +03:00
|
|
|
mMonitor.AssertCurrentThreadOwns();
|
2015-01-08 11:04:31 +03:00
|
|
|
|
2016-07-31 00:49:03 +03:00
|
|
|
if (!aDoPartialDecode) {
|
|
|
|
return SurfaceWithFormat(new gfxSurfaceDrawable(aSurface, mImageSize),
|
2016-10-01 06:11:59 +03:00
|
|
|
mFormat);
|
2010-08-13 17:30:02 +04:00
|
|
|
}
|
|
|
|
|
2015-03-31 20:48:00 +03:00
|
|
|
gfxRect available = gfxRect(mDecoded.x, mDecoded.y, mDecoded.width,
|
|
|
|
mDecoded.height);
|
2010-08-13 17:30:02 +04:00
|
|
|
|
2016-07-30 23:41:57 +03:00
|
|
|
if (aDoTile) {
|
2010-08-13 17:30:02 +04:00
|
|
|
// Create a temporary surface.
|
|
|
|
// Give this surface an alpha channel because there are
|
|
|
|
// transparent pixels in the padding or undecoded area
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DrawTarget> target =
|
2014-04-20 05:28:38 +04:00
|
|
|
gfxPlatform::GetPlatform()->
|
2016-07-31 00:49:03 +03:00
|
|
|
CreateOffscreenContentDrawTarget(mImageSize, SurfaceFormat::B8G8R8A8);
|
2015-03-31 20:48:00 +03:00
|
|
|
if (!target) {
|
2010-08-13 17:30:02 +04:00
|
|
|
return SurfaceWithFormat();
|
2015-03-31 20:48:00 +03:00
|
|
|
}
|
2010-08-13 17:30:02 +04:00
|
|
|
|
2016-07-30 23:41:57 +03:00
|
|
|
SurfacePattern pattern(aSurface,
|
|
|
|
aRegion.GetExtendMode(),
|
|
|
|
Matrix::Translation(mDecoded.x, mDecoded.y));
|
|
|
|
target->FillRect(ToRect(aRegion.Intersect(available).Rect()), pattern);
|
2012-03-24 02:10:50 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SourceSurface> newsurf = target->Snapshot();
|
2016-07-31 00:49:03 +03:00
|
|
|
return SurfaceWithFormat(new gfxSurfaceDrawable(newsurf, mImageSize),
|
2015-03-31 20:48:00 +03:00
|
|
|
target->GetFormat());
|
2010-08-13 17:30:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Not tiling, and we have a surface, so we can account for
|
2016-07-31 00:49:03 +03:00
|
|
|
// a partial decode just by twiddling parameters.
|
|
|
|
aRegion = aRegion.Intersect(available);
|
2015-09-23 21:49:05 +03:00
|
|
|
IntSize availableSize(mDecoded.width, mDecoded.height);
|
2016-07-31 00:49:03 +03:00
|
|
|
|
2014-03-02 20:17:26 +04:00
|
|
|
return SurfaceWithFormat(new gfxSurfaceDrawable(aSurface, availableSize),
|
2010-08-13 17:30:27 +04: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-21 05:50:15 +04:00
|
|
|
}
|
|
|
|
|
2014-08-23 00:12:38 +04:00
|
|
|
bool imgFrame::Draw(gfxContext* aContext, const ImageRegion& aRegion,
|
2017-01-03 08:53:22 +03:00
|
|
|
SamplingFilter aSamplingFilter, uint32_t aImageFlags,
|
|
|
|
float aOpacity)
|
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 05:50:15 +04:00
|
|
|
{
|
2014-05-24 01:12:29 +04:00
|
|
|
PROFILER_LABEL("imgFrame", "Draw",
|
|
|
|
js::ProfileEntry::Category::GRAPHICS);
|
|
|
|
|
2015-01-08 11:04:31 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2014-08-23 00:12:38 +04:00
|
|
|
NS_ASSERTION(!aRegion.Rect().IsEmpty(), "Drawing empty region!");
|
|
|
|
NS_ASSERTION(!aRegion.IsRestricted() ||
|
|
|
|
!aRegion.Rect().Intersect(aRegion.Restriction()).IsEmpty(),
|
|
|
|
"We must be allowed to sample *some* source pixels!");
|
2016-07-31 00:49:03 +03:00
|
|
|
MOZ_ASSERT(mFrameRect.IsEqualEdges(IntRect(IntPoint(), mImageSize)),
|
|
|
|
"Directly drawing an image with a non-trivial frame rect!");
|
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 05:50:15 +04:00
|
|
|
|
2016-07-31 00:49:03 +03:00
|
|
|
if (mPalettedImageData) {
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Directly drawing a paletted image!");
|
|
|
|
return false;
|
|
|
|
}
|
2015-01-08 11:04:31 +03:00
|
|
|
|
2016-07-31 00:49:03 +03:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2014-11-27 00:22:10 +03:00
|
|
|
|
2016-09-15 14:53:12 +03:00
|
|
|
// Possibly convert this image into a GPU texture, this may also cause our
|
2017-01-18 21:31:20 +03:00
|
|
|
// mLockedSurface to be released and the OS to release the underlying memory.
|
2016-09-15 14:53:12 +03:00
|
|
|
Optimize(aContext->GetDrawTarget());
|
|
|
|
|
2016-03-24 03:31:42 +03:00
|
|
|
bool doPartialDecode = !AreAllPixelsWritten();
|
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 05:50:15 +04:00
|
|
|
|
2016-08-18 22:43:16 +03:00
|
|
|
RefPtr<SourceSurface> surf = GetSourceSurfaceInternal();
|
2016-07-30 23:41:57 +03:00
|
|
|
if (!surf) {
|
2014-04-20 05:28:38 +04:00
|
|
|
return false;
|
2014-03-02 20:17:26 +04:00
|
|
|
}
|
|
|
|
|
2014-11-27 00:22:10 +03:00
|
|
|
gfxRect imageRect(0, 0, mImageSize.width, mImageSize.height);
|
2014-08-23 00:12:38 +04:00
|
|
|
bool doTile = !imageRect.Contains(aRegion.Rect()) &&
|
2012-04-18 02:04:15 +04:00
|
|
|
!(aImageFlags & imgIContainer::FLAG_CLAMP);
|
2015-11-23 19:17:35 +03:00
|
|
|
|
2014-08-23 00:12:38 +04:00
|
|
|
ImageRegion region(aRegion);
|
2010-08-13 17:30:02 +04:00
|
|
|
SurfaceWithFormat surfaceResult =
|
2016-07-31 00:49:03 +03:00
|
|
|
SurfaceForDrawing(doPartialDecode, doTile, region, 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-21 05:50:15 +04:00
|
|
|
|
2010-08-13 17:30:02 +04:00
|
|
|
if (surfaceResult.IsValid()) {
|
2010-08-13 17:30:27 +04:00
|
|
|
gfxUtils::DrawPixelSnapped(aContext, surfaceResult.mDrawable,
|
2014-08-23 00:12:38 +04:00
|
|
|
imageRect.Size(), region, surfaceResult.mFormat,
|
2017-01-03 08:53:22 +03:00
|
|
|
aSamplingFilter, aImageFlags, aOpacity);
|
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 05:50:15 +04:00
|
|
|
}
|
2017-02-08 23:48:59 +03:00
|
|
|
|
|
|
|
// Image got put into a painted layer, it will not be shared with another
|
|
|
|
// process.
|
|
|
|
MarkSurfaceShared(surf);
|
2014-03-02 20:17:26 +04: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-21 05:50:15 +04:00
|
|
|
}
|
|
|
|
|
2015-01-08 11:04:31 +03:00
|
|
|
nsresult
|
|
|
|
imgFrame::ImageUpdated(const nsIntRect& aUpdateRect)
|
|
|
|
{
|
2015-01-12 06:28:02 +03:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2015-01-08 11:04:31 +03:00
|
|
|
return ImageUpdatedInternal(aUpdateRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
imgFrame::ImageUpdatedInternal(const nsIntRect& aUpdateRect)
|
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 05:50:15 +04:00
|
|
|
{
|
2015-01-12 06:28:02 +03:00
|
|
|
mMonitor.AssertCurrentThreadOwns();
|
2013-07-04 22:45:57 +04: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 05:50:15 +04:00
|
|
|
mDecoded.UnionRect(mDecoded, aUpdateRect);
|
|
|
|
|
2016-05-27 08:19:38 +03:00
|
|
|
// Clamp to the frame rect to ensure that decoder bugs don't result in a
|
|
|
|
// decoded rect that extends outside the bounds of the frame rect.
|
|
|
|
mDecoded.IntersectRect(mDecoded, mFrameRect);
|
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 05:50:15 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-01-08 11:04:31 +03:00
|
|
|
void
|
2015-01-12 06:28:02 +03:00
|
|
|
imgFrame::Finish(Opacity aFrameOpacity /* = Opacity::SOME_TRANSPARENCY */,
|
|
|
|
DisposalMethod aDisposalMethod /* = DisposalMethod::KEEP */,
|
2016-07-20 02:22:34 +03:00
|
|
|
FrameTimeout aTimeout
|
|
|
|
/* = FrameTimeout::FromRawMilliseconds(0) */,
|
2016-06-25 01:20:32 +03:00
|
|
|
BlendMethod aBlendMethod /* = BlendMethod::OVER */,
|
2017-02-08 23:48:59 +03:00
|
|
|
const Maybe<IntRect>& aBlendRect /* = Nothing() */,
|
|
|
|
bool aFinalize /* = true */)
|
2015-01-08 11:04:31 +03:00
|
|
|
{
|
2015-01-12 06:28:02 +03:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2015-01-08 11:04:31 +03:00
|
|
|
MOZ_ASSERT(mLockCount > 0, "Image data should be locked");
|
|
|
|
|
|
|
|
mDisposalMethod = aDisposalMethod;
|
2016-07-20 02:22:34 +03:00
|
|
|
mTimeout = aTimeout;
|
2015-01-08 11:04:31 +03:00
|
|
|
mBlendMethod = aBlendMethod;
|
2016-06-25 01:20:32 +03:00
|
|
|
mBlendRect = aBlendRect;
|
2015-01-08 11:04:31 +03:00
|
|
|
ImageUpdatedInternal(GetRect());
|
2017-02-08 23:48:59 +03:00
|
|
|
|
|
|
|
if (aFinalize) {
|
|
|
|
FinalizeSurfaceInternal();
|
|
|
|
}
|
|
|
|
|
2016-03-24 03:31:42 +03:00
|
|
|
mFinished = true;
|
|
|
|
|
|
|
|
// The image is now complete, wake up anyone who's waiting.
|
|
|
|
mMonitor.NotifyAll();
|
2015-01-08 11:04:31 +03:00
|
|
|
}
|
|
|
|
|
2015-03-31 20:48:00 +03: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-21 05:50:15 +04:00
|
|
|
{
|
2015-01-12 06:28:02 +03:00
|
|
|
mMonitor.AssertCurrentThreadOwns();
|
2015-01-08 11:04:31 +03:00
|
|
|
|
2017-01-18 21:31:20 +03:00
|
|
|
if (mRawSurface) {
|
2016-05-27 08:19:38 +03:00
|
|
|
return mFrameRect.width * BytesPerPixel(mFormat);
|
2015-03-31 20:48:00 +03:00
|
|
|
}
|
2014-02-25 07:37:51 +04:00
|
|
|
|
2015-03-31 20:48:00 +03:00
|
|
|
if (mPaletteDepth) {
|
2016-05-27 08:19:38 +03:00
|
|
|
return mFrameRect.width;
|
2015-03-31 20:48:00 +03:00
|
|
|
}
|
2010-05-22 08:10:14 +04: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-21 05:50:15 +04:00
|
|
|
}
|
|
|
|
|
2015-03-31 20:48:00 +03: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-21 05:50:15 +04:00
|
|
|
{
|
2016-05-27 08:19:38 +03:00
|
|
|
return GetImageBytesPerRow() * mFrameRect.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-21 05:50:15 +04:00
|
|
|
}
|
|
|
|
|
2015-01-08 11:04:31 +03:00
|
|
|
void
|
|
|
|
imgFrame::GetImageData(uint8_t** aData, uint32_t* aLength) 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 05:50:15 +04:00
|
|
|
{
|
2015-01-12 06:28:02 +03:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2015-01-08 11:04:31 +03:00
|
|
|
GetImageDataInternal(aData, aLength);
|
|
|
|
}
|
2012-09-26 19:33:06 +04:00
|
|
|
|
2015-01-08 11:04:31 +03:00
|
|
|
void
|
|
|
|
imgFrame::GetImageDataInternal(uint8_t** aData, uint32_t* aLength) const
|
|
|
|
{
|
2015-01-12 06:28:02 +03:00
|
|
|
mMonitor.AssertCurrentThreadOwns();
|
2015-01-08 11:04:31 +03:00
|
|
|
MOZ_ASSERT(mLockCount > 0, "Image data should be locked");
|
|
|
|
|
2017-01-18 21:31:20 +03:00
|
|
|
if (mLockedSurface) {
|
2017-02-08 23:48:59 +03:00
|
|
|
// TODO: This is okay for now because we only realloc shared surfaces on
|
|
|
|
// the main thread after decoding has finished, but if animations want to
|
|
|
|
// read frame data off the main thread, we will need to reconsider this.
|
2017-01-18 21:31:20 +03:00
|
|
|
*aData = mLockedSurface->GetData();
|
2015-03-31 20:48:00 +03:00
|
|
|
MOZ_ASSERT(*aData,
|
2017-01-18 21:31:20 +03:00
|
|
|
"mLockedSurface is non-null, but GetData is null in GetImageData");
|
2015-01-08 11:04:31 +03:00
|
|
|
} else if (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 05:50:15 +04:00
|
|
|
*aData = mPalettedImageData + PaletteDataLength();
|
2015-03-31 20:48:00 +03:00
|
|
|
MOZ_ASSERT(*aData,
|
|
|
|
"mPalettedImageData is non-null, but result is null in GetImageData");
|
2015-01-08 11:04:31 +03:00
|
|
|
} else {
|
2015-03-31 20:48:00 +03:00
|
|
|
MOZ_ASSERT(false,
|
2017-01-18 21:31:20 +03:00
|
|
|
"Have neither mLockedSurface nor mPalettedImageData in GetImageData");
|
2012-07-30 18:20:58 +04:00
|
|
|
*aData = nullptr;
|
2015-01-08 11:04:31 +03: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 05:50:15 +04:00
|
|
|
|
2015-01-08 11:04:31 +03:00
|
|
|
*aLength = GetImageDataLength();
|
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 05:50:15 +04:00
|
|
|
}
|
|
|
|
|
2015-03-31 20:48:00 +03:00
|
|
|
uint8_t*
|
|
|
|
imgFrame::GetImageData() const
|
2013-06-14 17:42:01 +04:00
|
|
|
{
|
2015-03-31 20:48:00 +03:00
|
|
|
uint8_t* data;
|
2013-06-14 17:42:01 +04:00
|
|
|
uint32_t length;
|
|
|
|
GetImageData(&data, &length);
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2015-03-31 20:48:00 +03: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-21 05:50:15 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04: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-21 05:50:15 +04:00
|
|
|
}
|
|
|
|
|
2015-03-31 20:48:00 +03: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-21 05:50:15 +04:00
|
|
|
{
|
2015-01-08 11:04:31 +03:00
|
|
|
AssertImageDataLocked();
|
2012-09-26 19:33:06 +04: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 05:50:15 +04:00
|
|
|
if (!mPalettedImageData) {
|
2012-07-30 18:20:58 +04: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-21 05:50:15 +04:00
|
|
|
*length = 0;
|
|
|
|
} else {
|
2015-03-31 20:48:00 +03: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-21 05:50:15 +04:00
|
|
|
*length = PaletteDataLength();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-31 20:48:00 +03:00
|
|
|
uint32_t*
|
|
|
|
imgFrame::GetPaletteData() const
|
2013-06-14 17:42:01 +04:00
|
|
|
{
|
|
|
|
uint32_t* data;
|
|
|
|
uint32_t length;
|
|
|
|
GetPaletteData(&data, &length);
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2015-01-08 11:04:31 +03:00
|
|
|
nsresult
|
|
|
|
imgFrame::LockImageData()
|
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 05:50:15 +04:00
|
|
|
{
|
2015-01-12 06:28:02 +03:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2013-05-24 17:52:34 +04:00
|
|
|
|
2015-01-08 11:04:31 +03:00
|
|
|
MOZ_ASSERT(mLockCount >= 0, "Unbalanced locks and unlocks");
|
2012-09-26 19:33:06 +04:00
|
|
|
if (mLockCount < 0) {
|
2012-09-29 02:00:28 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
2012-09-26 19:33:06 +04:00
|
|
|
}
|
2012-09-26 19:33:06 +04:00
|
|
|
|
|
|
|
mLockCount++;
|
|
|
|
|
|
|
|
// If we are not the first lock, there's nothing to do.
|
|
|
|
if (mLockCount != 1) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-01-18 21:31:20 +03:00
|
|
|
// If we're the first lock, but have the locked surface, we're OK.
|
|
|
|
if (mLockedSurface) {
|
2015-01-08 11:04:31 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-09-26 19:33:06 +04:00
|
|
|
// Paletted images don't have surfaces, so there's nothing to do.
|
2015-01-08 11:04:31 +03:00
|
|
|
if (mPalettedImageData) {
|
2012-09-26 19:33:06 +04:00
|
|
|
return NS_OK;
|
2015-01-08 11:04:31 +03:00
|
|
|
}
|
|
|
|
|
2015-09-20 02:21:02 +03:00
|
|
|
MOZ_ASSERT_UNREACHABLE("It's illegal to re-lock an optimized imgFrame");
|
|
|
|
return NS_ERROR_FAILURE;
|
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 05:50:15 +04:00
|
|
|
}
|
|
|
|
|
2015-01-08 11:04:31 +03:00
|
|
|
void
|
|
|
|
imgFrame::AssertImageDataLocked() 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 05:50:15 +04:00
|
|
|
{
|
2015-01-08 11:04:31 +03:00
|
|
|
#ifdef DEBUG
|
2015-01-12 06:28:02 +03:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2015-01-08 11:04:31 +03:00
|
|
|
MOZ_ASSERT(mLockCount > 0, "Image data should be locked");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
imgFrame::UnlockImageData()
|
|
|
|
{
|
2015-01-12 06:28:02 +03:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2013-05-24 17:52:34 +04:00
|
|
|
|
2014-09-19 06:26:01 +04:00
|
|
|
MOZ_ASSERT(mLockCount > 0, "Unlocking an unlocked image!");
|
|
|
|
if (mLockCount <= 0) {
|
2012-09-26 19:33:06 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2016-03-24 03:31:42 +03:00
|
|
|
MOZ_ASSERT(mLockCount > 1 || mFinished || mAborted,
|
|
|
|
"Should have Finish()'d or aborted before unlocking");
|
2015-01-12 06:28:02 +03:00
|
|
|
|
2014-09-19 06:26:01 +04:00
|
|
|
mLockCount--;
|
2014-02-25 07:37:51 +04: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 05:50:15 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-09-19 06:26:01 +04:00
|
|
|
void
|
|
|
|
imgFrame::SetOptimizable()
|
|
|
|
{
|
2015-01-08 11:04:31 +03:00
|
|
|
AssertImageDataLocked();
|
2015-07-31 17:29:10 +03:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2014-09-19 06:26:01 +04:00
|
|
|
mOptimizable = true;
|
2014-02-25 07:37:51 +04:00
|
|
|
}
|
|
|
|
|
2017-02-08 23:48:59 +03:00
|
|
|
void
|
|
|
|
imgFrame::FinalizeSurface()
|
|
|
|
{
|
|
|
|
MonitorAutoLock lock(mMonitor);
|
|
|
|
FinalizeSurfaceInternal();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
imgFrame::FinalizeSurfaceInternal()
|
|
|
|
{
|
|
|
|
mMonitor.AssertCurrentThreadOwns();
|
|
|
|
|
|
|
|
// Not all images will have mRawSurface to finalize (i.e. paletted images).
|
|
|
|
if (!mRawSurface || mRawSurface->GetType() != SurfaceType::DATA_SHARED) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto sharedSurf = static_cast<SourceSurfaceSharedData*>(mRawSurface.get());
|
|
|
|
sharedSurf->Finalize();
|
|
|
|
}
|
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
already_AddRefed<SourceSurface>
|
2016-08-18 22:43:16 +03:00
|
|
|
imgFrame::GetSourceSurface()
|
2014-04-20 05:28:38 +04:00
|
|
|
{
|
2015-01-12 06:28:02 +03:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2016-08-18 22:43:16 +03:00
|
|
|
return GetSourceSurfaceInternal();
|
2015-01-08 11:04:31 +03:00
|
|
|
}
|
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
already_AddRefed<SourceSurface>
|
2016-08-18 22:43:16 +03:00
|
|
|
imgFrame::GetSourceSurfaceInternal()
|
2015-01-08 11:04:31 +03:00
|
|
|
{
|
2015-01-12 06:28:02 +03:00
|
|
|
mMonitor.AssertCurrentThreadOwns();
|
2015-01-08 11:04:31 +03:00
|
|
|
|
2014-04-20 05:28:38 +04:00
|
|
|
if (mOptSurface) {
|
2015-03-31 20:48:00 +03:00
|
|
|
if (mOptSurface->IsValid()) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SourceSurface> surf(mOptSurface);
|
2015-05-01 16:14:16 +03:00
|
|
|
return surf.forget();
|
2015-03-31 20:48:00 +03:00
|
|
|
} else {
|
2014-04-20 05:28:38 +04:00
|
|
|
mOptSurface = nullptr;
|
2015-03-31 20:48:00 +03:00
|
|
|
}
|
2014-04-20 05:28:38 +04:00
|
|
|
}
|
|
|
|
|
2017-01-18 21:31:20 +03:00
|
|
|
if (mLockedSurface) {
|
|
|
|
RefPtr<SourceSurface> surf(mLockedSurface);
|
2015-05-01 16:14:16 +03:00
|
|
|
return surf.forget();
|
2015-03-31 20:48:00 +03:00
|
|
|
}
|
2014-04-20 05:28:38 +04:00
|
|
|
|
2017-02-08 18:51:08 +03:00
|
|
|
if (!mRawSurface) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-01-18 21:31:20 +03:00
|
|
|
return CreateLockedSurface(mRawSurface, mFrameRect.Size(), mFormat);
|
2014-04-20 05:28:38 +04:00
|
|
|
}
|
|
|
|
|
2015-01-08 11:04:31 +03:00
|
|
|
AnimationData
|
|
|
|
imgFrame::GetAnimationData() 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 05:50:15 +04:00
|
|
|
{
|
2015-01-12 06:28:02 +03:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2015-01-08 11:04:31 +03:00
|
|
|
MOZ_ASSERT(mLockCount > 0, "Image data should be 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-21 05:50:15 +04:00
|
|
|
|
2015-01-08 11:04:31 +03:00
|
|
|
uint8_t* data;
|
|
|
|
if (mPalettedImageData) {
|
|
|
|
data = mPalettedImageData;
|
|
|
|
} else {
|
|
|
|
uint32_t length;
|
|
|
|
GetImageDataInternal(&data, &length);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasAlpha = mFormat == SurfaceFormat::B8G8R8A8;
|
|
|
|
|
|
|
|
return AnimationData(data, PaletteDataLength(), mTimeout, GetRect(),
|
2016-06-25 01:20:32 +03:00
|
|
|
mBlendMethod, mBlendRect, mDisposalMethod, hasAlpha);
|
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 05:50:15 +04:00
|
|
|
}
|
|
|
|
|
2015-01-12 06:28:02 +03:00
|
|
|
void
|
|
|
|
imgFrame::Abort()
|
|
|
|
{
|
|
|
|
MonitorAutoLock lock(mMonitor);
|
|
|
|
|
|
|
|
mAborted = true;
|
|
|
|
|
|
|
|
// Wake up anyone who's waiting.
|
2015-01-16 02:11:36 +03:00
|
|
|
mMonitor.NotifyAll();
|
2015-01-12 06:28:02 +03:00
|
|
|
}
|
|
|
|
|
2016-04-01 20:44:17 +03:00
|
|
|
bool
|
|
|
|
imgFrame::IsAborted() const
|
|
|
|
{
|
|
|
|
MonitorAutoLock lock(mMonitor);
|
|
|
|
return mAborted;
|
|
|
|
}
|
|
|
|
|
2015-01-08 11:04:31 +03:00
|
|
|
bool
|
2016-03-24 03:31:42 +03:00
|
|
|
imgFrame::IsFinished() 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 05:50:15 +04:00
|
|
|
{
|
2015-01-12 06:28:02 +03:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2016-03-24 03:31:42 +03:00
|
|
|
return mFinished;
|
2015-01-12 06:28:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-03-24 03:31:42 +03:00
|
|
|
imgFrame::WaitUntilFinished() const
|
2015-01-12 06:28:02 +03:00
|
|
|
{
|
|
|
|
MonitorAutoLock lock(mMonitor);
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
// Return if we're aborted or complete.
|
2016-03-24 03:31:42 +03:00
|
|
|
if (mAborted || mFinished) {
|
2015-01-12 06:28:02 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Not complete yet, so we'll have to wait.
|
|
|
|
mMonitor.Wait();
|
|
|
|
}
|
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 05:50:15 +04:00
|
|
|
}
|
2009-11-13 02:18:40 +03:00
|
|
|
|
2015-01-08 11:04:31 +03:00
|
|
|
bool
|
2016-03-24 03:31:42 +03:00
|
|
|
imgFrame::AreAllPixelsWritten() const
|
2012-03-24 02:10:50 +04:00
|
|
|
{
|
2015-01-12 06:28:02 +03:00
|
|
|
mMonitor.AssertCurrentThreadOwns();
|
2016-05-27 08:19:38 +03:00
|
|
|
return mDecoded.IsEqualInterior(mFrameRect);
|
2012-03-24 02:10:50 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool imgFrame::GetCompositingFailed() const
|
2009-11-13 02:18:40 +03:00
|
|
|
{
|
2015-01-08 11:04:31 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2009-11-13 02:18:40 +03:00
|
|
|
return mCompositingFailed;
|
|
|
|
}
|
|
|
|
|
2015-03-31 20:48:00 +03:00
|
|
|
void
|
|
|
|
imgFrame::SetCompositingFailed(bool val)
|
2009-11-13 02:18:40 +03:00
|
|
|
{
|
2015-01-08 11:04:31 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2009-11-13 02:18:40 +03:00
|
|
|
mCompositingFailed = val;
|
|
|
|
}
|
2010-03-12 13:08:25 +03:00
|
|
|
|
2015-07-29 07:02:45 +03:00
|
|
|
void
|
|
|
|
imgFrame::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
|
|
|
size_t& aHeapSizeOut,
|
2017-02-22 17:30:22 +03:00
|
|
|
size_t& aNonHeapSizeOut,
|
|
|
|
size_t& aSharedHandlesOut) const
|
2010-05-22 08:10:14 +04:00
|
|
|
{
|
2015-01-12 06:28:02 +03:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2015-01-08 11:04:31 +03:00
|
|
|
|
2015-07-29 07:02:45 +03:00
|
|
|
if (mPalettedImageData) {
|
|
|
|
aHeapSizeOut += aMallocSizeOf(mPalettedImageData);
|
2014-02-25 07:37:51 +04:00
|
|
|
}
|
2017-01-18 21:31:20 +03:00
|
|
|
if (mLockedSurface) {
|
|
|
|
aHeapSizeOut += aMallocSizeOf(mLockedSurface);
|
2010-05-22 08:10:14 +04:00
|
|
|
}
|
2015-07-29 07:02:45 +03:00
|
|
|
if (mOptSurface) {
|
|
|
|
aHeapSizeOut += aMallocSizeOf(mOptSurface);
|
2014-02-25 07:37:51 +04:00
|
|
|
}
|
2017-01-18 21:31:20 +03:00
|
|
|
if (mRawSurface) {
|
|
|
|
aHeapSizeOut += aMallocSizeOf(mRawSurface);
|
|
|
|
mRawSurface->AddSizeOfExcludingThis(aMallocSizeOf, aHeapSizeOut,
|
|
|
|
aNonHeapSizeOut);
|
2017-02-22 17:30:22 +03:00
|
|
|
|
|
|
|
if (mRawSurface->GetType() == SurfaceType::DATA_SHARED) {
|
|
|
|
auto sharedSurface =
|
|
|
|
static_cast<SourceSurfaceSharedData*>(mRawSurface.get());
|
|
|
|
if (sharedSurface->CanShare()) {
|
|
|
|
++aSharedHandlesOut;
|
|
|
|
}
|
|
|
|
}
|
2014-04-15 09:24:01 +04:00
|
|
|
}
|
2010-05-22 08:10:14 +04:00
|
|
|
}
|
2014-07-10 19:00:31 +04:00
|
|
|
|
|
|
|
} // namespace image
|
|
|
|
} // namespace mozilla
|