Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
bigmatrix.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2012 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"
15#include "include/core/SkPath.h"
17#include "include/core/SkRect.h"
22#include "tools/ToolUtils.h"
23
24DEF_SIMPLE_GM_BG(bigmatrix, canvas, 50, 50, ToolUtils::color_to_565(0xFF66AA99)) {
25 SkMatrix m;
26 m.reset();
27 m.setRotate(33 * SK_Scalar1);
28 m.postScale(3000 * SK_Scalar1, 3000 * SK_Scalar1);
29 m.postTranslate(6000 * SK_Scalar1, -5000 * SK_Scalar1);
30 canvas->concat(m);
31
33 paint.setColor(SK_ColorRED);
34 paint.setAntiAlias(true);
35
36 bool success = m.invert(&m);
37 SkASSERT(success);
38 (void)success; // silence compiler :(
39
40 SkPoint pt = {10 * SK_Scalar1, 10 * SK_Scalar1};
41 SkScalar small = 1 / (500 * SK_Scalar1);
42
43 m.mapPoints(&pt, 1);
44 canvas->drawCircle(pt.fX, pt.fY, small, paint);
45
46 pt.set(30 * SK_Scalar1, 10 * SK_Scalar1);
47 m.mapPoints(&pt, 1);
48 SkRect rect = {pt.fX - small, pt.fY - small, pt.fX + small, pt.fY + small};
49 canvas->drawRect(rect, paint);
50
51 SkBitmap bmp;
52 bmp.allocN32Pixels(2, 2);
53 uint32_t* pixels = reinterpret_cast<uint32_t*>(bmp.getPixels());
54 pixels[0] = SkPackARGB32(0xFF, 0xFF, 0x00, 0x00);
55 pixels[1] = SkPackARGB32(0xFF, 0x00, 0xFF, 0x00);
56 pixels[2] = SkPackARGB32(0x80, 0x00, 0x00, 0x00);
57 pixels[3] = SkPackARGB32(0xFF, 0x00, 0x00, 0xFF);
58 pt.set(30 * SK_Scalar1, 30 * SK_Scalar1);
59 m.mapPoints(&pt, 1);
60 SkMatrix s;
61 s.reset();
62 s.setScale(SK_Scalar1 / 1000, SK_Scalar1 / 1000);
65 paint.setAntiAlias(false);
66 rect.setLTRB(pt.fX - small, pt.fY - small, pt.fX + small, pt.fY + small);
67 canvas->drawRect(rect, paint);
68}
#define SkASSERT(cond)
Definition SkAssert.h:116
static SkPMColor SkPackARGB32(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
#define SK_Scalar1
Definition SkScalar.h:18
void * getPixels() const
Definition SkBitmap.h:283
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition SkBitmap.cpp:669
void allocN32Pixels(int width, int height, bool isOpaque=false)
Definition SkBitmap.cpp:232
const Paint & paint
float SkScalar
Definition extension.cpp:12
struct MyStruct s
#define DEF_SIMPLE_GM_BG(NAME, CANVAS, W, H, BGCOLOR)
Definition gm.h:52
SkColor color_to_565(SkColor color)
float fX
x-axis value
void set(float x, float y)
float fY
y-axis value