Chromium Code Reviews| Index: gm/patch.cpp |
| diff --git a/gm/patch.cpp b/gm/patch.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..627249ba2c14021ea64ccfff27ab86db2e20f2bf |
| --- /dev/null |
| +++ b/gm/patch.cpp |
| @@ -0,0 +1,89 @@ |
| + |
| +/* |
| + * Copyright 2014 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +// This test only works with the GPU backend. |
| + |
| +#include "gm.h" |
| + |
| +#if SK_SUPPORT_GPU |
| + |
| +#include "GrContext.h" |
| +#include "GrTest.h" |
| + |
| +#include "SkPatch.h" |
| +#include <stdio.h> |
| + |
| +namespace skiagm { |
| +/** |
| + * This GM draws a SkPatch. |
| + */ |
| +class SkPatchGM : public GM { |
| +public: |
| + SkPatchGM() { |
| + this->setBGColor(0xFFFFFFFF); |
| + } |
| + |
| +protected: |
| + virtual SkString onShortName() SK_OVERRIDE { |
| + return SkString("skpatch"); |
| + } |
| + |
| + virtual SkISize onISize() SK_OVERRIDE { |
| + return SkISize::Make(800, 800); |
| + } |
| + |
| + virtual uint32_t onGetFlags() const SK_OVERRIDE { |
| + // This is a GPU-specific GM. |
|
dandov
2014/07/22 18:00:30
The GM is not GPU-specific anymore, should I retur
|
| + return kGPUOnly_Flag; |
| + } |
| + |
| + |
| + virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| + |
| + SkPaint paint; |
| + SkColor colors[4] = { |
| + SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorCYAN |
| + }; |
| + SkPoint points[] = { |
| + {100,100}, {130,50}, {500,70}, {650,60}, |
| + {110,590}, {140,550}, {515,595}, {600,700}, |
| + {70,150}, {125,400}, |
| + {350,125}, {490,555} |
| + }; |
| + |
| + SkPatch coons(points, &colors, 10); |
| + coons.setData(); |
| + |
| + canvas->drawVertices(SkCanvas::kTriangles_VertexMode,coons.getVertexCount(), |
| + coons.getPoints(), coons.getTexCoords(), coons.getColors(), NULL, coons.getIndices(), |
| + coons.getIndexCount(), paint); |
| + |
| + //draw control points |
| + canvas->drawPoints(SkCanvas::kLines_PointMode, 4, coons.getBottomPoints(), paint); |
| + canvas->drawPoints(SkCanvas::kLines_PointMode, 4, coons.getTopPoints(), paint); |
| + canvas->drawPoints(SkCanvas::kLines_PointMode, 4, coons.getLeftPoints(), paint); |
| + canvas->drawPoints(SkCanvas::kLines_PointMode, 4, coons.getRightPoints(), paint); |
| + |
| + paint.setStrokeWidth(5); |
| + paint.setColor(SK_ColorRED); |
| + |
| + canvas->drawPoints(SkCanvas::kPoints_PointMode, 4, coons.getBottomPoints(), paint); |
| + canvas->drawPoints(SkCanvas::kPoints_PointMode, 4, coons.getTopPoints(), paint); |
| + canvas->drawPoints(SkCanvas::kPoints_PointMode, 4, coons.getLeftPoints(), paint); |
| + canvas->drawPoints(SkCanvas::kPoints_PointMode, 4, coons.getRightPoints(), paint); |
| + } |
| + |
| +private: |
| + typedef GM INHERITED; |
| +}; |
| + |
| +DEF_GM( return SkNEW(SkPatchGM); ) |
| + |
| +} |
| + |
| +#endif |