diff options
author | 2016-02-09 16:28:46 -0800 | |
---|---|---|
committer | 2016-02-09 16:28:46 -0800 | |
commit | 64e75330916f670cf9db9eb7a850afc325b18645 (patch) | |
tree | c58dab2c288218be347258031e0a452dabafb8ec /tests | |
parent | 77a5b0e1b48845c5b6715c2948df87f5df053696 (diff) |
Revert of skia: Add support for CHROMIUM_image backed textures. (patchset #19 id:380001 of https://codereview.chromium.org/1623653002/ )
Reason for revert:
Breaks ASAN bot:
Direct leak of 56 byte(s) in 1 object(s) allocated from:
...
test_CustomTexture
https://uberchromegw.corp.google.com/i/client.skia/builders/Test-Ubuntu-GCC-Golo-GPU-GT610-x86_64-Debug-ASAN/builds/2676/steps/dm/logs/stdio
Original issue's description:
> skia: Add support for CHROMIUM_image backed textures.
>
> I created a new abstract base class TextureStorageAllocator that consumers of
> Skia can subclass and pass back to Skia. When a surface is created with a
> pointer to a TextureStorageAllocator, any textures it creates, or that are
> derived from the original surface, will allocate and deallocate storage using
> the methods on TextureStorageAllocator.
>
> BUG=https://code.google.com/p/chromium/issues/detail?id=579664
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1623653002
>
> Committed: https://skia.googlesource.com/skia/+/92098e691f10a010e7421125ba4d44c02506bb55
>
> Committed: https://skia.googlesource.com/skia/+/7fec91ce6660190f8d7c5eb6f3061e4550cc672b
>
> Committed: https://skia.googlesource.com/skia/+/b8d6e088590160f1198110c2371b802c1d541a36
TBR=bsalomon@chromium.org,cblume@chromium.org,bsalomon@google.com,robertphillips@google.com,egdaniel@google.com,reed@google.com,erikchen@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=https://code.google.com/p/chromium/issues/detail?id=579664
Review URL: https://codereview.chromium.org/1684993002
Diffstat (limited to 'tests')
-rw-r--r-- | tests/TextureStorageAllocator.cpp | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/tests/TextureStorageAllocator.cpp b/tests/TextureStorageAllocator.cpp deleted file mode 100644 index da5bff2986..0000000000 --- a/tests/TextureStorageAllocator.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2016 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "Test.h" -#if SK_SUPPORT_GPU -#include "gl/GrGLGpu.h" -#include "GrContext.h" -#include "SkSurface_Gpu.h" -#include "../include/gpu/gl/SkGLContext.h" -#include "../include/gpu/GrTypes.h" -#include "../include/private/SkTemplates.h" - -class TestStorageAllocator { - public: - static GrTextureStorageAllocator::Result allocateTextureStorage(void* ctx, - GrBackendObject texture, unsigned width, unsigned height, GrPixelConfig config, - const void* srcData, GrSurfaceOrigin) { - TestStorageAllocator* allocator = static_cast<TestStorageAllocator*>(ctx); - if (!allocator->m_allowAllocation) - return GrTextureStorageAllocator::Result::kFailed; - SkAutoTMalloc<uint8_t> pixels(width * height * 4); - memset(pixels.get(), 0, width * height * 4); - - GrGLuint id; - GrGLenum target = GR_GL_TEXTURE_2D; - GR_GL_CALL(allocator->m_gl, GenTextures(1, &id)); - GR_GL_CALL(allocator->m_gl, BindTexture(target, id)); - GR_GL_CALL(allocator->m_gl, TexParameteri(target, GR_GL_TEXTURE_MAG_FILTER, GR_GL_NEAREST)); - GR_GL_CALL(allocator->m_gl, TexParameteri(target, GR_GL_TEXTURE_MIN_FILTER, GR_GL_NEAREST)); - GR_GL_CALL(allocator->m_gl, TexParameteri(target, GR_GL_TEXTURE_WRAP_S, GR_GL_CLAMP_TO_EDGE)); - GR_GL_CALL(allocator->m_gl, TexParameteri(target, GR_GL_TEXTURE_WRAP_T, GR_GL_CLAMP_TO_EDGE)); - GR_GL_CALL(allocator->m_gl, TexImage2D(target, 0, GR_GL_RGBA, width, height, 0, GR_GL_RGBA, - GR_GL_UNSIGNED_BYTE, pixels.get())); - - GrGLTextureInfo* info = reinterpret_cast<GrGLTextureInfo*>(texture); - info->fID = id; - info->fTarget = target; - allocator->m_mostRecentlyAllocatedStorage = id; - return GrTextureStorageAllocator::Result::kSucceededWithoutUpload; - } - static void deallocateTextureStorage(void* ctx, GrBackendObject texture) { - TestStorageAllocator* allocator = static_cast<TestStorageAllocator*>(ctx); - GrGLTextureInfo* info = reinterpret_cast<GrGLTextureInfo*>(texture); - GR_GL_CALL(allocator->m_gl, DeleteTextures(1, &(info->fID))); - } - - GrGLuint m_mostRecentlyAllocatedStorage; - const GrGLInterface* m_gl; - bool m_allowAllocation; -}; - -DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CustomTexture, reporter, context, glContext) { - static const int kWidth = 13; - static const int kHeight = 13; - - const GrGLInterface* gl = glContext->gl(); - TestStorageAllocator allocator; - allocator.m_allowAllocation = true; - allocator.m_gl = gl; - GrTextureStorageAllocator grAllocator; - grAllocator.fAllocateTextureStorage = &TestStorageAllocator::allocateTextureStorage; - grAllocator.fDeallocateTextureStorage= &TestStorageAllocator::deallocateTextureStorage; - grAllocator.fCtx = &allocator; - - SkSurface* surface = SkSurface_Gpu::NewRenderTarget( - context, SkSurface_Gpu::kNo_Budgeted, SkImageInfo::MakeN32Premul(kWidth, kHeight), 0, - NULL, grAllocator); - REPORTER_ASSERT(reporter, surface); - GrGLuint id = allocator.m_mostRecentlyAllocatedStorage; - - SkImage* image = surface->newImageSnapshot(); - REPORTER_ASSERT(reporter, image->isTextureBacked()); - SkImageInfo imageInfo = SkImageInfo::MakeN32Premul(1,1); - GrColor dest = 0x11223344; - REPORTER_ASSERT(reporter, image->readPixels(imageInfo, &dest, 4 * kWidth, 0, 0)); - REPORTER_ASSERT(reporter, GrColorUnpackG(dest) == 0); - - surface->getCanvas()->clear(SK_ColorGREEN); - SkImage* image2 = surface->newImageSnapshot(); - REPORTER_ASSERT(reporter, image2->isTextureBacked()); - REPORTER_ASSERT(reporter, allocator.m_mostRecentlyAllocatedStorage != id); - - REPORTER_ASSERT(reporter, image2->readPixels(imageInfo, &dest, 4 * kWidth, 0, 0)); - REPORTER_ASSERT(reporter, GrColorUnpackG(dest) == 255); -} - -DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CustomTextureFailure, reporter, context, glContext) { - static const int kWidth = 13; - static const int kHeight = 13; - - const GrGLInterface* gl = glContext->gl(); - TestStorageAllocator allocator; - allocator.m_allowAllocation = false; - allocator.m_gl = gl; - GrTextureStorageAllocator grAllocator; - grAllocator.fAllocateTextureStorage = &TestStorageAllocator::allocateTextureStorage; - grAllocator.fDeallocateTextureStorage= &TestStorageAllocator::deallocateTextureStorage; - grAllocator.fCtx = &allocator; - SkSurface* surface = SkSurface_Gpu::NewRenderTarget( - context, SkSurface_Gpu::kNo_Budgeted, SkImageInfo::MakeN32Premul(kWidth, kHeight), 0, - NULL, grAllocator); - REPORTER_ASSERT(reporter, !surface); -} - -#endif |