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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/image/SkImage_Raster.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
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkTypes.h"
9 #if SK_SUPPORT_GPU
10 #include "GrContextFactory.h"
11 #endif
12 #include "SkImage.h"
13 #include "SkSurface.h"
14
15 #include "Test.h"
16
17 DEF_TEST(ImageIsOpaqueTest, reporter) {
18 SkImageInfo infoTransparent = SkImageInfo::MakeN32Premul(5, 5);
19 SkAutoTUnref<SkSurface> surfaceTransparent(SkSurface::NewRaster(infoTranspar ent));
20 REPORTER_ASSERT(reporter, !surfaceTransparent->newImageSnapshot()->isOpaque( ));
21
22 SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType);
23 SkAutoTUnref<SkSurface> surfaceOpaque(SkSurface::NewRaster(infoOpaque));
24 REPORTER_ASSERT(reporter, surfaceOpaque->newImageSnapshot()->isOpaque());
25 }
26
27 #if SK_SUPPORT_GPU
28
29 DEF_GPUTEST(ImageIsOpaqueTest_GPU, reporter, factory) {
30 for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
31 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContext Type) i;
32
33 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) {
34 continue;
35 }
36
37 GrContext* context = factory->get(glCtxType);
38
39 if (NULL == context) {
40 continue;
41 }
42
43 SkImageInfo infoTransparent = SkImageInfo::MakeN32Premul(5, 5);
44 SkAutoTUnref<SkSurface> surfaceTransparent(SkSurface::NewRenderTarget(co ntext, infoTransparent));
45 REPORTER_ASSERT(reporter, !surfaceTransparent->newImageSnapshot()->isOpa que());
46
47 SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType) ;
48 SkAutoTUnref<SkSurface> surfaceOpaque(SkSurface::NewRenderTarget(context , infoOpaque));
49 REPORTER_ASSERT(reporter, !surfaceOpaque->newImageSnapshot()->isOpaque() );
50
51 }
52 }
53
54 #endif
OLDNEW
« 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