diff options
author | Chris Craik <ccraik@google.com> | 2014-01-06 12:43:42 -0800 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2014-01-13 17:56:03 +0000 |
commit | a3ac0a2df64dcfb8b0b01f1cf05e9afd1439e1f4 (patch) | |
tree | a46a47658126ecf2f3365eab0c944b80bead0dd3 /framesequence/jni/FrameSequence_gif.h | |
parent | 58ce8de3fbb0cfed369b6a38d0f5c92104745eb4 (diff) | |
download | android_frameworks_ex-a3ac0a2df64dcfb8b0b01f1cf05e9afd1439e1f4.tar.gz android_frameworks_ex-a3ac0a2df64dcfb8b0b01f1cf05e9afd1439e1f4.tar.bz2 android_frameworks_ex-a3ac0a2df64dcfb8b0b01f1cf05e9afd1439e1f4.zip |
Import FrameSequence
Change-Id: I09b668925366a22e8e7e80e4abeae24b3a98c639
(cherry picked from commit a1265c3d8a20e805e0c45083d5c7d728d4b70009)
Diffstat (limited to 'framesequence/jni/FrameSequence_gif.h')
-rw-r--r-- | framesequence/jni/FrameSequence_gif.h | 84 |
1 files changed, 84 insertions, 0 deletions
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 |