| 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 // This is a GPU-backend specific test. It relies on static intializers to work | 8 // This is a GPU-backend specific test. It relies on static intializers to work |
| 9 | 9 |
| 10 #include "SkTypes.h" | 10 #include "SkTypes.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 gpu->discard(NULL); | 52 gpu->discard(NULL); |
| 53 SkAutoTMalloc<GrColor> buffer(25); | 53 SkAutoTMalloc<GrColor> buffer(25); |
| 54 | 54 |
| 55 GrSurfaceDesc surfDesc; | 55 GrSurfaceDesc surfDesc; |
| 56 surfDesc.fFlags = kRenderTarget_GrSurfaceFlag; | 56 surfDesc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 57 surfDesc.fOrigin = kTopLeft_GrSurfaceOrigin; | 57 surfDesc.fOrigin = kTopLeft_GrSurfaceOrigin; |
| 58 surfDesc.fWidth = 5; | 58 surfDesc.fWidth = 5; |
| 59 surfDesc.fHeight = 5; | 59 surfDesc.fHeight = 5; |
| 60 surfDesc.fConfig = config; | 60 surfDesc.fConfig = config; |
| 61 surfDesc.fSampleCnt = 0; | 61 surfDesc.fSampleCnt = 0; |
| 62 GrTexture* tex = gpu->createTexture(surfDesc, SkBudgeted::kNo, nullptr, 0); | 62 GrTexture* tex = gpu->createTexture(surfDesc, SkBudgeted::kNo); |
| 63 SkASSERT(tex); | 63 SkASSERT(tex); |
| 64 SkASSERT(tex->asRenderTarget()); | 64 SkASSERT(tex->asRenderTarget()); |
| 65 SkIRect rect = SkIRect::MakeWH(5, 5); | 65 SkIRect rect = SkIRect::MakeWH(5, 5); |
| 66 | 66 |
| 67 gpu->clear(rect, GrColor_TRANSPARENT_BLACK, tex->asRenderTarget()); | 67 gpu->clear(rect, GrColor_TRANSPARENT_BLACK, tex->asRenderTarget()); |
| 68 | 68 |
| 69 gpu->readPixels(tex, 0, 0, 5, 5, config, (void*)buffer.get(), 0); | 69 gpu->readPixels(tex, 0, 0, 5, 5, config, (void*)buffer.get(), 0); |
| 70 | 70 |
| 71 REPORTER_ASSERT(reporter, does_full_buffer_contain_correct_color(buffer.get(
), | 71 REPORTER_ASSERT(reporter, does_full_buffer_contain_correct_color(buffer.get(
), |
| 72 GrColor_TRA
NSPARENT_BLACK, | 72 GrColor_TRA
NSPARENT_BLACK, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 SkAutoTMalloc<GrColor> buffer(width * height); | 107 SkAutoTMalloc<GrColor> buffer(width * height); |
| 108 SkAutoTMalloc<GrColor> subBuffer(subWidth * subHeight); | 108 SkAutoTMalloc<GrColor> subBuffer(subWidth * subHeight); |
| 109 | 109 |
| 110 GrSurfaceDesc surfDesc; | 110 GrSurfaceDesc surfDesc; |
| 111 surfDesc.fFlags = kRenderTarget_GrSurfaceFlag; | 111 surfDesc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 112 surfDesc.fOrigin = kTopLeft_GrSurfaceOrigin; | 112 surfDesc.fOrigin = kTopLeft_GrSurfaceOrigin; |
| 113 surfDesc.fWidth = width; | 113 surfDesc.fWidth = width; |
| 114 surfDesc.fHeight = height; | 114 surfDesc.fHeight = height; |
| 115 surfDesc.fConfig = config; | 115 surfDesc.fConfig = config; |
| 116 surfDesc.fSampleCnt = 0; | 116 surfDesc.fSampleCnt = 0; |
| 117 GrTexture* tex = gpu->createTexture(surfDesc, SkBudgeted::kNo, nullptr, 0); | 117 GrTexture* tex = gpu->createTexture(surfDesc, SkBudgeted::kNo); |
| 118 SkASSERT(tex); | 118 SkASSERT(tex); |
| 119 SkASSERT(tex->asRenderTarget()); | 119 SkASSERT(tex->asRenderTarget()); |
| 120 | 120 |
| 121 SkIRect fullRect = SkIRect::MakeWH(10, 10); | 121 SkIRect fullRect = SkIRect::MakeWH(10, 10); |
| 122 gpu->clear(fullRect, GrColor_TRANSPARENT_BLACK, tex->asRenderTarget()); | 122 gpu->clear(fullRect, GrColor_TRANSPARENT_BLACK, tex->asRenderTarget()); |
| 123 | 123 |
| 124 gpu->readPixels(tex, 0, 0, width, height, config, (void*)buffer.get(), 0); | 124 gpu->readPixels(tex, 0, 0, width, height, config, (void*)buffer.get(), 0); |
| 125 | 125 |
| 126 REPORTER_ASSERT(reporter, does_full_buffer_contain_correct_color(buffer.get(
), | 126 REPORTER_ASSERT(reporter, does_full_buffer_contain_correct_color(buffer.get(
), |
| 127 GrColor_TRA
NSPARENT_BLACK, | 127 GrColor_TRA
NSPARENT_BLACK, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 subHeight))
; | 189 subHeight))
; |
| 190 gpu->readPixels(tex, subWidth, subHeight, subWidth, subHeight, | 190 gpu->readPixels(tex, subWidth, subHeight, subWidth, subHeight, |
| 191 config, (void*)subBuffer.get(), 0); | 191 config, (void*)subBuffer.get(), 0); |
| 192 REPORTER_ASSERT(reporter, does_full_buffer_contain_correct_color(subBuffer.g
et(), | 192 REPORTER_ASSERT(reporter, does_full_buffer_contain_correct_color(subBuffer.g
et(), |
| 193 subColor4, | 193 subColor4, |
| 194 config, | 194 config, |
| 195 subWidth, | 195 subWidth, |
| 196 subHeight))
; | 196 subHeight))
; |
| 197 } | 197 } |
| 198 | 198 |
| 199 DEF_GPUTEST(VkClearTests, reporter, factory) { | 199 DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkClearTests, reporter, ctxInfo) { |
| 200 GrContextOptions opts; | 200 basic_clear_test(reporter, ctxInfo.fGrContext, kRGBA_8888_GrPixelConfig); |
| 201 opts.fSuppressPrints = true; | 201 basic_clear_test(reporter, ctxInfo.fGrContext, kBGRA_8888_GrPixelConfig); |
| 202 GrContextFactory debugFactory(opts); | 202 sub_clear_test(reporter, ctxInfo.fGrContext, kRGBA_8888_GrPixelConfig); |
| 203 for (int type = 0; type < GrContextFactory::kContextTypeCnt; ++type) { | 203 sub_clear_test(reporter, ctxInfo.fGrContext, kBGRA_8888_GrPixelConfig); |
| 204 if (static_cast<GrContextFactory::ContextType>(type) != | |
| 205 GrContextFactory::kNativeGL_ContextType) { | |
| 206 continue; | |
| 207 } | |
| 208 GrContext* context = debugFactory.get(static_cast<GrContextFactory::Cont
extType>(type)); | |
| 209 if (context) { | |
| 210 basic_clear_test(reporter, context, kRGBA_8888_GrPixelConfig); | |
| 211 basic_clear_test(reporter, context, kBGRA_8888_GrPixelConfig); | |
| 212 sub_clear_test(reporter, context, kRGBA_8888_GrPixelConfig); | |
| 213 sub_clear_test(reporter, context, kBGRA_8888_GrPixelConfig); | |
| 214 } | |
| 215 | |
| 216 } | |
| 217 } | 204 } |
| 218 | 205 |
| 219 #endif | 206 #endif |
| OLD | NEW |