Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  ImageUtils.h   Sprache: C

 
/* -*- 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/. */


#ifndef mozilla_image_ImageUtils_h
#define mozilla_image_ImageUtils_h

#include "FrameTimeout.h"
#include "mozilla/image/SurfaceFlags.h"
#include "mozilla/Assertions.h"
#include "mozilla/Maybe.h"
#include "mozilla/MozPromise.h"
#include "mozilla/RefPtr.h"
#include "mozilla/ThreadSafeWeakPtr.h"
#include "nsString.h"
#include "nsTArray.h"

namespace mozilla {
class ErrorResult;

namespace gfx {
class SourceSurface;
}

namespace image {
class Decoder;
class imgFrame;
class ImageMetadata;
class SourceBuffer;

/**
 * The type of decoder; this is usually determined from a MIME type using
 * DecoderFactory::GetDecoderType() or ImageUtils::GetDecoderType().
 */

enum class DecoderType {
  PNG,
  GIF,
  JPEG,
  BMP,
  BMP_CLIPBOARD,
  ICO,
  ICON,
  WEBP,
  AVIF,
  JXL,
  UNKNOWN
};

struct DecodeMetadataResult {
  int32_t mWidth = 0;
  int32_t mHeight = 0;
  int32_t mRepetitions = -1;
  uint32_t mFrameCount = 0;
  bool mAnimated = false;
  bool mFrameCountComplete = true;
};

struct DecodeFrameCountResult {
  uint32_t mFrameCount = 0;
  bool mFinished = false;
};

struct DecodedFrame {
  RefPtr<gfx::SourceSurface> mSurface;
  FrameTimeout mTimeout;
};

struct DecodeFramesResult {
  nsTArray<DecodedFrame> mFrames;
  bool mFinished = false;
};

using DecodeMetadataPromise = MozPromise<DecodeMetadataResult, nsresult, true>;
using DecodeFrameCountPromise =
    MozPromise<DecodeFrameCountResult, nsresult, true>;
using DecodeFramesPromise = MozPromise<DecodeFramesResult, nsresult, true>;

class AnonymousMetadataDecoderTask;
class AnonymousFrameCountDecoderTask;
class AnonymousFramesDecoderTask;

class AnonymousDecoder : public SupportsThreadSafeWeakPtr<AnonymousDecoder> {
 public:
  virtual RefPtr<DecodeMetadataPromise> DecodeMetadata() = 0;

  virtual void Destroy() = 0;

  virtual RefPtr<DecodeFrameCountPromise> DecodeFrameCount(
      uint32_t aKnownFrameCount) = 0;

  virtual RefPtr<DecodeFramesPromise> DecodeFrames(size_t aCount) = 0;

  virtual void CancelDecodeFrames() = 0;

#ifdef MOZ_REFCOUNTED_LEAK_CHECKING
  virtual const chartypeName() const = 0;
  virtual size_t typeSize() const = 0;
#endif

  virtual ~AnonymousDecoder();

 protected:
  AnonymousDecoder();

  // Returns true if successfully initialized else false.
  virtual bool Initialize(RefPtr<Decoder>&& aDecoder) = 0;

  virtual void OnMetadata(const ImageMetadata* aMetadata) = 0;

  virtual void OnFrameCount(uint32_t aFrameCount, bool aComplete) = 0;

  // Returns true if the caller should continue decoding more frames if
  // possible.
  virtual bool OnFrameAvailable(RefPtr<imgFrame>&& aFrame,
                                RefPtr<gfx::SourceSurface>&& aSurface) = 0;

  virtual void OnFramesComplete() = 0;

  friend class AnonymousMetadataDecoderTask;
  friend class AnonymousFrameCountDecoderTask;
  friend class AnonymousFramesDecoderTask;
};

class ImageUtils {
 public:
  static already_AddRefed<AnonymousDecoder> CreateDecoder(
      SourceBuffer* aSourceBuffer, DecoderType aType,
      const Maybe<gfx::IntSize>& aOutputSize, SurfaceFlags aSurfaceFlags);

  static DecoderType GetDecoderType(const nsACString& aMimeType);

 private:
  ImageUtils() = delete;
  ~ImageUtils() = delete;
};

}  // namespace image
}  // namespace mozilla

#endif  // mozilla_image_ImageUtils_h

94%


¤ Dauer der Verarbeitung: 0.17 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge