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 18 matching lines...) Expand all Loading... |
29 canvas->writePixels(bmp, 0, 0, unpremulConfig); | 29 canvas->writePixels(bmp, 0, 0, unpremulConfig); |
30 } | 30 } |
31 | 31 |
32 static const SkCanvas::Config8888 gUnpremulConfigs[] = { | 32 static const SkCanvas::Config8888 gUnpremulConfigs[] = { |
33 SkCanvas::kNative_Unpremul_Config8888, | 33 SkCanvas::kNative_Unpremul_Config8888, |
34 SkCanvas::kBGRA_Unpremul_Config8888, | 34 SkCanvas::kBGRA_Unpremul_Config8888, |
35 SkCanvas::kRGBA_Unpremul_Config8888, | 35 SkCanvas::kRGBA_Unpremul_Config8888, |
36 }; | 36 }; |
37 | 37 |
38 DEF_GPUTEST(PremulAlphaRoundTrip, reporter, factory) { | 38 DEF_GPUTEST(PremulAlphaRoundTrip, reporter, factory) { |
| 39 const SkImageInfo info = SkImageInfo::MakeN32Premul(256, 256); |
| 40 |
39 SkAutoTUnref<SkBaseDevice> device; | 41 SkAutoTUnref<SkBaseDevice> device; |
40 for (int dtype = 0; dtype < 2; ++dtype) { | 42 for (int dtype = 0; dtype < 2; ++dtype) { |
41 | 43 |
42 int glCtxTypeCnt = 1; | 44 int glCtxTypeCnt = 1; |
43 #if SK_SUPPORT_GPU | 45 #if SK_SUPPORT_GPU |
44 if (0 != dtype) { | 46 if (0 != dtype) { |
45 glCtxTypeCnt = GrContextFactory::kGLContextTypeCnt; | 47 glCtxTypeCnt = GrContextFactory::kGLContextTypeCnt; |
46 } | 48 } |
47 #endif | 49 #endif |
48 for (int glCtxType = 0; glCtxType < glCtxTypeCnt; ++glCtxType) { | 50 for (int glCtxType = 0; glCtxType < glCtxTypeCnt; ++glCtxType) { |
49 if (0 == dtype) { | 51 if (0 == dtype) { |
50 device.reset(new SkBitmapDevice(SkBitmap::kARGB_8888_Config, | 52 device.reset(SkBitmapDevice::Create(info)); |
51 256, | |
52 256, | |
53 false)); | |
54 } else { | 53 } else { |
55 #if SK_SUPPORT_GPU | 54 #if SK_SUPPORT_GPU |
56 GrContextFactory::GLContextType type = | 55 GrContextFactory::GLContextType type = |
57 static_cast<GrContextFactory::GLContextType>(glCtxType); | 56 static_cast<GrContextFactory::GLContextType>(glCtxType); |
58 if (!GrContextFactory::IsRenderingGLContext(type)) { | 57 if (!GrContextFactory::IsRenderingGLContext(type)) { |
59 continue; | 58 continue; |
60 } | 59 } |
61 GrContext* context = factory->get(type); | 60 GrContext* context = factory->get(type); |
62 if (NULL == context) { | 61 if (NULL == context) { |
63 continue; | 62 continue; |
64 } | 63 } |
65 | 64 |
66 device.reset(new SkGpuDevice(context, SkBitmap::kARGB_8888_Confi
g, 256, 256)); | 65 device.reset(SkGpuDevice::Create(context, info, 0)); |
67 #else | 66 #else |
68 continue; | 67 continue; |
69 #endif | 68 #endif |
70 } | 69 } |
71 SkCanvas canvas(device); | 70 SkCanvas canvas(device); |
72 | 71 |
73 SkBitmap readBmp1; | 72 SkBitmap readBmp1; |
74 readBmp1.allocN32Pixels(256, 256); | 73 readBmp1.allocN32Pixels(256, 256); |
75 SkBitmap readBmp2; | 74 SkBitmap readBmp2; |
76 readBmp2.allocN32Pixels(256, 256); | 75 readBmp2.allocN32Pixels(256, 256); |
(...skipping 23 matching lines...) Expand all Loading... |
100 for (int y = 0; y < 256 && success; ++y) { | 99 for (int y = 0; y < 256 && success; ++y) { |
101 for (int x = 0; x < 256 && success; ++x) { | 100 for (int x = 0; x < 256 && success; ++x) { |
102 int i = y * 256 + x; | 101 int i = y * 256 + x; |
103 REPORTER_ASSERT(reporter, success = pixels1[i] == pixels
2[i]); | 102 REPORTER_ASSERT(reporter, success = pixels1[i] == pixels
2[i]); |
104 } | 103 } |
105 } | 104 } |
106 } | 105 } |
107 } | 106 } |
108 } | 107 } |
109 } | 108 } |
OLD | NEW |