Bug 1386439 - Record image-drawing in RasterImage::GetImageContainer and RasterImage::GetFrameAtSize for browser_image_startup.js. r=tnikkel
MozReview-Commit-ID: 1JDWyx8toTB
--- a/browser/base/content/test/performance/browser_startup_images.js
+++ b/browser/base/content/test/performance/browser_startup_images.js
@@ -92,64 +92,27 @@ const whitelist = [
},
{
file: "resource://gre-resources/broken-image.png",
platforms: ["win", "macosx"],
intermittentNotLoaded: ["win", "macosx"],
},
{
- file: "chrome://browser/skin/places/unfiledBookmarks.png",
- hidpi: "<not loaded>",
- platforms: ["win", "macosx"],
- intermittentNotLoaded: ["win", "macosx"],
- },
- {
- file: "chrome://browser/skin/urlbar-history-dropmarker.png",
- hidpi: "<not loaded>",
- platforms: ["win", "macosx"],
- intermittentShown: ["win", "macosx"],
- },
-
- {
file: "chrome://global/skin/icons/chevron.png",
hidpi: "chrome://global/skin/icons/chevron@2x.png",
platforms: ["macosx"],
},
{
- file: "chrome://pocket/content/panels/img/pocketmenuitem16.png",
- hidpi: "chrome://pocket/content/panels/img/pocketmenuitem16@2x.png",
- platforms: ["macosx"],
- },
-
- {
- file: "chrome://browser/skin/places/bookmarksToolbar.png",
- hidpi: "chrome://browser/skin/places/bookmarksToolbar@2x.png",
- platforms: ["macosx"],
- },
-
- {
- file: "chrome://global/skin/tree/folder.png",
- hidpi: "chrome://global/skin/tree/folder@2x.png",
- platforms: ["macosx"],
- },
-
- {
file: "chrome://global/skin/toolbar/chevron.gif",
platforms: ["win", "linux"],
},
{
- file: "chrome://browser/skin/reload-stop-go.png",
- platforms: ["win", "linux"],
- intermittentShown: ["win", "linux"],
- },
-
- {
file: "chrome://global/skin/icons/resizer.png",
platforms: ["win"],
},
];
add_task(async function() {
let startupRecorder = Cc["@mozilla.org/test/startuprecorder;1"].getService().wrappedJSObject;
await startupRecorder.done;
--- a/image/RasterImage.cpp
+++ b/image/RasterImage.cpp
@@ -537,16 +537,21 @@ RasterImage::GetFrame(uint32_t aWhichFra
return GetFrameAtSize(mSize, aWhichFrame, aFlags);
}
NS_IMETHODIMP_(already_AddRefed<SourceSurface>)
RasterImage::GetFrameAtSize(const IntSize& aSize,
uint32_t aWhichFrame,
uint32_t aFlags)
{
+
+#ifdef DEBUG
+ NotifyDrawingObservers();
+#endif
+
RefPtr<SourceSurface> surf =
GetFrameInternal(aSize, aWhichFrame, aFlags).second().forget();
// If we are here, it suggests the image is embedded in a canvas or some
// other path besides layers, and we won't need the file handle.
MarkSurfaceShared(surf);
return surf.forget();
}
@@ -659,16 +664,20 @@ RasterImage::GetImageContainer(LayerMana
DrawResult drawResult;
RefPtr<layers::Image> image;
Tie(drawResult, image) = GetCurrentImage(container, aFlags);
if (!image) {
return nullptr;
}
+#ifdef DEBUG
+ NotifyDrawingObservers();
+#endif
+
// |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.
AutoTArray<ImageContainer::NonOwningImage, 1> imageList;
imageList.AppendElement(ImageContainer::NonOwningImage(image, TimeStamp(),
mLastFrameID++,
mImageProducerID));
container->SetCurrentImagesInTransaction(imageList);
@@ -1392,27 +1401,17 @@ RasterImage::DrawInternal(DrawableSurfac
uint32_t aFlags,
float aOpacity)
{
gfxContextMatrixAutoSaveRestore saveMatrix(aContext);
ImageRegion region(aRegion);
bool frameIsFinished = aSurface->IsFinished();
#ifdef DEBUG
- // Record the image drawing for startup performance testing.
- if (NS_IsMainThread()) {
- 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());
- }
- }
+ NotifyDrawingObservers();
#endif
// By now we may have a frame with the requested size. If not, we need to
// adjust the drawing parameters accordingly.
IntSize finalSize = aSurface->GetImageSize();
bool couldRedecodeForBetterFrame = false;
if (finalSize != aSize) {
gfx::Size scale(double(aSize.width) / finalSize.width,
@@ -1651,16 +1650,36 @@ RasterImage::GetFramesNotified(uint32_t*
NS_ENSURE_ARG_POINTER(aFramesNotified);
*aFramesNotified = mFramesNotified;
return NS_OK;
}
#endif
+#ifdef DEBUG
+void
+RasterImage::NotifyDrawingObservers()
+{
+ if (!mURI || !NS_IsMainThread()) {
+ 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
+
void
RasterImage::NotifyProgress(Progress aProgress,
const IntRect& aInvalidRect /* = IntRect() */,
const Maybe<uint32_t>& aFrameCount /* = Nothing() */,
DecoderFlags aDecoderFlags
/* = DefaultDecoderFlags() */,
SurfaceFlags aSurfaceFlags
/* = DefaultSurfaceFlags() */)
--- a/image/RasterImage.h
+++ b/image/RasterImage.h
@@ -311,16 +311,21 @@ private:
uint32_t aWhichFrame,
uint32_t aFlags);
Pair<DrawResult, RefPtr<layers::Image>>
GetCurrentImage(layers::ImageContainer* aContainer, uint32_t aFlags);
void UpdateImageContainer();
+#ifdef DEBUG
+ // Records the image drawing for startup performance testing.
+ void NotifyDrawingObservers();
+#endif
+
//////////////////////////////////////////////////////////////////////////////
// Decoding.
//////////////////////////////////////////////////////////////////////////////
/**
* Creates and runs a decoder, either synchronously or asynchronously
* according to @aFlags. Decodes at the provided target size @aSize, using
* decode flags @aFlags. Performs a single-frame decode of this image unless