Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: tests/SurfaceTest.cpp

Issue 2093943002: Have gpu createTestingOlyBackendTexture know if it is a render target or not (Closed) Base URL: https://skia.googlesource.com/skia.git@moreUnitTests
Patch Set: Have gpu createTestingOlyBackendTexture know if it is a render target or not Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/vk/GrVkGpu.cpp ('k') | tests/VkWrapTests.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 return static_cast<intptr_t>(0); 353 return static_cast<intptr_t>(0);
354 } 354 }
355 return static_cast<intptr_t>(rt->getUniqueID()); 355 return static_cast<intptr_t>(rt->getUniqueID());
356 }; 356 };
357 357
358 test_unique_image_snap(reporter, surface.get(), false, imageBackingStore , 358 test_unique_image_snap(reporter, surface.get(), false, imageBackingStore ,
359 surfaceBackingStore); 359 surfaceBackingStore);
360 360
361 // Test again with a "direct" render target; 361 // Test again with a "direct" render target;
362 GrBackendObject textureObject = context->getGpu()->createTestingOnlyBack endTexture(nullptr, 362 GrBackendObject textureObject = context->getGpu()->createTestingOnlyBack endTexture(nullptr,
363 10, 10, kRGBA_8888_GrPixelConfig); 363 10, 10, kRGBA_8888_GrPixelConfig, true);
364 GrBackendTextureDesc desc; 364 GrBackendTextureDesc desc;
365 desc.fConfig = kRGBA_8888_GrPixelConfig; 365 desc.fConfig = kRGBA_8888_GrPixelConfig;
366 desc.fWidth = 10; 366 desc.fWidth = 10;
367 desc.fHeight = 10; 367 desc.fHeight = 10;
368 desc.fFlags = kRenderTarget_GrBackendTextureFlag; 368 desc.fFlags = kRenderTarget_GrBackendTextureFlag;
369 desc.fTextureHandle = textureObject; 369 desc.fTextureHandle = textureObject;
370 GrTexture* texture = context->textureProvider()->wrapBackendTexture(desc ); 370 GrTexture* texture = context->textureProvider()->wrapBackendTexture(desc );
371 { 371 {
372 auto surface(SkSurface::MakeRenderTargetDirect(texture->asRenderTarg et())); 372 auto surface(SkSurface::MakeRenderTargetDirect(texture->asRenderTarg et()));
373 test_unique_image_snap(reporter, surface.get(), true, imageBackingSt ore, 373 test_unique_image_snap(reporter, surface.get(), true, imageBackingSt ore,
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 const int kWidth = 10; 757 const int kWidth = 10;
758 const int kHeight = 10; 758 const int kHeight = 10;
759 SkAutoTDeleteArray<uint32_t> pixels(new uint32_t[kWidth * kHeight]); 759 SkAutoTDeleteArray<uint32_t> pixels(new uint32_t[kWidth * kHeight]);
760 sk_memset32(pixels.get(), color, kWidth * kHeight); 760 sk_memset32(pixels.get(), color, kWidth * kHeight);
761 GrBackendTextureDesc desc; 761 GrBackendTextureDesc desc;
762 desc.fConfig = kRGBA_8888_GrPixelConfig; 762 desc.fConfig = kRGBA_8888_GrPixelConfig;
763 desc.fWidth = kWidth; 763 desc.fWidth = kWidth;
764 desc.fHeight = kHeight; 764 desc.fHeight = kHeight;
765 desc.fFlags = kRenderTarget_GrBackendTextureFlag; 765 desc.fFlags = kRenderTarget_GrBackendTextureFlag;
766 desc.fTextureHandle = context->getGpu()->createTestingOnlyBackendTexture( 766 desc.fTextureHandle = context->getGpu()->createTestingOnlyBackendTexture(
767 pixels.get(), kWidth, kHeight, kRGBA_8888_GrPixelConfig); 767 pixels.get(), kWidth, kHeight, kRGBA_8888_GrPixelConfig, true);
768 desc.fSampleCnt = sampleCnt; 768 desc.fSampleCnt = sampleCnt;
769 sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture(context, desc, nullptr); 769 sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture(context, desc, nullptr);
770 if (!surface) { 770 if (!surface) {
771 context->getGpu()->deleteTestingOnlyBackendTexture(desc.fTextureHandle); 771 context->getGpu()->deleteTestingOnlyBackendTexture(desc.fTextureHandle);
772 return nullptr; 772 return nullptr;
773 } 773 }
774 *outTexture = desc.fTextureHandle; 774 *outTexture = desc.fTextureHandle;
775 return surface; 775 return surface;
776 } 776 }
777 777
778 static sk_sp<SkSurface> create_gpu_surface_backend_texture_as_render_target( 778 static sk_sp<SkSurface> create_gpu_surface_backend_texture_as_render_target(
779 GrContext* context, int sampleCnt, uint32_t color, GrBackendObject* outTextu re) { 779 GrContext* context, int sampleCnt, uint32_t color, GrBackendObject* outTextu re) {
780 const int kWidth = 10; 780 const int kWidth = 10;
781 const int kHeight = 10; 781 const int kHeight = 10;
782 SkAutoTDeleteArray<uint32_t> pixels(new uint32_t[kWidth * kHeight]); 782 SkAutoTDeleteArray<uint32_t> pixels(new uint32_t[kWidth * kHeight]);
783 sk_memset32(pixels.get(), color, kWidth * kHeight); 783 sk_memset32(pixels.get(), color, kWidth * kHeight);
784 GrBackendTextureDesc desc; 784 GrBackendTextureDesc desc;
785 desc.fConfig = kRGBA_8888_GrPixelConfig; 785 desc.fConfig = kRGBA_8888_GrPixelConfig;
786 desc.fWidth = kWidth; 786 desc.fWidth = kWidth;
787 desc.fHeight = kHeight; 787 desc.fHeight = kHeight;
788 desc.fFlags = kRenderTarget_GrBackendTextureFlag; 788 desc.fFlags = kRenderTarget_GrBackendTextureFlag;
789 desc.fTextureHandle = context->getGpu()->createTestingOnlyBackendTexture( 789 desc.fTextureHandle = context->getGpu()->createTestingOnlyBackendTexture(
790 pixels.get(), kWidth, kHeight, kRGBA_8888_GrPixelConfig); 790 pixels.get(), kWidth, kHeight, kRGBA_8888_GrPixelConfig, true);
791 desc.fSampleCnt = sampleCnt; 791 desc.fSampleCnt = sampleCnt;
792 sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTextureAsRenderTarget(c ontext, desc, 792 sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTextureAsRenderTarget(c ontext, desc,
793 n ullptr); 793 n ullptr);
794 if (!surface) { 794 if (!surface) {
795 context->getGpu()->deleteTestingOnlyBackendTexture(desc.fTextureHandle); 795 context->getGpu()->deleteTestingOnlyBackendTexture(desc.fTextureHandle);
796 return nullptr; 796 return nullptr;
797 } 797 }
798 *outTexture = desc.fTextureHandle; 798 *outTexture = desc.fTextureHandle;
799 return surface; 799 return surface;
800 } 800 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 // our surface functions. 958 // our surface functions.
959 GrRenderTarget* rt = surface->getCanvas()->internal_private_accessTo pLayerDrawContext() 959 GrRenderTarget* rt = surface->getCanvas()->internal_private_accessTo pLayerDrawContext()
960 ->accessRenderTarget(); 960 ->accessRenderTarget();
961 REPORTER_ASSERT(reporter, 961 REPORTER_ASSERT(reporter,
962 ctxInfo.grContext()->resourceProvider()->attachStenc ilAttachment(rt)); 962 ctxInfo.grContext()->resourceProvider()->attachStenc ilAttachment(rt));
963 gpu->deleteTestingOnlyBackendTexture(textureObject); 963 gpu->deleteTestingOnlyBackendTexture(textureObject);
964 } 964 }
965 } 965 }
966 } 966 }
967 #endif 967 #endif
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkGpu.cpp ('k') | tests/VkWrapTests.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698