aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode
diff options
context:
space:
mode:
authorGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-11-23 20:10:41 +0000
committerGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-11-23 20:10:41 +0000
commite522ca5d5f249bd51a00cb68bb051f811d0a9e85 (patch)
treef69fea7ec607bbc9cb88e1a154b5c37a3c626852 /samplecode
parent90209caa686464cad70dd9d60b53c3d967eb57da (diff)
fix winding bug in lineclipper
expose path.dump() all the time UP arrow now toggles a grid of clip rects in sample app git-svn-id: http://skia.googlecode.com/svn/trunk@443 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode')
-rw-r--r--samplecode/SampleApp.cpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index c485356b1f..2d0da1f71b 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -129,6 +129,8 @@ public:
SampleWindow(void* hwnd);
virtual ~SampleWindow();
+ virtual void draw(SkCanvas* canvas);
+
protected:
virtual void onDraw(SkCanvas* canvas);
virtual bool onHandleKey(SkKey key);
@@ -167,6 +169,7 @@ private:
CanvasType fCanvasType;
bool fUseClip;
+ bool fNClip;
bool fRepeatDrawing;
bool fAnimating;
bool fRotate;
@@ -210,6 +213,7 @@ SampleWindow::SampleWindow(void* hwnd) : INHERITED(hwnd) {
fCanvasType = kRaster_CanvasType;
fUseClip = false;
+ fNClip = false;
fRepeatDrawing = false;
fAnimating = false;
fRotate = false;
@@ -237,6 +241,33 @@ SampleWindow::~SampleWindow() {
delete fGLCanvas;
}
+#define XCLIP_N 4
+#define YCLIP_N 1
+
+void SampleWindow::draw(SkCanvas* canvas) {
+ if (fNClip) {
+ // this->INHERITED::draw(canvas);
+ // SkBitmap orig = capture_bitmap(canvas);
+
+ const SkScalar w = this->width();
+ const SkScalar h = this->height();
+ const SkScalar cw = w / XCLIP_N;
+ const SkScalar ch = h / YCLIP_N;
+ for (int y = 0; y < YCLIP_N; y++) {
+ for (int x = 0; x < XCLIP_N; x++) {
+ SkAutoCanvasRestore acr(canvas, true);
+ SkRect r = {
+ x * cw, y * ch, (x + 1) * cw, (y + 1) * ch
+ };
+ canvas->clipRect(r);
+ this->INHERITED::draw(canvas);
+ }
+ }
+ } else {
+ this->INHERITED::draw(canvas);
+ }
+}
+
void SampleWindow::onDraw(SkCanvas* canvas) {
if (fRepeatDrawing) {
this->inval(NULL);
@@ -511,7 +542,7 @@ bool SampleWindow::onHandleKey(SkKey key) {
this->inval(NULL);
return true;
case kUp_SkKey:
- fUseClip = !fUseClip;
+ fNClip = !fNClip;
this->updateTitle();
this->inval(NULL);
return true;
@@ -604,7 +635,9 @@ void SampleWindow::updateTitle() {
if (fRotate) {
title.prepend("<R> ");
}
-
+ if (fNClip) {
+ title.prepend("<C> ");
+ }
this->setTitle(title.c_str());
}