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