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

68 Коммитов

Автор SHA1 Сообщение Дата
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
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
Seth Fowler 97b4a5d8c7 Bug 1289957 (Part 2) - Notify RasterImage about new frames in NotifyProgress() and remove OnAddedFrame(). r=edwin 2016-07-28 00:12:50 -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 dc9bddc5cd Bug 1288040 (Part 12) - Use Moz2D types in FrameAnimator code. r=edwin 2016-07-20 16:30:44 -07:00
Seth Fowler 8bb93146a8 Bug 1288040 (Part 11) - Clean up RefreshResult. r=edwin 2016-07-20 16:30:41 -07:00
Seth Fowler 3e8d8d790f Bug 1288040 (Part 10) - Determine the first frame refresh area of animated images while decoding them. r=edwin 2016-07-20 16:30:39 -07:00
Seth Fowler 642c28d837 Bug 1288040 (Part 9) - Determine the loop length of animated images while decoding them. r=edwin 2016-07-20 16:30:36 -07:00
Seth Fowler 049339870a Bug 1288040 (Part 8) - Return a FrameTimeout value from FrameAnimator::GetSingleLoopTime(). r=edwin 2016-07-20 16:30:34 -07:00
Seth Fowler 930f26424f Bug 1288040 (Part 7) - Make FrameAnimator::GetTimeoutForFrame() a private method that doesn't rely on AnimationState. r=edwin 2016-07-20 16:30:32 -07:00
Seth Fowler 78ccdc2e84 Bug 1288040 (Part 5) - Wrap frame timeout values in a FrameTimeout type that ensures they're normalized. r=edwin 2016-07-20 16:30:28 -07:00
Seth Fowler 4306ec9de5 Bug 1288040 (Part 3) - Get rid of RefreshResult.error, a field which nothing cares about. r=edwin 2016-07-20 16:30:24 -07:00
Seth Fowler 4af805ced1 Bug 1288040 (Part 2) - Don't reset the last composited frame index when we reset animation. r=edwin 2016-07-20 16:30:21 -07:00
Seth Fowler 34caf5552c Bug 1288040 (Part 1) - Separate FrameAnimator's state into a separate class, AnimationState. r=edwin 2016-07-20 16:30:19 -07:00
Seth Fowler 17074a1b49 Bug 1255107 (Part 3) - Use SurfacePipe in the PNG decoder. r=njn 2016-06-25 14:04:05 -07:00
Nicholas Nethercote 9ec20a644f Bug 1277122 - Add missing null checks for pixman_image_create_bits(). r=seth,lsalzman.
--HG--
extra : rebase_source : dec917d2efd9a262bd06816dcbb541acd3892340
2016-06-01 14:27:30 +10: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 931f4f6e1d Bug 1251405. Part 2. Use 64 bit ints to hold the delay between the current time and the last animation time. r=edwin
When storing ms, 32 bit ints can hold 2^32/1000/60/60/24 ~= 49 days. It's quite conceivable that someone would leave a tab in the background for 50 days.
2016-03-04 21:54:03 -06:00
Timothy Nikkel 01190b0b2c Bug 1251405. Part 1. Fix a significant signed/unsigned mismatch in handling the return value of FrameAnimator::GetSingleLoopTime. r=edwin
GetSingleLoopTime returns -1 on exceptional cases but we used an unsigned int to hold the return value in AdvanceFrame. So the |loopTime > 0| check would succeed. Fortunately the |delay.ToMilliseconds() > loopTime| check would fail because loopTime was MAX_UNIT32, so we didn't do anything incorrect.

http://hg.mozilla.org/mozilla-central/rev/263980931d1b (bug 890743) changed GetSingleLoopTime from returning 0 (and uint32_t) to -1 (and int32_t) on exceptional cases. But the caller of GetSingleLoopTime wasn't updated.
2016-03-04 21:54:00 -06:00
Timothy Nikkel 0676b70928 Bug 1251403. Determine the correct index of the next frame before getting the next frame. r=edwin
With the addition of the mDoneDecoding check to this code it is now safe to move it before the canDisplay check.
2016-03-02 21:52:36 -06:00