2010-08-14 08:09:48 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-08-14 08:09:48 +04:00
|
|
|
|
|
|
|
#include "Image.h"
|
2017-11-17 14:45:24 +03:00
|
|
|
#include "Layers.h" // for LayerManager
|
2014-05-08 22:37:39 +04:00
|
|
|
#include "nsRefreshDriver.h"
|
|
|
|
#include "mozilla/TimeStamp.h"
|
2017-11-17 14:45:24 +03:00
|
|
|
#include "mozilla/Tuple.h" // for Tie
|
2010-08-14 08:09:48 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2012-01-06 20:02:27 +04:00
|
|
|
namespace image {
|
2010-08-14 08:09:48 +04:00
|
|
|
|
2015-04-28 21:46:17 +03:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Memory Reporting
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
ImageMemoryCounter::ImageMemoryCounter(Image* aImage,
|
2017-07-28 13:10:04 +03:00
|
|
|
SizeOfState& aState,
|
2015-04-28 21:46:17 +03:00
|
|
|
bool aIsUsed)
|
|
|
|
: mIsUsed(aIsUsed)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aImage);
|
|
|
|
|
|
|
|
// Extract metadata about the image.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ImageURL> imageURL(aImage->GetURI());
|
2015-04-28 21:46:17 +03:00
|
|
|
if (imageURL) {
|
|
|
|
imageURL->GetSpec(mURI);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t width = 0;
|
|
|
|
int32_t height = 0;
|
|
|
|
aImage->GetWidth(&width);
|
|
|
|
aImage->GetHeight(&height);
|
|
|
|
mIntrinsicSize.SizeTo(width, height);
|
|
|
|
|
|
|
|
mType = aImage->GetType();
|
|
|
|
|
|
|
|
// Populate memory counters for source and decoded data.
|
2017-07-28 13:10:04 +03:00
|
|
|
mValues.SetSource(aImage->SizeOfSourceWithComputedFallback(aState));
|
|
|
|
aImage->CollectSizeOfSurfaces(mSurfaces, aState.mMallocSizeOf);
|
2015-04-28 21:46:17 +03:00
|
|
|
|
|
|
|
// Compute totals.
|
|
|
|
for (const SurfaceMemoryCounter& surfaceCounter : mSurfaces) {
|
|
|
|
mValues += surfaceCounter.Values();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Image Base Types
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-11-17 14:45:27 +03:00
|
|
|
void
|
|
|
|
ImageResource::SetCurrentImage(ImageContainer* aContainer,
|
|
|
|
SourceSurface* aSurface,
|
2017-11-17 14:45:25 +03:00
|
|
|
bool aInTransaction)
|
2017-11-17 14:45:24 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(aContainer);
|
|
|
|
|
2017-11-17 14:45:27 +03:00
|
|
|
if (!aSurface) {
|
2017-11-17 14:45:24 +03:00
|
|
|
// The OS threw out some or all of our buffer. We'll need to wait for the
|
|
|
|
// redecode (which was automatically triggered by GetFrame) to complete.
|
2017-11-17 14:45:27 +03:00
|
|
|
return;
|
2017-11-17 14:45:24 +03:00
|
|
|
}
|
|
|
|
|
2017-11-17 14:45:25 +03:00
|
|
|
// |image| holds a reference to a SourceSurface which in turn holds a lock on
|
|
|
|
// the current frame's data buffer, ensuring that it doesn't get freed as
|
|
|
|
// long as the layer system keeps this ImageContainer alive.
|
2017-11-17 14:45:27 +03:00
|
|
|
RefPtr<layers::Image> image = new layers::SourceSurfaceImage(aSurface);
|
2017-11-17 14:45:25 +03:00
|
|
|
|
|
|
|
// We can share the producer ID with other containers because it is only
|
|
|
|
// used internally to validate the frames given to a particular container
|
|
|
|
// so that another object cannot add its own. Similarly the frame ID is
|
|
|
|
// only used internally to ensure it is always increasing, and skipping
|
|
|
|
// IDs from an individual container's perspective is acceptable.
|
2017-11-17 14:45:25 +03:00
|
|
|
AutoTArray<ImageContainer::NonOwningImage, 1> imageList;
|
|
|
|
imageList.AppendElement(ImageContainer::NonOwningImage(image, TimeStamp(),
|
|
|
|
mLastFrameID++,
|
|
|
|
mImageProducerID));
|
|
|
|
|
|
|
|
if (aInTransaction) {
|
|
|
|
aContainer->SetCurrentImagesInTransaction(imageList);
|
|
|
|
} else {
|
|
|
|
aContainer->SetCurrentImages(imageList);
|
|
|
|
}
|
2017-11-17 14:45:24 +03:00
|
|
|
}
|
|
|
|
|
2017-11-17 14:45:24 +03:00
|
|
|
already_AddRefed<ImageContainer>
|
|
|
|
ImageResource::GetImageContainerImpl(LayerManager* aManager,
|
|
|
|
const IntSize& aSize,
|
|
|
|
uint32_t aFlags)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(aManager);
|
|
|
|
MOZ_ASSERT((aFlags & ~(FLAG_SYNC_DECODE |
|
|
|
|
FLAG_SYNC_DECODE_IF_FAST |
|
2017-11-17 14:45:26 +03:00
|
|
|
FLAG_ASYNC_NOTIFY |
|
|
|
|
FLAG_HIGH_QUALITY_SCALING))
|
2017-11-17 14:45:24 +03:00
|
|
|
== FLAG_NONE,
|
|
|
|
"Unsupported flag passed to GetImageContainer");
|
|
|
|
|
2017-11-17 14:45:26 +03:00
|
|
|
IntSize size = GetImageContainerSize(aManager, aSize, aFlags);
|
|
|
|
if (size.IsEmpty()) {
|
2017-11-17 14:45:24 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mAnimationConsumers == 0) {
|
|
|
|
SendOnUnlockedDraw(aFlags);
|
|
|
|
}
|
|
|
|
|
2017-11-17 14:45:28 +03:00
|
|
|
uint32_t flags = (aFlags & ~(FLAG_SYNC_DECODE |
|
|
|
|
FLAG_SYNC_DECODE_IF_FAST)) | FLAG_ASYNC_NOTIFY;
|
2017-11-17 14:45:25 +03:00
|
|
|
RefPtr<layers::ImageContainer> container;
|
|
|
|
ImageContainerEntry* entry = nullptr;
|
|
|
|
int i = mImageContainers.Length() - 1;
|
|
|
|
for (; i >= 0; --i) {
|
|
|
|
entry = &mImageContainers[i];
|
|
|
|
container = entry->mContainer.get();
|
2017-11-17 14:45:28 +03:00
|
|
|
if (size == entry->mSize && flags == entry->mFlags) {
|
2017-11-17 14:45:25 +03:00
|
|
|
// Lack of a container is handled below.
|
|
|
|
break;
|
|
|
|
} else if (!container) {
|
|
|
|
// Stop tracking if our weak pointer to the image container was freed.
|
|
|
|
mImageContainers.RemoveElementAt(i);
|
2017-11-17 15:54:50 +03:00
|
|
|
} else {
|
|
|
|
// It isn't a match, but still valid. Forget the container so we don't
|
|
|
|
// try to reuse it below.
|
|
|
|
container = nullptr;
|
2017-11-17 14:45:25 +03:00
|
|
|
}
|
|
|
|
}
|
2017-11-17 14:45:24 +03:00
|
|
|
|
2017-11-17 15:54:50 +03:00
|
|
|
if (container) {
|
2017-11-17 14:45:25 +03:00
|
|
|
switch (entry->mLastDrawResult) {
|
2017-11-17 14:45:25 +03:00
|
|
|
case DrawResult::SUCCESS:
|
|
|
|
case DrawResult::BAD_IMAGE:
|
|
|
|
case DrawResult::BAD_ARGS:
|
|
|
|
return container.forget();
|
|
|
|
case DrawResult::NOT_READY:
|
|
|
|
case DrawResult::INCOMPLETE:
|
|
|
|
case DrawResult::TEMPORARY_ERROR:
|
|
|
|
// Temporary conditions where we need to rerequest the frame to recover.
|
|
|
|
break;
|
|
|
|
case DrawResult::WRONG_SIZE:
|
|
|
|
// Unused by GetFrameInternal
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Unhandled DrawResult type!");
|
|
|
|
return container.forget();
|
|
|
|
}
|
2017-11-17 14:45:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
NotifyDrawingObservers();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
DrawResult drawResult;
|
|
|
|
IntSize bestSize;
|
|
|
|
RefPtr<SourceSurface> surface;
|
|
|
|
Tie(drawResult, bestSize, surface) =
|
|
|
|
GetFrameInternal(size, FRAME_CURRENT, aFlags | FLAG_ASYNC_NOTIFY);
|
|
|
|
|
|
|
|
// The requested size might be refused by the surface cache (i.e. due to
|
|
|
|
// factor-of-2 mode). In that case we don't want to create an entry for this
|
|
|
|
// specific size, but rather re-use the entry for the substituted size.
|
|
|
|
if (bestSize != size) {
|
|
|
|
MOZ_ASSERT(!bestSize.IsEmpty());
|
|
|
|
|
|
|
|
// We can only remove the entry if we no longer have a container, because if
|
|
|
|
// there are strong references to it remaining, we need to still update it
|
|
|
|
// in UpdateImageContainer.
|
|
|
|
if (i >= 0 && !container) {
|
|
|
|
mImageContainers.RemoveElementAt(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Forget about the stale container, if any. This lets the entry creation
|
|
|
|
// logic do its job below, if it turns out there is no existing best entry
|
|
|
|
// or the best entry doesn't have a container.
|
|
|
|
container = nullptr;
|
|
|
|
|
|
|
|
// We need to do the entry search again for the new size. We skip pruning
|
|
|
|
// because we did this above once already, but ImageContainer is threadsafe,
|
|
|
|
// so there is a remote possibility it got freed.
|
|
|
|
i = mImageContainers.Length() - 1;
|
|
|
|
for (; i >= 0; --i) {
|
|
|
|
entry = &mImageContainers[i];
|
2017-11-17 14:45:28 +03:00
|
|
|
if (bestSize == entry->mSize && flags == entry->mFlags) {
|
2017-11-17 14:45:27 +03:00
|
|
|
container = entry->mContainer.get();
|
|
|
|
if (container) {
|
|
|
|
switch (entry->mLastDrawResult) {
|
|
|
|
case DrawResult::SUCCESS:
|
|
|
|
case DrawResult::BAD_IMAGE:
|
|
|
|
case DrawResult::BAD_ARGS:
|
|
|
|
return container.forget();
|
|
|
|
case DrawResult::NOT_READY:
|
|
|
|
case DrawResult::INCOMPLETE:
|
|
|
|
case DrawResult::TEMPORARY_ERROR:
|
|
|
|
// Temporary conditions where we need to rerequest the frame to
|
|
|
|
// recover. We have already done so!
|
|
|
|
break;
|
|
|
|
case DrawResult::WRONG_SIZE:
|
|
|
|
// Unused by GetFrameInternal
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Unhandled DrawResult type!");
|
|
|
|
return container.forget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!container) {
|
2017-11-17 14:45:25 +03:00
|
|
|
// We need a new ImageContainer, so create one.
|
|
|
|
container = LayerManager::CreateImageContainer();
|
2017-11-17 14:45:25 +03:00
|
|
|
|
|
|
|
if (i >= 0) {
|
|
|
|
entry->mContainer = container;
|
|
|
|
} else {
|
|
|
|
entry = mImageContainers.AppendElement(
|
2017-11-17 14:45:28 +03:00
|
|
|
ImageContainerEntry(bestSize, container.get(), flags));
|
2017-11-17 14:45:25 +03:00
|
|
|
}
|
2017-11-17 14:45:24 +03:00
|
|
|
}
|
|
|
|
|
2017-11-17 14:45:27 +03:00
|
|
|
SetCurrentImage(container, surface, true);
|
|
|
|
entry->mLastDrawResult = drawResult;
|
2017-11-17 14:45:24 +03:00
|
|
|
return container.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-11-17 14:45:25 +03:00
|
|
|
ImageResource::UpdateImageContainer()
|
2017-11-17 14:45:24 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
2017-11-17 14:45:25 +03:00
|
|
|
for (int i = mImageContainers.Length() - 1; i >= 0; --i) {
|
|
|
|
ImageContainerEntry& entry = mImageContainers[i];
|
|
|
|
RefPtr<ImageContainer> container = entry.mContainer.get();
|
|
|
|
if (container) {
|
2017-11-17 14:45:27 +03:00
|
|
|
IntSize bestSize;
|
|
|
|
RefPtr<SourceSurface> surface;
|
|
|
|
Tie(entry.mLastDrawResult, bestSize, surface) =
|
2017-11-17 14:45:28 +03:00
|
|
|
GetFrameInternal(entry.mSize, FRAME_CURRENT, entry.mFlags);
|
2017-11-17 14:45:27 +03:00
|
|
|
|
|
|
|
// It is possible that this is a factor-of-2 substitution. Since we
|
|
|
|
// managed to convert the weak reference into a strong reference, that
|
|
|
|
// means that an imagelib user still is holding onto the container. thus
|
|
|
|
// we cannot consolidate and must keep updating the duplicate container.
|
|
|
|
SetCurrentImage(container, surface, false);
|
2017-11-17 14:45:25 +03:00
|
|
|
} else {
|
|
|
|
// Stop tracking if our weak pointer to the image container was freed.
|
|
|
|
mImageContainers.RemoveElementAt(i);
|
|
|
|
}
|
2017-11-17 14:45:24 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ImageResource::ReleaseImageContainer()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2017-11-17 14:45:25 +03:00
|
|
|
mImageContainers.Clear();
|
2017-11-17 14:45:24 +03:00
|
|
|
}
|
|
|
|
|
2010-08-14 08:09:48 +04:00
|
|
|
// Constructor
|
2013-09-28 22:28:44 +04:00
|
|
|
ImageResource::ImageResource(ImageURL* aURI) :
|
2013-09-28 22:28:42 +04:00
|
|
|
mURI(aURI),
|
2012-12-20 02:24:32 +04:00
|
|
|
mInnerWindowId(0),
|
2010-09-08 04:33:02 +04:00
|
|
|
mAnimationConsumers(0),
|
2010-11-17 23:39:23 +03:00
|
|
|
mAnimationMode(kNormalAnimMode),
|
2011-10-17 18:59:28 +04:00
|
|
|
mInitialized(false),
|
|
|
|
mAnimating(false),
|
2017-11-17 14:45:23 +03:00
|
|
|
mError(false),
|
|
|
|
mImageProducerID(ImageContainer::AllocateProducerID()),
|
2017-11-17 14:45:25 +03:00
|
|
|
mLastFrameID(0)
|
2015-03-26 05:36:00 +03:00
|
|
|
{ }
|
2010-08-14 08:09:48 +04:00
|
|
|
|
2015-04-29 02:32:02 +03:00
|
|
|
ImageResource::~ImageResource()
|
|
|
|
{
|
|
|
|
// Ask our ProgressTracker to drop its weak reference to us.
|
|
|
|
mProgressTracker->ResetImage();
|
|
|
|
}
|
|
|
|
|
2010-09-08 04:33:02 +04:00
|
|
|
void
|
2012-12-20 02:24:32 +04:00
|
|
|
ImageResource::IncrementAnimationConsumers()
|
2010-09-08 04:33:02 +04:00
|
|
|
{
|
2013-09-28 22:28:43 +04:00
|
|
|
MOZ_ASSERT(NS_IsMainThread(), "Main thread only to encourage serialization "
|
|
|
|
"with DecrementAnimationConsumers");
|
2010-09-08 04:33:02 +04:00
|
|
|
mAnimationConsumers++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-12-20 02:24:32 +04:00
|
|
|
ImageResource::DecrementAnimationConsumers()
|
2010-09-08 04:33:02 +04:00
|
|
|
{
|
2013-09-28 22:28:43 +04:00
|
|
|
MOZ_ASSERT(NS_IsMainThread(), "Main thread only to encourage serialization "
|
|
|
|
"with IncrementAnimationConsumers");
|
2015-03-26 05:36:00 +03:00
|
|
|
MOZ_ASSERT(mAnimationConsumers >= 1,
|
|
|
|
"Invalid no. of animation consumers!");
|
2010-09-08 04:33:02 +04:00
|
|
|
mAnimationConsumers--;
|
|
|
|
}
|
|
|
|
|
2012-10-20 00:27:11 +04:00
|
|
|
nsresult
|
2012-12-20 02:24:32 +04:00
|
|
|
ImageResource::GetAnimationModeInternal(uint16_t* aAnimationMode)
|
2010-11-17 23:39:23 +03:00
|
|
|
{
|
2015-03-26 05:36:00 +03:00
|
|
|
if (mError) {
|
2010-11-17 23:39:23 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
2015-03-26 05:36:00 +03:00
|
|
|
}
|
2010-11-17 23:39:23 +03:00
|
|
|
|
|
|
|
NS_ENSURE_ARG_POINTER(aAnimationMode);
|
2012-10-20 00:27:11 +04:00
|
|
|
|
2010-11-17 23:39:23 +03:00
|
|
|
*aAnimationMode = mAnimationMode;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-10-20 00:27:11 +04:00
|
|
|
nsresult
|
2012-12-20 02:24:32 +04:00
|
|
|
ImageResource::SetAnimationModeInternal(uint16_t aAnimationMode)
|
2010-11-17 23:39:23 +03:00
|
|
|
{
|
2015-03-26 05:36:00 +03:00
|
|
|
if (mError) {
|
2010-11-17 23:39:23 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
2015-03-26 05:36:00 +03:00
|
|
|
}
|
2010-11-17 23:39:23 +03:00
|
|
|
|
|
|
|
NS_ASSERTION(aAnimationMode == kNormalAnimMode ||
|
|
|
|
aAnimationMode == kDontAnimMode ||
|
|
|
|
aAnimationMode == kLoopOnceAnimMode,
|
|
|
|
"Wrong Animation Mode is being set!");
|
2012-10-20 00:27:11 +04:00
|
|
|
|
2010-11-17 23:39:23 +03:00
|
|
|
mAnimationMode = aAnimationMode;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-05-08 22:37:39 +04:00
|
|
|
bool
|
|
|
|
ImageResource::HadRecentRefresh(const TimeStamp& aTime)
|
|
|
|
{
|
|
|
|
// Our threshold for "recent" is 1/2 of the default refresh-driver interval.
|
|
|
|
// This ensures that we allow for frame rates at least as fast as the
|
|
|
|
// refresh driver's default rate.
|
|
|
|
static TimeDuration recentThreshold =
|
|
|
|
TimeDuration::FromMilliseconds(nsRefreshDriver::DefaultInterval() / 2.0);
|
|
|
|
|
|
|
|
if (!mLastRefreshTime.IsNull() &&
|
|
|
|
aTime - mLastRefreshTime < recentThreshold) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// else, we can proceed with a refresh.
|
|
|
|
// But first, update our last refresh time:
|
|
|
|
mLastRefreshTime = aTime;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-09-08 04:33:02 +04:00
|
|
|
void
|
2012-12-20 02:24:32 +04:00
|
|
|
ImageResource::EvaluateAnimation()
|
2010-09-08 04:33:02 +04:00
|
|
|
{
|
|
|
|
if (!mAnimating && ShouldAnimate()) {
|
|
|
|
nsresult rv = StartAnimation();
|
|
|
|
mAnimating = NS_SUCCEEDED(rv);
|
|
|
|
} else if (mAnimating && !ShouldAnimate()) {
|
|
|
|
StopAnimation();
|
|
|
|
}
|
|
|
|
}
|
2010-08-23 06:30:45 +04:00
|
|
|
|
2016-11-17 09:25:53 +03:00
|
|
|
void
|
|
|
|
ImageResource::SendOnUnlockedDraw(uint32_t aFlags)
|
|
|
|
{
|
|
|
|
if (!mProgressTracker) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(aFlags & FLAG_ASYNC_NOTIFY)) {
|
|
|
|
mProgressTracker->OnUnlockedDraw();
|
|
|
|
} else {
|
|
|
|
NotNull<RefPtr<ImageResource>> image = WrapNotNull(this);
|
2017-08-15 03:24:55 +03:00
|
|
|
nsCOMPtr<nsIEventTarget> eventTarget = mProgressTracker->GetEventTarget();
|
|
|
|
nsCOMPtr<nsIRunnable> ev = NS_NewRunnableFunction(
|
2017-06-12 22:34:10 +03:00
|
|
|
"image::ImageResource::SendOnUnlockedDraw", [=]() -> void {
|
|
|
|
RefPtr<ProgressTracker> tracker = image->GetProgressTracker();
|
|
|
|
if (tracker) {
|
|
|
|
tracker->OnUnlockedDraw();
|
|
|
|
}
|
2017-08-15 03:24:55 +03:00
|
|
|
});
|
|
|
|
eventTarget->Dispatch(ev.forget(), NS_DISPATCH_NORMAL);
|
2016-11-17 09:25:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-17 14:45:23 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
|
|
|
ImageResource::NotifyDrawingObservers()
|
|
|
|
{
|
|
|
|
if (!mURI || !NS_IsMainThread()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool match = false;
|
|
|
|
if ((NS_FAILED(mURI->SchemeIs("resource", &match)) || !match) &&
|
|
|
|
(NS_FAILED(mURI->SchemeIs("chrome", &match)) || !match)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Record the image drawing for startup performance testing.
|
|
|
|
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
|
|
|
NS_WARNING_ASSERTION(obs, "Can't get an observer service handle");
|
|
|
|
if (obs) {
|
|
|
|
nsCOMPtr<nsIURI> imageURI = mURI->ToIURI();
|
|
|
|
nsAutoCString spec;
|
|
|
|
imageURI->GetSpec(spec);
|
|
|
|
obs->NotifyObservers(nullptr, "image-drawing", NS_ConvertUTF8toUTF16(spec).get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-01-06 20:02:27 +04:00
|
|
|
} // namespace image
|
2010-08-14 08:09:48 +04:00
|
|
|
} // namespace mozilla
|