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 "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkImage.h" | 10 #include "SkImage.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 fBitmap.setInfo(info); | 118 fBitmap.setInfo(info); |
119 if (fImage->getTexture()) { | 119 if (fImage->getTexture()) { |
120 #if SK_SUPPORT_GPU | 120 #if SK_SUPPORT_GPU |
121 fBitmap.setPixelRef(new SkGrPixelRef(info, fImage->getTexture()))->u
nref(); | 121 fBitmap.setPixelRef(new SkGrPixelRef(info, fImage->getTexture()))->u
nref(); |
122 #endif | 122 #endif |
123 } else { | 123 } else { |
124 SkPixmap pmap; | 124 SkPixmap pmap; |
125 if (!fImage->peekPixels(&pmap)) { | 125 if (!fImage->peekPixels(&pmap)) { |
126 sk_throw(); | 126 sk_throw(); |
127 } | 127 } |
128 fBitmap.installPixels(pmap.info(), pmap.writable_addr(), pmap.rowByt
es()); | 128 fBitmap.installPixels(pmap); |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 void onPerCanvasPostDraw(SkCanvas*) override { | 132 void onPerCanvasPostDraw(SkCanvas*) override { |
133 // Release the image and raster surface here to prevent out of order des
truction | 133 // Release the image and raster surface here to prevent out of order des
truction |
134 // between these and the gpu interface. | 134 // between these and the gpu interface. |
135 fImage.reset(nullptr); | 135 fImage.reset(nullptr); |
136 fBitmap.reset(); | 136 fBitmap.reset(); |
137 } | 137 } |
138 | 138 |
(...skipping 30 matching lines...) Expand all Loading... |
169 } | 169 } |
170 } | 170 } |
171 | 171 |
172 private: | 172 private: |
173 typedef Benchmark INHERITED; | 173 typedef Benchmark INHERITED; |
174 }; | 174 }; |
175 DEF_BENCH( return new ImageFilterSpriteBench(kSprite_Type, "sprite"); ) | 175 DEF_BENCH( return new ImageFilterSpriteBench(kSprite_Type, "sprite"); ) |
176 DEF_BENCH( return new ImageFilterSpriteBench(kBitmap_Type, "bitmap"); ) | 176 DEF_BENCH( return new ImageFilterSpriteBench(kBitmap_Type, "bitmap"); ) |
177 DEF_BENCH( return new ImageFilterSpriteBench(kImage_Type, "image"); ) | 177 DEF_BENCH( return new ImageFilterSpriteBench(kImage_Type, "image"); ) |
178 | 178 |
OLD | NEW |