3695bdb587
There was only one virtual method, so switch that to a bool stored in the base class. The derived types exist as hints for the reader, and an easy way to adjust how the new localToDevice is constructed. With this change, we don't need SkSimpleMatrixProvider. SkMatrixProvider is concrete, so we can use it directly. SkOverrideDeviceMatrixProvider no longer needs the original provider for anything, so remove that parameter. It now exists solely to inhibit the hitsPixelCenters flag. Fix a few spots (SkParticleBinding, some sites in SkRuntimeEffect) where we used SkSimpleMatrixProvider, even though the local coordinates being passed did not obey the hits-pixel-centers constraints. Most importantly, document how localToDeviceHitsPixelCenters works. Change-Id: Ibe9060bac0822d0edf52a507d390bd198d8e6dbd Reviewed-on: https://skia-review.googlesource.com/c/skia/+/482176 Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
77 lines
2.2 KiB
C++
77 lines
2.2 KiB
C++
/*
|
|
* Copyright 2013 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/SkColorPriv.h"
|
|
#include "include/core/SkMatrix.h"
|
|
#include "include/core/SkPath.h"
|
|
#include "src/core/SkAutoPixmapStorage.h"
|
|
#include "src/core/SkDraw.h"
|
|
#include "src/core/SkMatrixProvider.h"
|
|
#include "src/core/SkRasterClip.h"
|
|
|
|
class DrawPathBench : public Benchmark {
|
|
SkPaint fPaint;
|
|
SkString fName;
|
|
SkPath fPath;
|
|
SkRasterClip fRC;
|
|
SkAutoPixmapStorage fPixmap;
|
|
SkMatrixProvider fIdentityMatrixProvider;
|
|
SkDraw fDraw;
|
|
bool fDrawCoverage;
|
|
public:
|
|
DrawPathBench(bool drawCoverage)
|
|
: fIdentityMatrixProvider(SkMatrix::I()), fDrawCoverage(drawCoverage) {
|
|
fPaint.setAntiAlias(true);
|
|
fName.printf("draw_coverage_%s", drawCoverage ? "true" : "false");
|
|
|
|
fPath.moveTo(0, 0);
|
|
fPath.quadTo(500, 0, 500, 500);
|
|
fPath.quadTo(250, 0, 0, 500);
|
|
|
|
fPixmap.alloc(SkImageInfo::MakeA8(500, 500));
|
|
if (!drawCoverage) {
|
|
// drawPathCoverage() goes out of its way to work fine with an uninitialized
|
|
// dst buffer, even in "SrcOver" mode, but ordinary drawing sure doesn't.
|
|
fPixmap.erase(0);
|
|
}
|
|
|
|
fRC.setRect(fPath.getBounds().round());
|
|
|
|
fDraw.fDst = fPixmap;
|
|
fDraw.fMatrixProvider = &fIdentityMatrixProvider;
|
|
fDraw.fRC = &fRC;
|
|
}
|
|
|
|
protected:
|
|
const char* onGetName() override {
|
|
return fName.c_str();
|
|
}
|
|
|
|
void onDraw(int loops, SkCanvas* canvas) override {
|
|
if (fDrawCoverage) {
|
|
for (int i = 0; i < loops; ++i) {
|
|
fDraw.drawPathCoverage(fPath, fPaint);
|
|
}
|
|
} else {
|
|
for (int i = 0; i < loops; ++i) {
|
|
fDraw.drawPath(fPath, fPaint);
|
|
}
|
|
}
|
|
}
|
|
|
|
private:
|
|
using INHERITED = Benchmark;
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
DEF_BENCH( return new DrawPathBench(false) )
|
|
DEF_BENCH( return new DrawPathBench(true) )
|