Remove GM::onDrawBackground

Bug: skia:8731
Change-Id: Ied8f3035eff1c37dd4b785f850f95a8c56a8a67b
Reviewed-on: https://skia-review.googlesource.com/c/188632
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
This commit is contained in:
Chris Dalton 2019-02-01 12:15:42 -07:00 committed by Skia Commit-Bot
parent b45f47dc3e
commit 21ca3702f8
4 changed files with 10 additions and 25 deletions

View File

@ -99,17 +99,6 @@ private:
return SkISize::Make(640, 480);
}
void onDrawBackground(SkCanvas* canvas) override {
canvas->clear(SK_ColorWHITE);
if (this->initCodec()) {
SkAutoCanvasRestore acr(canvas, true);
for (int frameIndex = 0; frameIndex < fTotalFrames; frameIndex++) {
this->drawFrame(canvas, frameIndex);
canvas->translate(SkIntToScalar(fCodec->getInfo().width()), 0);
}
}
}
bool initCodec() {
if (fCodec) {
return true;
@ -137,12 +126,19 @@ private:
}
void onDraw(SkCanvas* canvas) override {
if (!fCodec) {
if (!this->initCodec()) {
SkString errorText = SkStringPrintf("Nothing to draw; %s", FLAGS_animatedGif[0]);
error(canvas, errorText);
return;
}
canvas->save();
for (int frameIndex = 0; frameIndex < fTotalFrames; frameIndex++) {
this->drawFrame(canvas, frameIndex);
canvas->translate(SkIntToScalar(fCodec->getInfo().width()), 0);
}
canvas->restore();
SkAutoCanvasRestore acr(canvas, true);
canvas->translate(0, SkIntToScalar(fCodec->getInfo().height()));
this->drawFrame(canvas, fFrame);

View File

@ -43,7 +43,7 @@ void GM::drawBackground(SkCanvas* canvas) {
this->onOnceBeforeDraw();
}
SkAutoCanvasRestore acr(canvas, true);
this->onDrawBackground(canvas);
canvas->drawColor(fBGColor, SkBlendMode::kSrc);
}
const char* GM::getName() {
@ -63,10 +63,6 @@ bool GM::animate(const SkAnimTimer& timer) {
/////////////////////////////////////////////////////////////////////////////////////////////
void GM::onDrawBackground(SkCanvas* canvas) {
canvas->drawColor(fBGColor, SkBlendMode::kSrc);
}
void GM::drawSizeBounds(SkCanvas* canvas, SkColor color) {
SkISize size = this->getISize();
SkRect r = SkRect::MakeWH(SkIntToScalar(size.width()),

View File

@ -102,7 +102,6 @@ namespace skiagm {
protected:
virtual void onOnceBeforeDraw() {}
virtual void onDraw(SkCanvas*) = 0;
virtual void onDrawBackground(SkCanvas*);
virtual SkISize onISize() = 0;
virtual SkString onShortName() = 0;

View File

@ -23,7 +23,7 @@ namespace skiagm {
*/
class Xfermodes3GM : public GM {
public:
Xfermodes3GM() {}
Xfermodes3GM() { this->setBGColor(sk_tool_utils::color_to_565(0xFF70D0E0)); }
protected:
SkString onShortName() override {
@ -34,12 +34,6 @@ protected:
return SkISize::Make(630, 1215);
}
void onDrawBackground(SkCanvas* canvas) override {
SkPaint bgPaint;
bgPaint.setColor(sk_tool_utils::color_to_565(0xFF70D0E0));
canvas->drawPaint(bgPaint);
}
void onDraw(SkCanvas* canvas) override {
canvas->translate(SkIntToScalar(10), SkIntToScalar(20));