c0bd9f9fe5
Current strategy: everything from the top Things to look at first are the manual changes: - added tools/rewrite_includes.py - removed -Idirectives from BUILD.gn - various compile.sh simplifications - tweak tools/embed_resources.py - update gn/find_headers.py to write paths from the top - update gn/gn_to_bp.py SkUserConfig.h layout so that #include "include/config/SkUserConfig.h" always gets the header we want. No-Presubmit: true Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Hal Canary <halcanary@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
82 lines
2.2 KiB
C++
82 lines
2.2 KiB
C++
/*
|
|
* Copyright 2015 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
#include "bench/Benchmark.h"
|
|
#include "include/core/SkBitmap.h"
|
|
#include "include/core/SkCanvas.h"
|
|
#include "include/core/SkMatrix.h"
|
|
#include "include/core/SkPaint.h"
|
|
#include "include/core/SkString.h"
|
|
|
|
/**
|
|
* This bench measures the rendering time of SkCanvas::drawBitmap with different anti-aliasing /
|
|
* matrix combinations.
|
|
*/
|
|
|
|
class DrawBitmapAABench : public Benchmark {
|
|
public:
|
|
DrawBitmapAABench(bool doAA, const SkMatrix& matrix, const char name[])
|
|
: fMatrix(matrix)
|
|
, fName("draw_bitmap_") {
|
|
|
|
fPaint.setAntiAlias(doAA);
|
|
// Most clients use filtering, so let's focus on this for now.
|
|
fPaint.setFilterQuality(kLow_SkFilterQuality);
|
|
fName.appendf("%s_%s", doAA ? "aa" : "noaa", name);
|
|
}
|
|
|
|
protected:
|
|
const char* onGetName() override {
|
|
return fName.c_str();
|
|
}
|
|
|
|
void onDelayedSetup() override {
|
|
fBitmap.allocN32Pixels(200, 200);
|
|
fBitmap.eraseARGB(255, 0, 255, 0);
|
|
}
|
|
|
|
void onDraw(int loops, SkCanvas* canvas) override {
|
|
canvas->concat(fMatrix);
|
|
for (int i = 0; i < loops; i++) {
|
|
canvas->drawBitmap(fBitmap, 0, 0, &fPaint);
|
|
}
|
|
}
|
|
|
|
private:
|
|
SkPaint fPaint;
|
|
SkMatrix fMatrix;
|
|
SkString fName;
|
|
SkBitmap fBitmap;
|
|
|
|
typedef Benchmark INHERITED;
|
|
};
|
|
|
|
DEF_BENCH( return new DrawBitmapAABench(false, SkMatrix::MakeScale(1), "ident"); )
|
|
|
|
DEF_BENCH( return new DrawBitmapAABench(false, SkMatrix::MakeScale(1.17f), "scale"); )
|
|
|
|
DEF_BENCH( return new DrawBitmapAABench(false, SkMatrix::MakeTrans(17.5f, 17.5f), "translate"); )
|
|
|
|
DEF_BENCH(
|
|
SkMatrix m;
|
|
m.reset();
|
|
m.preRotate(15);
|
|
return new DrawBitmapAABench(false, m, "rotate");
|
|
)
|
|
|
|
DEF_BENCH( return new DrawBitmapAABench(true, SkMatrix::MakeScale(1), "ident"); )
|
|
|
|
DEF_BENCH( return new DrawBitmapAABench(true, SkMatrix::MakeScale(1.17f), "scale"); )
|
|
|
|
DEF_BENCH( return new DrawBitmapAABench(true, SkMatrix::MakeTrans(17.5f, 17.5f), "translate"); )
|
|
|
|
DEF_BENCH(
|
|
SkMatrix m;
|
|
m.reset();
|
|
m.preRotate(15);
|
|
return new DrawBitmapAABench(true, m, "rotate");
|
|
)
|