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

Side by Side Diff: tests/TextureStorageAllocator.cpp

Issue 1860593002: One signature for creating unit tests that run on premade GrContexts (Closed) Base URL: https://skia.googlesource.com/skia.git@try_no_native
Patch Set: another guess to fix windows Created 4 years, 8 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 | « tests/TextBlobCacheTest.cpp ('k') | tests/WritePixelsTest.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 2016 Google Inc. 2 * Copyright 2016 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 "gl/GrGLGpu.h" 10 #include "gl/GrGLGpu.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 TestStorageAllocator* allocator = static_cast<TestStorageAllocator*>(ctx); 46 TestStorageAllocator* allocator = static_cast<TestStorageAllocator*>(ctx);
47 GrGLTextureInfo* info = reinterpret_cast<GrGLTextureInfo*>(texture); 47 GrGLTextureInfo* info = reinterpret_cast<GrGLTextureInfo*>(texture);
48 GR_GL_CALL(allocator->m_gl, DeleteTextures(1, &(info->fID))); 48 GR_GL_CALL(allocator->m_gl, DeleteTextures(1, &(info->fID)));
49 } 49 }
50 50
51 GrGLuint m_mostRecentlyAllocatedStorage; 51 GrGLuint m_mostRecentlyAllocatedStorage;
52 const GrGLInterface* m_gl; 52 const GrGLInterface* m_gl;
53 bool m_allowAllocation; 53 bool m_allowAllocation;
54 }; 54 };
55 55
56 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CustomTexture, reporter, context, glContext) { 56 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CustomTexture, reporter, ctxInfo) {
57 GrContext* context = ctxInfo.fGrContext;
58 sk_gpu_test::GLTestContext* glContext = ctxInfo.fGLContext;
57 static const int kWidth = 13; 59 static const int kWidth = 13;
58 static const int kHeight = 13; 60 static const int kHeight = 13;
59 61
60 const GrGLInterface* gl = glContext->gl(); 62 const GrGLInterface* gl = glContext->gl();
61 TestStorageAllocator allocator; 63 TestStorageAllocator allocator;
62 allocator.m_allowAllocation = true; 64 allocator.m_allowAllocation = true;
63 allocator.m_gl = gl; 65 allocator.m_gl = gl;
64 GrTextureStorageAllocator grAllocator; 66 GrTextureStorageAllocator grAllocator;
65 grAllocator.fAllocateTextureStorage = &TestStorageAllocator::allocateTexture Storage; 67 grAllocator.fAllocateTextureStorage = &TestStorageAllocator::allocateTexture Storage;
66 grAllocator.fDeallocateTextureStorage= &TestStorageAllocator::deallocateText ureStorage; 68 grAllocator.fDeallocateTextureStorage= &TestStorageAllocator::deallocateText ureStorage;
(...skipping 14 matching lines...) Expand all
81 83
82 surface->getCanvas()->clear(SK_ColorGREEN); 84 surface->getCanvas()->clear(SK_ColorGREEN);
83 sk_sp<SkImage> image2(surface->makeImageSnapshot()); 85 sk_sp<SkImage> image2(surface->makeImageSnapshot());
84 REPORTER_ASSERT(reporter, image2->isTextureBacked()); 86 REPORTER_ASSERT(reporter, image2->isTextureBacked());
85 REPORTER_ASSERT(reporter, allocator.m_mostRecentlyAllocatedStorage != id); 87 REPORTER_ASSERT(reporter, allocator.m_mostRecentlyAllocatedStorage != id);
86 88
87 REPORTER_ASSERT(reporter, image2->readPixels(imageInfo, &dest, 4 * kWidth, 0 , 0)); 89 REPORTER_ASSERT(reporter, image2->readPixels(imageInfo, &dest, 4 * kWidth, 0 , 0));
88 REPORTER_ASSERT(reporter, GrColorUnpackG(dest) == 255); 90 REPORTER_ASSERT(reporter, GrColorUnpackG(dest) == 255);
89 } 91 }
90 92
91 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CustomTextureFailure, reporter, context, glCo ntext) { 93 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CustomTextureFailure, reporter, ctxInfo) {
92 static const int kWidth = 13; 94 static const int kWidth = 13;
93 static const int kHeight = 13; 95 static const int kHeight = 13;
94 96
95 const GrGLInterface* gl = glContext->gl(); 97 const GrGLInterface* gl = ctxInfo.fGLContext->gl();
96 TestStorageAllocator allocator; 98 TestStorageAllocator allocator;
97 allocator.m_allowAllocation = false; 99 allocator.m_allowAllocation = false;
98 allocator.m_gl = gl; 100 allocator.m_gl = gl;
99 GrTextureStorageAllocator grAllocator; 101 GrTextureStorageAllocator grAllocator;
100 grAllocator.fAllocateTextureStorage = &TestStorageAllocator::allocateTexture Storage; 102 grAllocator.fAllocateTextureStorage = &TestStorageAllocator::allocateTexture Storage;
101 grAllocator.fDeallocateTextureStorage= &TestStorageAllocator::deallocateText ureStorage; 103 grAllocator.fDeallocateTextureStorage= &TestStorageAllocator::deallocateText ureStorage;
102 grAllocator.fCtx = &allocator; 104 grAllocator.fCtx = &allocator;
103 auto surface(SkSurface_Gpu::MakeRenderTarget( 105 auto surface(SkSurface_Gpu::MakeRenderTarget(
104 context, SkBudgeted::kNo, SkImageInfo::MakeN32Premul(kWidth, kHeight ), 0, 106 ctxInfo.fGrContext, SkBudgeted::kNo, SkImageInfo::MakeN32Premul(kWid th, kHeight), 0,
105 NULL, grAllocator)); 107 NULL, grAllocator));
106 REPORTER_ASSERT(reporter, !surface); 108 REPORTER_ASSERT(reporter, !surface);
107 } 109 }
108 110
109 #endif 111 #endif
OLDNEW
« no previous file with comments | « tests/TextBlobCacheTest.cpp ('k') | tests/WritePixelsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698