Minor code cleanup (left over from prior CL)
This was requested in https://codereview.chromium.org/1309543012/ (Add new GM to directly exercise perspective bitmap drawing)
Review URL: https://codereview.chromium.org/1320673011
diff --git a/gm/lighting.cpp b/gm/lighting.cpp
index d68e67d..af102d7 100644
--- a/gm/lighting.cpp
+++ b/gm/lighting.cpp
@@ -17,7 +17,7 @@
class ImageLightingGM : public GM {
public:
- ImageLightingGM() : fInitialized(false) {
+ ImageLightingGM() {
this->setBGColor(0xFF000000);
}
@@ -27,19 +27,6 @@
return SkString("lighting");
}
- void make_bitmap() {
- fBitmap.allocN32Pixels(100, 100);
- SkCanvas canvas(fBitmap);
- canvas.clear(0x00000000);
- SkPaint paint;
- paint.setAntiAlias(true);
- sk_tool_utils::set_portable_typeface(&paint);
- paint.setColor(0xFFFFFFFF);
- paint.setTextSize(SkIntToScalar(96));
- const char* str = "e";
- canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70), paint);
- }
-
SkISize onISize() override {
return SkISize::Make(WIDTH, HEIGHT);
}
@@ -53,11 +40,11 @@
canvas->restore();
}
+ void onOnceBeforeDraw() override {
+ fBitmap = sk_tool_utils::create_string_bitmap(100, 100, 0xFFFFFFFF, 20, 70, 96, "e");
+ }
+
void onDraw(SkCanvas* canvas) override {
- if (!fInitialized) {
- make_bitmap();
- fInitialized = true;
- }
canvas->clear(sk_tool_utils::color_to_565(0xFF101010));
SkPaint checkPaint;
checkPaint.setColor(sk_tool_utils::color_to_565(0xFF202020));
@@ -163,9 +150,9 @@
}
private:
- typedef GM INHERITED;
SkBitmap fBitmap;
- bool fInitialized;
+
+ typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////