| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkTypes.h" | 8 #include "SkTypes.h" |
| 9 #include "Test.h" | 9 #include "Test.h" |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 SkImageInfo info = SkImageInfo::Make(100, 200, | 41 SkImageInfo info = SkImageInfo::Make(100, 200, |
| 42 static_cast<SkColorType>(ct
), | 42 static_cast<SkColorType>(ct
), |
| 43 static_cast<SkAlphaType>(at
), | 43 static_cast<SkAlphaType>(at
), |
| 44 static_cast<SkColorProfileT
ype>(pt)); | 44 static_cast<SkColorProfileT
ype>(pt)); |
| 45 test_flatten(reporter, info); | 45 test_flatten(reporter, info); |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 static void check_isopaque(skiatest::Reporter* reporter, SkSurface* surface, boo
l expectedOpaque) { | 51 static void check_isopaque(skiatest::Reporter* reporter, const sk_sp<SkSurface>&
surface, |
| 52 bool expectedOpaque) { |
| 52 sk_sp<SkImage> image(surface->makeImageSnapshot()); | 53 sk_sp<SkImage> image(surface->makeImageSnapshot()); |
| 53 REPORTER_ASSERT(reporter, image->isOpaque() == expectedOpaque); | 54 REPORTER_ASSERT(reporter, image->isOpaque() == expectedOpaque); |
| 54 } | 55 } |
| 55 | 56 |
| 56 DEF_TEST(ImageIsOpaqueTest, reporter) { | 57 DEF_TEST(ImageIsOpaqueTest, reporter) { |
| 57 SkImageInfo infoTransparent = SkImageInfo::MakeN32Premul(5, 5); | 58 SkImageInfo infoTransparent = SkImageInfo::MakeN32Premul(5, 5); |
| 58 SkAutoTUnref<SkSurface> surfaceTransparent(SkSurface::NewRaster(infoTranspar
ent)); | 59 auto surfaceTransparent(SkSurface::MakeRaster(infoTransparent)); |
| 59 check_isopaque(reporter, surfaceTransparent, false); | 60 check_isopaque(reporter, surfaceTransparent, false); |
| 60 | 61 |
| 61 SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType); | 62 SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType); |
| 62 SkAutoTUnref<SkSurface> surfaceOpaque(SkSurface::NewRaster(infoOpaque)); | 63 auto surfaceOpaque(SkSurface::MakeRaster(infoOpaque)); |
| 63 check_isopaque(reporter, surfaceOpaque, true); | 64 check_isopaque(reporter, surfaceOpaque, true); |
| 64 } | 65 } |
| 65 | 66 |
| 66 #if SK_SUPPORT_GPU | 67 #if SK_SUPPORT_GPU |
| 67 | 68 |
| 68 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageIsOpaqueTest_Gpu, reporter, context) { | 69 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageIsOpaqueTest_Gpu, reporter, context) { |
| 69 SkImageInfo infoTransparent = SkImageInfo::MakeN32Premul(5, 5); | 70 SkImageInfo infoTransparent = SkImageInfo::MakeN32Premul(5, 5); |
| 70 SkAutoTUnref<SkSurface> surfaceTransparent( | 71 auto surfaceTransparent(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo
, infoTransparent)); |
| 71 SkSurface::NewRenderTarget(context, SkBudgeted::kNo, infoTransparent)); | |
| 72 check_isopaque(reporter, surfaceTransparent, false); | 72 check_isopaque(reporter, surfaceTransparent, false); |
| 73 | 73 |
| 74 SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType); | 74 SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType); |
| 75 SkAutoTUnref<SkSurface> surfaceOpaque( | 75 auto surfaceOpaque(SkSurface::MakeRenderTarget(context,SkBudgeted::kNo, info
Opaque)); |
| 76 SkSurface::NewRenderTarget(context,SkBudgeted::kNo, infoOpaque)); | |
| 77 | 76 |
| 78 check_isopaque(reporter, surfaceOpaque, true); | 77 check_isopaque(reporter, surfaceOpaque, true); |
| 79 } | 78 } |
| 80 | 79 |
| 81 #endif | 80 #endif |
| OLD | NEW |