add onSendClickToChildren to views, so a view can capture all clicks.
speedup some of the unittests that were too slow minor cleanup in SkScan_Path, in prep for larger changes git-svn-id: http://skia.googlecode.com/svn/trunk@426 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
f0f4e9abba
commit
e72fee513a
@ -314,7 +314,13 @@ protected:
|
|||||||
|
|
||||||
/** Override this if you might handle the click
|
/** 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
|
/** Override this to track clicks, returning true as long as you want to track
|
||||||
the pen/mouse.
|
the pen/mouse.
|
||||||
*/
|
*/
|
||||||
|
@ -29,7 +29,11 @@ protected:
|
|||||||
return this->INHERITED::onQuery(evt);
|
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 ix = (int)(SkScalarDiv(x * N, W));
|
||||||
int iy = (int)(SkScalarDiv(y * N, H));
|
int iy = (int)(SkScalarDiv(y * N, H));
|
||||||
if (ix >= 0 && iy >= 0) {
|
if (ix >= 0 && iy >= 0) {
|
||||||
@ -88,4 +92,3 @@ SkCanvas* OverView::beforeChildren(SkCanvas* canvas) {
|
|||||||
return canvas;
|
return canvas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,9 +119,13 @@ protected:
|
|||||||
SkIntToScalar(250), SkIntToScalar(400));
|
SkIntToScalar(250), SkIntToScalar(400));
|
||||||
canvas->drawOval(oval, p);
|
canvas->drawOval(oval, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) {
|
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);
|
this->inval(NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -369,43 +369,6 @@ static int build_edges(SkEdge edge[], const SkPath& path,
|
|||||||
return (int)(list - start);
|
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
|
#ifdef SK_DEBUG
|
||||||
/* 'quick' computation of the max sized needed to allocated for
|
/* 'quick' computation of the max sized needed to allocated for
|
||||||
our edgelist.
|
our edgelist.
|
||||||
@ -466,6 +429,41 @@ static int cheap_worst_case_edge_count(const SkPath& path, size_t* storage) {
|
|||||||
return edgeCount;
|
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
|
// 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
|
// the path is contained in the clip, and so we can ignore it during the blit
|
||||||
//
|
//
|
||||||
|
@ -343,18 +343,23 @@ void SkView::Click::copyType(const char type[])
|
|||||||
|
|
||||||
SkView::Click* SkView::findClickHandler(SkScalar x, SkScalar y)
|
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;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
F2BIter iter(this);
|
if (this->onSendClickToChildren(x, y)) {
|
||||||
SkView* child;
|
F2BIter iter(this);
|
||||||
|
SkView* child;
|
||||||
|
|
||||||
while ((child = iter.next()) != NULL)
|
while ((child = iter.next()) != NULL)
|
||||||
{
|
{
|
||||||
Click* click = child->findClickHandler(x - child->fLoc.fX, y - child->fLoc.fY);
|
Click* click = child->findClickHandler(x - child->fLoc.fX,
|
||||||
if (click)
|
y - child->fLoc.fY);
|
||||||
return click;
|
if (click) {
|
||||||
}
|
return click;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return this->onFindClickHandler(x, y);
|
return this->onFindClickHandler(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,38 +422,37 @@ void SkView::DoClickUp(Click* click, int x, int y)
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void SkView::invokeLayout()
|
void SkView::invokeLayout() {
|
||||||
{
|
|
||||||
SkView::Layout* layout = this->getLayout();
|
SkView::Layout* layout = this->getLayout();
|
||||||
|
|
||||||
if (layout)
|
if (layout) {
|
||||||
layout->layoutChildren(this);
|
layout->layoutChildren(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkView::onDraw(SkCanvas* canvas)
|
void SkView::onDraw(SkCanvas* canvas) {
|
||||||
{
|
|
||||||
Artist* artist = this->getArtist();
|
Artist* artist = this->getArtist();
|
||||||
|
|
||||||
if (artist)
|
if (artist) {
|
||||||
artist->draw(this, canvas);
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkView::onClick(Click*)
|
bool SkView::onClick(Click*) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkView::handleInval(const SkRect& r)
|
bool SkView::handleInval(const SkRect& r) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ static void TestMath(skiatest::Reporter* reporter) {
|
|||||||
REPORTER_ASSERT(reporter, clamp == clamp2);
|
REPORTER_ASSERT(reporter, clamp == clamp2);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 100000; i++) {
|
for (i = 0; i < 10000; i++) {
|
||||||
SkPoint p;
|
SkPoint p;
|
||||||
|
|
||||||
p.setLength(rand.nextS(), rand.nextS(), SK_Scalar1);
|
p.setLength(rand.nextS(), rand.nextS(), SK_Scalar1);
|
||||||
@ -256,7 +256,7 @@ static void TestMath(skiatest::Reporter* reporter) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SkLONGLONG
|
#ifdef SkLONGLONG
|
||||||
for (i = 0; i < 100000; i++) {
|
for (i = 0; i < 10000; i++) {
|
||||||
SkFixed numer = rand.nextS();
|
SkFixed numer = rand.nextS();
|
||||||
SkFixed denom = rand.nextS();
|
SkFixed denom = rand.nextS();
|
||||||
SkFixed result = SkFixedDiv(numer, denom);
|
SkFixed result = SkFixedDiv(numer, denom);
|
||||||
@ -321,7 +321,7 @@ static void TestMath(skiatest::Reporter* reporter) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SK_CAN_USE_FLOAT
|
#ifdef SK_CAN_USE_FLOAT
|
||||||
for (i = 0; i < 100000; i++) {
|
for (i = 0; i < 10000; i++) {
|
||||||
SkFract x = rand.nextU() >> 1;
|
SkFract x = rand.nextU() >> 1;
|
||||||
double xx = (double)x / SK_Fract1;
|
double xx = (double)x / SK_Fract1;
|
||||||
SkFract xr = SkFractSqrt(x);
|
SkFract xr = SkFractSqrt(x);
|
||||||
@ -351,7 +351,7 @@ static void TestMath(skiatest::Reporter* reporter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int maxDiff = 0;
|
int maxDiff = 0;
|
||||||
for (i = 0; i < 10000; i++) {
|
for (i = 0; i < 1000; i++) {
|
||||||
SkFixed rads = rand.nextS() >> 10;
|
SkFixed rads = rand.nextS() >> 10;
|
||||||
double frads = SkFixedToFloat(rads);
|
double frads = SkFixedToFloat(rads);
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ static void test_pack8(skiatest::Reporter* reporter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (size_t size = 1; size <= 512; size += 1) {
|
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 src[600], src2[600];
|
||||||
uint8_t dst[600];
|
uint8_t dst[600];
|
||||||
rand_fill(src, size);
|
rand_fill(src, size);
|
||||||
@ -104,7 +104,7 @@ static void test_pack8(skiatest::Reporter* reporter) {
|
|||||||
bool match = memcmp(src, src2, size * sizeof(uint8_t)) == 0;
|
bool match = memcmp(src, src2, size * sizeof(uint8_t)) == 0;
|
||||||
REPORTER_ASSERT(reporter, match);
|
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 skip = gRand.nextU() % size;
|
||||||
size_t write = gRand.nextU() % size;
|
size_t write = gRand.nextU() % size;
|
||||||
if (skip + write > size) {
|
if (skip + write > size) {
|
||||||
|
Loading…
Reference in New Issue
Block a user