check-point for reviving animator

git-svn-id: http://skia.googlecode.com/svn/trunk@380 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@android.com 2009-10-13 13:33:16 +00:00
Родитель d0d0e65a63
Коммит 0f0cfaecf2
5 изменённых файлов: 92 добавлений и 3 удалений

Просмотреть файл

@ -122,7 +122,7 @@
so this flag is optional.
*/
#ifdef SK_DEBUG
#define SK_SUPPORT_UNITTEST
//#define SK_SUPPORT_UNITTEST
#endif
#endif

Просмотреть файл

@ -0,0 +1,88 @@
#include "SampleCode.h"
#include "SkView.h"
#include "SkCanvas.h"
#include "SkAnimator.h"
#include "SkStream.h"
class SkAnimatorView : public SkView {
public:
SkAnimatorView();
virtual ~SkAnimatorView();
void setURIBase(const char dir[]);
SkAnimator* getAnimator() const { return fAnimator; }
bool decodeFile(const char path[]);
bool decodeMemory(const void* buffer, size_t size);
bool decodeStream(SkStream* stream);
protected:
// overrides
virtual void onDraw(SkCanvas*);
private:
SkString fBaseURI;
SkAnimator* fAnimator;
typedef SkView INHERITED;
};
SkAnimatorView::SkAnimatorView() : fAnimator(NULL) {
}
SkAnimatorView::~SkAnimatorView() {
delete fAnimator;
}
void SkAnimatorView::setURIBase(const char dir[]) {
fBaseURI.set(dir);
}
bool SkAnimatorView::decodeFile(const char path[]) {
SkFILEStream* is = new SkFILEStream(path);
SkAutoUnref aur(is);
return is->isValid() && this->decodeStream(is);
}
bool SkAnimatorView::decodeMemory(const void* buffer, size_t size) {
SkMemoryStream* is = new SkMemoryStream(buffer, size);
SkAutoUnref aur(is);
return this->decodeStream(is);
}
bool SkAnimatorView::decodeStream(SkStream* stream) {
delete fAnimator;
fAnimator = new SkAnimator;
fAnimator->setURIBase(fBaseURI.c_str());
if (!fAnimator->decodeStream(stream)) {
delete fAnimator;
fAnimator = NULL;
return false;
}
return true;
}
#include "SkTime.h"
void SkAnimatorView::onDraw(SkCanvas* canvas) {
if (fAnimator) {
canvas->drawColor(SK_ColorWHITE);
fAnimator->draw(canvas, SkTime::GetMSecs());
this->inval(NULL);
}
}
//////////////////////////////////////////////////////////////////////////////
static SkView* MyFactory() {
SkAnimatorView* av = new SkAnimatorView;
// av->decodeFile("/skimages/test.xml");
av->setURIBase("/skia/trunk/animations/");
av->decodeFile("/skia/trunk/animations/movie#1.xml");
return av;
}
static SkViewRegister reg(MyFactory);

Просмотреть файл

@ -273,5 +273,5 @@ void SkDrawPaint::setupPaint(SkPaint* paint) const {
if (underline != -1)
paint->setUnderlineText(SkToBool(underline));
if (xfermode != (SkXfermode::Mode) -1)
paint->setXfermode((SkXfermode::Mode) xfermode);
paint->setXfermodeMode((SkXfermode::Mode) xfermode);
}

Просмотреть файл

@ -20,6 +20,7 @@
#include "SkSnapshot.h"
#include "SkAnimateMaker.h"
#include "SkCanvas.h"
#include "SkImageEncoder.h"
#if SK_USE_CONDENSED_INFO == 0

Просмотреть файл

@ -16,7 +16,7 @@
*/
#include "SkTextBox.h"
#include "SkGlyphCache.h"
#include "../src/core/SkGlyphCache.h"
#include "SkUtils.h"
#include "SkAutoKern.h"