imgIContainer.idl (30813B)
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/. */ 6 7 #include "nsISupports.idl" 8 9 webidl Document; 10 11 %{C++ 12 #include "ImgDrawResult.h" 13 #include "gfxPoint.h" 14 #include "mozilla/gfx/Types.h" 15 #include "mozilla/AspectRatio.h" 16 #include "mozilla/Maybe.h" 17 #include "mozilla/RefPtr.h" 18 #include "nsRect.h" 19 #include "nsSize.h" 20 #include "nsTArray.h" 21 #include "limits.h" 22 23 class gfxContext; 24 class nsIFrame; 25 26 namespace mozilla { 27 class TimeStamp; 28 class SVGImageContext; 29 struct MediaFeatureChange; 30 31 namespace gfx { 32 class SourceSurface; 33 } 34 35 class WindowRenderer; 36 namespace layers { 37 class ImageContainer; 38 } 39 40 namespace image { 41 class ImageRegion; 42 class ImageIntRegion; 43 class WebRenderImageProvider; 44 struct Orientation; 45 struct Resolution; 46 47 /** 48 * This represents an image's intrinsic size, in units of pixels (the same 49 * units as our 'width' and 'height' attributes). Both components are 50 * optional, because an image (particularly a vector image) may lack an 51 * intrinsic width and/or height. 52 * 53 * We use signed types for the components, but the values are expected to be 54 * nonnegative; any negative values should be considered an error. (Zero is 55 * valid, though.) 56 * 57 * Note that this is similar to a gfx::IntSize, except for the use of Maybe<> 58 * to reflect that the components are optional. This is also similar to 59 * nsIFrame.h's mozilla::IntrinsicSize class, with the difference being pixel 60 * units here vs. nscoord units there. 61 */ 62 struct ImageIntrinsicSize { 63 Maybe<int32_t> mWidth; 64 Maybe<int32_t> mHeight; 65 }; 66 67 } 68 } 69 70 %} 71 72 native AspectRatio(mozilla::AspectRatio); 73 native ImageIntrinsicSize(mozilla::image::ImageIntrinsicSize); 74 native ImgDrawResult(mozilla::image::ImgDrawResult); 75 [ptr] native gfxContext(gfxContext); 76 [ref] native gfxMatrix(gfxMatrix); 77 [ref] native gfxRect(gfxRect); 78 [ref] native gfxSize(gfxSize); 79 native SamplingFilter(mozilla::gfx::SamplingFilter); 80 [ref] native nsIntRect(nsIntRect); 81 native nsIntRectByVal(nsIntRect); 82 [ref] native nsIntSize(nsIntSize); 83 native nsSize(nsSize); 84 [ptr] native nsIFrame(nsIFrame); 85 native TempRefImageContainer(already_AddRefed<mozilla::layers::ImageContainer>); 86 [ptr] native ImageContainer(mozilla::layers::ImageContainer); 87 [ptr] native WebRenderImageProvider(mozilla::image::WebRenderImageProvider); 88 [ref] native ImageRegion(mozilla::image::ImageRegion); 89 [ptr] native WindowRenderer(mozilla::WindowRenderer); 90 native Orientation(mozilla::image::Orientation); 91 native ImageResolution(mozilla::image::Resolution); 92 [ref] native TimeStamp(mozilla::TimeStamp); 93 [ref] native SVGImageContext(mozilla::SVGImageContext); 94 [ref] native MaybeImageIntRegion(mozilla::Maybe<mozilla::image::ImageIntRegion>); 95 native TempRefSourceSurface(already_AddRefed<mozilla::gfx::SourceSurface>); 96 native TempRefImgIContainer(already_AddRefed<imgIContainer>); 97 native nsIntSizeByVal(nsIntSize); 98 [ref] native MediaFeatureChange(mozilla::MediaFeatureChange); 99 100 101 /** 102 * imgIContainer is the interface that represents an image. It allows 103 * access to frames as Thebes surfaces. It also allows drawing of images 104 * onto Thebes contexts. 105 * 106 * Internally, imgIContainer also manages animation of images. 107 */ 108 [scriptable, builtinclass, uuid(a8dbee24-ff86-4755-b40e-51175caf31af)] 109 interface imgIContainer : nsISupports 110 { 111 /** 112 * The width of the container rectangle. In the case of any error, 113 * zero is returned, and an exception will be thrown. 114 */ 115 readonly attribute int32_t width; 116 117 /** 118 * The height of the container rectangle. In the case of any error, 119 * zero is returned, and an exception will be thrown. 120 */ 121 readonly attribute int32_t height; 122 123 /** 124 * The intrinsic size of this image in pixels. The values and units here are 125 * the same as those that the 'width' and 'height' attributes (declared 126 * above) would return. 127 * 128 * If an image lacks an intrinsic width and/or height, then that component 129 * will be Nothing() in the returned value. (This is different from the 130 * 'width' and 'height' attributes; they treat this case as an error, for 131 * historical reasons, but we can handle it more elegantly here.) 132 * 133 * In case of any error, an exception will be thrown. 134 */ 135 [noscript] readonly attribute ImageIntrinsicSize intrinsicSize; 136 137 /** 138 * The intrinsic size of this image in appunits. If the image has no intrinsic 139 * size in a dimension, -1 will be returned for that dimension. In the case of 140 * any error, an exception will be thrown. 141 * 142 * XXXdholbert maybe this should use the actual IntrinsicSize type (defined 143 * in nsIFrame.h, specifically for replaced elements like images, also 144 * using nscoord units but with Maybe<> to represent sizes being missing)? 145 */ 146 [noscript] readonly attribute nsSize intrinsicSizeInAppUnits; 147 148 /** 149 * The (dimensionless) intrinsic ratio of this image. Might return a 150 * degenerate ratio (one that returns 'false' when coerced to a bool) 151 * if the image is in an error state, or there's no ratio. 152 */ 153 [notxpcom, nostdcall] readonly attribute AspectRatio intrinsicRatio; 154 155 /** 156 * The x coordinate of the image's hotspot, or 0 if there is no hotspot. 157 */ 158 readonly attribute int32_t hotspotX; 159 160 /** 161 * The y coordinate of the image's hotspot, or 0 if there is no hotspot. 162 */ 163 readonly attribute int32_t hotspotY; 164 165 /** 166 * Given a size at which this image will be displayed, and the drawing 167 * parameters affecting how it will be drawn, returns the image size which 168 * should be used to draw to produce the highest quality result. This is the 169 * appropriate size, for example, to use as an input to the pixel snapping 170 * algorithm. 171 * 172 * For best results the size returned by this method should not be cached. It 173 * can change over time due to changes in the internal state of the image. 174 * 175 * @param aDest The size of the destination rect into which this image will be 176 * drawn, in device pixels. 177 * @param aWhichFrame Frame specifier of the FRAME_* variety. 178 * @param aSamplingFilter The filter to be used if we're scaling the image. 179 * @param aFlags Flags of the FLAG_* variety 180 */ 181 [notxpcom, nostdcall] nsIntSizeByVal 182 optimalImageSizeForDest([const] in gfxSize aDest, in uint32_t aWhichFrame, 183 in SamplingFilter aSamplingFilter, in uint32_t aFlags); 184 185 /** 186 * Enumerated values for the 'type' attribute (below). 187 */ 188 const unsigned short TYPE_RASTER = 0; 189 const unsigned short TYPE_VECTOR = 1; 190 const unsigned short TYPE_REQUEST = 2; 191 192 /** 193 * The type of this image (one of the TYPE_* values above). 194 */ 195 [infallible] readonly attribute unsigned short type; 196 197 /** 198 * Whether this image is animated. You can only be guaranteed that querying 199 * this will not throw if STATUS_DECODE_COMPLETE is set on the imgIRequest. 200 * 201 * @throws NS_ERROR_NOT_AVAILABLE if the animated state cannot be determined. 202 */ 203 readonly attribute boolean animated; 204 205 /** 206 * Provider ID for image providers created by this image. 207 */ 208 [infallible] readonly attribute unsigned long providerId; 209 210 /** 211 * Flags for imgIContainer operations. 212 * 213 * Meanings: 214 * 215 * FLAG_NONE: Lack of flags. 216 * 217 * FLAG_SYNC_DECODE: Forces synchronous/non-progressive decode of all 218 * available data before the call returns. 219 * 220 * FLAG_SYNC_DECODE_IF_FAST: Like FLAG_SYNC_DECODE, but requests a sync decode 221 * be performed only if ImageLib estimates it can be completed very quickly. 222 * 223 * FLAG_ASYNC_NOTIFY: Send notifications asynchronously, even if we decode 224 * synchronously because of FLAG_SYNC_DECODE or FLAG_SYNC_DECODE_IF_FAST. 225 * 226 * FLAG_DECODE_NO_PREMULTIPLY_ALPHA: Do not premultiply alpha if 227 * it's not already premultiplied in the image data. 228 * 229 * FLAG_DECODE_NO_COLORSPACE_CONVERSION: Do not do any colorspace conversion; 230 * ignore any embedded profiles, and don't convert to any particular 231 * destination space. 232 * 233 * FLAG_CLAMP: Extend the image to the fill area by clamping image sample 234 * coordinates instead of by tiling. This only affects 'draw'. 235 * 236 * FLAG_HIGH_QUALITY_SCALING: A hint as to whether this image should be 237 * scaled using the high quality scaler. Do not set this if not drawing to 238 * a window or not listening to invalidations. Passing this flag will do two 239 * things: 1) request a decode of the image at the size asked for by the 240 * caller if one isn't already started or complete, and 2) allows a decoded 241 * frame of any size (it could be neither the requested size, nor the 242 * intrinsic size) to be substituted. 243 * 244 * FLAG_BYPASS_SURFACE_CACHE: Forces drawing to happen rather than taking 245 * cached rendering from the surface cache. This is used when we are printing, 246 * for example, where we want the vector commands from VectorImages to end up 247 * in the PDF output rather than a cached rendering at screen resolution. 248 * 249 * FLAG_FORCE_PRESERVEASPECTRATIO_NONE: Force scaling this image 250 * non-uniformly if necessary. This flag is for vector image only. A raster 251 * image should ignore this flag. While drawing a vector image with this 252 * flag, do not force uniform scaling even if its root <svg> node has a 253 * preserveAspectRatio attribute that would otherwise require uniform 254 * scaling , such as xMinYMin/ xMidYMin. Always scale the graphic content of 255 * the given image non-uniformly if necessary such that the image's 256 * viewBox (if specified or implied by height/width attributes) exactly 257 * matches the viewport rectangle. 258 * 259 * FLAG_FORCE_UNIFORM_SCALING: Signal to ClippedImage::OptimalSizeForDest that 260 * its returned size can only scale the image's size *uniformly* (by the same 261 * factor in each dimension). We need this flag when painting border-image 262 * section with SVG image source-data, if the SVG image has no viewBox and no 263 * intrinsic size. In such a case, we synthesize a viewport for the SVG image 264 * (a "window into SVG space") based on the border image area, and we need to 265 * be sure we don't subsequently scale that viewport in a way that distorts 266 * its contents by stretching them more in one dimension than the other. 267 * 268 * FLAG_AVOID_REDECODE_FOR_SIZE: If there is already a raster surface 269 * available for this image, but it is not the same size as requested, skip 270 * starting a new decode for said size. 271 * 272 * FLAG_DECODE_TO_SRGB_COLORSPACE: Instead of converting the colorspace to 273 * the display's colorspace, use sRGB. 274 * 275 * FLAG_RECORD_BLOB: Instead of rasterizing an SVG image on the main thread, 276 * record the drawing commands using blob images. 277 */ 278 const unsigned long FLAG_NONE = 0x0; 279 const unsigned long FLAG_SYNC_DECODE = 0x1; 280 const unsigned long FLAG_SYNC_DECODE_IF_FAST = 0x2; 281 const unsigned long FLAG_ASYNC_NOTIFY = 0x4; 282 const unsigned long FLAG_DECODE_NO_PREMULTIPLY_ALPHA = 0x8; 283 const unsigned long FLAG_DECODE_NO_COLORSPACE_CONVERSION = 0x10; 284 const unsigned long FLAG_CLAMP = 0x20; 285 const unsigned long FLAG_HIGH_QUALITY_SCALING = 0x40; 286 const unsigned long FLAG_BYPASS_SURFACE_CACHE = 0x80; 287 const unsigned long FLAG_FORCE_PRESERVEASPECTRATIO_NONE = 0x100; 288 const unsigned long FLAG_FORCE_UNIFORM_SCALING = 0x200; 289 const unsigned long FLAG_AVOID_REDECODE_FOR_SIZE = 0x400; 290 const unsigned long FLAG_DECODE_TO_SRGB_COLORSPACE = 0x800; 291 const unsigned long FLAG_RECORD_BLOB = 0x1000; 292 293 /** 294 * A constant specifying the default set of decode flags (i.e., the default 295 * values for FLAG_DECODE_*). 296 */ 297 const unsigned long DECODE_FLAGS_DEFAULT = 0; 298 299 /** 300 * A constant specifying the decode flags recommended to be used when 301 * re-encoding an image, or with the clipboard. 302 */ 303 const unsigned long DECODE_FLAGS_FOR_REENCODE = 304 FLAG_DECODE_NO_PREMULTIPLY_ALPHA | FLAG_DECODE_TO_SRGB_COLORSPACE; 305 306 /** 307 * Constants for specifying various "special" frames. 308 * 309 * FRAME_FIRST: The first frame 310 * FRAME_CURRENT: The current frame 311 * 312 * FRAME_MAX_VALUE should be set to the value of the maximum constant above, 313 * as it is used for ensuring that a valid value was passed in. 314 */ 315 const unsigned long FRAME_FIRST = 0; 316 const unsigned long FRAME_CURRENT = 1; 317 const unsigned long FRAME_MAX_VALUE = 1; 318 319 /** 320 * Get a surface for the given frame. This may be a platform-native, 321 * optimized surface, so you cannot inspect its pixel data. If you 322 * need that, use SourceSurface::GetDataSurface. 323 * 324 * @param aWhichFrame Frame specifier of the FRAME_* variety. 325 * @param aFlags Flags of the FLAG_* variety 326 */ 327 [noscript, notxpcom] TempRefSourceSurface getFrame(in uint32_t aWhichFrame, 328 in uint32_t aFlags); 329 330 /** 331 * Get a surface for the given frame at the specified size. Matching the 332 * requested size is best effort; it's not guaranteed that the surface you get 333 * will be a perfect match. (Some reasons you may get a surface of a different 334 * size include: if you requested upscaling, if downscale-during-decode is 335 * disabled, or if you didn't request the first frame.) 336 * 337 * @param aSize The desired size. 338 * @param aWhichFrame Frame specifier of the FRAME_* variety. 339 * @param aFlags Flags of the FLAG_* variety 340 */ 341 [noscript, notxpcom] TempRefSourceSurface getFrameAtSize([const] in nsIntSize aSize, 342 in uint32_t aWhichFrame, 343 in uint32_t aFlags); 344 345 /** 346 * Returns true if this image will draw opaquely right now if asked to draw 347 * with FLAG_HIGH_QUALITY_SCALING and otherwise default flags. If this image 348 * (when decoded) is opaque but no decoded frames are available then 349 * willDrawOpaqueNow will return false. 350 */ 351 [noscript, notxpcom] boolean willDrawOpaqueNow(); 352 353 /** 354 * Returns true if this image has a frame and the frame currently has a 355 * least 1 decoded pixel. Only valid for raster images. 356 */ 357 [noscript, notxpcom] boolean hasDecodedPixels(); 358 359 /** 360 * @return true if getImageContainer() is expected to return a valid 361 * ImageContainer when passed the given @Renderer and @Flags 362 * parameters. 363 */ 364 [noscript, notxpcom] boolean isImageContainerAvailable(in WindowRenderer aRenderer, 365 in uint32_t aFlags); 366 367 /** 368 * Attempts to find a WebRenderImageProvider containing the current frame at 369 * the given size. Match the requested size is best effort; it's not 370 * guaranteed that the surface you get will be a perfect match. (Some reasons 371 * you may get a surface of a different size include: if you requested 372 * upscaling, or if downscale-during-decode is disabled.) 373 * 374 * @param aRenderer The WindowRenderer which will be used to render the 375 * ImageContainer. 376 * @param aSVGContext If specified, SVG-related rendering context, such as 377 * overridden attributes on the image document's root <svg> 378 * node, and the size of the viewport that the full image 379 * would occupy. Ignored for raster images. 380 * @param aFlags Decoding / drawing flags (in other words, FLAG_* flags). 381 * Currently only FLAG_SYNC_DECODE and FLAG_SYNC_DECODE_IF_FAST 382 * are supported. 383 * @param aProvider Return value for WebRenderImageProvider for the current 384 * frame. May be null depending on the draw result. 385 * @return The draw result for the current frame. 386 */ 387 [noscript, notxpcom] ImgDrawResult getImageProvider(in WindowRenderer aRenderer, 388 [const] in nsIntSize aSize, 389 [const] in SVGImageContext aSVGContext, 390 [const] in MaybeImageIntRegion aRegion, 391 in uint32_t aFlags, 392 out WebRenderImageProvider aProvider); 393 394 /** 395 * Draw the requested frame of this image onto the context specified. 396 * 397 * Drawing an image involves scaling it to a certain size (which may be 398 * implemented as a "smart" scale by substituting an HQ-scaled frame or 399 * rendering at a high DPI), and then selecting a region of that image to 400 * draw. That region is drawn onto the graphics context and in the process 401 * transformed by the context matrix, which determines the final area that is 402 * filled. The basic process looks like this: 403 * 404 * +------------------+ 405 * | Image | 406 * | | 407 * | intrinsic width | 408 * | X | 409 * | intrinsic height | 410 * +------------------+ 411 * / \ 412 * / \ 413 * / (scale to aSize) \ 414 * / \ 415 * +----------------------------+ 416 * | | 417 * | Scaled Image | 418 * | aSize.width X aSize.height | 419 * | | 420 * | +---------+ | 421 * | | aRegion | | 422 * | +---------+ | 423 * +-------(---------(----------+ 424 * | | 425 * / \ 426 * | (transform | 427 * / by aContext \ 428 * | matrix) | 429 * / \ 430 * +---------------------+ 431 * | | 432 * | Fill Rect | 433 * | | 434 * +---------------------+ 435 * 436 * The region may extend outside of the scaled image's boundaries. It's 437 * actually a region in tiled image space, which is formed by tiling the 438 * scaled image infinitely in every direction. Drawing with a region larger 439 * than the scaled image thus causes the filled area to contain multiple tiled 440 * copies of the image, which looks like this: 441 * 442 * .................................................... 443 * : : : : 444 * : Tile : Tile : Tile : 445 * : +------------[aRegion]------------+ : 446 * :........|.......:................:........|.......: 447 * : | : : | : 448 * : Ti|le : Scaled Image : Ti|le : 449 * : | : : | : 450 * :........|.......:................:........|.......: 451 * : +---------------------------------+ : 452 * : Ti|le : Tile : Ti|le : 453 * : / : : \ : 454 * :......(.........:................:..........).....: 455 * | | 456 * / \ 457 * | (transform by aContext matrix) | 458 * / \ 459 * +---------------------------------------------+ 460 * | : : | 461 * |.....:.................................:.....| 462 * | : : | 463 * | : Tiled Fill : | 464 * | : : | 465 * |.....:.................................:.....| 466 * | : : | 467 * +---------------------------------------------+ 468 * 469 * 470 * @param aContext The Thebes context to draw the image to. 471 * @param aSize The size to which the image should be scaled before drawing. 472 * This requirement may be satisfied using HQ scaled frames, 473 * selecting from different resolution layers, drawing at a 474 * higher DPI, or just performing additional scaling on the 475 * graphics context. Callers can use optimalImageSizeForDest() 476 * to determine the best choice for this parameter if they have 477 * no special size requirements. 478 * @param aRegion The region in tiled image space which will be drawn onto the 479 * graphics context. aRegion is in the coordinate space of the 480 * image after it has been scaled to aSize - that is, the image 481 * is scaled first, and then aRegion is applied. When aFlags 482 * includes FLAG_CLAMP, the image will be extended to this area 483 * by clamping image sample coordinates. Otherwise, the image 484 * will be automatically tiled as necessary. aRegion can also 485 * optionally contain a second region which restricts the set 486 * of pixels we're allowed to sample from when drawing; this 487 * is only of use to callers which need to draw with pixel 488 * snapping. 489 * @param aWhichFrame Frame specifier of the FRAME_* variety. 490 * @param aSamplingFilter The filter to be used if we're scaling the image. 491 * @param aSVGContext If specified, SVG-related rendering context, such as 492 * overridden attributes on the image document's root <svg> 493 * node, and the size of the viewport that the full image 494 * would occupy. Ignored for raster images. 495 * @param aFlags Flags of the FLAG_* variety 496 * @return A ImgDrawResult value indicating whether and to what degree the 497 * drawing operation was successful. 498 */ 499 [noscript, notxpcom] ImgDrawResult 500 draw(in gfxContext aContext, 501 [const] in nsIntSize aSize, 502 [const] in ImageRegion aRegion, 503 in uint32_t aWhichFrame, 504 in SamplingFilter aSamplingFilter, 505 [const] in SVGImageContext aSVGContext, 506 in uint32_t aFlags, 507 in float aOpacity); 508 509 /* 510 * Ensures that an image is decoding. Calling this function guarantees that 511 * the image will at some point fire off decode notifications. Images that 512 * can be decoded "quickly" according to some heuristic will be decoded 513 * synchronously. 514 * 515 * @param aFlags Flags of the FLAG_* variety. Only FLAG_ASYNC_NOTIFY 516 * is accepted; all others are ignored. 517 * @param aWhichFrame Frame specifier of the FRAME_* variety. 518 */ 519 [noscript] void startDecoding(in uint32_t aFlags, in uint32_t aWhichFrame); 520 521 %{C++ 522 nsresult StartDecoding(uint32_t aFlags) { 523 return StartDecoding(aFlags, FRAME_CURRENT); 524 } 525 %} 526 527 /* 528 * Exactly like startDecoding above except returns whether the current frame 529 * of the image is complete or not. 530 * 531 * @param aFlags Flags of the FLAG_* variety. Only FLAG_ASYNC_NOTIFY 532 * is accepted; all others are ignored. 533 * @param aWhichFrame Frame specifier of the FRAME_* variety. 534 */ 535 [noscript, notxpcom] boolean startDecodingWithResult(in uint32_t aFlags, in uint32_t aWhichFrame); 536 537 %{C++ 538 bool StartDecodingWithResult(uint32_t aFlags) { 539 return StartDecodingWithResult(aFlags, FRAME_CURRENT); 540 } 541 %} 542 543 /* 544 * This method triggers decoding for an image, but unlike startDecoding() it 545 * enables the caller to provide more detailed information about the decode 546 * request. 547 * 548 * @param aFlags Flags of the FLAG_* variety. 549 * @param aWhichFrame Frame specifier of the FRAME_* variety. 550 * @return DECODE_SURFACE_AVAILABLE if is a surface that satisfies the 551 * request and it is fully decoded. 552 * DECODE_REQUESTED if we requested a decode. 553 * DECODE_REQUEST_FAILED if we failed to request a decode. This means 554 * that either there is an error in the image or we cannot allocate a 555 * surface that big. 556 */ 557 cenum DecodeResult : 8 { 558 DECODE_SURFACE_AVAILABLE = 0, 559 DECODE_REQUESTED = 1, 560 DECODE_REQUEST_FAILED = 2 561 }; 562 [noscript, notxpcom] imgIContainer_DecodeResult requestDecodeWithResult(in uint32_t aFlags, in uint32_t aWhichFrame); 563 564 %{C++ 565 DecodeResult RequestDecodeWithResult(uint32_t aFlags) { 566 return RequestDecodeWithResult(aFlags, FRAME_CURRENT); 567 } 568 %} 569 570 /* 571 * This method triggers decoding for an image, but unlike startDecoding() it 572 * enables the caller to provide more detailed information about the decode 573 * request. 574 * 575 * @param aSize The size to which the image should be scaled while decoding, 576 * if possible. If the image cannot be scaled to this size while 577 * being decoded, it will be decoded at its intrinsic size. 578 * @param aFlags Flags of the FLAG_* variety. 579 * @param aWhichFrame Frame specifier of the FRAME_* variety. 580 */ 581 [noscript] void requestDecodeForSize([const] in nsIntSize aSize, 582 in uint32_t aFlags, 583 in uint32_t aWhichFrame); 584 585 %{C++ 586 nsresult RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags) { 587 return RequestDecodeForSize(aSize, aFlags, FRAME_CURRENT); 588 } 589 %} 590 591 /** 592 * Increments the lock count on the image. An image will not be discarded 593 * as long as the lock count is nonzero. Note that it is still possible for 594 * the image to be undecoded if decode-on-draw is enabled and the image 595 * was never drawn. 596 * 597 * Upon instantiation images have a lock count of zero. 598 */ 599 void lockImage(); 600 601 /** 602 * Decreases the lock count on the image. If the lock count drops to zero, 603 * the image is allowed to discard its frame data to save memory. 604 * 605 * Upon instantiation images have a lock count of zero. It is an error to 606 * call this method without first having made a matching lockImage() call. 607 * In other words, the lock count is not allowed to be negative. 608 */ 609 void unlockImage(); 610 611 /** 612 * If this image is unlocked, discard its decoded data. If the image is 613 * locked or has already been discarded, do nothing. 614 */ 615 void requestDiscard(); 616 617 /** 618 * Indicates that this imgIContainer has been triggered to update 619 * its internal animation state. Likely this should only be called 620 * from within nsImageFrame or objects of similar type. 621 */ 622 [notxpcom] void requestRefresh([const] in TimeStamp aTime); 623 624 /** 625 * Animation mode Constants 626 * 0 = normal 627 * 1 = don't animate 628 * 2 = loop once 629 */ 630 const short kNormalAnimMode = 0; 631 const short kDontAnimMode = 1; 632 const short kLoopOnceAnimMode = 2; 633 634 attribute unsigned short animationMode; 635 636 /* Methods to control animation */ 637 void resetAnimation(); 638 639 /* 640 * Returns an index for the requested animation frame (either FRAME_FIRST or 641 * FRAME_CURRENT). 642 * 643 * The units of the index aren't specified, and may vary between different 644 * types of images. What you can rely on is that on all occasions when 645 * getFrameIndex(FRAME_CURRENT) returns a certain value, 646 * draw(..FRAME_CURRENT..) will draw the same frame. The same holds for 647 * FRAME_FIRST as well. 648 * 649 * @param aWhichFrame Frame specifier of the FRAME_* variety. 650 */ 651 [notxpcom] float getFrameIndex(in uint32_t aWhichFrame); 652 653 /* 654 * Returns the inherent orientation of the image, as described in the image's 655 * metadata (e.g. EXIF). 656 */ 657 [notxpcom] Orientation getOrientation(); 658 659 /* 660 * Returns the intrinsic resolution of the image, or 1.0 if the image doesn't 661 * declare any. 662 */ 663 [notxpcom] ImageResolution getResolution(); 664 665 /* 666 * Returns the delay, in ms, between the first and second frame. If this 667 * returns 0, there is no delay between first and second frame (i.e., this 668 * image could render differently whenever it draws). 669 * 670 * If this image is not animated, or not known to be animated (see attribute 671 * animated), returns -1. 672 */ 673 [notxpcom] int32_t getFirstFrameDelay(); 674 675 /* 676 * If this is an animated image that hasn't started animating already, this 677 * sets the animation's start time to the indicated time. 678 * 679 * This has no effect if the image isn't animated or it has started animating 680 * already; it also has no effect if the image format doesn't care about 681 * animation start time. 682 * 683 * In all cases, animation does not actually begin until startAnimation(), 684 * resetAnimation(), or requestRefresh() is called for the first time. 685 */ 686 [notxpcom] void setAnimationStartTime([const] in TimeStamp aTime); 687 688 /* 689 * Given an invalidation rect in the coordinate system used by the decoder, 690 * returns an invalidation rect in image space. 691 * 692 * This is the identity transformation in most cases, but the result can 693 * differ if the image is wrapped by an ImageWrapper that changes its size 694 * or orientation. 695 */ 696 [notxpcom] nsIntRectByVal 697 getImageSpaceInvalidationRect([const] in nsIntRect aRect); 698 699 /* 700 * Removes any ImageWrappers and returns the unwrapped base image. 701 */ 702 [notxpcom, nostdcall] TempRefImgIContainer unwrap(); 703 704 /* 705 * Propagate the use counters (if any) from this container to the passed in 706 * document. 707 */ 708 [noscript, notxpcom] void propagateUseCounters(in Document aReferencingDocument); 709 710 /* 711 * Called when media feature values that apply to all documents (such as 712 * those based on system metrics) have changed. If this image is a type 713 * that can respond to media queries (i.e., an SVG image), this function 714 * is overridden to handle restyling and invalidating the image. 715 */ 716 [notxpcom, nostdcall] void mediaFeatureValuesChangedAllDocuments([const] in MediaFeatureChange aChange); 717 718 /* 719 * Get the set of sizes the image can decode to natively. 720 */ 721 [nostdcall] Array<nsIntSizeByVal> getNativeSizes(); 722 723 [nostdcall, notxpcom] size_t getNativeSizesLength(); 724 };