From a3ac0a2df64dcfb8b0b01f1cf05e9afd1439e1f4 Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Mon, 6 Jan 2014 12:43:42 -0800 Subject: Import FrameSequence Change-Id: I09b668925366a22e8e7e80e4abeae24b3a98c639 (cherry picked from commit a1265c3d8a20e805e0c45083d5c7d728d4b70009) --- framesequence/jni/FrameSequence_gif.h | 84 +++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 framesequence/jni/FrameSequence_gif.h (limited to 'framesequence/jni/FrameSequence_gif.h') diff --git a/framesequence/jni/FrameSequence_gif.h b/framesequence/jni/FrameSequence_gif.h new file mode 100644 index 0000000..fbc4959 --- /dev/null +++ b/framesequence/jni/FrameSequence_gif.h @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef RASTERMILL_FRAMESQUENCE_GIF_H +#define RASTERMILL_FRAMESQUENCE_GIF_H + +#include "config.h" +#include "gif_lib.h" + +#include "Stream.h" +#include "Color.h" +#include "FrameSequence.h" + +class FrameSequence_gif : public FrameSequence { +public: + FrameSequence_gif(Stream* stream); + virtual ~FrameSequence_gif(); + + virtual int getWidth() const { + return mGif ? mGif->SWidth : 0; + } + + virtual int getHeight() const { + return mGif ? mGif->SHeight : 0; + } + + virtual int getFrameCount() const { + return mGif ? mGif->ImageCount : 0; + } + + virtual bool isOpaque() const { + return (mBgColor & COLOR_8888_ALPHA_MASK) == COLOR_8888_ALPHA_MASK; + } + + virtual FrameSequenceState* createState() const; + + GifFileType* getGif() const { return mGif; } + Color8888 getBackgroundColor() const { return mBgColor; } + bool getPreservedFrame(int frameIndex) const { return mPreservedFrames[frameIndex]; } + int getRestoringFrame(int frameIndex) const { return mRestoringFrames[frameIndex]; } + +private: + GifFileType* mGif; + Color8888 mBgColor; + + // array of bool per frame - if true, frame data is used by a later DISPOSE_PREVIOUS frame + bool* mPreservedFrames; + + // array of ints per frame - if >= 0, points to the index of the preserve that frame needs + int* mRestoringFrames; +}; + +class FrameSequenceState_gif : public FrameSequenceState { +public: + FrameSequenceState_gif(const FrameSequence_gif& frameSequence); + virtual ~FrameSequenceState_gif(); + + // returns frame's delay time in ms + virtual long drawFrame(int frameNr, + Color8888* outputPtr, int outputPixelStride, int previousFrameNr); + +private: + void savePreserveBuffer(Color8888* outputPtr, int outputPixelStride, int frameNr); + void restorePreserveBuffer(Color8888* outputPtr, int outputPixelStride); + + const FrameSequence_gif& mFrameSequence; + Color8888* mPreserveBuffer; + int mPreserveBufferFrame; +}; + +#endif //RASTERMILL_FRAMESQUENCE_GIF_H -- cgit v1.2.3