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
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "gm/gm.h"
|
2019-05-01 14:59:30 +00:00
|
|
|
#include "include/core/SkBitmap.h"
|
|
|
|
#include "include/core/SkCanvas.h"
|
|
|
|
#include "include/core/SkColor.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkColorPriv.h"
|
2019-05-01 14:59:30 +00:00
|
|
|
#include "include/core/SkMatrix.h"
|
|
|
|
#include "include/core/SkPaint.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkPath.h"
|
2019-05-01 14:59:30 +00:00
|
|
|
#include "include/core/SkPoint.h"
|
|
|
|
#include "include/core/SkRect.h"
|
|
|
|
#include "include/core/SkScalar.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkShader.h"
|
2019-05-01 14:59:30 +00:00
|
|
|
#include "include/core/SkTileMode.h"
|
|
|
|
#include "include/core/SkTypes.h"
|
|
|
|
#include "tools/ToolUtils.h"
|
2012-03-15 14:40:46 +00:00
|
|
|
|
2019-03-20 16:12:10 +00:00
|
|
|
DEF_SIMPLE_GM_BG(bigmatrix, canvas, 50, 50, ToolUtils::color_to_565(0xFF66AA99)) {
|
|
|
|
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);
|
|
|
|
|
|
|
|
bool success = m.invert(&m);
|
|
|
|
SkASSERT(success);
|
|
|
|
(void)success; // silence compiler :(
|
|
|
|
|
|
|
|
SkPoint pt = {10 * SK_Scalar1, 10 * SK_Scalar1};
|
|
|
|
SkScalar small = 1 / (500 * SK_Scalar1);
|
|
|
|
|
|
|
|
m.mapPoints(&pt, 1);
|
2020-08-25 15:48:41 +00:00
|
|
|
canvas->drawCircle(pt.fX, pt.fY, small, paint);
|
2019-03-20 16:12:10 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
bmp.allocN32Pixels(2, 2);
|
|
|
|
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);
|
2020-12-12 14:51:11 +00:00
|
|
|
paint.setShader(bmp.makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat,
|
2021-01-15 02:59:01 +00:00
|
|
|
SkSamplingOptions(SkFilterMode::kLinear), s));
|
2019-03-20 16:12:10 +00:00
|
|
|
paint.setAntiAlias(false);
|
|
|
|
rect.setLTRB(pt.fX - small, pt.fY - small, pt.fX + small, pt.fY + small);
|
|
|
|
canvas->drawRect(rect, paint);
|
2012-03-15 14:40:46 +00:00
|
|
|
}
|