d053ce9c54
Reason for revert:
guard has now landed in chrome
Original issue's description:
> Revert of Revert[2] of "switch colorfilters to sk_sp (patchset #11 id:200001 of https://codereview.chromium.o… (patchset #3 id:40001 of https://codereview.chromium.org/1825073002/ )
>
> Reason for revert:
> CreateModeFilter not compiling
>
> Original issue's description:
> > Revert[2] of "switch colorfilters to sk_sp (patchset #11 id:200001 of https://codereview.chromium.org/1822623002/ )"
> >
> > Fixed legacy withColorFilter to call new(er) make method
> >
> > This reverts commit 1eb81db650
.
> >
> > BUG=skia:
> > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1825073002
> >
> > TBR=
> >
> > Committed: https://skia.googlesource.com/skia/+/4c9776b046dd5e9e46e2d1ce35154855c8fcb381
>
> TBR=
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/d6889293dd0942f27f9593f679722c956831f2c4
TBR=
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=skia:
Review URL: https://codereview.chromium.org/1827433002
93 lines
3.2 KiB
C++
93 lines
3.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 "Benchmark.h"
|
|
#include "SkBlurMask.h"
|
|
#include "SkBlurMaskFilter.h"
|
|
#include "SkCanvas.h"
|
|
#include "SkColorFilter.h"
|
|
#include "SkLayerDrawLooper.h"
|
|
#include "SkPaint.h"
|
|
#include "SkPath.h"
|
|
#include "SkPoint.h"
|
|
#include "SkRRect.h"
|
|
#include "SkRect.h"
|
|
#include "SkString.h"
|
|
#include "SkXfermode.h"
|
|
|
|
// Large blurred RR appear frequently on web pages. This benchmark measures our
|
|
// performance in this case.
|
|
class BlurRoundRectBench : public Benchmark {
|
|
public:
|
|
BlurRoundRectBench(int width, int height, int cornerRadius)
|
|
: fName("blurroundrect") {
|
|
fName.appendf("_WH[%ix%i]_cr[%i]", width, height, cornerRadius);
|
|
SkRect r = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
|
|
fRRect.setRectXY(r, SkIntToScalar(cornerRadius), SkIntToScalar(cornerRadius));
|
|
}
|
|
|
|
const char* onGetName() override {
|
|
return fName.c_str();
|
|
}
|
|
|
|
SkIPoint onGetSize() override {
|
|
return SkIPoint::Make(SkScalarCeilToInt(fRRect.rect().width()),
|
|
SkScalarCeilToInt(fRRect.rect().height()));
|
|
}
|
|
|
|
void onDraw(int loops, SkCanvas* canvas) override {
|
|
SkLayerDrawLooper::Builder looperBuilder;
|
|
{
|
|
SkLayerDrawLooper::LayerInfo info;
|
|
info.fPaintBits = SkLayerDrawLooper::kMaskFilter_Bit
|
|
| SkLayerDrawLooper::kColorFilter_Bit;
|
|
info.fColorMode = SkXfermode::kSrc_Mode;
|
|
info.fOffset = SkPoint::Make(SkIntToScalar(-1), SkIntToScalar(0));
|
|
info.fPostTranslate = false;
|
|
SkPaint* paint = looperBuilder.addLayerOnTop(info);
|
|
SkMaskFilter* maskFilter = SkBlurMaskFilter::Create(
|
|
kNormal_SkBlurStyle,
|
|
SkBlurMask::ConvertRadiusToSigma(SK_ScalarHalf),
|
|
SkBlurMaskFilter::kHighQuality_BlurFlag);
|
|
paint->setMaskFilter(maskFilter)->unref();
|
|
paint->setColorFilter(SkColorFilter::MakeModeFilter(SK_ColorLTGRAY,
|
|
SkXfermode::kSrcIn_Mode));
|
|
paint->setColor(SK_ColorGRAY);
|
|
}
|
|
{
|
|
SkLayerDrawLooper::LayerInfo info;
|
|
looperBuilder.addLayerOnTop(info);
|
|
}
|
|
SkPaint dullPaint;
|
|
dullPaint.setAntiAlias(true);
|
|
|
|
SkPaint loopedPaint;
|
|
loopedPaint.setLooper(looperBuilder.detach());
|
|
loopedPaint.setAntiAlias(true);
|
|
loopedPaint.setColor(SK_ColorCYAN);
|
|
|
|
for (int i = 0; i < loops; i++) {
|
|
canvas->drawRect(fRRect.rect(), dullPaint);
|
|
canvas->drawRRect(fRRect, loopedPaint);
|
|
}
|
|
}
|
|
|
|
private:
|
|
SkString fName;
|
|
SkRRect fRRect;
|
|
|
|
typedef Benchmark INHERITED;
|
|
};
|
|
|
|
// Create one with dimensions/rounded corners based on the skp
|
|
DEF_BENCH(return new BlurRoundRectBench(600, 5514, 6);)
|
|
// Same radii, much smaller rectangle
|
|
DEF_BENCH(return new BlurRoundRectBench(100, 100, 6);)
|
|
// Other radii options
|
|
DEF_BENCH(return new BlurRoundRectBench(100, 100, 30);)
|
|
DEF_BENCH(return new BlurRoundRectBench(100, 100, 90);)
|