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

Side by Side Diff: src/gpu/GrAuditTrail.cpp

Issue 1753753002: Move some GrAuditTrail fuctions to cpp file (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 9 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 | « include/private/GrAuditTrail.h ('k') | no next file » | 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 2016 Google Inc. 2 * Copyright 2016 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 "GrAuditTrail.h" 8 #include "GrAuditTrail.h"
9 #include "batches/GrBatch.h" 9 #include "batches/GrBatch.h"
10 10
11 const int GrAuditTrail::kGrAuditTrailInvalidID = -1; 11 const int GrAuditTrail::kGrAuditTrailInvalidID = -1;
12 12
13 void GrAuditTrail::addBatch(const char* name, const SkRect& bounds) {
14 SkASSERT(fEnabled);
15 Batch* batch = new Batch;
16 fBatchPool.emplace_back(batch);
17 batch->fName = name;
18 batch->fBounds = bounds;
19 batch->fClientID = kGrAuditTrailInvalidID;
20 batch->fBatchListID = kGrAuditTrailInvalidID;
21 batch->fChildID = kGrAuditTrailInvalidID;
22 fCurrentBatch = batch;
23
24 if (fClientID != kGrAuditTrailInvalidID) {
25 batch->fClientID = fClientID;
26 Batches** batchesLookup = fClientIDLookup.find(fClientID);
27 Batches* batches = nullptr;
28 if (!batchesLookup) {
29 batches = new Batches;
30 fClientIDLookup.set(fClientID, batches);
31 } else {
32 batches = *batchesLookup;
33 }
34
35 batches->push_back(fCurrentBatch);
36 }
37 }
38
13 void GrAuditTrail::batchingResultCombined(GrBatch* combiner) { 39 void GrAuditTrail::batchingResultCombined(GrBatch* combiner) {
14 int* indexPtr = fIDLookup.find(combiner); 40 int* indexPtr = fIDLookup.find(combiner);
15 SkASSERT(indexPtr); 41 SkASSERT(indexPtr);
16 int index = *indexPtr; 42 int index = *indexPtr;
17 SkASSERT(index < fBatchList.count()); 43 SkASSERT(index < fBatchList.count());
18 BatchNode& batch = *fBatchList[index]; 44 BatchNode& batch = *fBatchList[index];
19 45
20 // set the ids for the child batch 46 // set the ids for the child batch
21 fCurrentBatch->fBatchListID = index; 47 fCurrentBatch->fBatchListID = index;
22 fCurrentBatch->fChildID = batch.fChildren.count(); 48 fCurrentBatch->fChildID = batch.fChildren.count();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 BatchInfo::Batch& outBatch = outBatchInfo.fBatches.push_back (); 94 BatchInfo::Batch& outBatch = outBatchInfo.fBatches.push_back ();
69 const Batch* currentBatch = bn->fChildren[j]; 95 const Batch* currentBatch = bn->fChildren[j];
70 outBatch.fBounds = currentBatch->fBounds; 96 outBatch.fBounds = currentBatch->fBounds;
71 outBatch.fClientID = currentBatch->fClientID; 97 outBatch.fClientID = currentBatch->fClientID;
72 } 98 }
73 } 99 }
74 } 100 }
75 } 101 }
76 } 102 }
77 103
104 void GrAuditTrail::fullReset() {
105 SkASSERT(fEnabled);
106 fBatchList.reset();
107 fIDLookup.reset();
108 // free all client batches
109 fClientIDLookup.foreach([](const int&, Batches** batches) { delete *batches; });
110 fClientIDLookup.reset();
111 fBatchPool.reset(); // must be last, frees all of the memory
112 }
78 113
79 template <typename T> 114 template <typename T>
80 void GrAuditTrail::JsonifyTArray(SkString* json, const char* name, const T& arra y, 115 void GrAuditTrail::JsonifyTArray(SkString* json, const char* name, const T& arra y,
81 bool addComma) { 116 bool addComma) {
82 if (array.count()) { 117 if (array.count()) {
83 if (addComma) { 118 if (addComma) {
84 json->appendf(","); 119 json->appendf(",");
85 } 120 }
86 json->appendf("\"%s\": [", name); 121 json->appendf("\"%s\": [", name);
87 for (int i = 0; i < array.count(); i++) { 122 for (int i = 0; i < array.count(); i++) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 248
214 SkString GrAuditTrail::BatchNode::toJson() const { 249 SkString GrAuditTrail::BatchNode::toJson() const {
215 SkString json; 250 SkString json;
216 json.append("{"); 251 json.append("{");
217 json.appendf("\"RenderTarget\": \"%u\",", fRenderTargetUniqueID); 252 json.appendf("\"RenderTarget\": \"%u\",", fRenderTargetUniqueID);
218 skrect_to_json(&json, "Bounds", fBounds); 253 skrect_to_json(&json, "Bounds", fBounds);
219 JsonifyTArray(&json, "Batches", fChildren, true); 254 JsonifyTArray(&json, "Batches", fChildren, true);
220 json.append("}"); 255 json.append("}");
221 return json; 256 return json;
222 } 257 }
OLDNEW
« no previous file with comments | « include/private/GrAuditTrail.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698