2 * Copyright 2014 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
10 #include "GrContextFactory.h"
13 #include "SkSurface.h"
17 static void check_isopaque(skiatest::Reporter* reporter, SkSurface* surface, bool expectedOpaque) {
18 SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
19 REPORTER_ASSERT(reporter, image->isOpaque() == expectedOpaque);
22 DEF_TEST(ImageIsOpaqueTest, reporter) {
23 SkImageInfo infoTransparent = SkImageInfo::MakeN32Premul(5, 5);
24 SkAutoTUnref<SkSurface> surfaceTransparent(SkSurface::NewRaster(infoTransparent));
25 check_isopaque(reporter, surfaceTransparent, false);
27 SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType);
28 SkAutoTUnref<SkSurface> surfaceOpaque(SkSurface::NewRaster(infoOpaque));
29 check_isopaque(reporter, surfaceOpaque, true);
34 DEF_GPUTEST(ImageIsOpaqueTest_GPU, reporter, factory) {
35 for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
36 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType) i;
38 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) {
42 GrContext* context = factory->get(glCtxType);
44 if (NULL == context) {
48 SkImageInfo infoTransparent = SkImageInfo::MakeN32Premul(5, 5);
49 SkAutoTUnref<SkSurface> surfaceTransparent(SkSurface::NewRenderTarget(context, infoTransparent));
50 check_isopaque(reporter, surfaceTransparent, false);
52 SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType);
53 SkAutoTUnref<SkSurface> surfaceOpaque(SkSurface::NewRenderTarget(context, infoOpaque));
55 // this is failing right now : TODO fix me
56 check_isopaque(reporter, surfaceOpaque, true);