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

57 Коммитов

Автор SHA1 Сообщение Дата
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
Timothy Nikkel fbd3ebdb6d Bug 926048. Part 4. Update the current animation frame time if we hit the end of decoded frames before all frames are decoded. r=edwin
Before the previous patch we would (wrongly) loop through the decoded frames even though we didn't have all of the frames of the animation. This had the beneficial side effect of advancing mCurrentAnimationFrameTime to aTime (the current time). With the previous patch we stop at the last decoded frame and don't advance mCurrentAnimationFrameTime, so it can lag behind. The problem with this is that when we have finished decoding we will then try to catch mCurrentAnimationFrameTime up, and this will jump us to a random point in the animation. So we need to advance mCurrentAnimationFrameTime ourselves.

If we were blocked on network/decoding then displaying the last available decoded frame is the correct frame to be displaying. So we are up to date. So we advance mCurrentAnimationFrameTime to the current time.
2016-03-01 22:34:40 -06:00
Timothy Nikkel 9199efb919 Bug 926048. Part 3. Correctly check if we are at the end of an animated image. r=edwin
mImage->GetNumFrames() is the current number of decoded frames (that the RasterImage knows about), so it only represents the last frame of the animation if we are done decoding.

If we are not fully decoded, and we are on the last decoded frame, just stay on the last decoded frame. When more frames get decoded (or we determine that we are the last frame of the animation) we will advance.

One might expect that if |nextFrameIndex == mImage->GetNumFrames()| then |GetRawFrame(nextFrameIndex)| would return a null surface. But that is not the case because the decoding thread can insert frames into the surface cache that the RasterImage hasn't acknowledged yet (because it has to do so on the main thread, which we are currently running on).

This is why moving animated images to the surface cache is likely the cause of this bug.

This introduces an issue that is explained in, and fixed by the next patch.
2016-03-01 22:34:40 -06:00
Timothy Nikkel 4bad8c1f9e Bug 926048. Part 2. Remove useless GetRawFrame call. r=edwin
|nextFrameIndex| is either |currentFrameIndex + 1| or 0, as can be seen from reading the code above this.

Also fix the whitespace on DoBlend call.
2016-03-01 22:34:39 -06:00
Timothy Nikkel 57a929ef04 Bug 926048. Part 1. Simplify FrameAnimator::AdvanceFrame slightly. We don't need a |timeout| variable, we only check it once. r=edwin 2016-03-01 22:34:39 -06:00
Chris Peterson c5cfbed605 Bug 1235297 - Annotate intentional switch fallthroughs to suppress -Wimplicit-fallthrough warnings in image/decoders/. r=tn
image/FrameAnimator.cpp:442:5: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
image/FrameAnimator.cpp:576:7: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]

image/decoders/nsGIFDecoder2.cpp:1110:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels

image/decoders/nsJPEGDecoder.cpp:418:3 [-Wimplicit-fallthrough] unannotated fall-through between switch labels
image/decoders/nsJPEGDecoder.cpp:444:3 [-Wimplicit-fallthrough] unannotated fall-through between switch labels
image/decoders/nsJPEGDecoder.cpp:465:3 [-Wimplicit-fallthrough] unannotated fall-through between switch labels
image/decoders/nsJPEGDecoder.cpp:537:3 [-Wimplicit-fallthrough] unannotated fall-through between switch labels

--HG--
extra : rebase_source : ec1da93105ef06d156d9d60ae8950d04f3197e38
2015-12-24 23:50:32 -07:00
David Rajchenbach-Teller 583ca7286d Bug 1224374 - Profiler labels for the top 26-100 chrome hangs;r=BenWa
--HG--
extra : rebase_source : 39e94507c0288863e495322a6899ff009840870d
2016-01-15 11:38:03 +01:00
Sebastian Hengst d8d4a2d1a5 Backed out 2 changesets (bug 1224374) for Windows bustage. r=bustage on a CLOSED TREE
Backed out changeset 5f458e6e4997 (bug 1224374)
Backed out changeset 0dc02cb0b604 (bug 1224374)
2016-01-19 21:30:41 +01:00
David Rajchenbach-Teller 2d53758d08 Bug 1224374 - Profiler labels for the top 26-100 chrome hangs;r=BenWa
--HG--
extra : rebase_source : 51d39d6f88bf58ccb29f5897c3dbbe71007ee842
2016-01-15 11:38:03 +01:00
Nathan Froyd 01583602a9 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
The bulk of this commit was generated with a script, executed at the top
level of a typical source code checkout.  The only non-machine-generated
part was modifying MFBT's moz.build to reflect the new naming.

CLOSED TREE makes big refactorings like this a piece of cake.

 # The main substitution.
find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \
    xargs perl -p -i -e '
 s/nsRefPtr\.h/RefPtr\.h/g; # handle includes
 s/nsRefPtr ?</RefPtr</g;   # handle declarations and variables
'

 # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h.
perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h

 # Handle nsRefPtr.h itself, a couple places that define constructors
 # from nsRefPtr, and code generators specially.  We do this here, rather
 # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename
 # things like nsRefPtrHashtable.
perl -p -i -e 's/nsRefPtr/RefPtr/g' \
     mfbt/nsRefPtr.h \
     xpcom/glue/nsCOMPtr.h \
     xpcom/base/OwningNonNull.h \
     ipc/ipdl/ipdl/lower.py \
     ipc/ipdl/ipdl/builtin.py \
     dom/bindings/Codegen.py \
     python/lldbutils/lldbutils/utils.py

 # In our indiscriminate substitution above, we renamed
 # nsRefPtrGetterAddRefs, the class behind getter_AddRefs.  Fix that up.
find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \
    xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g'

if [ -d .git ]; then
    git mv mfbt/nsRefPtr.h mfbt/RefPtr.h
else
    hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h
fi

--HG--
rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 01:24:48 -04:00
Seth Fowler f89ca1d90f Bug 1185800 - Add DecoderFlags and SurfaceFlags enum classes and use them instead of imgIContainer flags in all decoder-related code. r=tn 2015-08-14 17:56:44 -07:00
Seth Fowler 7e909725b3 Bug 1194059 (Part 2) - Always detect IS_ANIMATED during the metadata decode. r=tn 2015-08-14 00:37:13 -07:00