ab244f045a
This reverts commit9d5f66d9c2
. Reason for revert: Leon landed Android fixes. Original change's description: > Revert "Reland: Remove SkLights include from SkCanvas.h" > > This reverts commitfed00319c9
. > > Reason for revert: breaking the Android roll. > > Original change's description: > > Reland: Remove SkLights include from SkCanvas.h > > > > SkLights.h pulls in a bunch of other headers and is not needed (fwdecl > > works fine). > > > > Change-Id: I3ed97cd7861e51dcb7cfa7950a97b420dbc6fbfb > > TBR=reed@google.com > > Reviewed-on: https://skia-review.googlesource.com/15143 > > Commit-Queue: Florin Malita <fmalita@chromium.org> > > Reviewed-by: Florin Malita <fmalita@chromium.org> > > > > TBR=fmalita@chromium.org,reed@google.com > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > > Change-Id: I3b0e69f1d04d160f16a5567b09982d35cc9ca84e > Reviewed-on: https://skia-review.googlesource.com/15195 > Reviewed-by: Florin Malita <fmalita@chromium.org> > Commit-Queue: Florin Malita <fmalita@chromium.org> > TBR=msarett@google.com,reviews@skia.org,fmalita@chromium.org,reed@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I0a1c2f9df61f16987ab72dfb4f3a205fbcc37667 Reviewed-on: https://skia-review.googlesource.com/15229 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
82 lines
2.1 KiB
C++
82 lines
2.1 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 "Benchmark.h"
|
|
#include "SkBitmap.h"
|
|
#include "SkCanvas.h"
|
|
#include "SkMatrix.h"
|
|
#include "SkPaint.h"
|
|
#include "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");
|
|
)
|