Remove work from constructors to facilitate debugging.
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1562093002 Review URL: https://codereview.chromium.org/1562093002
This commit is contained in:
parent
cdee009886
commit
b10fe4941b
@ -22,24 +22,9 @@
|
||||
// This GM mimics a blurred RR seen in the wild.
|
||||
class BlurRoundRectGM : public skiagm::GM {
|
||||
public:
|
||||
BlurRoundRectGM(int width, int height, int radius)
|
||||
: fName("blurroundrect")
|
||||
{
|
||||
SkRect r = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
|
||||
fRRect.setRectXY(r, SkIntToScalar(radius), SkIntToScalar(radius));
|
||||
fName.appendf("-WH-%ix%i-corner-%i", width, height, radius);
|
||||
}
|
||||
|
||||
BlurRoundRectGM(int width, int height)
|
||||
: fName("blurroundrect") {
|
||||
: fName("blurroundrect"), fWidth(width), fHeight(height) {
|
||||
fName.appendf("-WH-%ix%i-unevenCorners", width, height);
|
||||
SkVector radii[4];
|
||||
radii[0].set(SkIntToScalar(30), SkIntToScalar(30));
|
||||
radii[1].set(SkIntToScalar(10), SkIntToScalar(10));
|
||||
radii[2].set(SkIntToScalar(30), SkIntToScalar(30));
|
||||
radii[3].set(SkIntToScalar(10), SkIntToScalar(10));
|
||||
SkRect r = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
|
||||
fRRect.setRectRadii(r, radii);
|
||||
}
|
||||
|
||||
SkString onShortName() override {
|
||||
@ -47,8 +32,17 @@ public:
|
||||
}
|
||||
|
||||
SkISize onISize() override {
|
||||
return SkISize::Make(SkScalarCeilToInt(fRRect.rect().width()),
|
||||
SkScalarCeilToInt(fRRect.rect().height()));
|
||||
return SkISize::Make(fWidth, fHeight);
|
||||
}
|
||||
|
||||
void onOnceBeforeDraw() override {
|
||||
SkVector radii[4];
|
||||
radii[0].set(SkIntToScalar(30), SkIntToScalar(30));
|
||||
radii[1].set(SkIntToScalar(10), SkIntToScalar(10));
|
||||
radii[2].set(SkIntToScalar(30), SkIntToScalar(30));
|
||||
radii[3].set(SkIntToScalar(10), SkIntToScalar(10));
|
||||
SkRect r = SkRect::MakeWH(SkIntToScalar(fWidth), SkIntToScalar(fHeight));
|
||||
fRRect.setRectRadii(r, radii);
|
||||
}
|
||||
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
@ -89,6 +83,7 @@ public:
|
||||
private:
|
||||
SkString fName;
|
||||
SkRRect fRRect;
|
||||
int fWidth, fHeight;
|
||||
|
||||
typedef skiagm::GM INHERITED;
|
||||
};
|
||||
|
@ -162,13 +162,14 @@ static SkShader* make_linear_gradient_shader(int length) {
|
||||
|
||||
class ComposeShaderBitmapGM : public skiagm::GM {
|
||||
public:
|
||||
ComposeShaderBitmapGM()
|
||||
: fColorBitmapShader(nullptr)
|
||||
, fAlpha8BitmapShader(nullptr)
|
||||
, fLinearGradientShader(nullptr)
|
||||
{
|
||||
ComposeShaderBitmapGM() {}
|
||||
~ComposeShaderBitmapGM() {
|
||||
SkSafeUnref(fColorBitmapShader);
|
||||
SkSafeUnref(fAlpha8BitmapShader);
|
||||
SkSafeUnref(fLinearGradientShader);
|
||||
}
|
||||
|
||||
protected:
|
||||
void onOnceBeforeDraw() override {
|
||||
draw_color_bm(&fColorBitmap, squareLength);
|
||||
draw_alpha8_bm(&fAlpha8Bitmap, squareLength);
|
||||
@ -181,13 +182,6 @@ public:
|
||||
fLinearGradientShader = make_linear_gradient_shader(squareLength);
|
||||
}
|
||||
|
||||
~ComposeShaderBitmapGM() {
|
||||
SkSafeUnref(fColorBitmapShader);
|
||||
SkSafeUnref(fAlpha8BitmapShader);
|
||||
SkSafeUnref(fLinearGradientShader);
|
||||
}
|
||||
|
||||
protected:
|
||||
SkString onShortName() override {
|
||||
return SkString("composeshader_bitmap");
|
||||
}
|
||||
@ -230,6 +224,7 @@ protected:
|
||||
canvas->translate(0, r.height() + 5);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
/** This determines the length and width of the bitmaps used in the SkComposeShaders. Values
|
||||
* above 20 may cause an SkASSERT to fail in SkSmallAllocator. However, larger values will
|
||||
@ -240,9 +235,9 @@ private:
|
||||
|
||||
SkBitmap fColorBitmap;
|
||||
SkBitmap fAlpha8Bitmap;
|
||||
SkShader* fColorBitmapShader;
|
||||
SkShader* fAlpha8BitmapShader;
|
||||
SkShader* fLinearGradientShader;
|
||||
SkShader* fColorBitmapShader{nullptr};
|
||||
SkShader* fAlpha8BitmapShader{nullptr};
|
||||
SkShader* fLinearGradientShader{nullptr};
|
||||
|
||||
typedef GM INHERITED;
|
||||
};
|
||||
|
@ -26,12 +26,15 @@ public:
|
||||
kAA_Clip_Type,
|
||||
kEffect_Type,
|
||||
};
|
||||
RRectGM(Type type) : fType(type) {
|
||||
RRectGM(Type type) : fType(type) { }
|
||||
|
||||
protected:
|
||||
|
||||
void onOnceBeforeDraw() override {
|
||||
this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
|
||||
this->setUpRRects();
|
||||
}
|
||||
|
||||
protected:
|
||||
SkString onShortName() override {
|
||||
SkString name("rrect");
|
||||
switch (fType) {
|
||||
|
Loading…
Reference in New Issue
Block a user