OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkConfig8888.h" | 10 #include "SkConfig8888.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 SkBitmap bmp; | 51 SkBitmap bmp; |
52 bmp.allocN32Pixels(256, 256); | 52 bmp.allocN32Pixels(256, 256); |
53 | 53 |
54 for (int a = 0; a < 256; ++a) { | 54 for (int a = 0; a < 256; ++a) { |
55 uint32_t* pixels = bmp.getAddr32(0, a); | 55 uint32_t* pixels = bmp.getAddr32(0, a); |
56 for (int r = 0; r < 256; ++r) { | 56 for (int r = 0; r < 256; ++r) { |
57 pixels[r] = proc(SkColorSetARGB(a, r, 0, 0)); | 57 pixels[r] = proc(SkColorSetARGB(a, r, 0, 0)); |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 SkImageInfo info = bmp.info(); | 61 const SkImageInfo info = SkImageInfo::Make(bmp.width(), bmp.height(), |
62 info.fColorType = colorType; | 62 colorType, kUnpremul_SkAlphaType)
; |
63 info.fAlphaType = kUnpremul_SkAlphaType; | |
64 canvas->writePixels(info, bmp.getPixels(), bmp.rowBytes(), 0, 0); | 63 canvas->writePixels(info, bmp.getPixels(), bmp.rowBytes(), 0, 0); |
65 } | 64 } |
66 | 65 |
67 DEF_GPUTEST(PremulAlphaRoundTrip, reporter, factory) { | 66 DEF_GPUTEST(PremulAlphaRoundTrip, reporter, factory) { |
68 const SkImageInfo info = SkImageInfo::MakeN32Premul(256, 256); | 67 const SkImageInfo info = SkImageInfo::MakeN32Premul(256, 256); |
69 | 68 |
70 for (int dtype = 0; dtype < 2; ++dtype) { | 69 for (int dtype = 0; dtype < 2; ++dtype) { |
71 | 70 |
72 int glCtxTypeCnt = 1; | 71 int glCtxTypeCnt = 1; |
73 #if SK_SUPPORT_GPU | 72 #if SK_SUPPORT_GPU |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 if (pixels1[x] != pixels2[x]) { | 124 if (pixels1[x] != pixels2[x]) { |
126 SkDebugf("%x != %x, x = %d, y = %d\n", pixels1[x], p
ixels2[x], x, y); | 125 SkDebugf("%x != %x, x = %d, y = %d\n", pixels1[x], p
ixels2[x], x, y); |
127 } | 126 } |
128 REPORTER_ASSERT(reporter, success = pixels1[x] == pixels
2[x]); | 127 REPORTER_ASSERT(reporter, success = pixels1[x] == pixels
2[x]); |
129 } | 128 } |
130 } | 129 } |
131 } | 130 } |
132 } | 131 } |
133 } | 132 } |
134 } | 133 } |
OLD | NEW |