Use a struct for client GL texture handles

Review URL: https://codereview.chromium.org/1429863009
This commit is contained in:
bsalomon 2015-11-10 11:54:56 -08:00 committed by Commit bot
parent 6dfe9ac3aa
commit 091f60c2a0
12 changed files with 141 additions and 86 deletions

View File

@ -93,7 +93,7 @@ protected:
fRGBImage.reset(SkImage::NewRasterCopy(rgbBmp.info(), rgbColors, rgbBmp.rowBytes()));
}
void createYUVTextures(GrContext* context, GrBackendObject yuvIDs[3]) {
void createYUVTextures(GrContext* context, GrBackendObject yuvHandles[3]) {
const GrGpu* gpu = context->getGpu();
if (!gpu) {
return;
@ -101,15 +101,15 @@ protected:
for (int i = 0; i < 3; ++i) {
SkASSERT(fYUVBmps[i].width() == SkToInt(fYUVBmps[i].rowBytes()));
yuvIDs[i] = gpu->createTestingOnlyBackendTexture(fYUVBmps[i].getPixels(),
fYUVBmps[i].width(),
fYUVBmps[i].height(),
kAlpha_8_GrPixelConfig);
yuvHandles[i] = gpu->createTestingOnlyBackendTexture(fYUVBmps[i].getPixels(),
fYUVBmps[i].width(),
fYUVBmps[i].height(),
kAlpha_8_GrPixelConfig);
}
context->resetContext();
}
void deleteYUVTextures(GrContext* context, const GrBackendObject yuvIDs[3]) {
void deleteYUVTextures(GrContext* context, const GrBackendObject yuvHandles[3]) {
const GrGpu* gpu = context->getGpu();
if (!gpu) {
@ -117,7 +117,7 @@ protected:
}
for (int i = 0; i < 3; ++i) {
gpu->deleteTestingOnlyBackendTexture(yuvIDs[i]);
gpu->deleteTestingOnlyBackendTexture(yuvHandles[i]);
}
context->resetContext();
@ -131,8 +131,8 @@ protected:
return;
}
GrBackendObject yuvIDs[3];
this->createYUVTextures(context, yuvIDs);
GrBackendObject yuvHandles[3];
this->createYUVTextures(context, yuvHandles);
static const SkScalar kPad = 10.f;
@ -146,10 +146,10 @@ protected:
for (int space = kJPEG_SkYUVColorSpace; space <= kLastEnum_SkYUVColorSpace; ++space) {
images.push_back(SkImage::NewFromYUVTexturesCopy(context,
static_cast<SkYUVColorSpace>(space),
yuvIDs, sizes,
yuvHandles, sizes,
kTopLeft_GrSurfaceOrigin));
}
this->deleteYUVTextures(context, yuvIDs);
this->deleteYUVTextures(context, yuvHandles);
for (int i = 0; i < images.count(); ++ i) {
SkScalar y = (i + 1) * kPad + i * fYUVBmps[0].height();
SkScalar x = kPad;

View File

@ -18,6 +18,7 @@
'SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG',
'SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS',
'SK_SUPPORT_LEGACY_GRADIENT_DITHERING',
'SK_IGNORE_GL_TEXTURE_TARGET',
],
},
}

View File

@ -14,6 +14,7 @@
#
'skia_for_chromium_defines': [
'SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS',
'SK_IGNORE_GL_TEXTURE_TARGET',
],
},
}

View File

@ -58,4 +58,17 @@ typedef signed long int GrGLintptr;
typedef signed long int GrGLsizeiptr;
#endif
///////////////////////////////////////////////////////////////////////////////
/**
* Types for interacting with GL resources created externally to Skia. GrBackendObjects for GL
* textures are really const GrGLTexture*
*/
struct GrGLTextureInfo {
GrGLenum fTarget;
GrGLuint fID;
};
GR_STATIC_ASSERT(sizeof(GrBackendObject) >= sizeof(const GrGLTextureInfo*));
#endif

View File

@ -413,10 +413,16 @@ GrTexture* GrGLGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc,
if (!this->configToGLFormats(desc.fConfig, false, nullptr, nullptr, nullptr)) {
return nullptr;
}
if (0 == desc.fTextureHandle) {
#ifdef SK_IGNORE_GL_TEXTURE_TARGET
if (!desc.fTextureHandle) {
return nullptr;
}
#else
const GrGLTextureInfo* info = reinterpret_cast<const GrGLTextureInfo*>(desc.fTextureHandle);
if (!info || !info->fID) {
return nullptr;
}
#endif
int maxSize = this->caps()->maxTextureSize();
if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
@ -426,9 +432,13 @@ GrTexture* GrGLGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc,
GrGLTexture::IDDesc idDesc;
GrSurfaceDesc surfDesc;
idDesc.fTextureID = static_cast<GrGLuint>(desc.fTextureHandle);
#ifdef SK_IGNORE_GL_TEXTURE_TARGET
idDesc.fInfo.fID = static_cast<GrGLuint>(desc.fTextureHandle);
// We only support GL_TEXTURE_2D at the moment.
idDesc.fTarget = GR_GL_TEXTURE_2D;
idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D;
#else
idDesc.fInfo = *info;
#endif
switch (ownership) {
case kAdopt_GrWrapOwnership:
@ -460,7 +470,7 @@ GrTexture* GrGLGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc,
if (renderTarget) {
GrGLRenderTarget::IDDesc rtIDDesc;
if (!this->createRenderTargetObjects(surfDesc, GrGpuResource::kUncached_LifeCycle,
idDesc.fTextureID, idDesc.fTarget, &rtIDDesc)) {
idDesc.fInfo, &rtIDDesc)) {
return nullptr;
}
texture = new GrGLTextureRenderTarget(this, surfDesc, idDesc, rtIDDesc);
@ -893,8 +903,7 @@ static bool renderbuffer_storage_msaa(const GrGLContext& ctx,
bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc,
GrGpuResource::LifeCycle lifeCycle,
GrGLuint texID,
GrGLenum textureTarget,
const GrGLTextureInfo& texInfo,
GrGLRenderTarget::IDDesc* idDesc) {
idDesc->fMSColorRenderbufferID = 0;
idDesc->fRTFBOID = 0;
@ -971,13 +980,13 @@ bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc,
if (this->glCaps().usesImplicitMSAAResolve() && desc.fSampleCnt > 0) {
GL_CALL(FramebufferTexture2DMultisample(GR_GL_FRAMEBUFFER,
GR_GL_COLOR_ATTACHMENT0,
textureTarget,
texID, 0, desc.fSampleCnt));
texInfo.fTarget,
texInfo.fID, 0, desc.fSampleCnt));
} else {
GL_CALL(FramebufferTexture2D(GR_GL_FRAMEBUFFER,
GR_GL_COLOR_ATTACHMENT0,
textureTarget,
texID, 0));
texInfo.fTarget,
texInfo.fID, 0));
}
if ((desc.fFlags & kCheckAllocation_GrSurfaceFlag) ||
!this->glCaps().isConfigVerifiedColorAttachment(desc.fConfig)) {
@ -1027,21 +1036,21 @@ GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag);
GrGLTexture::IDDesc idDesc;
GL_CALL(GenTextures(1, &idDesc.fTextureID));
GL_CALL(GenTextures(1, &idDesc.fInfo.fID));
idDesc.fLifeCycle = lifeCycle;
// We only support GL_TEXTURE_2D at the moment.
idDesc.fTarget = GR_GL_TEXTURE_2D;
idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D;
if (!idDesc.fTextureID) {
if (!idDesc.fInfo.fID) {
return return_null_texture();
}
this->setScratchTextureUnit();
GL_CALL(BindTexture(idDesc.fTarget, idDesc.fTextureID));
GL_CALL(BindTexture(idDesc.fInfo.fTarget, idDesc.fInfo.fID));
if (renderTarget && this->glCaps().textureUsageSupport()) {
// provides a hint about how this texture will be used
GL_CALL(TexParameteri(idDesc.fTarget,
GL_CALL(TexParameteri(idDesc.fInfo.fTarget,
GR_GL_TEXTURE_USAGE,
GR_GL_FRAMEBUFFER_ATTACHMENT));
}
@ -1056,34 +1065,33 @@ GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
initialTexParams.fMagFilter = GR_GL_NEAREST;
initialTexParams.fWrapS = GR_GL_CLAMP_TO_EDGE;
initialTexParams.fWrapT = GR_GL_CLAMP_TO_EDGE;
GL_CALL(TexParameteri(idDesc.fTarget,
GL_CALL(TexParameteri(idDesc.fInfo.fTarget,
GR_GL_TEXTURE_MAG_FILTER,
initialTexParams.fMagFilter));
GL_CALL(TexParameteri(idDesc.fTarget,
GL_CALL(TexParameteri(idDesc.fInfo.fTarget,
GR_GL_TEXTURE_MIN_FILTER,
initialTexParams.fMinFilter));
GL_CALL(TexParameteri(idDesc.fTarget,
GL_CALL(TexParameteri(idDesc.fInfo.fTarget,
GR_GL_TEXTURE_WRAP_S,
initialTexParams.fWrapS));
GL_CALL(TexParameteri(idDesc.fTarget,
GL_CALL(TexParameteri(idDesc.fInfo.fTarget,
GR_GL_TEXTURE_WRAP_T,
initialTexParams.fWrapT));
if (!this->uploadTexData(desc, idDesc.fTarget, true, 0, 0,
if (!this->uploadTexData(desc, idDesc.fInfo.fTarget, true, 0, 0,
desc.fWidth, desc.fHeight,
desc.fConfig, srcData, rowBytes)) {
GL_CALL(DeleteTextures(1, &idDesc.fTextureID));
GL_CALL(DeleteTextures(1, &idDesc.fInfo.fID));
return return_null_texture();
}
GrGLTexture* tex;
if (renderTarget) {
// unbind the texture from the texture unit before binding it to the frame buffer
GL_CALL(BindTexture(idDesc.fTarget, 0));
GL_CALL(BindTexture(idDesc.fInfo.fTarget, 0));
GrGLRenderTarget::IDDesc rtIDDesc;
if (!this->createRenderTargetObjects(desc, lifeCycle, idDesc.fTextureID, idDesc.fTarget,
&rtIDDesc)) {
GL_CALL(DeleteTextures(1, &idDesc.fTextureID));
if (!this->createRenderTargetObjects(desc, lifeCycle, idDesc.fInfo, &rtIDDesc)) {
GL_CALL(DeleteTextures(1, &idDesc.fInfo.fID));
return return_null_texture();
}
tex = new GrGLTextureRenderTarget(this, desc, idDesc, rtIDDesc);
@ -1107,17 +1115,17 @@ GrTexture* GrGLGpu::onCreateCompressedTexture(const GrSurfaceDesc& desc,
}
GrGLTexture::IDDesc idDesc;
GL_CALL(GenTextures(1, &idDesc.fTextureID));
GL_CALL(GenTextures(1, &idDesc.fInfo.fID));
idDesc.fLifeCycle = lifeCycle;
// We only support GL_TEXTURE_2D at the moment.
idDesc.fTarget = GR_GL_TEXTURE_2D;
idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D;
if (!idDesc.fTextureID) {
if (!idDesc.fInfo.fID) {
return return_null_texture();
}
this->setScratchTextureUnit();
GL_CALL(BindTexture(idDesc.fTarget, idDesc.fTextureID));
GL_CALL(BindTexture(idDesc.fInfo.fTarget, idDesc.fInfo.fID));
// Some drivers like to know filter/wrap before seeing glTexImage2D. Some
// drivers have a bug where an FBO won't be complete if it includes a
@ -1129,21 +1137,21 @@ GrTexture* GrGLGpu::onCreateCompressedTexture(const GrSurfaceDesc& desc,
initialTexParams.fMagFilter = GR_GL_NEAREST;
initialTexParams.fWrapS = GR_GL_CLAMP_TO_EDGE;
initialTexParams.fWrapT = GR_GL_CLAMP_TO_EDGE;
GL_CALL(TexParameteri(idDesc.fTarget,
GL_CALL(TexParameteri(idDesc.fInfo.fTarget,
GR_GL_TEXTURE_MAG_FILTER,
initialTexParams.fMagFilter));
GL_CALL(TexParameteri(idDesc.fTarget,
GL_CALL(TexParameteri(idDesc.fInfo.fTarget,
GR_GL_TEXTURE_MIN_FILTER,
initialTexParams.fMinFilter));
GL_CALL(TexParameteri(idDesc.fTarget,
GL_CALL(TexParameteri(idDesc.fInfo.fTarget,
GR_GL_TEXTURE_WRAP_S,
initialTexParams.fWrapS));
GL_CALL(TexParameteri(idDesc.fTarget,
GL_CALL(TexParameteri(idDesc.fInfo.fTarget,
GR_GL_TEXTURE_WRAP_T,
initialTexParams.fWrapT));
if (!this->uploadCompressedTexData(desc, idDesc.fTarget, srcData)) {
GL_CALL(DeleteTextures(1, &idDesc.fTextureID));
if (!this->uploadCompressedTexData(desc, idDesc.fInfo.fTarget, srcData)) {
GL_CALL(DeleteTextures(1, &idDesc.fInfo.fID));
return return_null_texture();
}
@ -3220,16 +3228,17 @@ void GrGLGpu::xferBarrier(GrRenderTarget* rt, GrXferBarrierType type) {
}
GrBackendObject GrGLGpu::createTestingOnlyBackendTexture(void* pixels, int w, int h,
GrPixelConfig config) const {
GrGLuint texID;
GL_CALL(GenTextures(1, &texID));
GrPixelConfig config) const {
GrGLTextureInfo* info = new GrGLTextureInfo;
info->fTarget = GR_GL_TEXTURE_2D;
GL_CALL(GenTextures(1, &info->fID));
GL_CALL(ActiveTexture(GR_GL_TEXTURE0));
GL_CALL(PixelStorei(GR_GL_UNPACK_ALIGNMENT, 1));
GL_CALL(BindTexture(GR_GL_TEXTURE_2D, texID));
GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_MAG_FILTER, GR_GL_NEAREST));
GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_MIN_FILTER, GR_GL_NEAREST));
GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_WRAP_S, GR_GL_CLAMP_TO_EDGE));
GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_WRAP_T, GR_GL_CLAMP_TO_EDGE));
GL_CALL(BindTexture(info->fTarget, info->fID));
GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_MAG_FILTER, GR_GL_NEAREST));
GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_MIN_FILTER, GR_GL_NEAREST));
GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_WRAP_S, GR_GL_CLAMP_TO_EDGE));
GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_WRAP_T, GR_GL_CLAMP_TO_EDGE));
GrGLenum internalFormat = 0x0; // suppress warning
GrGLenum externalFormat = 0x0; // suppress warning
@ -3237,14 +3246,24 @@ GrBackendObject GrGLGpu::createTestingOnlyBackendTexture(void* pixels, int w, in
this->configToGLFormats(config, false, &internalFormat, &externalFormat, &externalType);
GL_CALL(TexImage2D(GR_GL_TEXTURE_2D, 0, internalFormat, w, h, 0, externalFormat,
GL_CALL(TexImage2D(info->fTarget, 0, internalFormat, w, h, 0, externalFormat,
externalType, pixels));
return texID;
#ifdef SK_IGNORE_GL_TEXTURE_TARGET
GrGLuint id = info->fID;
delete info;
return id;
#else
return reinterpret_cast<GrBackendObject>(info);
#endif
}
bool GrGLGpu::isTestingOnlyBackendTexture(GrBackendObject id) const {
#ifdef SK_IGNORE_GL_TEXTURE_TARGET
GrGLuint texID = (GrGLuint)id;
#else
GrGLuint texID = reinterpret_cast<const GrGLTextureInfo*>(id)->fID;
#endif
GrGLboolean result;
GL_CALL_RET(result, IsTexture(texID));
@ -3253,8 +3272,18 @@ bool GrGLGpu::isTestingOnlyBackendTexture(GrBackendObject id) const {
}
void GrGLGpu::deleteTestingOnlyBackendTexture(GrBackendObject id) const {
#ifdef SK_IGNORE_GL_TEXTURE_TARGET
GrGLuint texID = (GrGLuint)id;
#else
const GrGLTextureInfo* info = reinterpret_cast<const GrGLTextureInfo*>(id);
GrGLuint texID = info->fID;
#endif
GL_CALL(DeleteTextures(1, &texID));
#ifndef SK_IGNORE_GL_TEXTURE_TARGET
delete info;
#endif
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -304,8 +304,7 @@ private:
int width = -1, int height = -1);
bool createRenderTargetObjects(const GrSurfaceDesc&, GrGpuResource::LifeCycle lifeCycle,
GrGLenum textureTarget, GrGLuint texID,
GrGLRenderTarget::IDDesc*);
const GrGLTextureInfo& texInfo, GrGLRenderTarget::IDDesc*);
enum TempFBOTarget {
kSrc_TempFBOTarget,

View File

@ -27,31 +27,35 @@ GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc&
}
void GrGLTexture::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) {
SkASSERT(0 != idDesc.fTextureID);
SkASSERT(0 != idDesc.fInfo.fID);
fTexParams.invalidate();
fTexParamsTimestamp = GrGpu::kExpiredTimestamp;
fTarget = idDesc.fTarget;
fTextureID = idDesc.fTextureID;
fInfo = idDesc.fInfo;
fTextureIDLifecycle = idDesc.fLifeCycle;
}
void GrGLTexture::onRelease() {
if (fTextureID) {
if (fInfo.fID) {
if (GrGpuResource::kBorrowed_LifeCycle != fTextureIDLifecycle) {
GL_CALL(DeleteTextures(1, &fTextureID));
GL_CALL(DeleteTextures(1, &fInfo.fID));
}
fTextureID = 0;
fInfo.fID = 0;
}
INHERITED::onRelease();
}
void GrGLTexture::onAbandon() {
fTextureID = 0;
fInfo.fTarget = 0;
fInfo.fID = 0;
INHERITED::onAbandon();
}
GrBackendObject GrGLTexture::getTextureHandle() const {
#ifdef SK_IGNORE_GL_TEXTURE_TARGET
return static_cast<GrBackendObject>(this->textureID());
#else
return reinterpret_cast<GrBackendObject>(&fInfo);
#endif
}
void GrGLTexture::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump,

View File

@ -28,8 +28,7 @@ public:
};
struct IDDesc {
GrGLenum fTarget;
GrGLuint fTextureID;
GrGLTextureInfo fInfo;
GrGpuResource::LifeCycle fLifeCycle;
};
@ -51,9 +50,9 @@ public:
fTexParamsTimestamp = timestamp;
}
GrGLuint textureID() const { return fTextureID; }
GrGLuint textureID() const { return fInfo.fID; }
GrGLenum target() const { return fTarget; }
GrGLenum target() const { return fInfo.fTarget; }
protected:
// The public constructor registers this object with the cache. However, only the most derived
@ -72,8 +71,9 @@ protected:
private:
TexParams fTexParams;
GrGpu::ResetTimestamp fTexParamsTimestamp;
GrGLenum fTarget;
GrGLuint fTextureID;
// Holds the texture target and ID. A pointer to this may be shared to external clients for
// direct interaction with the GL object.
GrGLTextureInfo fInfo;
// We track this separately from GrGpuResource because this may be both a texture and a render
// target, and the texture may be wrapped while the render target is not.

View File

@ -1164,10 +1164,12 @@ static void test_no_dual_source_blending(skiatest::Reporter* reporter) {
return;
}
GrBackendObject backendTex =
ctx->getGpu()->createTestingOnlyBackendTexture(nullptr, 100, 100, kRGBA_8888_GrPixelConfig);
GrBackendTextureDesc fakeDesc;
fakeDesc.fConfig = kRGBA_8888_GrPixelConfig;
fakeDesc.fWidth = fakeDesc.fHeight = 100;
fakeDesc.fTextureHandle = 1;
fakeDesc.fTextureHandle = backendTex;
SkAutoTUnref<GrTexture> fakeTexture(ctx->textureProvider()->wrapBackendTexture(fakeDesc,
kBorrow_GrWrapOwnership));
GrXferProcessor::DstTexture fakeDstTexture;
@ -1213,6 +1215,7 @@ static void test_no_dual_source_blending(skiatest::Reporter* reporter) {
}
}
}
ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTex);
}
#endif

View File

@ -11,6 +11,7 @@
#include "GrContext.h"
#include "GrContextFactory.h"
#include "GrGpu.h"
#include "GrRenderTarget.h"
#include "GrTexture.h"
#include "GrSurfacePriv.h"
@ -44,13 +45,16 @@ DEF_GPUTEST(GrSurface, reporter, factory) {
REPORTER_ASSERT(reporter, tex1 == tex1->asTexture());
REPORTER_ASSERT(reporter, static_cast<GrSurface*>(tex1) == tex1->asTexture());
GrBackendObject backendTex = context->getGpu()->createTestingOnlyBackendTexture(
nullptr, 256, 256, kSkia8888_GrPixelConfig);
GrBackendTextureDesc backendDesc;
backendDesc.fConfig = kSkia8888_GrPixelConfig;
backendDesc.fFlags = kRenderTarget_GrBackendTextureFlag;
backendDesc.fWidth = 256;
backendDesc.fHeight = 256;
backendDesc.fSampleCnt = 0;
backendDesc.fTextureHandle = 5;
backendDesc.fTextureHandle = backendTex;
GrSurface* texRT2 = context->textureProvider()->wrapBackendTexture(
backendDesc, kBorrow_GrWrapOwnership);
REPORTER_ASSERT(reporter, texRT2 == texRT2->asRenderTarget());
@ -60,11 +64,12 @@ DEF_GPUTEST(GrSurface, reporter, factory) {
REPORTER_ASSERT(reporter, texRT2->asRenderTarget() ==
static_cast<GrSurface*>(texRT2->asTexture()));
REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT2->asRenderTarget()) ==
static_cast<GrSurface*>(texRT2->asTexture()));
static_cast<GrSurface*>(texRT2->asTexture()));
texRT1->unref();
texRT2->unref();
tex1->unref();
context->getGpu()->deleteTestingOnlyBackendTexture(backendTex);
}
}

View File

@ -183,12 +183,12 @@ static void test_wrapped_resources(skiatest::Reporter* reporter, GrContext* cont
return;
}
GrBackendObject texIDs[2];
GrBackendObject texHandles[2];
static const int kW = 100;
static const int kH = 100;
texIDs[0] = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kRGBA_8888_GrPixelConfig);
texIDs[1] = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kRGBA_8888_GrPixelConfig);
texHandles[0] = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kRGBA_8888_GrPixelConfig);
texHandles[1] = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kRGBA_8888_GrPixelConfig);
context->resetContext();
@ -197,11 +197,11 @@ static void test_wrapped_resources(skiatest::Reporter* reporter, GrContext* cont
desc.fWidth = kW;
desc.fHeight = kH;
desc.fTextureHandle = texIDs[0];
desc.fTextureHandle = texHandles[0];
SkAutoTUnref<GrTexture> borrowed(context->textureProvider()->wrapBackendTexture(
desc, kBorrow_GrWrapOwnership));
desc.fTextureHandle = texIDs[1];
desc.fTextureHandle = texHandles[1];
SkAutoTUnref<GrTexture> adopted(context->textureProvider()->wrapBackendTexture(
desc, kAdopt_GrWrapOwnership));
@ -215,13 +215,13 @@ static void test_wrapped_resources(skiatest::Reporter* reporter, GrContext* cont
context->flush();
bool borrowedIsAlive = gpu->isTestingOnlyBackendTexture(texIDs[0]);
bool adoptedIsAlive = gpu->isTestingOnlyBackendTexture(texIDs[1]);
bool borrowedIsAlive = gpu->isTestingOnlyBackendTexture(texHandles[0]);
bool adoptedIsAlive = gpu->isTestingOnlyBackendTexture(texHandles[1]);
REPORTER_ASSERT(reporter, borrowedIsAlive);
REPORTER_ASSERT(reporter, !adoptedIsAlive);
gpu->deleteTestingOnlyBackendTexture(texIDs[0]);
gpu->deleteTestingOnlyBackendTexture(texHandles[0]);
context->resetContext();
}

View File

@ -118,8 +118,8 @@ static void test_wrapped_texture_surface(skiatest::Reporter* reporter, GrContext
static const uint32_t kOrigColor = 0xFFAABBCC;
SkAutoTArray<uint32_t> pixels(kW * kH);
sk_memset32(pixels.get(), kOrigColor, kW * kH);
GrBackendObject texID = gpu->createTestingOnlyBackendTexture(pixels.get(), kW, kH,
kRGBA_8888_GrPixelConfig);
GrBackendObject texHandle = gpu->createTestingOnlyBackendTexture(pixels.get(), kW, kH,
kRGBA_8888_GrPixelConfig);
GrBackendTextureDesc wrappedDesc;
wrappedDesc.fConfig = kRGBA_8888_GrPixelConfig;
@ -128,7 +128,7 @@ static void test_wrapped_texture_surface(skiatest::Reporter* reporter, GrContext
wrappedDesc.fOrigin = kBottomLeft_GrSurfaceOrigin;
wrappedDesc.fSampleCnt = 0;
wrappedDesc.fFlags = kRenderTarget_GrBackendTextureFlag;
wrappedDesc.fTextureHandle = texID;
wrappedDesc.fTextureHandle = texHandle;
SkAutoTUnref<SkSurface> surface(SkSurface::NewWrappedRenderTarget(ctx, wrappedDesc, nullptr));
REPORTER_ASSERT(reporter, surface);