drawBitmap is deprecated
- starting to remove duplicate/unneeded benches Change-Id: I4cd2e73b4e5d6664a99cc4a51f82436970d12eb6 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/358219 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
568f0ae778
commit
069e484cc3
@ -1,329 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011 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/SkPaint.h"
|
||||
#include "include/core/SkString.h"
|
||||
#include "include/utils/SkRandom.h"
|
||||
#include "tools/ToolUtils.h"
|
||||
|
||||
/* Variants for bitmaps
|
||||
|
||||
- src depth (32 w+w/o alpha), 565, 4444, index, a8
|
||||
- paint options: filtering, dither, alpha
|
||||
- matrix options: translate, scale, rotate, persp
|
||||
- tiling: none, repeat, mirror, clamp
|
||||
|
||||
*/
|
||||
|
||||
class BitmapBench : public Benchmark {
|
||||
const SkColorType fColorType;
|
||||
const SkAlphaType fAlphaType;
|
||||
const bool fForceUpdate; //bitmap marked as dirty before each draw. forces bitmap to be updated on device cache
|
||||
const bool fDoScale;
|
||||
|
||||
SkBitmap fBitmap;
|
||||
SkPaint fPaint;
|
||||
SkString fName;
|
||||
|
||||
enum { W = 128 };
|
||||
enum { H = 128 };
|
||||
public:
|
||||
BitmapBench(SkColorType ct, SkAlphaType at, bool forceUpdate, bool doScale)
|
||||
: fColorType(ct)
|
||||
, fAlphaType(at)
|
||||
, fForceUpdate(forceUpdate)
|
||||
, fDoScale(doScale)
|
||||
{}
|
||||
|
||||
protected:
|
||||
const char* onGetName() override {
|
||||
fName.set("bitmap");
|
||||
fName.appendf("_%s%s",
|
||||
ToolUtils::colortype_name(fColorType),
|
||||
kOpaque_SkAlphaType == fAlphaType ? "" : "_A");
|
||||
if (fDoScale) {
|
||||
fName.append("_scale");
|
||||
}
|
||||
if (fForceUpdate) {
|
||||
fName.append("_update");
|
||||
}
|
||||
|
||||
return fName.c_str();
|
||||
}
|
||||
|
||||
void onDelayedSetup() override {
|
||||
SkBitmap bm;
|
||||
|
||||
bm.allocPixels(SkImageInfo::Make(W, H, fColorType, fAlphaType));
|
||||
bm.eraseColor(kOpaque_SkAlphaType == fAlphaType ? SK_ColorBLACK : 0);
|
||||
|
||||
this->onDrawIntoBitmap(bm);
|
||||
|
||||
fBitmap = bm;
|
||||
if (!fForceUpdate) {
|
||||
fBitmap.setImmutable();
|
||||
}
|
||||
}
|
||||
|
||||
void onDraw(int loops, SkCanvas* canvas) override {
|
||||
if (fDoScale) {
|
||||
canvas->scale(.99f, .99f);
|
||||
}
|
||||
SkIPoint dim = this->getSize();
|
||||
SkRandom rand;
|
||||
|
||||
SkPaint paint(fPaint);
|
||||
this->setupPaint(&paint);
|
||||
|
||||
const SkBitmap& bitmap = fBitmap;
|
||||
const SkScalar x0 = SkIntToScalar(-bitmap.width() / 2);
|
||||
const SkScalar y0 = SkIntToScalar(-bitmap.height() / 2);
|
||||
|
||||
for (int i = 0; i < loops; i++) {
|
||||
SkScalar x = x0 + rand.nextUScalar1() * dim.fX;
|
||||
SkScalar y = y0 + rand.nextUScalar1() * dim.fY;
|
||||
|
||||
if (fForceUpdate)
|
||||
bitmap.notifyPixelsChanged();
|
||||
|
||||
canvas->drawBitmap(bitmap, x, y, &paint);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void onDrawIntoBitmap(const SkBitmap& bm) {
|
||||
const int w = bm.width();
|
||||
const int h = bm.height();
|
||||
|
||||
SkCanvas canvas(bm);
|
||||
SkPaint p;
|
||||
p.setAntiAlias(true);
|
||||
p.setColor(SK_ColorRED);
|
||||
canvas.drawCircle(SkIntToScalar(w)/2, SkIntToScalar(h)/2,
|
||||
SkIntToScalar(std::min(w, h))*3/8, p);
|
||||
|
||||
SkRect r;
|
||||
r.setWH(SkIntToScalar(w), SkIntToScalar(h));
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
p.setStrokeWidth(SkIntToScalar(4));
|
||||
p.setColor(SK_ColorBLUE);
|
||||
canvas.drawRect(r, p);
|
||||
}
|
||||
|
||||
private:
|
||||
using INHERITED = Benchmark;
|
||||
};
|
||||
|
||||
/** Explicitly invoke some filter types to improve coverage of acceleration
|
||||
procs. */
|
||||
|
||||
enum Flags {
|
||||
kScale_Flag = 1 << 0,
|
||||
kRotate_Flag = 1 << 1,
|
||||
kBilerp_Flag = 1 << 2,
|
||||
kBicubic_Flag = 1 << 3,
|
||||
};
|
||||
|
||||
static bool isBilerp(uint32_t flags) {
|
||||
return (flags & (kBilerp_Flag | kBicubic_Flag)) == (kBilerp_Flag);
|
||||
}
|
||||
|
||||
static bool isBicubic(uint32_t flags) {
|
||||
return (flags & (kBilerp_Flag | kBicubic_Flag)) == (kBilerp_Flag | kBicubic_Flag);
|
||||
}
|
||||
|
||||
class FilterBitmapBench : public BitmapBench {
|
||||
uint32_t fFlags;
|
||||
SkString fFullName;
|
||||
public:
|
||||
FilterBitmapBench(SkColorType ct, SkAlphaType at, bool forceUpdate, uint32_t flags)
|
||||
: INHERITED(ct, at, forceUpdate, false)
|
||||
, fFlags(flags) {
|
||||
}
|
||||
|
||||
protected:
|
||||
const char* onGetName() override {
|
||||
fFullName.set(INHERITED::onGetName());
|
||||
if (fFlags & kScale_Flag) {
|
||||
fFullName.append("_scale");
|
||||
}
|
||||
if (fFlags & kRotate_Flag) {
|
||||
fFullName.append("_rotate");
|
||||
}
|
||||
if (isBilerp(fFlags)) {
|
||||
fFullName.append("_bilerp");
|
||||
} else if (isBicubic(fFlags)) {
|
||||
fFullName.append("_bicubic");
|
||||
}
|
||||
|
||||
return fFullName.c_str();
|
||||
}
|
||||
|
||||
void onDraw(int loops, SkCanvas* canvas) override {
|
||||
SkISize dim = canvas->getBaseLayerSize();
|
||||
if (fFlags & kScale_Flag) {
|
||||
const SkScalar x = SkIntToScalar(dim.fWidth) / 2;
|
||||
const SkScalar y = SkIntToScalar(dim.fHeight) / 2;
|
||||
|
||||
canvas->translate(x, y);
|
||||
// just enough so we can't take the sprite case
|
||||
canvas->scale(1.1f, 1.1f);
|
||||
canvas->translate(-x, -y);
|
||||
}
|
||||
if (fFlags & kRotate_Flag) {
|
||||
const SkScalar x = SkIntToScalar(dim.fWidth) / 2;
|
||||
const SkScalar y = SkIntToScalar(dim.fHeight) / 2;
|
||||
canvas->rotate(SkIntToScalar(35), x, y);
|
||||
}
|
||||
INHERITED::onDraw(loops, canvas);
|
||||
}
|
||||
|
||||
void setupPaint(SkPaint* paint) override {
|
||||
this->INHERITED::setupPaint(paint);
|
||||
|
||||
int index = 0;
|
||||
if (fFlags & kBilerp_Flag) {
|
||||
index |= 1;
|
||||
}
|
||||
if (fFlags & kBicubic_Flag) {
|
||||
index |= 2;
|
||||
}
|
||||
static const SkFilterQuality gQualitys[] = {
|
||||
kNone_SkFilterQuality,
|
||||
kLow_SkFilterQuality,
|
||||
kMedium_SkFilterQuality,
|
||||
kHigh_SkFilterQuality
|
||||
};
|
||||
paint->setFilterQuality(gQualitys[index]);
|
||||
}
|
||||
|
||||
private:
|
||||
using INHERITED = BitmapBench;
|
||||
};
|
||||
|
||||
/** Verify optimizations that test source alpha values. */
|
||||
|
||||
class SourceAlphaBitmapBench : public BitmapBench {
|
||||
public:
|
||||
enum SourceAlpha { kOpaque_SourceAlpha, kTransparent_SourceAlpha,
|
||||
kTwoStripes_SourceAlpha, kThreeStripes_SourceAlpha};
|
||||
private:
|
||||
SkString fFullName;
|
||||
SourceAlpha fSourceAlpha;
|
||||
public:
|
||||
SourceAlphaBitmapBench(SourceAlpha alpha, SkColorType ct, bool forceUpdate = false)
|
||||
: INHERITED(ct, kPremul_SkAlphaType, forceUpdate, false)
|
||||
, fSourceAlpha(alpha) {
|
||||
}
|
||||
|
||||
protected:
|
||||
const char* onGetName() override {
|
||||
fFullName.set(INHERITED::onGetName());
|
||||
|
||||
if (fSourceAlpha == kOpaque_SourceAlpha) {
|
||||
fFullName.append("_source_opaque");
|
||||
} else if (fSourceAlpha == kTransparent_SourceAlpha) {
|
||||
fFullName.append("_source_transparent");
|
||||
} else if (fSourceAlpha == kTwoStripes_SourceAlpha) {
|
||||
fFullName.append("_source_stripes_two");
|
||||
} else if (fSourceAlpha == kThreeStripes_SourceAlpha) {
|
||||
fFullName.append("_source_stripes_three");
|
||||
}
|
||||
|
||||
return fFullName.c_str();
|
||||
}
|
||||
|
||||
void onDrawIntoBitmap(const SkBitmap& bm) override {
|
||||
const int w = bm.width();
|
||||
const int h = bm.height();
|
||||
|
||||
if (kOpaque_SourceAlpha == fSourceAlpha) {
|
||||
bm.eraseColor(SK_ColorBLACK);
|
||||
} else if (kTransparent_SourceAlpha == fSourceAlpha) {
|
||||
bm.eraseColor(0);
|
||||
} else if (kTwoStripes_SourceAlpha == fSourceAlpha) {
|
||||
bm.eraseColor(0);
|
||||
|
||||
SkCanvas canvas(bm);
|
||||
SkPaint p;
|
||||
p.setAntiAlias(false);
|
||||
p.setStyle(SkPaint::kFill_Style);
|
||||
p.setColor(SK_ColorRED);
|
||||
|
||||
// Draw red vertical stripes on transparent background
|
||||
SkRect r;
|
||||
for (int x = 0; x < w; x+=2)
|
||||
{
|
||||
r.setLTRB(SkIntToScalar(x), 0, SkIntToScalar(x+1), SkIntToScalar(h));
|
||||
canvas.drawRect(r, p);
|
||||
}
|
||||
|
||||
} else if (kThreeStripes_SourceAlpha == fSourceAlpha) {
|
||||
bm.eraseColor(0);
|
||||
|
||||
SkCanvas canvas(bm);
|
||||
SkPaint p;
|
||||
p.setAntiAlias(false);
|
||||
p.setStyle(SkPaint::kFill_Style);
|
||||
|
||||
// Draw vertical stripes on transparent background with a pattern
|
||||
// where the first pixel is fully transparent, the next is semi-transparent
|
||||
// and the third is fully opaque.
|
||||
SkRect r;
|
||||
for (int x = 0; x < w; x++)
|
||||
{
|
||||
if (x % 3 == 0) {
|
||||
continue; // Keep transparent
|
||||
} else if (x % 3 == 1) {
|
||||
p.setColor(SkColorSetARGB(127, 127, 127, 127)); // Semi-transparent
|
||||
} else if (x % 3 == 2) {
|
||||
p.setColor(SK_ColorRED); // Opaque
|
||||
}
|
||||
r.setLTRB(SkIntToScalar(x), 0, SkIntToScalar(x+1), SkIntToScalar(h));
|
||||
canvas.drawRect(r, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
using INHERITED = BitmapBench;
|
||||
};
|
||||
|
||||
DEF_BENCH( return new BitmapBench(kN32_SkColorType, kPremul_SkAlphaType, false, false); )
|
||||
DEF_BENCH( return new BitmapBench(kN32_SkColorType, kOpaque_SkAlphaType, false, false); )
|
||||
DEF_BENCH( return new BitmapBench(kN32_SkColorType, kOpaque_SkAlphaType, false, true); )
|
||||
DEF_BENCH( return new BitmapBench(kRGB_565_SkColorType, kOpaque_SkAlphaType, false, false); )
|
||||
DEF_BENCH( return new BitmapBench(kN32_SkColorType, kOpaque_SkAlphaType, true, false); )
|
||||
DEF_BENCH( return new BitmapBench(kN32_SkColorType, kOpaque_SkAlphaType, true, false); )
|
||||
|
||||
// scale filter -> S32_opaque_D32_filter_DX_{SSE2,SSSE3} and Fact9 is also for S32_D16_filter_DX_SSE2
|
||||
DEF_BENCH( return new FilterBitmapBench(kN32_SkColorType, kPremul_SkAlphaType, false, kScale_Flag | kBilerp_Flag); )
|
||||
DEF_BENCH( return new FilterBitmapBench(kN32_SkColorType, kOpaque_SkAlphaType, false, kScale_Flag | kBilerp_Flag); )
|
||||
DEF_BENCH( return new FilterBitmapBench(kN32_SkColorType, kOpaque_SkAlphaType, true, kScale_Flag | kBilerp_Flag); )
|
||||
DEF_BENCH( return new FilterBitmapBench(kN32_SkColorType, kOpaque_SkAlphaType, true, kScale_Flag | kBilerp_Flag); )
|
||||
|
||||
// The following two cases test the performance regression of b/70172912 .
|
||||
DEF_BENCH( return new FilterBitmapBench(kRGB_565_SkColorType, kOpaque_SkAlphaType, false, kScale_Flag | kBilerp_Flag); )
|
||||
DEF_BENCH( return new BitmapBench(kRGB_565_SkColorType, kOpaque_SkAlphaType, false, true); )
|
||||
|
||||
// scale rotate filter -> S32_opaque_D32_filter_DXDY_{SSE2,SSSE3}
|
||||
DEF_BENCH( return new FilterBitmapBench(kN32_SkColorType, kPremul_SkAlphaType, false, kScale_Flag | kRotate_Flag | kBilerp_Flag); )
|
||||
DEF_BENCH( return new FilterBitmapBench(kN32_SkColorType, kOpaque_SkAlphaType, false, kScale_Flag | kRotate_Flag | kBilerp_Flag); )
|
||||
DEF_BENCH( return new FilterBitmapBench(kN32_SkColorType, kOpaque_SkAlphaType, true, kScale_Flag | kRotate_Flag | kBilerp_Flag); )
|
||||
DEF_BENCH( return new FilterBitmapBench(kN32_SkColorType, kOpaque_SkAlphaType, true, kScale_Flag | kRotate_Flag | kBilerp_Flag); )
|
||||
|
||||
DEF_BENCH( return new FilterBitmapBench(kN32_SkColorType, kPremul_SkAlphaType, false, kScale_Flag | kBilerp_Flag | kBicubic_Flag); )
|
||||
DEF_BENCH( return new FilterBitmapBench(kN32_SkColorType, kPremul_SkAlphaType, false, kScale_Flag | kRotate_Flag | kBilerp_Flag | kBicubic_Flag); )
|
||||
|
||||
// source alpha tests -> S32A_Opaque_BlitRow32_{arm,neon}
|
||||
DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kOpaque_SourceAlpha, kN32_SkColorType); )
|
||||
DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kTransparent_SourceAlpha, kN32_SkColorType); )
|
||||
DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kTwoStripes_SourceAlpha, kN32_SkColorType); )
|
||||
DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kThreeStripes_SourceAlpha, kN32_SkColorType); )
|
@ -1,115 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011 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/SkPaint.h"
|
||||
#include "include/core/SkString.h"
|
||||
#include "include/private/SkTo.h"
|
||||
#include "include/utils/SkRandom.h"
|
||||
|
||||
static void draw_into_bitmap(const SkBitmap& bm) {
|
||||
const int w = bm.width();
|
||||
const int h = bm.height();
|
||||
|
||||
SkCanvas canvas(bm);
|
||||
SkPaint p;
|
||||
p.setAntiAlias(true);
|
||||
p.setColor(SK_ColorRED);
|
||||
canvas.drawCircle(SkIntToScalar(w)/2, SkIntToScalar(h)/2,
|
||||
SkIntToScalar(std::min(w, h))*3/8, p);
|
||||
|
||||
SkRect r;
|
||||
r.setWH(SkIntToScalar(w), SkIntToScalar(h));
|
||||
p.setStyle(SkPaint::kStroke_Style);
|
||||
p.setStrokeWidth(SkIntToScalar(4));
|
||||
p.setColor(SK_ColorBLUE);
|
||||
canvas.drawRect(r, p);
|
||||
}
|
||||
|
||||
/* Variants for bitmaprect
|
||||
src : entire bitmap, subset, fractional subset
|
||||
dst : same size as src, diff size
|
||||
paint : filter-p
|
||||
*/
|
||||
|
||||
class BitmapRectBench : public Benchmark {
|
||||
SkBitmap fBitmap;
|
||||
bool fSlightMatrix;
|
||||
uint8_t fAlpha;
|
||||
SkFilterQuality fFilterQuality;
|
||||
SkString fName;
|
||||
SkRect fSrcR, fDstR;
|
||||
|
||||
static const int kWidth = 128;
|
||||
static const int kHeight = 128;
|
||||
public:
|
||||
BitmapRectBench(U8CPU alpha, SkFilterQuality filterQuality,
|
||||
bool slightMatrix) {
|
||||
fAlpha = SkToU8(alpha);
|
||||
fFilterQuality = filterQuality;
|
||||
fSlightMatrix = slightMatrix;
|
||||
|
||||
fBitmap.setInfo(SkImageInfo::MakeN32Premul(kWidth, kHeight));
|
||||
}
|
||||
|
||||
protected:
|
||||
const char* onGetName() override {
|
||||
fName.printf("bitmaprect_%02X_%sfilter_%s",
|
||||
fAlpha,
|
||||
kNone_SkFilterQuality == fFilterQuality ? "no" : "",
|
||||
fSlightMatrix ? "trans" : "identity");
|
||||
return fName.c_str();
|
||||
}
|
||||
|
||||
void onDelayedSetup() override {
|
||||
fBitmap.allocPixels();
|
||||
fBitmap.setAlphaType(kOpaque_SkAlphaType);
|
||||
fBitmap.eraseColor(SK_ColorBLACK);
|
||||
draw_into_bitmap(fBitmap);
|
||||
|
||||
fSrcR.setWH(SkIntToScalar(kWidth), SkIntToScalar(kHeight));
|
||||
fDstR.setWH(SkIntToScalar(kWidth), SkIntToScalar(kHeight));
|
||||
|
||||
if (fSlightMatrix) {
|
||||
// want fractional translate
|
||||
fDstR.offset(SK_Scalar1 / 3, SK_Scalar1 * 5 / 7);
|
||||
// want enough to create a scale matrix, but not enough to scare
|
||||
// off our sniffer which tries to see if the matrix is "effectively"
|
||||
// translate-only.
|
||||
fDstR.fRight += SK_Scalar1 / (kWidth * 60);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void onDraw(int loops, SkCanvas* canvas) override {
|
||||
SkRandom rand;
|
||||
|
||||
SkPaint paint;
|
||||
this->setupPaint(&paint);
|
||||
paint.setFilterQuality(fFilterQuality);
|
||||
paint.setAlpha(fAlpha);
|
||||
|
||||
for (int i = 0; i < loops; i++) {
|
||||
canvas->drawBitmapRect(fBitmap, fSrcR, fDstR, &paint,
|
||||
SkCanvas::kStrict_SrcRectConstraint);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
using INHERITED = Benchmark;
|
||||
};
|
||||
|
||||
DEF_BENCH(return new BitmapRectBench(0xFF, kNone_SkFilterQuality, false))
|
||||
DEF_BENCH(return new BitmapRectBench(0x80, kNone_SkFilterQuality, false))
|
||||
DEF_BENCH(return new BitmapRectBench(0xFF, kLow_SkFilterQuality, false))
|
||||
DEF_BENCH(return new BitmapRectBench(0x80, kLow_SkFilterQuality, false))
|
||||
|
||||
DEF_BENCH(return new BitmapRectBench(0xFF, kNone_SkFilterQuality, true))
|
||||
DEF_BENCH(return new BitmapRectBench(0xFF, kLow_SkFilterQuality, true))
|
@ -34,7 +34,7 @@
|
||||
// of the source (not inset). This is intended to exercise blurring a smaller source bitmap to a
|
||||
// larger destination.
|
||||
|
||||
static SkBitmap make_checkerboard(int width, int height) {
|
||||
static sk_sp<SkImage> make_checkerboard(int width, int height) {
|
||||
SkBitmap bm;
|
||||
bm.allocN32Pixels(width, height);
|
||||
SkCanvas canvas(bm);
|
||||
@ -55,7 +55,7 @@ static SkBitmap make_checkerboard(int width, int height) {
|
||||
}
|
||||
}
|
||||
|
||||
return bm;
|
||||
return bm.asImage();
|
||||
}
|
||||
|
||||
class BlurImageFilterBench : public Benchmark {
|
||||
@ -92,8 +92,8 @@ protected:
|
||||
void onDraw(int loops, SkCanvas* canvas) override {
|
||||
static const int kX = 0;
|
||||
static const int kY = 0;
|
||||
const SkIRect bmpRect = SkIRect::MakeXYWH(kX, kY, fCheckerboard.width(),
|
||||
fCheckerboard.height());
|
||||
const SkIRect bmpRect = SkIRect::MakeXYWH(kX, kY, fCheckerboard->width(),
|
||||
fCheckerboard->height());
|
||||
const SkIRect bmpRectInset = bmpRect.makeInset(10, 10);
|
||||
|
||||
sk_sp<SkImageFilter> input = fIsExpanded
|
||||
@ -104,9 +104,10 @@ protected:
|
||||
fIsExpanded ? &bmpRect : fIsCropped ? &bmpRectInset : nullptr;
|
||||
SkPaint paint;
|
||||
paint.setImageFilter(SkImageFilters::Blur(fSigmaX, fSigmaY, std::move(input), crop));
|
||||
SkSamplingOptions sampling;
|
||||
|
||||
for (int i = 0; i < loops; i++) {
|
||||
canvas->drawBitmap(fCheckerboard, kX, kY, &paint);
|
||||
canvas->drawImage(fCheckerboard, kX, kY, sampling, &paint);
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,7 +118,7 @@ private:
|
||||
bool fIsCropped;
|
||||
bool fIsExpanded;
|
||||
bool fInitialized;
|
||||
SkBitmap fCheckerboard;
|
||||
sk_sp<SkImage> fCheckerboard;
|
||||
SkScalar fSigmaX, fSigmaY;
|
||||
using INHERITED = Benchmark;
|
||||
};
|
||||
|
@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 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/SkImage.h"
|
||||
#include "include/core/SkString.h"
|
||||
#include "include/core/SkSurface.h"
|
||||
#include "src/core/SkAutoPixmapStorage.h"
|
||||
|
||||
class CTConvertBench : public Benchmark {
|
||||
public:
|
||||
enum class Mode { kDrawBitmap, kReadPixels };
|
||||
|
||||
CTConvertBench(SkColorType from, SkColorType to, Mode m)
|
||||
: fName(SkStringPrintf("ctconvert_%d_%d_%s", from, to,
|
||||
m == Mode::kReadPixels ? "readpixels" : "drawbitmap"))
|
||||
, fFrom(from)
|
||||
, fTo(to)
|
||||
, fMode(m) {}
|
||||
|
||||
bool isSuitableFor(Backend backend) override {
|
||||
return backend == kNonRendering_Backend;
|
||||
}
|
||||
|
||||
protected:
|
||||
const char* onGetName() override {
|
||||
return fName.c_str();
|
||||
}
|
||||
|
||||
void onPreDraw(SkCanvas*) override {
|
||||
if (fSrc.addr()) return;
|
||||
|
||||
fSrc.alloc(SkImageInfo::Make(kBMSize, kBMSize, fFrom, kPremul_SkAlphaType));
|
||||
fSrc.erase(0x80808080);
|
||||
|
||||
fDst.alloc(SkImageInfo::Make(kBMSize, kBMSize, fTo , kPremul_SkAlphaType));
|
||||
|
||||
if (fMode == Mode::kDrawBitmap) {
|
||||
fSrcBM.installPixels(fSrc);
|
||||
fDstSurf = SkSurface::MakeRasterDirect(fDst.info(), fDst.writable_addr(),
|
||||
fDst.info().minRowBytes());
|
||||
}
|
||||
}
|
||||
|
||||
void onDraw(int loops, SkCanvas*) override {
|
||||
switch (fMode) {
|
||||
case Mode::kDrawBitmap: {
|
||||
SkPaint p;
|
||||
p.setBlendMode(SkBlendMode::kSrc);
|
||||
for (int i = 0; i < loops; ++i) {
|
||||
fDstSurf->getCanvas()->drawBitmap(fSrcBM, 0, 0, &p);
|
||||
}
|
||||
} break;
|
||||
case Mode::kReadPixels: {
|
||||
for (int i = 0; i < loops; ++i) {
|
||||
fSrc.readPixels(fDst);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr size_t kBMSize = 512;
|
||||
|
||||
const SkString fName;
|
||||
const SkColorType fFrom, fTo;
|
||||
const Mode fMode;
|
||||
|
||||
SkAutoPixmapStorage fSrc, fDst;
|
||||
SkBitmap fSrcBM;
|
||||
sk_sp<SkSurface> fDstSurf;
|
||||
|
||||
using INHERITED = Benchmark;
|
||||
};
|
||||
|
||||
DEF_BENCH( return new CTConvertBench(kRGBA_8888_SkColorType, kBGRA_8888_SkColorType,
|
||||
CTConvertBench::Mode::kDrawBitmap); )
|
||||
|
||||
DEF_BENCH( return new CTConvertBench(kRGBA_8888_SkColorType, kBGRA_8888_SkColorType,
|
||||
CTConvertBench::Mode::kReadPixels); )
|
||||
|
||||
DEF_BENCH( return new CTConvertBench(kRGBA_8888_SkColorType, kRGBA_8888_SkColorType,
|
||||
CTConvertBench::Mode::kDrawBitmap); )
|
||||
|
||||
DEF_BENCH( return new CTConvertBench(kRGBA_8888_SkColorType, kRGBA_8888_SkColorType,
|
||||
CTConvertBench::Mode::kReadPixels); )
|
@ -33,15 +33,14 @@ protected:
|
||||
void makeBitmap() {
|
||||
const int w = this->isSmall() ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE;
|
||||
const int h = this->isSmall() ? FILTER_HEIGHT_SMALL : FILTER_HEIGHT_LARGE;
|
||||
fBitmap.allocN32Pixels(w, h);
|
||||
SkCanvas canvas(fBitmap);
|
||||
canvas.clear(0x00000000);
|
||||
auto surf = SkSurface::MakeRasterN32Premul(w, h);
|
||||
SkPaint paint;
|
||||
paint.setColor(0xFF884422);
|
||||
|
||||
SkFont font;
|
||||
font.setSize(SkIntToScalar(96));
|
||||
canvas.drawSimpleText("g", 1, SkTextEncoding::kUTF8, SkIntToScalar(15), SkIntToScalar(55), font, paint);
|
||||
surf->getCanvas()->drawSimpleText("g", 1, SkTextEncoding::kUTF8, 15, 55, font, paint);
|
||||
fImage = surf->makeImageSnapshot();
|
||||
}
|
||||
|
||||
void makeCheckerboard() {
|
||||
@ -71,17 +70,14 @@ protected:
|
||||
|
||||
void drawClippedBitmap(SkCanvas* canvas, int x, int y, const SkPaint& paint) {
|
||||
canvas->save();
|
||||
canvas->clipRect(SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(y),
|
||||
SkIntToScalar(fBitmap.width()),
|
||||
SkIntToScalar(fBitmap.height())));
|
||||
canvas->drawBitmap(fBitmap, SkIntToScalar(x), SkIntToScalar(y), &paint);
|
||||
canvas->clipIRect(fImage->bounds().makeOffset(x, y));
|
||||
canvas->drawImage(fImage, SkIntToScalar(x), SkIntToScalar(y), &paint);
|
||||
canvas->restore();
|
||||
}
|
||||
|
||||
inline bool isSmall() const { return fIsSmall; }
|
||||
|
||||
SkBitmap fBitmap;
|
||||
sk_sp<SkImage> fCheckerboard;
|
||||
sk_sp<SkImage> fImage, fCheckerboard;
|
||||
|
||||
private:
|
||||
bool fInitialized;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "bench/Benchmark.h"
|
||||
#include "include/core/SkBitmap.h"
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkImage.h"
|
||||
#include "include/core/SkM44.h"
|
||||
#include "include/core/SkPaint.h"
|
||||
#include "include/core/SkShader.h"
|
||||
@ -140,7 +141,7 @@ protected:
|
||||
|
||||
SkPaint p2; // for drawVertices path
|
||||
p2.setColor(0xFF000000);
|
||||
p2.setShader(fAtlas.makeShader(SkSamplingOptions(SkFilterMode::kLinear)));
|
||||
p2.setShader(fAtlas->makeShader(SkSamplingOptions(SkFilterMode::kLinear)));
|
||||
|
||||
for (int i = 0; i < loops; ++i, ++fNumSaved) {
|
||||
if (0 == i % kNumBeforeClear) {
|
||||
@ -190,7 +191,8 @@ protected:
|
||||
canvas->concat(mat);
|
||||
if (fUseAtlas) {
|
||||
const int curCell = i % (kNumAtlasedX * kNumAtlasedY);
|
||||
SkIRect src = fAtlasRects[curCell % (kNumAtlasedX)][curCell / (kNumAtlasedX)];
|
||||
SkRect src = SkRect::Make(
|
||||
fAtlasRects[curCell % (kNumAtlasedX)][curCell / (kNumAtlasedX)]);
|
||||
|
||||
if (fUseDrawVertices) {
|
||||
SkPoint uvs[4] = {
|
||||
@ -203,11 +205,11 @@ protected:
|
||||
4, verts, uvs, nullptr, 6, indices),
|
||||
SkBlendMode::kModulate, p2);
|
||||
} else {
|
||||
canvas->drawBitmapRect(fAtlas, src, dst, &p,
|
||||
canvas->drawImageRect(fAtlas, src, dst, SkSamplingOptions(), &p,
|
||||
SkCanvas::kFast_SrcRectConstraint);
|
||||
}
|
||||
} else {
|
||||
canvas->drawBitmapRect(fCheckerboard, dst, &p);
|
||||
canvas->drawImageRect(fCheckerboard, dst, SkSamplingOptions(), &p);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -239,19 +241,19 @@ private:
|
||||
// 0 & 1 are always x & y translate. 2 is either scale or rotate.
|
||||
SkScalar fSaved[kNumBeforeClear][3];
|
||||
|
||||
SkBitmap fCheckerboard;
|
||||
SkBitmap fAtlas;
|
||||
sk_sp<SkImage> fCheckerboard, fAtlas;
|
||||
SkIRect fAtlasRects[kNumAtlasedX][kNumAtlasedY];
|
||||
|
||||
// Note: the resulting checker board has transparency
|
||||
void makeCheckerboard() {
|
||||
static int kCheckSize = 16;
|
||||
|
||||
fCheckerboard.allocN32Pixels(kCheckerboardWidth, kCheckerboardHeight);
|
||||
SkBitmap bm;
|
||||
bm.allocN32Pixels(kCheckerboardWidth, kCheckerboardHeight);
|
||||
for (int y = 0; y < kCheckerboardHeight; ++y) {
|
||||
int even = (y / kCheckSize) % 2;
|
||||
|
||||
SkPMColor* scanline = fCheckerboard.getAddr32(0, y);
|
||||
SkPMColor* scanline = bm.getAddr32(0, y);
|
||||
|
||||
for (int x = 0; x < kCheckerboardWidth; ++x) {
|
||||
if (even == (x / kCheckSize) % 2) {
|
||||
@ -261,6 +263,7 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
fCheckerboard = bm.asImage();
|
||||
}
|
||||
|
||||
// Note: the resulting atlas has transparency
|
||||
@ -279,13 +282,14 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
fAtlas.allocN32Pixels(kTotAtlasWidth, kTotAtlasHeight);
|
||||
SkBitmap bm;
|
||||
bm.allocN32Pixels(kTotAtlasWidth, kTotAtlasHeight);
|
||||
|
||||
for (int y = 0; y < kTotAtlasHeight; ++y) {
|
||||
int colorY = y / (kAtlasCellHeight + kAtlasSpacer);
|
||||
bool inColorY = (y % (kAtlasCellHeight + kAtlasSpacer)) >= kAtlasSpacer;
|
||||
|
||||
SkPMColor* scanline = fAtlas.getAddr32(0, y);
|
||||
SkPMColor* scanline = bm.getAddr32(0, y);
|
||||
|
||||
for (int x = 0; x < kTotAtlasWidth; ++x, ++scanline) {
|
||||
int colorX = x / (kAtlasCellWidth + kAtlasSpacer);
|
||||
@ -299,6 +303,7 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
fAtlas = bm.asImage();
|
||||
}
|
||||
|
||||
using INHERITED = Benchmark;
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "include/core/SkBitmap.h"
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkImageFilter.h"
|
||||
#include "include/core/SkSurface.h"
|
||||
#include "include/effects/SkColorMatrixFilter.h"
|
||||
#include "include/effects/SkGradientShader.h"
|
||||
#include "include/effects/SkImageFilters.h"
|
||||
@ -40,21 +41,19 @@ protected:
|
||||
for(int i = 0; i < loops; i++) {
|
||||
SkPaint paint;
|
||||
paint.setImageFilter(fImageFilter);
|
||||
canvas->drawBitmap(fBitmap, 0, 0, &paint);
|
||||
canvas->drawImage(fImage, 0, 0, SkSamplingOptions(), &paint);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
sk_sp<SkImageFilter> fImageFilter;
|
||||
SkBitmap fBitmap;
|
||||
sk_sp<SkImage> fImage;
|
||||
|
||||
void makeBitmap() {
|
||||
int W = 400;
|
||||
int H = 400;
|
||||
fBitmap.allocN32Pixels(W, H);
|
||||
fBitmap.eraseColor(SK_ColorTRANSPARENT);
|
||||
auto surf = SkSurface::MakeRasterN32Premul(W, H);
|
||||
|
||||
SkCanvas canvas(fBitmap);
|
||||
SkPaint paint;
|
||||
SkPoint pts[] = { {0, 0}, {SkIntToScalar(W), SkIntToScalar(H)} };
|
||||
SkColor colors[] = {
|
||||
@ -63,7 +62,8 @@ private:
|
||||
};
|
||||
paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
|
||||
SkTileMode::kClamp));
|
||||
canvas.drawPaint(paint);
|
||||
surf->getCanvas()->drawPaint(paint);
|
||||
fImage = surf->makeImageSnapshot(); // shader->makeImage()
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,86 +0,0 @@
|
||||
/*
|
||||
* 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/effects/SkImageFilters.h"
|
||||
#include "include/utils/SkRandom.h"
|
||||
|
||||
#define FILTER_WIDTH_SMALL 32
|
||||
#define FILTER_HEIGHT_SMALL 32
|
||||
#define FILTER_WIDTH_LARGE 256
|
||||
#define FILTER_HEIGHT_LARGE 256
|
||||
|
||||
class MagnifierBench : public Benchmark {
|
||||
public:
|
||||
MagnifierBench(bool small) :
|
||||
fIsSmall(small), fInitialized(false) {
|
||||
}
|
||||
|
||||
protected:
|
||||
const char* onGetName() override {
|
||||
return fIsSmall ? "magnifier_small" : "magnifier_large";
|
||||
}
|
||||
|
||||
void onDelayedSetup() override {
|
||||
if (!fInitialized) {
|
||||
make_checkerboard();
|
||||
fInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
void onDraw(int loops, SkCanvas* canvas) override {
|
||||
const int w = fIsSmall ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE;
|
||||
const int h = fIsSmall ? FILTER_HEIGHT_SMALL : FILTER_HEIGHT_LARGE;
|
||||
SkPaint paint;
|
||||
paint.setImageFilter(
|
||||
SkImageFilters::Magnifier(
|
||||
SkRect::MakeXYWH(SkIntToScalar(w / 4),
|
||||
SkIntToScalar(h / 4),
|
||||
SkIntToScalar(w / 2),
|
||||
SkIntToScalar(h / 2)), 100, nullptr));
|
||||
|
||||
for (int i = 0; i < loops; i++) {
|
||||
canvas->drawBitmap(fCheckerboard, 0, 0, &paint);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void make_checkerboard() {
|
||||
const int w = fIsSmall ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE;
|
||||
const int h = fIsSmall ? FILTER_HEIGHT_SMALL : FILTER_HEIGHT_LARGE;
|
||||
fCheckerboard.allocN32Pixels(w, h);
|
||||
SkCanvas canvas(fCheckerboard);
|
||||
canvas.clear(0x00000000);
|
||||
SkPaint darkPaint;
|
||||
darkPaint.setColor(0xFF804020);
|
||||
SkPaint lightPaint;
|
||||
lightPaint.setColor(0xFF244484);
|
||||
for (int y = 0; y < h; y += 16) {
|
||||
for (int x = 0; x < w; x += 16) {
|
||||
canvas.save();
|
||||
canvas.translate(SkIntToScalar(x), SkIntToScalar(y));
|
||||
canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint);
|
||||
canvas.drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint);
|
||||
canvas.drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint);
|
||||
canvas.drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint);
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool fIsSmall;
|
||||
bool fInitialized;
|
||||
SkBitmap fCheckerboard;
|
||||
using INHERITED = Benchmark;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DEF_BENCH( return new MagnifierBench(true); )
|
||||
DEF_BENCH( return new MagnifierBench(false); )
|
@ -82,8 +82,6 @@ inline T make_fuzz_t(Fuzz* fuzz) {
|
||||
|
||||
static sk_sp<SkImage> make_fuzz_image(Fuzz*);
|
||||
|
||||
static SkBitmap make_fuzz_bitmap(Fuzz*);
|
||||
|
||||
static sk_sp<SkPicture> make_fuzz_picture(Fuzz*, int depth);
|
||||
|
||||
static sk_sp<SkColorFilter> make_fuzz_colorfilter(Fuzz* fuzz, int depth) {
|
||||
@ -202,15 +200,6 @@ static sk_sp<SkShader> make_fuzz_shader(Fuzz* fuzz, int depth) {
|
||||
FuzzNiceMatrix(fuzz, &matrix);
|
||||
}
|
||||
return img->makeShader(tmX, tmY, SkSamplingOptions(), useMatrix ? &matrix : nullptr);
|
||||
case 4:
|
||||
bitmap = make_fuzz_bitmap(fuzz);
|
||||
fuzz->nextEnum(&tmX, SkTileMode::kLastTileMode);
|
||||
fuzz->nextEnum(&tmY, SkTileMode::kLastTileMode);
|
||||
fuzz->next(&useMatrix);
|
||||
if (useMatrix) {
|
||||
FuzzNiceMatrix(fuzz, &matrix);
|
||||
}
|
||||
return bitmap.makeShader(tmX, tmY, SkSamplingOptions(), useMatrix ? &matrix : nullptr);
|
||||
case 5:
|
||||
shader1 = make_fuzz_shader(fuzz, depth - 1); // limit recursion.
|
||||
FuzzNiceMatrix(fuzz, &matrix);
|
||||
@ -822,25 +811,6 @@ static sk_sp<SkImage> make_fuzz_image(Fuzz* fuzz) {
|
||||
nullptr);
|
||||
}
|
||||
|
||||
static SkBitmap make_fuzz_bitmap(Fuzz* fuzz) {
|
||||
SkBitmap bitmap;
|
||||
int w, h;
|
||||
fuzz->nextRange(&w, 1, 1024);
|
||||
fuzz->nextRange(&h, 1, 1024);
|
||||
if (!bitmap.tryAllocN32Pixels(w, h)) {
|
||||
SkDEBUGF("Could not allocate pixels %d x %d", w, h);
|
||||
return bitmap;
|
||||
}
|
||||
for (int y = 0; y < h; ++y) {
|
||||
for (int x = 0; x < w; ++x) {
|
||||
SkColor c;
|
||||
fuzz->next(&c);
|
||||
*bitmap.getAddr32(x, y) = SkPreMultiplyColor(c);
|
||||
}
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static T make_fuzz_enum_range(Fuzz* fuzz, T maxv) {
|
||||
T value;
|
||||
@ -1323,66 +1293,6 @@ static void fuzz_canvas(Fuzz* fuzz, SkCanvas* canvas, int depth = 9) {
|
||||
canvas->drawImageNine(img, center, dst, usePaint ? &paint : nullptr);
|
||||
break;
|
||||
}
|
||||
case 38: {
|
||||
SkBitmap bitmap = make_fuzz_bitmap(fuzz);
|
||||
SkScalar left, top;
|
||||
bool usePaint;
|
||||
fuzz->next(&left, &top, &usePaint);
|
||||
if (usePaint) {
|
||||
fuzz_paint(fuzz, &paint, depth - 1);
|
||||
}
|
||||
canvas->drawBitmap(bitmap, left, top, usePaint ? &paint : nullptr);
|
||||
break;
|
||||
}
|
||||
case 39: {
|
||||
SkBitmap bitmap = make_fuzz_bitmap(fuzz);
|
||||
SkRect src, dst;
|
||||
bool usePaint;
|
||||
fuzz->next(&src, &dst, &usePaint);
|
||||
if (usePaint) {
|
||||
fuzz_paint(fuzz, &paint, depth - 1);
|
||||
}
|
||||
SkCanvas::SrcRectConstraint constraint =
|
||||
make_fuzz_t<bool>(fuzz) ? SkCanvas::kStrict_SrcRectConstraint
|
||||
: SkCanvas::kFast_SrcRectConstraint;
|
||||
canvas->drawBitmapRect(bitmap, src, dst, usePaint ? &paint : nullptr, constraint);
|
||||
break;
|
||||
}
|
||||
case 40: {
|
||||
SkBitmap img = make_fuzz_bitmap(fuzz);
|
||||
SkIRect src;
|
||||
SkRect dst;
|
||||
bool usePaint;
|
||||
fuzz->next(&src, &dst, &usePaint);
|
||||
if (usePaint) {
|
||||
fuzz_paint(fuzz, &paint, depth - 1);
|
||||
}
|
||||
SkCanvas::SrcRectConstraint constraint =
|
||||
make_fuzz_t<bool>(fuzz) ? SkCanvas::kStrict_SrcRectConstraint
|
||||
: SkCanvas::kFast_SrcRectConstraint;
|
||||
canvas->drawBitmapRect(img, src, dst, usePaint ? &paint : nullptr, constraint);
|
||||
break;
|
||||
}
|
||||
case 41: {
|
||||
SkBitmap img = make_fuzz_bitmap(fuzz);
|
||||
SkRect dst;
|
||||
bool usePaint;
|
||||
fuzz->next(&dst, &usePaint);
|
||||
if (usePaint) {
|
||||
fuzz_paint(fuzz, &paint, depth - 1);
|
||||
}
|
||||
SkCanvas::SrcRectConstraint constraint =
|
||||
make_fuzz_t<bool>(fuzz) ? SkCanvas::kStrict_SrcRectConstraint
|
||||
: SkCanvas::kFast_SrcRectConstraint;
|
||||
canvas->drawBitmapRect(img, dst, usePaint ? &paint : nullptr, constraint);
|
||||
break;
|
||||
}
|
||||
case 42: {
|
||||
break;
|
||||
}
|
||||
case 43: {
|
||||
break;
|
||||
}
|
||||
case 44: {
|
||||
auto img = make_fuzz_image(fuzz);
|
||||
bool usePaint;
|
||||
|
@ -250,19 +250,6 @@ static void fuzz_drawPath(Fuzz* fuzz) {
|
||||
cnv->clipPath(path, kIntersect_SkClipOp, bl);
|
||||
}
|
||||
|
||||
static void fuzz_drawBitmap(Fuzz* fuzz) {
|
||||
SkPaint p;
|
||||
init_paint(fuzz, &p);
|
||||
sk_sp<SkSurface> surface;
|
||||
init_surface(fuzz, &surface);
|
||||
SkBitmap bmp;
|
||||
init_bitmap(fuzz, &bmp);
|
||||
|
||||
SkScalar a, b;
|
||||
fuzz->next(&a, &b);
|
||||
surface->getCanvas()->drawBitmap(bmp, a, b, &p);
|
||||
}
|
||||
|
||||
static void fuzz_drawImage(Fuzz* fuzz) {
|
||||
SkPaint p;
|
||||
init_paint(fuzz, &p);
|
||||
@ -336,10 +323,6 @@ DEF_FUZZ(DrawFunctions, fuzz) {
|
||||
fuzz_drawImage(fuzz);
|
||||
return;
|
||||
case 6:
|
||||
SkDEBUGF("Fuzz DrawBitmap\n");
|
||||
fuzz_drawBitmap(fuzz);
|
||||
return;
|
||||
case 7:
|
||||
SkDEBUGF("Fuzz DrawPaint\n");
|
||||
fuzz_drawPaint(fuzz);
|
||||
return;
|
||||
|
@ -46,7 +46,7 @@ bool FuzzAndroidCodec(sk_sp<SkData> bytes, uint8_t sampleSize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
surface->getCanvas()->drawBitmap(bm, 0, 0);
|
||||
surface->getCanvas()->drawImage(bm.asImage(), 0, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "include/core/SkBitmap.h"
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkData.h"
|
||||
#include "include/core/SkImage.h"
|
||||
#include "include/core/SkImageFilter.h"
|
||||
#include "include/core/SkPaint.h"
|
||||
#include "src/core/SkFontMgrPriv.h"
|
||||
@ -28,12 +29,11 @@ void FuzzImageFilterDeserialize(sk_sp<SkData> bytes) {
|
||||
SkPaint paint;
|
||||
paint.setImageFilter(flattenable);
|
||||
canvas.save();
|
||||
canvas.clipRect(SkRect::MakeXYWH(
|
||||
0, 0, SkIntToScalar(BitmapSize), SkIntToScalar(BitmapSize)));
|
||||
canvas.clipIRect(bitmap.bounds());
|
||||
|
||||
// This call shouldn't crash or cause ASAN to flag any memory issues
|
||||
// If nothing bad happens within this call, everything is fine
|
||||
canvas.drawBitmap(bitmap, 0, 0, &paint);
|
||||
canvas.drawImage(bitmap.asImage(), 0, 0, SkSamplingOptions(), &paint);
|
||||
|
||||
canvas.restore();
|
||||
}
|
||||
|
@ -14,8 +14,6 @@ bench_sources = [
|
||||
"$_bench/Benchmark.cpp",
|
||||
"$_bench/BezierBench.cpp",
|
||||
"$_bench/BigPathBench.cpp",
|
||||
"$_bench/BitmapBench.cpp",
|
||||
"$_bench/BitmapRectBench.cpp",
|
||||
"$_bench/BitmapRegionDecoderBench.cpp",
|
||||
"$_bench/BlendmodeBench.cpp",
|
||||
"$_bench/BlurBench.cpp",
|
||||
@ -23,7 +21,6 @@ bench_sources = [
|
||||
"$_bench/BlurRectBench.cpp",
|
||||
"$_bench/BlurRectsBench.cpp",
|
||||
"$_bench/BulkRectBench.cpp",
|
||||
"$_bench/CTConvertBench.cpp",
|
||||
"$_bench/ChartBench.cpp",
|
||||
"$_bench/ChecksumBench.cpp",
|
||||
"$_bench/ChromeBench.cpp",
|
||||
@ -71,7 +68,6 @@ bench_sources = [
|
||||
"$_bench/JSONBench.cpp",
|
||||
"$_bench/LightingBench.cpp",
|
||||
"$_bench/LineBench.cpp",
|
||||
"$_bench/MagnifierBench.cpp",
|
||||
"$_bench/MathBench.cpp",
|
||||
"$_bench/Matrix44Bench.cpp",
|
||||
"$_bench/MatrixBench.cpp",
|
||||
|
@ -109,6 +109,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ApplyGamma, reporter, ctxInfo) {
|
||||
|
||||
SkBitmap bm;
|
||||
bm.installPixels(ii, srcPixels.get(), kRowBytes);
|
||||
auto img = bm.asImage();
|
||||
|
||||
SkAutoTMalloc<uint32_t> read(kBaseSize.area());
|
||||
|
||||
@ -133,7 +134,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ApplyGamma, reporter, ctxInfo) {
|
||||
gammaPaint.setColorFilter(toSRGB ? SkColorFilters::LinearToSRGBGamma()
|
||||
: SkColorFilters::SRGBToLinearGamma());
|
||||
|
||||
dstCanvas->drawBitmap(bm, 0, 0, &gammaPaint);
|
||||
dstCanvas->drawImage(img, 0, 0, SkSamplingOptions(), &gammaPaint);
|
||||
dst->flushAndSubmit();
|
||||
|
||||
sk_memset32(read.get(), 0, kBaseSize.fWidth * kBaseSize.fHeight);
|
||||
|
@ -1315,7 +1315,7 @@ static void test_huge_blur(SkCanvas* canvas, skiatest::Reporter* reporter) {
|
||||
// Check that a blur with a very large radius does not crash or assert.
|
||||
SkPaint paint;
|
||||
paint.setImageFilter(SkImageFilters::Blur(SkIntToScalar(1<<30), SkIntToScalar(1<<30), nullptr));
|
||||
canvas->drawBitmap(bitmap, 0, 0, &paint);
|
||||
canvas->drawImage(bitmap.asImage(), 0, 0, SkSamplingOptions(), &paint);
|
||||
}
|
||||
|
||||
DEF_TEST(HugeBlurImageFilter, reporter) {
|
||||
|
Loading…
Reference in New Issue
Block a user