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

Side by Side Diff: src/gpu/batches/GrDrawPathBatch.cpp

Issue 1908433002: Batch multiple single NVPR draw paths to instanced draws Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address review comments Created 4 years, 8 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/batches/GrDrawPathBatch.h ('k') | src/gpu/gl/GrGLPath.h » ('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 2015 Google Inc. 2 * Copyright 2015 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 "GrDrawPathBatch.h" 8 #include "GrDrawPathBatch.h"
9 9
10 static void pre_translate_transform_values(const float* xforms, 10 static void pre_translate_transform_values(const float* xforms,
11 GrPathRendering::PathTransformType ty pe, int count, 11 GrPathRendering::PathTransformType ty pe, int count,
12 SkScalar x, SkScalar y, float* dst); 12 SkScalar x, SkScalar y, float* dst);
13 13
14 SkString GrDrawPathBatch::dumpInfo() const { 14 SkString GrDrawPathBatch::dumpInfo() const {
15 SkString string; 15 SkString string;
16 string.printf("PATH: 0x%p", fPath.get()); 16 string.printf("Color: 0x%08x Fill: %x Path count: %d Paths: ", this->color() , this->fillType(),
17 fTotalPathCount);
18 const GrDrawPathBatch* batch = this;
19 do {
20 string.appendf("0x%p", batch->fPath.get());
21 batch = batch->fNext.get();
22 } while (batch);
23 string.append("\n");
17 return string; 24 return string;
18 } 25 }
19 26
27 bool GrDrawPathBatch::ListBoundsIntersects(const GrDrawPathBatch* a, const GrDra wPathBatch* b) {
28 if (!SkRect::Intersects(a->fBounds, b->fBounds)) {
29 return false;
30 }
31 if (!a->fNext && !b->fNext) {
32 return true;
33 }
34 const GrDrawPathBatch* firstA = a;
35 do {
36 do {
37 if (SkRect::Intersects(a->fPathBounds, b->fPathBounds)) {
38 return true;
39 }
40 a = a->fNext.get();
41 } while (a);
42 a = firstA;
43 b = b->fNext.get();
44 } while (b);
45 return false;
46 }
47
48 bool GrDrawPathBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) {
49 GrDrawPathBatch* that = t->cast<GrDrawPathBatch>();
50 if (this->color() != that->color() ||
51 !this->viewMatrix().cheapEqualTo(that->viewMatrix())) {
52 return false;
53 }
54 if (!GrPipeline::AreEqual(*this->pipeline(), *that->pipeline(), false)) {
55 return false;
56 }
57 if (that->fillType() != this->fillType() ||
58 this->stencilSettings() != that->stencilSettings()) {
59 return false;
60 }
61 if (ListBoundsIntersects(this, that)) {
62 return false;
63 }
64 if (!fPath.get()->canCombineDrawPathBatchWith(*that->fPath.get())) {
65 return false;
66 }
67 SkASSERT(!*fLastSlot);
68 fLastSlot->reset(SkRef(that));
69 fLastSlot = that->fLastSlot;
70 fTotalPathCount += that->fTotalPathCount;
71 this->joinBounds(that->fBounds);
72 return true;
73 }
74
20 void GrDrawPathBatch::onDraw(GrBatchFlushState* state) { 75 void GrDrawPathBatch::onDraw(GrBatchFlushState* state) {
21 GrProgramDesc desc;
22
23 SkAutoTUnref<GrPathProcessor> pathProc(GrPathProcessor::Create(this->color() , 76 SkAutoTUnref<GrPathProcessor> pathProc(GrPathProcessor::Create(this->color() ,
24 this->overrid es(), 77 this->overrid es(),
25 this->viewMat rix())); 78 this->viewMat rix()));
26 state->gpu()->pathRendering()->drawPath(*this->pipeline(), *pathProc, this-> stencilSettings(), 79 if (fTotalPathCount > 1) {
27 fPath.get()); 80 SkAutoSTMalloc<32, const GrPath*> paths(fTotalPathCount);
81 GrDrawPathBatch* batch = this;
82 int i = 0;
83 do {
84 paths[i++] = batch->fPath.get();
85 batch = batch->fNext.get();
86 } while (batch);
87 state->gpu()->pathRendering()->drawPaths(*this->pipeline(), *pathProc,
88 this->stencilSettings(), paths, fTotalPathCount);
89 } else {
90 const GrPath* path = fPath.get();
91 state->gpu()->pathRendering()->drawPaths(*this->pipeline(), *pathProc,
92 this->stencilSettings(), &path, 1);
93 }
28 } 94 }
29 95
30 SkString GrDrawPathRangeBatch::dumpInfo() const { 96 SkString GrDrawPathRangeBatch::dumpInfo() const {
31 SkString string; 97 SkString string;
32 string.printf("RANGE: 0x%p COUNTS: [", fPathRange.get()); 98 string.printf("RANGE: 0x%p COUNTS: [", fPathRange.get());
33 for (DrawList::Iter iter(fDraws); iter.get(); iter.next()) { 99 for (DrawList::Iter iter(fDraws); iter.get(); iter.next()) {
34 string.appendf("%d, ", iter.get()->fInstanceData->count()); 100 string.appendf("%d, ", iter.get()->fInstanceData->count());
35 } 101 }
36 string.remove(string.size() - 2, 2); 102 string.remove(string.size() - 2, 2);
37 string.append("]"); 103 string.append("]");
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 dst[i + 3] = xforms[i + 3]; 268 dst[i + 3] = xforms[i + 3];
203 dst[i + 4] = xforms[i + 4]; 269 dst[i + 4] = xforms[i + 4];
204 dst[i + 5] = xforms[i + 3] * x + xforms[i + 4] * y + xforms[i + 5]; 270 dst[i + 5] = xforms[i + 3] * x + xforms[i + 4] * y + xforms[i + 5];
205 } 271 }
206 break; 272 break;
207 default: 273 default:
208 SkFAIL("Unknown transform type."); 274 SkFAIL("Unknown transform type.");
209 break; 275 break;
210 } 276 }
211 } 277 }
OLDNEW
« no previous file with comments | « src/gpu/batches/GrDrawPathBatch.h ('k') | src/gpu/gl/GrGLPath.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698