Remove GrTextureStorageAllocator. This was added from Chromium but never used and not expected to be used.

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1886613003

Review URL: https://codereview.chromium.org/1886613003
This commit is contained in:
bsalomon 2016-04-13 14:29:25 -07:00 committed by Commit bot
parent 0e3c55431b
commit 7e68ab7318
13 changed files with 17 additions and 250 deletions

View File

@ -112,13 +112,9 @@ public:
/** /**
* Return a new surface whose contents will be drawn to an offscreen * Return a new surface whose contents will be drawn to an offscreen
* render target, allocated by the surface. * render target, allocated by the surface.
*
* The GrTextureStorageAllocator will be reused if SkImage snapshots create
* additional textures.
*/ */
static sk_sp<SkSurface> MakeRenderTarget( static sk_sp<SkSurface> MakeRenderTarget(
GrContext*, SkBudgeted, const SkImageInfo&, int sampleCount, const SkSurfaceProps*, GrContext*, SkBudgeted, const SkImageInfo&, int sampleCount, const SkSurfaceProps*);
GrTextureStorageAllocator = GrTextureStorageAllocator());
static sk_sp<SkSurface> MakeRenderTarget(GrContext* gr, SkBudgeted b, const SkImageInfo& info) { static sk_sp<SkSurface> MakeRenderTarget(GrContext* gr, SkBudgeted b, const SkImageInfo& info) {
return MakeRenderTarget(gr, b, info, 0, nullptr); return MakeRenderTarget(gr, b, info, 0, nullptr);
@ -172,8 +168,7 @@ public:
return MakeFromBackendTextureAsRenderTarget(ctx, desc, props).release(); return MakeFromBackendTextureAsRenderTarget(ctx, desc, props).release();
} }
static SkSurface* NewRenderTarget(GrContext* ctx, SkBudgeted b, const SkImageInfo& info, static SkSurface* NewRenderTarget(GrContext* ctx, SkBudgeted b, const SkImageInfo& info,
int sampleCount, const SkSurfaceProps* props = NULL, int sampleCount, const SkSurfaceProps* props = NULL) {
GrTextureStorageAllocator a = GrTextureStorageAllocator()) {
return MakeRenderTarget(ctx, b, info, sampleCount, props, a).release(); return MakeRenderTarget(ctx, b, info, sampleCount, props, a).release();
} }
static SkSurface* NewRenderTarget(GrContext* gr, SkBudgeted b, const SkImageInfo& info) { static SkSurface* NewRenderTarget(GrContext* gr, SkBudgeted b, const SkImageInfo& info) {

View File

@ -443,58 +443,6 @@ struct GrMipLevel {
size_t fRowBytes; size_t fRowBytes;
}; };
/**
* An container of function pointers which consumers of Skia can fill in and
* pass to Skia. Skia will use these function pointers in place of its backend
* API texture creation function. Either all of the function pointers should be
* filled in, or they should all be nullptr.
*/
struct GrTextureStorageAllocator {
GrTextureStorageAllocator()
: fAllocateTextureStorage(nullptr)
, fDeallocateTextureStorage(nullptr) {
}
enum class Result {
kSucceededAndUploaded,
kSucceededWithoutUpload,
kFailed
};
typedef Result (*AllocateTextureStorageProc)(
void* ctx, GrBackendObject texture, unsigned width,
unsigned height, GrPixelConfig config, const void* srcData, GrSurfaceOrigin);
typedef void (*DeallocateTextureStorageProc)(void* ctx, GrBackendObject texture);
/*
* Generates and binds a texture to |textureStorageTarget()|. Allocates
* storage for the texture.
*
* In OpenGL, the MIN and MAX filters for the created texture must be
* GL_LINEAR. The WRAP_S and WRAP_T must be GL_CLAMP_TO_EDGE.
*
* If |srcData| is not nullptr, then the implementation of this function
* may attempt to upload the data into the texture. On successful upload,
* or if |srcData| is nullptr, returns kSucceededAndUploaded.
*/
AllocateTextureStorageProc fAllocateTextureStorage;
/*
* Deallocate the storage for the given texture.
*
* Skia does not always destroy its outstanding textures. See
* GrContext::abandonContext() for more details. The consumer of Skia is
* responsible for making sure that all textures are destroyed, even if this
* callback is not invoked.
*/
DeallocateTextureStorageProc fDeallocateTextureStorage;
/*
* The context to use when invoking fAllocateTextureStorage and
* fDeallocateTextureStorage.
*/
void* fCtx;
};
/** /**
* Describes a surface to be created. * Describes a surface to be created.
*/ */
@ -528,13 +476,6 @@ struct GrSurfaceDesc {
* max supported count. * max supported count.
*/ */
int fSampleCnt; int fSampleCnt;
/**
* A custom platform-specific allocator to use in place of the backend APIs
* usual texture creation method (e.g. TexImage2D in OpenGL).
*/
GrTextureStorageAllocator fTextureStorageAllocator;
bool fIsMipMapped; //!< Indicates if the texture has mipmaps bool fIsMipMapped; //!< Indicates if the texture has mipmaps
}; };

View File

@ -90,8 +90,7 @@ GrTexture::GrTexture(GrGpu* gpu, LifeCycle lifeCycle, const GrSurfaceDesc& desc,
GrSLType samplerType, bool wasMipMapDataProvided) GrSLType samplerType, bool wasMipMapDataProvided)
: INHERITED(gpu, lifeCycle, desc) : INHERITED(gpu, lifeCycle, desc)
, fSamplerType(samplerType) { , fSamplerType(samplerType) {
if (!this->isExternal() && !GrPixelConfigIsCompressed(desc.fConfig) && if (!this->isExternal() && !GrPixelConfigIsCompressed(desc.fConfig)) {
!desc.fTextureStorageAllocator.fAllocateTextureStorage) {
GrScratchKey key; GrScratchKey key;
GrTexturePriv::ComputeScratchKey(desc, &key); GrTexturePriv::ComputeScratchKey(desc, &key);
this->setScratchKey(key); this->setScratchKey(key);

View File

@ -50,8 +50,7 @@ GrTexture* GrTextureProvider::createMipMappedTexture(const GrSurfaceDesc& desc,
!fGpu->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { !fGpu->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
return nullptr; return nullptr;
} }
if (!GrPixelConfigIsCompressed(desc.fConfig) && if (!GrPixelConfigIsCompressed(desc.fConfig)) {
!desc.fTextureStorageAllocator.fAllocateTextureStorage) {
if (mipLevelCount < 2) { if (mipLevelCount < 2) {
static const uint32_t kFlags = kExact_ScratchTextureFlag | static const uint32_t kFlags = kExact_ScratchTextureFlag |
kNoCreate_ScratchTextureFlag; kNoCreate_ScratchTextureFlag;

View File

@ -144,15 +144,13 @@ SkGpuDevice* SkGpuDevice::Create(GrRenderTarget* rt, int width, int height,
SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkBudgeted budgeted, SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkBudgeted budgeted,
const SkImageInfo& info, int sampleCount, const SkImageInfo& info, int sampleCount,
const SkSurfaceProps* props, InitContents init, const SkSurfaceProps* props, InitContents init) {
GrTextureStorageAllocator customAllocator) {
unsigned flags; unsigned flags;
if (!CheckAlphaTypeAndGetFlags(&info, init, &flags)) { if (!CheckAlphaTypeAndGetFlags(&info, init, &flags)) {
return nullptr; return nullptr;
} }
SkAutoTUnref<GrRenderTarget> rt(CreateRenderTarget( SkAutoTUnref<GrRenderTarget> rt(CreateRenderTarget(context, budgeted, info, sampleCount));
context, budgeted, info, sampleCount, customAllocator));
if (nullptr == rt) { if (nullptr == rt) {
return nullptr; return nullptr;
} }
@ -179,9 +177,8 @@ SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height,
} }
} }
GrRenderTarget* SkGpuDevice::CreateRenderTarget( GrRenderTarget* SkGpuDevice::CreateRenderTarget(GrContext* context, SkBudgeted budgeted,
GrContext* context, SkBudgeted budgeted, const SkImageInfo& origInfo, const SkImageInfo& origInfo, int sampleCount) {
int sampleCount, GrTextureStorageAllocator textureStorageAllocator) {
if (kUnknown_SkColorType == origInfo.colorType() || if (kUnknown_SkColorType == origInfo.colorType() ||
origInfo.width() < 0 || origInfo.height() < 0) { origInfo.width() < 0 || origInfo.height() < 0) {
return nullptr; return nullptr;
@ -211,7 +208,6 @@ GrRenderTarget* SkGpuDevice::CreateRenderTarget(
desc.fHeight = info.height(); desc.fHeight = info.height();
desc.fConfig = SkImageInfo2GrPixelConfig(info, *context->caps()); desc.fConfig = SkImageInfo2GrPixelConfig(info, *context->caps());
desc.fSampleCnt = sampleCount; desc.fSampleCnt = sampleCount;
desc.fTextureStorageAllocator = textureStorageAllocator;
desc.fIsMipMapped = false; desc.fIsMipMapped = false;
GrTexture* texture = context->textureProvider()->createTexture(desc, budgeted, nullptr, 0); GrTexture* texture = context->textureProvider()->createTexture(desc, budgeted, nullptr, 0);
if (nullptr == texture) { if (nullptr == texture) {
@ -359,8 +355,7 @@ void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) {
SkBudgeted budgeted = fRenderTarget->resourcePriv().isBudgeted(); SkBudgeted budgeted = fRenderTarget->resourcePriv().isBudgeted();
SkAutoTUnref<GrRenderTarget> newRT(CreateRenderTarget( SkAutoTUnref<GrRenderTarget> newRT(CreateRenderTarget(
this->context(), budgeted, this->imageInfo(), fRenderTarget->desc().fSampleCnt, this->context(), budgeted, this->imageInfo(), fRenderTarget->desc().fSampleCnt));
fRenderTarget->desc().fTextureStorageAllocator));
if (nullptr == newRT) { if (nullptr == newRT) {
return; return;

View File

@ -52,8 +52,7 @@ public:
* the resource cache budget. On failure, returns nullptr. * the resource cache budget. On failure, returns nullptr.
*/ */
static SkGpuDevice* Create(GrContext*, SkBudgeted, const SkImageInfo&, static SkGpuDevice* Create(GrContext*, SkBudgeted, const SkImageInfo&,
int sampleCount, const SkSurfaceProps*, int sampleCount, const SkSurfaceProps*, InitContents);
InitContents, GrTextureStorageAllocator = GrTextureStorageAllocator());
~SkGpuDevice() override {} ~SkGpuDevice() override {}
@ -259,7 +258,7 @@ private:
bool drawDashLine(const SkPoint pts[2], const SkPaint& paint); bool drawDashLine(const SkPoint pts[2], const SkPaint& paint);
static GrRenderTarget* CreateRenderTarget(GrContext*, SkBudgeted, const SkImageInfo&, static GrRenderTarget* CreateRenderTarget(GrContext*, SkBudgeted, const SkImageInfo&,
int sampleCount, GrTextureStorageAllocator); int sampleCount);
void drawSpriteWithFilter(const SkDraw&, const SkBitmap&, int x, int y, void drawSpriteWithFilter(const SkDraw&, const SkBitmap&, int x, int y,
const SkPaint&) override; const SkPaint&) override;

View File

@ -75,7 +75,6 @@ static SkGrPixelRef* copy_to_new_texture_pixelref(GrTexture* texture, SkColorTyp
} }
desc.fFlags = kRenderTarget_GrSurfaceFlag; desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType, dstPT, *context->caps()); desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType, dstPT, *context->caps());
desc.fTextureStorageAllocator = texture->desc().fTextureStorageAllocator;
desc.fIsMipMapped = false; desc.fIsMipMapped = false;
GrTexture* dst = context->textureProvider()->createTexture(desc, SkBudgeted::kNo, nullptr, 0); GrTexture* dst = context->textureProvider()->createTexture(desc, SkBudgeted::kNo, nullptr, 0);

View File

@ -1342,8 +1342,7 @@ bool GrGLGpu::uploadTexData(const GrSurfaceDesc& desc,
bool succeeded = true; bool succeeded = true;
if (kNewTexture_UploadType == uploadType && if (kNewTexture_UploadType == uploadType &&
0 == left && 0 == top && 0 == left && 0 == top &&
desc.fWidth == width && desc.fHeight == height && desc.fWidth == width && desc.fHeight == height) {
!desc.fTextureStorageAllocator.fAllocateTextureStorage) {
succeeded = allocate_and_populate_uncompressed_texture(desc, *interface, caps, target, succeeded = allocate_and_populate_uncompressed_texture(desc, *interface, caps, target,
internalFormat, externalFormat, internalFormat, externalFormat,
externalType, texelsShallowCopy, externalType, texelsShallowCopy,
@ -1863,10 +1862,6 @@ int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) {
bool GrGLGpu::createTextureImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info, bool GrGLGpu::createTextureImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info,
bool renderTarget, GrGLTexture::TexParams* initialTexParams, bool renderTarget, GrGLTexture::TexParams* initialTexParams,
const SkTArray<GrMipLevel>& texels) { const SkTArray<GrMipLevel>& texels) {
if (desc.fTextureStorageAllocator.fAllocateTextureStorage) {
return this->createTextureExternalAllocatorImpl(desc, info, texels);
}
info->fID = 0; info->fID = 0;
info->fTarget = GR_GL_TEXTURE_2D; info->fTarget = GR_GL_TEXTURE_2D;
GL_CALL(GenTextures(1, &(info->fID))); GL_CALL(GenTextures(1, &(info->fID)));
@ -1897,39 +1892,6 @@ bool GrGLGpu::createTextureImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info
return true; return true;
} }
bool GrGLGpu::createTextureExternalAllocatorImpl(const GrSurfaceDesc& desc,
GrGLTextureInfo* info,
const SkTArray<GrMipLevel>& texels) {
// We do not make SkTArray available outside of Skia,
// and so we do not want to allow mipmaps to external
// allocators just yet.
SkASSERT(texels.count() < 2);
const void* pixels = nullptr;
if (!texels.empty()) {
pixels = texels.begin()->fPixels;
}
switch (desc.fTextureStorageAllocator.fAllocateTextureStorage(
desc.fTextureStorageAllocator.fCtx, reinterpret_cast<GrBackendObject>(info),
desc.fWidth, desc.fHeight, desc.fConfig, pixels, desc.fOrigin)) {
case GrTextureStorageAllocator::Result::kSucceededAndUploaded:
return true;
case GrTextureStorageAllocator::Result::kFailed:
return false;
case GrTextureStorageAllocator::Result::kSucceededWithoutUpload:
break;
}
if (!this->uploadTexData(desc, info->fTarget, kNewTexture_UploadType, 0, 0,
desc.fWidth, desc.fHeight,
desc.fConfig, texels)) {
desc.fTextureStorageAllocator.fDeallocateTextureStorage(
desc.fTextureStorageAllocator.fCtx, reinterpret_cast<GrBackendObject>(info));
return false;
}
return true;
}
GrStencilAttachment* GrGLGpu::createStencilAttachmentForRenderTarget(const GrRenderTarget* rt, GrStencilAttachment* GrGLGpu::createStencilAttachmentForRenderTarget(const GrRenderTarget* rt,
int width, int width,
int height) { int height) {

View File

@ -141,8 +141,7 @@ private:
// compatible stencil format, or negative if there is no compatible stencil format. // compatible stencil format, or negative if there is no compatible stencil format.
int getCompatibleStencilIndex(GrPixelConfig config); int getCompatibleStencilIndex(GrPixelConfig config);
// If |desc.fTextureStorageAllocator| exists, use that to create the
// texture. Otherwise, create the texture directly.
// Returns whether the texture is successfully created. On success, the // Returns whether the texture is successfully created. On success, the
// result is stored in |info|. // result is stored in |info|.
// The texture is populated with |texels|, if it exists. // The texture is populated with |texels|, if it exists.
@ -150,8 +149,6 @@ private:
bool createTextureImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info, bool createTextureImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info,
bool renderTarget, GrGLTexture::TexParams* initialTexParams, bool renderTarget, GrGLTexture::TexParams* initialTexParams,
const SkTArray<GrMipLevel>& texels); const SkTArray<GrMipLevel>& texels);
bool createTextureExternalAllocatorImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info,
const SkTArray<GrMipLevel>& texels);
void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) override; void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) override;

View File

@ -58,13 +58,7 @@ void GrGLTexture::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) {
void GrGLTexture::onRelease() { void GrGLTexture::onRelease() {
if (fInfo.fID) { if (fInfo.fID) {
if (GrGpuResource::kBorrowed_LifeCycle != fTextureIDLifecycle) { if (GrGpuResource::kBorrowed_LifeCycle != fTextureIDLifecycle) {
if (this->desc().fTextureStorageAllocator.fDeallocateTextureStorage) { GL_CALL(DeleteTextures(1, &fInfo.fID));
this->desc().fTextureStorageAllocator.fDeallocateTextureStorage(
this->desc().fTextureStorageAllocator.fCtx,
reinterpret_cast<GrBackendObject>(&fInfo));
} else {
GL_CALL(DeleteTextures(1, &fInfo.fID));
}
} }
fInfo.fID = 0; fInfo.fID = 0;
} }

View File

@ -227,7 +227,7 @@ sk_sp<SkSurface> SkSurface::MakeRenderTargetDirect(GrRenderTarget*, const SkSurf
} }
sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrContext*, SkBudgeted, const SkImageInfo&, int, sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrContext*, SkBudgeted, const SkImageInfo&, int,
const SkSurfaceProps*, GrTextureStorageAllocator) { const SkSurfaceProps*) {
return nullptr; return nullptr;
} }

View File

@ -146,11 +146,9 @@ sk_sp<SkSurface> SkSurface::MakeRenderTargetDirect(GrRenderTarget* target,
sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrContext* ctx, SkBudgeted budgeted, sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrContext* ctx, SkBudgeted budgeted,
const SkImageInfo& info, int sampleCount, const SkImageInfo& info, int sampleCount,
const SkSurfaceProps* props, const SkSurfaceProps* props) {
GrTextureStorageAllocator customAllocator) {
SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create( SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(
ctx, budgeted, info, sampleCount, props, SkGpuDevice::kClear_InitContents, ctx, budgeted, info, sampleCount, props, SkGpuDevice::kClear_InitContents));
customAllocator));
if (!device) { if (!device) {
return nullptr; return nullptr;
} }

View File

@ -1,111 +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 "gl/GLTestContext.h"
#include "GrContext.h"
#include "SkSurface_Gpu.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_GL_RENDERING_CONTEXTS(CustomTexture, reporter, ctxInfo) {
GrContext* context = ctxInfo.fGrContext;
sk_gpu_test::GLTestContext* glContext = ctxInfo.fGLContext;
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;
auto surface(SkSurface_Gpu::MakeRenderTarget(
context, SkBudgeted::kNo, SkImageInfo::MakeN32Premul(kWidth, kHeight), 0,
NULL, grAllocator));
REPORTER_ASSERT(reporter, surface);
GrGLuint id = allocator.m_mostRecentlyAllocatedStorage;
sk_sp<SkImage> image(surface->makeImageSnapshot());
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);
sk_sp<SkImage> image2(surface->makeImageSnapshot());
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_GL_RENDERING_CONTEXTS(CustomTextureFailure, reporter, ctxInfo) {
static const int kWidth = 13;
static const int kHeight = 13;
const GrGLInterface* gl = ctxInfo.fGLContext->gl();
TestStorageAllocator allocator;
allocator.m_allowAllocation = false;
allocator.m_gl = gl;
GrTextureStorageAllocator grAllocator;
grAllocator.fAllocateTextureStorage = &TestStorageAllocator::allocateTextureStorage;
grAllocator.fDeallocateTextureStorage= &TestStorageAllocator::deallocateTextureStorage;
grAllocator.fCtx = &allocator;
auto surface(SkSurface_Gpu::MakeRenderTarget(
ctxInfo.fGrContext, SkBudgeted::kNo, SkImageInfo::MakeN32Premul(kWidth, kHeight), 0,
NULL, grAllocator));
REPORTER_ASSERT(reporter, !surface);
}
#endif