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

Side by Side Diff: src/gpu/GrOvalRenderer.cpp

Issue 1316123003: Style Change: SkNEW->new; SkDELETE->delete (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-26 (Wednesday) 15:59:00 EDT Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrNonAtomicRef.h ('k') | src/gpu/GrPaint.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrOvalRenderer.h" 8 #include "GrOvalRenderer.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 * vec4f : (p.xy, outerRad, innerRad) 65 * vec4f : (p.xy, outerRad, innerRad)
66 * p is the position in the normalized space. 66 * p is the position in the normalized space.
67 * outerRad is the outerRadius in device space. 67 * outerRad is the outerRadius in device space.
68 * innerRad is the innerRadius in normalized space (ignored if not s troking). 68 * innerRad is the innerRadius in normalized space (ignored if not s troking).
69 */ 69 */
70 70
71 class CircleEdgeEffect : public GrGeometryProcessor { 71 class CircleEdgeEffect : public GrGeometryProcessor {
72 public: 72 public:
73 static GrGeometryProcessor* Create(GrColor color, bool stroke, const SkMatri x& localMatrix, 73 static GrGeometryProcessor* Create(GrColor color, bool stroke, const SkMatri x& localMatrix,
74 bool usesLocalCoords) { 74 bool usesLocalCoords) {
75 return SkNEW_ARGS(CircleEdgeEffect, (color, stroke, localMatrix, usesLoc alCoords)); 75 return new CircleEdgeEffect(color, stroke, localMatrix, usesLocalCoords) ;
76 } 76 }
77 77
78 const Attribute* inPosition() const { return fInPosition; } 78 const Attribute* inPosition() const { return fInPosition; }
79 const Attribute* inCircleEdge() const { return fInCircleEdge; } 79 const Attribute* inCircleEdge() const { return fInCircleEdge; }
80 GrColor color() const { return fColor; } 80 GrColor color() const { return fColor; }
81 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; } 81 bool colorIgnored() const { return GrColor_ILLEGAL == fColor; }
82 const SkMatrix& localMatrix() const { return fLocalMatrix; } 82 const SkMatrix& localMatrix() const { return fLocalMatrix; }
83 bool usesLocalCoords() const { return fUsesLocalCoords; } 83 bool usesLocalCoords() const { return fUsesLocalCoords; }
84 virtual ~CircleEdgeEffect() {} 84 virtual ~CircleEdgeEffect() {}
85 85
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 }; 166 };
167 167
168 virtual void getGLProcessorKey(const GrBatchTracker& bt, 168 virtual void getGLProcessorKey(const GrBatchTracker& bt,
169 const GrGLSLCaps& caps, 169 const GrGLSLCaps& caps,
170 GrProcessorKeyBuilder* b) const override { 170 GrProcessorKeyBuilder* b) const override {
171 GLProcessor::GenKey(*this, bt, caps, b); 171 GLProcessor::GenKey(*this, bt, caps, b);
172 } 172 }
173 173
174 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, 174 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
175 const GrGLSLCaps&) const ov erride { 175 const GrGLSLCaps&) const ov erride {
176 return SkNEW_ARGS(GLProcessor, (*this, bt)); 176 return new GLProcessor(*this, bt);
177 } 177 }
178 178
179 private: 179 private:
180 CircleEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix, bo ol usesLocalCoords) 180 CircleEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix, bo ol usesLocalCoords)
181 : fColor(color) 181 : fColor(color)
182 , fLocalMatrix(localMatrix) 182 , fLocalMatrix(localMatrix)
183 , fUsesLocalCoords(usesLocalCoords) { 183 , fUsesLocalCoords(usesLocalCoords) {
184 this->initClassID<CircleEdgeEffect>(); 184 this->initClassID<CircleEdgeEffect>();
185 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe rtexAttribType, 185 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe rtexAttribType,
186 kHigh_GrSLPrecision)); 186 kHigh_GrSLPrecision));
(...skipping 30 matching lines...) Expand all
217 * ellipse, specified as a 2D offset from center, and the reciprocals of the out er and inner radii, 217 * ellipse, specified as a 2D offset from center, and the reciprocals of the out er and inner radii,
218 * in both x and y directions. 218 * in both x and y directions.
219 * 219 *
220 * We are using an implicit function of x^2/a^2 + y^2/b^2 - 1 = 0. 220 * We are using an implicit function of x^2/a^2 + y^2/b^2 - 1 = 0.
221 */ 221 */
222 222
223 class EllipseEdgeEffect : public GrGeometryProcessor { 223 class EllipseEdgeEffect : public GrGeometryProcessor {
224 public: 224 public:
225 static GrGeometryProcessor* Create(GrColor color, bool stroke, const SkMatri x& localMatrix, 225 static GrGeometryProcessor* Create(GrColor color, bool stroke, const SkMatri x& localMatrix,
226 bool usesLocalCoords) { 226 bool usesLocalCoords) {
227 return SkNEW_ARGS(EllipseEdgeEffect, (color, stroke, localMatrix, usesLo calCoords)); 227 return new EllipseEdgeEffect(color, stroke, localMatrix, usesLocalCoords );
228 } 228 }
229 229
230 virtual ~EllipseEdgeEffect() {} 230 virtual ~EllipseEdgeEffect() {}
231 231
232 const char* name() const override { return "EllipseEdge"; } 232 const char* name() const override { return "EllipseEdge"; }
233 233
234 const Attribute* inPosition() const { return fInPosition; } 234 const Attribute* inPosition() const { return fInPosition; }
235 const Attribute* inEllipseOffset() const { return fInEllipseOffset; } 235 const Attribute* inEllipseOffset() const { return fInEllipseOffset; }
236 const Attribute* inEllipseRadii() const { return fInEllipseRadii; } 236 const Attribute* inEllipseRadii() const { return fInEllipseRadii; }
237 GrColor color() const { return fColor; } 237 GrColor color() const { return fColor; }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 }; 342 };
343 343
344 virtual void getGLProcessorKey(const GrBatchTracker& bt, 344 virtual void getGLProcessorKey(const GrBatchTracker& bt,
345 const GrGLSLCaps& caps, 345 const GrGLSLCaps& caps,
346 GrProcessorKeyBuilder* b) const override { 346 GrProcessorKeyBuilder* b) const override {
347 GLProcessor::GenKey(*this, bt, caps, b); 347 GLProcessor::GenKey(*this, bt, caps, b);
348 } 348 }
349 349
350 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, 350 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
351 const GrGLSLCaps&) const ov erride { 351 const GrGLSLCaps&) const ov erride {
352 return SkNEW_ARGS(GLProcessor, (*this, bt)); 352 return new GLProcessor(*this, bt);
353 } 353 }
354 354
355 private: 355 private:
356 EllipseEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix, 356 EllipseEdgeEffect(GrColor color, bool stroke, const SkMatrix& localMatrix,
357 bool usesLocalCoords) 357 bool usesLocalCoords)
358 : fColor(color) 358 : fColor(color)
359 , fLocalMatrix(localMatrix) 359 , fLocalMatrix(localMatrix)
360 , fUsesLocalCoords(usesLocalCoords) { 360 , fUsesLocalCoords(usesLocalCoords) {
361 this->initClassID<EllipseEdgeEffect>(); 361 this->initClassID<EllipseEdgeEffect>();
362 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe rtexAttribType)); 362 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe rtexAttribType));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 * 399 *
400 * The result is device-independent and can be used with any affine matrix. 400 * The result is device-independent and can be used with any affine matrix.
401 */ 401 */
402 402
403 class DIEllipseEdgeEffect : public GrGeometryProcessor { 403 class DIEllipseEdgeEffect : public GrGeometryProcessor {
404 public: 404 public:
405 enum Mode { kStroke = 0, kHairline, kFill }; 405 enum Mode { kStroke = 0, kHairline, kFill };
406 406
407 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix , Mode mode, 407 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& viewMatrix , Mode mode,
408 bool usesLocalCoords) { 408 bool usesLocalCoords) {
409 return SkNEW_ARGS(DIEllipseEdgeEffect, (color, viewMatrix, mode, usesLoc alCoords)); 409 return new DIEllipseEdgeEffect(color, viewMatrix, mode, usesLocalCoords) ;
410 } 410 }
411 411
412 virtual ~DIEllipseEdgeEffect() {} 412 virtual ~DIEllipseEdgeEffect() {}
413 413
414 const char* name() const override { return "DIEllipseEdge"; } 414 const char* name() const override { return "DIEllipseEdge"; }
415 415
416 const Attribute* inPosition() const { return fInPosition; } 416 const Attribute* inPosition() const { return fInPosition; }
417 const Attribute* inEllipseOffsets0() const { return fInEllipseOffsets0; } 417 const Attribute* inEllipseOffsets0() const { return fInEllipseOffsets0; }
418 const Attribute* inEllipseOffsets1() const { return fInEllipseOffsets1; } 418 const Attribute* inEllipseOffsets1() const { return fInEllipseOffsets1; }
419 GrColor color() const { return fColor; } 419 GrColor color() const { return fColor; }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 }; 542 };
543 543
544 virtual void getGLProcessorKey(const GrBatchTracker& bt, 544 virtual void getGLProcessorKey(const GrBatchTracker& bt,
545 const GrGLSLCaps& caps, 545 const GrGLSLCaps& caps,
546 GrProcessorKeyBuilder* b) const override { 546 GrProcessorKeyBuilder* b) const override {
547 GLProcessor::GenKey(*this, bt, caps, b); 547 GLProcessor::GenKey(*this, bt, caps, b);
548 } 548 }
549 549
550 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, 550 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt,
551 const GrGLSLCaps&) const ov erride { 551 const GrGLSLCaps&) const ov erride {
552 return SkNEW_ARGS(GLProcessor, (*this, bt)); 552 return new GLProcessor(*this, bt);
553 } 553 }
554 554
555 private: 555 private:
556 DIEllipseEdgeEffect(GrColor color, const SkMatrix& viewMatrix, Mode mode, 556 DIEllipseEdgeEffect(GrColor color, const SkMatrix& viewMatrix, Mode mode,
557 bool usesLocalCoords) 557 bool usesLocalCoords)
558 : fColor(color) 558 : fColor(color)
559 , fViewMatrix(viewMatrix) 559 , fViewMatrix(viewMatrix)
560 , fUsesLocalCoords(usesLocalCoords) { 560 , fUsesLocalCoords(usesLocalCoords) {
561 this->initClassID<DIEllipseEdgeEffect>(); 561 this->initClassID<DIEllipseEdgeEffect>();
562 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe rtexAttribType, 562 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe rtexAttribType,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 public: 629 public:
630 struct Geometry { 630 struct Geometry {
631 GrColor fColor; 631 GrColor fColor;
632 SkMatrix fViewMatrix; 632 SkMatrix fViewMatrix;
633 SkScalar fInnerRadius; 633 SkScalar fInnerRadius;
634 SkScalar fOuterRadius; 634 SkScalar fOuterRadius;
635 bool fStroke; 635 bool fStroke;
636 SkRect fDevBounds; 636 SkRect fDevBounds;
637 }; 637 };
638 638
639 static GrDrawBatch* Create(const Geometry& geometry) { 639 static GrDrawBatch* Create(const Geometry& geometry) { return new CircleBatc h(geometry); }
640 return SkNEW_ARGS(CircleBatch, (geometry));
641 }
642 640
643 const char* name() const override { return "CircleBatch"; } 641 const char* name() const override { return "CircleBatch"; }
644 642
645 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 643 void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
646 // When this is called on a batch, there is only one geometry bundle 644 // When this is called on a batch, there is only one geometry bundle
647 out->setKnownFourComponents(fGeoData[0].fColor); 645 out->setKnownFourComponents(fGeoData[0].fColor);
648 } 646 }
649 647
650 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { 648 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
651 out->setUnknownSingleComponent(); 649 out->setUnknownSingleComponent();
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 GrColor fColor; 846 GrColor fColor;
849 SkMatrix fViewMatrix; 847 SkMatrix fViewMatrix;
850 SkScalar fXRadius; 848 SkScalar fXRadius;
851 SkScalar fYRadius; 849 SkScalar fYRadius;
852 SkScalar fInnerXRadius; 850 SkScalar fInnerXRadius;
853 SkScalar fInnerYRadius; 851 SkScalar fInnerYRadius;
854 bool fStroke; 852 bool fStroke;
855 SkRect fDevBounds; 853 SkRect fDevBounds;
856 }; 854 };
857 855
858 static GrDrawBatch* Create(const Geometry& geometry) { 856 static GrDrawBatch* Create(const Geometry& geometry) { return new EllipseBat ch(geometry); }
859 return SkNEW_ARGS(EllipseBatch, (geometry));
860 }
861 857
862 const char* name() const override { return "EllipseBatch"; } 858 const char* name() const override { return "EllipseBatch"; }
863 859
864 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 860 void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
865 // When this is called on a batch, there is only one geometry bundle 861 // When this is called on a batch, there is only one geometry bundle
866 out->setKnownFourComponents(fGeoData[0].fColor); 862 out->setKnownFourComponents(fGeoData[0].fColor);
867 } 863 }
868 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { 864 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
869 out->setUnknownSingleComponent(); 865 out->setUnknownSingleComponent();
870 } 866 }
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 SkScalar fYRadius; 1113 SkScalar fYRadius;
1118 SkScalar fInnerXRadius; 1114 SkScalar fInnerXRadius;
1119 SkScalar fInnerYRadius; 1115 SkScalar fInnerYRadius;
1120 SkScalar fGeoDx; 1116 SkScalar fGeoDx;
1121 SkScalar fGeoDy; 1117 SkScalar fGeoDy;
1122 DIEllipseEdgeEffect::Mode fMode; 1118 DIEllipseEdgeEffect::Mode fMode;
1123 SkRect fBounds; 1119 SkRect fBounds;
1124 }; 1120 };
1125 1121
1126 static GrDrawBatch* Create(const Geometry& geometry, const SkRect& bounds) { 1122 static GrDrawBatch* Create(const Geometry& geometry, const SkRect& bounds) {
1127 return SkNEW_ARGS(DIEllipseBatch, (geometry, bounds)); 1123 return new DIEllipseBatch(geometry, bounds);
1128 } 1124 }
1129 1125
1130 const char* name() const override { return "DIEllipseBatch"; } 1126 const char* name() const override { return "DIEllipseBatch"; }
1131 1127
1132 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 1128 void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
1133 // When this is called on a batch, there is only one geometry bundle 1129 // When this is called on a batch, there is only one geometry bundle
1134 out->setKnownFourComponents(fGeoData[0].fColor); 1130 out->setKnownFourComponents(fGeoData[0].fColor);
1135 } 1131 }
1136 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { 1132 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
1137 out->setUnknownSingleComponent(); 1133 out->setUnknownSingleComponent();
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 struct Geometry { 1465 struct Geometry {
1470 GrColor fColor; 1466 GrColor fColor;
1471 SkMatrix fViewMatrix; 1467 SkMatrix fViewMatrix;
1472 SkScalar fInnerRadius; 1468 SkScalar fInnerRadius;
1473 SkScalar fOuterRadius; 1469 SkScalar fOuterRadius;
1474 bool fStroke; 1470 bool fStroke;
1475 SkRect fDevBounds; 1471 SkRect fDevBounds;
1476 }; 1472 };
1477 1473
1478 static GrDrawBatch* Create(const Geometry& geometry) { 1474 static GrDrawBatch* Create(const Geometry& geometry) {
1479 return SkNEW_ARGS(RRectCircleRendererBatch, (geometry)); 1475 return new RRectCircleRendererBatch(geometry);
1480 } 1476 }
1481 1477
1482 const char* name() const override { return "RRectCircleBatch"; } 1478 const char* name() const override { return "RRectCircleBatch"; }
1483 1479
1484 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 1480 void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
1485 // When this is called on a batch, there is only one geometry bundle 1481 // When this is called on a batch, there is only one geometry bundle
1486 out->setKnownFourComponents(fGeoData[0].fColor); 1482 out->setKnownFourComponents(fGeoData[0].fColor);
1487 } 1483 }
1488 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { 1484 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
1489 out->setUnknownSingleComponent(); 1485 out->setUnknownSingleComponent();
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 SkMatrix fViewMatrix; 1641 SkMatrix fViewMatrix;
1646 SkScalar fXRadius; 1642 SkScalar fXRadius;
1647 SkScalar fYRadius; 1643 SkScalar fYRadius;
1648 SkScalar fInnerXRadius; 1644 SkScalar fInnerXRadius;
1649 SkScalar fInnerYRadius; 1645 SkScalar fInnerYRadius;
1650 bool fStroke; 1646 bool fStroke;
1651 SkRect fDevBounds; 1647 SkRect fDevBounds;
1652 }; 1648 };
1653 1649
1654 static GrDrawBatch* Create(const Geometry& geometry) { 1650 static GrDrawBatch* Create(const Geometry& geometry) {
1655 return SkNEW_ARGS(RRectEllipseRendererBatch, (geometry)); 1651 return new RRectEllipseRendererBatch(geometry);
1656 } 1652 }
1657 1653
1658 const char* name() const override { return "RRectEllipseRendererBatch"; } 1654 const char* name() const override { return "RRectEllipseRendererBatch"; }
1659 1655
1660 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 1656 void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
1661 // When this is called on a batch, there is only one geometry bundle 1657 // When this is called on a batch, there is only one geometry bundle
1662 out->setKnownFourComponents(fGeoData[0].fColor); 1658 out->setKnownFourComponents(fGeoData[0].fColor);
1663 } 1659 }
1664 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { 1660 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
1665 out->setUnknownSingleComponent(); 1661 out->setUnknownSingleComponent();
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
2037 } 2033 }
2038 2034
2039 DRAW_BATCH_TEST_DEFINE(RRectBatch) { 2035 DRAW_BATCH_TEST_DEFINE(RRectBatch) {
2040 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); 2036 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random);
2041 GrColor color = GrRandomColor(random); 2037 GrColor color = GrRandomColor(random);
2042 const SkRRect& rrect = GrTest::TestRRectSimple(random); 2038 const SkRRect& rrect = GrTest::TestRRectSimple(random);
2043 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra ndom)); 2039 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra ndom));
2044 } 2040 }
2045 2041
2046 #endif 2042 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrNonAtomicRef.h ('k') | src/gpu/GrPaint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698