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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 const GrGLInterface* gl = glContext->gl(); | 60 const GrGLInterface* gl = glContext->gl(); |
61 TestStorageAllocator allocator; | 61 TestStorageAllocator allocator; |
62 allocator.m_allowAllocation = true; | 62 allocator.m_allowAllocation = true; |
63 allocator.m_gl = gl; | 63 allocator.m_gl = gl; |
64 GrTextureStorageAllocator grAllocator; | 64 GrTextureStorageAllocator grAllocator; |
65 grAllocator.fAllocateTextureStorage = &TestStorageAllocator::allocateTexture
Storage; | 65 grAllocator.fAllocateTextureStorage = &TestStorageAllocator::allocateTexture
Storage; |
66 grAllocator.fDeallocateTextureStorage= &TestStorageAllocator::deallocateText
ureStorage; | 66 grAllocator.fDeallocateTextureStorage= &TestStorageAllocator::deallocateText
ureStorage; |
67 grAllocator.fCtx = &allocator; | 67 grAllocator.fCtx = &allocator; |
68 | 68 |
69 SkAutoTUnref<SkSurface> surface(SkSurface_Gpu::NewRenderTarget( | 69 SkAutoTUnref<SkSurface> surface(SkSurface_Gpu::NewRenderTarget( |
70 context, SkBudgeted::kNo, SkImageInfo::MakeN32Premul(kWidth, kHeight
), 0, | 70 context, SkSurface_Gpu::kNo_Budgeted, SkImageInfo::MakeN32Premul(kWi
dth, kHeight), 0, |
71 NULL, grAllocator)); | 71 NULL, grAllocator)); |
72 REPORTER_ASSERT(reporter, surface); | 72 REPORTER_ASSERT(reporter, surface); |
73 GrGLuint id = allocator.m_mostRecentlyAllocatedStorage; | 73 GrGLuint id = allocator.m_mostRecentlyAllocatedStorage; |
74 | 74 |
75 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); | 75 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); |
76 REPORTER_ASSERT(reporter, image->isTextureBacked()); | 76 REPORTER_ASSERT(reporter, image->isTextureBacked()); |
77 SkImageInfo imageInfo = SkImageInfo::MakeN32Premul(1,1); | 77 SkImageInfo imageInfo = SkImageInfo::MakeN32Premul(1,1); |
78 GrColor dest = 0x11223344; | 78 GrColor dest = 0x11223344; |
79 REPORTER_ASSERT(reporter, image->readPixels(imageInfo, &dest, 4 * kWidth, 0,
0)); | 79 REPORTER_ASSERT(reporter, image->readPixels(imageInfo, &dest, 4 * kWidth, 0,
0)); |
80 REPORTER_ASSERT(reporter, GrColorUnpackG(dest) == 0); | 80 REPORTER_ASSERT(reporter, GrColorUnpackG(dest) == 0); |
(...skipping 13 matching lines...) Expand all Loading... |
94 | 94 |
95 const GrGLInterface* gl = glContext->gl(); | 95 const GrGLInterface* gl = glContext->gl(); |
96 TestStorageAllocator allocator; | 96 TestStorageAllocator allocator; |
97 allocator.m_allowAllocation = false; | 97 allocator.m_allowAllocation = false; |
98 allocator.m_gl = gl; | 98 allocator.m_gl = gl; |
99 GrTextureStorageAllocator grAllocator; | 99 GrTextureStorageAllocator grAllocator; |
100 grAllocator.fAllocateTextureStorage = &TestStorageAllocator::allocateTexture
Storage; | 100 grAllocator.fAllocateTextureStorage = &TestStorageAllocator::allocateTexture
Storage; |
101 grAllocator.fDeallocateTextureStorage= &TestStorageAllocator::deallocateText
ureStorage; | 101 grAllocator.fDeallocateTextureStorage= &TestStorageAllocator::deallocateText
ureStorage; |
102 grAllocator.fCtx = &allocator; | 102 grAllocator.fCtx = &allocator; |
103 SkAutoTUnref<SkSurface> surface(SkSurface_Gpu::NewRenderTarget( | 103 SkAutoTUnref<SkSurface> surface(SkSurface_Gpu::NewRenderTarget( |
104 context, SkBudgeted::kNo, SkImageInfo::MakeN32Premul(kWidth, kHeight
), 0, | 104 context, SkSurface_Gpu::kNo_Budgeted, SkImageInfo::MakeN32Premul(kWi
dth, kHeight), 0, |
105 NULL, grAllocator)); | 105 NULL, grAllocator)); |
106 REPORTER_ASSERT(reporter, !surface); | 106 REPORTER_ASSERT(reporter, !surface); |
107 } | 107 } |
108 | 108 |
109 #endif | 109 #endif |
OLD | NEW |