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

Side by Side Diff: gm/beziereffects.cpp

Issue 1286043004: Make GrVertexBatch objects hold their own draws during GrDrawTarget flush (Closed) Base URL: https://skia.googlesource.com/skia.git@m
Patch Set: forward decl Created 5 years, 4 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 | « 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
11 #include "gm.h" 11 #include "gm.h"
12 12
13 #if SK_SUPPORT_GPU 13 #if SK_SUPPORT_GPU
14 14
15 #include "GrBatchTarget.h" 15 #include "GrBatchFlushState.h"
16 #include "GrContext.h" 16 #include "GrContext.h"
17 #include "GrPathUtils.h" 17 #include "GrPathUtils.h"
18 #include "GrTest.h" 18 #include "GrTest.h"
19 #include "SkColorPriv.h" 19 #include "SkColorPriv.h"
20 #include "SkDevice.h" 20 #include "SkDevice.h"
21 #include "SkGeometry.h" 21 #include "SkGeometry.h"
22 22
23 #include "batches/GrTestBatch.h" 23 #include "batches/GrTestBatch.h"
24 24
25 #include "effects/GrBezierEffect.h" 25 #include "effects/GrBezierEffect.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 Geometry* geoData(int index) override { 64 Geometry* geoData(int index) override {
65 SkASSERT(0 == index); 65 SkASSERT(0 == index);
66 return &fGeometry; 66 return &fGeometry;
67 } 67 }
68 68
69 const Geometry* geoData(int index) const override { 69 const Geometry* geoData(int index) const override {
70 SkASSERT(0 == index); 70 SkASSERT(0 == index);
71 return &fGeometry; 71 return &fGeometry;
72 } 72 }
73 73
74 void onGenerateGeometry(GrBatchTarget* batchTarget) override { 74 void generateGeometry(Target* target) override {
75 QuadHelper helper; 75 QuadHelper helper;
76 size_t vertexStride = this->geometryProcessor()->getVertexStride(); 76 size_t vertexStride = this->geometryProcessor()->getVertexStride();
77 SkASSERT(vertexStride == sizeof(Vertex)); 77 SkASSERT(vertexStride == sizeof(Vertex));
78 Vertex* verts = reinterpret_cast<Vertex*>(helper.init(batchTarget, verte xStride, 1)); 78 Vertex* verts = reinterpret_cast<Vertex*>(helper.init(target, vertexStri de, 1));
79 if (!verts) { 79 if (!verts) {
80 return; 80 return;
81 } 81 }
82 82
83 verts[0].fPosition.setRectFan(fGeometry.fBounds.fLeft, fGeometry.fBounds .fTop, 83 verts[0].fPosition.setRectFan(fGeometry.fBounds.fLeft, fGeometry.fBounds .fTop,
84 fGeometry.fBounds.fRight, fGeometry.fBound s.fBottom, 84 fGeometry.fBounds.fRight, fGeometry.fBound s.fBottom,
85 sizeof(Vertex)); 85 sizeof(Vertex));
86 for (int v = 0; v < 4; ++v) { 86 for (int v = 0; v < 4; ++v) {
87 verts[v].fKLM[0] = eval_line(verts[v].fPosition, fKlmEqs + 0, fSign) ; 87 verts[v].fKLM[0] = eval_line(verts[v].fPosition, fKlmEqs + 0, fSign) ;
88 verts[v].fKLM[1] = eval_line(verts[v].fPosition, fKlmEqs + 3, fSign) ; 88 verts[v].fKLM[1] = eval_line(verts[v].fPosition, fKlmEqs + 3, fSign) ;
89 verts[v].fKLM[2] = eval_line(verts[v].fPosition, fKlmEqs + 6, 1.f); 89 verts[v].fKLM[2] = eval_line(verts[v].fPosition, fKlmEqs + 6, 1.f);
90 } 90 }
91 helper.issueDraw(batchTarget); 91 helper.recordDraw(target);
92 } 92 }
93 93
94 Geometry fGeometry; 94 Geometry fGeometry;
95 SkScalar fKlmEqs[9]; 95 SkScalar fKlmEqs[9];
96 SkScalar fSign; 96 SkScalar fSign;
97 97
98 static const int kVertsPerCubic = 4; 98 static const int kVertsPerCubic = 4;
99 static const int kIndicesPerCubic = 6; 99 static const int kIndicesPerCubic = 6;
100 100
101 typedef GrTestBatch INHERITED; 101 typedef GrTestBatch INHERITED;
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 Geometry* geoData(int index) override { 460 Geometry* geoData(int index) override {
461 SkASSERT(0 == index); 461 SkASSERT(0 == index);
462 return &fGeometry; 462 return &fGeometry;
463 } 463 }
464 464
465 const Geometry* geoData(int index) const override { 465 const Geometry* geoData(int index) const override {
466 SkASSERT(0 == index); 466 SkASSERT(0 == index);
467 return &fGeometry; 467 return &fGeometry;
468 } 468 }
469 469
470 void onGenerateGeometry(GrBatchTarget* batchTarget) override { 470 void generateGeometry(Target* target) override {
471 QuadHelper helper; 471 QuadHelper helper;
472 size_t vertexStride = this->geometryProcessor()->getVertexStride(); 472 size_t vertexStride = this->geometryProcessor()->getVertexStride();
473 SkASSERT(vertexStride == sizeof(Vertex)); 473 SkASSERT(vertexStride == sizeof(Vertex));
474 Vertex* verts = reinterpret_cast<Vertex*>(helper.init(batchTarget, verte xStride, 1)); 474 Vertex* verts = reinterpret_cast<Vertex*>(helper.init(target, vertexStri de, 1));
475 if (!verts) { 475 if (!verts) {
476 return; 476 return;
477 } 477 }
478 verts[0].fPosition.setRectFan(fGeometry.fBounds.fLeft, fGeometry.fBounds .fTop, 478 verts[0].fPosition.setRectFan(fGeometry.fBounds.fLeft, fGeometry.fBounds .fTop,
479 fGeometry.fBounds.fRight, fGeometry.fBound s.fBottom, 479 fGeometry.fBounds.fRight, fGeometry.fBound s.fBottom,
480 sizeof(Vertex)); 480 sizeof(Vertex));
481 fDevToUV.apply<4, sizeof(Vertex), sizeof(SkPoint)>(verts); 481 fDevToUV.apply<4, sizeof(Vertex), sizeof(SkPoint)>(verts);
482 helper.issueDraw(batchTarget); 482 helper.recordDraw(target);
483 } 483 }
484 484
485 Geometry fGeometry; 485 Geometry fGeometry;
486 GrPathUtils::QuadUVMatrix fDevToUV; 486 GrPathUtils::QuadUVMatrix fDevToUV;
487 487
488 static const int kVertsPerCubic = 4; 488 static const int kVertsPerCubic = 4;
489 static const int kIndicesPerCubic = 6; 489 static const int kIndicesPerCubic = 6;
490 490
491 typedef GrTestBatch INHERITED; 491 typedef GrTestBatch INHERITED;
492 }; 492 };
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 typedef GM INHERITED; 631 typedef GM INHERITED;
632 }; 632 };
633 633
634 DEF_GM( return SkNEW(BezierCubicEffects); ) 634 DEF_GM( return SkNEW(BezierCubicEffects); )
635 DEF_GM( return SkNEW(BezierConicEffects); ) 635 DEF_GM( return SkNEW(BezierConicEffects); )
636 DEF_GM( return SkNEW(BezierQuadEffects); ) 636 DEF_GM( return SkNEW(BezierQuadEffects); )
637 637
638 } 638 }
639 639
640 #endif 640 #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