add 'o' option to show fat-oval
git-svn-id: http://skia.googlecode.com/svn/trunk@8002 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/samplecode/SampleFatBits.cpp b/samplecode/SampleFatBits.cpp
index 7ac87a7..04fa1a3 100644
--- a/samplecode/SampleFatBits.cpp
+++ b/samplecode/SampleFatBits.cpp
@@ -51,6 +51,7 @@
fShowSkeleton = true;
fUseGPU = false;
fUseClip = false;
+ fRectAsOval = false;
fClipRect.set(2, 2, 11, 8 );
}
@@ -69,6 +70,8 @@
bool getUseGPU() const { return fUseGPU; }
void setUseGPU(bool ug) { fUseGPU = ug; }
+ void toggleRectAsOval() { fRectAsOval = !fRectAsOval; }
+
bool getUseClip() const { return fUseClip; }
void setUseClip(bool uc) { fUseClip = uc; }
@@ -103,7 +106,7 @@
void drawRect(SkCanvas* canvas, SkPoint pts[2]);
private:
- bool fAA, fGrid, fShowSkeleton, fUseGPU, fUseClip;
+ bool fAA, fGrid, fShowSkeleton, fUseGPU, fUseClip, fRectAsOval;
Style fStyle;
int fW, fH, fZoom;
SkMatrix fMatrix, fInverse;
@@ -148,7 +151,7 @@
rr.inset(-SkIntToScalar(fZoom)/2, -SkIntToScalar(fZoom)/2);
path.addRect(rr);
} else {
- path.addRect(r);
+ fRectAsOval ? path.addOval(r) : path.addRect(r);
if (fUseGPU) {
path.moveTo(r.fLeft, r.fTop);
path.lineTo(r.fRight, r.fBottom);
@@ -310,7 +313,10 @@
erase(fMinSurface);
this->setupPaint(&paint);
paint.setColor(FAT_PIXEL_COLOR);
- fMinSurface->getCanvas()->drawRect(r, paint);
+ {
+ SkCanvas* c = fMinSurface->getCanvas();
+ fRectAsOval ? c->drawOval(r, paint) : c->drawRect(r, paint);
+ }
this->copyMinToMax();
SkCanvas* max = fMaxSurface->getCanvas();
@@ -368,6 +374,10 @@
fIsRect = !fIsRect;
this->inval(NULL);
return true;
+ case 'o':
+ fFB.toggleRectAsOval();
+ this->inval(NULL);
+ return true;
case 'x':
fFB.setGrid(!fFB.getGrid());
this->inval(NULL);