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

Side by Side Diff: src/gpu/effects/GrBezierEffect.cpp

Issue 1428543003: Create GLSL base class for ProgramDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add space Created 5 years, 1 month 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/batches/GrAAConvexPathRenderer.cpp ('k') | src/gpu/effects/GrBicubicEffect.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 "GrBezierEffect.h" 8 #include "GrBezierEffect.h"
9 9
10 #include "gl/GrGLFragmentProcessor.h" 10 #include "gl/GrGLFragmentProcessor.h"
11 #include "gl/GrGLGeometryProcessor.h" 11 #include "gl/GrGLGeometryProcessor.h"
12 #include "gl/GrGLUtil.h" 12 #include "gl/GrGLUtil.h"
13 #include "gl/builders/GrGLProgramBuilder.h" 13 #include "gl/builders/GrGLProgramBuilder.h"
14 #include "glsl/GrGLSLProgramDataManager.h"
14 15
15 class GrGLConicEffect : public GrGLGeometryProcessor { 16 class GrGLConicEffect : public GrGLGeometryProcessor {
16 public: 17 public:
17 GrGLConicEffect(const GrGeometryProcessor&); 18 GrGLConicEffect(const GrGeometryProcessor&);
18 19
19 void onEmitCode(EmitArgs&, GrGPArgs*) override; 20 void onEmitCode(EmitArgs&, GrGPArgs*) override;
20 21
21 static inline void GenKey(const GrGeometryProcessor&, 22 static inline void GenKey(const GrGeometryProcessor&,
22 const GrGLSLCaps&, 23 const GrGLSLCaps&,
23 GrProcessorKeyBuilder*); 24 GrProcessorKeyBuilder*);
24 25
25 void setData(const GrGLProgramDataManager& pdman, 26 void setData(const GrGLSLProgramDataManager& pdman,
26 const GrPrimitiveProcessor& primProc) override { 27 const GrPrimitiveProcessor& primProc) override {
27 const GrConicEffect& ce = primProc.cast<GrConicEffect>(); 28 const GrConicEffect& ce = primProc.cast<GrConicEffect>();
28 29
29 if (!ce.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(ce.viewMa trix())) { 30 if (!ce.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(ce.viewMa trix())) {
30 fViewMatrix = ce.viewMatrix(); 31 fViewMatrix = ce.viewMatrix();
31 GrGLfloat viewMatrix[3 * 3]; 32 float viewMatrix[3 * 3];
32 GrGLGetMatrix<3>(viewMatrix, fViewMatrix); 33 GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
33 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); 34 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
34 } 35 }
35 36
36 if (ce.color() != fColor) { 37 if (ce.color() != fColor) {
37 GrGLfloat c[4]; 38 float c[4];
38 GrColorToRGBAFloat(ce.color(), c); 39 GrColorToRGBAFloat(ce.color(), c);
39 pdman.set4fv(fColorUniform, 1, c); 40 pdman.set4fv(fColorUniform, 1, c);
40 fColor = ce.color(); 41 fColor = ce.color();
41 } 42 }
42 43
43 if (ce.coverageScale() != 0xff && ce.coverageScale() != fCoverageScale) { 44 if (ce.coverageScale() != 0xff && ce.coverageScale() != fCoverageScale) {
44 pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(ce.coverag eScale())); 45 pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(ce.coverag eScale()));
45 fCoverageScale = ce.coverageScale(); 46 fCoverageScale = ce.coverageScale();
46 } 47 }
47 } 48 }
48 49
49 void setTransformData(const GrPrimitiveProcessor& primProc, 50 void setTransformData(const GrPrimitiveProcessor& primProc,
50 const GrGLProgramDataManager& pdman, 51 const GrGLSLProgramDataManager& pdman,
51 int index, 52 int index,
52 const SkTArray<const GrCoordTransform*, true>& transfo rms) override { 53 const SkTArray<const GrCoordTransform*, true>& transfo rms) override {
53 this->setTransformDataHelper<GrConicEffect>(primProc, pdman, index, tran sforms); 54 this->setTransformDataHelper<GrConicEffect>(primProc, pdman, index, tran sforms);
54 } 55 }
55 56
56 private: 57 private:
57 SkMatrix fViewMatrix; 58 SkMatrix fViewMatrix;
58 GrColor fColor; 59 GrColor fColor;
59 uint8_t fCoverageScale; 60 uint8_t fCoverageScale;
60 GrPrimitiveEdgeType fEdgeType; 61 GrPrimitiveEdgeType fEdgeType;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 class GrGLQuadEffect : public GrGLGeometryProcessor { 232 class GrGLQuadEffect : public GrGLGeometryProcessor {
232 public: 233 public:
233 GrGLQuadEffect(const GrGeometryProcessor&); 234 GrGLQuadEffect(const GrGeometryProcessor&);
234 235
235 void onEmitCode(EmitArgs&, GrGPArgs*) override; 236 void onEmitCode(EmitArgs&, GrGPArgs*) override;
236 237
237 static inline void GenKey(const GrGeometryProcessor&, 238 static inline void GenKey(const GrGeometryProcessor&,
238 const GrGLSLCaps&, 239 const GrGLSLCaps&,
239 GrProcessorKeyBuilder*); 240 GrProcessorKeyBuilder*);
240 241
241 void setData(const GrGLProgramDataManager& pdman, 242 void setData(const GrGLSLProgramDataManager& pdman,
242 const GrPrimitiveProcessor& primProc) override { 243 const GrPrimitiveProcessor& primProc) override {
243 const GrQuadEffect& qe = primProc.cast<GrQuadEffect>(); 244 const GrQuadEffect& qe = primProc.cast<GrQuadEffect>();
244 245
245 if (!qe.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(qe.viewMa trix())) { 246 if (!qe.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(qe.viewMa trix())) {
246 fViewMatrix = qe.viewMatrix(); 247 fViewMatrix = qe.viewMatrix();
247 GrGLfloat viewMatrix[3 * 3]; 248 float viewMatrix[3 * 3];
248 GrGLGetMatrix<3>(viewMatrix, fViewMatrix); 249 GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
249 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); 250 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
250 } 251 }
251 252
252 if (qe.color() != fColor) { 253 if (qe.color() != fColor) {
253 GrGLfloat c[4]; 254 float c[4];
254 GrColorToRGBAFloat(qe.color(), c); 255 GrColorToRGBAFloat(qe.color(), c);
255 pdman.set4fv(fColorUniform, 1, c); 256 pdman.set4fv(fColorUniform, 1, c);
256 fColor = qe.color(); 257 fColor = qe.color();
257 } 258 }
258 259
259 if (qe.coverageScale() != 0xff && qe.coverageScale() != fCoverageScale) { 260 if (qe.coverageScale() != 0xff && qe.coverageScale() != fCoverageScale) {
260 pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(qe.coverag eScale())); 261 pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(qe.coverag eScale()));
261 fCoverageScale = qe.coverageScale(); 262 fCoverageScale = qe.coverageScale();
262 } 263 }
263 } 264 }
264 265
265 void setTransformData(const GrPrimitiveProcessor& primProc, 266 void setTransformData(const GrPrimitiveProcessor& primProc,
266 const GrGLProgramDataManager& pdman, 267 const GrGLSLProgramDataManager& pdman,
267 int index, 268 int index,
268 const SkTArray<const GrCoordTransform*, true>& transfo rms) override { 269 const SkTArray<const GrCoordTransform*, true>& transfo rms) override {
269 this->setTransformDataHelper<GrQuadEffect>(primProc, pdman, index, trans forms); 270 this->setTransformDataHelper<GrQuadEffect>(primProc, pdman, index, trans forms);
270 } 271 }
271 272
272 private: 273 private:
273 SkMatrix fViewMatrix; 274 SkMatrix fViewMatrix;
274 GrColor fColor; 275 GrColor fColor;
275 uint8_t fCoverageScale; 276 uint8_t fCoverageScale;
276 GrPrimitiveEdgeType fEdgeType; 277 GrPrimitiveEdgeType fEdgeType;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 class GrGLCubicEffect : public GrGLGeometryProcessor { 434 class GrGLCubicEffect : public GrGLGeometryProcessor {
434 public: 435 public:
435 GrGLCubicEffect(const GrGeometryProcessor&); 436 GrGLCubicEffect(const GrGeometryProcessor&);
436 437
437 void onEmitCode(EmitArgs&, GrGPArgs*) override; 438 void onEmitCode(EmitArgs&, GrGPArgs*) override;
438 439
439 static inline void GenKey(const GrGeometryProcessor&, 440 static inline void GenKey(const GrGeometryProcessor&,
440 const GrGLSLCaps&, 441 const GrGLSLCaps&,
441 GrProcessorKeyBuilder*); 442 GrProcessorKeyBuilder*);
442 443
443 void setData(const GrGLProgramDataManager& pdman, 444 void setData(const GrGLSLProgramDataManager& pdman,
444 const GrPrimitiveProcessor& primProc) override { 445 const GrPrimitiveProcessor& primProc) override {
445 const GrCubicEffect& ce = primProc.cast<GrCubicEffect>(); 446 const GrCubicEffect& ce = primProc.cast<GrCubicEffect>();
446 447
447 if (!ce.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(ce.viewMa trix())) { 448 if (!ce.viewMatrix().isIdentity() && !fViewMatrix.cheapEqualTo(ce.viewMa trix())) {
448 fViewMatrix = ce.viewMatrix(); 449 fViewMatrix = ce.viewMatrix();
449 GrGLfloat viewMatrix[3 * 3]; 450 float viewMatrix[3 * 3];
450 GrGLGetMatrix<3>(viewMatrix, fViewMatrix); 451 GrGLGetMatrix<3>(viewMatrix, fViewMatrix);
451 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); 452 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix);
452 } 453 }
453 454
454 if (ce.color() != fColor) { 455 if (ce.color() != fColor) {
455 GrGLfloat c[4]; 456 float c[4];
456 GrColorToRGBAFloat(ce.color(), c); 457 GrColorToRGBAFloat(ce.color(), c);
457 pdman.set4fv(fColorUniform, 1, c); 458 pdman.set4fv(fColorUniform, 1, c);
458 fColor = ce.color(); 459 fColor = ce.color();
459 } 460 }
460 } 461 }
461 462
462 private: 463 private:
463 SkMatrix fViewMatrix; 464 SkMatrix fViewMatrix;
464 GrColor fColor; 465 GrColor fColor;
465 GrPrimitiveEdgeType fEdgeType; 466 GrPrimitiveEdgeType fEdgeType;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 do { 630 do {
630 GrPrimitiveEdgeType edgeType = 631 GrPrimitiveEdgeType edgeType =
631 static_cast<GrPrimitiveEdgeType>( 632 static_cast<GrPrimitiveEdgeType>(
632 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); 633 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt));
633 gp = GrCubicEffect::Create(GrRandomColor(d->fRandom), 634 gp = GrCubicEffect::Create(GrRandomColor(d->fRandom),
634 GrTest::TestMatrix(d->fRandom), edgeType, *d- >fCaps); 635 GrTest::TestMatrix(d->fRandom), edgeType, *d- >fCaps);
635 } while (nullptr == gp); 636 } while (nullptr == gp);
636 return gp; 637 return gp;
637 } 638 }
638 639
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAAConvexPathRenderer.cpp ('k') | src/gpu/effects/GrBicubicEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698