OLD | NEW |
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 * vec4f : (p.xy, outerRad, innerRad) | 68 * vec4f : (p.xy, outerRad, innerRad) |
69 * p is the position in the normalized space. | 69 * p is the position in the normalized space. |
70 * outerRad is the outerRadius in device space. | 70 * outerRad is the outerRadius in device space. |
71 * innerRad is the innerRadius in normalized space (ignored if not s
troking). | 71 * innerRad is the innerRadius in normalized space (ignored if not s
troking). |
72 */ | 72 */ |
73 | 73 |
74 class CircleGeometryProcessor : public GrGeometryProcessor { | 74 class CircleGeometryProcessor : public GrGeometryProcessor { |
75 public: | 75 public: |
76 CircleGeometryProcessor(bool stroke, const SkMatrix& localMatrix) : fLocalMa
trix(localMatrix){ | 76 CircleGeometryProcessor(bool stroke, const SkMatrix& localMatrix) : fLocalMa
trix(localMatrix){ |
77 this->initClassID<CircleGeometryProcessor>(); | 77 this->initClassID<CircleGeometryProcessor>(); |
78 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType, | 78 fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttrib
Type, |
79 kHigh_GrSLPrecision)); | 79 kHigh_GrSLPrecision); |
80 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA
ttribType)); | 80 fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType)
; |
81 fInCircleEdge = &this->addVertexAttrib(Attribute("inCircleEdge", | 81 fInCircleEdge = &this->addVertexAttrib("inCircleEdge", kVec4f_GrVertexAt
tribType); |
82 kVec4f_GrVertexAttribTy
pe)); | |
83 fStroke = stroke; | 82 fStroke = stroke; |
84 } | 83 } |
85 | 84 |
86 bool implementsDistanceVector() const override { return true; }; | 85 bool implementsDistanceVector() const override { return true; }; |
87 | 86 |
88 virtual ~CircleGeometryProcessor() {} | 87 virtual ~CircleGeometryProcessor() {} |
89 | 88 |
90 const char* name() const override { return "CircleEdge"; } | 89 const char* name() const override { return "CircleEdge"; } |
91 | 90 |
92 void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override { | 91 void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 * in both x and y directions. | 204 * in both x and y directions. |
206 * | 205 * |
207 * We are using an implicit function of x^2/a^2 + y^2/b^2 - 1 = 0. | 206 * We are using an implicit function of x^2/a^2 + y^2/b^2 - 1 = 0. |
208 */ | 207 */ |
209 | 208 |
210 class EllipseGeometryProcessor : public GrGeometryProcessor { | 209 class EllipseGeometryProcessor : public GrGeometryProcessor { |
211 public: | 210 public: |
212 EllipseGeometryProcessor(bool stroke, const SkMatrix& localMatrix) | 211 EllipseGeometryProcessor(bool stroke, const SkMatrix& localMatrix) |
213 : fLocalMatrix(localMatrix) { | 212 : fLocalMatrix(localMatrix) { |
214 this->initClassID<EllipseGeometryProcessor>(); | 213 this->initClassID<EllipseGeometryProcessor>(); |
215 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); | 214 fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttrib
Type); |
216 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA
ttribType)); | 215 fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType)
; |
217 fInEllipseOffset = &this->addVertexAttrib(Attribute("inEllipseOffset", | 216 fInEllipseOffset = &this->addVertexAttrib("inEllipseOffset", kVec2f_GrVe
rtexAttribType); |
218 kVec2f_GrVertexAttri
bType)); | 217 fInEllipseRadii = &this->addVertexAttrib("inEllipseRadii", kVec4f_GrVert
exAttribType); |
219 fInEllipseRadii = &this->addVertexAttrib(Attribute("inEllipseRadii", | |
220 kVec4f_GrVertexAttrib
Type)); | |
221 fStroke = stroke; | 218 fStroke = stroke; |
222 } | 219 } |
223 | 220 |
224 virtual ~EllipseGeometryProcessor() {} | 221 virtual ~EllipseGeometryProcessor() {} |
225 | 222 |
226 const char* name() const override { return "EllipseEdge"; } | 223 const char* name() const override { return "EllipseEdge"; } |
227 | 224 |
228 void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override { | 225 void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override { |
229 GLSLProcessor::GenKey(*this, caps, b); | 226 GLSLProcessor::GenKey(*this, caps, b); |
230 } | 227 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 * The result is device-independent and can be used with any affine matrix. | 351 * The result is device-independent and can be used with any affine matrix. |
355 */ | 352 */ |
356 | 353 |
357 enum class DIEllipseStyle { kStroke = 0, kHairline, kFill }; | 354 enum class DIEllipseStyle { kStroke = 0, kHairline, kFill }; |
358 | 355 |
359 class DIEllipseGeometryProcessor : public GrGeometryProcessor { | 356 class DIEllipseGeometryProcessor : public GrGeometryProcessor { |
360 public: | 357 public: |
361 DIEllipseGeometryProcessor(const SkMatrix& viewMatrix, DIEllipseStyle style) | 358 DIEllipseGeometryProcessor(const SkMatrix& viewMatrix, DIEllipseStyle style) |
362 : fViewMatrix(viewMatrix) { | 359 : fViewMatrix(viewMatrix) { |
363 this->initClassID<DIEllipseGeometryProcessor>(); | 360 this->initClassID<DIEllipseGeometryProcessor>(); |
364 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType, | 361 fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttrib
Type, |
365 kHigh_GrSLPrecision)); | 362 kHigh_GrSLPrecision); |
366 fInColor = &this->addVertexAttrib(Attribute("inColor", kVec4ub_GrVertexA
ttribType)); | 363 fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType)
; |
367 fInEllipseOffsets0 = &this->addVertexAttrib(Attribute("inEllipseOffsets0
", | 364 fInEllipseOffsets0 = &this->addVertexAttrib("inEllipseOffsets0", kVec2f_
GrVertexAttribType); |
368 kVec2f_GrVertexAtt
ribType)); | 365 fInEllipseOffsets1 = &this->addVertexAttrib("inEllipseOffsets1", kVec2f_
GrVertexAttribType); |
369 fInEllipseOffsets1 = &this->addVertexAttrib(Attribute("inEllipseOffsets1
", | |
370 kVec2f_GrVertexAtt
ribType)); | |
371 fStyle = style; | 366 fStyle = style; |
372 } | 367 } |
373 | 368 |
374 | 369 |
375 virtual ~DIEllipseGeometryProcessor() {} | 370 virtual ~DIEllipseGeometryProcessor() {} |
376 | 371 |
377 const char* name() const override { return "DIEllipseEdge"; } | 372 const char* name() const override { return "DIEllipseEdge"; } |
378 | 373 |
379 void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override { | 374 void getGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override { |
380 GLSLProcessor::GenKey(*this, caps, b); | 375 GLSLProcessor::GenKey(*this, caps, b); |
(...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1689 } | 1684 } |
1690 | 1685 |
1691 DRAW_BATCH_TEST_DEFINE(RRectBatch) { | 1686 DRAW_BATCH_TEST_DEFINE(RRectBatch) { |
1692 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); | 1687 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); |
1693 GrColor color = GrRandomColor(random); | 1688 GrColor color = GrRandomColor(random); |
1694 const SkRRect& rrect = GrTest::TestRRectSimple(random); | 1689 const SkRRect& rrect = GrTest::TestRRectSimple(random); |
1695 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); | 1690 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra
ndom)); |
1696 } | 1691 } |
1697 | 1692 |
1698 #endif | 1693 #endif |
OLD | NEW |