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

Unified Diff: tests/ImageIsOpaqueTest.cpp

Issue 406673003: Add the method isOpaque() to SkImage (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase master Created 6 years, 4 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
« no previous file with comments | « src/image/SkImage_Raster.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
new file mode 100644
index 0000000000000000000000000000000000000000..902e24d827fa2b641e11f37da72868d7783caa6d
--- /dev/null
+++ b/tests/ImageIsOpaqueTest.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkTypes.h"
+#if SK_SUPPORT_GPU
+#include "GrContextFactory.h"
+#endif
+#include "SkImage.h"
+#include "SkSurface.h"
+
+#include "Test.h"
+
+DEF_TEST(ImageIsOpaqueTest, reporter) {
+ SkImageInfo infoTransparent = SkImageInfo::MakeN32Premul(5, 5);
+ SkAutoTUnref<SkSurface> surfaceTransparent(SkSurface::NewRaster(infoTransparent));
+ REPORTER_ASSERT(reporter, !surfaceTransparent->newImageSnapshot()->isOpaque());
+
+ SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType);
+ SkAutoTUnref<SkSurface> surfaceOpaque(SkSurface::NewRaster(infoOpaque));
+ REPORTER_ASSERT(reporter, surfaceOpaque->newImageSnapshot()->isOpaque());
+}
+
+#if SK_SUPPORT_GPU
+
+DEF_GPUTEST(ImageIsOpaqueTest_GPU, reporter, factory) {
+ for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
+ GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType) i;
+
+ if (!GrContextFactory::IsRenderingGLContext(glCtxType)) {
+ continue;
+ }
+
+ GrContext* context = factory->get(glCtxType);
+
+ if (NULL == context) {
+ continue;
+ }
+
+ SkImageInfo infoTransparent = SkImageInfo::MakeN32Premul(5, 5);
+ SkAutoTUnref<SkSurface> surfaceTransparent(SkSurface::NewRenderTarget(context, infoTransparent));
+ REPORTER_ASSERT(reporter, !surfaceTransparent->newImageSnapshot()->isOpaque());
+
+ SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType);
+ SkAutoTUnref<SkSurface> surfaceOpaque(SkSurface::NewRenderTarget(context, infoOpaque));
+ REPORTER_ASSERT(reporter, !surfaceOpaque->newImageSnapshot()->isOpaque());
+
+ }
+}
+
+#endif
« no previous file with comments | « src/image/SkImage_Raster.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698