41template<
int kRectCount, RectangleLayout kLayout, ImageMode kImageMode, DrawMode kDrawMode>
45 "kQuad only supported for solid color draws");
47 inline static constexpr int kWidth = 1024;
48 inline static constexpr int kHeight = 1024;
99 for (
int i = 0;
i < kRectCount; ++
i) {
109 paint.setAntiAlias(
true);
121 paint.setAntiAlias(
true);
123 for (
int i = 0;
i < kRectCount; ++
i) {
141 for (
int i = 0;
i < kRectCount; ++
i) {
150 paint.setAntiAlias(
true);
157 sdc->drawQuadSet(
nullptr, std::move(grPaint), view, batch, kRectCount);
165 paint.setAntiAlias(
true);
166 for (
int i = 0;
i < kRectCount; ++
i) {
181 return fName.
c_str();
185 static constexpr SkScalar kMinRectSize = 0.2f;
186 static constexpr SkScalar kMaxRectSize = 300.f;
189 for (
int i = 0;
i < kRectCount;
i++) {
191 SkScalar w = rand.
nextF() * (kMaxRectSize - kMinRectSize) + kMinRectSize;
192 SkScalar h = rand.
nextF() * (kMaxRectSize - kMinRectSize) + kMinRectSize;
200 SkASSERT(gridSize * gridSize >= kRectCount);
248 for (
int i = 0;
i < loops;
i++) {
273#define ADD_BENCH(n, layout, imageMode, drawMode) \
274 DEF_BENCH( return (new BulkRectBench<n, layout, imageMode, drawMode>()); )
276#define ADD_BENCH_FAMILY(n, layout) \
277 ADD_BENCH(n, layout, ImageMode::kShared, DrawMode::kBatch) \
278 ADD_BENCH(n, layout, ImageMode::kShared, DrawMode::kRef) \
279 ADD_BENCH(n, layout, ImageMode::kUnique, DrawMode::kBatch) \
280 ADD_BENCH(n, layout, ImageMode::kUnique, DrawMode::kRef) \
281 ADD_BENCH(n, layout, ImageMode::kNone, DrawMode::kBatch) \
282 ADD_BENCH(n, layout, ImageMode::kNone, DrawMode::kRef) \
283 ADD_BENCH(n, layout, ImageMode::kNone, DrawMode::kQuad)
288#undef ADD_BENCH_FAMILY
#define ADD_BENCH_FAMILY(n, layout)
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
@ kSrcOver
r = s + (1-sa)*d
constexpr SkColor SK_ColorWHITE
bool SkPaintToGrPaint(GrRecordingContext *context, const GrColorInfo &dstColorInfo, const SkPaint &skPaint, const SkMatrix &ctm, const SkSurfaceProps &surfaceProps, GrPaint *grPaint)
#define SkScalarCeilToInt(x)
virtual bool isSuitableFor(Backend backend)
void onPerCanvasPreDraw(SkCanvas *canvas) override
static constexpr int kHeight
static constexpr int kImageCount
SkRect fRects[kRectCount]
bool isSuitableFor(Backend backend) override
void drawSolidColorsRef(SkCanvas *canvas) const
SkISize onGetSize() override
void onDelayedSetup() override
sk_sp< SkImage > fImages[kImageCount > 0 ? kImageCount :1]
static constexpr int kWidth
SkColor4f fColors[kRectCount]
void drawSolidColorsBatch(SkCanvas *canvas) const
void drawImagesBatch(SkCanvas *canvas) const
void drawImagesRef(SkCanvas *canvas) const
void onDraw(int loops, SkCanvas *canvas) override
void onPerCanvasPostDraw(SkCanvas *canvas) override
const char * onGetName() override
sk_sp< SkImage > asImage() const
void allocN32Pixels(int width, int height, bool isOpaque=false)
void eraseColor(SkColor4f) const
void drawRect(const SkRect &rect, const SkPaint &paint)
SkMatrix getLocalToDeviceAs3x3() const
virtual GrRecordingContext * recordingContext() const
@ kFast_SrcRectConstraint
sample outside bounds; faster
void experimental_DrawEdgeAAQuad(const SkRect &rect, const SkPoint clip[4], QuadAAFlags aaFlags, const SkColor4f &color, SkBlendMode mode)
void experimental_DrawEdgeAAImageSet(const ImageSetEntry imageSet[], int cnt, const SkPoint dstClips[], const SkMatrix preViewMatrices[], const SkSamplingOptions &, const SkPaint *paint=nullptr, SrcRectConstraint constraint=kStrict_SrcRectConstraint)
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
static const SkMatrix & I()
void append(const char text[])
const char * c_str() const
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
void reset(T *ptr=nullptr)
SK_API sk_sp< SkImage > TextureFromImage(GrDirectContext *, const SkImage *, skgpu::Mipmapped=skgpu::Mipmapped::kNo, skgpu::Budgeted=skgpu::Budgeted::kYes)
sk_sp< const SkImage > image
const myers::Point & get(const myers::Segment &)
SurfaceDrawContext * TopDeviceSurfaceDrawContext(const SkCanvas *canvas)
SkSamplingOptions(SkFilterMode::kLinear))
constexpr bool contains(std::string_view str, std::string_view needle)
sk_sp< const SkImage > fImage
void setXYWH(float x, float y, float width, float height)
static SkRect MakeIWH(int w, int h)
static constexpr SkRect MakeWH(float w, float h)