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

89 Коммитов

Автор SHA1 Сообщение Дата
Andrew Osmond 2377303d82 Bug 1530774 - Part 1. Remove support in FrameAnimator for blending partial/paletted frames. r=tnikkel
Differential Revision: https://phabricator.services.mozilla.com/D23714
2019-03-18 07:30:34 -04:00
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 Osmond 229f450427 Bug 1508393 - Enable animated images producing full frames by default. r=tnikkel
Also, fix a minor bug where when we discard an animated image that is a
full frame animated image, we need to reset
AnimationState::mCompositedFrameInvalid to false, just like we do for
animated images blended by FrameAnimator. This is because it is used as
part of our state checking in FrameAnimator::GetCompositedFrame before
we are willing to yield frame data.

Differential Revision: https://phabricator.services.mozilla.com/D12362
2018-11-19 21:05:54 -05:00
Andrew Osmond 95d4e6266a Bug 1465619 - Part 1. Use imgFrame directly instead of RawAccessFrameRef in FrameAnimator. r=tnikkel
When blending full frames off the main thread, FrameAnimator no longer
requires access to the raw data of the frame to advance the animation.
Now we only request a RawAccessFrameRef for the current/next frames when
we have discovered that we need to do blending on the main thread.

In addition to avoiding the mutex overhead of RawAccessFrameRef, this
will also facilitate potentially optimizing the surfaces for the
DrawTarget for individual animated image frames.

Differential Revision: https://phabricator.services.mozilla.com/D7506
2018-10-22 13:40:35 -04: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 8be55f0165 Bug 1337111 - Part 5. Add pref to force decoding of full frames, disabled by default. r=tnikkel 2018-09-17 15:06:29 -04:00
Coroiu Cristina de5411772c Backed out 6 changesets (bug 1337111) for build bustages at builds/worker/workspace/build/src/image/SurfaceFilters.h on a CLOSED TREE
Backed out changeset ca0caa556dc9 (bug 1337111)
Backed out changeset d7d7fa868d0d (bug 1337111)
Backed out changeset 93e956e89a21 (bug 1337111)
Backed out changeset f36337c1309b (bug 1337111)
Backed out changeset 1b1e25b0b345 (bug 1337111)
Backed out changeset 3785cdebe6a3 (bug 1337111)
2018-09-17 20:42:30 +03:00
Andrew Osmond f823b924c8 Bug 1337111 - Part 5. Add pref to force decoding of full frames, disabled by default. r=tnikkel 2018-09-17 13:21:38 -04:00
Tom Ritter ecde18b5d1 Bug 1473714 Remove unneeded commit in image/FrameAnimator.cpp:AdvanceFrame
Reviewers: tnikkel

Reviewed By: tnikkel

Bug #: 1473714

Differential Revision: https://phabricator.services.mozilla.com/D2622
2018-08-02 05:55:59 +03: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 d2e5cfae55 Bug 1462355 - Part 7. Don't hit the SurfaceCache in FrameAnimator::GetCompositedFrame if possible. r=tnikkel
In FrameAnimator::GetCompositedFrame, we call SurfaceCache::Lookup even
when we use the composited frame directly and leave the lookup result
unused. The only value in performing the lookup could be to mark the
surface as used to avoid expiring it too soon, but
FrameAnimator::RequestRefresh should already be doing enough to keep it
alive, if the image isn't locked in the first place.
2018-05-29 08:36:13 -04:00
Andrew Osmond 77b6f542e8 Bug 1462355 - Part 6. Reuse RawAccessFrameRef in FrameAnimator where possible. r=tnikkel
In FrameAnimator::RequestRefresh and AdvanceFrame, we currently create
several RawAccessFrameRef objects to the same frames, either to get
timeouts or perform the blending. With some tweaking, we can avoid
requesting the same frame more than once. This will avoid mutex locks on
the surface provider and the frame itself.
2018-05-29 08:36:12 -04:00
Andrew Osmond 8c7d13e7f7 Bug 1462355 - Part 5. Avoid converting from DrawableFrameRef to RawAccessFrameRef. r=tnikkel
DrawableSurface only exposes DrawableFrameRef to its users. This is
sufficient for the drawing related code in general, but FrameAnimator
really needs RawAccessFrameRef to the underlying pixel data (which may
be paletted). While one can get a RawAccessFrameRef from a
DrawableFrameRef, it requires yet another lock of the imgFrame's mutex.
We can avoid this extra lock if we just allow the callers to get the
right data type in the first place.
2018-05-29 08:36:12 -04:00
Andrew Osmond f1dd034aa6 Bug 1462355 - Part 3. Make FrameAnimator use the new imgFrame/RawAccessFrameRef methods. r=tnikkel 2018-05-29 08:36:12 -04:00
Andrew Osmond d19566e09c Bug 1454149 - Do not advance animated images which are not displayed. r=tnikkel
All animated images on a page are currently registered with the refresh
driver and advance with the tick refresh. These animations may not even
be in view, and if they are large and thus cause redecoding, cause a
marked increase in CPU usage for no benefit to the user.

This patch adds an additional flag, mCompositedFrameRequested, to the
AnimationState used by FrameAnimator. It is set to true each time the
current animated image frame is requested via
FrameAnimator::GetCompositedFrame. It is set to false each time the
frame is advanced in FrameAnimator::AdvanceFrame (via
FrameAnimator::RequestRefresh). If it is true when
FrameAnimator::RequestRefresh is called, then it will advance the
animation according to the normal rules. If it is false, then it will
set the current animation time to the current time instead of advancing.

This should not cause the animation to fall behind anymore or skip
frames more than it does today. This is because if
FrameAnimator::GetCompositedFrame is not called, then the internal state
of the animation is advancing ahead of what the user sees. Once it is
called, the new frame is far ahead of the previously displayed frame.
The only difference now is that we will display the previous frame for
slightly longer until the next refresh tick.

Note that if an animated image is layerized (should not happen today) or
otherwise uses an ImageContainer, this optimization fails. While we know
whether or not we have an image container, we do not know if anything is
actively using it.
2018-05-09 08:04:20 -04:00
Andrew Osmond 646219b1e7 Bug 523950 - Part 4. Expose new surface provider APIs that will help drive animation decoding. r=tnikkel
Note that AnimationSurfaceProvider will override these methods to give a
proper implementation in a later patch in this series. For now, they are
mostly stubbed, using the default implementation from ISurfaceProvider.

They focus on the main operations we perform on an animation:

1) Progressing through the animation, e.g. advancing a frame. If we
don't decode the whole animation up front, we need to know at the
decoder level where we are in the display of the animation.

2) Restarting an animation from the beginning. This is a specialized
case of the above, where we want to skip explicitly advancing through
the remaining frames and instead restart at the beginning. The decoder
may have already discarded the earliest frames and must start redecoding
them.

3) Knowing whether or not the decoder is still active, e.g. can we be
missing frames.
2018-02-28 13:34:52 -05: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
Milan Sreckovic d0d070b48c Bug 1423567: Use BaseRect access methods instead of member variables in image/ r=aosmond
MozReview-Commit-ID: JNYZsts6pCO

--HG--
extra : rebase_source : d37ce77ec84af302018f95285cff61b2ba28c957
2017-12-20 16:46:28 -05: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
Milan Sreckovic 5c01b5706c Bug 1387514: Upgrade BaseRect (derived classes) width and height direct member variable use to instead use Width()/SetWidth() and Height()/SetHeight() in image/*. r=aosmond
MozReview-Commit-ID: 8gyxxLziVe7

--HG--
extra : rebase_source : c79e81e10c54106645539c590bf81a03a300a909
2017-08-14 08:29:56 -04:00
Andrew Osmond b15e213fc9 Bug 1388733 - Ensure animations resume when the image surfaces are discarded while still decoding. r=tnikkel
When an animated image has been discarded, we avoided marking the
composited frame invalid unless it had been previously decoded. Most of
the time this was fine, but if the animated image was still decoding for
the first time, then we still had a composited frame lingering that we
did not mark as invalid. As a result, when we called
RasterImage::LookupFrame (and indirectly
FrameAnimator::GetCompositedFrame), it would always return the
composited frame. This meant that RasterImage::Decode would never be
called to trigger a redecode. At the same time,
FrameAnimator::RequestRefresh would not cause us to advance the frame
because the state was still discarded.

With this patch we separate out the concepts of "has ever requested to
be decoded" and "has ever completed decoding." The former is now used to
control whether or not a composited frame is marked as invalid after we
discover we currently have no surface for the animation -- this solves
the animation remaining frozen as we now request the redecode as
expected. The latter remains used to determine if we actually know the
total number of frames.
2017-08-09 22:26:55 -04:00
Nicholas Nethercote 58786e1ea7 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 17:08:53 +10:00
Timothy Nikkel 7be47e636c Bug 1374123. Correctly pass aAllowInvalidation flag from FrameAnimator::UpdateState to UpdateStateInternal. r=aosmond 2017-06-19 15:21:53 -05:00
Timothy Nikkel 5dbb032f4f Bug 1363092. Don't update the state of an animated image that requires an invalidation when creating a new decoder because we may not be able to send invalidations. r=aosmond 2017-06-01 02:19:55 -05:00
Timothy Nikkel 07c22d39dd Bug 1364365. Limit the number of full loops of an animated image we can skip to the number of remaining loops. r=aosmond
The optimization is incorrect if we try to skip ahead more full loops then are remaining in the loop count.
2017-05-24 16:20:41 -05:00
Timothy Nikkel c570406a5e Bug 1360572. Invalidate the whole animated image when the composited frame becomes valid. r=aosmond
We invalidate if FrameAnimator::UpdateState marks the composited frame as valid, but we fail to do so if FrameAnimator::RequestRefresh does so.

The other place that sets the composited frame as valid is RasterImage::Decode. This call is actually redundant because the UpdateState call will do the same.

Even though we will invalidate when the decode produces results we could still draw incorrectly if something else invalidates. In which case we would only draw the part of the image that was invalidated. But that should actually be impossible as explained in the comment.
2017-05-03 21:20:35 -05:00
Timothy Nikkel 432937f220 Bug 1361642. Return PENDING from FrameAnimator::GetCompositedFrame is a decode is pending so that we don't start another decode. r=aosmond 2017-05-04 01:25:10 -05:00
Iris Hsiao ab85c1ac98 Backed out changeset dda520b4ed32 (bug 1360572) for Assertion failure at RasterImage.cpp 2017-05-04 11:30:45 +08:00
Timothy Nikkel 82de893b0a Bug 1360572. Invalidate the whole animated image when the composited frame becomes valid. r=aosmond
We invalidate if FrameAnimator::UpdateState marks the composited frame as valid, but we fail to do so if FrameAnimator::RequestRefresh does so.

The other place that sets the composited frame as valid is RasterImage::Decode. This call is actually redundant because the UpdateState call will do the same.

Even though we will invalidate when the decode produces results we could still draw incorrectly if something else invalidates. In which case we would only draw the part of the image that was invalidated. But that should actually be impossible as explained in the comment.
2017-05-03 21:20:35 -05:00
Timothy Nikkel 91e6c26580 Bug 1353299. Make sure to invalidate when composited frame becomes valid. r=aosmond
We draw nothing when the composited frame is invalid, so when we mark it valid we should invalidate. Usually the action that causes the composited frame to be valid will invalidate (ie RequestRefresh).
2017-04-06 04:00:36 -05:00
Timothy Nikkel c11cd13119 Bug 1352008. Check return value of DrawableSurface::Seek because if it failed it will return the first frame when you ask for a frame. r=aosmond 2017-03-30 19:07:05 -05:00
Timothy Nikkel 1614a73bad Bug 1343341. Rewrite animation state updating to derive new state purely based on SurfaceCache and RasterImage::mAnimationFinished. r=aosmond
If the SurfaceCache discards our frames on another thread, the runnable that notifies us of that discard could race with a decode complete notification. So we can't rely on any ordering of SetDiscarded and NotifyDecodeComplete. Thus we must derive our state purely from the SurfaceCache (and mAnimationFinished from RasterImage).

We also update the image state in RequestRefresh (the main place where we use the state that is updated).

The other main place we use the state is GetCompositedFrame, but we don't update the state there. It should be fine because the only time this might lag behind reality is if the frames are discarded, and it should be fine to continue drawing the composited frame until the discard notification arrives.

The way that we tell that an animated image has all of its frames complete in the surface cache is less than ideal.
2017-03-26 00:04:53 -05:00
Timothy Nikkel 2776a4ad96 Bug 1343341. In FrameAnimator look up our frames once and pass them around. r=aosmond
The SurfaceCache can discard on any thread at any time. So we could be in the middle of advancing frames of a fully decoded animated image and then the frames could disappear out from under us.

Making the code deal with that kind of a situation would make the logic very complicated. So instead just look up the frames once and pass them around, that way they never change during while we are advancing the frame.
2017-03-24 00:57:30 -05:00
Timothy Nikkel 3d98a47ed8 Bug 1343341. Change GetTimeoutForFrame to return a Maybe, and make all callers deal with a lack of a return value. r=aosmond
Do this to allow GetTimeoutForFrame to be called for frames that haven't been decoded yet. Propagate a Maybe result where it makes sense. The remaining callers just bail if they get no return value. Many of them can just assert that they get a return value because they already got the same frame, so the timeout has to be available.

The logic is a little tricky because we have "Forever" timeouts that were sort of treated as error cases.
2017-03-23 00:02:54 -05:00
Timothy Nikkel e9cd32eecd Bug 1343341. Fix a bug with redecoding images whose animation is finished. r=aosmond
For animated images with finite animations we can finish running their animation. At which point we won't call RequestRefresh, and so we will never mark the composited frame as valid (since that is the only place we do that).

To fix this we mark the composited frame as valid when we finish decoding.

But we can do better than that, we can mark the composited frame as valid immediately when we create a new decoded since we are just drawing the final frame from now on.
2017-03-17 00:41:44 -05:00
Timothy Nikkel d69ec52e66 Bug 1343341. Create state on the AnimationState object to track whether the image is decoded or not. r=aosmond
We end up needing to track a few different things.

The large comment in the patch explains.
2017-03-16 03:06:04 -05:00
Timothy Nikkel bb32ac7fbf Backed out changeset a23edcf5b82a (bug 1343341) 2017-03-15 03:13:51 -05:00
Timothy Nikkel a2ceaae0b8 Bug 1343341. Create state on the AnimationState object to track whether the image is decoded or not. r=aosmond
We end up needing to track a few different things.

The large comment in the patch explains.
2017-03-15 02:47:37 -05:00
Timothy Nikkel d58225c24c Backed out changeset 7f13c7a84acb (bug 1343341) for hitting a fatal assert that it added in RasterImage::OnSurfaceDiscard sometimes on android reftests. 2017-03-02 02:24:29 -06:00
Timothy Nikkel add901e3a2 Bug 1343341. Include gfxPref.h to fix build bustage. 2017-03-01 23:05:44 -06:00
Timothy Nikkel 558fc1aa45 Bug 1343341. Create state on the AnimationState object to track whether the image is decoded or not. r=aosmond
We end up needing to track a few different things.

The large comment in the patch explains.
2017-03-01 22:45:54 -06:00
Timothy Nikkel 362304b8ee Bug 1343341. Rename mDoneDecoding to mHasBeenDecoded. r=aosmond
When we allow animated images to be discarded we still want to track if the image has been fully decoded before, but it would be confusing to say that it is "done decoding" because that sounds like the image is currently decoded, even though it could be discarded at the time.
2017-03-01 22:45:54 -06: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 c31478a16b Bug 1331938 - Part 3. Switch to using VolatileSourceSurface instead of VolatileBuffer directly in imgFrame. r=tnikkel 2017-01-18 13:31:20 -05:00
Andrew Osmond f978bf206a Bug 1319025 - Fix how animated images disposal method should use frame rect size instead of the image size as its bounds. r=tnikkel 2016-11-25 10:38:37 -05:00
Timothy Nikkel b69c01ee55 Bug 1317907. Refactor FrameAnimator::GetCompositedFrame to be a bit simpler. r=aosmond
FrameAnimator::GetCompositedFrame is only ever called with the current animation frame index. This is good because it can return invalid results if it is called for some other frame number.
2016-11-29 01:01:43 -06:00
Andrew Osmond 1d4866a48f Bug 1120279 - Always check if the next frame is available before advancing an animation. 2016-09-21 12:55:26 -04:00