| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 SkAutoTUnref<GrTexture> src(context->textureProvider()->createTexture( | 82 SkAutoTUnref<GrTexture> src(context->textureProvider()->createTexture( |
| 83 copySrcDesc, SkBudgeted::kYes, pixels.get(), 0)); | 83 copySrcDesc, SkBudgeted::kYes, pixels.get(), 0)); |
| 84 | 84 |
| 85 context->copySurface(rectangleTexture, src); | 85 context->copySurface(rectangleTexture, src); |
| 86 test_read_pixels(reporter, context, rectangleTexture, pixels.get()); | 86 test_read_pixels(reporter, context, rectangleTexture, pixels.get()); |
| 87 } | 87 } |
| 88 | 88 |
| 89 static void test_clear(skiatest::Reporter* reporter, GrContext* context, | 89 static void test_clear(skiatest::Reporter* reporter, GrContext* context, |
| 90 GrTexture* rectangleTexture) { | 90 GrTexture* rectangleTexture) { |
| 91 if (rectangleTexture->asRenderTarget()) { | 91 if (rectangleTexture->asRenderTarget()) { |
| 92 int w = rectangleTexture->width(); |
| 93 int h = rectangleTexture->height(); |
| 94 |
| 92 sk_sp<GrDrawContext> dc( | 95 sk_sp<GrDrawContext> dc( |
| 93 context->drawContext(sk_ref_sp(rectangleTexture->asR
enderTarget()))); | 96 context->drawContext(w, h, sk_ref_sp(rectangleTexture->as
RenderTarget()))); |
| 94 if (!dc) { | 97 if (!dc) { |
| 95 ERRORF(reporter, "Could not get GrDrawContext for rectangle texture.
"); | 98 ERRORF(reporter, "Could not get GrDrawContext for rectangle texture.
"); |
| 96 return; | 99 return; |
| 97 } | 100 } |
| 98 | 101 |
| 99 // Clear the whole thing. | 102 // Clear the whole thing. |
| 100 GrColor color0 = GrColorPackRGBA(0xA, 0xB, 0xC, 0xD); | 103 GrColor color0 = GrColorPackRGBA(0xA, 0xB, 0xC, 0xD); |
| 101 dc->clear(nullptr, color0, false); | 104 dc->clear(nullptr, color0, false); |
| 102 | 105 |
| 103 int w = rectangleTexture->width(); | |
| 104 int h = rectangleTexture->height(); | |
| 105 int pixelCnt = w * h; | 106 int pixelCnt = w * h; |
| 106 SkAutoTMalloc<uint32_t> expectedPixels(pixelCnt); | 107 SkAutoTMalloc<uint32_t> expectedPixels(pixelCnt); |
| 107 | 108 |
| 108 // The clear color is a GrColor, our readback is to kRGBA_8888, which ma
y be different. | 109 // The clear color is a GrColor, our readback is to kRGBA_8888, which ma
y be different. |
| 109 uint32_t expectedColor0 = 0; | 110 uint32_t expectedColor0 = 0; |
| 110 uint8_t* expectedBytes0 = SkTCast<uint8_t*>(&expectedColor0); | 111 uint8_t* expectedBytes0 = SkTCast<uint8_t*>(&expectedColor0); |
| 111 expectedBytes0[0] = GrColorUnpackR(color0); | 112 expectedBytes0[0] = GrColorUnpackR(color0); |
| 112 expectedBytes0[1] = GrColorUnpackG(color0); | 113 expectedBytes0[1] = GrColorUnpackG(color0); |
| 113 expectedBytes0[2] = GrColorUnpackB(color0); | 114 expectedBytes0[2] = GrColorUnpackB(color0); |
| 114 expectedBytes0[3] = GrColorUnpackA(color0); | 115 expectedBytes0[3] = GrColorUnpackA(color0); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 202 |
| 202 test_write_pixels(reporter, context, rectangleTexture); | 203 test_write_pixels(reporter, context, rectangleTexture); |
| 203 | 204 |
| 204 test_clear(reporter, context, rectangleTexture); | 205 test_clear(reporter, context, rectangleTexture); |
| 205 | 206 |
| 206 GR_GL_CALL(glContext->gl(), DeleteTextures(1, &rectTexID)); | 207 GR_GL_CALL(glContext->gl(), DeleteTextures(1, &rectTexID)); |
| 207 } | 208 } |
| 208 } | 209 } |
| 209 | 210 |
| 210 #endif | 211 #endif |
| OLD | NEW |