Wire up mouse and keyboard events in CanvasKit viewer
Change-Id: I10b57f18edb516b48be3ba16f98a540370ec689f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292793
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
diff --git a/samplecode/SampleTessellatedWedge.cpp b/samplecode/SampleTessellatedWedge.cpp
index a46adce..89731cb 100644
--- a/samplecode/SampleTessellatedWedge.cpp
+++ b/samplecode/SampleTessellatedWedge.cpp
@@ -22,9 +22,9 @@
// This sample enables wireframe and visualizes the triangulation generated by
// GrTessellateWedgeShader.
-class TessellatedWedgeView : public Sample {
+class TessellatedWedge : public Sample {
public:
- TessellatedWedgeView() {
+ TessellatedWedge() {
#if 0
fPath.moveTo(1, 0);
int numSides = 32 * 3;
@@ -56,7 +56,7 @@
class Click;
};
-void TessellatedWedgeView::onDrawContent(SkCanvas* canvas) {
+void TessellatedWedge::onDrawContent(SkCanvas* canvas) {
canvas->clear(SK_ColorBLACK);
GrContext* ctx = canvas->getGrContext();
@@ -65,8 +65,8 @@
SkString error;
if (!rtc || !ctx) {
error = "GPU Only.";
- } else if (!ctx->priv().caps()->shaderCaps()->tessellationSupport()) {
- error = "GPU tessellation not supported.";
+ } else if (!ctx->priv().caps()->drawInstancedSupport()) {
+ error = "Instanced rendering not supported.";
} else if (1 == rtc->numSamples() && !ctx->priv().caps()->mixedSamplesSupport()) {
error = "MSAA/mixed samples only.";
}
@@ -110,7 +110,7 @@
fLastViewMatrix = canvas->getTotalMatrix();
}
-class TessellatedWedgeView::Click : public Sample::Click {
+class TessellatedWedge::Click : public Sample::Click {
public:
Click(int ptIdx) : fPtIdx(ptIdx) {}
@@ -128,7 +128,7 @@
int fPtIdx;
};
-Sample::Click* TessellatedWedgeView::onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey) {
+Sample::Click* TessellatedWedge::onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey) {
const SkPoint* pts = SkPathPriv::PointData(fPath);
float fuzz = 20 / fLastViewMatrix.getMaxScale();
for (int i = 0; i < fPath.countPoints(); ++i) {
@@ -140,13 +140,13 @@
return new Click(-1);
}
-bool TessellatedWedgeView::onClick(Sample::Click* click) {
+bool TessellatedWedge::onClick(Sample::Click* click) {
Click* myClick = (Click*)click;
myClick->doClick(&fPath);
return true;
}
-bool TessellatedWedgeView::onChar(SkUnichar unichar) {
+bool TessellatedWedge::onChar(SkUnichar unichar) {
switch (unichar) {
case 'w':
fFlags = (GrTessellatePathOp::Flags)(
@@ -160,6 +160,7 @@
return false;
}
-DEF_SAMPLE(return new TessellatedWedgeView;)
+Sample* MakeTessellatedWedgeSample() { return new TessellatedWedge; }
+static SampleRegistry gTessellatedWedgeSample(MakeTessellatedWedgeSample);
#endif // SK_SUPPORT_GPU