OLD | NEW |
| (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 | |
OLD | NEW |