| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "Test.h" | 8 #include "Test.h" |
| 9 | 9 |
| 10 // This test is specific to the GPU backend. | 10 // This test is specific to the GPU backend. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // let Skia know we will be using this texture as a render target | 43 // let Skia know we will be using this texture as a render target |
| 44 desc.fFlags = rt ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlag
s; | 44 desc.fFlags = rt ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlag
s; |
| 45 // it is a single channel texture | 45 // it is a single channel texture |
| 46 desc.fConfig = kAlpha_8_GrPixelConfig; | 46 desc.fConfig = kAlpha_8_GrPixelConfig; |
| 47 desc.fWidth = X_SIZE; | 47 desc.fWidth = X_SIZE; |
| 48 desc.fHeight = Y_SIZE; | 48 desc.fHeight = Y_SIZE; |
| 49 | 49 |
| 50 // We are initializing the texture with zeros here | 50 // We are initializing the texture with zeros here |
| 51 memset(alphaData, 0, X_SIZE * Y_SIZE); | 51 memset(alphaData, 0, X_SIZE * Y_SIZE); |
| 52 SkAutoTUnref<GrTexture> texture( | 52 SkAutoTUnref<GrTexture> texture( |
| 53 context->textureProvider()->createTexture(desc, SkBudgeted::kNo , al
phaData, 0)); | 53 context->textureProvider()->createTexture(desc, false, alphaData, 0)
); |
| 54 if (!texture) { | 54 if (!texture) { |
| 55 if (!rt) { | 55 if (!rt) { |
| 56 ERRORF(reporter, "Could not create alpha texture."); | 56 ERRORF(reporter, "Could not create alpha texture."); |
| 57 } | 57 } |
| 58 continue; | 58 continue; |
| 59 } | 59 } |
| 60 | 60 |
| 61 // create a distinctive texture | 61 // create a distinctive texture |
| 62 for (int y = 0; y < Y_SIZE; ++y) { | 62 for (int y = 0; y < Y_SIZE; ++y) { |
| 63 for (int x = 0; x < X_SIZE; ++x) { | 63 for (int x = 0; x < X_SIZE; ++x) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 desc.fHeight = Y_SIZE; | 143 desc.fHeight = Y_SIZE; |
| 144 | 144 |
| 145 uint32_t rgbaData[X_SIZE * Y_SIZE]; | 145 uint32_t rgbaData[X_SIZE * Y_SIZE]; |
| 146 // Make the alpha channel of the rgba texture come from alphaData. | 146 // Make the alpha channel of the rgba texture come from alphaData. |
| 147 for (int y = 0; y < Y_SIZE; ++y) { | 147 for (int y = 0; y < Y_SIZE; ++y) { |
| 148 for (int x = 0; x < X_SIZE; ++x) { | 148 for (int x = 0; x < X_SIZE; ++x) { |
| 149 rgbaData[y * X_SIZE + x] = GrColorPackRGBA(6, 7, 8, alphaDat
a[y * X_SIZE + x]); | 149 rgbaData[y * X_SIZE + x] = GrColorPackRGBA(6, 7, 8, alphaDat
a[y * X_SIZE + x]); |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 SkAutoTUnref<GrTexture> texture( | 152 SkAutoTUnref<GrTexture> texture( |
| 153 context->textureProvider()->createTexture(desc, SkBudgeted::kNo,
rgbaData, 0)); | 153 context->textureProvider()->createTexture(desc, false, rgbaData,
0)); |
| 154 if (!texture) { | 154 if (!texture) { |
| 155 // We always expect to be able to create a RGBA texture | 155 // We always expect to be able to create a RGBA texture |
| 156 if (!rt && kRGBA_8888_GrPixelConfig == desc.fConfig) { | 156 if (!rt && kRGBA_8888_GrPixelConfig == desc.fConfig) { |
| 157 ERRORF(reporter, "Failed to create RGBA texture."); | 157 ERRORF(reporter, "Failed to create RGBA texture."); |
| 158 } | 158 } |
| 159 continue; | 159 continue; |
| 160 } | 160 } |
| 161 | 161 |
| 162 for (auto rowBytes : kRowBytes) { | 162 for (auto rowBytes : kRowBytes) { |
| 163 size_t nonZeroRowBytes = rowBytes ? rowBytes : X_SIZE; | 163 size_t nonZeroRowBytes = rowBytes ? rowBytes : X_SIZE; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 174 SkString msg; | 174 SkString msg; |
| 175 msg.printf("rt:%d, rb:%d", rt, SkToU32(rowBytes)); | 175 msg.printf("rt:%d, rb:%d", rt, SkToU32(rowBytes)); |
| 176 validate_alpha_data(reporter, X_SIZE, Y_SIZE, readback.get(), no
nZeroRowBytes, | 176 validate_alpha_data(reporter, X_SIZE, Y_SIZE, readback.get(), no
nZeroRowBytes, |
| 177 alphaData, msg); | 177 alphaData, msg); |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| 183 #endif | 183 #endif |
| OLD | NEW |