2012-03-15 14:40:46 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2015-08-05 20:57:49 +00:00
|
|
|
|
2012-03-15 14:40:46 +00:00
|
|
|
#include "gm.h"
|
2017-03-22 17:47:51 +00:00
|
|
|
#include "sk_tool_utils.h"
|
2012-03-15 14:40:46 +00:00
|
|
|
|
|
|
|
#include "SkColorPriv.h"
|
2015-08-05 20:57:49 +00:00
|
|
|
#include "SkPath.h"
|
2012-03-15 14:40:46 +00:00
|
|
|
#include "SkShader.h"
|
|
|
|
|
2015-09-09 15:16:41 +00:00
|
|
|
DEF_SIMPLE_GM_BG(bigmatrix, canvas, 50, 50,
|
|
|
|
sk_tool_utils::color_to_565(0xFF66AA99)) {
|
2012-03-15 14:40:46 +00:00
|
|
|
SkMatrix m;
|
|
|
|
m.reset();
|
|
|
|
m.setRotate(33 * SK_Scalar1);
|
|
|
|
m.postScale(3000 * SK_Scalar1, 3000 * SK_Scalar1);
|
|
|
|
m.postTranslate(6000 * SK_Scalar1, -5000 * SK_Scalar1);
|
|
|
|
canvas->concat(m);
|
|
|
|
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setColor(SK_ColorRED);
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
|
2012-04-19 19:25:49 +00:00
|
|
|
bool success = m.invert(&m);
|
2012-06-06 12:10:45 +00:00
|
|
|
SkASSERT(success);
|
2013-01-07 19:54:40 +00:00
|
|
|
(void) success; // silence compiler :(
|
2012-03-15 14:40:46 +00:00
|
|
|
|
|
|
|
SkPath path;
|
|
|
|
|
|
|
|
SkPoint pt = {10 * SK_Scalar1, 10 * SK_Scalar1};
|
|
|
|
SkScalar small = 1 / (500 * SK_Scalar1);
|
|
|
|
|
|
|
|
m.mapPoints(&pt, 1);
|
|
|
|
path.addCircle(pt.fX, pt.fY, small);
|
|
|
|
canvas->drawPath(path, paint);
|
|
|
|
|
|
|
|
pt.set(30 * SK_Scalar1, 10 * SK_Scalar1);
|
|
|
|
m.mapPoints(&pt, 1);
|
|
|
|
SkRect rect = {pt.fX - small, pt.fY - small,
|
|
|
|
pt.fX + small, pt.fY + small};
|
|
|
|
canvas->drawRect(rect, paint);
|
|
|
|
|
|
|
|
SkBitmap bmp;
|
2014-01-25 16:46:20 +00:00
|
|
|
bmp.allocN32Pixels(2, 2);
|
2012-03-15 14:40:46 +00:00
|
|
|
uint32_t* pixels = reinterpret_cast<uint32_t*>(bmp.getPixels());
|
|
|
|
pixels[0] = SkPackARGB32(0xFF, 0xFF, 0x00, 0x00);
|
|
|
|
pixels[1] = SkPackARGB32(0xFF, 0x00, 0xFF, 0x00);
|
|
|
|
pixels[2] = SkPackARGB32(0x80, 0x00, 0x00, 0x00);
|
|
|
|
pixels[3] = SkPackARGB32(0xFF, 0x00, 0x00, 0xFF);
|
|
|
|
pt.set(30 * SK_Scalar1, 30 * SK_Scalar1);
|
|
|
|
m.mapPoints(&pt, 1);
|
|
|
|
SkMatrix s;
|
|
|
|
s.reset();
|
|
|
|
s.setScale(SK_Scalar1 / 1000, SK_Scalar1 / 1000);
|
2016-03-09 17:50:50 +00:00
|
|
|
paint.setShader(SkShader::MakeBitmapShader(bmp, SkShader::kRepeat_TileMode,
|
|
|
|
SkShader::kRepeat_TileMode, &s));
|
2012-03-15 14:40:46 +00:00
|
|
|
paint.setAntiAlias(false);
|
2015-03-16 17:08:34 +00:00
|
|
|
paint.setFilterQuality(kLow_SkFilterQuality);
|
2012-03-15 14:40:46 +00:00
|
|
|
rect.setLTRB(pt.fX - small, pt.fY - small,
|
|
|
|
pt.fX + small, pt.fY + small);
|
|
|
|
canvas->drawRect(rect, paint);
|
|
|
|
}
|