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 "Resources.h" | 9 #include "Resources.h" |
10 #include "Test.h" | 10 #include "Test.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 auto surfaceTransparent(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo
, infoTransparent)); | 95 auto surfaceTransparent(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo
, infoTransparent)); |
96 check_isopaque(reporter, surfaceTransparent, false); | 96 check_isopaque(reporter, surfaceTransparent, false); |
97 | 97 |
98 SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType); | 98 SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType); |
99 auto surfaceOpaque(SkSurface::MakeRenderTarget(context,SkBudgeted::kNo, info
Opaque)); | 99 auto surfaceOpaque(SkSurface::MakeRenderTarget(context,SkBudgeted::kNo, info
Opaque)); |
100 | 100 |
101 check_isopaque(reporter, surfaceOpaque, true); | 101 check_isopaque(reporter, surfaceOpaque, true); |
102 } | 102 } |
103 | 103 |
104 #endif | 104 #endif |
| 105 |
| 106 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 107 #include "SkPictureRecorder.h" |
| 108 |
| 109 static sk_sp<SkPicture> make_picture() { |
| 110 SkPictureRecorder recorder; |
| 111 SkCanvas* canvas = recorder.beginRecording({ 0, 0, 10, 10 }); |
| 112 canvas->drawColor(SK_ColorRED); |
| 113 return recorder.finishRecordingAsPicture(); |
| 114 } |
| 115 |
| 116 DEF_TEST(Image_isAlphaOnly, reporter) { |
| 117 SkPMColor pmColors = 0; |
| 118 SkPixmap pmap = { |
| 119 SkImageInfo::MakeN32Premul(1, 1), |
| 120 &pmColors, |
| 121 sizeof(pmColors) |
| 122 }; |
| 123 for (auto& image : { |
| 124 SkImage::MakeRasterCopy(pmap), |
| 125 GetResourceAsImage("mandrill_128.png"), |
| 126 GetResourceAsImage("color_wheel.jpg"), |
| 127 SkImage::MakeFromPicture(make_picture(), { 10, 10 }, nullptr, nullptr), |
| 128 }) |
| 129 { |
| 130 REPORTER_ASSERT(reporter, image->isAlphaOnly() == false); |
| 131 } |
| 132 |
| 133 REPORTER_ASSERT(reporter, SkImage::MakeRasterCopy({ |
| 134 SkImageInfo::MakeA8(1, 1), (uint8_t*)&pmColors, 1})->isAlphaOnly() == tr
ue); |
| 135 } |
OLD | NEW |