| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // Clear the whole thing. | 97 // Clear the whole thing. |
| 98 GrColor color0 = GrColorPackRGBA(0xA, 0xB, 0xC, 0xD); | 98 GrColor color0 = GrColorPackRGBA(0xA, 0xB, 0xC, 0xD); |
| 99 dc->clear(nullptr, color0, false); | 99 dc->clear(nullptr, color0, false); |
| 100 | 100 |
| 101 int w = rectangleTexture->width(); | 101 int w = rectangleTexture->width(); |
| 102 int h = rectangleTexture->height(); | 102 int h = rectangleTexture->height(); |
| 103 int pixelCnt = w * h; | 103 int pixelCnt = w * h; |
| 104 SkAutoTMalloc<uint32_t> expectedPixels(pixelCnt); | 104 SkAutoTMalloc<uint32_t> expectedPixels(pixelCnt); |
| 105 | 105 |
| 106 // The clear color is a GrColor, our readback is to kRGBA_8888, which ma
y be different. | 106 // The clear color is a GrColor, our readback is to kRGBA_8888, which ma
y be different. |
| 107 uint32_t expectedColor0; | 107 uint32_t expectedColor0 = 0; |
| 108 uint8_t* expectedBytes0 = SkTCast<uint8_t*>(&expectedColor0); | 108 uint8_t* expectedBytes0 = SkTCast<uint8_t*>(&expectedColor0); |
| 109 expectedBytes0[0] = GrColorUnpackR(color0); | 109 expectedBytes0[0] = GrColorUnpackR(color0); |
| 110 expectedBytes0[1] = GrColorUnpackG(color0); | 110 expectedBytes0[1] = GrColorUnpackG(color0); |
| 111 expectedBytes0[2] = GrColorUnpackB(color0); | 111 expectedBytes0[2] = GrColorUnpackB(color0); |
| 112 expectedBytes0[3] = GrColorUnpackA(color0); | 112 expectedBytes0[3] = GrColorUnpackA(color0); |
| 113 for (int i = 0; i < rectangleTexture->width() * rectangleTexture->height
(); ++i) { | 113 for (int i = 0; i < rectangleTexture->width() * rectangleTexture->height
(); ++i) { |
| 114 expectedPixels.get()[i] = expectedColor0; | 114 expectedPixels.get()[i] = expectedColor0; |
| 115 } | 115 } |
| 116 | 116 |
| 117 // Clear the the top to a different color. | 117 // Clear the the top to a different color. |
| 118 GrColor color1 = GrColorPackRGBA(0x1, 0x2, 0x3, 0x4); | 118 GrColor color1 = GrColorPackRGBA(0x1, 0x2, 0x3, 0x4); |
| 119 SkIRect rect = SkIRect::MakeWH(w, h/2); | 119 SkIRect rect = SkIRect::MakeWH(w, h/2); |
| 120 dc->clear(&rect, color1, false); | 120 dc->clear(&rect, color1, false); |
| 121 | 121 |
| 122 uint32_t expectedColor1; | 122 uint32_t expectedColor1 = 0; |
| 123 uint8_t* expectedBytes1 = SkTCast<uint8_t*>(&expectedColor1); | 123 uint8_t* expectedBytes1 = SkTCast<uint8_t*>(&expectedColor1); |
| 124 expectedBytes1[0] = GrColorUnpackR(color1); | 124 expectedBytes1[0] = GrColorUnpackR(color1); |
| 125 expectedBytes1[1] = GrColorUnpackG(color1); | 125 expectedBytes1[1] = GrColorUnpackG(color1); |
| 126 expectedBytes1[2] = GrColorUnpackB(color1); | 126 expectedBytes1[2] = GrColorUnpackB(color1); |
| 127 expectedBytes1[3] = GrColorUnpackA(color1); | 127 expectedBytes1[3] = GrColorUnpackA(color1); |
| 128 | 128 |
| 129 for (int y = 0; y < h/2; ++y) { | 129 for (int y = 0; y < h/2; ++y) { |
| 130 for (int x = 0; x < w; ++x) { | 130 for (int x = 0; x < w; ++x) { |
| 131 expectedPixels.get()[y * h + x] = expectedColor1; | 131 expectedPixels.get()[y * h + x] = expectedColor1; |
| 132 } | 132 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 197 |
| 198 test_write_pixels(reporter, context, rectangleTexture); | 198 test_write_pixels(reporter, context, rectangleTexture); |
| 199 | 199 |
| 200 test_clear(reporter, context, rectangleTexture); | 200 test_clear(reporter, context, rectangleTexture); |
| 201 | 201 |
| 202 GR_GL_CALL(glContext->gl(), DeleteTextures(1, &rectTexID)); | 202 GR_GL_CALL(glContext->gl(), DeleteTextures(1, &rectTexID)); |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 #endif | 206 #endif |
| OLD | NEW |