gfx/skia/trunk/include/images/SkMovie.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/images/SkMovie.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,80 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2008 The Android Open Source Project
     1.7 + *
     1.8 + * Use of this source code is governed by a BSD-style license that can be
     1.9 + * found in the LICENSE file.
    1.10 + */
    1.11 +
    1.12 +
    1.13 +#ifndef SkMovie_DEFINED
    1.14 +#define SkMovie_DEFINED
    1.15 +
    1.16 +#include "SkRefCnt.h"
    1.17 +#include "SkCanvas.h"
    1.18 +
    1.19 +class SkStreamRewindable;
    1.20 +
    1.21 +class SkMovie : public SkRefCnt {
    1.22 +public:
    1.23 +    SK_DECLARE_INST_COUNT(SkMovie)
    1.24 +
    1.25 +    /** Try to create a movie from the stream. If the stream format is not
    1.26 +        supported, return NULL.
    1.27 +    */
    1.28 +    static SkMovie* DecodeStream(SkStreamRewindable*);
    1.29 +    /** Try to create a movie from the specified file path. If the file is not
    1.30 +        found, or the format is not supported, return NULL. If a movie is
    1.31 +        returned, the stream may be retained by the movie (via ref()) until
    1.32 +        the movie is finished with it (by calling unref()).
    1.33 +    */
    1.34 +    static SkMovie* DecodeFile(const char path[]);
    1.35 +    /** Try to create a movie from the specified memory.
    1.36 +        If the format is not supported, return NULL. If a movie is returned,
    1.37 +        the data will have been read or copied, and so the caller may free
    1.38 +        it.
    1.39 +    */
    1.40 +    static SkMovie* DecodeMemory(const void* data, size_t length);
    1.41 +
    1.42 +    SkMSec  duration();
    1.43 +    int     width();
    1.44 +    int     height();
    1.45 +    int     isOpaque();
    1.46 +
    1.47 +    /** Specify the time code (between 0...duration) to sample a bitmap
    1.48 +        from the movie. Returns true if this time code generated a different
    1.49 +        bitmap/frame from the previous state (i.e. true means you need to
    1.50 +        redraw).
    1.51 +    */
    1.52 +    bool setTime(SkMSec);
    1.53 +
    1.54 +    // return the right bitmap for the current time code
    1.55 +    const SkBitmap& bitmap();
    1.56 +
    1.57 +protected:
    1.58 +    struct Info {
    1.59 +        SkMSec  fDuration;
    1.60 +        int     fWidth;
    1.61 +        int     fHeight;
    1.62 +        bool    fIsOpaque;
    1.63 +    };
    1.64 +
    1.65 +    virtual bool onGetInfo(Info*) = 0;
    1.66 +    virtual bool onSetTime(SkMSec) = 0;
    1.67 +    virtual bool onGetBitmap(SkBitmap*) = 0;
    1.68 +
    1.69 +    // visible for subclasses
    1.70 +    SkMovie();
    1.71 +
    1.72 +private:
    1.73 +    Info        fInfo;
    1.74 +    SkMSec      fCurrTime;
    1.75 +    SkBitmap    fBitmap;
    1.76 +    bool        fNeedBitmap;
    1.77 +
    1.78 +    void ensureInfo();
    1.79 +
    1.80 +    typedef SkRefCnt INHERITED;
    1.81 +};
    1.82 +
    1.83 +#endif

mercurial