00001 /* 00002 * Copyright (C) 2008 The Android Open Source Project 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef SkMovie_DEFINED 00018 #define SkMovie_DEFINED 00019 00020 #include "SkRefCnt.h" 00021 #include "SkCanvas.h" 00022 00023 class SkStream; 00024 00025 class SkMovie : public SkRefCnt { 00026 public: 00030 static SkMovie* DecodeStream(SkStream*); 00036 static SkMovie* DecodeFile(const char path[]); 00042 static SkMovie* DecodeMemory(const void* data, size_t length); 00043 00044 SkMSec duration(); 00045 int width(); 00046 int height(); 00047 int isOpaque(); 00048 00054 bool setTime(SkMSec); 00055 00056 // return the right bitmap for the current time code 00057 const SkBitmap& bitmap(); 00058 00059 protected: 00060 struct Info { 00061 SkMSec fDuration; 00062 int fWidth; 00063 int fHeight; 00064 bool fIsOpaque; 00065 }; 00066 00067 virtual bool onGetInfo(Info*) = 0; 00068 virtual bool onSetTime(SkMSec) = 0; 00069 virtual bool onGetBitmap(SkBitmap*) = 0; 00070 00071 // visible for subclasses 00072 SkMovie(); 00073 00074 private: 00075 Info fInfo; 00076 SkMSec fCurrTime; 00077 SkBitmap fBitmap; 00078 bool fNeedBitmap; 00079 00080 void ensureInfo(); 00081 }; 00082 00083 #endif