| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, SkBudgeted::kNo, SkImageInfo::MakeN32Premul(kWidth, 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 sk_sp<SkImage> image(surface->makeImageSnapshot()); |
| 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); |
| 81 | 81 |
| 82 surface->getCanvas()->clear(SK_ColorGREEN); | 82 surface->getCanvas()->clear(SK_ColorGREEN); |
| 83 SkAutoTUnref<SkImage> image2(surface->newImageSnapshot()); | 83 sk_sp<SkImage> image2(surface->makeImageSnapshot()); |
| 84 REPORTER_ASSERT(reporter, image2->isTextureBacked()); | 84 REPORTER_ASSERT(reporter, image2->isTextureBacked()); |
| 85 REPORTER_ASSERT(reporter, allocator.m_mostRecentlyAllocatedStorage != id); | 85 REPORTER_ASSERT(reporter, allocator.m_mostRecentlyAllocatedStorage != id); |
| 86 | 86 |
| 87 REPORTER_ASSERT(reporter, image2->readPixels(imageInfo, &dest, 4 * kWidth, 0
, 0)); | 87 REPORTER_ASSERT(reporter, image2->readPixels(imageInfo, &dest, 4 * kWidth, 0
, 0)); |
| 88 REPORTER_ASSERT(reporter, GrColorUnpackG(dest) == 255); | 88 REPORTER_ASSERT(reporter, GrColorUnpackG(dest) == 255); |
| 89 } | 89 } |
| 90 | 90 |
| 91 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CustomTextureFailure, reporter, context, glCo
ntext) { | 91 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CustomTextureFailure, reporter, context, glCo
ntext) { |
| 92 static const int kWidth = 13; | 92 static const int kWidth = 13; |
| 93 static const int kHeight = 13; | 93 static const int kHeight = 13; |
| 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, SkBudgeted::kNo, SkImageInfo::MakeN32Premul(kWidth, 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 |