Adding the notion of a volatile bitmap to SkBitmap.
Volatility is a hint that indicates that the contents of a bitmap
are ephemeral. SkGpuDevice will not preserve volatile bitmaps
in its texture cache, and will use textures from a pool of
keyless (recyclable) textures to avoid the performance hit of
texture allocation and release.
A subsequent change is required in webkit in order to take advantage
of this optimization. putImageData, and other methods that create
temporary bitmaps will have to mark their bitmaps as volatile.
before rendering them through skia.
git-svn-id: http://skia.googlecode.com/svn/trunk@1769 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index b9e7d47..4f2d7c4 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1459,19 +1459,22 @@
entry = ctx->lockKeylessTexture(desc);
}
} else {
- uint32_t p0, p1;
- p0 = bitmap.getGenerationID();
- p1 = bitmap.pixelRefOffset();
-
- GrTextureKey key(p0, p1, bitmap.width(), bitmap.height());
- entry = ctx->findAndLockTexture(&key, sampler);
-
+ if (!bitmap.isVolatile()) {
+ uint32_t p0, p1;
+ p0 = bitmap.getGenerationID();
+ p1 = bitmap.pixelRefOffset();
+ GrTextureKey key(p0, p1, bitmap.width(), bitmap.height());
+
+ entry = ctx->findAndLockTexture(&key, sampler);
+ if (NULL == entry)
+ entry = sk_gr_create_bitmap_texture(ctx, &key, sampler,
+ bitmap);
+ } else {
+ entry = sk_gr_create_bitmap_texture(ctx, NULL, sampler, bitmap);
+ }
if (NULL == entry) {
- entry = sk_gr_create_bitmap_texture(ctx, &key, sampler, bitmap);
- if (NULL == entry) {
- GrPrintf("---- failed to create texture for cache [%d %d]\n",
- bitmap.width(), bitmap.height());
- }
+ GrPrintf("---- failed to create texture for cache [%d %d]\n",
+ bitmap.width(), bitmap.height());
}
}