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

Unified Diff: tests/ImageIsOpaqueTest.cpp

Issue 2461773002: add isAlphaOnly() query (Closed)
Patch Set: add test Created 4 years, 2 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
« include/core/SkImage.h ('K') | « src/image/SkImage.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ImageIsOpaqueTest.cpp
diff --git a/tests/ImageIsOpaqueTest.cpp b/tests/ImageIsOpaqueTest.cpp
index ab995c8140426b4eaf78d72d1a2acb49f783bd72..cc7255d37a47def80e1178930f37ee730e125984 100644
--- a/tests/ImageIsOpaqueTest.cpp
+++ b/tests/ImageIsOpaqueTest.cpp
@@ -102,3 +102,34 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageIsOpaqueTest_Gpu, reporter, ctxInfo) {
}
#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+#include "SkPictureRecorder.h"
+
+static sk_sp<SkPicture> make_picture() {
+ SkPictureRecorder recorder;
+ SkCanvas* canvas = recorder.beginRecording({ 0, 0, 10, 10 });
+ canvas->drawColor(SK_ColorRED);
+ return recorder.finishRecordingAsPicture();
+}
+
+DEF_TEST(Image_isAlphaOnly, reporter) {
+ SkPMColor pmColors = 0;
+ SkPixmap pmap = {
+ SkImageInfo::MakeN32Premul(1, 1),
+ &pmColors,
+ sizeof(pmColors)
+ };
+ for (auto& image : {
+ SkImage::MakeRasterCopy(pmap),
+ GetResourceAsImage("mandrill_128.png"),
+ GetResourceAsImage("color_wheel.jpg"),
+ SkImage::MakeFromPicture(make_picture(), { 10, 10 }, nullptr, nullptr),
+ })
+ {
+ REPORTER_ASSERT(reporter, image->isAlphaOnly() == false);
+ }
+
+ REPORTER_ASSERT(reporter, SkImage::MakeRasterCopy({
+ SkImageInfo::MakeA8(1, 1), (uint8_t*)&pmColors, 1})->isAlphaOnly() == true);
+}
« include/core/SkImage.h ('K') | « src/image/SkImage.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698