optimize circularclips to act as a bench, fix null-check bug in etcbench
BUG=skia: R=krajcevski@google.com, rmistry@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/345183003
This commit is contained in:
parent
9ac68ee259
commit
bbf3e8982d
@ -210,8 +210,11 @@ protected:
|
||||
}
|
||||
|
||||
virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
|
||||
SkPixelRef* pr = fBitmap.pixelRef();
|
||||
for (int i = 0; i < loops; ++i) {
|
||||
this->fBitmap.pixelRef()->notifyPixelsChanged();
|
||||
if (pr) {
|
||||
pr->notifyPixelsChanged();
|
||||
}
|
||||
canvas->drawBitmap(this->fBitmap, 0, 0, NULL);
|
||||
}
|
||||
}
|
||||
|
@ -9,15 +9,24 @@
|
||||
#include "SkCanvas.h"
|
||||
#include "SkPath.h"
|
||||
|
||||
namespace skiagm {
|
||||
class CircularClipsGM : public skiagm::GM {
|
||||
SkScalar fX1, fX2, fY, fR;
|
||||
SkPath fCircle1, fCircle2;
|
||||
|
||||
class CircularClipsGM : public GM {
|
||||
public:
|
||||
CircularClipsGM() {}
|
||||
CircularClipsGM() {
|
||||
fX1 = 80;
|
||||
fX2 = 120;
|
||||
fY = 50;
|
||||
fR = 40;
|
||||
|
||||
fCircle1.addCircle(fX1, fY, fR, SkPath::kCW_Direction);
|
||||
fCircle2.addCircle(fX2, fY, fR, SkPath::kCW_Direction);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual uint32_t onGetFlags() const SK_OVERRIDE {
|
||||
return kSkipTiled_Flag;
|
||||
return kSkipTiled_Flag | kAsBench_Flag;
|
||||
}
|
||||
|
||||
virtual SkString onShortName() {
|
||||
@ -38,45 +47,37 @@ protected:
|
||||
SkRegion::kReplace_Op,
|
||||
};
|
||||
|
||||
SkScalar x1 = 80, x2 = 120;
|
||||
SkScalar y = 50;
|
||||
SkScalar r = 40;
|
||||
|
||||
SkPath circle1, circle2;
|
||||
circle1.addCircle(x1, y, r, SkPath::kCW_Direction);
|
||||
circle2.addCircle(x2, y, r, SkPath::kCW_Direction);
|
||||
SkRect rect = SkRect::MakeLTRB(x1 - r, y - r, x2 + r, y + r);
|
||||
SkRect rect = SkRect::MakeLTRB(fX1 - fR, fY - fR, fX2 + fR, fY + fR);
|
||||
|
||||
SkPaint fillPaint;
|
||||
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
circle1.toggleInverseFillType();
|
||||
fCircle1.toggleInverseFillType();
|
||||
if (i % 2 == 0) {
|
||||
circle2.toggleInverseFillType();
|
||||
fCircle2.toggleInverseFillType();
|
||||
}
|
||||
|
||||
canvas->save();
|
||||
for (size_t op = 0; op < SK_ARRAY_COUNT(ops); op++) {
|
||||
canvas->save();
|
||||
|
||||
canvas->clipPath(circle1, SkRegion::kReplace_Op);
|
||||
canvas->clipPath(circle2, ops[op]);
|
||||
canvas->clipPath(fCircle1, SkRegion::kReplace_Op);
|
||||
canvas->clipPath(fCircle2, ops[op]);
|
||||
|
||||
canvas->drawRect(rect, fillPaint);
|
||||
|
||||
canvas->restore();
|
||||
canvas->translate(0, 2 * y);
|
||||
canvas->translate(0, 2 * fY);
|
||||
}
|
||||
canvas->restore();
|
||||
canvas->translate(x1 + x2, 0);
|
||||
canvas->translate(fX1 + fX2, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
typedef GM INHERITED;
|
||||
typedef skiagm::GM INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DEF_GM( return new CircularClipsGM; )
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user