summaryrefslogtreecommitdiffstats
path: root/image/imgFrame.h
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-11-20 20:38:49 +0100
committerwolfbeast <mcwerewolf@gmail.com>2018-11-20 20:38:49 +0100
commit807acf738f63d95fbecfb9129092aaa2379889ba (patch)
treed701e0f93dca6b66759a784e7d8a53f18d66ff3c /image/imgFrame.h
parent238b430ec0446d08a8fd513ae7b4000b5996fd69 (diff)
downloadUXP-807acf738f63d95fbecfb9129092aaa2379889ba.tar
UXP-807acf738f63d95fbecfb9129092aaa2379889ba.tar.gz
UXP-807acf738f63d95fbecfb9129092aaa2379889ba.tar.lz
UXP-807acf738f63d95fbecfb9129092aaa2379889ba.tar.xz
UXP-807acf738f63d95fbecfb9129092aaa2379889ba.zip
Bug 1462355 - Part 1a. Make imgFrame animation parameters threadsafe.
We currently choose to set the animation parameters (blend method, blend rect, disposal method, timeout) in imgFrame::Finish instead of imgFrame::InitForDecoder. The decoders themselves already have access to the necessary information at the time InitForDecoder is called, so there is no reason to do this. Moving the configuration to initialization will allow us to relax the mutex protection on these parameters. This part simply reorganizes imgFrame, and subsequent parts will introduce the necessary changes to SurfacePipe and decoders.
Diffstat (limited to 'image/imgFrame.h')
-rw-r--r--image/imgFrame.h72
1 files changed, 26 insertions, 46 deletions
diff --git a/image/imgFrame.h b/image/imgFrame.h
index e864aca7f..32aabacae 100644
--- a/image/imgFrame.h
+++ b/image/imgFrame.h
@@ -12,6 +12,7 @@
#include "mozilla/Monitor.h"
#include "mozilla/Move.h"
#include "mozilla/VolatileBuffer.h"
+#include "AnimationParams.h"
#include "gfxDrawable.h"
#include "imgIContainer.h"
#include "MainThreadUtils.h"
@@ -23,24 +24,6 @@ class ImageRegion;
class DrawableFrameRef;
class RawAccessFrameRef;
-enum class BlendMethod : int8_t {
- // All color components of the frame, including alpha, overwrite the current
- // contents of the frame's output buffer region.
- SOURCE,
-
- // The frame should be composited onto the output buffer based on its alpha,
- // using a simple OVER operation.
- OVER
-};
-
-enum class DisposalMethod : int8_t {
- CLEAR_ALL = -1, // Clear the whole image, revealing what's underneath.
- NOT_SPECIFIED, // Leave the frame and let the new frame draw on top.
- KEEP, // Leave the frame and let the new frame draw on top.
- CLEAR, // Clear the frame's area, revealing what's underneath.
- RESTORE_PREVIOUS // Restore the previous (composited) frame.
-};
-
enum class Opacity : uint8_t {
FULLY_OPAQUE,
SOME_TRANSPARENCY
@@ -210,14 +193,19 @@ public:
const nsIntRect& aRect,
SurfaceFormat aFormat,
uint8_t aPaletteDepth = 0,
- bool aNonPremult = false);
+ bool aNonPremult = false,
+ const Maybe<AnimationParams>& aAnimParams = Nothing());
nsresult InitForDecoder(const nsIntSize& aSize,
SurfaceFormat aFormat,
uint8_t aPaletteDepth = 0)
{
- return InitForDecoder(aSize, nsIntRect(0, 0, aSize.width, aSize.height),
- aFormat, aPaletteDepth);
+ nsIntRect frameRect(0, 0, aSize.width, aSize.height);
+ AnimationParams animParams { frameRect, FrameTimeout::Forever(),
+ /* aFrameNum */ 1, BlendMethod::OVER,
+ DisposalMethod::NOT_SPECIFIED };
+ return InitForDecoder(aSize, frameRect,
+ aFormat, aPaletteDepth, false, Some(animParams));
}
@@ -268,22 +256,8 @@ public:
* RawAccessFrameRef pointing to an imgFrame.
*
* @param aFrameOpacity Whether this imgFrame is opaque.
- * @param aDisposalMethod For animation frames, how this imgFrame is cleared
- * from the compositing frame before the next frame is
- * displayed.
- * @param aTimeout For animation frames, the timeout before the next
- * frame is displayed.
- * @param aBlendMethod For animation frames, a blending method to be used
- * when compositing this frame.
- * @param aBlendRect For animation frames, if present, the subrect in
- * which @aBlendMethod applies. Outside of this
- * subrect, BlendMethod::OVER is always used.
*/
- void Finish(Opacity aFrameOpacity = Opacity::SOME_TRANSPARENCY,
- DisposalMethod aDisposalMethod = DisposalMethod::KEEP,
- FrameTimeout aTimeout = FrameTimeout::FromRawMilliseconds(0),
- BlendMethod aBlendMethod = BlendMethod::OVER,
- const Maybe<IntRect>& aBlendRect = Nothing());
+ void Finish(Opacity aFrameOpacity = Opacity::SOME_TRANSPARENCY);
/**
* Mark this imgFrame as aborted. This informs the imgFrame that if it isn't
@@ -322,9 +296,15 @@ public:
*/
uint32_t GetBytesPerPixel() const { return GetIsPaletted() ? 1 : 4; }
- IntSize GetImageSize() const { return mImageSize; }
- IntRect GetRect() const { return mFrameRect; }
+ const IntSize& GetImageSize() const { return mImageSize; }
+ const IntRect& GetRect() const { return mFrameRect; }
IntSize GetSize() const { return mFrameRect.Size(); }
+ const IntRect& GetBlendRect() const { return mBlendRect; }
+ IntRect GetBoundedBlendRect() const { return mBlendRect.Intersect(mFrameRect); }
+ FrameTimeout GetTimeout() const { return mTimeout; }
+ BlendMethod GetBlendMethod() const { return mBlendMethod; }
+ DisposalMethod GetDisposalMethod() const { return mDisposalMethod; }
+ bool FormatHasAlpha() const { return mFormat == SurfaceFormat::B8G8R8A8; }
void GetImageData(uint8_t** aData, uint32_t* length) const;
uint8_t* GetImageData() const;
@@ -406,14 +386,6 @@ private: // data
//! Number of RawAccessFrameRefs currently alive for this imgFrame.
int32_t mLockCount;
- //! The timeout for this frame.
- FrameTimeout mTimeout;
-
- DisposalMethod mDisposalMethod;
- BlendMethod mBlendMethod;
- Maybe<IntRect> mBlendRect;
- SurfaceFormat mFormat;
-
bool mHasNoAlpha;
bool mAborted;
bool mFinished;
@@ -426,6 +398,14 @@ private: // data
IntSize mImageSize;
IntRect mFrameRect;
+ IntRect mBlendRect;
+
+ //! The timeout for this frame.
+ FrameTimeout mTimeout;
+
+ DisposalMethod mDisposalMethod;
+ BlendMethod mBlendMethod;
+ SurfaceFormat mFormat;
// The palette and image data for images that are paletted, since Cairo
// doesn't support these images.