Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Unified Diff: tests/ShaderTest.cpp

Issue 2355703003: Avoid bitmap copy in SkMakeBitmapShader, fix hwui unit test (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/image/SkImageShader.cpp ('K') | « src/image/SkImageShader.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ShaderTest.cpp
diff --git a/tests/ShaderTest.cpp b/tests/ShaderTest.cpp
index 83240478ad98c145762c6d70fe31ffb09e907e66..8ba55bba5fb0e42822ed02471dc31abdbaee7e42 100644
--- a/tests/ShaderTest.cpp
+++ b/tests/ShaderTest.cpp
@@ -55,3 +55,24 @@ DEF_TEST(Shader_isABitmap, reporter) {
check_isabitmap(reporter, shader0.get(), W, H, tmx, tmy, localM);
check_isabitmap(reporter, shader1.get(), W, H, tmx, tmy, localM);
}
+
+static void create_bitmap(SkBitmap* bitmap) {
+ SkImageInfo info = SkImageInfo::Make(1, 1, kN32_SkColorType, kPremul_SkAlphaType);
+ bitmap->setInfo(info);
+ bitmap->allocPixels(info);
+}
+
+DEF_TEST(Shader_AndroidFramework, r) {
+ SkBitmap origBitmap;
+ create_bitmap(&origBitmap);
+ //origBitmap.setImmutable();
+ 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
+ SkShader::kRepeat_TileMode);
+
+ SkBitmap bitmap;
+ SkShader::TileMode xy[2];
+ REPORTER_ASSERT(r, s->isABitmap(&bitmap, nullptr, xy));
+ REPORTER_ASSERT(r, SkShader::kClamp_TileMode == xy[0]);
+ REPORTER_ASSERT(r, SkShader::kRepeat_TileMode == xy[1]);
+ REPORTER_ASSERT(r, origBitmap.pixelRef() == bitmap.pixelRef());
+}
« src/image/SkImageShader.cpp ('K') | « src/image/SkImageShader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698