OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Test.h" | 8 #include "Test.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkImage.h" | 10 #include "SkImage.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 const SkMatrix localM = SkMatrix::MakeScale(2, 3); | 48 const SkMatrix localM = SkMatrix::MakeScale(2, 3); |
49 const SkShader::TileMode tmx = SkShader::kRepeat_TileMode; | 49 const SkShader::TileMode tmx = SkShader::kRepeat_TileMode; |
50 const SkShader::TileMode tmy = SkShader::kMirror_TileMode; | 50 const SkShader::TileMode tmy = SkShader::kMirror_TileMode; |
51 | 51 |
52 auto shader0 = SkShader::MakeBitmapShader(bm, tmx, tmy, &localM); | 52 auto shader0 = SkShader::MakeBitmapShader(bm, tmx, tmy, &localM); |
53 auto shader1 = SkImage::MakeFromBitmap(bm)->makeShader(tmx, tmy, &localM); | 53 auto shader1 = SkImage::MakeFromBitmap(bm)->makeShader(tmx, tmy, &localM); |
54 | 54 |
55 check_isabitmap(reporter, shader0.get(), W, H, tmx, tmy, localM); | 55 check_isabitmap(reporter, shader0.get(), W, H, tmx, tmy, localM); |
56 check_isabitmap(reporter, shader1.get(), W, H, tmx, tmy, localM); | 56 check_isabitmap(reporter, shader1.get(), W, H, tmx, tmy, localM); |
57 } | 57 } |
58 | |
59 static void create_bitmap(SkBitmap* bitmap) { | |
60 SkImageInfo info = SkImageInfo::Make(1, 1, kN32_SkColorType, kPremul_SkAlpha Type); | |
61 bitmap->setInfo(info); | |
62 bitmap->allocPixels(info); | |
63 } | |
64 | |
65 DEF_TEST(Shader_AndroidFramework, r) { | |
66 SkBitmap origBitmap; | |
67 create_bitmap(&origBitmap); | |
68 //origBitmap.setImmutable(); | |
69 sk_sp<SkShader> s = SkShader::MakeBitmapShader(origBitmap, SkShader::kClamp_ TileMode, | |
reed1
2016/09/20 17:19:06
Tests are allowed to call private APIs, e.g. SkIma
| |
70 SkShader::kRepeat_TileMode); | |
71 | |
72 SkBitmap bitmap; | |
73 SkShader::TileMode xy[2]; | |
74 REPORTER_ASSERT(r, s->isABitmap(&bitmap, nullptr, xy)); | |
75 REPORTER_ASSERT(r, SkShader::kClamp_TileMode == xy[0]); | |
76 REPORTER_ASSERT(r, SkShader::kRepeat_TileMode == xy[1]); | |
77 REPORTER_ASSERT(r, origBitmap.pixelRef() == bitmap.pixelRef()); | |
78 } | |
OLD | NEW |