| Index: ui/gfx/image/image_family.cc
|
| diff --git a/ui/gfx/image/image_family.cc b/ui/gfx/image/image_family.cc
|
| index af0c2bf3675b367d9c78c7a428f38d0ddd4d2f77..b9d28bddd9df387e8b7fbc99544379de6b95e79a 100644
|
| --- a/ui/gfx/image/image_family.cc
|
| +++ b/ui/gfx/image/image_family.cc
|
| @@ -117,8 +117,14 @@ gfx::Image ImageFamily::CreateExact(int width, int height) const {
|
| if (!image)
|
| return gfx::Image();
|
|
|
| - if (image->Width() == width && image->Height() == height)
|
| - return gfx::Image(*image);
|
| + if (image->Width() == width && image->Height() == height) {
|
| + // Make a copy at gfx::ImageSkia level, so that resulting image's ref count
|
| + // is not racy to |image|. Since this function can run on a different thread
|
| + // than the thread |image| created on, we should not touch the
|
| + // non-thread-safe ref count in gfx::Image here.
|
| + std::unique_ptr<gfx::ImageSkia> image_skia(image->CopyImageSkia());
|
| + return gfx::Image(*image_skia);
|
| + }
|
|
|
| SkBitmap bitmap = image->AsBitmap();
|
| SkBitmap resized_bitmap = skia::ImageOperations::Resize(
|
|
|