| OLD | NEW |
| 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 "GrReorderCommandBuilder.h" | 8 #include "GrReorderCommandBuilder.h" |
| 9 | 9 |
| 10 template <class Left, class Right> | 10 template <class Left, class Right> |
| 11 static bool intersect(const Left& a, const Right& b) { | 11 static bool intersect(const Left& a, const Right& b) { |
| 12 SkASSERT(a.fLeft <= a.fRight && a.fTop <= a.fBottom && | 12 SkASSERT(a.fLeft <= a.fRight && a.fTop <= a.fBottom && |
| 13 b.fLeft <= b.fRight && b.fTop <= b.fBottom); | 13 b.fLeft <= b.fRight && b.fTop <= b.fBottom); |
| 14 return a.fLeft < b.fRight && b.fLeft < a.fRight && | 14 return a.fLeft < b.fRight && b.fLeft < a.fRight && |
| 15 a.fTop < b.fBottom && b.fTop < a.fBottom; | 15 a.fTop < b.fBottom && b.fTop < a.fBottom; |
| 16 } | 16 } |
| 17 | 17 |
| 18 GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(GrBatch* batch, | 18 GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(GrDrawBatch* bat
ch, |
| 19 const GrCaps& ca
ps) { | 19 const GrCaps& ca
ps) { |
| 20 // Check if there is a Batch Draw we can batch with by linearly searching ba
ck until we either | 20 // Check if there is a Batch Draw we can batch with by linearly searching ba
ck until we either |
| 21 // 1) check every draw | 21 // 1) check every draw |
| 22 // 2) intersect with something | 22 // 2) intersect with something |
| 23 // 3) find a 'blocker' | 23 // 3) find a 'blocker' |
| 24 // Experimentally we have found that most batching occurs within the first 1
0 comparisons. | 24 // Experimentally we have found that most batching occurs within the first 1
0 comparisons. |
| 25 static const int kMaxLookback = 10; | 25 static const int kMaxLookback = 10; |
| 26 int i = 0; | 26 int i = 0; |
| 27 | 27 |
| 28 GrRenderTarget* rt = batch->pipeline()->getRenderTarget(); | 28 GrRenderTarget* rt = batch->pipeline()->getRenderTarget(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 #endif | 100 #endif |
| 101 } | 101 } |
| 102 #if GR_BATCH_SPEW | 102 #if GR_BATCH_SPEW |
| 103 else { | 103 else { |
| 104 GrBATCH_INFO("\t\tBreaking because empty command buffer\n"); | 104 GrBATCH_INFO("\t\tBreaking because empty command buffer\n"); |
| 105 } | 105 } |
| 106 #endif | 106 #endif |
| 107 | 107 |
| 108 return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (batch, this-
>batchTarget())); | 108 return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (batch, this-
>batchTarget())); |
| 109 } | 109 } |
| OLD | NEW |