Home | History | Annotate | Download | only in gm
      1 /*
      2  * Copyright 2016 Google Inc.
      3  *
      4  * Use of this source code is governed by a BSD-style license that can be
      5  * found in the LICENSE file.
      6  */
      7 
      8 #include "gm.h"
      9 #include "sk_tool_utils.h"
     10 #include "SkBlurMask.h"
     11 #include "SkBlurMaskFilter.h"
     12 #include "SkPath.h"
     13 
     14 class SimpleRectGM : public skiagm::GM {
     15 public:
     16     SimpleRectGM() {}
     17 
     18 protected:
     19     SkString onShortName() override {
     20         SkString name;
     21         name.printf("simplerect");
     22         return name;
     23     }
     24 
     25     SkISize onISize() override {
     26         return SkISize::Make(800, 800);
     27     }
     28 
     29     void onDraw(SkCanvas* canvas) override {
     30         canvas->translate(1, 1);    // want to exercise non-identity ctm performance
     31 
     32         const SkScalar min = -20;
     33         const SkScalar max = 800;
     34         const SkScalar size = 20;
     35 
     36         SkRandom rand;
     37         SkPaint paint;
     38         for (int i = 0; i < 10000; i++) {
     39             paint.setColor(sk_tool_utils::color_to_565(rand.nextU() | (0xFF << 24)));
     40             SkScalar x = rand.nextRangeScalar(min, max);
     41             SkScalar y = rand.nextRangeScalar(min, max);
     42             SkScalar w = rand.nextRangeScalar(0, size);
     43             SkScalar h = rand.nextRangeScalar(0, size);
     44             canvas->drawRect(SkRect::MakeXYWH(x, y, w, h), paint);
     45         }
     46     }
     47 
     48     bool onAnimate(const SkAnimTimer& timer) override {
     49         return true;
     50     }
     51 
     52 private:
     53 
     54     typedef GM INHERITED;
     55 };
     56 DEF_GM(return new SimpleRectGM;)
     57