| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 // This test only works with the GPU backend. | 9 // This test only works with the GPU backend. |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "effects/GrConvexPolyEffect.h" | 27 #include "effects/GrConvexPolyEffect.h" |
| 28 | 28 |
| 29 namespace skiagm { | 29 namespace skiagm { |
| 30 | 30 |
| 31 class ConvexPolyTestBatch : public GrTestBatch { | 31 class ConvexPolyTestBatch : public GrTestBatch { |
| 32 public: | 32 public: |
| 33 struct Geometry : public GrTestBatch::Geometry { | 33 struct Geometry : public GrTestBatch::Geometry { |
| 34 SkRect fBounds; | 34 SkRect fBounds; |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 const char* name() const SK_OVERRIDE { return "ConvexPolyTestBatch"; } | 37 const char* name() const override { return "ConvexPolyTestBatch"; } |
| 38 | 38 |
| 39 static GrBatch* Create(const GrGeometryProcessor* gp, const Geometry& geo) { | 39 static GrBatch* Create(const GrGeometryProcessor* gp, const Geometry& geo) { |
| 40 return SkNEW_ARGS(ConvexPolyTestBatch, (gp, geo)); | 40 return SkNEW_ARGS(ConvexPolyTestBatch, (gp, geo)); |
| 41 } | 41 } |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 ConvexPolyTestBatch(const GrGeometryProcessor* gp, const Geometry& geo) | 44 ConvexPolyTestBatch(const GrGeometryProcessor* gp, const Geometry& geo) |
| 45 : INHERITED(gp) | 45 : INHERITED(gp) |
| 46 , fGeometry(geo) { | 46 , fGeometry(geo) { |
| 47 } | 47 } |
| 48 | 48 |
| 49 Geometry* geoData(int index) SK_OVERRIDE { | 49 Geometry* geoData(int index) override { |
| 50 SkASSERT(0 == index); | 50 SkASSERT(0 == index); |
| 51 return &fGeometry; | 51 return &fGeometry; |
| 52 } | 52 } |
| 53 | 53 |
| 54 void onGenerateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeli
ne) SK_OVERRIDE { | 54 void onGenerateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeli
ne) override { |
| 55 size_t vertexStride = this->geometryProcessor()->getVertexStride(); | 55 size_t vertexStride = this->geometryProcessor()->getVertexStride(); |
| 56 | 56 |
| 57 const GrVertexBuffer* vertexBuffer; | 57 const GrVertexBuffer* vertexBuffer; |
| 58 int firstVertex; | 58 int firstVertex; |
| 59 | 59 |
| 60 void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, | 60 void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, |
| 61 kVertsPerCubic, | 61 kVertsPerCubic, |
| 62 &vertexBuffer, | 62 &vertexBuffer, |
| 63 &firstVertex); | 63 &firstVertex); |
| 64 | 64 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 /** | 97 /** |
| 98 * This GM directly exercises a GrProcessor that draws convex polygons. | 98 * This GM directly exercises a GrProcessor that draws convex polygons. |
| 99 */ | 99 */ |
| 100 class ConvexPolyEffect : public GM { | 100 class ConvexPolyEffect : public GM { |
| 101 public: | 101 public: |
| 102 ConvexPolyEffect() { | 102 ConvexPolyEffect() { |
| 103 this->setBGColor(0xFFFFFFFF); | 103 this->setBGColor(0xFFFFFFFF); |
| 104 } | 104 } |
| 105 | 105 |
| 106 protected: | 106 protected: |
| 107 SkString onShortName() SK_OVERRIDE { | 107 SkString onShortName() override { |
| 108 return SkString("convex_poly_effect"); | 108 return SkString("convex_poly_effect"); |
| 109 } | 109 } |
| 110 | 110 |
| 111 SkISize onISize() SK_OVERRIDE { | 111 SkISize onISize() override { |
| 112 return SkISize::Make(720, 800); | 112 return SkISize::Make(720, 800); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void onOnceBeforeDraw() SK_OVERRIDE { | 115 void onOnceBeforeDraw() override { |
| 116 SkPath tri; | 116 SkPath tri; |
| 117 tri.moveTo(5.f, 5.f); | 117 tri.moveTo(5.f, 5.f); |
| 118 tri.lineTo(100.f, 20.f); | 118 tri.lineTo(100.f, 20.f); |
| 119 tri.lineTo(15.f, 100.f); | 119 tri.lineTo(15.f, 100.f); |
| 120 | 120 |
| 121 fPaths.addToTail(tri); | 121 fPaths.addToTail(tri); |
| 122 fPaths.addToTail(SkPath())->reverseAddPath(tri); | 122 fPaths.addToTail(SkPath())->reverseAddPath(tri); |
| 123 | 123 |
| 124 tri.close(); | 124 tri.close(); |
| 125 fPaths.addToTail(tri); | 125 fPaths.addToTail(tri); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 155 fRects.addToTail(SkRect::MakeLTRB(5.5f, 0.5f, 29.5f, 0.75f)); | 155 fRects.addToTail(SkRect::MakeLTRB(5.5f, 0.5f, 29.5f, 0.75f)); |
| 156 // vertically/horizontally thin rects that don't cover pixel centers | 156 // vertically/horizontally thin rects that don't cover pixel centers |
| 157 fRects.addToTail(SkRect::MakeLTRB(5.55f, 0.5f, 5.75f, 24.5f)); | 157 fRects.addToTail(SkRect::MakeLTRB(5.55f, 0.5f, 5.75f, 24.5f)); |
| 158 fRects.addToTail(SkRect::MakeLTRB(5.5f, .05f, 29.5f, .25f)); | 158 fRects.addToTail(SkRect::MakeLTRB(5.5f, .05f, 29.5f, .25f)); |
| 159 // small in x and y | 159 // small in x and y |
| 160 fRects.addToTail(SkRect::MakeLTRB(5.05f, .55f, 5.45f, .85f)); | 160 fRects.addToTail(SkRect::MakeLTRB(5.05f, .55f, 5.45f, .85f)); |
| 161 // inverted in x and y | 161 // inverted in x and y |
| 162 fRects.addToTail(SkRect::MakeLTRB(100.f, 50.5f, 5.f, 0.5f)); | 162 fRects.addToTail(SkRect::MakeLTRB(100.f, 50.5f, 5.f, 0.5f)); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 165 void onDraw(SkCanvas* canvas) override { |
| 166 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); | 166 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); |
| 167 if (NULL == rt) { | 167 if (NULL == rt) { |
| 168 this->drawGpuOnlyMessage(canvas); | 168 this->drawGpuOnlyMessage(canvas); |
| 169 return; | 169 return; |
| 170 } | 170 } |
| 171 GrContext* context = rt->getContext(); | 171 GrContext* context = rt->getContext(); |
| 172 if (NULL == context) { | 172 if (NULL == context) { |
| 173 return; | 173 return; |
| 174 } | 174 } |
| 175 | 175 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 SkTLList<SkPath> fPaths; | 284 SkTLList<SkPath> fPaths; |
| 285 SkTLList<SkRect> fRects; | 285 SkTLList<SkRect> fRects; |
| 286 | 286 |
| 287 typedef GM INHERITED; | 287 typedef GM INHERITED; |
| 288 }; | 288 }; |
| 289 | 289 |
| 290 DEF_GM( return SkNEW(ConvexPolyEffect); ) | 290 DEF_GM( return SkNEW(ConvexPolyEffect); ) |
| 291 } | 291 } |
| 292 | 292 |
| 293 #endif | 293 #endif |
| OLD | NEW |