Flutter Engine
The Flutter Engine
simplerect.cpp
Go to the documentation of this file.
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/gm.h"
11#include "include/core/SkRect.h"
13#include "include/core/SkSize.h"
15#include "src/base/SkRandom.h"
16#include "tools/ToolUtils.h"
17
18class SimpleRectGM : public skiagm::GM {
19public:
21
22protected:
23 SkString getName() const override {
25 name.printf("simplerect");
26 return name;
27 }
28
29 SkISize getISize() override { return SkISize::Make(800, 800); }
30
31 void onDraw(SkCanvas* canvas) override {
32 canvas->translate(1, 1); // want to exercise non-identity ctm performance
33
34 const SkScalar min = -20;
35 const SkScalar max = 800;
36 const SkScalar size = 20;
37
38 SkRandom rand;
40 for (int i = 0; i < 10000; i++) {
41 paint.setColor(ToolUtils::color_to_565(rand.nextU() | (0xFF << 24)));
44 SkScalar w = rand.nextRangeScalar(0, size);
45 SkScalar h = rand.nextRangeScalar(0, size);
46 canvas->drawRect(SkRect::MakeXYWH(x, y, w, h), paint);
47 }
48 }
49
50 bool onAnimate(double nanos) override { return true; }
51
52private:
53
54 using INHERITED = GM;
55};
56DEF_GM(return new SimpleRectGM;)
SkString getName() const override
Definition: simplerect.cpp:23
SkISize getISize() override
Definition: simplerect.cpp:29
bool onAnimate(double nanos) override
Definition: simplerect.cpp:50
void onDraw(SkCanvas *canvas) override
Definition: simplerect.cpp:31
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
uint32_t nextU()
Definition: SkRandom.h:42
SkScalar nextRangeScalar(SkScalar min, SkScalar max)
Definition: SkRandom.h:106
Definition: gm.h:110
GM(SkColor backgroundColor=SK_ColorWHITE)
Definition: gm.cpp:81
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
#define DEF_GM(CODE)
Definition: gm.h:40
static float max(float r, float g, float b)
Definition: hsl.cpp:49
static float min(float r, float g, float b)
Definition: hsl.cpp:48
double y
double x
SkColor color_to_565(SkColor color)
Definition: ToolUtils.cpp:139
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
SkScalar w
SkScalar h
Definition: SkSize.h:16
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659