本文整理汇总了C++中GrTexture::resourcePriv方法的典型用法代码示例。如果您正苦于以下问题:C++ GrTexture::resourcePriv方法的具体用法?C++ GrTexture::resourcePriv怎么用?C++ GrTexture::resourcePriv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrTexture
的用法示例。
在下文中一共展示了GrTexture::resourcePriv方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createCachedMask
GrTexture* GrClipMaskManager::createCachedMask(int width, int height, const GrUniqueKey& key,
bool renderTarget) {
GrSurfaceDesc desc;
desc.fWidth = width;
desc.fHeight = height;
desc.fFlags = renderTarget ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags;
if (!renderTarget || fDrawTarget->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) {
desc.fConfig = kAlpha_8_GrPixelConfig;
} else {
desc.fConfig = kRGBA_8888_GrPixelConfig;
}
GrTexture* texture = fDrawTarget->cmmAccess().resourceProvider()->createApproxTexture(desc, 0);
if (!texture) {
return nullptr;
}
texture->resourcePriv().setUniqueKey(key);
return texture;
}
示例2: refCopy
GrTexture* GrTextureAdjuster::refCopy(const CopyParams& copyParams) {
GrTexture* texture = this->originalTexture();
GrContext* context = texture->getContext();
const SkIRect* contentArea = this->contentAreaOrNull();
GrUniqueKey key;
this->makeCopyKey(copyParams, &key);
if (key.isValid()) {
GrTexture* cachedCopy = context->textureProvider()->findAndRefTextureByUniqueKey(key);
if (cachedCopy) {
return cachedCopy;
}
}
GrTexture* copy = copy_on_gpu(texture, contentArea, copyParams);
if (copy) {
if (key.isValid()) {
copy->resourcePriv().setUniqueKey(key);
this->didCacheCopy(key);
}
}
return copy;
}
示例3: tryLockAsTexture
GrTexture* SkImageCacherator::tryLockAsTexture(GrContext* ctx, SkImageUsageType usage) {
#if SK_SUPPORT_GPU
const uint32_t uniqueID = fGenerator->uniqueID();
const SkImageInfo& info = this->info();
GrUniqueKey key;
GrMakeKeyFromImageID(&key, uniqueID, info.width(), info.height(), SkIPoint::Make(0, 0),
*ctx->caps(), usage);
GrTexture* tex = ctx->textureProvider()->findAndRefTextureByUniqueKey(key);
if (tex) {
return tex; // we got a cache hit!
}
tex = fGenerator->generateTexture(ctx, usage);
if (tex) {
tex->resourcePriv().setUniqueKey(key);
}
return tex;
#else
return nullptr;
#endif
}
示例4: createTexture
GrTexture* GrGpu::createTexture(const GrSurfaceDesc& desc, bool budgeted,
const void* srcData, size_t rowBytes) {
if (!this->caps()->isConfigTexturable(desc.fConfig)) {
return NULL;
}
bool isRT = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag);
if (isRT && !this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
return NULL;
}
GrTexture *tex = NULL;
if (GrPixelConfigIsCompressed(desc.fConfig)) {
// We shouldn't be rendering into this
SkASSERT((desc.fFlags & kRenderTarget_GrSurfaceFlag) == 0);
if (!this->caps()->npotTextureTileSupport() &&
(!SkIsPow2(desc.fWidth) || !SkIsPow2(desc.fHeight))) {
return NULL;
}
this->handleDirtyContext();
tex = this->onCreateCompressedTexture(desc, budgeted, srcData);
} else {
this->handleDirtyContext();
tex = this->onCreateTexture(desc, budgeted, srcData, rowBytes);
}
if (!this->caps()->reuseScratchTextures() && !isRT) {
tex->resourcePriv().removeScratchKey();
}
if (tex) {
fStats.incTextureCreates();
if (srcData) {
fStats.incTextureUploads();
}
}
return tex;
}
示例5: createTexture
GrTexture* GrGpu::createTexture(const GrSurfaceDesc& origDesc, bool budgeted,
const void* srcData, size_t rowBytes) {
GrSurfaceDesc desc = origDesc;
if (!this->caps()->isConfigTexturable(desc.fConfig)) {
return nullptr;
}
bool isRT = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag);
if (isRT && !this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
return nullptr;
}
// We currently do not support multisampled textures
if (!isRT && desc.fSampleCnt > 0) {
return nullptr;
}
GrTexture *tex = nullptr;
if (isRT) {
int maxRTSize = this->caps()->maxRenderTargetSize();
if (desc.fWidth > maxRTSize || desc.fHeight > maxRTSize) {
return nullptr;
}
} else {
int maxSize = this->caps()->maxTextureSize();
if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
return nullptr;
}
}
GrGpuResource::LifeCycle lifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle :
GrGpuResource::kUncached_LifeCycle;
desc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount());
// Attempt to catch un- or wrongly initialized sample counts;
SkASSERT(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64);
desc.fOrigin = resolve_origin(desc.fOrigin, isRT);
if (GrPixelConfigIsCompressed(desc.fConfig)) {
// We shouldn't be rendering into this
SkASSERT(!isRT);
SkASSERT(0 == desc.fSampleCnt);
if (!this->caps()->npotTextureTileSupport() &&
(!SkIsPow2(desc.fWidth) || !SkIsPow2(desc.fHeight))) {
return nullptr;
}
this->handleDirtyContext();
tex = this->onCreateCompressedTexture(desc, lifeCycle, srcData);
} else {
this->handleDirtyContext();
tex = this->onCreateTexture(desc, lifeCycle, srcData, rowBytes);
}
if (!this->caps()->reuseScratchTextures() && !isRT) {
tex->resourcePriv().removeScratchKey();
}
if (tex) {
fStats.incTextureCreates();
if (srcData) {
fStats.incTextureUploads();
}
}
return tex;
}