Move work from ctor to onOnceBeforeDraw in ShowMipLevel GMs
authorrobertphillips <robertphillips@google.com>
Fri, 26 Aug 2016 17:04:26 +0000 (10:04 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 26 Aug 2016 17:04:26 +0000 (10:04 -0700)
These were making debugging stroking more difficult than necessary

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

Review-Url: https://codereview.chromium.org/2285813002

gm/showmiplevels.cpp

index 9f07434..05395bd 100644 (file)
@@ -105,12 +105,7 @@ public:
         }
     }
 
-    ShowMipLevels(int N) : fN(N) {
-        fBM[0] = sk_tool_utils::create_checkerboard_bitmap(N, N, SK_ColorBLACK, SK_ColorWHITE, 2);
-        fBM[1] = make_bitmap(N, N);
-        fBM[2] = make_bitmap2(N, N);
-        fBM[3] = make_bitmap3(N, N);
-    }
+    ShowMipLevels(int N) : fN(N) { }
 
 protected:
 
@@ -198,6 +193,13 @@ protected:
         }
     }
 
+    void onOnceBeforeDraw() override {
+        fBM[0] = sk_tool_utils::create_checkerboard_bitmap(fN, fN, SK_ColorBLACK, SK_ColorWHITE, 2);
+        fBM[1] = make_bitmap(fN, fN);
+        fBM[2] = make_bitmap2(fN, fN);
+        fBM[3] = make_bitmap3(fN, fN);
+    }
+
     void onDraw(SkCanvas* canvas) override {
         canvas->translate(4, 4);
         for (const auto& bm : fBM) {
@@ -222,12 +224,7 @@ class ShowMipLevels2 : public skiagm::GM {
     SkBitmap  fBM[4];
 
 public:
-    ShowMipLevels2(int w, int h) : fW(w), fH(h) {
-        fBM[0] = sk_tool_utils::create_checkerboard_bitmap(w, h, SHOW_MIP_COLOR, SK_ColorWHITE, 2);
-        fBM[1] = make_bitmap(w, h);
-        fBM[2] = make_bitmap2(w, h);
-        fBM[3] = make_bitmap3(w, h);
-    }
+    ShowMipLevels2(int w, int h) : fW(w), fH(h) { }
 
 protected:
 
@@ -292,6 +289,14 @@ protected:
         }
     }
 
+    void onOnceBeforeDraw() override {
+        fBM[0] = sk_tool_utils::create_checkerboard_bitmap(fW, fH,
+                                                           SHOW_MIP_COLOR, SK_ColorWHITE, 2);
+        fBM[1] = make_bitmap(fW, fH);
+        fBM[2] = make_bitmap2(fW, fH);
+        fBM[3] = make_bitmap3(fW, fH);
+    }
+
     void onDraw(SkCanvas* canvas) override {
         canvas->translate(4, 4);
         for (const auto& bm : fBM) {