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

86 Коммитов

Автор SHA1 Сообщение Дата
Sylvestre Ledru 265e672179 Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
# ignore-this-changeset

--HG--
extra : amend_source : 4d301d3b0b8711c4692392aa76088ba7fd7d1022
2018-11-30 11:46:48 +01:00
Andrew McCreight 6e20b07cec Bug 1511141 - Disable formatting for more MOZ_COLLECT_REPORT calls. r=erahm
Differential Revision: https://phabricator.services.mozilla.com/D13463

--HG--
extra : moz-landing-system : lando
2018-11-29 21:41:48 +00:00
Timothy Nikkel 6a62719550 Bug 1256603. Make aMarkUsed parameters required everywhere. r=aosmond 2018-10-13 00:31:03 -05:00
Timothy Nikkel df61b9e8ff Bug 1256603. Only mark images as used in the surface cache if we actually use them. r=aosmond
We were marking them used even if only a decode was requested.

This can cause us to hold extra decoded copies of the image around because we have a tendency to request decode at the intrinsic size.
2018-10-13 00:31:02 -05:00
Andrew Osmond b6cb944219 Bug 1492930 - Part 3. Expose all frames to image memory reporting. r=tnikkel
At present, surface providers roll up all of their individual surfaces
into a single reporting unit. Specifically this means animated image
frames are all reported as a block. This patch removes that
consolidation and reports every frame as its own SurfaceMemoryReport.
This is important because each frame may have its own external image ID,
and we want to cross reference that with what we expect from the GPU
shared surfaces cache.
2018-09-25 09:13:51 -04:00
Narcis Beleuzu 3a8485e6e6 Backed out 6 changesets (bug 1492930) for build bustages on ImageMemoryReporter.cpp. CLOSED TREE
Backed out changeset 9d1ff0d0af47 (bug 1492930)
Backed out changeset bdb1bf2d8062 (bug 1492930)
Backed out changeset 2959314ecf7c (bug 1492930)
Backed out changeset 587e01daa080 (bug 1492930)
Backed out changeset 1a6b422c5a90 (bug 1492930)
Backed out changeset a3b3f4cdc9fa (bug 1492930)
2018-09-25 13:33:17 +03:00
Andrew Osmond d49646bb7a Bug 1492930 - Part 3. Expose all frames to image memory reporting. r=tnikkel
At present, surface providers roll up all of their individual surfaces
into a single reporting unit. Specifically this means animated image
frames are all reported as a block. This patch removes that
consolidation and reports every frame as its own SurfaceMemoryReport.
This is important because each frame may have its own external image ID,
and we want to cross reference that with what we expect from the GPU
shared surfaces cache.
2018-09-25 06:18:06 -04:00
Andrew Osmond 5f4c3fc4b2 Bug 1456558 - Part 2. Implement factor of 2 scaling support for SVGs in the surface cache. r=tnikkel
There is one main difference between raster images and vector images
with respect to factor of 2 scaling. Vector images may be scaled
infinitely and so we need to extend factor of 2 scaling to permit
growing instead of just shrinking. Also, we don't want to scale
infinitely, so we should configure a maximum size limit. This size limit
will apply even outside of factor of 2 scaling, and so the caller
(VectorImage) will need to be careful to take this into account.
2018-09-20 20:22:03 -04:00
Andrew Osmond 70ad830c48 Bug 1456558 - Part 1. Move the allowed raster size calculation from imgFrame to SurfaceCache. r=tnikkel 2018-09-20 20:22:00 -04:00
Andreea Pavel 3805f6a285 Backed out 3 changesets (bug 1456558) for crashtest assertion failures on a CLOSED TREE
Backed out changeset 70d8f11cf6e8 (bug 1456558)
Backed out changeset af9fc3daf97c (bug 1456558)
Backed out changeset f209a9d848f4 (bug 1456558)
2018-09-21 02:13:41 +03:00
Andrew Osmond f799e4bd72 Bug 1456558 - Part 2. Implement factor of 2 scaling support for SVGs in the surface cache. r=tnikkel
There is one main difference between raster images and vector images
with respect to factor of 2 scaling. Vector images may be scaled
infinitely and so we need to extend factor of 2 scaling to permit
growing instead of just shrinking. Also, we don't want to scale
infinitely, so we should configure a maximum size limit. This size limit
will apply even outside of factor of 2 scaling, and so the caller
(VectorImage) will need to be careful to take this into account.
2018-09-20 18:15:32 -04:00
Andrew Osmond 0362a85f44 Bug 1456558 - Part 1. Move the allowed raster size calculation from imgFrame to SurfaceCache. r=tnikkel 2018-09-20 18:15:29 -04:00
Brian Hackett 0e56d01089 Bug 1479647 - Ensure that surface caches have consistent ordering between recording and replaying, r=tnikkel.
--HG--
extra : rebase_source : 34ea2efa9b2916667f46a93a9aa76933383fe8ef
2018-07-31 19:31:14 +00:00
Emilio Cobos Álvarez fffb25b74f Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
This was done automatically replacing:

  s/mozilla::Move/std::move/
  s/ Move(/ std::move(/
  s/(Move(/(std::move(/

Removing the 'using mozilla::Move;' lines.

And then with a few manual fixups, see the bug for the split series..

MozReview-Commit-ID: Jxze3adipUh
2018-06-01 10:45:27 +02:00
Andrew Osmond cd7cf0fad3 Bug 1427639 - Part 2. Fix misleading image memory reporting on Android. r=tnikkel
The shared memory handle reporting has been generalized to be an
external handle reporting. This is used for both shared memory, and for
volatile memory (on Android.) This will allow us to have a better sense
of just how many handles are being used by images on Android.

Additionally we were not properly reporting forced heap allocated
memory, if we were putting animated frames on the heap. This is because
we used SourceSurfaceAlignedRawData without implementing
AddSizeOfExcludingThis.
2018-02-22 14:26:29 -05:00
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