| 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 "SkCanvasPriv.h" | 9 #include "SkCanvasPriv.h" |
| 10 #include "SkImage.h" | 10 #include "SkImage.h" |
| 11 #include "SkRecordDraw.h" | 11 #include "SkRecordDraw.h" |
| 12 #include "SkRecords.h" | 12 #include "SkRecords.h" |
| 13 | 13 |
| 14 GrReplacements::ReplacementInfo* GrReplacements::newReplacement(uint32_t picture
ID, | 14 GrReplacements::ReplacementInfo* GrReplacements::newReplacement(uint32_t picture
ID, |
| 15 const SkMatrix&
initialMat, | 15 const SkMatrix&
initialMat, |
| 16 const int* key,
int keySize) { | 16 const int* key,
int keySize) { |
| 17 ReplacementInfo* replacement = SkNEW_ARGS(ReplacementInfo, (pictureID, initi
alMat, | 17 ReplacementInfo* replacement = SkNEW_ARGS(ReplacementInfo, (pictureID, initi
alMat, |
| 18 key, keySize)); | 18 key, keySize)); |
| 19 fReplacementHash.add(replacement); | 19 fReplacementHash.add(replacement); |
| 20 return replacement; | 20 return replacement; |
| 21 } | 21 } |
| 22 | 22 |
| 23 void GrReplacements::freeAll() { | 23 void GrReplacements::freeAll() { |
| 24 SkTDynamicHash<ReplacementInfo, ReplacementInfo::Key>::Iter iter(&fReplaceme
ntHash); | 24 SkTDynamicHash<ReplacementInfo, ReplacementInfo::Key>::Iter iter(&fReplaceme
ntHash); |
| 25 | 25 |
| 26 for (; !iter.done(); ++iter) { | 26 for (; !iter.done(); ++iter) { |
| 27 ReplacementInfo* replacement = &(*iter); | 27 ReplacementInfo* replacement = &(*iter); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 int drawPictureOffset; | 128 int drawPictureOffset; |
| 129 if (fOps.count()) { | 129 if (fOps.count()) { |
| 130 drawPictureOffset = fOps[fIndex]; | 130 drawPictureOffset = fOps[fIndex]; |
| 131 } else { | 131 } else { |
| 132 drawPictureOffset = fIndex; | 132 drawPictureOffset = fIndex; |
| 133 } | 133 } |
| 134 | 134 |
| 135 fOpIndexStack.push(drawPictureOffset); | 135 fOpIndexStack.push(drawPictureOffset); |
| 136 | 136 |
| 137 SkAutoCanvasMatrixPaint acmp(fCanvas, dp.matrix, dp.paint, dp.picture->c
ullRect()); | 137 SkAutoCanvasMatrixPaint acmp(fCanvas, &dp.matrix, dp.paint, dp.picture->
cullRect()); |
| 138 | 138 |
| 139 // Draw sub-pictures with the same replacement list but a different pict
ure | 139 // Draw sub-pictures with the same replacement list but a different pict
ure |
| 140 ReplaceDraw draw(fCanvas, this->drawablePicts(), this->drawableCount(), | 140 ReplaceDraw draw(fCanvas, this->drawablePicts(), this->drawableCount(), |
| 141 fTopLevelPicture, dp.picture, fReplacements, fInitialMa
trix, fCallback, | 141 fTopLevelPicture, dp.picture, fReplacements, fInitialMa
trix, fCallback, |
| 142 fOpIndexStack.begin(), fOpIndexStack.count()); | 142 fOpIndexStack.begin(), fOpIndexStack.count()); |
| 143 | 143 |
| 144 fNumReplaced += draw.draw(); | 144 fNumReplaced += draw.draw(); |
| 145 | 145 |
| 146 fOpIndexStack.pop(); | 146 fOpIndexStack.pop(); |
| 147 } | 147 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 }; | 205 }; |
| 206 | 206 |
| 207 int GrRecordReplaceDraw(const SkPicture* picture, | 207 int GrRecordReplaceDraw(const SkPicture* picture, |
| 208 SkCanvas* canvas, | 208 SkCanvas* canvas, |
| 209 const GrReplacements* replacements, | 209 const GrReplacements* replacements, |
| 210 const SkMatrix& initialMatrix, | 210 const SkMatrix& initialMatrix, |
| 211 SkDrawPictureCallback* callback) { | 211 SkDrawPictureCallback* callback) { |
| 212 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); | 212 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); |
| 213 | 213 |
| 214 // TODO: drawablePicts? | 214 // TODO: drawablePicts? |
| 215 ReplaceDraw draw(canvas, NULL, 0, | 215 ReplaceDraw draw(canvas, NULL, 0, |
| 216 picture, picture, | 216 picture, picture, |
| 217 replacements, initialMatrix, callback, NULL, 0); | 217 replacements, initialMatrix, callback, NULL, 0); |
| 218 | 218 |
| 219 return draw.draw(); | 219 return draw.draw(); |
| 220 } | 220 } |
| OLD | NEW |