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

Side by Side 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 unified diff | Download patch
« src/image/SkImageShader.cpp ('K') | « src/image/SkImageShader.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« 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