本文整理汇总了C++中GrTexture::getUniqueKey方法的典型用法代码示例。如果您正苦于以下问题:C++ GrTexture::getUniqueKey方法的具体用法?C++ GrTexture::getUniqueKey怎么用?C++ GrTexture::getUniqueKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrTexture
的用法示例。
在下文中一共展示了GrTexture::getUniqueKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GrIsBitmapInCache
bool GrIsBitmapInCache(const GrContext* ctx,
const SkBitmap& bitmap,
const GrTextureParams* params) {
Stretch stretch;
get_stretch(ctx, bitmap.width(), bitmap.height(), params, &stretch);
// Handle the case where the bitmap is explicitly texture backed.
GrTexture* texture = bitmap.getTexture();
if (texture) {
if (Stretch::kNone_Type == stretch.fType) {
return true;
}
// No keys for volatile bitmaps.
if (bitmap.isVolatile()) {
return false;
}
const GrUniqueKey& key = texture->getUniqueKey();
if (!key.isValid()) {
return false;
}
GrUniqueKey stretchedKey;
make_stretched_key(key, stretch, &stretchedKey);
return ctx->textureProvider()->existsTextureWithUniqueKey(stretchedKey);
}
// We don't cache volatile bitmaps
if (bitmap.isVolatile()) {
return false;
}
GrUniqueKey key, stretchedKey;
make_bitmap_keys(bitmap, stretch, &key, &stretchedKey);
return ctx->textureProvider()->existsTextureWithUniqueKey(
(Stretch::kNone_Type == stretch.fType) ? key : stretchedKey);
}
示例2: GrRefCachedBitmapTexture
GrTexture* GrRefCachedBitmapTexture(GrContext* ctx,
const SkBitmap& bitmap,
const GrTextureParams* params) {
Stretch stretch;
get_stretch(ctx, bitmap.width(), bitmap.height(), params, &stretch);
GrTexture* result = bitmap.getTexture();
if (result) {
if (Stretch::kNone_Type == stretch.fType) {
return SkRef(result);
}
GrUniqueKey stretchedKey;
// Don't create a key for the resized version if the bmp is volatile.
if (!bitmap.isVolatile()) {
const GrUniqueKey& key = result->getUniqueKey();
if (key.isValid()) {
make_stretched_key(key, stretch, &stretchedKey);
GrTexture* stretched =
ctx->textureProvider()->findAndRefTextureByUniqueKey(stretchedKey);
if (stretched) {
return stretched;
}
}
}
return stretch_texture(result, stretch, bitmap.pixelRef(), stretchedKey);
}
GrUniqueKey key, resizedKey;
if (!bitmap.isVolatile()) {
// If the bitmap isn't changing try to find a cached copy first.
make_bitmap_keys(bitmap, stretch, &key, &resizedKey);
result = ctx->textureProvider()->findAndRefTextureByUniqueKey(
resizedKey.isValid() ? resizedKey : key);
if (result) {
return result;
}
}
result = create_bitmap_texture(ctx, bitmap, stretch, key, resizedKey);
if (result) {
return result;
}
SkErrorInternals::SetError( kInternalError_SkError,
"---- failed to create texture for cache [%d %d]\n",
bitmap.width(), bitmap.height());
return NULL;
}