Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5705)

Unified Diff: bench/ImageBench.cpp

Issue 1530203002: Reland of move drawSprite from canvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gm/dropshadowimagefilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/ImageBench.cpp
diff --git a/bench/ImageBench.cpp b/bench/ImageBench.cpp
index 40de28121fb5d6695902200bb5518a37cccf3eae..097ed91d5de45f36d6d07fd4428693184a46067e 100644
--- a/bench/ImageBench.cpp
+++ b/bench/ImageBench.cpp
@@ -62,117 +62,3 @@
typedef Benchmark INHERITED;
};
DEF_BENCH( return new Image2RasterBench; )
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-#include "SkOffsetImageFilter.h"
-
-#if SK_SUPPORT_GPU
-#include "SkGrPixelRef.h"
-#endif
-
-enum MyDrawType {
- kSprite_Type,
- kBitmap_Type,
- kImage_Type,
-};
-
-/*
- * Want to time drawing images/bitmaps via drawSprite, and via drawBitmap/drawImage but with
- * a non-scaling matrix and a clip that is tight to the image bounds. In this scenario, we
- * should be able to match the speed of drawSprite.
- *
- * An optimal result should be that all three types: sprite/bitmap/image draw at the same speed.
- */
-class ImageFilterSpriteBench : public Benchmark {
- SkAutoTUnref<SkImage> fImage;
- SkBitmap fBitmap;
- SkString fName;
- MyDrawType fType;
-
-public:
- ImageFilterSpriteBench(MyDrawType dt, const char suffix[]) : fType(dt) {
- fName.printf("image-filter-sprite-draw-%s", suffix);
- }
-
- bool isSuitableFor(Backend backend) override {
- return kGPU_Backend == backend || kRaster_Backend == backend;
- }
-
-protected:
- bool isVisual() override {
- return true;
- }
-
- const char* onGetName() override {
- return fName.c_str();
- }
-
- void onPerCanvasPreDraw(SkCanvas* canvas) override {
- const SkImageInfo info = SkImageInfo::MakeN32Premul(500, 500);
- SkAutoTUnref<SkSurface> surface(canvas->newSurface(info));
-
- surface->getCanvas()->drawColor(SK_ColorRED);
- fImage.reset(surface->newImageSnapshot());
-
- fBitmap.setInfo(info);
- if (fImage->getTexture()) {
-#if SK_SUPPORT_GPU
- fBitmap.setPixelRef(new SkGrPixelRef(info, fImage->getTexture()))->unref();
-#endif
- } else {
- SkPixmap pmap;
- if (!fImage->peekPixels(&pmap)) {
- sk_throw();
- }
- fBitmap.installPixels(pmap);
- }
- }
-
- void onPerCanvasPostDraw(SkCanvas*) override {
- // Release the image and raster surface here to prevent out of order destruction
- // between these and the gpu interface.
- fImage.reset(nullptr);
- fBitmap.reset();
- }
-
- void onDraw(int loops, SkCanvas* canvas) override {
- // This clip is important; it allows the drawImage/drawBitmap code to fall into the
- // fast (sprite) case, since the imagefilter's output should match.
- //
- // When we address skbug.com/4526 we should be able to remove the need for this clip.
- //
- canvas->clipRect(SkRect::MakeIWH(fImage->width(), fImage->height()));
-
- const SkScalar kDelta = 10;
- SkPaint paint;
- for (int i = 0; i < loops; i++) {
- for (int inner = 0; inner < 10; ++inner) {
- // build the filter everytime, so we don't accidentally draw a cached version,
- // since the point of this bench is to time the actual imagefilter
- // handling/overhead.
- SkAutoTUnref<SkImageFilter> filter(SkOffsetImageFilter::Create(kDelta, kDelta));
- paint.setImageFilter(filter);
-
- switch (fType) {
- case kSprite_Type:
- canvas->drawSprite(fBitmap, 0, 0, &paint);
- break;
- case kBitmap_Type:
- canvas->drawBitmap(fBitmap, 0, 0, &paint);
- break;
- case kImage_Type:
- canvas->drawImage(fImage, 0, 0, &paint);
- break;
- }
- }
- }
- }
-
-private:
- typedef Benchmark INHERITED;
-};
-DEF_BENCH( return new ImageFilterSpriteBench(kSprite_Type, "sprite"); )
-DEF_BENCH( return new ImageFilterSpriteBench(kBitmap_Type, "bitmap"); )
-DEF_BENCH( return new ImageFilterSpriteBench(kImage_Type, "image"); )
-
« no previous file with comments | « no previous file | gm/dropshadowimagefilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698