| 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 "SKPBench.h" | 8 #include "SKPBench.h" |
| 9 #include "SkCommandLineFlags.h" | 9 #include "SkCommandLineFlags.h" |
| 10 #include "SkMultiPictureDraw.h" | 10 #include "SkMultiPictureDraw.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 return backend != kNonRendering_Backend; | 91 return backend != kNonRendering_Backend; |
| 92 } | 92 } |
| 93 | 93 |
| 94 SkIPoint SKPBench::onGetSize() { | 94 SkIPoint SKPBench::onGetSize() { |
| 95 return SkIPoint::Make(fClip.width(), fClip.height()); | 95 return SkIPoint::Make(fClip.width(), fClip.height()); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void SKPBench::onDraw(const int loops, SkCanvas* canvas) { | 98 void SKPBench::onDraw(const int loops, SkCanvas* canvas) { |
| 99 if (fUseMultiPictureDraw) { | 99 if (fUseMultiPictureDraw) { |
| 100 for (int i = 0; i < loops; i++) { | 100 for (int i = 0; i < loops; i++) { |
| 101 SkMultiPictureDraw mpd; | 101 this->drawMPDPicture(); |
| 102 | |
| 103 for (int j = 0; j < fTileRects.count(); ++j) { | |
| 104 SkMatrix trans; | |
| 105 trans.setTranslate(-fTileRects[j].fLeft/fScale, | |
| 106 -fTileRects[j].fTop/fScale); | |
| 107 mpd.add(fSurfaces[j]->getCanvas(), fPic, &trans); | |
| 108 } | |
| 109 | |
| 110 mpd.draw(); | |
| 111 | |
| 112 for (int j = 0; j < fTileRects.count(); ++j) { | |
| 113 fSurfaces[j]->getCanvas()->flush(); | |
| 114 } | |
| 115 } | 102 } |
| 116 } else { | 103 } else { |
| 117 for (int i = 0; i < loops; i++) { | 104 for (int i = 0; i < loops; i++) { |
| 118 for (int j = 0; j < fTileRects.count(); ++j) { | 105 this->drawPicture(); |
| 119 const SkMatrix trans = SkMatrix::MakeTrans(-fTileRects[j].fLeft
/ fScale, | |
| 120 -fTileRects[j].fTop /
fScale); | |
| 121 fSurfaces[j]->getCanvas()->drawPicture(fPic, &trans, NULL); | |
| 122 } | |
| 123 | |
| 124 for (int j = 0; j < fTileRects.count(); ++j) { | |
| 125 fSurfaces[j]->getCanvas()->flush(); | |
| 126 } | |
| 127 } | 106 } |
| 128 } | 107 } |
| 129 } | 108 } |
| 109 |
| 110 void SKPBench::drawMPDPicture() { |
| 111 SkMultiPictureDraw mpd; |
| 112 |
| 113 for (int j = 0; j < fTileRects.count(); ++j) { |
| 114 SkMatrix trans; |
| 115 trans.setTranslate(-fTileRects[j].fLeft/fScale, |
| 116 -fTileRects[j].fTop/fScale); |
| 117 mpd.add(fSurfaces[j]->getCanvas(), fPic, &trans); |
| 118 } |
| 119 |
| 120 mpd.draw(); |
| 121 |
| 122 for (int j = 0; j < fTileRects.count(); ++j) { |
| 123 fSurfaces[j]->getCanvas()->flush(); |
| 124 } |
| 125 } |
| 126 |
| 127 void SKPBench::drawPicture() { |
| 128 for (int j = 0; j < fTileRects.count(); ++j) { |
| 129 const SkMatrix trans = SkMatrix::MakeTrans(-fTileRects[j].fLeft / fScale
, |
| 130 -fTileRects[j].fTop / fScale)
; |
| 131 fSurfaces[j]->getCanvas()->drawPicture(fPic, &trans, NULL); |
| 132 } |
| 133 |
| 134 for (int j = 0; j < fTileRects.count(); ++j) { |
| 135 fSurfaces[j]->getCanvas()->flush(); |
| 136 } |
| 137 } |
| OLD | NEW |