Index: bench/ImageBench.cpp |
diff --git a/bench/ImageBench.cpp b/bench/ImageBench.cpp |
index e3fe230353ec907f738f12516e30822ef7c0450f..69ab17f2c1583a9369753b22ae9c1498201b722d 100644 |
--- a/bench/ImageBench.cpp |
+++ b/bench/ImageBench.cpp |
@@ -10,14 +10,14 @@ |
#include "SkImage.h" |
#include "SkSurface.h" |
-class GPU2RasterImageBench : public Benchmark { |
+class Image2RasterBench : public Benchmark { |
public: |
- GPU2RasterImageBench() { |
- fName.set("gpu2raster_image"); |
+ Image2RasterBench() { |
+ fName.set("native_image_to_raster_surface"); |
} |
bool isSuitableFor(Backend backend) override { |
- return kGPU_Backend == backend; |
+ return kGPU_Backend == backend || kRaster_Backend == backend; |
} |
protected: |
@@ -25,33 +25,35 @@ protected: |
return fName.c_str(); |
} |
+ // We explicitly want to bench drawing a Image [cpu or gpu backed] into a raster target, |
+ // to ensure that we can cache the read-back in the case of gpu -> raster |
+ // |
void onPerCanvasPreDraw(SkCanvas* canvas) override { |
- // create a gpu-backed Image |
- SkImageInfo info = SkImageInfo::MakeN32Premul(500, 500); |
+ // create an Image reflecting the canvas (gpu or cpu) |
+ SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); |
SkAutoTUnref<SkSurface> surface(canvas->newSurface(info)); |
canvas->drawColor(SK_ColorRED); |
- fGpuImage.reset(surface->newImageSnapshot()); |
+ fImage.reset(surface->newImageSnapshot()); |
// create a cpu-backed Surface |
fRasterSurface.reset(SkSurface::NewRaster(info)); |
} |
void onDraw(const int loops, SkCanvas*) override { |
- // Time drawing a gpu-image into a raster-surface |
for (int i = 0; i < loops; i++) { |
for (int inner = 0; inner < 10; ++inner) { |
- fRasterSurface->getCanvas()->drawImage(fGpuImage, 0, 0); |
+ fRasterSurface->getCanvas()->drawImage(fImage, 0, 0); |
} |
} |
} |
private: |
SkString fName; |
- SkAutoTUnref<SkImage> fGpuImage; |
+ SkAutoTUnref<SkImage> fImage; |
SkAutoTUnref<SkSurface> fRasterSurface; |
typedef Benchmark INHERITED; |
}; |
-DEF_BENCH( return new GPU2RasterImageBench; ) |
+DEF_BENCH( return new Image2RasterBench; ) |