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

Side by Side Diff: gm/beziereffects.cpp

Issue 783763002: Initial CL to move color / coverage off of drawstate (Closed) Base URL: https://skia.googlesource.com/skia.git@no-static-gp
Patch Set: bug fix Created 6 years 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 | « no previous file | gm/convexpolyeffect.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 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 }; 85 };
86 for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType ) { 86 for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType ) {
87 SkAutoTUnref<GrGeometryProcessor> gp; 87 SkAutoTUnref<GrGeometryProcessor> gp;
88 { // scope to contain GrTestTarget 88 { // scope to contain GrTestTarget
89 GrTestTarget tt; 89 GrTestTarget tt;
90 context->getTestTarget(&tt); 90 context->getTestTarget(&tt);
91 if (NULL == tt.target()) { 91 if (NULL == tt.target()) {
92 continue; 92 continue;
93 } 93 }
94 GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType; 94 GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType;
95 gp.reset(GrCubicEffect::Create(et, *tt.target()->caps())); 95 gp.reset(GrCubicEffect::Create(0xff000000, et, *tt.target()- >caps()));
96 if (!gp) { 96 if (!gp) {
97 continue; 97 continue;
98 } 98 }
99 } 99 }
100 100
101 SkScalar x = SkScalarMul(col, w); 101 SkScalar x = SkScalarMul(col, w);
102 SkScalar y = SkScalarMul(row, h); 102 SkScalar y = SkScalarMul(row, h);
103 SkPoint controlPts[] = { 103 SkPoint controlPts[] = {
104 {x + baseControlPts[0].fX, y + baseControlPts[0].fY}, 104 {x + baseControlPts[0].fX, y + baseControlPts[0].fY},
105 {x + baseControlPts[1].fX, y + baseControlPts[1].fY}, 105 {x + baseControlPts[1].fX, y + baseControlPts[1].fY},
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 bounds.fRight, bounds.fBottom, 159 bounds.fRight, bounds.fBottom,
160 sizeof(Vertex)); 160 sizeof(Vertex));
161 for (int v = 0; v < 4; ++v) { 161 for (int v = 0; v < 4; ++v) {
162 verts[v].fKLM[0] = eval_line(verts[v].fPosition, klmEqs + 0, klmSigns[c]); 162 verts[v].fKLM[0] = eval_line(verts[v].fPosition, klmEqs + 0, klmSigns[c]);
163 verts[v].fKLM[1] = eval_line(verts[v].fPosition, klmEqs + 3, klmSigns[c]); 163 verts[v].fKLM[1] = eval_line(verts[v].fPosition, klmEqs + 3, klmSigns[c]);
164 verts[v].fKLM[2] = eval_line(verts[v].fPosition, klmEqs + 6, 1.f); 164 verts[v].fKLM[2] = eval_line(verts[v].fPosition, klmEqs + 6, 1.f);
165 } 165 }
166 166
167 ds.setGeometryProcessor(gp); 167 ds.setGeometryProcessor(gp);
168 ds.setRenderTarget(rt); 168 ds.setRenderTarget(rt);
169 ds.setColor(0xff000000);
170 169
171 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuf fer()); 170 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuf fer());
172 tt.target()->drawIndexed(&ds, kTriangleFan_GrPrimitiveType, 0, 0, 4, 6); 171 tt.target()->drawIndexed(&ds, kTriangleFan_GrPrimitiveType, 0, 0, 4, 6);
173 } 172 }
174 ++col; 173 ++col;
175 if (numCols == col) { 174 if (numCols == col) {
176 col = 0; 175 col = 0;
177 ++row; 176 ++row;
178 } 177 }
179 } 178 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 SkScalar weight = rand.nextRangeF(0.f, 2.f); 244 SkScalar weight = rand.nextRangeF(0.f, 2.f);
246 for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType ) { 245 for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType ) {
247 SkAutoTUnref<GrGeometryProcessor> gp; 246 SkAutoTUnref<GrGeometryProcessor> gp;
248 { // scope to contain GrTestTarget 247 { // scope to contain GrTestTarget
249 GrTestTarget tt; 248 GrTestTarget tt;
250 context->getTestTarget(&tt); 249 context->getTestTarget(&tt);
251 if (NULL == tt.target()) { 250 if (NULL == tt.target()) {
252 continue; 251 continue;
253 } 252 }
254 GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType; 253 GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType;
255 gp.reset(GrConicEffect::Create(et, *tt.target()->caps())); 254 gp.reset(GrConicEffect::Create(0xff000000, et, *tt.target()- >caps()));
256 if (!gp) { 255 if (!gp) {
257 continue; 256 continue;
258 } 257 }
259 } 258 }
260 259
261 SkScalar x = SkScalarMul(col, w); 260 SkScalar x = SkScalarMul(col, w);
262 SkScalar y = SkScalarMul(row, h); 261 SkScalar y = SkScalarMul(row, h);
263 SkPoint controlPts[] = { 262 SkPoint controlPts[] = {
264 {x + baseControlPts[0].fX, y + baseControlPts[0].fY}, 263 {x + baseControlPts[0].fX, y + baseControlPts[0].fY},
265 {x + baseControlPts[1].fX, y + baseControlPts[1].fY}, 264 {x + baseControlPts[1].fX, y + baseControlPts[1].fY},
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 bounds.fRight, bounds.fBottom, 315 bounds.fRight, bounds.fBottom,
317 sizeof(Vertex)); 316 sizeof(Vertex));
318 for (int v = 0; v < 4; ++v) { 317 for (int v = 0; v < 4; ++v) {
319 verts[v].fKLM[0] = eval_line(verts[v].fPosition, klmEqs + 0, 1.f); 318 verts[v].fKLM[0] = eval_line(verts[v].fPosition, klmEqs + 0, 1.f);
320 verts[v].fKLM[1] = eval_line(verts[v].fPosition, klmEqs + 3, 1.f); 319 verts[v].fKLM[1] = eval_line(verts[v].fPosition, klmEqs + 3, 1.f);
321 verts[v].fKLM[2] = eval_line(verts[v].fPosition, klmEqs + 6, 1.f); 320 verts[v].fKLM[2] = eval_line(verts[v].fPosition, klmEqs + 6, 1.f);
322 } 321 }
323 322
324 ds.setGeometryProcessor(gp); 323 ds.setGeometryProcessor(gp);
325 ds.setRenderTarget(rt); 324 ds.setRenderTarget(rt);
326 ds.setColor(0xff000000);
327 325
328 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuf fer()); 326 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuf fer());
329 tt.target()->drawIndexed(&ds, kTriangleFan_GrPrimitiveType, 0, 0, 4, 6); 327 tt.target()->drawIndexed(&ds, kTriangleFan_GrPrimitiveType, 0, 0, 4, 6);
330 } 328 }
331 ++col; 329 ++col;
332 if (numCols == col) { 330 if (numCols == col) {
333 col = 0; 331 col = 0;
334 ++row; 332 ++row;
335 } 333 }
336 } 334 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 }; 434 };
437 for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType ) { 435 for(int edgeType = 0; edgeType < kGrProcessorEdgeTypeCnt; ++edgeType ) {
438 SkAutoTUnref<GrGeometryProcessor> gp; 436 SkAutoTUnref<GrGeometryProcessor> gp;
439 { // scope to contain GrTestTarget 437 { // scope to contain GrTestTarget
440 GrTestTarget tt; 438 GrTestTarget tt;
441 context->getTestTarget(&tt); 439 context->getTestTarget(&tt);
442 if (NULL == tt.target()) { 440 if (NULL == tt.target()) {
443 continue; 441 continue;
444 } 442 }
445 GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType; 443 GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)edgeType;
446 gp.reset(GrQuadEffect::Create(et, *tt.target()->caps())); 444 gp.reset(GrQuadEffect::Create(0xff000000, et, *tt.target()-> caps()));
447 if (!gp) { 445 if (!gp) {
448 continue; 446 continue;
449 } 447 }
450 } 448 }
451 449
452 SkScalar x = SkScalarMul(col, w); 450 SkScalar x = SkScalarMul(col, w);
453 SkScalar y = SkScalarMul(row, h); 451 SkScalar y = SkScalarMul(row, h);
454 SkPoint controlPts[] = { 452 SkPoint controlPts[] = {
455 {x + baseControlPts[0].fX, y + baseControlPts[0].fY}, 453 {x + baseControlPts[0].fX, y + baseControlPts[0].fY},
456 {x + baseControlPts[1].fX, y + baseControlPts[1].fY}, 454 {x + baseControlPts[1].fX, y + baseControlPts[1].fY},
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 500
503 verts[0].fPosition.setRectFan(bounds.fLeft, bounds.fTop, 501 verts[0].fPosition.setRectFan(bounds.fLeft, bounds.fTop,
504 bounds.fRight, bounds.fBottom, 502 bounds.fRight, bounds.fBottom,
505 sizeof(Vertex)); 503 sizeof(Vertex));
506 504
507 GrPathUtils::QuadUVMatrix DevToUV(pts); 505 GrPathUtils::QuadUVMatrix DevToUV(pts);
508 DevToUV.apply<4, sizeof(Vertex), sizeof(SkPoint)>(verts); 506 DevToUV.apply<4, sizeof(Vertex), sizeof(SkPoint)>(verts);
509 507
510 ds.setGeometryProcessor(gp); 508 ds.setGeometryProcessor(gp);
511 ds.setRenderTarget(rt); 509 ds.setRenderTarget(rt);
512 ds.setColor(0xff000000);
513 510
514 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuf fer()); 511 tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuf fer());
515 tt.target()->drawIndexed(&ds, kTriangles_GrPrimitiveType, 0, 0, 4, 6); 512 tt.target()->drawIndexed(&ds, kTriangles_GrPrimitiveType, 0, 0, 4, 6);
516 } 513 }
517 ++col; 514 ++col;
518 if (numCols == col) { 515 if (numCols == col) {
519 col = 0; 516 col = 0;
520 ++row; 517 ++row;
521 } 518 }
522 } 519 }
523 } 520 }
524 } 521 }
525 522
526 private: 523 private:
527 typedef GM INHERITED; 524 typedef GM INHERITED;
528 }; 525 };
529 526
530 DEF_GM( return SkNEW(BezierCubicEffects); ) 527 DEF_GM( return SkNEW(BezierCubicEffects); )
531 DEF_GM( return SkNEW(BezierConicEffects); ) 528 DEF_GM( return SkNEW(BezierConicEffects); )
532 DEF_GM( return SkNEW(BezierQuadEffects); ) 529 DEF_GM( return SkNEW(BezierQuadEffects); )
533 530
534 } 531 }
535 532
536 #endif 533 #endif
OLDNEW
« no previous file with comments | « no previous file | gm/convexpolyeffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698