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

Unified Diff: samplecode/SampleHairline.cpp

Issue 888283002: allow GMs to animate (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: switch all existing animations to use animatePulse Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/SampleHT.cpp ('k') | samplecode/SamplePathEffects.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleHairline.cpp
diff --git a/samplecode/SampleHairline.cpp b/samplecode/SampleHairline.cpp
index 807a319e80344da5218df884b4b69c58f90ac3b6..3c254472fa735202fbf3041f7939018df016e316 100644
--- a/samplecode/SampleHairline.cpp
+++ b/samplecode/SampleHairline.cpp
@@ -30,20 +30,6 @@
static SkRandom gRand;
-static void test_chromium_9005() {
- SkBitmap bm;
- bm.allocN32Pixels(800, 600);
-
- SkCanvas canvas(bm);
-
- SkPoint pt0 = { 799.33374f, 1.2360189f };
- SkPoint pt1 = { 808.49969f, -7.4338055f };
-
- SkPaint paint;
- paint.setAntiAlias(true);
- canvas.drawLine(pt0.fX, pt0.fY, pt1.fX, pt1.fY, paint);
-}
-
static void generate_pts(SkPoint pts[], int count, int w, int h) {
for (int i = 0; i < count; i++) {
pts[i].set(gRand.nextUScalar1() * 3 * w - SkIntToScalar(w),
@@ -191,7 +177,6 @@ class HairlineView : public SampleView {
bool fDoAA;
public:
HairlineView() {
- fCounter = 0;
fProcIndex = 0;
fDoAA = true;
fNow = 0;
@@ -199,7 +184,7 @@ public:
protected:
// overrides from SkEventSink
- virtual bool onQuery(SkEvent* evt) {
+ bool onQuery(SkEvent* evt) SK_OVERRIDE {
if (SampleCode::TitleQ(*evt)) {
SkString str;
str.printf("Hair-%s", gProcs[fProcIndex].fName);
@@ -215,15 +200,9 @@ protected:
canvas->drawBitmap(b1, SkIntToScalar(b0.width()), 0, NULL);
}
- int fCounter;
-
- virtual void onDrawContent(SkCanvas* canvas) {
+ void onDrawContent(SkCanvas* canvas) SK_OVERRIDE {
gRand.setSeed(fNow);
- if (false) { // avoid bit rot, suppress warning
- test_chromium_9005();
- }
-
SkBitmap bm, bm2;
bm.allocN32Pixels(WIDTH + MARGIN*2, HEIGHT + MARGIN*2);
// this will erase our margin, which we want to always stay 0
@@ -240,23 +219,18 @@ protected:
bm2.eraseColor(SK_ColorTRANSPARENT);
gProcs[fProcIndex].fProc(&c2, paint, bm);
canvas->drawBitmap(bm2, SkIntToScalar(10), SkIntToScalar(10), NULL);
+ }
- SkMSec now = SampleCode::GetAnimTime();
- if (fNow != now) {
- fNow = now;
- fCounter += 1;
- fDoAA = !fDoAA;
- if (fCounter > 50) {
- fProcIndex = cycle_hairproc_index(fProcIndex);
- // todo: signal that we want to rebuild our TITLE
- fCounter = 0;
- }
- this->inval(NULL);
+ bool onAnimatePulse(SkMSec curr, SkMSec prev) SK_OVERRIDE {
+ if (fDoAA) {
+ fProcIndex = cycle_hairproc_index(fProcIndex);
+ // todo: signal that we want to rebuild our TITLE
}
+ fDoAA = !fDoAA;
+ return true;
}
- virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y,
- unsigned modi) {
+ SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) SK_OVERRIDE {
fDoAA = !fDoAA;
this->inval(NULL);
return this->INHERITED::onFindClickHandler(x, y, modi);
« no previous file with comments | « samplecode/SampleHT.cpp ('k') | samplecode/SamplePathEffects.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698