image/public/imgIContainer.idl

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /** -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     2  *
     3  * This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #include "nsISupports.idl"
     9 %{C++
    10 #include "gfxImageSurface.h"
    11 #include "gfxContext.h"
    12 #include "gfxMatrix.h"
    13 #include "gfxRect.h"
    14 #include "GraphicsFilter.h"
    15 #include "gfxASurface.h"
    16 #include "mozilla/gfx/2D.h"
    17 #include "mozilla/RefPtr.h"
    18 #include "nsRect.h"
    19 #include "nsSize.h"
    20 #include "limits.h"
    22 namespace mozilla {
    23 namespace layers {
    24 class LayerManager;
    25 class ImageContainer;
    26 }
    27 }
    29 class nsIFrame;
    31 namespace mozilla {
    32 class TimeStamp;
    33 class SVGImageContext;
    34 }
    36 namespace mozilla {
    37 namespace image {
    38 class Orientation;
    39 }
    40 }
    42 %}
    44 [ptr] native gfxImageSurface(gfxImageSurface);
    45 [ptr] native gfxASurface(gfxASurface);
    46 native gfxImageFormat(gfxASurface::gfxImageFormat);
    47 [ptr] native gfxContext(gfxContext);
    48 [ref] native gfxMatrix(gfxMatrix);
    49 [ref] native gfxRect(gfxRect);
    50 native gfxGraphicsFilter(GraphicsFilter);
    51 [ref] native nsIntRect(nsIntRect);
    52 [ref] native nsIntSize(nsIntSize);
    53 native nsSize(nsSize);
    54 [ptr] native nsIFrame(nsIFrame);
    55 [ptr] native ImageContainer(mozilla::layers::ImageContainer);
    56 [ptr] native LayerManager(mozilla::layers::LayerManager);
    57 native Orientation(mozilla::image::Orientation);
    58 [ref] native TimeStamp(mozilla::TimeStamp);
    59 [ptr] native SVGImageContext(mozilla::SVGImageContext);
    60 native TempRefSourceSurface(mozilla::TemporaryRef<mozilla::gfx::SourceSurface>);
    63 /**
    64  * imgIContainer is the interface that represents an image. It allows
    65  * access to frames as Thebes surfaces. It also allows drawing of images
    66  * onto Thebes contexts.
    67  *
    68  * Internally, imgIContainer also manages animation of images.
    69  */
    70 [scriptable, builtinclass, uuid(503a830c-734d-4362-91f6-73f83ac59646)]
    71 interface imgIContainer : nsISupports
    72 {
    73   /**
    74    * The width of the container rectangle.  In the case of any error,
    75    * zero is returned, and an exception will be thrown.
    76    */
    77   readonly attribute int32_t width;
    79   /**
    80    * The height of the container rectangle.  In the case of any error,
    81    * zero is returned, and an exception will be thrown.
    82    */
    83   readonly attribute int32_t height;
    85   /**
    86    * The intrinsic size of this image in appunits. If the image has no intrinsic
    87    * size in a dimension, -1 will be returned for that dimension. In the case of
    88    * any error, an exception will be thrown.
    89    */
    90   [noscript] readonly attribute nsSize intrinsicSize;
    92   /**
    93    * The (dimensionless) intrinsic ratio of this image. In the case of any error,
    94    * an exception will be thrown.
    95    */
    96   [noscript] readonly attribute nsSize intrinsicRatio;
    98   /**
    99     * Enumerated values for the 'type' attribute (below).
   100     */
   101   const unsigned short TYPE_RASTER = 0;
   102   const unsigned short TYPE_VECTOR = 1;
   104   /**
   105    * The type of this image (one of the TYPE_* values above).
   106    */
   107   readonly attribute unsigned short type;
   109   /**
   110    * Direct C++ accessor for 'type' attribute, for convenience.
   111    */
   112   [noscript, notxpcom] uint16_t GetType();
   114   /**
   115    * Whether this image is animated. You can only be guaranteed that querying
   116    * this will not throw if STATUS_DECODE_COMPLETE is set on the imgIRequest.
   117    *
   118    * @throws NS_ERROR_NOT_AVAILABLE if the animated state cannot be determined.
   119    */
   120   readonly attribute boolean animated;
   122   /**
   123    * Flags for imgIContainer operations.
   124    *
   125    * Meanings:
   126    *
   127    * FLAG_NONE: Lack of flags
   128    *
   129    * FLAG_SYNC_DECODE: Forces synchronous/non-progressive decode of all
   130    * available data before the call returns. It is an error to pass this flag
   131    * from a call stack that originates in a decoder (ie, from a decoder
   132    * observer event).
   133    *
   134    * FLAG_DECODE_NO_PREMULTIPLY_ALPHA: Do not premultiply alpha if
   135    * it's not already premultiplied in the image data.
   136    *
   137    * FLAG_DECODE_NO_COLORSPACE_CONVERSION: Do not do any colorspace conversion;
   138    * ignore any embedded profiles, and don't convert to any particular destination
   139    * space.
   140    *
   141    * FLAG_CLAMP: Extend the image to the fill area by clamping image sample
   142    * coordinates instead of by tiling. This only affects 'draw'.
   143    *
   144    * FLAG_HIGH_QUALITY_SCALING: A hint as to whether this image should be
   145    * scaled using the high quality scaler. Do not set this if not drawing to
   146    * a window or not listening to invalidations.
   147    */
   149   const long FLAG_NONE            = 0x0;
   150   const long FLAG_SYNC_DECODE     = 0x1;
   151   const long FLAG_DECODE_NO_PREMULTIPLY_ALPHA = 0x2;
   152   const long FLAG_DECODE_NO_COLORSPACE_CONVERSION = 0x4;
   153   const long FLAG_CLAMP           = 0x8;
   154   const long FLAG_HIGH_QUALITY_SCALING = 0x10;
   155   const long FLAG_WANT_DATA_SURFACE = 0x20;
   157   /**
   158     * Constants for specifying various "special" frames.
   159     *
   160     * FRAME_FIRST: The first frame
   161     * FRAME_CURRENT: The current frame
   162     *
   163     * FRAME_MAX_VALUE should be set to the value of the maximum constant above,
   164     * as it is used for ensuring that a valid value was passed in.
   165     */
   166   const unsigned long FRAME_FIRST = 0;
   167   const unsigned long FRAME_CURRENT = 1;
   168   const unsigned long FRAME_MAX_VALUE = 1;
   170   /**
   171    * Get a surface for the given frame. This may be a platform-native,
   172    * optimized surface, so you cannot inspect its pixel data. If you
   173    * need that, use gfxASurface::GetAsReadableARGB32ImageSurface or
   174    * gfxASurface::CopyToARGB32ImageSurface.
   175    *
   176    * @param aWhichFrame Frame specifier of the FRAME_* variety.
   177    * @param aFlags Flags of the FLAG_* variety
   178    */
   179   [noscript, notxpcom] TempRefSourceSurface getFrame(in uint32_t aWhichFrame,
   180                                                      in uint32_t aFlags);
   182   /**
   183    * Whether the given frame is opaque; that is, needs the background painted
   184    * behind it.
   185    *
   186    * @param aWhichFrame Frame specifier of the FRAME_* variety.
   187    */
   188   [notxpcom] boolean frameIsOpaque(in uint32_t aWhichFrame);
   190   /**
   191    * Attempts to create an ImageContainer (and Image) containing the current
   192    * frame. Only valid for RASTER type images.
   193    */
   194   [noscript] ImageContainer getImageContainer(in LayerManager aManager);
   196   /**
   197    * Draw a frame onto the context specified.
   198    *
   199    * @param aContext The Thebes context to draw the image to.
   200    * @param aFilter The filter to be used if we're scaling the image.
   201    * @param aUserSpaceToImageSpace The transformation from user space (e.g.,
   202    *                               appunits) to image space.
   203    * @param aFill The area in the context to draw pixels to. When aFlags includes
   204    *              FLAG_CLAMP, the image will be extended to this area by clampling
   205    *              image sample coordinates. Otherwise, the image will be
   206    *              automatically tiled as necessary.
   207    * @param aSubimage The area of the image, in pixels, that we are allowed to
   208    *                  sample from.
   209    * @param aViewportSize
   210    *          The size (in CSS pixels) of the viewport that would be available
   211    *          for the full image to occupy, if we were drawing the full image.
   212    *          (Note that we might not actually be drawing the full image -- we
   213    *          might be restricted by aSubimage -- but we still need the full
   214    *          image's viewport-size in order for SVG images with the "viewBox"
   215    *          attribute to position their content correctly.)
   216    * @param aSVGContext If non-null, SVG-related rendering context such as
   217    *                    overridden attributes on the image document's root <svg>
   218    *                    node. Ignored for raster images.
   219    * @param aWhichFrame Frame specifier of the FRAME_* variety.
   220    * @param aFlags Flags of the FLAG_* variety
   221    */
   222   [noscript] void draw(in gfxContext aContext,
   223                        in gfxGraphicsFilter aFilter,
   224                        [const] in gfxMatrix aUserSpaceToImageSpace,
   225                        [const] in gfxRect aFill,
   226                        [const] in nsIntRect aSubimage,
   227                        [const] in nsIntSize aViewportSize,
   228                        [const] in SVGImageContext aSVGContext,
   229                        in uint32_t aWhichFrame,
   230                        in uint32_t aFlags);
   232   /*
   233    * Ensures that an image is decoding. Calling this function guarantees that
   234    * the image will at some point fire off decode notifications. Calling draw()
   235    * or getFrame() triggers the same mechanism internally. Thus, if you want to
   236    * be sure that the image will be decoded but don't want to access it until
   237    * then, you must call requestDecode().
   238    */
   239   void requestDecode();
   241   /*
   242    * This is equivalent to requestDecode() but it also decodes some of the image.
   243    */
   244   [noscript] void startDecoding();
   246   /*
   247    * Returns true if no more decoding can be performed on this image. Images
   248    * with errors return true since they cannot be decoded any further. Note that
   249    * because decoded images may be discarded, isDecoded() may return false even
   250    * if it has returned true in the past.
   251    */
   252   [noscript, notxpcom, nostdcall] bool isDecoded();
   254   /**
   255     * Increments the lock count on the image. An image will not be discarded
   256     * as long as the lock count is nonzero. Note that it is still possible for
   257     * the image to be undecoded if decode-on-draw is enabled and the image
   258     * was never drawn.
   259     *
   260     * Upon instantiation images have a lock count of zero.
   261     */
   262   void lockImage();
   264   /**
   265     * Decreases the lock count on the image. If the lock count drops to zero,
   266     * the image is allowed to discard its frame data to save memory.
   267     *
   268     * Upon instantiation images have a lock count of zero. It is an error to
   269     * call this method without first having made a matching lockImage() call.
   270     * In other words, the lock count is not allowed to be negative.
   271     */
   272   void unlockImage();
   274   /**
   275    * If this image is unlocked, discard its decoded data.  If the image is
   276    * locked or has already been discarded, do nothing.
   277    */
   278   void requestDiscard();
   280   /**
   281     * Indicates that this imgIContainer has been triggered to update
   282     * its internal animation state. Likely this should only be called
   283     * from within nsImageFrame or objects of similar type.
   284     */
   285   [notxpcom] void requestRefresh([const] in TimeStamp aTime);
   287   /**
   288    * Animation mode Constants
   289    *   0 = normal
   290    *   1 = don't animate
   291    *   2 = loop once
   292    */
   293   const short kNormalAnimMode   = 0;
   294   const short kDontAnimMode     = 1;
   295   const short kLoopOnceAnimMode = 2;
   297   attribute unsigned short animationMode;
   299   /* Methods to control animation */
   300   void resetAnimation();
   302   /*
   303    * Returns an index for the requested animation frame (either FRAME_FIRST or
   304    * FRAME_CURRENT).
   305    *
   306    * The units of the index aren't specified, and may vary between different
   307    * types of images. What you can rely on is that on all occasions when
   308    * getFrameIndex(FRAME_CURRENT) returns a certain value,
   309    * draw(..FRAME_CURRENT..) will draw the same frame. The same holds for
   310    * FRAME_FIRST as well.
   311    *
   312    * @param aWhichFrame Frame specifier of the FRAME_* variety.
   313    */
   314   [notxpcom] float getFrameIndex(in uint32_t aWhichFrame);
   316   /*
   317    * Returns the inherent orientation of the image, as described in the image's
   318    * metadata (e.g. EXIF).
   319    */
   320   [notxpcom] Orientation getOrientation();
   322   /*
   323    * Returns the delay, in ms, between the first and second frame. If this
   324    * returns 0, there is no delay between first and second frame (i.e., this
   325    * image could render differently whenever it draws).
   326    *
   327    * If this image is not animated, or not known to be animated (see attribute
   328    * animated), returns -1.
   329    */
   330   [notxpcom] int32_t getFirstFrameDelay();
   332   /*
   333    * If this is an animated image that hasn't started animating already, this
   334    * sets the animation's start time to the indicated time.
   335    *
   336    * This has no effect if the image isn't animated or it has started animating
   337    * already; it also has no effect if the image format doesn't care about
   338    * animation start time.
   339    *
   340    * In all cases, animation does not actually begin until startAnimation(),
   341    * resetAnimation(), or requestRefresh() is called for the first time.
   342    */
   343   [notxpcom] void setAnimationStartTime([const] in TimeStamp aTime);
   344 };

mercurial