Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: samplecode/SampleMovie.cpp

Issue 901933004: migrate more samples over to SkAnimTImer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix warning Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « samplecode/SampleMipMap.cpp ('k') | samplecode/SampleOvalTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1
2 /*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8 #include "SampleCode.h"
9 #include "SkView.h"
10 #include "SkCanvas.h"
11 #include "SkMovie.h"
12 #include "SkTime.h"
13 #include <new>
14
15 class AnimGifView : public SkView {
16 SkMovie* fMovie;
17 public:
18 AnimGifView() {
19 fMovie = SkMovie::DecodeFile("/skimages/dollarblk.gif");
20 }
21
22 virtual ~AnimGifView() {
23 SkSafeUnref(fMovie);
24 }
25
26 protected:
27 // overrides from SkEventSink
28 virtual bool onQuery(SkEvent* evt) {
29 if (SampleCode::TitleQ(*evt)) {
30 SampleCode::TitleR(evt, "Animated Gif");
31 return true;
32 }
33 return this->INHERITED::onQuery(evt);
34 }
35
36 void drawBG(SkCanvas* canvas) {
37 canvas->drawColor(0xFFDDDDDD);
38 }
39
40 virtual void onDraw(SkCanvas* canvas) {
41 this->drawBG(canvas);
42
43 if (fMovie) {
44 if (fMovie->duration()) {
45 fMovie->setTime(SkTime::GetMSecs() % fMovie->duration());
46 } else {
47 fMovie->setTime(0);
48 }
49 canvas->drawBitmap(fMovie->bitmap(), SkIntToScalar(20),
50 SkIntToScalar(20));
51 this->inval(NULL);
52 }
53 }
54
55 private:
56 SkPath fPath;
57
58 typedef SkView INHERITED;
59 };
60
61 //////////////////////////////////////////////////////////////////////////////
62
63 static SkView* MyFactory() { return new AnimGifView; }
64 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleMipMap.cpp ('k') | samplecode/SampleOvalTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698