aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode/SampleFatBits.cpp
diff options
context:
space:
mode:
authorGravatar mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-06 02:18:33 +0000
committerGravatar mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-06 02:18:33 +0000
commit64494e99af8f834a0343a4d1ee0aa4c2860e13a3 (patch)
tree24b00f83150fc621e4ae6b047e68d7f44c3cf89a /samplecode/SampleFatBits.cpp
parent812b6f59fafc213260a56a4a4264ebf23646f662 (diff)
add 'o' option to show fat-oval
git-svn-id: http://skia.googlecode.com/svn/trunk@8002 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode/SampleFatBits.cpp')
-rw-r--r--samplecode/SampleFatBits.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/samplecode/SampleFatBits.cpp b/samplecode/SampleFatBits.cpp
index 7ac87a7bc0..04fa1a39cb 100644
--- a/samplecode/SampleFatBits.cpp
+++ b/samplecode/SampleFatBits.cpp
@@ -51,6 +51,7 @@ public:
fShowSkeleton = true;
fUseGPU = false;
fUseClip = false;
+ fRectAsOval = false;
fClipRect.set(2, 2, 11, 8 );
}
@@ -69,6 +70,8 @@ public:
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 @@ public:
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 @@ private:
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 @@ void FatBits::drawRect(SkCanvas* canvas, SkPoint pts[2]) {
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 @@ protected:
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);