blob: b39f2eab73aeb9db2ff979624ef047cf0b2c566c [file] [log] [blame]
bsalomon@google.com1a38d552012-03-15 14:40:46 +00001/*
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 */
bungemand3ebb482015-08-05 13:57:49 -07007
bsalomon@google.com1a38d552012-03-15 14:40:46 +00008#include "gm.h"
9
10#include "SkColorPriv.h"
bungemand3ebb482015-08-05 13:57:49 -070011#include "SkPath.h"
bsalomon@google.com1a38d552012-03-15 14:40:46 +000012#include "SkShader.h"
13
halcanary2a243382015-09-09 08:16:41 -070014DEF_SIMPLE_GM_BG(bigmatrix, canvas, 50, 50,
15 sk_tool_utils::color_to_565(0xFF66AA99)) {
bsalomon@google.com1a38d552012-03-15 14:40:46 +000016 SkMatrix m;
17 m.reset();
18 m.setRotate(33 * SK_Scalar1);
19 m.postScale(3000 * SK_Scalar1, 3000 * SK_Scalar1);
20 m.postTranslate(6000 * SK_Scalar1, -5000 * SK_Scalar1);
21 canvas->concat(m);
22
23 SkPaint paint;
24 paint.setColor(SK_ColorRED);
25 paint.setAntiAlias(true);
26
reed@google.com57b19352012-04-19 19:25:49 +000027 bool success = m.invert(&m);
caryclark@google.com13130862012-06-06 12:10:45 +000028 SkASSERT(success);
humper@google.com0e515772013-01-07 19:54:40 +000029 (void) success; // silence compiler :(
bsalomon@google.com1a38d552012-03-15 14:40:46 +000030
31 SkPath path;
32
33 SkPoint pt = {10 * SK_Scalar1, 10 * SK_Scalar1};
34 SkScalar small = 1 / (500 * SK_Scalar1);
35
36 m.mapPoints(&pt, 1);
37 path.addCircle(pt.fX, pt.fY, small);
38 canvas->drawPath(path, paint);
39
40 pt.set(30 * SK_Scalar1, 10 * SK_Scalar1);
41 m.mapPoints(&pt, 1);
42 SkRect rect = {pt.fX - small, pt.fY - small,
43 pt.fX + small, pt.fY + small};
44 canvas->drawRect(rect, paint);
45
46 SkBitmap bmp;
reed@google.comeb9a46c2014-01-25 16:46:20 +000047 bmp.allocN32Pixels(2, 2);
bsalomon@google.com1a38d552012-03-15 14:40:46 +000048 uint32_t* pixels = reinterpret_cast<uint32_t*>(bmp.getPixels());
49 pixels[0] = SkPackARGB32(0xFF, 0xFF, 0x00, 0x00);
50 pixels[1] = SkPackARGB32(0xFF, 0x00, 0xFF, 0x00);
51 pixels[2] = SkPackARGB32(0x80, 0x00, 0x00, 0x00);
52 pixels[3] = SkPackARGB32(0xFF, 0x00, 0x00, 0xFF);
bsalomon@google.com1a38d552012-03-15 14:40:46 +000053 pt.set(30 * SK_Scalar1, 30 * SK_Scalar1);
54 m.mapPoints(&pt, 1);
bsalomon@google.com1a38d552012-03-15 14:40:46 +000055 SkMatrix s;
56 s.reset();
57 s.setScale(SK_Scalar1 / 1000, SK_Scalar1 / 1000);
reed2ad1aa62016-03-09 09:50:50 -080058 paint.setShader(SkShader::MakeBitmapShader(bmp, SkShader::kRepeat_TileMode,
59 SkShader::kRepeat_TileMode, &s));
bsalomon@google.com1a38d552012-03-15 14:40:46 +000060 paint.setAntiAlias(false);
reed93a12152015-03-16 10:08:34 -070061 paint.setFilterQuality(kLow_SkFilterQuality);
bsalomon@google.com1a38d552012-03-15 14:40:46 +000062 rect.setLTRB(pt.fX - small, pt.fY - small,
63 pt.fX + small, pt.fY + small);
64 canvas->drawRect(rect, paint);
bsalomon@google.com1a38d552012-03-15 14:40:46 +000065}