| OLD | NEW |
| 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 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 void GrAuditTrail::batchingResultNew(GrBatch* batch) { | 29 void GrAuditTrail::batchingResultNew(GrBatch* batch) { |
| 30 // Our algorithm doesn't bother to reorder inside of a BatchNode | 30 // Our algorithm doesn't bother to reorder inside of a BatchNode |
| 31 // so the ChildID will start at 0 | 31 // so the ChildID will start at 0 |
| 32 fCurrentBatch->fBatchListID = fBatchList.count(); | 32 fCurrentBatch->fBatchListID = fBatchList.count(); |
| 33 fCurrentBatch->fChildID = 0; | 33 fCurrentBatch->fChildID = 0; |
| 34 | 34 |
| 35 // We use the batch pointer as a key to find the batchnode we are 'glomming'
batches onto | 35 // We use the batch pointer as a key to find the batchnode we are 'glomming'
batches onto |
| 36 fIDLookup.set(batch, fCurrentBatch->fBatchListID); | 36 fIDLookup.set(batch, fCurrentBatch->fBatchListID); |
| 37 BatchNode* batchNode = new BatchNode; | 37 BatchNode* batchNode = new BatchNode; |
| 38 batchNode->fBounds = fCurrentBatch->fBounds; | 38 batchNode->fBounds = fCurrentBatch->fBounds; |
| 39 batchNode->fRenderTargetUniqueID = batch->renderTargetUniqueID(); |
| 39 batchNode->fChildren.push_back(fCurrentBatch); | 40 batchNode->fChildren.push_back(fCurrentBatch); |
| 40 fBatchList.emplace_back(batchNode); | 41 fBatchList.emplace_back(batchNode); |
| 41 } | 42 } |
| 42 | 43 |
| 43 void GrAuditTrail::getBoundsByClientID(SkTArray<BatchInfo>* outInfo, int clientI
D) { | 44 void GrAuditTrail::getBoundsByClientID(SkTArray<BatchInfo>* outInfo, int clientI
D) { |
| 44 Batches** batchesLookup = fClientIDLookup.find(clientID); | 45 Batches** batchesLookup = fClientIDLookup.find(clientID); |
| 45 if (batchesLookup) { | 46 if (batchesLookup) { |
| 46 // We track which batchlistID we're currently looking at. If it changes
, then we | 47 // We track which batchlistID we're currently looking at. If it changes
, then we |
| 47 // need to push back a new batch info struct. We happen to know that ba
tches are | 48 // need to push back a new batch info struct. We happen to know that ba
tches are |
| 48 // in sequential order in the batchlist, otherwise we'd have to do more
bookkeeping | 49 // in sequential order in the batchlist, otherwise we'd have to do more
bookkeeping |
| 49 int currentBatchListID = kGrAuditTrailInvalidID; | 50 int currentBatchListID = kGrAuditTrailInvalidID; |
| 50 for (int i = 0; i < (*batchesLookup)->count(); i++) { | 51 for (int i = 0; i < (*batchesLookup)->count(); i++) { |
| 51 const Batch* batch = (**batchesLookup)[i]; | 52 const Batch* batch = (**batchesLookup)[i]; |
| 52 | 53 |
| 53 // Because we will copy out all of the batches associated with a giv
en | 54 // Because we will copy out all of the batches associated with a giv
en |
| 54 // batch list id everytime the id changes, we only have to update ou
r struct | 55 // batch list id everytime the id changes, we only have to update ou
r struct |
| 55 // when the id changes. | 56 // when the id changes. |
| 56 if (kGrAuditTrailInvalidID == currentBatchListID || | 57 if (kGrAuditTrailInvalidID == currentBatchListID || |
| 57 batch->fBatchListID != currentBatchListID) { | 58 batch->fBatchListID != currentBatchListID) { |
| 58 BatchInfo& outBatchInfo = outInfo->push_back(); | 59 BatchInfo& outBatchInfo = outInfo->push_back(); |
| 59 currentBatchListID = batch->fBatchListID; | 60 currentBatchListID = batch->fBatchListID; |
| 60 | 61 |
| 61 // copy out all of the batches so the client can display them ev
en if | 62 // copy out all of the batches so the client can display them ev
en if |
| 62 // they have a different clientID | 63 // they have a different clientID |
| 63 const BatchNode* bn = fBatchList[currentBatchListID]; | 64 const BatchNode* bn = fBatchList[currentBatchListID]; |
| 64 outBatchInfo.fBounds = bn->fBounds; | 65 outBatchInfo.fBounds = bn->fBounds; |
| 66 outBatchInfo.fRenderTargetUniqueID = bn->fRenderTargetUniqueID; |
| 65 for (int j = 0; j < bn->fChildren.count(); j++) { | 67 for (int j = 0; j < bn->fChildren.count(); j++) { |
| 66 BatchInfo::Batch& outBatch = outBatchInfo.fBatches.push_back
(); | 68 BatchInfo::Batch& outBatch = outBatchInfo.fBatches.push_back
(); |
| 67 const Batch* currentBatch = bn->fChildren[j]; | 69 const Batch* currentBatch = bn->fChildren[j]; |
| 68 outBatch.fBounds = currentBatch->fBounds; | 70 outBatch.fBounds = currentBatch->fBounds; |
| 69 outBatch.fClientID = currentBatch->fClientID; | 71 outBatch.fClientID = currentBatch->fClientID; |
| 70 } | 72 } |
| 71 } | 73 } |
| 72 } | 74 } |
| 73 } | 75 } |
| 74 } | 76 } |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 json.appendf("\"BatchListID\": \"%d\",", fBatchListID); | 207 json.appendf("\"BatchListID\": \"%d\",", fBatchListID); |
| 206 json.appendf("\"ChildID\": \"%d\",", fChildID); | 208 json.appendf("\"ChildID\": \"%d\",", fChildID); |
| 207 skrect_to_json(&json, "Bounds", fBounds); | 209 skrect_to_json(&json, "Bounds", fBounds); |
| 208 json.append("}"); | 210 json.append("}"); |
| 209 return json; | 211 return json; |
| 210 } | 212 } |
| 211 | 213 |
| 212 SkString GrAuditTrail::BatchNode::toJson() const { | 214 SkString GrAuditTrail::BatchNode::toJson() const { |
| 213 SkString json; | 215 SkString json; |
| 214 json.append("{"); | 216 json.append("{"); |
| 217 json.appendf("\"RenderTarget\": \"%u\",", fRenderTargetUniqueID); |
| 215 skrect_to_json(&json, "Bounds", fBounds); | 218 skrect_to_json(&json, "Bounds", fBounds); |
| 216 JsonifyTArray(&json, "Batches", fChildren, true); | 219 JsonifyTArray(&json, "Batches", fChildren, true); |
| 217 json.append("}"); | 220 json.append("}"); |
| 218 return json; | 221 return json; |
| 219 } | 222 } |
| OLD | NEW |