Verb autoClose(SkPoint pts[2]);
};
-#ifdef SK_DEBUG
- /** @cond UNIT_TEST */
void dump(bool forceClose, const char title[] = NULL) const;
- /** @endcond */
-#endif
+ void dump() const;
void flatten(SkFlattenableWriteBuffer&) const;
void unflatten(SkFlattenableReadBuffer&);
void offset(SkScalar dx, SkScalar dy);
/** Call this to have the view draw into the specified canvas. */
- void draw(SkCanvas* canvas);
+ virtual void draw(SkCanvas* canvas);
+
/** Call this to invalidate part of all of a view, requesting that the view's
draw method be called. The rectangle parameter specifies the part of the view
that should be redrawn. If it is null, it specifies the entire view bounds.
SampleWindow(void* hwnd);
virtual ~SampleWindow();
+ virtual void draw(SkCanvas* canvas);
+
protected:
virtual void onDraw(SkCanvas* canvas);
virtual bool onHandleKey(SkKey key);
CanvasType fCanvasType;
bool fUseClip;
+ bool fNClip;
bool fRepeatDrawing;
bool fAnimating;
bool fRotate;
fCanvasType = kRaster_CanvasType;
fUseClip = false;
+ fNClip = false;
fRepeatDrawing = false;
fAnimating = false;
fRotate = false;
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);
this->inval(NULL);
return true;
case kUp_SkKey:
- fUseClip = !fUseClip;
+ fNClip = !fNClip;
this->updateTitle();
this->inval(NULL);
return true;
if (fRotate) {
title.prepend("<R> ");
}
-
+ if (fNClip) {
+ title.prepend("<C> ");
+ }
this->setTitle(title.c_str());
}
SkPoint resultStorage[kMaxPoints];
SkPoint* result; // points to our results, either tmp or resultStorage
int lineCount = 1;
+ bool reverse;
if (pts[0].fX < pts[1].fX) {
index0 = 0;
index1 = 1;
+ reverse = false;
} else {
index0 = 1;
index1 = 0;
+ reverse = true;
}
-
+
if (tmp[index1].fX <= clip.fLeft) { // wholly to the left
tmp[0].fX = tmp[1].fX = clip.fLeft;
result = tmp;
+ reverse = false;
} else if (tmp[index0].fX >= clip.fRight) { // wholly to the right
tmp[0].fX = tmp[1].fX = clip.fRight;
result = tmp;
+ reverse = false;
} else {
result = resultStorage;
SkPoint* r = result;
}
// Now copy the results into the caller's lines[] parameter
- if (0 == index1) {
+ if (reverse) {
// copy the pts in reverse order to maintain winding order
for (int i = 0; i <= lineCount; i++) {
lines[lineCount - i] = result[i];
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
-#ifdef SK_DEBUG
-
-void SkPath::validate() const {
- SkASSERT(this != NULL);
- SkASSERT((fFillType & ~3) == 0);
- fPts.validate();
- fVerbs.validate();
-
- if (!fBoundsIsDirty) {
- SkRect bounds;
- compute_pt_bounds(&bounds, fPts);
- if (fPts.count() <= 1) {
- // if we're empty, fBounds may be empty but translated, so we can't
- // necessarily compare to bounds directly
- // try path.addOval(2, 2, 2, 2) which is empty, but the bounds will
- // be [2, 2, 2, 2]
- SkASSERT(bounds.isEmpty());
- SkASSERT(fBounds.isEmpty());
- } else {
- fBounds.contains(bounds);
- }
- }
-}
-
void SkPath::dump(bool forceClose, const char title[]) const {
Iter iter(*this, forceClose);
SkPoint pts[4];
SkDebugf("path: done %s\n", title ? title : "");
}
+void SkPath::dump() const {
+ this->dump(false);
+}
+
+#ifdef SK_DEBUG
+void SkPath::validate() const {
+ SkASSERT(this != NULL);
+ SkASSERT((fFillType & ~3) == 0);
+ fPts.validate();
+ fVerbs.validate();
+
+ if (!fBoundsIsDirty) {
+ SkRect bounds;
+ compute_pt_bounds(&bounds, fPts);
+ if (fPts.count() <= 1) {
+ // if we're empty, fBounds may be empty but translated, so we can't
+ // necessarily compare to bounds directly
+ // try path.addOval(2, 2, 2, 2) which is empty, but the bounds will
+ // be [2, 2, 2, 2]
+ SkASSERT(bounds.isEmpty());
+ SkASSERT(fBounds.isEmpty());
+ } else {
+ fBounds.contains(bounds);
+ }
+ }
+}
#endif
+