зеркало из https://github.com/mozilla/pjs.git
Bug 558934: Cache extended and none-extended surfaces separately. r=jrmuizel a=dholbert
This commit is contained in:
Родитель
4197e710ab
Коммит
434a530653
|
@ -585,13 +585,13 @@ _cairo_d2d_create_strokestyle_for_stroke_style(const cairo_stroke_style_t *style
|
|||
return strokeStyle;
|
||||
}
|
||||
|
||||
cairo_user_data_key_t bitmap_key;
|
||||
cairo_user_data_key_t bitmap_key_nonextend;
|
||||
cairo_user_data_key_t bitmap_key_extend;
|
||||
cairo_user_data_key_t bitmap_key_snapshot;
|
||||
|
||||
struct cached_bitmap {
|
||||
/** The cached bitmap */
|
||||
RefPtr<ID2D1Bitmap> bitmap;
|
||||
/** The cached bitmap was created with a transparent rectangle around it */
|
||||
bool isNoneExtended;
|
||||
/** The cached bitmap is dirty and needs its data refreshed */
|
||||
bool dirty;
|
||||
/** Order of snapshot detach/release bitmap called not guaranteed, single threaded refcount for now */
|
||||
|
@ -616,7 +616,7 @@ static void _d2d_release_bitmap(void *bitmap)
|
|||
*/
|
||||
static void _d2d_snapshot_detached(cairo_surface_t *surface)
|
||||
{
|
||||
cached_bitmap *existingBitmap = (cached_bitmap*)cairo_surface_get_user_data(surface, &bitmap_key);
|
||||
cached_bitmap *existingBitmap = (cached_bitmap*)cairo_surface_get_user_data(surface, &bitmap_key_snapshot);
|
||||
if (existingBitmap) {
|
||||
existingBitmap->dirty = true;
|
||||
}
|
||||
|
@ -760,10 +760,12 @@ _cairo_d2d_create_brush_for_pattern(cairo_d2d_surface_t *d2dsurf,
|
|||
cairo_surface_pattern_t *surfacePattern =
|
||||
(cairo_surface_pattern_t*)pattern;
|
||||
D2D1_EXTEND_MODE extendMode;
|
||||
bool nonExtended = false;
|
||||
|
||||
cairo_user_data_key_t *key = &bitmap_key_extend;
|
||||
|
||||
if (pattern->extend == CAIRO_EXTEND_NONE) {
|
||||
extendMode = D2D1_EXTEND_MODE_CLAMP;
|
||||
nonExtended = true;
|
||||
key = &bitmap_key_nonextend;
|
||||
/**
|
||||
* For image surfaces we create a slightly larger bitmap with
|
||||
* a transparent border around it for this case. Need to translate
|
||||
|
@ -862,19 +864,20 @@ _cairo_d2d_create_brush_for_pattern(cairo_d2d_surface_t *d2dsurf,
|
|||
}
|
||||
|
||||
cached_bitmap *cachebitmap = NULL;
|
||||
|
||||
if (!tiled) {
|
||||
cachebitmap =
|
||||
(cached_bitmap*)cairo_surface_get_user_data(
|
||||
surfacePattern->surface,
|
||||
&bitmap_key);
|
||||
key);
|
||||
}
|
||||
|
||||
if (cachebitmap && cachebitmap->isNoneExtended == nonExtended) {
|
||||
if (cachebitmap) {
|
||||
sourceBitmap = cachebitmap->bitmap;
|
||||
if (cachebitmap->dirty) {
|
||||
D2D1_RECT_U rect;
|
||||
/** No need to take tiling into account - tiled surfaces are never cached. */
|
||||
if (nonExtended) {
|
||||
if (pattern->extend == CAIRO_EXTEND_NONE) {
|
||||
rect = D2D1::RectU(1, 1, srcSurf->width + 1, srcSurf->height + 1);
|
||||
} else {
|
||||
rect = D2D1::RectU(0, 0, srcSurf->width, srcSurf->height);
|
||||
|
@ -887,7 +890,7 @@ _cairo_d2d_create_brush_for_pattern(cairo_d2d_surface_t *d2dsurf,
|
|||
cachebitmap->refs++;
|
||||
cachebitmap->dirty = false;
|
||||
cairo_surface_set_user_data(nullSurf,
|
||||
&bitmap_key,
|
||||
&bitmap_key_snapshot,
|
||||
cachebitmap,
|
||||
NULL);
|
||||
_cairo_surface_attach_snapshot(surfacePattern->surface,
|
||||
|
@ -896,7 +899,6 @@ _cairo_d2d_create_brush_for_pattern(cairo_d2d_surface_t *d2dsurf,
|
|||
}
|
||||
} else {
|
||||
cached_bitmap *cachebitmap = new cached_bitmap;
|
||||
cachebitmap->isNoneExtended = nonExtended;
|
||||
if (pattern->extend != CAIRO_EXTEND_NONE) {
|
||||
d2dsurf->rt->CreateBitmap(D2D1::SizeU(width, height),
|
||||
srcSurf->data + yoffset * srcSurf->stride + xoffset,
|
||||
|
@ -937,13 +939,13 @@ _cairo_d2d_create_brush_for_pattern(cairo_d2d_surface_t *d2dsurf,
|
|||
cachebitmap->bitmap = sourceBitmap;
|
||||
cachebitmap->refs = 2;
|
||||
cairo_surface_set_user_data(surfacePattern->surface,
|
||||
&bitmap_key,
|
||||
key,
|
||||
cachebitmap,
|
||||
_d2d_release_bitmap);
|
||||
cairo_surface_t *nullSurf =
|
||||
_cairo_null_surface_create(CAIRO_CONTENT_COLOR_ALPHA);
|
||||
cairo_surface_set_user_data(nullSurf,
|
||||
&bitmap_key,
|
||||
&bitmap_key_snapshot,
|
||||
cachebitmap,
|
||||
NULL);
|
||||
_cairo_surface_attach_snapshot(surfacePattern->surface,
|
||||
|
|
Загрузка…
Ссылка в новой задаче