15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/*
25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.  All rights reserved.
45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2008-2009 Torch Mobile, Inc.
55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modification, are permitted provided that the following conditions
85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * are met:
95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 1. Redistributions of source code must retain the above copyright
105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *    notice, this list of conditions and the following disclaimer.
115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 2. Redistributions in binary form must reproduce the above copyright
125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *    notice, this list of conditions and the following disclaimer in the
135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *    documentation and/or other materials provided with the distribution.
145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
255267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */
275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#ifndef BitmapImage_h
295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define BitmapImage_h
305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
311e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "platform/geometry/IntSize.h"
32f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)#include "platform/graphics/Color.h"
33a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)#include "platform/graphics/FrameData.h"
34a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)#include "platform/graphics/Image.h"
351e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "platform/graphics/ImageOrientation.h"
36a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)#include "platform/graphics/ImageSource.h"
37591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "wtf/Forward.h"
385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
39c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink {
405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
41591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochclass NativeImageSkia;
425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)template <typename T> class Timer;
435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
44a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)class PLATFORM_EXPORT BitmapImage : public Image {
455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    friend class GeneratedImage;
465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    friend class CrossfadeGeneratedImage;
47bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)    friend class GradientGeneratedImage;
485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    friend class GraphicsContext;
495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)public:
507242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    static PassRefPtr<BitmapImage> create(PassRefPtr<NativeImageSkia>, ImageObserver* = 0);
517242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci
525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    static PassRefPtr<BitmapImage> create(ImageObserver* observer = 0)
535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    {
545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)        return adoptRef(new BitmapImage(observer));
555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    }
567242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci
575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    virtual ~BitmapImage();
585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
595267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    virtual bool isBitmapImage() const OVERRIDE;
605267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
617242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    virtual bool currentFrameHasSingleSecurityOrigin() const OVERRIDE;
625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
635267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    virtual IntSize size() const OVERRIDE;
645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    IntSize sizeRespectingOrientation() const;
655267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    virtual bool getHotSpot(IntPoint&) const OVERRIDE;
667242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    virtual String filenameExtension() const OVERRIDE;
675267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    virtual bool dataChanged(bool allDataReceived) OVERRIDE;
687242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci
697242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    bool isAllDataReceived() const { return m_allDataReceived; }
70323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)    bool hasColorProfile() const;
717242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    void resetDecoder();
725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
737242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    // It may look unusual that there's no start animation call as public API.
747242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    // This because we start and stop animating lazily. Animation starts when
757242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    // the image is rendered, and automatically pauses once all observers no
767242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    // longer want to render the image.
775267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    virtual void stopAnimation() OVERRIDE;
785267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    virtual void resetAnimation() OVERRIDE;
79d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    virtual bool maybeAnimated() OVERRIDE;
805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
81591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    virtual PassRefPtr<NativeImageSkia> nativeImageForCurrentFrame() OVERRIDE;
82c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    virtual PassRefPtr<Image> imageForDefaultFrame() OVERRIDE;
83926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    virtual bool currentFrameKnownToBeOpaque() OVERRIDE;
845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    ImageOrientation currentFrameOrientation();
855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
86197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#if ENABLE(ASSERT)
875267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    virtual bool notSolidColor() OVERRIDE;
885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#endif
895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)private:
91c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles)    friend class BitmapImageTest;
92c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles)
935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    void updateSize() const;
945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)protected:
965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    enum RepetitionCountStatus {
975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      Unknown,    // We haven't checked the source's repetition count.
985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      Uncertain,  // We have a repetition count, but it might be wrong (some GIFs have a count after the image data, and will report "loop once" until all data has been decoded).
995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)      Certain     // The repetition count is known to be correct.
1005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    };
1015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
102591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    BitmapImage(PassRefPtr<NativeImageSkia>, ImageObserver* = 0);
1035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    BitmapImage(ImageObserver* = 0);
1045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
105e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator, WebBlendMode) OVERRIDE;
106e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator, WebBlendMode, RespectImageOrientationEnum) OVERRIDE;
1075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    size_t currentFrame() const { return m_currentFrame; }
1095267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    size_t frameCount();
1107242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci
111591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    PassRefPtr<NativeImageSkia> frameAtIndex(size_t);
1127242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci
1135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool frameIsCompleteAtIndex(size_t);
1145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    float frameDurationAtIndex(size_t);
1155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool frameHasAlphaAtIndex(size_t);
1165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    ImageOrientation frameOrientationAtIndex(size_t);
1175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Decodes and caches a frame. Never accessed except internally.
1195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    void cacheFrame(size_t index);
1207242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci
1215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Called before accessing m_frames[index]. Returns false on index out of bounds.
1225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool ensureFrameIsCached(size_t index);
1235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
124c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles)    // Called to invalidate cached data. When |destroyAll| is true, we wipe out
125c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles)    // the entire frame buffer cache and tell the image source to destroy
126c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles)    // everything; this is used when e.g. we want to free some room in the image
127c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles)    // cache. If |destroyAll| is false, we delete frames except the current
128c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles)    // frame; this is used while animating large images to keep memory footprint
129c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles)    // low; the decoder should preserve the current frame and may preserve some
130c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles)    // other frames to avoid redecoding the whole image on every frame.
131c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles)    virtual void destroyDecodedData(bool destroyAll) OVERRIDE;
1325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1335267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    // If the image is large enough, calls destroyDecodedData().
1345267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    void destroyDecodedDataIfNecessary();
1355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Generally called by destroyDecodedData(), destroys whole-image metadata
1375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // and notifies observers that the memory footprint has (hopefully)
1385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // decreased by |frameBytesCleared|.
1395267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    void destroyMetadataAndNotify(size_t frameBytesCleared);
1405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1415267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    // Whether or not size is available yet.
1425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool isSizeAvailable();
1435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Animation.
1455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    int repetitionCount(bool imageKnownToBeComplete);  // |imageKnownToBeComplete| should be set if the caller knows the entire image has been decoded.
1465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool shouldAnimate();
14710f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch    virtual void startAnimation(CatchUpAnimation = CatchUp) OVERRIDE;
1485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    void advanceAnimation(Timer<BitmapImage>*);
1495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Function that does the real work of advancing the animation.  When
1515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // skippingFrames is true, we're in the middle of a loop trying to skip over
1525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // a bunch of animation frames, so we should not do things like decode each
1535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // one or notify our observers.
1545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Returns whether the animation was advanced.
1555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool internalAdvanceAnimation(bool skippingFrames);
1565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Checks to see if the image is a 1x1 solid color.  We optimize these images and just do a fill rect instead.
1585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // This check should happen regardless whether m_checkedForSolidColor is already set, as the frame may have
1595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // changed.
1605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    void checkForSolidColor();
1615267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
16209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    virtual bool mayFillWithSolidColor() OVERRIDE;
16309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    virtual Color solidColor() const OVERRIDE;
1645267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
1657242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucciprivate:
1665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    ImageSource m_source;
1675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    mutable IntSize m_size; // The size to use for the overall image (will just be the size of the first image).
1685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    mutable IntSize m_sizeRespectingOrientation;
1695267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
1705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    size_t m_currentFrame; // The index of the current frame of animation.
1715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    Vector<FrameData, 1> m_frames; // An array of the cached frames of the animation. We have to ref frames to pin them in the cache.
1725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    Timer<BitmapImage>* m_frameTimer;
1745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    int m_repetitionCount; // How many total animation loops we should do.  This will be cAnimationNone if this image type is incapable of animation.
1755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    RepetitionCountStatus m_repetitionCountStatus;
1765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    int m_repetitionsComplete;  // How many repetitions we've finished.
1775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    double m_desiredFrameStartTime;  // The system time at which we hope to see the next call to startAnimation().
1785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    Color m_solidColor;  // If we're a 1x1 solid color, this is the color to use to fill.
1805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    size_t m_frameCount;
1825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool m_isSolidColor : 1; // Whether or not we are a 1x1 solid image.
1845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool m_checkedForSolidColor : 1; // Whether we've checked the frame for solid color.
1855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool m_animationFinished : 1; // Whether or not we've completed the entire animation.
1875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool m_allDataReceived : 1; // Whether or not we've received all our data.
1895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    mutable bool m_haveSize : 1; // Whether or not our |m_size| member variable has the final overall image size yet.
1905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool m_sizeAvailable : 1; // Whether or not we can obtain the size of the first image frame yet from ImageIO.
1915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    mutable bool m_hasUniformFrameSize : 1;
1925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    mutable bool m_haveFrameCount : 1;
1935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)};
1945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
195a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)DEFINE_IMAGE_TYPE_CASTS(BitmapImage);
196a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles)
197e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)} // namespace blink
1985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#endif
200