Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: samplecode/SamplePatch.cpp

Issue 441373002: fix hittest in Patch sample (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SamplePatch.cpp
diff --git a/samplecode/SamplePatch.cpp b/samplecode/SamplePatch.cpp
index fe94bbfd52812df1fd9edf2d3f26014d5fba03e6..d3ae71ac80b737260b3cd8ba487cdccdfa820239 100644
--- a/samplecode/SamplePatch.cpp
+++ b/samplecode/SamplePatch.cpp
@@ -218,6 +218,9 @@ static void drawpatches(SkCanvas* canvas, const SkPaint& paint, int nu, int nv,
patch->draw(canvas, paint, 10, 10, true, true);
}
+const SkScalar DX = 20;
+const SkScalar DY = 0;
+
class PatchView : public SampleView {
SkShader* fShader0;
SkShader* fShader1;
@@ -271,7 +274,7 @@ protected:
paint.setDither(true);
paint.setFilterLevel(SkPaint::kLow_FilterLevel);
- canvas->translate(SkIntToScalar(20), 0);
+ canvas->translate(DX, DY);
Patch patch;
@@ -327,6 +330,8 @@ protected:
virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y,
unsigned modi) SK_OVERRIDE {
+ x -= DX;
+ y -= DY;
for (size_t i = 0; i < SK_ARRAY_COUNT(fPts); i++) {
if (hittest(fPts[i], x, y)) {
return new PtClick(this, (int)i);
@@ -336,7 +341,7 @@ protected:
}
virtual bool onClick(Click* click) {
- fPts[((PtClick*)click)->fIndex].set(click->fCurr.fX, click->fCurr.fY);
+ fPts[((PtClick*)click)->fIndex].set(click->fCurr.fX - DX, click->fCurr.fY - DY);
this->inval(NULL);
return true;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698