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" |
| 11 #include "GrContextPriv.h" |
11 #include "GrDrawContext.h" | 12 #include "GrDrawContext.h" |
12 #include "gl/GrGLGpu.h" | 13 #include "gl/GrGLGpu.h" |
13 #include "gl/GrGLUtil.h" | 14 #include "gl/GrGLUtil.h" |
14 #include "gl/GLTestContext.h" | 15 #include "gl/GLTestContext.h" |
15 | 16 |
16 static void test_read_pixels(skiatest::Reporter* reporter, GrContext* context, | 17 static void test_read_pixels(skiatest::Reporter* reporter, GrContext* context, |
17 GrTexture* rectangleTexture, uint32_t expectedPixel
Values[]) { | 18 GrTexture* rectangleTexture, uint32_t expectedPixel
Values[]) { |
18 int pixelCnt = rectangleTexture->width() * rectangleTexture->height(); | 19 int pixelCnt = rectangleTexture->width() * rectangleTexture->height(); |
19 SkAutoTMalloc<uint32_t> pixels(pixelCnt); | 20 SkAutoTMalloc<uint32_t> pixels(pixelCnt); |
20 memset(pixels.get(), 0, sizeof(uint32_t)*pixelCnt); | 21 memset(pixels.get(), 0, sizeof(uint32_t)*pixelCnt); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 SkAutoTUnref<GrTexture> src(context->textureProvider()->createTexture( | 83 SkAutoTUnref<GrTexture> src(context->textureProvider()->createTexture( |
83 copySrcDesc, SkBudgeted::kYes, pixels.get(), 0)); | 84 copySrcDesc, SkBudgeted::kYes, pixels.get(), 0)); |
84 | 85 |
85 context->copySurface(rectangleTexture, src); | 86 context->copySurface(rectangleTexture, src); |
86 test_read_pixels(reporter, context, rectangleTexture, pixels.get()); | 87 test_read_pixels(reporter, context, rectangleTexture, pixels.get()); |
87 } | 88 } |
88 | 89 |
89 static void test_clear(skiatest::Reporter* reporter, GrContext* context, | 90 static void test_clear(skiatest::Reporter* reporter, GrContext* context, |
90 GrTexture* rectangleTexture) { | 91 GrTexture* rectangleTexture) { |
91 if (rectangleTexture->asRenderTarget()) { | 92 if (rectangleTexture->asRenderTarget()) { |
92 sk_sp<GrDrawContext> dc( | 93 sk_sp<GrDrawContext> dc(context->contextPriv().makeWrappedDrawContext( |
93 context->makeDrawContext(sk_ref_sp(rectangleTexture-
>asRenderTarget()), | 94 sk_ref_sp(rectangleTexture->
asRenderTarget()), |
94 nullptr)); | 95 nullptr)); |
95 if (!dc) { | 96 if (!dc) { |
96 ERRORF(reporter, "Could not get GrDrawContext for rectangle texture.
"); | 97 ERRORF(reporter, "Could not get GrDrawContext for rectangle texture.
"); |
97 return; | 98 return; |
98 } | 99 } |
99 | 100 |
100 // Clear the whole thing. | 101 // Clear the whole thing. |
101 GrColor color0 = GrColorPackRGBA(0xA, 0xB, 0xC, 0xD); | 102 GrColor color0 = GrColorPackRGBA(0xA, 0xB, 0xC, 0xD); |
102 dc->clear(nullptr, color0, false); | 103 dc->clear(nullptr, color0, false); |
103 | 104 |
104 int w = rectangleTexture->width(); | 105 int w = rectangleTexture->width(); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 203 |
203 test_write_pixels(reporter, context, rectangleTexture); | 204 test_write_pixels(reporter, context, rectangleTexture); |
204 | 205 |
205 test_clear(reporter, context, rectangleTexture); | 206 test_clear(reporter, context, rectangleTexture); |
206 | 207 |
207 GR_GL_CALL(glContext->gl(), DeleteTextures(1, &rectTexID)); | 208 GR_GL_CALL(glContext->gl(), DeleteTextures(1, &rectTexID)); |
208 } | 209 } |
209 } | 210 } |
210 | 211 |
211 #endif | 212 #endif |
OLD | NEW |