2012-12-19 05:59:30 +00: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 11:12:37 +00: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 01:50:15 +00:00
|
|
|
|
|
|
|
#include "imgFrame.h"
|
2014-08-22 20:12:38 +00:00
|
|
|
#include "ImageRegion.h"
|
2014-09-23 22:32:19 +00: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 01:50:15 +00:00
|
|
|
|
|
|
|
#include "prenv.h"
|
|
|
|
|
2014-02-09 08:04:38 +00: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 01:50:15 +00:00
|
|
|
#include "gfxPlatform.h"
|
2017-02-13 21:34:54 +00:00
|
|
|
#include "gfxPrefs.h"
|
2010-08-13 13:30:02 +00:00
|
|
|
#include "gfxUtils.h"
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
|
2013-03-18 14:25:50 +00:00
|
|
|
#include "GeckoProfiler.h"
|
2014-11-28 03:55:57 +00:00
|
|
|
#include "MainThreadUtils.h"
|
2016-06-25 06:22:29 +00:00
|
|
|
#include "mozilla/CheckedInt.h"
|
2018-03-14 18:19:13 +00:00
|
|
|
#include "mozilla/gfx/gfxVars.h"
|
2016-06-25 06:22:29 +00:00
|
|
|
#include "mozilla/gfx/Tools.h"
|
2018-02-22 19:26:29 +00:00
|
|
|
#include "mozilla/gfx/SourceSurfaceRawData.h"
|
2017-02-08 20:48:59 +00:00
|
|
|
#include "mozilla/layers/SourceSurfaceSharedData.h"
|
2017-01-18 18:31:20 +00:00
|
|
|
#include "mozilla/layers/SourceSurfaceVolatileData.h"
|
2016-06-25 06:22:29 +00:00
|
|
|
#include "mozilla/Likely.h"
|
2013-06-23 12:03:39 +00:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2013-09-07 02:15:49 +00:00
|
|
|
#include "nsMargin.h"
|
2015-01-08 08:04:31 +00: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 01:50:15 +00:00
|
|
|
|
2014-07-10 15:00:31 +00:00
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
using namespace gfx;
|
|
|
|
|
|
|
|
namespace image {
|
2012-03-15 20:30:41 +00:00
|
|
|
|
2014-02-25 03:37:51 +00:00
|
|
|
static void
|
2017-01-18 18:31:20 +00:00
|
|
|
ScopedMapRelease(void* aMap)
|
2014-02-25 03:37:51 +00:00
|
|
|
{
|
2017-01-18 18:31:20 +00:00
|
|
|
delete static_cast<DataSourceSurface::ScopedMap*>(aMap);
|
2014-02-25 03:37:51 +00:00
|
|
|
}
|
|
|
|
|
2014-06-10 19:44:04 +00: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 14:00:52 +00:00
|
|
|
static already_AddRefed<DataSourceSurface>
|
2017-01-18 18:31:20 +00:00
|
|
|
CreateLockedSurface(DataSourceSurface *aSurface,
|
2014-04-20 01:28:38 +00:00
|
|
|
const IntSize& size,
|
|
|
|
SurfaceFormat format)
|
2014-02-25 03:37:51 +00:00
|
|
|
{
|
2017-02-08 20:48:59 +00: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 18:31:20 +00: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 03:37:51 +00:00
|
|
|
}
|
|
|
|
|
2017-01-18 18:31:20 +00:00
|
|
|
delete smap;
|
|
|
|
return nullptr;
|
2014-02-25 03:37:51 +00:00
|
|
|
}
|
|
|
|
|
2018-02-22 19:26:29 +00:00
|
|
|
static bool
|
|
|
|
ShouldUseHeap(const IntSize& aSize,
|
|
|
|
int32_t aStride,
|
|
|
|
bool aIsAnimated)
|
|
|
|
{
|
|
|
|
// On some platforms (i.e. Android), a volatile buffer actually keeps a file
|
|
|
|
// handle active. We would like to avoid too many since we could easily
|
|
|
|
// exhaust the pool. However, other platforms we do not have the file handle
|
|
|
|
// problem, and additionally we may avoid a superfluous memset since the
|
|
|
|
// volatile memory starts out as zero-filled. Hence the knobs below.
|
|
|
|
|
|
|
|
// For as long as an animated image is retained, its frames will never be
|
|
|
|
// released to let the OS purge volatile buffers.
|
|
|
|
if (aIsAnimated && gfxPrefs::ImageMemAnimatedUseHeap()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Lets us avoid too many small images consuming all of the handles. The
|
|
|
|
// actual allocation checks for overflow.
|
|
|
|
int32_t bufferSize = (aStride * aSize.width) / 1024;
|
|
|
|
if (bufferSize < gfxPrefs::ImageMemVolatileMinThresholdKB()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-01-18 18:31:20 +00:00
|
|
|
static already_AddRefed<DataSourceSurface>
|
|
|
|
AllocateBufferForImage(const IntSize& size,
|
|
|
|
SurfaceFormat format,
|
|
|
|
bool aIsAnimated = false)
|
2014-02-25 03:37:51 +00:00
|
|
|
{
|
2017-08-31 10:38:55 +00:00
|
|
|
int32_t stride = VolatileSurfaceStride(size, format);
|
|
|
|
|
2018-02-22 19:26:29 +00:00
|
|
|
if (ShouldUseHeap(size, stride, aIsAnimated)) {
|
|
|
|
RefPtr<SourceSurfaceAlignedRawData> newSurf =
|
|
|
|
new SourceSurfaceAlignedRawData();
|
|
|
|
if (newSurf->Init(size, format, false, 0, stride)) {
|
|
|
|
return newSurf.forget();
|
|
|
|
}
|
2017-08-16 12:57:40 +00:00
|
|
|
}
|
|
|
|
|
2018-02-16 14:50:40 +00:00
|
|
|
if (!aIsAnimated && gfxVars::GetUseWebRenderOrDefault()
|
|
|
|
&& gfxPrefs::ImageMemShared()) {
|
2017-02-08 20:48:59 +00:00
|
|
|
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 17:48:00 +00:00
|
|
|
}
|
2014-02-25 03:37:51 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-07-01 01:59:29 +00:00
|
|
|
static bool
|
2017-01-18 18:31:20 +00:00
|
|
|
ClearSurface(DataSourceSurface* aSurface, const IntSize& aSize, SurfaceFormat aFormat)
|
2016-07-01 01:59:29 +00:00
|
|
|
{
|
2017-01-18 18:31:20 +00:00
|
|
|
int32_t stride = aSurface->Stride();
|
|
|
|
uint8_t* data = aSurface->GetData();
|
|
|
|
MOZ_ASSERT(data);
|
2016-07-01 01:59:29 +00: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 18:31:20 +00:00
|
|
|
memset(data, 0xFF, stride * aSize.height);
|
|
|
|
} else if (aSurface->OnHeap()) {
|
2016-07-01 01:59:29 +00: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 18:31:20 +00:00
|
|
|
memset(data, 0, stride * aSize.height);
|
2016-07-01 01:59:29 +00: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 01:50:15 +00:00
|
|
|
// Returns true if an image of aWidth x aHeight is allowed and legal.
|
2015-03-31 17:48:00 +00: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 01:50:15 +00:00
|
|
|
{
|
|
|
|
// reject over-wide or over-tall images
|
2012-08-22 15:56:38 +00:00
|
|
|
const int32_t k64KLimit = 0x0000FFFF;
|
2012-10-26 13:32:10 +00: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 01:50:15 +00:00
|
|
|
NS_WARNING("image too big");
|
2011-10-17 14:59:28 +00: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 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2011-07-01 17:03:47 +00:00
|
|
|
// protect against invalid sizes
|
2012-10-26 13:32:10 +00:00
|
|
|
if (MOZ_UNLIKELY(aHeight <= 0 || aWidth <= 0)) {
|
2011-10-17 14:59:28 +00: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 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// check to make sure we don't overflow a 32-bit
|
2013-10-02 14:44:53 +00: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 01:50:15 +00:00
|
|
|
NS_WARNING("width or height too large");
|
2011-10-17 14:59:28 +00: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 01:50:15 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00: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 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2014-11-26 21:22:10 +00:00
|
|
|
static bool AllowedImageAndFrameDimensions(const nsIntSize& aImageSize,
|
|
|
|
const nsIntRect& aFrameRect)
|
|
|
|
{
|
|
|
|
if (!AllowedImageSize(aImageSize.width, aImageSize.height)) {
|
|
|
|
return false;
|
|
|
|
}
|
2017-08-14 12:29:56 +00:00
|
|
|
if (!AllowedImageSize(aFrameRect.Width(), aFrameRect.Height())) {
|
2014-11-26 21:22:10 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nsIntRect imageRect(0, 0, aImageSize.width, aImageSize.height);
|
|
|
|
if (!imageRect.Contains(aFrameRect)) {
|
2015-02-07 11:51:40 +00:00
|
|
|
NS_WARNING("Animated image frame does not fit inside bounds of image");
|
2014-11-26 21:22:10 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-01-08 08:04:31 +00:00
|
|
|
imgFrame::imgFrame()
|
2015-01-12 03:28:02 +00:00
|
|
|
: mMonitor("imgFrame")
|
2015-01-08 08:04:31 +00:00
|
|
|
, mDecoded(0, 0, 0, 0)
|
|
|
|
, mLockCount(0)
|
2015-01-12 03:28:02 +00:00
|
|
|
, mAborted(false)
|
2016-03-24 00:31:42 +00:00
|
|
|
, mFinished(false)
|
2015-07-31 14:29:10 +00:00
|
|
|
, mOptimizable(false)
|
2018-05-29 12:36:11 +00:00
|
|
|
, mTimeout(FrameTimeout::FromRawMilliseconds(100))
|
|
|
|
, mDisposalMethod(DisposalMethod::NOT_SPECIFIED)
|
|
|
|
, mBlendMethod(BlendMethod::OVER)
|
2018-06-14 05:21:37 +00:00
|
|
|
, mFormat(SurfaceFormat::UNKNOWN)
|
2015-01-08 08:04:31 +00: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 01:50:15 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
imgFrame::~imgFrame()
|
|
|
|
{
|
2015-01-12 03:28:02 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
MonitorAutoLock lock(mMonitor);
|
2016-03-24 00:31:42 +00:00
|
|
|
MOZ_ASSERT(mAborted || AreAllPixelsWritten());
|
|
|
|
MOZ_ASSERT(mAborted || mFinished);
|
2015-01-12 03:28:02 +00:00
|
|
|
#endif
|
|
|
|
|
2015-02-19 04:51:06 +00:00
|
|
|
free(mPalettedImageData);
|
2012-10-03 18:10:31 +00: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 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2014-09-14 22:22:45 +00:00
|
|
|
nsresult
|
2014-11-26 21:22:10 +00:00
|
|
|
imgFrame::InitForDecoder(const nsIntSize& aImageSize,
|
|
|
|
const nsIntRect& aRect,
|
2014-09-14 22:22:45 +00:00
|
|
|
SurfaceFormat aFormat,
|
2015-01-08 08:04:31 +00:00
|
|
|
uint8_t aPaletteDepth /* = 0 */,
|
2017-01-18 18:31:20 +00:00
|
|
|
bool aNonPremult /* = false */,
|
2018-05-29 12:36:11 +00:00
|
|
|
const Maybe<AnimationParams>& aAnimParams /* = Nothing() */)
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
{
|
2014-09-14 22:22:45 +00:00
|
|
|
// Assert for properties that should be verified by decoders,
|
|
|
|
// warn for properties related to bad content.
|
2014-11-26 21:22:10 +00:00
|
|
|
if (!AllowedImageAndFrameDimensions(aImageSize, aRect)) {
|
2013-05-22 09:10:38 +00:00
|
|
|
NS_WARNING("Should have legal image size");
|
2015-01-12 03:28:02 +00: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 01:50:15 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2013-05-22 09:10:38 +00:00
|
|
|
}
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
|
2015-03-29 14:59:08 +00:00
|
|
|
mImageSize = aImageSize;
|
2016-05-27 05:19:38 +00: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 01:50:15 +00:00
|
|
|
|
2018-05-29 12:36:11 +00:00
|
|
|
if (aAnimParams) {
|
|
|
|
mBlendRect = aAnimParams->mBlendRect;
|
|
|
|
mTimeout = aAnimParams->mTimeout;
|
|
|
|
mBlendMethod = aAnimParams->mBlendMethod;
|
|
|
|
mDisposalMethod = aAnimParams->mDisposalMethod;
|
|
|
|
} else {
|
|
|
|
mBlendRect = aRect;
|
|
|
|
}
|
|
|
|
|
2016-07-30 21:47:49 +00: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 01:50:15 +00:00
|
|
|
mFormat = aFormat;
|
|
|
|
mPaletteDepth = aPaletteDepth;
|
2015-01-08 08:04:31 +00: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 01:50:15 +00:00
|
|
|
|
|
|
|
if (aPaletteDepth != 0) {
|
|
|
|
// We're creating for a paletted image.
|
|
|
|
if (aPaletteDepth > 8) {
|
2013-05-22 09:10:38 +00:00
|
|
|
NS_WARNING("Should have legal palette depth");
|
2010-06-17 20:28:38 +00:00
|
|
|
NS_ERROR("This Depth is not supported");
|
2015-01-12 03:28:02 +00: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 01:50:15 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2015-01-08 08:04:31 +00: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 18:59:47 +00:00
|
|
|
size_t dataSize = PaletteDataLength() + mFrameRect.Area();
|
|
|
|
mPalettedImageData = static_cast<uint8_t*>(calloc(dataSize, sizeof(uint8_t)));
|
2015-03-31 17:48:00 +00:00
|
|
|
if (!mPalettedImageData) {
|
2016-06-01 18:59:47 +00:00
|
|
|
NS_WARNING("Call to calloc for paletted image data should succeed");
|
2015-03-31 17:48:00 +00:00
|
|
|
}
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
NS_ENSURE_TRUE(mPalettedImageData, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
} else {
|
2017-01-18 18:31:20 +00:00
|
|
|
MOZ_ASSERT(!mLockedSurface, "Called imgFrame::InitForDecoder() twice?");
|
2014-09-14 22:22:45 +00:00
|
|
|
|
2018-05-29 12:36:11 +00:00
|
|
|
bool postFirstFrame = aAnimParams && aAnimParams->mFrameNum > 0;
|
|
|
|
mRawSurface = AllocateBufferForImage(mFrameRect.Size(), mFormat, postFirstFrame);
|
2017-01-18 18:31:20 +00:00
|
|
|
if (!mRawSurface) {
|
2015-01-12 03:28:02 +00:00
|
|
|
mAborted = true;
|
2014-09-14 22:22:45 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2014-02-25 03:37:51 +00:00
|
|
|
}
|
2016-07-01 01:59:29 +00:00
|
|
|
|
2017-01-18 18:31:20 +00:00
|
|
|
mLockedSurface = CreateLockedSurface(mRawSurface, mFrameRect.Size(), mFormat);
|
|
|
|
if (!mLockedSurface) {
|
|
|
|
NS_WARNING("Failed to create LockedSurface");
|
2016-07-01 01:59:29 +00:00
|
|
|
mAborted = true;
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2017-02-14 03:28:45 +00:00
|
|
|
|
|
|
|
if (!ClearSurface(mRawSurface, mFrameRect.Size(), mFormat)) {
|
|
|
|
NS_WARNING("Could not clear allocated buffer");
|
|
|
|
mAborted = true;
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2014-09-14 22:22:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
imgFrame::InitWithDrawable(gfxDrawable* aDrawable,
|
|
|
|
const nsIntSize& aSize,
|
|
|
|
const SurfaceFormat aFormat,
|
2016-05-25 16:01:18 +00:00
|
|
|
SamplingFilter aSamplingFilter,
|
2016-09-15 11:53:12 +00:00
|
|
|
uint32_t aImageFlags,
|
|
|
|
gfx::BackendType aBackend)
|
2014-09-14 22:22:45 +00: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 03:28:02 +00:00
|
|
|
mAborted = true;
|
2014-09-14 22:22:45 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2015-03-29 14:59:08 +00:00
|
|
|
mImageSize = aSize;
|
2016-05-27 05:19:38 +00:00
|
|
|
mFrameRect = IntRect(IntPoint(0, 0), aSize);
|
2014-09-14 22:22:45 +00:00
|
|
|
|
|
|
|
mFormat = aFormat;
|
|
|
|
mPaletteDepth = 0;
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<DrawTarget> target;
|
2014-09-14 22:22:45 +00:00
|
|
|
|
2017-11-24 13:10:03 +00:00
|
|
|
bool canUseDataSurface = Factory::DoesBackendSupportDataDrawtarget(aBackend);
|
2014-09-14 22:22:45 +00:00
|
|
|
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 18:31:20 +00:00
|
|
|
MOZ_ASSERT(!mLockedSurface, "Called imgFrame::InitWithDrawable() twice?");
|
2014-09-14 22:22:45 +00:00
|
|
|
|
2017-01-18 18:31:20 +00:00
|
|
|
mRawSurface = AllocateBufferForImage(mFrameRect.Size(), mFormat);
|
|
|
|
if (!mRawSurface) {
|
2015-01-12 03:28:02 +00:00
|
|
|
mAborted = true;
|
2014-09-14 22:22:45 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
2017-01-18 18:31:20 +00:00
|
|
|
mLockedSurface = CreateLockedSurface(mRawSurface, mFrameRect.Size(), mFormat);
|
|
|
|
if (!mLockedSurface) {
|
|
|
|
NS_WARNING("Failed to create LockedSurface");
|
2015-01-12 03:28:02 +00:00
|
|
|
mAborted = true;
|
2014-09-14 22:22:45 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2016-07-01 01:59:29 +00:00
|
|
|
|
2017-01-18 18:31:20 +00:00
|
|
|
if (!ClearSurface(mRawSurface, mFrameRect.Size(), mFormat)) {
|
2016-07-01 01:59:29 +00:00
|
|
|
NS_WARNING("Could not clear allocated buffer");
|
|
|
|
mAborted = true;
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
2016-08-11 21:54:08 +00:00
|
|
|
target = gfxPlatform::CreateDrawTargetForData(
|
2017-01-18 18:31:20 +00:00
|
|
|
mLockedSurface->GetData(),
|
2016-08-11 21:54:08 +00:00
|
|
|
mFrameRect.Size(),
|
2017-01-18 18:31:20 +00:00
|
|
|
mLockedSurface->Stride(),
|
2016-08-11 21:54:08 +00:00
|
|
|
mFormat);
|
2014-09-14 22:22:45 +00: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 11:53:12 +00:00
|
|
|
if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(aBackend)) {
|
|
|
|
target = gfxPlatform::GetPlatform()->
|
|
|
|
CreateDrawTargetForBackend(aBackend, mFrameRect.Size(), mFormat);
|
|
|
|
} else {
|
|
|
|
target = gfxPlatform::GetPlatform()->
|
|
|
|
CreateOffscreenContentDrawTarget(mFrameRect.Size(), mFormat);
|
|
|
|
}
|
2014-09-14 22:22:45 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 19:18:11 +00:00
|
|
|
if (!target || !target->IsValid()) {
|
2015-01-12 03:28:02 +00:00
|
|
|
mAborted = true;
|
2014-09-14 22:22:45 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw using the drawable the caller provided.
|
2016-06-06 23:39:56 +00:00
|
|
|
RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(target);
|
2016-05-27 05:19:38 +00:00
|
|
|
MOZ_ASSERT(ctx); // Already checked the draw target above.
|
2017-06-28 15:41:21 +00:00
|
|
|
gfxUtils::DrawPixelSnapped(ctx, aDrawable, SizeDouble(mFrameRect.Size()),
|
2016-05-27 05:19:38 +00:00
|
|
|
ImageRegion::Create(ThebesRect(mFrameRect)),
|
2016-05-25 16:01:18 +00:00
|
|
|
mFormat, aSamplingFilter, aImageFlags);
|
2014-09-14 22:22:45 +00:00
|
|
|
|
2017-01-18 18:31:20 +00:00
|
|
|
if (canUseDataSurface && !mLockedSurface) {
|
2014-09-14 22:22:45 +00:00
|
|
|
NS_WARNING("Failed to create VolatileDataSourceSurface");
|
2015-01-12 03:28:02 +00:00
|
|
|
mAborted = true;
|
2014-09-14 22:22:45 +00: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 20:48:59 +00: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 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2015-01-12 03:28:02 +00:00
|
|
|
// If we reach this point, we should regard ourselves as complete.
|
|
|
|
mDecoded = GetRect();
|
2016-03-24 00:31:42 +00:00
|
|
|
mFinished = true;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
MonitorAutoLock lock(mMonitor);
|
|
|
|
MOZ_ASSERT(AreAllPixelsWritten());
|
|
|
|
#endif
|
2015-01-12 03:28:02 +00:00
|
|
|
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-03-31 17:48:00 +00:00
|
|
|
nsresult
|
2016-09-15 11:53:12 +00: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 01:50:15 +00:00
|
|
|
{
|
2013-05-24 13:52:34 +00:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2015-01-12 03:28:02 +00:00
|
|
|
mMonitor.AssertCurrentThreadOwns();
|
2017-07-06 12:00:35 +00:00
|
|
|
|
2016-09-15 11:53:12 +00:00
|
|
|
if (mLockCount > 0 || !mOptimizable) {
|
|
|
|
// Don't optimize right now.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-05-24 13:52:34 +00:00
|
|
|
|
2016-06-20 13:46:00 +00: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-23 22:32:19 +00:00
|
|
|
// Don't optimize during shutdown because gfxPlatform may not be available.
|
2015-03-31 17:48:00 +00:00
|
|
|
if (ShutdownTracker::ShutdownHasStarted()) {
|
2014-09-23 22:32:19 +00:00
|
|
|
return NS_OK;
|
2015-03-31 17:48:00 +00:00
|
|
|
}
|
2014-09-23 22:32:19 +00:00
|
|
|
|
2016-09-15 11:53:12 +00: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 01:50:15 +00:00
|
|
|
return NS_OK;
|
2015-03-31 17:48:00 +00:00
|
|
|
}
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
|
2016-07-30 20:41:57 +00: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 01:50:15 +00:00
|
|
|
return NS_OK;
|
2015-03-31 17:48:00 +00:00
|
|
|
}
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
|
2016-07-30 20:41:57 +00: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 17:48:00 +00:00
|
|
|
if (mNonPremult) {
|
2012-03-23 22:10:50 +00:00
|
|
|
return NS_OK;
|
2015-03-31 17:48:00 +00:00
|
|
|
}
|
2012-03-23 22:10:50 +00:00
|
|
|
|
2015-03-31 17:48:00 +00:00
|
|
|
mOptSurface = gfxPlatform::GetPlatform()
|
2017-01-18 18:31:20 +00:00
|
|
|
->ScreenReferenceDrawTarget()->OptimizeSourceSurface(mLockedSurface);
|
|
|
|
if (mOptSurface == mLockedSurface) {
|
2014-04-20 01:28:38 +00:00
|
|
|
mOptSurface = nullptr;
|
2015-03-31 17:48:00 +00:00
|
|
|
}
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
|
|
|
|
if (mOptSurface) {
|
2017-01-18 18:31:20 +00:00
|
|
|
// There's no reason to keep our original surface around if we have an
|
2016-08-09 21:47:26 +00:00
|
|
|
// optimized surface. Release our reference to it. This will leave
|
2017-01-18 18:31:20 +00: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 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2017-01-18 18:31:20 +00: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 11:53:12 +00:00
|
|
|
mOptimizable = false;
|
2014-09-19 02:26:01 +00:00
|
|
|
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-09-11 00:06:45 +00:00
|
|
|
DrawableFrameRef
|
|
|
|
imgFrame::DrawableRef()
|
|
|
|
{
|
|
|
|
return DrawableFrameRef(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
RawAccessFrameRef
|
2018-05-29 12:36:12 +00:00
|
|
|
imgFrame::RawAccessRef(bool aOnlyFinished /*= false*/)
|
2014-09-11 00:06:45 +00:00
|
|
|
{
|
2018-05-29 12:36:12 +00:00
|
|
|
return RawAccessFrameRef(this, aOnlyFinished);
|
2014-09-11 00:06:45 +00:00
|
|
|
}
|
|
|
|
|
2018-05-30 23:35:40 +00:00
|
|
|
void
|
|
|
|
imgFrame::SetRawAccessOnly()
|
|
|
|
{
|
|
|
|
AssertImageDataLocked();
|
|
|
|
|
|
|
|
// Lock our data and throw away the key.
|
|
|
|
LockImageData(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-13 13:30:02 +00:00
|
|
|
imgFrame::SurfaceWithFormat
|
2016-07-30 21:49:03 +00:00
|
|
|
imgFrame::SurfaceForDrawing(bool aDoPartialDecode,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aDoTile,
|
2014-08-22 20:12:38 +00:00
|
|
|
ImageRegion& aRegion,
|
2014-04-20 01:28:38 +00:00
|
|
|
SourceSurface* aSurface)
|
2010-08-13 13:30:02 +00:00
|
|
|
{
|
2015-01-08 08:04:31 +00:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2015-01-12 03:28:02 +00:00
|
|
|
mMonitor.AssertCurrentThreadOwns();
|
2015-01-08 08:04:31 +00:00
|
|
|
|
2016-07-30 21:49:03 +00:00
|
|
|
if (!aDoPartialDecode) {
|
|
|
|
return SurfaceWithFormat(new gfxSurfaceDrawable(aSurface, mImageSize),
|
2016-10-01 03:11:59 +00:00
|
|
|
mFormat);
|
2010-08-13 13:30:02 +00:00
|
|
|
}
|
|
|
|
|
2017-12-20 21:46:28 +00:00
|
|
|
gfxRect available = gfxRect(mDecoded.X(), mDecoded.Y(), mDecoded.Width(),
|
2017-08-14 12:29:56 +00:00
|
|
|
mDecoded.Height());
|
2010-08-13 13:30:02 +00:00
|
|
|
|
2016-07-30 20:41:57 +00:00
|
|
|
if (aDoTile) {
|
2010-08-13 13:30:02 +00: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 05:24:48 +00:00
|
|
|
RefPtr<DrawTarget> target =
|
2014-04-20 01:28:38 +00:00
|
|
|
gfxPlatform::GetPlatform()->
|
2016-07-30 21:49:03 +00:00
|
|
|
CreateOffscreenContentDrawTarget(mImageSize, SurfaceFormat::B8G8R8A8);
|
2015-03-31 17:48:00 +00:00
|
|
|
if (!target) {
|
2010-08-13 13:30:02 +00:00
|
|
|
return SurfaceWithFormat();
|
2015-03-31 17:48:00 +00:00
|
|
|
}
|
2010-08-13 13:30:02 +00:00
|
|
|
|
2016-07-30 20:41:57 +00:00
|
|
|
SurfacePattern pattern(aSurface,
|
|
|
|
aRegion.GetExtendMode(),
|
2017-12-20 21:46:28 +00:00
|
|
|
Matrix::Translation(mDecoded.X(), mDecoded.Y()));
|
2016-07-30 20:41:57 +00:00
|
|
|
target->FillRect(ToRect(aRegion.Intersect(available).Rect()), pattern);
|
2012-03-23 22:10:50 +00:00
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<SourceSurface> newsurf = target->Snapshot();
|
2016-07-30 21:49:03 +00:00
|
|
|
return SurfaceWithFormat(new gfxSurfaceDrawable(newsurf, mImageSize),
|
2015-03-31 17:48:00 +00:00
|
|
|
target->GetFormat());
|
2010-08-13 13:30:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Not tiling, and we have a surface, so we can account for
|
2016-07-30 21:49:03 +00:00
|
|
|
// a partial decode just by twiddling parameters.
|
|
|
|
aRegion = aRegion.Intersect(available);
|
2017-08-14 12:29:56 +00:00
|
|
|
IntSize availableSize(mDecoded.Width(), mDecoded.Height());
|
2016-07-30 21:49:03 +00:00
|
|
|
|
2014-03-02 16:17:26 +00:00
|
|
|
return SurfaceWithFormat(new gfxSurfaceDrawable(aSurface, availableSize),
|
2010-08-13 13:30:27 +00: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 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2014-08-22 20:12:38 +00:00
|
|
|
bool imgFrame::Draw(gfxContext* aContext, const ImageRegion& aRegion,
|
2017-01-03 05:53:22 +00: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 01:50:15 +00:00
|
|
|
{
|
Bug 1375392 - Tweak the PROFILER_LABEL* macros. r=mstange.
This patch makes the following changes to the macros.
- Removes PROFILER_LABEL_FUNC. It's only suitable for use in functions outside
classes, due to PROFILER_FUNCTION_NAME not getting class names, and it was
mostly misused.
- Removes PROFILER_FUNCTION_NAME. It's no longer used, and __func__ is
universally available now anyway.
- Combines the first two string literal arguments of PROFILER_LABEL and
PROFILER_LABEL_DYNAMIC into a single argument. There was no good reason for
them to be separate, and it forced a '::' in the label, which isn't always
appropriate. Also, the meaning of the "name_space" argument was interpreted
in an interesting variety of ways.
- Adds an "AUTO_" prefix to PROFILER_LABEL and PROFILER_LABEL_DYNAMIC, to make
it clearer they construct RAII objects rather than just being function calls.
(I myself have screwed up the scoping because of this in the past.)
- Fills in the 'js::ProfileEntry::Category::' qualifier within the macro, so
the caller doesn't need to. This makes a *lot* more of the uses fit onto a
single line.
The patch also makes the following changes to the macro uses (beyond those
required by the changes described above).
- Fixes a bunch of labels that had gotten out of sync with the name of the
class and/or function that encloses them.
- Removes a useless PROFILER_LABEL use within a trivial scope in
EventStateManager::DispatchMouseOrPointerEvent(). It clearly wasn't serving
any useful purpose. It also serves as extra evidence that the AUTO_ prefix is
a good idea.
- Tweaks DecodePool::SyncRunIf{Preferred,Possible} so that the labelling is
done within them, instead of at their callsites, because that's a more
standard way of doing things.
--HG--
extra : rebase_source : 318d1bc6fc1425a94aacbf489dd46e4f83211de4
2017-06-22 07:08:53 +00:00
|
|
|
AUTO_PROFILER_LABEL("imgFrame::Draw", GRAPHICS);
|
2014-05-23 21:12:29 +00:00
|
|
|
|
2015-01-08 08:04:31 +00:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2014-08-22 20:12:38 +00: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-30 21:49:03 +00: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 01:50:15 +00:00
|
|
|
|
2016-07-30 21:49:03 +00:00
|
|
|
if (mPalettedImageData) {
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Directly drawing a paletted image!");
|
|
|
|
return false;
|
|
|
|
}
|
2015-01-08 08:04:31 +00:00
|
|
|
|
2016-07-30 21:49:03 +00:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2014-11-26 21:22:10 +00:00
|
|
|
|
2016-09-15 11:53:12 +00:00
|
|
|
// Possibly convert this image into a GPU texture, this may also cause our
|
2017-01-18 18:31:20 +00:00
|
|
|
// mLockedSurface to be released and the OS to release the underlying memory.
|
2016-09-15 11:53:12 +00:00
|
|
|
Optimize(aContext->GetDrawTarget());
|
|
|
|
|
2016-03-24 00:31:42 +00: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 01:50:15 +00:00
|
|
|
|
2016-08-18 19:43:16 +00:00
|
|
|
RefPtr<SourceSurface> surf = GetSourceSurfaceInternal();
|
2016-07-30 20:41:57 +00:00
|
|
|
if (!surf) {
|
2014-04-20 01:28:38 +00:00
|
|
|
return false;
|
2014-03-02 16:17:26 +00:00
|
|
|
}
|
|
|
|
|
2014-11-26 21:22:10 +00:00
|
|
|
gfxRect imageRect(0, 0, mImageSize.width, mImageSize.height);
|
2014-08-22 20:12:38 +00:00
|
|
|
bool doTile = !imageRect.Contains(aRegion.Rect()) &&
|
2012-04-17 22:04:15 +00:00
|
|
|
!(aImageFlags & imgIContainer::FLAG_CLAMP);
|
2015-11-23 16:17:35 +00:00
|
|
|
|
2014-08-22 20:12:38 +00:00
|
|
|
ImageRegion region(aRegion);
|
2010-08-13 13:30:02 +00:00
|
|
|
SurfaceWithFormat surfaceResult =
|
2016-07-30 21:49:03 +00: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 01:50:15 +00:00
|
|
|
|
2010-08-13 13:30:02 +00:00
|
|
|
if (surfaceResult.IsValid()) {
|
2010-08-13 13:30:27 +00:00
|
|
|
gfxUtils::DrawPixelSnapped(aContext, surfaceResult.mDrawable,
|
2014-08-22 20:12:38 +00:00
|
|
|
imageRect.Size(), region, surfaceResult.mFormat,
|
2017-01-03 05:53:22 +00: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 01:50:15 +00:00
|
|
|
}
|
2017-02-08 20:48:59 +00:00
|
|
|
|
2014-03-02 16:17:26 +00: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 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2015-01-08 08:04:31 +00:00
|
|
|
nsresult
|
|
|
|
imgFrame::ImageUpdated(const nsIntRect& aUpdateRect)
|
|
|
|
{
|
2015-01-12 03:28:02 +00:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2015-01-08 08:04:31 +00: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 01:50:15 +00:00
|
|
|
{
|
2015-01-12 03:28:02 +00:00
|
|
|
mMonitor.AssertCurrentThreadOwns();
|
2013-07-04 18:45:57 +00:00
|
|
|
|
2016-05-27 05:19:38 +00: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.
|
2018-07-12 15:43:12 +00:00
|
|
|
IntRect updateRect = mFrameRect.Intersect(aUpdateRect);
|
|
|
|
if (updateRect.IsEmpty()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
mDecoded.UnionRect(mDecoded, updateRect);
|
|
|
|
|
|
|
|
// Paletted images cannot invalidate.
|
|
|
|
if (mPalettedImageData) {
|
|
|
|
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-21 01:50:15 +00:00
|
|
|
|
2017-12-01 11:59:21 +00:00
|
|
|
// Update our invalidation counters for any consumers watching for changes
|
|
|
|
// in the surface.
|
|
|
|
if (mRawSurface) {
|
2018-07-12 15:43:12 +00:00
|
|
|
mRawSurface->Invalidate(updateRect);
|
2017-12-01 11:59:21 +00:00
|
|
|
}
|
|
|
|
if (mLockedSurface && mRawSurface != mLockedSurface) {
|
2018-07-12 15:43:12 +00:00
|
|
|
mLockedSurface->Invalidate(updateRect);
|
2017-12-01 11:59:21 +00:00
|
|
|
}
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-01-08 08:04:31 +00:00
|
|
|
void
|
2015-01-12 03:28:02 +00:00
|
|
|
imgFrame::Finish(Opacity aFrameOpacity /* = Opacity::SOME_TRANSPARENCY */,
|
2017-02-08 20:48:59 +00:00
|
|
|
bool aFinalize /* = true */)
|
2015-01-08 08:04:31 +00:00
|
|
|
{
|
2015-01-12 03:28:02 +00:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2015-01-08 08:04:31 +00:00
|
|
|
MOZ_ASSERT(mLockCount > 0, "Image data should be locked");
|
|
|
|
|
2018-07-12 15:43:12 +00:00
|
|
|
if (mPalettedImageData) {
|
|
|
|
ImageUpdatedInternal(mFrameRect);
|
|
|
|
} else if (!mDecoded.IsEqualEdges(mFrameRect)) {
|
|
|
|
// The decoder should have produced rows starting from either the bottom or
|
|
|
|
// the top of the image. We need to calculate the region for which we have
|
|
|
|
// not yet invalidated.
|
|
|
|
IntRect delta(0, 0, mFrameRect.width, 0);
|
|
|
|
if (mDecoded.y == 0) {
|
|
|
|
delta.y = mDecoded.height;
|
|
|
|
delta.height = mFrameRect.height - mDecoded.height;
|
|
|
|
} else if (mDecoded.y + mDecoded.height == mFrameRect.height) {
|
|
|
|
delta.height = mFrameRect.height - mDecoded.y;
|
|
|
|
} else {
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Decoder only updated middle of image!");
|
|
|
|
delta = mFrameRect;
|
|
|
|
}
|
|
|
|
|
|
|
|
ImageUpdatedInternal(delta);
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(mDecoded.IsEqualEdges(mFrameRect));
|
2017-02-08 20:48:59 +00:00
|
|
|
|
|
|
|
if (aFinalize) {
|
|
|
|
FinalizeSurfaceInternal();
|
|
|
|
}
|
|
|
|
|
2016-03-24 00:31:42 +00:00
|
|
|
mFinished = true;
|
|
|
|
|
|
|
|
// The image is now complete, wake up anyone who's waiting.
|
|
|
|
mMonitor.NotifyAll();
|
2015-01-08 08:04:31 +00:00
|
|
|
}
|
|
|
|
|
2015-03-31 17:48:00 +00: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 01:50:15 +00:00
|
|
|
{
|
2015-01-12 03:28:02 +00:00
|
|
|
mMonitor.AssertCurrentThreadOwns();
|
2015-01-08 08:04:31 +00:00
|
|
|
|
2017-01-18 18:31:20 +00:00
|
|
|
if (mRawSurface) {
|
2017-08-14 12:29:56 +00:00
|
|
|
return mFrameRect.Width() * BytesPerPixel(mFormat);
|
2015-03-31 17:48:00 +00:00
|
|
|
}
|
2014-02-25 03:37:51 +00:00
|
|
|
|
2015-03-31 17:48:00 +00:00
|
|
|
if (mPaletteDepth) {
|
2017-08-14 12:29:56 +00:00
|
|
|
return mFrameRect.Width();
|
2015-03-31 17:48:00 +00:00
|
|
|
}
|
2010-05-22 04:10:14 +00: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 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2015-03-31 17:48:00 +00: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 01:50:15 +00:00
|
|
|
{
|
2017-08-14 12:29:56 +00: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 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2015-01-08 08:04:31 +00: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 01:50:15 +00:00
|
|
|
{
|
2015-01-12 03:28:02 +00:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2015-01-08 08:04:31 +00:00
|
|
|
GetImageDataInternal(aData, aLength);
|
|
|
|
}
|
2012-09-26 15:33:06 +00:00
|
|
|
|
2015-01-08 08:04:31 +00:00
|
|
|
void
|
|
|
|
imgFrame::GetImageDataInternal(uint8_t** aData, uint32_t* aLength) const
|
|
|
|
{
|
2015-01-12 03:28:02 +00:00
|
|
|
mMonitor.AssertCurrentThreadOwns();
|
2015-01-08 08:04:31 +00:00
|
|
|
MOZ_ASSERT(mLockCount > 0, "Image data should be locked");
|
|
|
|
|
2017-01-18 18:31:20 +00:00
|
|
|
if (mLockedSurface) {
|
2017-02-08 20:48:59 +00: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 18:31:20 +00:00
|
|
|
*aData = mLockedSurface->GetData();
|
2015-03-31 17:48:00 +00:00
|
|
|
MOZ_ASSERT(*aData,
|
2017-01-18 18:31:20 +00:00
|
|
|
"mLockedSurface is non-null, but GetData is null in GetImageData");
|
2015-01-08 08:04:31 +00: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 01:50:15 +00:00
|
|
|
*aData = mPalettedImageData + PaletteDataLength();
|
2015-03-31 17:48:00 +00:00
|
|
|
MOZ_ASSERT(*aData,
|
|
|
|
"mPalettedImageData is non-null, but result is null in GetImageData");
|
2015-01-08 08:04:31 +00:00
|
|
|
} else {
|
2015-03-31 17:48:00 +00:00
|
|
|
MOZ_ASSERT(false,
|
2017-01-18 18:31:20 +00:00
|
|
|
"Have neither mLockedSurface nor mPalettedImageData in GetImageData");
|
2012-07-30 14:20:58 +00:00
|
|
|
*aData = nullptr;
|
2015-01-08 08:04:31 +00:00
|
|
|
}
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
|
2015-01-08 08:04:31 +00: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 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2015-03-31 17:48:00 +00:00
|
|
|
uint8_t*
|
|
|
|
imgFrame::GetImageData() const
|
2013-06-14 13:42:01 +00:00
|
|
|
{
|
2015-03-31 17:48:00 +00:00
|
|
|
uint8_t* data;
|
2013-06-14 13:42:01 +00:00
|
|
|
uint32_t length;
|
|
|
|
GetImageData(&data, &length);
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2015-03-31 17:48:00 +00: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 01:50:15 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00: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 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2015-03-31 17:48:00 +00: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 01:50:15 +00:00
|
|
|
{
|
2015-01-08 08:04:31 +00:00
|
|
|
AssertImageDataLocked();
|
2012-09-26 15:33:06 +00:00
|
|
|
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
if (!mPalettedImageData) {
|
2012-07-30 14:20:58 +00: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 01:50:15 +00:00
|
|
|
*length = 0;
|
|
|
|
} else {
|
2015-03-31 17:48:00 +00: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 01:50:15 +00:00
|
|
|
*length = PaletteDataLength();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-31 17:48:00 +00:00
|
|
|
uint32_t*
|
|
|
|
imgFrame::GetPaletteData() const
|
2013-06-14 13:42:01 +00:00
|
|
|
{
|
|
|
|
uint32_t* data;
|
|
|
|
uint32_t length;
|
|
|
|
GetPaletteData(&data, &length);
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2018-05-29 12:36:12 +00:00
|
|
|
uint8_t*
|
|
|
|
imgFrame::LockImageData(bool aOnlyFinished)
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
{
|
2015-01-12 03:28:02 +00:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2013-05-24 13:52:34 +00:00
|
|
|
|
2015-01-08 08:04:31 +00:00
|
|
|
MOZ_ASSERT(mLockCount >= 0, "Unbalanced locks and unlocks");
|
2018-05-29 12:36:12 +00:00
|
|
|
if (mLockCount < 0 || (aOnlyFinished && !mFinished)) {
|
|
|
|
return nullptr;
|
2012-09-26 15:33:06 +00:00
|
|
|
}
|
|
|
|
|
2018-05-29 12:36:12 +00:00
|
|
|
uint8_t* data;
|
|
|
|
if (mPalettedImageData) {
|
|
|
|
data = mPalettedImageData;
|
|
|
|
} else if (mLockedSurface) {
|
|
|
|
data = mLockedSurface->GetData();
|
|
|
|
} else {
|
|
|
|
data = nullptr;
|
2015-01-08 08:04:31 +00:00
|
|
|
}
|
|
|
|
|
2018-05-29 12:36:12 +00:00
|
|
|
// If the raw data is still available, we should get a valid pointer for it.
|
|
|
|
if (!data) {
|
|
|
|
MOZ_ASSERT_UNREACHABLE("It's illegal to re-lock an optimized imgFrame");
|
|
|
|
return nullptr;
|
2015-01-08 08:04:31 +00:00
|
|
|
}
|
|
|
|
|
2018-05-29 12:36:12 +00:00
|
|
|
++mLockCount;
|
|
|
|
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-21 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2015-01-08 08:04:31 +00: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 01:50:15 +00:00
|
|
|
{
|
2015-01-08 08:04:31 +00:00
|
|
|
#ifdef DEBUG
|
2015-01-12 03:28:02 +00:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2015-01-08 08:04:31 +00:00
|
|
|
MOZ_ASSERT(mLockCount > 0, "Image data should be locked");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
imgFrame::UnlockImageData()
|
|
|
|
{
|
2015-01-12 03:28:02 +00:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2013-05-24 13:52:34 +00:00
|
|
|
|
2014-09-19 02:26:01 +00:00
|
|
|
MOZ_ASSERT(mLockCount > 0, "Unlocking an unlocked image!");
|
|
|
|
if (mLockCount <= 0) {
|
2012-09-26 15:33:06 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2016-03-24 00:31:42 +00:00
|
|
|
MOZ_ASSERT(mLockCount > 1 || mFinished || mAborted,
|
|
|
|
"Should have Finish()'d or aborted before unlocking");
|
2015-01-12 03:28:02 +00:00
|
|
|
|
2014-09-19 02:26:01 +00:00
|
|
|
mLockCount--;
|
2014-02-25 03:37:51 +00:00
|
|
|
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-09-19 02:26:01 +00:00
|
|
|
void
|
|
|
|
imgFrame::SetOptimizable()
|
|
|
|
{
|
2015-01-08 08:04:31 +00:00
|
|
|
AssertImageDataLocked();
|
2015-07-31 14:29:10 +00:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2014-09-19 02:26:01 +00:00
|
|
|
mOptimizable = true;
|
2014-02-25 03:37:51 +00:00
|
|
|
}
|
|
|
|
|
2017-02-08 20:48:59 +00: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 14:00:52 +00:00
|
|
|
already_AddRefed<SourceSurface>
|
2016-08-18 19:43:16 +00:00
|
|
|
imgFrame::GetSourceSurface()
|
2014-04-20 01:28:38 +00:00
|
|
|
{
|
2015-01-12 03:28:02 +00:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2016-08-18 19:43:16 +00:00
|
|
|
return GetSourceSurfaceInternal();
|
2015-01-08 08:04:31 +00:00
|
|
|
}
|
|
|
|
|
2015-06-17 14:00:52 +00:00
|
|
|
already_AddRefed<SourceSurface>
|
2016-08-18 19:43:16 +00:00
|
|
|
imgFrame::GetSourceSurfaceInternal()
|
2015-01-08 08:04:31 +00:00
|
|
|
{
|
2015-01-12 03:28:02 +00:00
|
|
|
mMonitor.AssertCurrentThreadOwns();
|
2015-01-08 08:04:31 +00:00
|
|
|
|
2014-04-20 01:28:38 +00:00
|
|
|
if (mOptSurface) {
|
2015-03-31 17:48:00 +00:00
|
|
|
if (mOptSurface->IsValid()) {
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<SourceSurface> surf(mOptSurface);
|
2015-05-01 13:14:16 +00:00
|
|
|
return surf.forget();
|
2015-03-31 17:48:00 +00:00
|
|
|
} else {
|
2014-04-20 01:28:38 +00:00
|
|
|
mOptSurface = nullptr;
|
2015-03-31 17:48:00 +00:00
|
|
|
}
|
2014-04-20 01:28:38 +00:00
|
|
|
}
|
|
|
|
|
2017-01-18 18:31:20 +00:00
|
|
|
if (mLockedSurface) {
|
|
|
|
RefPtr<SourceSurface> surf(mLockedSurface);
|
2015-05-01 13:14:16 +00:00
|
|
|
return surf.forget();
|
2015-03-31 17:48:00 +00:00
|
|
|
}
|
2014-04-20 01:28:38 +00:00
|
|
|
|
2017-02-08 15:51:08 +00:00
|
|
|
if (!mRawSurface) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-01-18 18:31:20 +00:00
|
|
|
return CreateLockedSurface(mRawSurface, mFrameRect.Size(), mFormat);
|
2014-04-20 01:28:38 +00:00
|
|
|
}
|
|
|
|
|
2015-01-12 03:28:02 +00:00
|
|
|
void
|
|
|
|
imgFrame::Abort()
|
|
|
|
{
|
|
|
|
MonitorAutoLock lock(mMonitor);
|
|
|
|
|
|
|
|
mAborted = true;
|
|
|
|
|
|
|
|
// Wake up anyone who's waiting.
|
2015-01-15 23:11:36 +00:00
|
|
|
mMonitor.NotifyAll();
|
2015-01-12 03:28:02 +00:00
|
|
|
}
|
|
|
|
|
2016-04-01 17:44:17 +00:00
|
|
|
bool
|
|
|
|
imgFrame::IsAborted() const
|
|
|
|
{
|
|
|
|
MonitorAutoLock lock(mMonitor);
|
|
|
|
return mAborted;
|
|
|
|
}
|
|
|
|
|
2015-01-08 08:04:31 +00:00
|
|
|
bool
|
2016-03-24 00:31:42 +00: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 01:50:15 +00:00
|
|
|
{
|
2015-01-12 03:28:02 +00:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2016-03-24 00:31:42 +00:00
|
|
|
return mFinished;
|
2015-01-12 03:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-03-24 00:31:42 +00:00
|
|
|
imgFrame::WaitUntilFinished() const
|
2015-01-12 03:28:02 +00:00
|
|
|
{
|
|
|
|
MonitorAutoLock lock(mMonitor);
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
// Return if we're aborted or complete.
|
2016-03-24 00:31:42 +00:00
|
|
|
if (mAborted || mFinished) {
|
2015-01-12 03:28:02 +00: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 01:50:15 +00:00
|
|
|
}
|
2009-11-12 23:18:40 +00:00
|
|
|
|
2015-01-08 08:04:31 +00:00
|
|
|
bool
|
2016-03-24 00:31:42 +00:00
|
|
|
imgFrame::AreAllPixelsWritten() const
|
2012-03-23 22:10:50 +00:00
|
|
|
{
|
2015-01-12 03:28:02 +00:00
|
|
|
mMonitor.AssertCurrentThreadOwns();
|
2016-05-27 05:19:38 +00:00
|
|
|
return mDecoded.IsEqualInterior(mFrameRect);
|
2012-03-23 22:10:50 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool imgFrame::GetCompositingFailed() const
|
2009-11-12 23:18:40 +00:00
|
|
|
{
|
2015-01-08 08:04:31 +00:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2009-11-12 23:18:40 +00:00
|
|
|
return mCompositingFailed;
|
|
|
|
}
|
|
|
|
|
2015-03-31 17:48:00 +00:00
|
|
|
void
|
|
|
|
imgFrame::SetCompositingFailed(bool val)
|
2009-11-12 23:18:40 +00:00
|
|
|
{
|
2015-01-08 08:04:31 +00:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2009-11-12 23:18:40 +00:00
|
|
|
mCompositingFailed = val;
|
|
|
|
}
|
2010-03-12 10:08:25 +00:00
|
|
|
|
2015-07-29 04:02:45 +00:00
|
|
|
void
|
|
|
|
imgFrame::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
|
|
|
size_t& aHeapSizeOut,
|
2017-02-22 14:30:22 +00:00
|
|
|
size_t& aNonHeapSizeOut,
|
2018-02-22 19:26:29 +00:00
|
|
|
size_t& aExtHandlesOut) const
|
2010-05-22 04:10:14 +00:00
|
|
|
{
|
2015-01-12 03:28:02 +00:00
|
|
|
MonitorAutoLock lock(mMonitor);
|
2015-01-08 08:04:31 +00:00
|
|
|
|
2015-07-29 04:02:45 +00:00
|
|
|
if (mPalettedImageData) {
|
|
|
|
aHeapSizeOut += aMallocSizeOf(mPalettedImageData);
|
2014-02-25 03:37:51 +00:00
|
|
|
}
|
2017-01-18 18:31:20 +00:00
|
|
|
if (mLockedSurface) {
|
|
|
|
aHeapSizeOut += aMallocSizeOf(mLockedSurface);
|
2010-05-22 04:10:14 +00:00
|
|
|
}
|
2015-07-29 04:02:45 +00:00
|
|
|
if (mOptSurface) {
|
|
|
|
aHeapSizeOut += aMallocSizeOf(mOptSurface);
|
2014-02-25 03:37:51 +00:00
|
|
|
}
|
2017-01-18 18:31:20 +00:00
|
|
|
if (mRawSurface) {
|
|
|
|
aHeapSizeOut += aMallocSizeOf(mRawSurface);
|
|
|
|
mRawSurface->AddSizeOfExcludingThis(aMallocSizeOf, aHeapSizeOut,
|
2018-02-22 19:26:29 +00:00
|
|
|
aNonHeapSizeOut, aExtHandlesOut);
|
2014-04-15 05:24:01 +00:00
|
|
|
}
|
2010-05-22 04:10:14 +00:00
|
|
|
}
|
2014-07-10 15:00:31 +00:00
|
|
|
|
|
|
|
} // namespace image
|
|
|
|
} // namespace mozilla
|