| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "gm.h" | 8 #include "gm.h" |
| 9 | 9 |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 path.addCircle(pt.fX, pt.fY, small); | 52 path.addCircle(pt.fX, pt.fY, small); |
| 53 canvas->drawPath(path, paint); | 53 canvas->drawPath(path, paint); |
| 54 | 54 |
| 55 pt.set(30 * SK_Scalar1, 10 * SK_Scalar1); | 55 pt.set(30 * SK_Scalar1, 10 * SK_Scalar1); |
| 56 m.mapPoints(&pt, 1); | 56 m.mapPoints(&pt, 1); |
| 57 SkRect rect = {pt.fX - small, pt.fY - small, | 57 SkRect rect = {pt.fX - small, pt.fY - small, |
| 58 pt.fX + small, pt.fY + small}; | 58 pt.fX + small, pt.fY + small}; |
| 59 canvas->drawRect(rect, paint); | 59 canvas->drawRect(rect, paint); |
| 60 | 60 |
| 61 SkBitmap bmp; | 61 SkBitmap bmp; |
| 62 bmp.setConfig(SkBitmap::kARGB_8888_Config, 2, 2); | 62 bmp.allocN32Pixels(2, 2); |
| 63 bmp.allocPixels(); | |
| 64 bmp.lockPixels(); | |
| 65 uint32_t* pixels = reinterpret_cast<uint32_t*>(bmp.getPixels()); | 63 uint32_t* pixels = reinterpret_cast<uint32_t*>(bmp.getPixels()); |
| 66 pixels[0] = SkPackARGB32(0xFF, 0xFF, 0x00, 0x00); | 64 pixels[0] = SkPackARGB32(0xFF, 0xFF, 0x00, 0x00); |
| 67 pixels[1] = SkPackARGB32(0xFF, 0x00, 0xFF, 0x00); | 65 pixels[1] = SkPackARGB32(0xFF, 0x00, 0xFF, 0x00); |
| 68 pixels[2] = SkPackARGB32(0x80, 0x00, 0x00, 0x00); | 66 pixels[2] = SkPackARGB32(0x80, 0x00, 0x00, 0x00); |
| 69 pixels[3] = SkPackARGB32(0xFF, 0x00, 0x00, 0xFF); | 67 pixels[3] = SkPackARGB32(0xFF, 0x00, 0x00, 0xFF); |
| 70 bmp.unlockPixels(); | |
| 71 pt.set(30 * SK_Scalar1, 30 * SK_Scalar1); | 68 pt.set(30 * SK_Scalar1, 30 * SK_Scalar1); |
| 72 m.mapPoints(&pt, 1); | 69 m.mapPoints(&pt, 1); |
| 73 SkShader* shader = SkShader::CreateBitmapShader( | 70 SkShader* shader = SkShader::CreateBitmapShader( |
| 74 bmp, | 71 bmp, |
| 75 SkShader::kRepeat_TileMode, | 72 SkShader::kRepeat_TileMode, |
| 76 SkShader::kRepeat_TileMode); | 73 SkShader::kRepeat_TileMode); |
| 77 SkMatrix s; | 74 SkMatrix s; |
| 78 s.reset(); | 75 s.reset(); |
| 79 s.setScale(SK_Scalar1 / 1000, SK_Scalar1 / 1000); | 76 s.setScale(SK_Scalar1 / 1000, SK_Scalar1 / 1000); |
| 80 shader->setLocalMatrix(s); | 77 shader->setLocalMatrix(s); |
| 81 paint.setShader(shader)->unref(); | 78 paint.setShader(shader)->unref(); |
| 82 paint.setAntiAlias(false); | 79 paint.setAntiAlias(false); |
| 83 paint.setFilterLevel(SkPaint::kLow_FilterLevel); | 80 paint.setFilterLevel(SkPaint::kLow_FilterLevel); |
| 84 rect.setLTRB(pt.fX - small, pt.fY - small, | 81 rect.setLTRB(pt.fX - small, pt.fY - small, |
| 85 pt.fX + small, pt.fY + small); | 82 pt.fX + small, pt.fY + small); |
| 86 canvas->drawRect(rect, paint); | 83 canvas->drawRect(rect, paint); |
| 87 } | 84 } |
| 88 | 85 |
| 89 private: | 86 private: |
| 90 typedef GM INHERITED; | 87 typedef GM INHERITED; |
| 91 }; | 88 }; |
| 92 | 89 |
| 93 ////////////////////////////////////////////////////////////////////////////// | 90 ////////////////////////////////////////////////////////////////////////////// |
| 94 | 91 |
| 95 static GM* MyFactory(void*) { return new BigMatrixGM; } | 92 static GM* MyFactory(void*) { return new BigMatrixGM; } |
| 96 static GMRegistry reg(MyFactory); | 93 static GMRegistry reg(MyFactory); |
| 97 | 94 |
| 98 } | 95 } |
| OLD | NEW |