mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1177615 - Rip everything related to FLAG_DECODE_STARTED out of ImageLib. r=tn
This commit is contained in:
parent
f5e251adb3
commit
a6509b47cc
@ -83,10 +83,6 @@ Decoder::Init()
|
||||
// No re-initializing
|
||||
MOZ_ASSERT(!mInitialized, "Can't re-initialize a decoder!");
|
||||
|
||||
if (!IsSizeDecode()) {
|
||||
mProgress |= FLAG_DECODE_STARTED;
|
||||
}
|
||||
|
||||
// Implementation-specific initialization
|
||||
InitInternal();
|
||||
|
||||
|
@ -45,7 +45,6 @@ public:
|
||||
|
||||
// Other, internal-only methods:
|
||||
virtual void SetHasImage() = 0;
|
||||
virtual void OnStartDecode() = 0;
|
||||
virtual bool NotificationsDeferred() const = 0;
|
||||
virtual void SetNotificationsDeferred(bool aDeferNotifications) = 0;
|
||||
|
||||
|
@ -76,7 +76,6 @@ public:
|
||||
virtual void BlockOnload() override { }
|
||||
virtual void UnblockOnload() override { }
|
||||
virtual void SetHasImage() override { }
|
||||
virtual void OnStartDecode() override { }
|
||||
virtual bool NotificationsDeferred() const override { return false; }
|
||||
virtual void SetNotificationsDeferred(bool) override { }
|
||||
|
||||
@ -315,12 +314,6 @@ MultipartImage::SetHasImage()
|
||||
mTracker->OnImageAvailable();
|
||||
}
|
||||
|
||||
void
|
||||
MultipartImage::OnStartDecode()
|
||||
{
|
||||
mTracker->SyncNotifyProgress(FLAG_DECODE_STARTED);
|
||||
}
|
||||
|
||||
bool
|
||||
MultipartImage::NotificationsDeferred() const
|
||||
{
|
||||
|
@ -58,7 +58,6 @@ public:
|
||||
const nsIntRect* aRect = nullptr) override;
|
||||
virtual void OnLoadComplete(bool aLastPart) override;
|
||||
virtual void SetHasImage() override;
|
||||
virtual void OnStartDecode() override;
|
||||
virtual bool NotificationsDeferred() const override;
|
||||
virtual void SetNotificationsDeferred(bool aDeferNotifications) override;
|
||||
|
||||
|
@ -30,14 +30,11 @@ CheckProgressConsistency(Progress aProgress)
|
||||
if (aProgress & FLAG_SIZE_AVAILABLE) {
|
||||
// No preconditions.
|
||||
}
|
||||
if (aProgress & FLAG_DECODE_STARTED) {
|
||||
if (aProgress & FLAG_DECODE_COMPLETE) {
|
||||
// No preconditions.
|
||||
}
|
||||
if (aProgress & FLAG_DECODE_COMPLETE) {
|
||||
MOZ_ASSERT(aProgress & FLAG_DECODE_STARTED);
|
||||
}
|
||||
if (aProgress & FLAG_FRAME_COMPLETE) {
|
||||
MOZ_ASSERT(aProgress & FLAG_DECODE_STARTED);
|
||||
// No preconditions.
|
||||
}
|
||||
if (aProgress & FLAG_LOAD_COMPLETE) {
|
||||
// No preconditions.
|
||||
@ -50,7 +47,6 @@ CheckProgressConsistency(Progress aProgress)
|
||||
MOZ_ASSERT(aProgress & (FLAG_SIZE_AVAILABLE | FLAG_HAS_ERROR));
|
||||
}
|
||||
if (aProgress & FLAG_IS_ANIMATED) {
|
||||
MOZ_ASSERT(aProgress & FLAG_DECODE_STARTED);
|
||||
MOZ_ASSERT(aProgress & FLAG_SIZE_AVAILABLE);
|
||||
}
|
||||
if (aProgress & FLAG_HAS_TRANSPARENCY) {
|
||||
@ -90,9 +86,6 @@ ProgressTracker::GetImageStatus() const
|
||||
if (mProgress & FLAG_SIZE_AVAILABLE) {
|
||||
status |= imgIRequest::STATUS_SIZE_AVAILABLE;
|
||||
}
|
||||
if (mProgress & FLAG_DECODE_STARTED) {
|
||||
status |= imgIRequest::STATUS_DECODE_STARTED;
|
||||
}
|
||||
if (mProgress & FLAG_DECODE_COMPLETE) {
|
||||
status |= imgIRequest::STATUS_DECODE_COMPLETE;
|
||||
}
|
||||
@ -275,10 +268,6 @@ ProgressTracker::SyncNotifyInternal(ObserverArray& aObservers,
|
||||
NOTIFY_IMAGE_OBSERVERS(aObservers, Notify(I::SIZE_AVAILABLE));
|
||||
}
|
||||
|
||||
if (aProgress & FLAG_DECODE_STARTED) {
|
||||
NOTIFY_IMAGE_OBSERVERS(aObservers, OnStartDecode());
|
||||
}
|
||||
|
||||
if (aProgress & FLAG_ONLOAD_BLOCKED) {
|
||||
NOTIFY_IMAGE_OBSERVERS(aObservers, BlockOnload());
|
||||
}
|
||||
|
@ -28,16 +28,15 @@ class Image;
|
||||
// Image progress bitflags.
|
||||
enum {
|
||||
FLAG_SIZE_AVAILABLE = 1u << 0, // STATUS_SIZE_AVAILABLE
|
||||
FLAG_DECODE_STARTED = 1u << 1, // STATUS_DECODE_STARTED
|
||||
FLAG_DECODE_COMPLETE = 1u << 2, // STATUS_DECODE_COMPLETE
|
||||
FLAG_FRAME_COMPLETE = 1u << 3, // STATUS_FRAME_COMPLETE
|
||||
FLAG_LOAD_COMPLETE = 1u << 4, // STATUS_LOAD_COMPLETE
|
||||
FLAG_ONLOAD_BLOCKED = 1u << 5,
|
||||
FLAG_ONLOAD_UNBLOCKED = 1u << 6,
|
||||
FLAG_IS_ANIMATED = 1u << 7, // STATUS_IS_ANIMATED
|
||||
FLAG_HAS_TRANSPARENCY = 1u << 8, // STATUS_HAS_TRANSPARENCY
|
||||
FLAG_LAST_PART_COMPLETE = 1u << 9,
|
||||
FLAG_HAS_ERROR = 1u << 10 // STATUS_ERROR
|
||||
FLAG_DECODE_COMPLETE = 1u << 1, // STATUS_DECODE_COMPLETE
|
||||
FLAG_FRAME_COMPLETE = 1u << 2, // STATUS_FRAME_COMPLETE
|
||||
FLAG_LOAD_COMPLETE = 1u << 3, // STATUS_LOAD_COMPLETE
|
||||
FLAG_ONLOAD_BLOCKED = 1u << 4,
|
||||
FLAG_ONLOAD_UNBLOCKED = 1u << 5,
|
||||
FLAG_IS_ANIMATED = 1u << 6, // STATUS_IS_ANIMATED
|
||||
FLAG_HAS_TRANSPARENCY = 1u << 7, // STATUS_HAS_TRANSPARENCY
|
||||
FLAG_LAST_PART_COMPLETE = 1u << 8,
|
||||
FLAG_HAS_ERROR = 1u << 9 // STATUS_ERROR
|
||||
};
|
||||
|
||||
typedef uint32_t Progress;
|
||||
|
@ -1238,12 +1238,8 @@ RasterImage::NotifyForLoadEvent(Progress aProgress)
|
||||
if (mDecodeOnlyOnDraw) {
|
||||
// For decode-only-on-draw images, we want to send notifications as if we've
|
||||
// already finished decoding. Otherwise some observers will never even try
|
||||
// to draw. (We may have already sent some of these notifications from
|
||||
// NotifyForDecodeOnlyOnDraw(), but ProgressTracker will ensure no duplicate
|
||||
// notifications get sent.)
|
||||
aProgress |= FLAG_DECODE_STARTED |
|
||||
FLAG_FRAME_COMPLETE |
|
||||
FLAG_DECODE_COMPLETE;
|
||||
// to draw.
|
||||
aProgress |= FLAG_FRAME_COMPLETE | FLAG_DECODE_COMPLETE;
|
||||
}
|
||||
|
||||
// If we encountered an error, make sure we notify for that as well.
|
||||
@ -1255,19 +1251,6 @@ RasterImage::NotifyForLoadEvent(Progress aProgress)
|
||||
NotifyProgress(aProgress);
|
||||
}
|
||||
|
||||
void
|
||||
RasterImage::NotifyForDecodeOnlyOnDraw()
|
||||
{
|
||||
if (!NS_IsMainThread()) {
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
NS_NewRunnableMethod(this, &RasterImage::NotifyForDecodeOnlyOnDraw);
|
||||
NS_DispatchToMainThread(runnable);
|
||||
return;
|
||||
}
|
||||
|
||||
NotifyProgress(FLAG_DECODE_STARTED);
|
||||
}
|
||||
|
||||
nsresult
|
||||
RasterImage::OnImageDataAvailable(nsIRequest*,
|
||||
nsISupports*,
|
||||
@ -1277,12 +1260,6 @@ RasterImage::OnImageDataAvailable(nsIRequest*,
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (MOZ_UNLIKELY(mDecodeOnlyOnDraw && aOffset == 0)) {
|
||||
// If we're a decode-only-on-draw image, send notifications as if we've just
|
||||
// started decoding.
|
||||
NotifyForDecodeOnlyOnDraw();
|
||||
}
|
||||
|
||||
// WriteToSourceBuffer always consumes everything it gets if it doesn't run
|
||||
// out of memory.
|
||||
uint32_t bytesRead;
|
||||
@ -1635,14 +1612,6 @@ RasterImage::Decode(const Maybe<IntSize>& aSize, uint32_t aFlags)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aSize) {
|
||||
// This isn't a size decode (which doesn't send any early notifications), so
|
||||
// send out notifications right away.
|
||||
NotifyProgress(decoder->TakeProgress(),
|
||||
decoder->TakeInvalidRect(),
|
||||
decoder->GetDecodeFlags());
|
||||
}
|
||||
|
||||
if (mHasSourceData) {
|
||||
// If we have all the data, we can sync decode if requested.
|
||||
if (aFlags & FLAG_SYNC_DECODE) {
|
||||
|
@ -246,7 +246,6 @@ public:
|
||||
bool aLastPart) override;
|
||||
|
||||
void NotifyForLoadEvent(Progress aProgress);
|
||||
void NotifyForDecodeOnlyOnDraw();
|
||||
|
||||
/**
|
||||
* A hint of the number of bytes of source data that the image contains. If
|
||||
|
@ -1095,12 +1095,10 @@ VectorImage::OnStartRequest(nsIRequest* aRequest, nsISupports* aCtxt)
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Sending StartDecode will block page load until the document's ready. (We
|
||||
// unblock it by sending StopDecode in OnSVGDocumentLoaded or
|
||||
// OnSVGDocumentError.)
|
||||
// Block page load until the document's ready. (We unblock it in
|
||||
// OnSVGDocumentLoaded or OnSVGDocumentError.)
|
||||
if (mProgressTracker) {
|
||||
mProgressTracker->SyncNotifyProgress(FLAG_DECODE_STARTED |
|
||||
FLAG_ONLOAD_BLOCKED);
|
||||
mProgressTracker->SyncNotifyProgress(FLAG_ONLOAD_BLOCKED);
|
||||
}
|
||||
|
||||
// Create a listener to wait until the SVG document is fully loaded, which
|
||||
|
@ -19,7 +19,7 @@ interface nsIPrincipal;
|
||||
* @version 0.1
|
||||
* @see imagelib2
|
||||
*/
|
||||
[scriptable, builtinclass, uuid(83a7708b-5c35-409f-bab3-7fc08be6a264)]
|
||||
[scriptable, builtinclass, uuid(4cb01f0a-ef94-4345-a8d7-1a93f15ff548)]
|
||||
interface imgIRequest : nsIRequest
|
||||
{
|
||||
/**
|
||||
@ -47,9 +47,6 @@ interface imgIRequest : nsIRequest
|
||||
*
|
||||
* STATUS_ERROR: An error occurred loading the image.
|
||||
*
|
||||
* STATUS_DECODE_STARTED: The decoding process has begun, but not yet
|
||||
* finished.
|
||||
*
|
||||
* STATUS_FRAME_COMPLETE: The first frame has been
|
||||
* completely decoded.
|
||||
*
|
||||
@ -64,11 +61,10 @@ interface imgIRequest : nsIRequest
|
||||
const long STATUS_SIZE_AVAILABLE = 0x1;
|
||||
const long STATUS_LOAD_COMPLETE = 0x2;
|
||||
const long STATUS_ERROR = 0x4;
|
||||
const long STATUS_DECODE_STARTED = 0x8;
|
||||
const long STATUS_FRAME_COMPLETE = 0x10;
|
||||
const long STATUS_DECODE_COMPLETE = 0x20;
|
||||
const long STATUS_IS_ANIMATED = 0x40;
|
||||
const long STATUS_HAS_TRANSPARENCY = 0x80;
|
||||
const long STATUS_FRAME_COMPLETE = 0x8;
|
||||
const long STATUS_DECODE_COMPLETE = 0x10;
|
||||
const long STATUS_IS_ANIMATED = 0x20;
|
||||
const long STATUS_HAS_TRANSPARENCY = 0x40;
|
||||
//@}
|
||||
|
||||
/**
|
||||
|
@ -912,6 +912,7 @@ struct NewPartResult final
|
||||
: mImage(aExistingImage)
|
||||
, mIsFirstPart(!aExistingImage)
|
||||
, mSucceeded(false)
|
||||
, mShouldResetCacheEntry(false)
|
||||
{ }
|
||||
|
||||
nsAutoCString mContentType;
|
||||
@ -919,6 +920,7 @@ struct NewPartResult final
|
||||
nsRefPtr<Image> mImage;
|
||||
const bool mIsFirstPart;
|
||||
bool mSucceeded;
|
||||
bool mShouldResetCacheEntry;
|
||||
};
|
||||
|
||||
static NewPartResult
|
||||
@ -978,6 +980,9 @@ PrepareForNewPart(nsIRequest* aRequest, nsIInputStream* aInStr, uint32_t aCount,
|
||||
// Transition to the new part.
|
||||
auto multipartImage = static_cast<MultipartImage*>(aExistingImage);
|
||||
multipartImage->BeginTransitionToPart(partImage);
|
||||
|
||||
// Reset our cache entry size so it doesn't keep growing without bound.
|
||||
result.mShouldResetCacheEntry = true;
|
||||
}
|
||||
} else {
|
||||
MOZ_ASSERT(!aExistingImage, "New part for non-multipart channel?");
|
||||
@ -1039,6 +1044,10 @@ imgRequest::FinishPreparingForNewPart(const NewPartResult& aResult)
|
||||
MOZ_ASSERT(progressTracker->HasImage());
|
||||
}
|
||||
|
||||
if (aResult.mShouldResetCacheEntry) {
|
||||
ResetCacheEntry();
|
||||
}
|
||||
|
||||
if (IsDecodeRequested()) {
|
||||
aResult.mImage->RequestDecode();
|
||||
}
|
||||
|
@ -804,21 +804,6 @@ imgRequestProxy::GetHasTransferredData(bool* hasData)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
imgRequestProxy::OnStartDecode()
|
||||
{
|
||||
// This notification is deliberately not propagated since there are no
|
||||
// listeners who care about it.
|
||||
if (GetOwner()) {
|
||||
// In the case of streaming jpegs, it is possible to get multiple
|
||||
// OnStartDecodes which indicates the beginning of a new decode. The cache
|
||||
// entry's size therefore needs to be reset to 0 here. If we do not do
|
||||
// this, the code in ProgressTrackerObserver::OnStopFrame will continue to
|
||||
// increase the data size cumulatively.
|
||||
GetOwner()->ResetCacheEntry();
|
||||
}
|
||||
}
|
||||
|
||||
static const char*
|
||||
NotificationTypeToString(int32_t aType)
|
||||
{
|
||||
|
@ -107,7 +107,6 @@ public:
|
||||
|
||||
// Other, internal-only methods:
|
||||
virtual void SetHasImage() override;
|
||||
virtual void OnStartDecode() override;
|
||||
|
||||
// Whether we want notifications from ProgressTracker to be deferred until
|
||||
// an event it has scheduled has been fired.
|
||||
|
Loading…
Reference in New Issue
Block a user