image/src/imgDecoderObserver.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /** -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef MOZILLA_IMAGELIB_IMGDECODEROBSERVER_H_
michael@0 7 #define MOZILLA_IMAGELIB_IMGDECODEROBSERVER_H_
michael@0 8
michael@0 9 #include "nsRect.h"
michael@0 10 #include "mozilla/WeakPtr.h"
michael@0 11
michael@0 12 struct nsIntRect;
michael@0 13
michael@0 14 /**
michael@0 15 * imgDecoderObserver interface
michael@0 16 *
michael@0 17 * This interface is used to observe Decoder objects.
michael@0 18 *
michael@0 19 * We make the distinction here between "load" and "decode" notifications. Load
michael@0 20 * notifications are fired as the image is loaded from the network or
michael@0 21 * filesystem. Decode notifications are fired as the image is decoded. If an
michael@0 22 * image is decoded on load and not visibly discarded, decode notifications are
michael@0 23 * nested logically inside load notifications as one might expect. However, with
michael@0 24 * decode-on-draw, the set of decode notifications can come completely _after_
michael@0 25 * the load notifications, and can come multiple times if the image is
michael@0 26 * discardable. Moreover, they can be interleaved in various ways. In general,
michael@0 27 * any presumed ordering between load and decode notifications should not be
michael@0 28 * relied upon.
michael@0 29 *
michael@0 30 * Decode notifications may or may not be synchronous, depending on the
michael@0 31 * situation. If imgIDecoder::FLAG_SYNC_DECODE is passed to a function that
michael@0 32 * triggers a decode, all notifications that can be generated from the currently
michael@0 33 * loaded data fire before the call returns. If FLAG_SYNC_DECODE is not passed,
michael@0 34 * all, some, or none of the notifications may fire before the call returns.
michael@0 35 */
michael@0 36 class imgDecoderObserver
michael@0 37 {
michael@0 38 public:
michael@0 39 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(imgDecoderObserver);
michael@0 40
michael@0 41 /**
michael@0 42 * Load notification.
michael@0 43 *
michael@0 44 * called at the same time that nsIRequestObserver::onStartRequest would be
michael@0 45 * (used only for observers of imgIRequest objects, which are nsIRequests,
michael@0 46 * not imgIDecoder objects)
michael@0 47 */
michael@0 48 virtual void OnStartRequest() = 0;
michael@0 49
michael@0 50 /**
michael@0 51 * Decode notification.
michael@0 52 *
michael@0 53 * Called as soon as the image begins getting decoded. This does not include
michael@0 54 * "header-only" decodes used by decode-on-draw to parse the width/height
michael@0 55 * out of the image. Thus, it is a decode notification only.
michael@0 56 */
michael@0 57 virtual void OnStartDecode() = 0;
michael@0 58
michael@0 59 /**
michael@0 60 * Load notification.
michael@0 61 *
michael@0 62 * Called once enough data has been loaded from the network that we were able
michael@0 63 * to parse the width/height from the image. By the time this callback is been
michael@0 64 * called, the size has been set on the container and STATUS_SIZE_AVAILABLE
michael@0 65 * has been set on the associated imgRequest.
michael@0 66 */
michael@0 67 virtual void OnStartContainer() = 0;
michael@0 68
michael@0 69 /**
michael@0 70 * Decode notification.
michael@0 71 *
michael@0 72 * Called when we know a frame has begun decoding.
michael@0 73 */
michael@0 74 virtual void OnStartFrame() = 0;
michael@0 75
michael@0 76 /**
michael@0 77 * Decode notification.
michael@0 78 *
michael@0 79 * called when there is more to paint.
michael@0 80 */
michael@0 81 virtual void FrameChanged(const nsIntRect * aDirtyRect) = 0;
michael@0 82
michael@0 83 /**
michael@0 84 * Decode notification.
michael@0 85 *
michael@0 86 * called when a frame is finished decoding.
michael@0 87 */
michael@0 88 virtual void OnStopFrame() = 0;
michael@0 89
michael@0 90 /**
michael@0 91 * Notification for when an image is known to be animated. This should be
michael@0 92 * fired at the earliest possible time.
michael@0 93 */
michael@0 94 virtual void OnImageIsAnimated() = 0;
michael@0 95
michael@0 96 /**
michael@0 97 * Decode notification.
michael@0 98 *
michael@0 99 * Called when all decoding has terminated.
michael@0 100 */
michael@0 101 virtual void OnStopDecode(nsresult status) = 0;
michael@0 102
michael@0 103 /**
michael@0 104 * Load notification.
michael@0 105 *
michael@0 106 * called at the same time that nsIRequestObserver::onStopRequest would be
michael@0 107 * (used only for observers of imgIRequest objects, which are nsIRequests,
michael@0 108 * not imgIDecoder objects)
michael@0 109 */
michael@0 110 virtual void OnStopRequest(bool aIsLastPart, nsresult aStatus) = 0;
michael@0 111
michael@0 112 /**
michael@0 113 * Called when the decoded image data is discarded. This means that the frames
michael@0 114 * no longer exist in decoded form, and any attempt to access or draw the
michael@0 115 * image will initiate a new series of progressive decode notifications.
michael@0 116 */
michael@0 117 virtual void OnDiscard() = 0;
michael@0 118
michael@0 119 /**
michael@0 120 * Called when we are asked to Draw an image that is not locked.
michael@0 121 */
michael@0 122 virtual void OnUnlockedDraw() = 0;
michael@0 123
michael@0 124 /**
michael@0 125 * Called when an image is realized to be in error state.
michael@0 126 */
michael@0 127 virtual void OnError() = 0;
michael@0 128
michael@0 129 protected:
michael@0 130 virtual ~imgDecoderObserver() = 0;
michael@0 131 };
michael@0 132
michael@0 133 // We must define a destructor because derived classes call our destructor from
michael@0 134 // theirs. Pure virtual destructors only requires that child classes implement
michael@0 135 // a virtual destructor, not that we can't have one too!
michael@0 136 inline imgDecoderObserver::~imgDecoderObserver()
michael@0 137 {}
michael@0 138
michael@0 139 #endif // MOZILLA_IMAGELIB_IMGDECODEROBSERVER_H

mercurial