Граф коммитов

71 Коммитов

Автор SHA1 Сообщение Дата
Andrew Osmond 5418665096 Bug 1368776 - Part 16. Ensure we more consistently pass the suggested size from SurfaceCache::LookupBestMatch. r=tnikkel
The suggested size is useful in more situations now that
GetImageContainerImpl requires it. It should be passed whenever we have
it available.
2017-11-17 06:45:28 -05:00
Andrew Osmond 1068bf07ec Bug 1415085 - Make CachedSurface::GetSurfaceKey return a reference instead of a copy. r=decoder 2017-11-07 08:10:01 -05:00
Gerald Squelart d2ed3d6312 Bug 1410252 - Convert 'WrapNotNull(new T(...' to 'MakeNotNull<T*>(...' - r=njn
Most cases where the pointer is stored into an already-declared variable can
trivially be changed to MakeNotNull<T*>, as the NotNull raw pointer will end
up in a smart pointer.

In RAII cases, the target type can be specified (e.g.:
`MakeNotNull<RefPtr<imgFrame>>)`), in which case the variable type may just be
`auto`, similar to the common use of MakeUnique.
Except when the target type is a base pointer, in which case it must be
specified in the declaration.

MozReview-Commit-ID: BYaSsvMhiDi

--HG--
extra : rebase_source : 8fe6f2aeaff5f515b7af2276c439004fa3a1f3ab
2017-10-20 18:25:33 +11:00
Andrew Osmond e467aa133a Bug 1401524 - Ensure SurfaceCache state coherency whenever we perform an operation that may discard surfaces. r=tnikkel
There are a number of operations with the surface cache which may result
in individual surfaces for a particular image cache to be removed. If an
image cache is emptied, and we are in factor of 2 mode, we should reset
it to the default mode, because we require at least one surface to be
available to determine the native/ideal size. Additionally, if the cache
is not locked, it should be removed entirely from the surface cache. We
handle this correctly in methods such as Lookup and LookupBestMatch, but
Prune and CollectSizeOfSurfaces can also cause this to happen, as
recently done in bug 1370412 and bug 1380649.
2017-09-21 16:56:38 -04:00
Andrew Osmond 39b7095b54 Bug 1380649 - Part 1. Ensure SurfaceCache::CollectSizeOfSurfaces removes purged volatile buffer-backed surfaces. r=tnikkel
When we lookup a surface in the cache, we are careful to remove any
surfaces which were backed by volatile memory and got purged before we
could reacquire the buffer. We were not so careful in doing that when
generating memory reports. ISurfaceProvider::AddSizeOfExcludingThis will
cause us to acquire the buffer, and if it was purged, forget about its
purged status. Later when we performed a lookup, we would forget the
purged status, and assume we have the right data. This would appear as
completely transparent for BGRA surfaces, and completely black for BGRX
surfaces.

With this patch, we now properly remove purged surfaces instead of
including them in the report. This ensures that the cache state is
consistent. This also resolves memory reports of surfaces which reported
using no data -- they were purged when the report was generated.

Additionally, there was a bug in SurfaceCache::PruneImage where we did
not discard surfaces outside the module lock. Both PruneImage and
CollectSizeOfSurfaces now free any discarded surfaces outside the lock.
2017-09-19 08:19:48 -04:00
Sebastian Hengst e5075ed4ca Backed out changeset d4f5756b1d12 (bug 1380649) for frequently asserting at image/SurfaceCache.cpp:138. r=backout 2017-09-19 10:51:21 +02:00
Andrew Osmond 264d6b5edf Bug 1380649 - Part 1. Ensure SurfaceCache::CollectSizeOfSurfaces removes purged volatile buffer-backed surfaces. r=tnikkel
When we lookup a surface in the cache, we are careful to remove any
surfaces which were backed by volatile memory and got purged before we
could reacquire the buffer. We were not so careful in doing that when
generating memory reports. ISurfaceProvider::AddSizeOfExcludingThis will
cause us to acquire the buffer, and if it was purged, forget about its
purged status. Later when we performed a lookup, we would forget the
purged status, and assume we have the right data. This would appear as
completely transparent for BGRA surfaces, and completely black for BGRX
surfaces.

With this patch, we now properly remove purged surfaces instead of
including them in the report. This ensures that the cache state is
consistent. This also resolves memory reports of surfaces which reported
using no data -- they were purged when the report was generated.

Additionally, there was a bug in SurfaceCache::PruneImage where we did
not discard surfaces outside the module lock. Both PruneImage and
CollectSizeOfSurfaces now free any discarded surfaces outside the lock.
2017-09-18 19:53:03 -04:00
Andrew Osmond 391b45bd79 Bug 1397223 - Gracefully handle failures in SurfaceCacheImpl::StartTracking. r=tnikkel
When the surface cache starts tracking an unlocked surface, it must
insert it into the expiration tracker, so that it can be freed later if
it is remains unused. ExpirationTrackerImpl::AddObjectLocked can fail
due to out-of-memory conditions or during shutdown, which we previously
ignored, and could leave us in a state where we think the surface is in
the tracker but is not. When we later try to mark the surface as used in
the tracker, it will hit a release assert because it doesn't exist. Now
we handle the insertion failure by discarding the surface. Marking the
surface as used can itself encounter a similar issue, and we handle it
the same way.

MozReview-Commit-ID: Kv6l0znnG48
2017-09-06 20:17:04 -07:00
Andrew Osmond efb55b8c17 Bug 1397235 - Ensure that we reset factor-of-2 mode for an ImageSurfaceCache when it becomes empty. r=tnikkel
An ImageSurfaceCache cannot enter factor-of-2 mode without a minimum
number of surfaces being present in its cache. However those surfaces
can be purged from the cache through various means (expire due to being
disuse, volatile buffers purged, etc). Also, it is entirely possible
that all the surfaces get purged, but the cache itself remains. Since
factor-of-2 mode requires at least one surface (to get the owning image
and its native size), we need to handle the case when the cache is
emptied appropriately. As such, we now reset the factor-of-2 mode (and
its pruned state) to the default (false) if we transition from non-empty
to empty.

MozReview-Commit-ID: EVaEqW59Asv
2017-09-06 20:16:31 -07:00
Andrew Osmond 277247123d Bug 1370412 - Part 9. Add factor of 2 state to the SurfaceCache memory reports. r=tnikkel 2017-09-05 07:58:46 -04:00
Andrew Osmond ba1e1bbaef Bug 1370412 - Part 8b. Add ImageSurfaceCache::Prune to discard surfaces which are not needed in factor of 2 mode. r=tnikkel 2017-09-05 07:58:46 -04:00
Andrew Osmond ee46542020 Bug 1370412 - Part 7. ImageSurfaceCache::Lookup should enter factor of 2 mode on cache misses. r=tnikkel 2017-09-05 07:58:45 -04:00
Andrew Osmond dedad4d54f Bug 1370412 - Part 6. ImageSurfaceCache::LookupBestMatch should enter factor of 2 mode on cache misses. r=tnikkel 2017-09-05 07:58:45 -04:00
Andrew Osmond 7dae87727c Bug 1370412 - Part 5. Add ImageSurfaceCache factor of 2 mode size calculations. r=tnikkel 2017-09-05 07:58:45 -04:00
Andrew Osmond 403e25501d Bug 1370412 - Part 4. Add ImageSurfaceCache::MaybeSetFactor2Mode and state. r=tnikkel 2017-09-05 07:58:45 -04:00
Andrew Osmond dc7109aa94 Bug 1370412 - Part 3. Break out ImageSurfaceCache::CompareArea from LookupBestMatch for reuse. r=tnikkel 2017-09-05 07:58:45 -04:00
Andrew Osmond 5360de90d7 Bug 1389479 - Part 2. Make the SurfaceCache free ImageSurfaceCache objects outside of the lock. r=tnikkel 2017-08-15 15:02:14 -04:00
Andrew Osmond 1cdcc57ee2 Bug 1390109 - Gracefully propogate ImageSurfaceCache::Insert OOM failures to SurfaceCache::Insert. r=tnikkel 2017-08-14 21:35:43 -04:00
Andrew Osmond 20dd87011b Bug 1351869 - Part 1. Make SurfaceCache using the system group for its expiration events. r=tnikkel 2017-08-14 20:23:09 -04:00
Bevis Tseng 87fae2d807 Bug 1350177 - Part 3: Refactor SurfaceCache with ExpirationTrackerImpl. r=froydnj,aosmond
Always acquire StaticMutexAutoLock for the use of ExpirationTrackerImpl.

--HG--
extra : rebase_source : 39d59130b9f1edd9fc43cc3597015a3f21b37977
2017-03-27 21:47:23 -04:00
Timothy Nikkel 23f3425afe Bug 1343341. Only set the animation state as discarded if we discarded the animated frames (and not a static frame from a first-frame-only decode). r=aosmond
The SurfaceCache can hold the first frame of a "static" decode as well as the animated frames in two seperate entries. We only care about what happens to the animated frames, so ignore OnSurfaceDiscarded for anything else.

To accomplish this we must pass the SurfaceKey to OnSurfaceDiscarded.
2017-03-16 03:06:06 -05:00
Timothy Nikkel 0f1d7652b6 Backed out changeset 29e2e6dd82d2 (bug 1343341) 2017-03-15 03:13:33 -05:00
Timothy Nikkel d1b5ed8ea1 Bug 1343341. Only set the animation state as discarded if we discarded the animated frames (and not a static frame from a first-frame-only decode). r=aosmond
The SurfaceCache can hold the first frame of a "static" decode as well as the animated frames in two seperate entries. We only care about what happens to the animated frames, so ignore OnSurfaceDiscarded for anything else.

To accomplish this we must pass the SurfaceKey to OnSurfaceDiscarded.
2017-03-15 02:47:40 -05:00
Timothy Nikkel 39e0784bbd Bug 1346510. Don't allow the surface cache to unlock the animated frames of an animated image (when discarding of animated images is disabled). r=aosmond
The pref has never been enabled, so this is quite surprising!

It is currently possible (and has been for quite a while) to discard animated images. All we need is the follow sequence of events.

1. Decode an animated image.
2. Move the animated image out of view (so it is not painted).
3. Call canvas.drawImage on the animated image (or anything else that asks for a first frame only decode). This creates a static entry in the surface cache for this first frame in addition to the animated entry. Because it is a static request we will also start a first frame decode. RasterImage::Decode calls SurfaceCache::UnlockEntries

https://dxr.mozilla.org/mozilla-central/rev/4ceb9062ea8f4113bfd1b3536ace4a840a72faa7/image/RasterImage.cpp#1166

and bam, the animated frames are now unlocked (even though the RasterImage, and it's entry in the surface cache is still locked).
4. Switch tabs, open about:memory and minimize memory to actual throw away the animated frames.
5. Switch back to the image tab, scroll the image back into view, it will not animate, it will just show the last composited frame forever.
2017-03-14 01:11:44 -05:00
Andrew Osmond 13df27efb8 Bug 1341624 - Include shared handle totals in memory reports for images. r=tnikkel 2017-02-22 09:30:22 -05:00
Andrew Osmond ae74757a34 Bug 1335045 - Make SurfaceCache mutex static to robustly control access to the image cache. r=tnikkel 2017-01-31 07:41:14 -05:00
Seth Fowler a5b5245612 Bug 1298551 - Respect CachedSurface::SetLocked() even if the underlying ISurfaceProvider is always locked. r=dholbert 2016-08-26 17:03:25 -07:00
Seth Fowler f8818933fa Bug 1296828 (Part 3) - Update SurfaceCache API to rely on ImageKeys and SurfaceKeys stored on ISurfaceProviders. r=dholbert 2016-08-26 17:03:19 -07:00
Seth Fowler 8f4ebfcf90 Bug 1296828 (Part 1) - Use ImageKey consistently in SurfaceCache. r=dholbert 2016-08-26 17:03:15 -07:00
Seth Fowler fd83d4ee88 Bug 1296762 (Part 3) - Use NotNull for all CachedSurfaces in SurfaceCache. r=dholbert 2016-08-25 11:42:00 -07:00
Seth Fowler 6006fb4945 Bug 1296762 (Part 2) - Forbid null ISurfaceProviders in SurfaceCache. r=dholbert 2016-08-25 11:41:58 -07:00
Seth Fowler dda03690ef Bug 1296762 (Part 1) - Remove SurfaceCache::InsertPlaceholder(). r=dholbert 2016-08-25 11:41:57 -07:00
Nicholas Nethercote c2306345d5 Bug 1297658 - Avoid unnecessary checking in memory reporters. r=erahm.
This patch removes checking of all the callback calls in memory reporter
CollectReport() functions, because it's not useful.

The patch also does some associated clean-up.

- Replaces some uses of nsIMemoryReporterCallback with the preferred
  nsIHandleReportCallback typedef.

- Replaces aCallback/aCb/aClosure with aHandleRepor/aData for CollectReports()
  parameter names, for consistency.

- Adds MOZ_MUST_USE/[must_use] in a few places in nsIMemoryReporter.idl.

- Uses the MOZ_COLLECT_REPORT macro in all suitable places.

Overall the patch reduces code size by ~300 lines and reduces the size of
libxul by about 37 KiB on my Linux64 builds.

--HG--
extra : rebase_source : e94323614bd10463a0c5134a7276238a7ca1cf23
2016-08-24 15:23:45 +10:00
Seth Fowler 1f92f3a7b9 Bug 1293472 (Part 3) - Store animated images in the surface cache as a sequence of frames, rather than each frame getting its own cache entry. r=dholbert,edwin,njn 2016-08-18 15:42:48 -07:00
Seth Fowler 8d183cc877 Bug 1296147 (Part 1) - Add a DrawableSurface smart pointer type to allow lazy surface generation. r=dholbert,edwin 2016-08-18 13:03:44 -07:00
Timothy Nikkel d7a0b010ae Backed out changeset 37340346a89e (Bug 1289628 - Return ISurfaceProvider objects from SurfaceCache lookup functions. r=dholbert,edwin) for causing bug 1292290. 2016-08-15 19:58:35 -05:00
Daniel Holbert ac90698e93 Bug 1292632 part 1: Remove a stale/unused #include from SurfaceCache.cpp. r=seth
MozReview-Commit-ID: feZgLQ1R7u
2016-08-05 17:09:45 -07:00
Seth Fowler df8d9955b6 Bug 1291033 (Part 1) - Ensure atomicity of ISurfaceProvider availability changes. r=dholbert 2016-08-04 18:47:41 -07:00
Seth Fowler 77c1dbccdb Bug 1289628 - Return ISurfaceProvider objects from SurfaceCache lookup functions. r=dholbert,edwin 2016-07-27 13:54:23 -07:00
Seth Fowler 6b52f4548a Bug 1286161 (Part 1) - Expose SourceBuffer and SurfaceCache constants which are useful for testing. r=edwin 2016-07-16 00:36:58 -07:00
Seth Fowler d7bb652cf1 Bug 1283967 - Remove unused function SurfaceCache::RemoveEntry(). r=dholbert 2016-07-02 18:47:47 -06:00
Seth Fowler 86430c09c8 Bug 1282327 (Part 2) - Update SurfaceCache documentation and method names to reflect the fact that cache entries are now ISurfaceProviders. r=dholbert 2016-07-02 18:47:45 -06:00
Seth Fowler f9272b3af2 Bug 1282327 (Part 1) - Store ISurfaceProviders in the ImageLib SurfaceCache. r=dholbert 2016-07-02 18:47:44 -06:00
Seth Fowler 43c4cb86a4 Revert "Bug 1282327 - Store ISurfaceProviders in the ImageLib SurfaceCache. r=dholbert"; it was accidentally pushed.
This reverts commit 57147126cc04361268e606ac9e94c65e2bd4c886.
2016-06-29 18:36:34 -07:00
Seth Fowler d35c501ce3 Bug 1282327 - Store ISurfaceProviders in the ImageLib SurfaceCache. r=dholbert 2016-06-29 18:33:20 -07:00
vincentliu 4332e3a00e Bug 1167557 - Log for Null surface in SurfaceCache::Insert. r=milan
---
 gfx/2d/Logging.h       | 1 +
 image/SurfaceCache.cpp | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
2016-05-19 13:01:26 +08:00
Jonathan Watt 6a7fdf9b55 No Bug - Remove some unnecessary SVGImageContext.h includes and add comments. r=sparky 2016-04-22 15:07:31 +01:00
Timothy Nikkel 5afe8e5453 Bug 1257101. imgFrame::IsImageComplete says whether we've had pixels decoded to the whole image rect, but it's used to check if the frame is finished decoding. These are different things when the image has more than one progress pass. r=seth
This means that in RasterImage::LookupFrame when we are asked to do a sync decode (if needed) we use WaitUntilComplete to wait until the frame is finished decoding.  But we would actually return after the next progressive pass notified the monitor to wake up. Thus, we would draw a not-fully-decoded image even though the sync decode flag was passed.

The change in FrameAnimator means that we won't draw the next frame in an animated image until all progressive passes of that image are complete. This seems like what we want anyways.

There is one real use of IsImageComplete left, in imgFrame::Draw, where we need to know if the decoded image data covers the whole image frame. (There are a couple of uses of IsImageComplete in asserts.)
2016-03-23 19:31:42 -05:00
Timothy Nikkel 567c526765 Bug 1251091. Fix surface key comparison in ImageSurfaceCache::LookupBestMatch. r=dholbert
http://hg.mozilla.org/mozilla-central/rev/411f18fdffeb (bug 1186796) had a mistake in it.

It changed ImageSurfaceCache::LookupBestMatch to use a for loop instead of using a callback to iterate each entry of the hashtable. The callback was called with the surface key of its entry, and it used the name |aSurfaceKey| for that key. ImageSurfaceCache::LookupBestMatch uses the name |aSurfaceKey| for the key we are looking for. So when the code from the callback was moved into the for loop in ImageSurfaceCache::LookupBestMatch the meaning of |aSurfaceKey| changed, but the code was not updated.
2016-02-29 12:20:50 -06:00
Timothy Nikkel 91dcacc8f5 Bug 1251742. Avoid overflow in computing area of surface sizes in SurfaceCache. r=dholbert
http://hg.mozilla.org/mozilla-central/rev/9727cdebb2ee (bug 1228314) fixed the first instance of this, but missed the next two for some reason.
2016-02-26 17:13:59 -06:00