| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrRecordReplaceDraw.h" | 8 #include "GrRecordReplaceDraw.h" |
| 9 #include "SkImage.h" | 9 #include "SkImage.h" |
| 10 #include "SkRecordDraw.h" | 10 #include "SkRecordDraw.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 SkCanvas* canvas, | 64 SkCanvas* canvas, |
| 65 const SkBBoxHierarchy* bbh, | 65 const SkBBoxHierarchy* bbh, |
| 66 const GrReplacements* replacements, | 66 const GrReplacements* replacements, |
| 67 SkDrawPictureCallback* callback) { | 67 SkDrawPictureCallback* callback) { |
| 68 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); | 68 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); |
| 69 | 69 |
| 70 SkRecords::Draw draw(canvas); | 70 SkRecords::Draw draw(canvas); |
| 71 const GrReplacements::ReplacementInfo* ri = NULL; | 71 const GrReplacements::ReplacementInfo* ri = NULL; |
| 72 int searchStart = 0; | 72 int searchStart = 0; |
| 73 | 73 |
| 74 if (NULL != bbh) { | 74 if (bbh) { |
| 75 // Draw only ops that affect pixels in the canvas's current clip. | 75 // Draw only ops that affect pixels in the canvas's current clip. |
| 76 // The SkRecord and BBH were recorded in identity space. This canvas | 76 // The SkRecord and BBH were recorded in identity space. This canvas |
| 77 // is not necessarily in that same space. getClipBounds() returns us | 77 // is not necessarily in that same space. getClipBounds() returns us |
| 78 // this canvas' clip bounds transformed back into identity space, which | 78 // this canvas' clip bounds transformed back into identity space, which |
| 79 // lets us query the BBH. | 79 // lets us query the BBH. |
| 80 SkRect query = { 0, 0, 0, 0 }; | 80 SkRect query = { 0, 0, 0, 0 }; |
| 81 (void)canvas->getClipBounds(&query); | 81 (void)canvas->getClipBounds(&query); |
| 82 | 82 |
| 83 SkTDArray<void*> ops; | 83 SkTDArray<void*> ops; |
| 84 bbh->search(query, &ops); | 84 bbh->search(query, &ops); |
| 85 | 85 |
| 86 for (int i = 0; i < ops.count(); i++) { | 86 for (int i = 0; i < ops.count(); i++) { |
| 87 if (NULL != callback && callback->abortDrawing()) { | 87 if (callback && callback->abortDrawing()) { |
| 88 return; | 88 return; |
| 89 } | 89 } |
| 90 ri = replacements->lookupByStart((uintptr_t)ops[i], &searchStart); | 90 ri = replacements->lookupByStart((uintptr_t)ops[i], &searchStart); |
| 91 if (NULL != ri) { | 91 if (ri) { |
| 92 draw_replacement_bitmap(ri, canvas); | 92 draw_replacement_bitmap(ri, canvas); |
| 93 | 93 |
| 94 while ((uintptr_t)ops[i] < ri->fStop) { | 94 while ((uintptr_t)ops[i] < ri->fStop) { |
| 95 ++i; | 95 ++i; |
| 96 } | 96 } |
| 97 SkASSERT((uintptr_t)ops[i] == ri->fStop); | 97 SkASSERT((uintptr_t)ops[i] == ri->fStop); |
| 98 continue; | 98 continue; |
| 99 } | 99 } |
| 100 | 100 |
| 101 record.visit<void>((uintptr_t)ops[i], draw); | 101 record.visit<void>((uintptr_t)ops[i], draw); |
| 102 } | 102 } |
| 103 } else { | 103 } else { |
| 104 for (unsigned int i = 0; i < record.count(); ++i) { | 104 for (unsigned int i = 0; i < record.count(); ++i) { |
| 105 if (NULL != callback && callback->abortDrawing()) { | 105 if (callback && callback->abortDrawing()) { |
| 106 return; | 106 return; |
| 107 } | 107 } |
| 108 ri = replacements->lookupByStart(i, &searchStart); | 108 ri = replacements->lookupByStart(i, &searchStart); |
| 109 if (NULL != ri) { | 109 if (ri) { |
| 110 draw_replacement_bitmap(ri, canvas); | 110 draw_replacement_bitmap(ri, canvas); |
| 111 | 111 |
| 112 i = ri->fStop; | 112 i = ri->fStop; |
| 113 continue; | 113 continue; |
| 114 } | 114 } |
| 115 | 115 |
| 116 record.visit<void>(i, draw); | 116 record.visit<void>(i, draw); |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 } | 119 } |
| OLD | NEW |