/** Override this if you might handle the click
*/
- virtual Click* onFindClickHandler(SkScalar x, SkScalar y);
+ virtual Click* onFindClickHandler(SkScalar x, SkScalar y);
+ /** Override this to decide if your children are targets for a click.
+ The default returns true, in which case your children views will be
+ candidates for onFindClickHandler. Returning false wil skip the children
+ and just call your onFindClickHandler.
+ */
+ virtual bool onSendClickToChildren(SkScalar x, SkScalar y);
/** Override this to track clicks, returning true as long as you want to track
the pen/mouse.
*/
return this->INHERITED::onQuery(evt);
}
- virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) {
+ virtual bool onSendClickToChildren(SkScalar x, SkScalar y) {
+ return false;
+ }
+
+ virtual Click* onFindClickHandler(SkScalar x, SkScalar y) {
int ix = (int)(SkScalarDiv(x * N, W));
int iy = (int)(SkScalarDiv(y * N, H));
if (ix >= 0 && iy >= 0) {
return canvas;
}
-
SkIntToScalar(250), SkIntToScalar(400));
canvas->drawOval(oval, p);
}
-
+
virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) {
- fCenter.set(x, y);
+ return new Click(this);
+ }
+
+ virtual bool onClick(Click* click) {
+ fCenter.set(click->fCurr.fX, click->fCurr.fY);
this->inval(NULL);
return NULL;
}
return (int)(list - start);
}
-extern "C" {
- static int edge_compare(const void* a, const void* b)
- {
- const SkEdge* edgea = *(const SkEdge**)a;
- const SkEdge* edgeb = *(const SkEdge**)b;
-
- int valuea = edgea->fFirstY;
- int valueb = edgeb->fFirstY;
-
- if (valuea == valueb)
- {
- valuea = edgea->fX;
- valueb = edgeb->fX;
- }
-
- // this overflows if valuea >>> valueb or vice-versa
- // return valuea - valueb;
- // do perform the slower but safe compares
- return (valuea < valueb) ? -1 : (valuea > valueb);
- }
-}
-
-static SkEdge* sort_edges(SkEdge* list[], int count, SkEdge** last)
-{
- qsort(list, count, sizeof(SkEdge*), edge_compare);
-
- // now make the edges linked in sorted order
- for (int i = 1; i < count; i++)
- {
- list[i - 1]->fNext = list[i];
- list[i]->fPrev = list[i - 1];
- }
-
- *last = list[count - 1];
- return list[0];
-}
-
#ifdef SK_DEBUG
/* 'quick' computation of the max sized needed to allocated for
our edgelist.
return edgeCount;
}
+///////////////////////////////////////////////////////////////////////////////
+
+extern "C" {
+ static int edge_compare(const void* a, const void* b) {
+ const SkEdge* edgea = *(const SkEdge**)a;
+ const SkEdge* edgeb = *(const SkEdge**)b;
+
+ int valuea = edgea->fFirstY;
+ int valueb = edgeb->fFirstY;
+
+ if (valuea == valueb) {
+ valuea = edgea->fX;
+ valueb = edgeb->fX;
+ }
+
+ // this overflows if valuea >>> valueb or vice-versa
+ // return valuea - valueb;
+ // do perform the slower but safe compares
+ return (valuea < valueb) ? -1 : (valuea > valueb);
+ }
+}
+
+static SkEdge* sort_edges(SkEdge* list[], int count, SkEdge** last) {
+ qsort(list, count, sizeof(SkEdge*), edge_compare);
+
+ // now make the edges linked in sorted order
+ for (int i = 1; i < count; i++) {
+ list[i - 1]->fNext = list[i];
+ list[i]->fPrev = list[i - 1];
+ }
+
+ *last = list[count - 1];
+ return list[0];
+}
+
// clipRect may be null, even though we always have a clip. This indicates that
// the path is contained in the clip, and so we can ignore it during the blit
//
SkView::Click* SkView::findClickHandler(SkScalar x, SkScalar y)
{
- if (x < 0 || y < 0 || x >= fWidth || y >= fHeight)
+ if (x < 0 || y < 0 || x >= fWidth || y >= fHeight) {
return false;
-
- F2BIter iter(this);
- SkView* child;
-
- while ((child = iter.next()) != NULL)
- {
- Click* click = child->findClickHandler(x - child->fLoc.fX, y - child->fLoc.fY);
- if (click)
- return click;
- }
+ }
+
+ if (this->onSendClickToChildren(x, y)) {
+ F2BIter iter(this);
+ SkView* child;
+
+ while ((child = iter.next()) != NULL)
+ {
+ Click* click = child->findClickHandler(x - child->fLoc.fX,
+ y - child->fLoc.fY);
+ if (click) {
+ return click;
+ }
+ }
+ }
return this->onFindClickHandler(x, y);
}
//////////////////////////////////////////////////////////////////////
-void SkView::invokeLayout()
-{
+void SkView::invokeLayout() {
SkView::Layout* layout = this->getLayout();
- if (layout)
+ if (layout) {
layout->layoutChildren(this);
+ }
}
-void SkView::onDraw(SkCanvas* canvas)
-{
+void SkView::onDraw(SkCanvas* canvas) {
Artist* artist = this->getArtist();
- if (artist)
+ if (artist) {
artist->draw(this, canvas);
+ }
}
-void SkView::onSizeChange()
-{
+void SkView::onSizeChange() {}
+
+bool SkView::onSendClickToChildren(SkScalar x, SkScalar y) {
+ return true;
}
-SkView::Click* SkView::onFindClickHandler(SkScalar x, SkScalar y)
-{
+SkView::Click* SkView::onFindClickHandler(SkScalar x, SkScalar y) {
return NULL;
}
-bool SkView::onClick(Click*)
-{
+bool SkView::onClick(Click*) {
return false;
}
-bool SkView::handleInval(const SkRect& r)
-{
+bool SkView::handleInval(const SkRect& r) {
return false;
}
REPORTER_ASSERT(reporter, clamp == clamp2);
}
- for (i = 0; i < 100000; i++) {
+ for (i = 0; i < 10000; i++) {
SkPoint p;
p.setLength(rand.nextS(), rand.nextS(), SK_Scalar1);
#endif
#ifdef SkLONGLONG
- for (i = 0; i < 100000; i++) {
+ for (i = 0; i < 10000; i++) {
SkFixed numer = rand.nextS();
SkFixed denom = rand.nextS();
SkFixed result = SkFixedDiv(numer, denom);
#endif
#ifdef SK_CAN_USE_FLOAT
- for (i = 0; i < 100000; i++) {
+ for (i = 0; i < 10000; i++) {
SkFract x = rand.nextU() >> 1;
double xx = (double)x / SK_Fract1;
SkFract xr = SkFractSqrt(x);
}
int maxDiff = 0;
- for (i = 0; i < 10000; i++) {
+ for (i = 0; i < 1000; i++) {
SkFixed rads = rand.nextS() >> 10;
double frads = SkFixedToFloat(rads);
}
for (size_t size = 1; size <= 512; size += 1) {
- for (int n = 200; n; n--) {
+ for (int n = 100; n; n--) {
uint8_t src[600], src2[600];
uint8_t dst[600];
rand_fill(src, size);
bool match = memcmp(src, src2, size * sizeof(uint8_t)) == 0;
REPORTER_ASSERT(reporter, match);
- for (int j = 0; j < 200; j++) {
+ for (int j = 0; j < 100; j++) {
size_t skip = gRand.nextU() % size;
size_t write = gRand.nextU() % size;
if (skip + write > size) {