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> |
(...skipping 14 matching lines...) Expand all Loading... |
25 int i = 0; | 25 int i = 0; |
26 batch->setPipeline(state->getPipeline()); | 26 batch->setPipeline(state->getPipeline()); |
27 GrRenderTarget* rt = state->getPipeline()->getRenderTarget(); | 27 GrRenderTarget* rt = state->getPipeline()->getRenderTarget(); |
28 if (!this->cmdBuffer()->empty()) { | 28 if (!this->cmdBuffer()->empty()) { |
29 GrTargetCommands::CmdBuffer::ReverseIter reverseIter(*this->cmdBuffer())
; | 29 GrTargetCommands::CmdBuffer::ReverseIter reverseIter(*this->cmdBuffer())
; |
30 | 30 |
31 do { | 31 do { |
32 if (Cmd::kDrawBatch_CmdType == reverseIter->type()) { | 32 if (Cmd::kDrawBatch_CmdType == reverseIter->type()) { |
33 DrawBatch* previous = static_cast<DrawBatch*>(reverseIter.get())
; | 33 DrawBatch* previous = static_cast<DrawBatch*>(reverseIter.get())
; |
34 | 34 |
35 // We cannot continue to search backwards if the render target c
hanges | |
36 if (previous->fBatch->pipeline()->getRenderTarget() != rt) { | 35 if (previous->fBatch->pipeline()->getRenderTarget() != rt) { |
37 break; | 36 break; |
38 } | 37 } |
39 | 38 // We cannot continue to search backwards if the render target c
hanges |
40 if (previous->fBatch->combineIfPossible(batch)) { | 39 if (previous->fBatch->combineIfPossible(batch)) { |
41 return NULL; | 40 return NULL; |
42 } | 41 } |
43 | 42 |
44 if (intersect(previous->fBatch->bounds(), batch->bounds())) { | 43 if (intersect(previous->fBatch->bounds(), batch->bounds())) { |
45 break; | 44 break; |
46 } | 45 } |
47 } else if (Cmd::kClear_CmdType == reverseIter->type()) { | 46 } else if (Cmd::kClear_CmdType == reverseIter->type()) { |
48 Clear* previous = static_cast<Clear*>(reverseIter.get()); | 47 Clear* previous = static_cast<Clear*>(reverseIter.get()); |
49 | 48 |
50 // We cannot continue to search backwards if the render target c
hanges | 49 // We cannot continue to search backwards if the render target c
hanges |
51 if (previous->renderTarget() != rt) { | 50 if (previous->renderTarget() != rt) { |
52 break; | 51 break; |
53 } | 52 } |
54 | 53 |
55 // We set the color to illegal if we are doing a discard. | 54 // We set the color to illegal if we are doing a discard. |
56 // If we can ignore the rect, then we do a full clear | |
57 if (previous->fColor == GrColor_ILLEGAL || | 55 if (previous->fColor == GrColor_ILLEGAL || |
58 previous->fCanIgnoreRect || | |
59 intersect(batch->bounds(), previous->fRect)) { | 56 intersect(batch->bounds(), previous->fRect)) { |
60 break; | 57 break; |
61 } | 58 } |
62 } else { | 59 } else { |
63 // TODO temporary until we can navigate the other types of comma
nds | 60 // TODO temporary until we can navigate the other types of comma
nds |
64 break; | 61 break; |
65 } | 62 } |
66 } while (reverseIter.previous() && ++i < kMaxLookback); | 63 } while (reverseIter.previous() && ++i < kMaxLookback); |
67 } | 64 } |
68 | 65 |
69 return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (state, batch
, | 66 return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (state, batch
, |
70 this->batchT
arget())); | 67 this->batchT
arget())); |
71 } | 68 } |
OLD | NEW |