2016-08-02 15:05:56 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "bench/Benchmark.h"
|
|
|
|
#include "include/core/SkBitmap.h"
|
|
|
|
#include "include/core/SkCanvas.h"
|
|
|
|
#include "include/core/SkRect.h"
|
|
|
|
#include "include/core/SkString.h"
|
2016-08-02 15:05:56 +00:00
|
|
|
|
|
|
|
class DrawLatticeBench : public Benchmark {
|
|
|
|
public:
|
|
|
|
DrawLatticeBench(int* xDivs, int xCount, int* yDivs, int yCount, const SkISize& srcSize,
|
|
|
|
const SkRect& dst, const char* desc)
|
|
|
|
: fSrcSize(srcSize)
|
|
|
|
, fDst(dst)
|
|
|
|
{
|
|
|
|
fLattice.fXDivs = xDivs;
|
|
|
|
fLattice.fXCount = xCount;
|
|
|
|
fLattice.fYDivs = yDivs;
|
|
|
|
fLattice.fYCount = yCount;
|
2017-12-11 18:01:58 +00:00
|
|
|
fLattice.fRectTypes = nullptr;
|
2016-09-30 20:09:01 +00:00
|
|
|
fLattice.fBounds = nullptr;
|
2017-12-11 18:01:58 +00:00
|
|
|
fLattice.fColors = nullptr;
|
2016-08-02 15:05:56 +00:00
|
|
|
|
|
|
|
fName = SkStringPrintf("DrawLattice_%s", desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* onGetName() override {
|
|
|
|
return fName.c_str();
|
|
|
|
}
|
|
|
|
|
Batched implementation of drawLattice() for GPU
Bechmarks (Nexus 6P):
Src=100x100, Dst=250x250, NumRects=9
Android 77.7us
Skia (without patch) 57.2us
Skia (with patch) 30.9us
Src=100x100, Dst=500x500, NumRects=9
Android 77.0us
Skia (without patch) 56.9us
Skia (with patch) 31.8us
Src=100x100, Dst=1000x1000, NumRects=9
Android 180us
Skia (without patch) 96.8us
Skia (with patch) 70.5us
Src=100x100, Dst=250x250, NumRects=15
Android 208us
Skia (without patch) 155us
Skia (with patch) 38.2us
Src=100x100, Dst=500x500, NumRects=15
Android 207us
Skia (without patch) 152us
Skia (with patch) 38.4us
Src=100x100, Dst=1000x1000, NumRects=15
Android 233us
Skia (without patch) 156us
Skia (with patch) 99.9us
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2255963002
Committed: https://skia.googlesource.com/skia/+/93242c4ae50dfcc0d922cdb3ba80bbc7b4bbe93d
Review-Url: https://codereview.chromium.org/2255963002
2016-08-18 22:46:03 +00:00
|
|
|
SkIPoint onGetSize() override {
|
|
|
|
return SkIPoint::Make(1000, 1000);
|
|
|
|
}
|
|
|
|
|
2016-08-02 15:05:56 +00:00
|
|
|
bool isSuitableFor(Backend backend) override {
|
|
|
|
return kRaster_Backend == backend || kGPU_Backend == backend;
|
|
|
|
}
|
|
|
|
|
|
|
|
void onDelayedSetup() override {
|
|
|
|
fBitmap.allocN32Pixels(fSrcSize.width(), fSrcSize.height());
|
|
|
|
fBitmap.eraseColor(0x880000FF);
|
|
|
|
}
|
|
|
|
|
|
|
|
void onDraw(int loops, SkCanvas* canvas) override {
|
|
|
|
for (int i = 0; i < loops; i++) {
|
|
|
|
canvas->drawBitmapLattice(fBitmap, fLattice, fDst);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
SkISize fSrcSize;
|
|
|
|
SkCanvas::Lattice fLattice;
|
|
|
|
SkRect fDst;
|
|
|
|
SkString fName;
|
|
|
|
SkBitmap fBitmap;
|
|
|
|
|
|
|
|
typedef Benchmark INHERITED;
|
|
|
|
};
|
|
|
|
|
Batched implementation of drawLattice() for GPU
Bechmarks (Nexus 6P):
Src=100x100, Dst=250x250, NumRects=9
Android 77.7us
Skia (without patch) 57.2us
Skia (with patch) 30.9us
Src=100x100, Dst=500x500, NumRects=9
Android 77.0us
Skia (without patch) 56.9us
Skia (with patch) 31.8us
Src=100x100, Dst=1000x1000, NumRects=9
Android 180us
Skia (without patch) 96.8us
Skia (with patch) 70.5us
Src=100x100, Dst=250x250, NumRects=15
Android 208us
Skia (without patch) 155us
Skia (with patch) 38.2us
Src=100x100, Dst=500x500, NumRects=15
Android 207us
Skia (without patch) 152us
Skia (with patch) 38.4us
Src=100x100, Dst=1000x1000, NumRects=15
Android 233us
Skia (without patch) 156us
Skia (with patch) 99.9us
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2255963002
Committed: https://skia.googlesource.com/skia/+/93242c4ae50dfcc0d922cdb3ba80bbc7b4bbe93d
Review-Url: https://codereview.chromium.org/2255963002
2016-08-18 22:46:03 +00:00
|
|
|
static int gDivs9[2] = { 25, 75, };
|
|
|
|
DEF_BENCH(return new DrawLatticeBench(gDivs9, 2, gDivs9, 2, SkISize::Make(100, 100),
|
|
|
|
SkRect::MakeWH(250.0f, 250.0f), "Src100_Dst250_Rects9");)
|
|
|
|
DEF_BENCH(return new DrawLatticeBench(gDivs9, 2, gDivs9, 2, SkISize::Make(100, 100),
|
|
|
|
SkRect::MakeWH(500.0f, 500.0f), "Src100_Dst500_Rects9");)
|
|
|
|
DEF_BENCH(return new DrawLatticeBench(gDivs9, 2, gDivs9, 2, SkISize::Make(100, 100),
|
|
|
|
SkRect::MakeWH(1000.0f, 1000.0f), "Src100_Dst1000_Rects9");)
|
|
|
|
static int gDivs15[4] = { 15, 45, 55, 85, };
|
|
|
|
DEF_BENCH(return new DrawLatticeBench(gDivs15, 4, gDivs15, 4, SkISize::Make(100, 100),
|
|
|
|
SkRect::MakeWH(250.0f, 250.0f), "Src100_Dst250_Rects15");)
|
|
|
|
DEF_BENCH(return new DrawLatticeBench(gDivs15, 4, gDivs15, 4, SkISize::Make(100, 100),
|
|
|
|
SkRect::MakeWH(500.0f, 500.0f), "Src100_Dst500_Rects15");)
|
|
|
|
DEF_BENCH(return new DrawLatticeBench(gDivs15, 4, gDivs15, 4, SkISize::Make(100, 100),
|
|
|
|
SkRect::MakeWH(1000.0f, 1000.0f), "Src100_Dst1000_Rects15");)
|