| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 <functional> | 8 #include <functional> |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkData.h" | 10 #include "SkData.h" |
| (...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 desc.fWidth = kWidth; | 893 desc.fWidth = kWidth; |
| 894 desc.fHeight = kHeight; | 894 desc.fHeight = kHeight; |
| 895 desc.fFlags = kRenderTarget_GrBackendTextureFlag; | 895 desc.fFlags = kRenderTarget_GrBackendTextureFlag; |
| 896 desc.fTextureHandle = textureObject; | 896 desc.fTextureHandle = textureObject; |
| 897 | 897 |
| 898 SkSurface* surface = SkSurface::NewFromBackendTexture(context, desc, nul
lptr); | 898 SkSurface* surface = SkSurface::NewFromBackendTexture(context, desc, nul
lptr); |
| 899 test_surface_clear(reporter, surface, grSurfaceGetter, 0xABABABAB); | 899 test_surface_clear(reporter, surface, grSurfaceGetter, 0xABABABAB); |
| 900 context->getGpu()->deleteTestingOnlyBackendTexture(textureObject); | 900 context->getGpu()->deleteTestingOnlyBackendTexture(textureObject); |
| 901 } | 901 } |
| 902 } | 902 } |
| 903 |
| 904 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ExternalTextureSurfaceUsesRenderTargetCache_G
pu, reporter, |
| 905 context) { |
| 906 |
| 907 static const int kWidth = 10; |
| 908 static const int kHeight = 10; |
| 909 SkAutoTDeleteArray<uint32_t> pixels(new uint32_t[kWidth * kHeight]); |
| 910 memset(pixels.get(), 0xAB, sizeof(uint32_t) * kWidth * kHeight); |
| 911 |
| 912 GrBackendObject textureObject = |
| 913 context->getGpu()->createTestingOnlyBackendTexture(pixels.get(), kWi
dth, kHeight, |
| 914 kRGBA_8888_GrPixe
lConfig); |
| 915 GrBackendTextureDesc desc; |
| 916 desc.fConfig = kRGBA_8888_GrPixelConfig; |
| 917 desc.fWidth = kWidth; |
| 918 desc.fHeight = kHeight; |
| 919 desc.fFlags = kRenderTarget_GrBackendTextureFlag; |
| 920 desc.fTextureHandle = textureObject; |
| 921 |
| 922 for (auto sampleCnt : { 0, 4 }) { |
| 923 desc.fSampleCnt = sampleCnt; |
| 924 |
| 925 SkAutoTUnref<SkSurface> surface1( |
| 926 SkSurface::NewFromBackendTextureAsRenderTarget(context, desc, nullpt
r)); |
| 927 GrBackendObject surface1_id; |
| 928 REPORTER_ASSERT(reporter, surface1->getRenderTargetHandle( |
| 929 &surface1_id, SkSurface::kFlushRead_BackendHandleAccess)); |
| 930 // TODO: check for clear. |
| 931 SkAutoTUnref<SkSurface> surface2( |
| 932 SkSurface::NewFromBackendTextureAsRenderTarget(context, desc, nullpt
r)); |
| 933 GrBackendObject surface2_id; |
| 934 REPORTER_ASSERT(reporter, surface2->getRenderTargetHandle( |
| 935 &surface2_id, SkSurface::kFlushRead_BackendHandleAccess)); |
| 936 // TODO: check for clear. |
| 937 |
| 938 REPORTER_ASSERT(reporter, surface1_id == surface2_id); |
| 939 } |
| 940 context->getGpu()->deleteTestingOnlyBackendTexture(textureObject); |
| 941 } |
| 903 #endif | 942 #endif |
| OLD | NEW |