зеркало из https://github.com/mozilla/moz-skia.git
Fixed Linux compiler complaints
http://codereview.appspot.com/6269045/ git-svn-id: http://skia.googlecode.com/svn/trunk@4135 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
009103d330
Коммит
07ef911f18
|
@ -58,11 +58,11 @@
|
|||
#define GrIsALIGN4(n) SkIsAlign4(n)
|
||||
|
||||
template <typename T> const T& GrMin(const T& a, const T& b) {
|
||||
return (a < b) ? a : b;
|
||||
return (a < b) ? a : b;
|
||||
}
|
||||
|
||||
template <typename T> const T& GrMax(const T& a, const T& b) {
|
||||
return (b < a) ? a : b;
|
||||
return (b < a) ? a : b;
|
||||
}
|
||||
|
||||
// compile time versions of min/max
|
||||
|
@ -468,7 +468,7 @@ struct GrTextureDesc {
|
|||
int fHeight; //!< Height of the texture
|
||||
|
||||
/**
|
||||
* Format of source data of the texture. Not guaraunteed to be the same as
|
||||
* Format of source data of the texture. Not guaranteed to be the same as
|
||||
* internal format used by 3D API.
|
||||
*/
|
||||
GrPixelConfig fConfig;
|
||||
|
|
|
@ -203,12 +203,18 @@ public:
|
|||
void detachAllChildren();
|
||||
|
||||
/** Convert the specified point from global coordinates into view-local coordinates
|
||||
*/
|
||||
void globalToLocal(SkPoint* pt) const { if (pt) this->globalToLocal(pt->fX, pt->fY, pt); }
|
||||
* Return true on success; false on failure
|
||||
*/
|
||||
bool globalToLocal(SkPoint* pt) const {
|
||||
if (NULL != pt) {
|
||||
return this->globalToLocal(pt->fX, pt->fY, pt);
|
||||
}
|
||||
return true; // nothing to do so return true
|
||||
}
|
||||
/** Convert the specified x,y from global coordinates into view-local coordinates, returning
|
||||
the answer in the local parameter.
|
||||
*/
|
||||
void globalToLocal(SkScalar globalX, SkScalar globalY, SkPoint* local) const;
|
||||
bool globalToLocal(SkScalar globalX, SkScalar globalY, SkPoint* local) const;
|
||||
|
||||
/** \class F2BIter
|
||||
|
||||
|
|
|
@ -1051,7 +1051,9 @@ void SampleWindow::magnify(SkCanvas* canvas) {
|
|||
int count = canvas->save();
|
||||
|
||||
SkMatrix m = canvas->getTotalMatrix();
|
||||
m.invert(&m);
|
||||
if (!m.invert(&m)) {
|
||||
return;
|
||||
}
|
||||
SkPoint offset, center;
|
||||
SkScalar mouseX = fMouseX * SK_Scalar1;
|
||||
SkScalar mouseY = fMouseY * SK_Scalar1;
|
||||
|
|
|
@ -116,12 +116,17 @@ protected:
|
|||
canvas->drawPoints(SkCanvas::kPoints_PointMode, 2, &fPts[1], paint);
|
||||
}
|
||||
|
||||
SkPoint invertPt(SkScalar x, SkScalar y) {
|
||||
SkPoint pt;
|
||||
bool invertPt(SkScalar x, SkScalar y, SkPoint* result) {
|
||||
if (NULL == result)
|
||||
return true;
|
||||
|
||||
SkMatrix m;
|
||||
fMatrix.invert(&m);
|
||||
m.mapXY(x, y, &pt);
|
||||
return pt;
|
||||
if (!fMatrix.invert(&m)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m.mapXY(x, y, result);
|
||||
return true;
|
||||
}
|
||||
|
||||
int hittest(SkScalar x, SkScalar y) {
|
||||
|
@ -143,7 +148,11 @@ protected:
|
|||
|
||||
virtual bool onClick(Click* click) {
|
||||
if (fDragIndex >= 0) {
|
||||
fPts[fDragIndex] = invertPt(click->fCurr.fX, click->fCurr.fY);
|
||||
if (!invertPt(click->fCurr.fX, click->fCurr.fY,
|
||||
&fPts[fDragIndex])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this->setViews();
|
||||
this->inval(NULL);
|
||||
return true;
|
||||
|
|
|
@ -371,84 +371,99 @@ void SkView::Click::copyType(const char type[])
|
|||
|
||||
SkView::Click* SkView::findClickHandler(SkScalar x, SkScalar y)
|
||||
{
|
||||
if (x < 0 || y < 0 || x >= fWidth || y >= fHeight) {
|
||||
return NULL;
|
||||
if (x < 0 || y < 0 || x >= fWidth || y >= fHeight) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (this->onSendClickToChildren(x, y)) {
|
||||
F2BIter iter(this);
|
||||
SkView* child;
|
||||
|
||||
|
||||
while ((child = iter.next()) != NULL)
|
||||
{
|
||||
SkPoint p;
|
||||
child->globalToLocal(x, y, &p);
|
||||
|
||||
if (!child->globalToLocal(x, y, &p)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Click* click = child->findClickHandler(p.fX, p.fY);
|
||||
|
||||
|
||||
if (click) {
|
||||
return click;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this->onFindClickHandler(x, y);
|
||||
|
||||
return this->onFindClickHandler(x, y);
|
||||
}
|
||||
|
||||
void SkView::DoClickDown(Click* click, int x, int y)
|
||||
{
|
||||
SkASSERT(click);
|
||||
SkASSERT(click);
|
||||
|
||||
SkView* target = (SkView*)SkEventSink::FindSink(click->fTargetID);
|
||||
if (target == NULL)
|
||||
return;
|
||||
SkView* target = (SkView*)SkEventSink::FindSink(click->fTargetID);
|
||||
if (NULL == target) {
|
||||
return;
|
||||
}
|
||||
|
||||
click->fIOrig.set(x, y);
|
||||
click->fICurr = click->fIPrev = click->fIOrig;
|
||||
click->fIOrig.set(x, y);
|
||||
click->fICurr = click->fIPrev = click->fIOrig;
|
||||
|
||||
click->fOrig.iset(x, y);
|
||||
target->globalToLocal(&click->fOrig);
|
||||
click->fPrev = click->fCurr = click->fOrig;
|
||||
click->fOrig.iset(x, y);
|
||||
if (!target->globalToLocal(&click->fOrig)) {
|
||||
// no history to let us recover from this failure
|
||||
return;
|
||||
}
|
||||
click->fPrev = click->fCurr = click->fOrig;
|
||||
|
||||
click->fState = Click::kDown_State;
|
||||
target->onClick(click);
|
||||
click->fState = Click::kDown_State;
|
||||
target->onClick(click);
|
||||
}
|
||||
|
||||
void SkView::DoClickMoved(Click* click, int x, int y)
|
||||
{
|
||||
SkASSERT(click);
|
||||
SkASSERT(click);
|
||||
|
||||
SkView* target = (SkView*)SkEventSink::FindSink(click->fTargetID);
|
||||
if (target == NULL)
|
||||
return;
|
||||
SkView* target = (SkView*)SkEventSink::FindSink(click->fTargetID);
|
||||
if (NULL == target) {
|
||||
return;
|
||||
}
|
||||
|
||||
click->fIPrev = click->fICurr;
|
||||
click->fICurr.set(x, y);
|
||||
click->fIPrev = click->fICurr;
|
||||
click->fICurr.set(x, y);
|
||||
|
||||
click->fPrev = click->fCurr;
|
||||
click->fCurr.iset(x, y);
|
||||
target->globalToLocal(&click->fCurr);
|
||||
click->fPrev = click->fCurr;
|
||||
click->fCurr.iset(x, y);
|
||||
if (!target->globalToLocal(&click->fCurr)) {
|
||||
// on failure pretend the mouse didn't move
|
||||
click->fCurr = click->fPrev;
|
||||
}
|
||||
|
||||
click->fState = Click::kMoved_State;
|
||||
target->onClick(click);
|
||||
click->fState = Click::kMoved_State;
|
||||
target->onClick(click);
|
||||
}
|
||||
|
||||
void SkView::DoClickUp(Click* click, int x, int y)
|
||||
{
|
||||
SkASSERT(click);
|
||||
SkASSERT(click);
|
||||
|
||||
SkView* target = (SkView*)SkEventSink::FindSink(click->fTargetID);
|
||||
if (target == NULL)
|
||||
return;
|
||||
SkView* target = (SkView*)SkEventSink::FindSink(click->fTargetID);
|
||||
if (NULL == target) {
|
||||
return;
|
||||
}
|
||||
|
||||
click->fIPrev = click->fICurr;
|
||||
click->fICurr.set(x, y);
|
||||
click->fIPrev = click->fICurr;
|
||||
click->fICurr.set(x, y);
|
||||
|
||||
click->fPrev = click->fCurr;
|
||||
click->fCurr.iset(x, y);
|
||||
target->globalToLocal(&click->fCurr);
|
||||
click->fPrev = click->fCurr;
|
||||
click->fCurr.iset(x, y);
|
||||
if (!target->globalToLocal(&click->fCurr)) {
|
||||
// on failure pretend the mouse didn't move
|
||||
click->fCurr = click->fPrev;
|
||||
}
|
||||
|
||||
click->fState = Click::kUp_State;
|
||||
target->onClick(click);
|
||||
click->fState = Click::kUp_State;
|
||||
target->onClick(click);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
@ -619,18 +634,22 @@ void SkView::localToGlobal(SkMatrix* matrix) const
|
|||
}
|
||||
}
|
||||
}
|
||||
void SkView::globalToLocal(SkScalar x, SkScalar y, SkPoint* local) const
|
||||
bool SkView::globalToLocal(SkScalar x, SkScalar y, SkPoint* local) const
|
||||
{
|
||||
SkASSERT(this);
|
||||
if (local)
|
||||
{
|
||||
SkASSERT(this);
|
||||
|
||||
if (NULL != local) {
|
||||
SkMatrix m;
|
||||
this->localToGlobal(&m);
|
||||
if (!m.invert(&m)) {
|
||||
return false;
|
||||
}
|
||||
SkPoint p;
|
||||
m.invert(&m);
|
||||
m.mapXY(x, y, &p);
|
||||
local->set(p.fX, p.fY);
|
||||
}
|
||||
local->set(p.fX, p.fY);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
|
Загрузка…
Ссылка в новой задаче