OLD | NEW |
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 Loading... |
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, ctxInfo) { | 56 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(CustomTexture, reporter, ctxInfo) { |
57 GrContext* context = ctxInfo.fGrContext; | 57 GrContext* context = ctxInfo.fGrContext; |
58 sk_gpu_test::GLTestContext* glContext = ctxInfo.fGLContext; | 58 sk_gpu_test::GLTestContext* glContext = ctxInfo.fGLContext; |
59 static const int kWidth = 13; | 59 static const int kWidth = 13; |
60 static const int kHeight = 13; | 60 static const int kHeight = 13; |
61 | 61 |
62 const GrGLInterface* gl = glContext->gl(); | 62 const GrGLInterface* gl = glContext->gl(); |
63 TestStorageAllocator allocator; | 63 TestStorageAllocator allocator; |
64 allocator.m_allowAllocation = true; | 64 allocator.m_allowAllocation = true; |
65 allocator.m_gl = gl; | 65 allocator.m_gl = gl; |
66 GrTextureStorageAllocator grAllocator; | 66 GrTextureStorageAllocator grAllocator; |
(...skipping 16 matching lines...) Expand all Loading... |
83 | 83 |
84 surface->getCanvas()->clear(SK_ColorGREEN); | 84 surface->getCanvas()->clear(SK_ColorGREEN); |
85 sk_sp<SkImage> image2(surface->makeImageSnapshot()); | 85 sk_sp<SkImage> image2(surface->makeImageSnapshot()); |
86 REPORTER_ASSERT(reporter, image2->isTextureBacked()); | 86 REPORTER_ASSERT(reporter, image2->isTextureBacked()); |
87 REPORTER_ASSERT(reporter, allocator.m_mostRecentlyAllocatedStorage != id); | 87 REPORTER_ASSERT(reporter, allocator.m_mostRecentlyAllocatedStorage != id); |
88 | 88 |
89 REPORTER_ASSERT(reporter, image2->readPixels(imageInfo, &dest, 4 * kWidth, 0
, 0)); | 89 REPORTER_ASSERT(reporter, image2->readPixels(imageInfo, &dest, 4 * kWidth, 0
, 0)); |
90 REPORTER_ASSERT(reporter, GrColorUnpackG(dest) == 255); | 90 REPORTER_ASSERT(reporter, GrColorUnpackG(dest) == 255); |
91 } | 91 } |
92 | 92 |
93 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CustomTextureFailure, reporter, ctxInfo) { | 93 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(CustomTextureFailure, reporter, ctxInfo) { |
94 static const int kWidth = 13; | 94 static const int kWidth = 13; |
95 static const int kHeight = 13; | 95 static const int kHeight = 13; |
96 | 96 |
97 const GrGLInterface* gl = ctxInfo.fGLContext->gl(); | 97 const GrGLInterface* gl = ctxInfo.fGLContext->gl(); |
98 TestStorageAllocator allocator; | 98 TestStorageAllocator allocator; |
99 allocator.m_allowAllocation = false; | 99 allocator.m_allowAllocation = false; |
100 allocator.m_gl = gl; | 100 allocator.m_gl = gl; |
101 GrTextureStorageAllocator grAllocator; | 101 GrTextureStorageAllocator grAllocator; |
102 grAllocator.fAllocateTextureStorage = &TestStorageAllocator::allocateTexture
Storage; | 102 grAllocator.fAllocateTextureStorage = &TestStorageAllocator::allocateTexture
Storage; |
103 grAllocator.fDeallocateTextureStorage= &TestStorageAllocator::deallocateText
ureStorage; | 103 grAllocator.fDeallocateTextureStorage= &TestStorageAllocator::deallocateText
ureStorage; |
104 grAllocator.fCtx = &allocator; | 104 grAllocator.fCtx = &allocator; |
105 auto surface(SkSurface_Gpu::MakeRenderTarget( | 105 auto surface(SkSurface_Gpu::MakeRenderTarget( |
106 ctxInfo.fGrContext, SkBudgeted::kNo, SkImageInfo::MakeN32Premul(kWid
th, kHeight), 0, | 106 ctxInfo.fGrContext, SkBudgeted::kNo, SkImageInfo::MakeN32Premul(kWid
th, kHeight), 0, |
107 NULL, grAllocator)); | 107 NULL, grAllocator)); |
108 REPORTER_ASSERT(reporter, !surface); | 108 REPORTER_ASSERT(reporter, !surface); |
109 } | 109 } |
110 | 110 |
111 #endif | 111 #endif |
OLD | NEW |