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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 test_read_pixels(reporter, context, rectangleTexture, pixels.get()); | 51 test_read_pixels(reporter, context, rectangleTexture, pixels.get()); |
52 } | 52 } |
53 | 53 |
54 static void test_copy_surface_src(skiatest::Reporter* reporter, GrContext* conte
xt, | 54 static void test_copy_surface_src(skiatest::Reporter* reporter, GrContext* conte
xt, |
55 GrTexture* rectangleTexture, uint32_t expected
PixelValues[]) { | 55 GrTexture* rectangleTexture, uint32_t expected
PixelValues[]) { |
56 GrSurfaceDesc copyDstDesc; | 56 GrSurfaceDesc copyDstDesc; |
57 copyDstDesc.fConfig = kRGBA_8888_GrPixelConfig; | 57 copyDstDesc.fConfig = kRGBA_8888_GrPixelConfig; |
58 copyDstDesc.fWidth = rectangleTexture->width(); | 58 copyDstDesc.fWidth = rectangleTexture->width(); |
59 copyDstDesc.fHeight = rectangleTexture->height(); | 59 copyDstDesc.fHeight = rectangleTexture->height(); |
60 copyDstDesc.fFlags = kRenderTarget_GrSurfaceFlag; | 60 copyDstDesc.fFlags = kRenderTarget_GrSurfaceFlag; |
61 SkAutoTUnref<GrTexture> dst(context->textureProvider()->createTexture(copyDs
tDesc, true)); | 61 SkAutoTUnref<GrTexture> dst(context->textureProvider()->createTexture( |
| 62 copyDstDesc, SkBudgeted::kYes)); |
62 context->copySurface(dst, rectangleTexture); | 63 context->copySurface(dst, rectangleTexture); |
63 test_read_pixels(reporter, context, dst, expectedPixelValues); | 64 test_read_pixels(reporter, context, dst, expectedPixelValues); |
64 } | 65 } |
65 | 66 |
66 static void test_copy_surface_dst(skiatest::Reporter* reporter, GrContext* conte
xt, | 67 static void test_copy_surface_dst(skiatest::Reporter* reporter, GrContext* conte
xt, |
67 GrTexture* rectangleTexture) { | 68 GrTexture* rectangleTexture) { |
68 int pixelCnt = rectangleTexture->width() * rectangleTexture->height(); | 69 int pixelCnt = rectangleTexture->width() * rectangleTexture->height(); |
69 SkAutoTMalloc<uint32_t> pixels(pixelCnt); | 70 SkAutoTMalloc<uint32_t> pixels(pixelCnt); |
70 for (int y = 0; y < rectangleTexture->width(); ++y) { | 71 for (int y = 0; y < rectangleTexture->width(); ++y) { |
71 for (int x = 0; x < rectangleTexture->height(); ++x) { | 72 for (int x = 0; x < rectangleTexture->height(); ++x) { |
72 pixels.get()[y * rectangleTexture->width() + x] = GrColorPackRGBA(y,
x, x * y, x *+ y); | 73 pixels.get()[y * rectangleTexture->width() + x] = GrColorPackRGBA(y,
x, x * y, x *+ y); |
73 } | 74 } |
74 } | 75 } |
75 | 76 |
76 GrSurfaceDesc copySrcDesc; | 77 GrSurfaceDesc copySrcDesc; |
77 copySrcDesc.fConfig = kRGBA_8888_GrPixelConfig; | 78 copySrcDesc.fConfig = kRGBA_8888_GrPixelConfig; |
78 copySrcDesc.fWidth = rectangleTexture->width(); | 79 copySrcDesc.fWidth = rectangleTexture->width(); |
79 copySrcDesc.fHeight = rectangleTexture->height(); | 80 copySrcDesc.fHeight = rectangleTexture->height(); |
80 copySrcDesc.fFlags = kRenderTarget_GrSurfaceFlag; | 81 copySrcDesc.fFlags = kRenderTarget_GrSurfaceFlag; |
81 SkAutoTUnref<GrTexture> src(context->textureProvider()->createTexture(copySr
cDesc, true, | 82 SkAutoTUnref<GrTexture> src(context->textureProvider()->createTexture( |
82 pixels
.get(), 0)); | 83 copySrcDesc, SkBudgeted::kYes, pixels.get(), 0)); |
83 | 84 |
84 context->copySurface(rectangleTexture, src); | 85 context->copySurface(rectangleTexture, src); |
85 test_read_pixels(reporter, context, rectangleTexture, pixels.get()); | 86 test_read_pixels(reporter, context, rectangleTexture, pixels.get()); |
86 } | 87 } |
87 | 88 |
88 static void test_clear(skiatest::Reporter* reporter, GrContext* context, | 89 static void test_clear(skiatest::Reporter* reporter, GrContext* context, |
89 GrTexture* rectangleTexture) { | 90 GrTexture* rectangleTexture) { |
90 if (rectangleTexture->asRenderTarget()) { | 91 if (rectangleTexture->asRenderTarget()) { |
91 SkAutoTUnref<GrDrawContext> dc(context->drawContext(rectangleTexture->as
RenderTarget())); | 92 SkAutoTUnref<GrDrawContext> dc(context->drawContext(rectangleTexture->as
RenderTarget())); |
92 if (!dc) { | 93 if (!dc) { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 198 |
198 test_write_pixels(reporter, context, rectangleTexture); | 199 test_write_pixels(reporter, context, rectangleTexture); |
199 | 200 |
200 test_clear(reporter, context, rectangleTexture); | 201 test_clear(reporter, context, rectangleTexture); |
201 | 202 |
202 GR_GL_CALL(glContext->gl(), DeleteTextures(1, &rectTexID)); | 203 GR_GL_CALL(glContext->gl(), DeleteTextures(1, &rectTexID)); |
203 } | 204 } |
204 } | 205 } |
205 | 206 |
206 #endif | 207 #endif |
OLD | NEW |