Remove caching from the draw-atlas GMs. Fixes bugs cycling backends.

When we would change backend or color type in SampleApp, we'd be rendering
from a no-longer-valid image, leading to missing output, etc...

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2381893004

Review-Url: https://codereview.chromium.org/2381893004
This commit is contained in:
brianosman 2016-09-29 13:43:49 -07:00 committed by Commit bot
parent eb0d91cfa2
commit 95e8d0a4ae
2 changed files with 6 additions and 15 deletions

View File

@ -35,8 +35,6 @@ class DrawAtlasGM : public skiagm::GM {
return surface->makeImageSnapshot();
}
sk_sp<SkImage> fAtlas;
public:
DrawAtlasGM() {}
@ -52,9 +50,7 @@ protected:
void onDraw(SkCanvas* canvas) override {
const SkRect target = { 50, 50, 80, 90 };
if (nullptr == fAtlas) {
fAtlas = MakeAtlas(canvas, target);
}
auto atlas = MakeAtlas(canvas, target);
const struct {
SkScalar fScale;
@ -91,9 +87,9 @@ protected:
paint.setFilterQuality(kLow_SkFilterQuality);
paint.setAntiAlias(true);
canvas->drawAtlas(fAtlas.get(), xform, tex, N, nullptr, &paint);
canvas->drawAtlas(atlas.get(), xform, tex, N, nullptr, &paint);
canvas->translate(0, 100);
canvas->drawAtlas(fAtlas.get(), xform, tex, colors, N, SkXfermode::kSrcIn_Mode, nullptr, &paint);
canvas->drawAtlas(atlas.get(), xform, tex, colors, N, SkXfermode::kSrcIn_Mode, nullptr, &paint);
}
private:

View File

@ -72,9 +72,7 @@ protected:
void onDraw(SkCanvas* canvas) override {
const SkRect target = SkRect::MakeWH(SkIntToScalar(kAtlasSize), SkIntToScalar(kAtlasSize));
if (nullptr == fAtlas) {
fAtlas = make_atlas(canvas, kAtlasSize);
}
auto atlas = make_atlas(canvas, kAtlasSize);
const struct {
SkXfermode::Mode fMode;
@ -151,11 +149,11 @@ protected:
canvas->translate(SkIntToScalar(i*(target.height()+kPad)),
SkIntToScalar(kTextPad+kPad));
// w/o a paint
canvas->drawAtlas(fAtlas.get(), xforms, rects, quadColors, numColors,
canvas->drawAtlas(atlas.get(), xforms, rects, quadColors, numColors,
gModes[i].fMode, nullptr, nullptr);
canvas->translate(0.0f, numColors*(target.height()+kPad));
// w a paint
canvas->drawAtlas(fAtlas.get(), xforms, rects, quadColors, numColors,
canvas->drawAtlas(atlas.get(), xforms, rects, quadColors, numColors,
gModes[i].fMode, nullptr, &paint);
canvas->restore();
}
@ -168,9 +166,6 @@ private:
static constexpr int kPad = 2;
static constexpr int kTextPad = 8;
sk_sp<SkImage> fAtlas;
typedef GM INHERITED;
};
DEF_GM( return new DrawAtlasColorsGM; )