/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** * An interface for tasks which can execute on the ImageLib DecodePool, and * various implementations.
*/
/// A priority hint that DecodePool can use when scheduling an IDecodingTask. enumclass TaskPriority : uint8_t { eLow, eHigh };
/** * An interface for tasks which can execute on the ImageLib DecodePool.
*/ class IDecodingTask : public IResumable { public: /// Run the task. virtualvoid Run() = 0;
/// @return true if, given the option, this task prefers to run synchronously. virtualbool ShouldPreferSyncRun() const = 0;
/// @return a priority hint that DecodePool can use when scheduling this task. virtual TaskPriority Priority() const = 0;
/// A default implementation of IResumable which resubmits the task to the /// DecodePool. Subclasses can override this if they need different behavior. void Resume() override;
/// Notify @aImage that @aDecoder has finished. void NotifyDecodeComplete(NotNull<RasterImage*> aImage,
NotNull<Decoder*> aDecoder);
};
/** * An IDecodingTask implementation for metadata decodes of images.
*/ class MetadataDecodingTask final : public IDecodingTask { public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MetadataDecodingTask, override)
// Metadata decodes are very fast (since they only need to examine an image's // header) so there's no reason to refuse to run them synchronously if the // caller will allow us to. bool ShouldPreferSyncRun() const override { returntrue; }
// Metadata decodes run at the highest priority because they block layout and // page load.
TaskPriority Priority() const override { return TaskPriority::eHigh; }
private: virtual ~MetadataDecodingTask() {}
/// Mutex protecting access to mDecoder.
Mutex mMutex MOZ_UNANNOTATED;
NotNull<RefPtr<Decoder>> mDecoder;
};
/** * An IDecodingTask implementation for anonymous decoders - that is, decoders * with no associated Image object.
*/ class AnonymousDecodingTask : public IDecodingTask { public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AnonymousDecodingTask, override)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.